Added bool, removed unused debug parameter

pull/3298/head
Evangel 2020-06-27 12:53:26 +10:00
parent d75d59a4fd
commit 6d85280c8d
3 changed files with 11 additions and 3 deletions

View File

@ -796,6 +796,7 @@ struct CustomExtension : public Object {
Nullable<double> mDoubleValue;
Nullable<uint64_t> mUint64Value;
Nullable<int64_t> mInt64Value;
Nullable<bool> mBoolValue;
// std::vector<CustomExtension> handles both Object and Array
Nullable<std::vector<CustomExtension>> mValues;
@ -807,7 +808,7 @@ struct CustomExtension : public Object {
size_t Size() const {
if (mValues.isPresent) {
return mValues.value.size();
} else if (mStringValue.isPresent || mDoubleValue.isPresent || mUint64Value.isPresent || mInt64Value.isPresent) {
} else if (mStringValue.isPresent || mDoubleValue.isPresent || mUint64Value.isPresent || mInt64Value.isPresent || mBoolValue.isPresent) {
return 1;
}
return 0;
@ -821,6 +822,7 @@ struct CustomExtension : public Object {
, mDoubleValue(other.mDoubleValue)
, mUint64Value(other.mUint64Value)
, mInt64Value(other.mInt64Value)
, mBoolValue(other.mBoolValue)
, mValues(other.mValues)
{
}

View File

@ -1241,6 +1241,10 @@ inline CustomExtension ReadExtensions(const char *name, Value& obj) {
ReadValue(obj, ret.mStringValue);
ret.mStringValue.isPresent = true;
}
else if (obj.IsBool()) {
ret.mBoolValue.value = obj.GetBool();
ret.mBoolValue.isPresent = true;
}
return ret;
}

View File

@ -847,7 +847,7 @@ static std::string GetNodeName(const Node &node) {
return node.name.empty() ? node.id : node.name;
}
void ParseExtensions(aiMetadata *metadata, const CustomExtension &extension, unsigned int depth = 0) {
void ParseExtensions(aiMetadata *metadata, const CustomExtension &extension) {
if (extension.mStringValue.isPresent) {
metadata->Add(extension.name.c_str(), aiString(extension.mStringValue.value));
} else if (extension.mDoubleValue.isPresent) {
@ -856,10 +856,12 @@ void ParseExtensions(aiMetadata *metadata, const CustomExtension &extension, uns
metadata->Add(extension.name.c_str(), extension.mUint64Value.value);
} else if (extension.mInt64Value.isPresent) {
metadata->Add(extension.name.c_str(), static_cast<int32_t>(extension.mInt64Value.value));
} else if (extension.mBoolValue.isPresent) {
metadata->Add(extension.name.c_str(), extension.mBoolValue.value);
} else if (extension.mValues.isPresent) {
aiMetadata val;
for (size_t i = 0; i < extension.mValues.value.size(); ++i) {
ParseExtensions(&val, extension.mValues.value[i], depth + 2);
ParseExtensions(&val, extension.mValues.value[i]);
}
metadata->Add(extension.name.c_str(), val);
}