mirror of
https://git.mirrors.martin98.com/https://github.com/syoyo/tinygltf.git
synced 2025-08-14 11:35:54 +08:00
Fix animation channel target node optionality
This commit is contained in:
parent
c2ca97b38b
commit
283b552a4e
20
tiny_gltf.h
20
tiny_gltf.h
@ -547,9 +547,10 @@ typedef std::map<std::string, Value> ExtensionMap;
|
|||||||
|
|
||||||
struct AnimationChannel {
|
struct AnimationChannel {
|
||||||
int sampler; // required
|
int sampler; // required
|
||||||
int target_node; // required (index of the node to target)
|
int target_node; // optional index of the node to target (alternative
|
||||||
std::string target_path; // required in ["translation", "rotation", "scale",
|
// target should be provided by extension)
|
||||||
// "weights"]
|
std::string target_path; // required with standard values of ["translation",
|
||||||
|
// "rotation", "scale", "weights"]
|
||||||
Value extras;
|
Value extras;
|
||||||
ExtensionMap extensions;
|
ExtensionMap extensions;
|
||||||
ExtensionMap target_extensions;
|
ExtensionMap target_extensions;
|
||||||
@ -5103,12 +5104,7 @@ static bool ParseAnimationChannel(
|
|||||||
if (FindMember(o, "target", targetIt) && IsObject(GetValue(targetIt))) {
|
if (FindMember(o, "target", targetIt) && IsObject(GetValue(targetIt))) {
|
||||||
const json &target_object = GetValue(targetIt);
|
const json &target_object = GetValue(targetIt);
|
||||||
|
|
||||||
if (!ParseIntegerProperty(&targetIndex, err, target_object, "node", true)) {
|
ParseIntegerProperty(&targetIndex, err, target_object, "node", false);
|
||||||
if (err) {
|
|
||||||
(*err) += "`node` field is missing in animation.channels.target\n";
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ParseStringProperty(&channel->target_path, err, target_object, "path",
|
if (!ParseStringProperty(&channel->target_path, err, target_object, "path",
|
||||||
true)) {
|
true)) {
|
||||||
@ -6968,7 +6964,11 @@ static void SerializeGltfAnimationChannel(const AnimationChannel &channel,
|
|||||||
SerializeNumberProperty("sampler", channel.sampler, o);
|
SerializeNumberProperty("sampler", channel.sampler, o);
|
||||||
{
|
{
|
||||||
json target;
|
json target;
|
||||||
SerializeNumberProperty("node", channel.target_node, target);
|
|
||||||
|
if (channel.target_node > 0) {
|
||||||
|
SerializeNumberProperty("node", channel.target_node, target);
|
||||||
|
}
|
||||||
|
|
||||||
SerializeStringProperty("path", channel.target_path, target);
|
SerializeStringProperty("path", channel.target_path, target);
|
||||||
|
|
||||||
SerializeExtensionMap(channel.target_extensions, target);
|
SerializeExtensionMap(channel.target_extensions, target);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user