677{
681
682 const std::string json_path = base_path + ".json";
683 const std::string exr_path = base_path + ".exr";
684
685 IO::JSONSerializer ser;
686 auto schema_opt = ser.read<State::FabricSchema>(json_path);
687 if (!schema_opt) {
688 m_last_error =
"Failed to load schema: " + ser.last_error();
690 return false;
691 }
692 const auto& schema = *schema_opt;
693
694 if (!version_supported(schema.version)) {
697 return false;
698 }
699
700 if (schema.entities.empty()) {
701 m_last_error =
"Schema contains no entities: " + json_path;
703 return false;
704 }
705
707 if (!pv_opt) {
709 return false;
710 }
711 const auto*
pixels = pv_opt->image.as_float();
712 const uint32_t
width = pv_opt->width;
713
714 std::vector<std::string> warnings;
715 note_older_version(schema.version, warnings);
716
717 for (size_t i = 0; i < schema.entities.size(); ++i) {
718 const auto& entry = schema.entities[i];
719
721 warnings.push_back("unknown kind '" + entry.kind + "' for id "
722 + std::to_string(entry.id) + ", skipping");
724 continue;
725 }
726
727 const Fields fields = read_fields(entry, *
pixels,
width, i, schema.ranges);
728 if (patch_entity(fabric, entry, fields, warnings)) {
730 } else {
731 warnings.push_back("id " + std::to_string(entry.id) + " not found as "
732 + entry.kind + ", skipping");
734 }
735 }
736
737 for (const auto& xrec : schema.expanses) {
738 restore_expanse(fabric, xrec, warnings);
739 }
740
741 log_warnings(warnings);
742
744 "StateDecoder: patched {} entities ({} missing) from {} + {}",
746
747 return true;
748}
#define MF_INFO(comp, ctx,...)
#define MF_ERROR(comp, ctx,...)
const std::vector< float > * pixels
@ FileIO
Filesystem I/O operations.
@ Nexus
Spatial indexing and scheduling for user-defined behaviour.
bool kind_known(std::string_view s)
Return true if s maps to a known Fabric::Kind token.
constexpr uint32_t k_exr_rows
RGBA32F EXR layout constants shared between encoder and decoder.