mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-04-21 10:58:44 +00:00
chore: use ordered_json for gltf
order is based on what blender does
7bea3666f8/addons/io_scene_gltf2/io/exp/export.py (L48)
This commit is contained in:
@@ -325,21 +325,21 @@ namespace gltf
|
|||||||
class JsonRoot
|
class JsonRoot
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::optional<std::vector<JsonAccessor>> accessors;
|
|
||||||
std::optional<std::vector<JsonAnimation>> animations;
|
|
||||||
JsonAsset asset;
|
JsonAsset asset;
|
||||||
std::optional<std::vector<JsonBuffer>> buffers;
|
|
||||||
std::optional<std::vector<JsonBufferView>> bufferViews;
|
|
||||||
std::optional<std::vector<JsonImage>> images;
|
|
||||||
std::optional<std::vector<JsonMaterial>> materials;
|
|
||||||
std::optional<std::vector<JsonMesh>> meshes;
|
|
||||||
std::optional<std::vector<JsonNode>> nodes;
|
|
||||||
std::optional<std::vector<JsonSkin>> skins;
|
|
||||||
std::optional<unsigned> scene;
|
std::optional<unsigned> scene;
|
||||||
std::optional<std::vector<JsonScene>> scenes;
|
std::optional<std::vector<JsonScene>> scenes;
|
||||||
|
std::optional<std::vector<JsonNode>> nodes;
|
||||||
|
std::optional<std::vector<JsonAnimation>> animations;
|
||||||
|
std::optional<std::vector<JsonMaterial>> materials;
|
||||||
|
std::optional<std::vector<JsonMesh>> meshes;
|
||||||
std::optional<std::vector<JsonTexture>> textures;
|
std::optional<std::vector<JsonTexture>> textures;
|
||||||
|
std::optional<std::vector<JsonImage>> images;
|
||||||
|
std::optional<std::vector<JsonSkin>> skins;
|
||||||
|
std::optional<std::vector<JsonAccessor>> accessors;
|
||||||
|
std::optional<std::vector<JsonBufferView>> bufferViews;
|
||||||
|
std::optional<std::vector<JsonBuffer>> buffers;
|
||||||
};
|
};
|
||||||
|
|
||||||
NLOHMANN_DEFINE_TYPE_EXTENSION(
|
NLOHMANN_DEFINE_TYPE_EXTENSION(
|
||||||
JsonRoot, accessors, animations, asset, buffers, bufferViews, images, materials, meshes, nodes, skins, scene, scenes, textures);
|
JsonRoot, asset, scene, scenes, nodes, animations, materials, meshes, textures, images, skins, accessors, bufferViews, buffers);
|
||||||
} // namespace gltf
|
} // namespace gltf
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ std::optional<std::string> BinOutput::CreateBufferUri(const void* buffer, size_t
|
|||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BinOutput::EmitJson(const nlohmann::json& json) const
|
void BinOutput::EmitJson(const nlohmann::ordered_json& json) const
|
||||||
{
|
{
|
||||||
static constexpr uint32_t ZERO = 0u;
|
static constexpr uint32_t ZERO = 0u;
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace gltf
|
|||||||
explicit BinOutput(std::ostream& stream);
|
explicit BinOutput(std::ostream& stream);
|
||||||
|
|
||||||
std::optional<std::string> CreateBufferUri(const void* buffer, size_t bufferSize) const override;
|
std::optional<std::string> CreateBufferUri(const void* buffer, size_t bufferSize) const override;
|
||||||
void EmitJson(const nlohmann::json& json) const override;
|
void EmitJson(const nlohmann::ordered_json& json) const override;
|
||||||
void EmitBuffer(const void* buffer, size_t bufferSize) const override;
|
void EmitBuffer(const void* buffer, size_t bufferSize) const override;
|
||||||
void Finalize() const override;
|
void Finalize() const override;
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ namespace gltf
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
virtual std::optional<std::string> CreateBufferUri(const void* buffer, size_t bufferSize) const = 0;
|
virtual std::optional<std::string> CreateBufferUri(const void* buffer, size_t bufferSize) const = 0;
|
||||||
virtual void EmitJson(const nlohmann::json& json) const = 0;
|
virtual void EmitJson(const nlohmann::ordered_json& json) const = 0;
|
||||||
virtual void EmitBuffer(const void* buffer, size_t bufferSize) const = 0;
|
virtual void EmitBuffer(const void* buffer, size_t bufferSize) const = 0;
|
||||||
virtual void Finalize() const = 0;
|
virtual void Finalize() const = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ std::optional<std::string> TextOutput::CreateBufferUri(const void* buffer, const
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextOutput::EmitJson(const nlohmann::json& json) const
|
void TextOutput::EmitJson(const nlohmann::ordered_json& json) const
|
||||||
{
|
{
|
||||||
m_stream << std::setw(4) << json;
|
m_stream << std::setw(4) << json;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace gltf
|
|||||||
explicit TextOutput(std::ostream& stream);
|
explicit TextOutput(std::ostream& stream);
|
||||||
|
|
||||||
std::optional<std::string> CreateBufferUri(const void* buffer, size_t bufferSize) const override;
|
std::optional<std::string> CreateBufferUri(const void* buffer, size_t bufferSize) const override;
|
||||||
void EmitJson(const nlohmann::json& json) const override;
|
void EmitJson(const nlohmann::ordered_json& json) const override;
|
||||||
void EmitBuffer(const void* buffer, size_t bufferSize) const override;
|
void EmitBuffer(const void* buffer, size_t bufferSize) const override;
|
||||||
void Finalize() const override;
|
void Finalize() const override;
|
||||||
|
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ namespace
|
|||||||
FillBufferData(gltf, xmodel, bufferData);
|
FillBufferData(gltf, xmodel, bufferData);
|
||||||
CreateBuffer(gltf, xmodel, bufferData);
|
CreateBuffer(gltf, xmodel, bufferData);
|
||||||
|
|
||||||
const json jRoot = gltf;
|
const ordered_json jRoot = gltf;
|
||||||
m_output->EmitJson(jRoot);
|
m_output->EmitJson(jRoot);
|
||||||
|
|
||||||
if (!bufferData.empty())
|
if (!bufferData.empty())
|
||||||
|
|||||||
Reference in New Issue
Block a user