Skip to content

Commit

Permalink
Improve glTF getSizeBytes generated code
Browse files Browse the repository at this point in the history
  • Loading branch information
azrogers committed Nov 7, 2024
1 parent ab08eba commit 03da4c4
Show file tree
Hide file tree
Showing 67 changed files with 304 additions and 356 deletions.
8 changes: 5 additions & 3 deletions CesiumGltf/generated/include/CesiumGltf/AccessorSparse.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ struct CESIUMGLTF_API AccessorSparse final

int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(this->count);
accum += this->indices.getSizeBytes();
accum += this->values.getSizeBytes();
accum += sizeof(AccessorSparse);
accum += this->indices.getSizeBytes() -
sizeof(CesiumGltf::AccessorSparseIndices);
accum +=
this->values.getSizeBytes() - sizeof(CesiumGltf::AccessorSparseValues);
return accum;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ struct CESIUMGLTF_API AccessorSparseIndices final

int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(this->bufferView);
accum += sizeof(this->byteOffset);
accum += sizeof(this->componentType);
accum += sizeof(AccessorSparseIndices);

return accum;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ struct CESIUMGLTF_API AccessorSparseValues final

int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(this->bufferView);
accum += sizeof(this->byteOffset);
accum += sizeof(AccessorSparseValues);

return accum;
}
};
Expand Down
19 changes: 6 additions & 13 deletions CesiumGltf/generated/include/CesiumGltf/AccessorSpec.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,20 +156,13 @@ struct CESIUMGLTF_API AccessorSpec : public CesiumGltf::NamedObject {

int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(this->bufferView);
accum += sizeof(this->byteOffset);
accum += sizeof(this->componentType);
accum += sizeof(this->normalized);
accum += sizeof(this->count);
accum += sizeof(this->type);
for (const double& value : this->max) {
accum += sizeof(value);
accum += sizeof(AccessorSpec);
accum += sizeof(double) * this->max.capacity();
accum += sizeof(double) * this->min.capacity();
if (this->sparse) {
accum +=
this->sparse->getSizeBytes() - sizeof(CesiumGltf::AccessorSparse);
}
for (const double& value : this->min) {
accum += sizeof(value);
}
accum += sizeof(this->sparse) +
(this->sparse.has_value() ? this->sparse->getSizeBytes() : 0);
return accum;
}

Expand Down
5 changes: 3 additions & 2 deletions CesiumGltf/generated/include/CesiumGltf/Animation.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ struct CESIUMGLTF_API Animation final : public CesiumGltf::NamedObject {

int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(Animation);
for (const CesiumGltf::AnimationChannel& value : this->channels) {
accum += value.getSizeBytes();
accum += value.getSizeBytes() - sizeof(CesiumGltf::AnimationChannel);
}
for (const CesiumGltf::AnimationSampler& value : this->samplers) {
accum += value.getSizeBytes();
accum += value.getSizeBytes() - sizeof(CesiumGltf::AnimationSampler);
}
return accum;
}
Expand Down
5 changes: 3 additions & 2 deletions CesiumGltf/generated/include/CesiumGltf/AnimationChannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ struct CESIUMGLTF_API AnimationChannel final

int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(this->sampler);
accum += this->target.getSizeBytes();
accum += sizeof(AnimationChannel);
accum += this->target.getSizeBytes() -
sizeof(CesiumGltf::AnimationChannelTarget);
return accum;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ struct CESIUMGLTF_API AnimationChannelTarget final

int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(this->node);
accum += sizeof(this->path);
accum += sizeof(AnimationChannelTarget);

return accum;
}
};
Expand Down
5 changes: 2 additions & 3 deletions CesiumGltf/generated/include/CesiumGltf/AnimationSampler.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ struct CESIUMGLTF_API AnimationSampler final

int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(this->input);
accum += sizeof(this->interpolation);
accum += sizeof(this->output);
accum += sizeof(AnimationSampler);

return accum;
}
};
Expand Down
16 changes: 10 additions & 6 deletions CesiumGltf/generated/include/CesiumGltf/Asset.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,17 @@ struct CESIUMGLTF_API Asset final : public CesiumUtility::ExtensibleObject {

int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(this->copyright) +
(this->copyright.has_value() ? this->copyright->size() : 0);
accum += sizeof(this->generator) +
(this->generator.has_value() ? this->generator->size() : 0);
accum += sizeof(Asset);
if (this->copyright) {
accum += this->copyright->size();
}
if (this->generator) {
accum += this->generator->size();
}
accum += this->version.size();
accum += sizeof(this->minVersion) +
(this->minVersion.has_value() ? this->minVersion->size() : 0);
if (this->minVersion) {
accum += this->minVersion->size();
}
return accum;
}
};
Expand Down
7 changes: 4 additions & 3 deletions CesiumGltf/generated/include/CesiumGltf/BufferSpec.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ struct CESIUMGLTF_API BufferSpec : public CesiumGltf::NamedObject {

int64_t getSizeBytes() const {
int64_t accum = 0;
accum +=
sizeof(this->uri) + (this->uri.has_value() ? this->uri->size() : 0);
accum += sizeof(this->byteLength);
accum += sizeof(BufferSpec);
if (this->uri) {
accum += this->uri->size();
}
return accum;
}

Expand Down
7 changes: 2 additions & 5 deletions CesiumGltf/generated/include/CesiumGltf/BufferView.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,8 @@ struct CESIUMGLTF_API BufferView final : public CesiumGltf::NamedObject {

int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(this->buffer);
accum += sizeof(this->byteOffset);
accum += sizeof(this->byteLength);
accum += sizeof(this->byteStride);
accum += sizeof(this->target);
accum += sizeof(BufferView);

return accum;
}
};
Expand Down
17 changes: 9 additions & 8 deletions CesiumGltf/generated/include/CesiumGltf/Camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,15 @@ struct CESIUMGLTF_API Camera final : public CesiumGltf::NamedObject {

int64_t getSizeBytes() const {
int64_t accum = 0;
accum +=
sizeof(this->orthographic) + (this->orthographic.has_value()
? this->orthographic->getSizeBytes()
: 0);
accum +=
sizeof(this->perspective) +
(this->perspective.has_value() ? this->perspective->getSizeBytes() : 0);
accum += sizeof(this->type);
accum += sizeof(Camera);
if (this->orthographic) {
accum += this->orthographic->getSizeBytes() -
sizeof(CesiumGltf::CameraOrthographic);
}
if (this->perspective) {
accum += this->perspective->getSizeBytes() -
sizeof(CesiumGltf::CameraPerspective);
}
return accum;
}
};
Expand Down
6 changes: 2 additions & 4 deletions CesiumGltf/generated/include/CesiumGltf/CameraOrthographic.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,8 @@ struct CESIUMGLTF_API CameraOrthographic final

int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(this->xmag);
accum += sizeof(this->ymag);
accum += sizeof(this->zfar);
accum += sizeof(this->znear);
accum += sizeof(CameraOrthographic);

return accum;
}
};
Expand Down
6 changes: 2 additions & 4 deletions CesiumGltf/generated/include/CesiumGltf/CameraPerspective.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,8 @@ struct CESIUMGLTF_API CameraPerspective final

int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(this->aspectRatio);
accum += sizeof(this->yfov);
accum += sizeof(this->zfar);
accum += sizeof(this->znear);
accum += sizeof(CameraPerspective);

return accum;
}
};
Expand Down
13 changes: 8 additions & 5 deletions CesiumGltf/generated/include/CesiumGltf/Class.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,16 @@ struct CESIUMGLTF_API Class final : public CesiumUtility::ExtensibleObject {

int64_t getSizeBytes() const {
int64_t accum = 0;
accum +=
sizeof(this->name) + (this->name.has_value() ? this->name->size() : 0);
accum += sizeof(this->description) +
(this->description.has_value() ? this->description->size() : 0);
accum += sizeof(Class);
if (this->name) {
accum += this->name->size();
}
if (this->description) {
accum += this->description->size();
}
for (auto& [k, v] : this->properties) {
accum += k.size();
accum += v.getSizeBytes();
accum += v.getSizeBytes() - sizeof(CesiumGltf::ClassProperty);
}
return accum;
}
Expand Down
41 changes: 13 additions & 28 deletions CesiumGltf/generated/include/CesiumGltf/ClassProperty.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,34 +190,19 @@ struct CESIUMGLTF_API ClassProperty final

int64_t getSizeBytes() const {
int64_t accum = 0;
accum +=
sizeof(this->name) + (this->name.has_value() ? this->name->size() : 0);
accum += sizeof(this->description) +
(this->description.has_value() ? this->description->size() : 0);
accum += sizeof(this->type);
accum += sizeof(this->componentType);
accum += sizeof(this->enumType) +
(this->enumType.has_value() ? this->enumType->size() : 0);
accum += sizeof(this->array);
accum += sizeof(this->count);
accum += sizeof(this->normalized);
accum += sizeof(this->offset) +
(this->offset.has_value() ? this->offset->getSizeBytes() : 0);
accum += sizeof(this->scale) +
(this->scale.has_value() ? this->scale->getSizeBytes() : 0);
accum += sizeof(this->max) +
(this->max.has_value() ? this->max->getSizeBytes() : 0);
accum += sizeof(this->min) +
(this->min.has_value() ? this->min->getSizeBytes() : 0);
accum += sizeof(this->required);
accum += sizeof(this->noData) +
(this->noData.has_value() ? this->noData->getSizeBytes() : 0);
accum += sizeof(this->defaultProperty) +
(this->defaultProperty.has_value()
? this->defaultProperty->getSizeBytes()
: 0);
accum += sizeof(this->semantic) +
(this->semantic.has_value() ? this->semantic->size() : 0);
accum += sizeof(ClassProperty);
if (this->name) {
accum += this->name->size();
}
if (this->description) {
accum += this->description->size();
}
if (this->enumType) {
accum += this->enumType->size();
}
if (this->semantic) {
accum += this->semantic->size();
}
return accum;
}
};
Expand Down
14 changes: 8 additions & 6 deletions CesiumGltf/generated/include/CesiumGltf/Enum.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,15 @@ struct CESIUMGLTF_API Enum final : public CesiumUtility::ExtensibleObject {

int64_t getSizeBytes() const {
int64_t accum = 0;
accum +=
sizeof(this->name) + (this->name.has_value() ? this->name->size() : 0);
accum += sizeof(this->description) +
(this->description.has_value() ? this->description->size() : 0);
accum += sizeof(this->valueType);
accum += sizeof(Enum);
if (this->name) {
accum += this->name->size();
}
if (this->description) {
accum += this->description->size();
}
for (const CesiumGltf::EnumValue& value : this->values) {
accum += value.getSizeBytes();
accum += value.getSizeBytes() - sizeof(CesiumGltf::EnumValue);
}
return accum;
}
Expand Down
7 changes: 4 additions & 3 deletions CesiumGltf/generated/include/CesiumGltf/EnumValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ struct CESIUMGLTF_API EnumValue final : public CesiumUtility::ExtensibleObject {

int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(EnumValue);
accum += this->name.size();
accum += sizeof(this->description) +
(this->description.has_value() ? this->description->size() : 0);
accum += sizeof(this->value);
if (this->description) {
accum += this->description->size();
}
return accum;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ struct CESIUMGLTF_API ExtensionBufferExtMeshoptCompression final

int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(this->fallback);
accum += sizeof(ExtensionBufferExtMeshoptCompression);

return accum;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,8 @@ struct CESIUMGLTF_API ExtensionBufferViewExtMeshoptCompression final

int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(this->buffer);
accum += sizeof(this->byteOffset);
accum += sizeof(this->byteLength);
accum += sizeof(this->byteStride);
accum += sizeof(this->count);
accum += sizeof(this->mode);
accum += sizeof(this->filter);
accum += sizeof(ExtensionBufferViewExtMeshoptCompression);

return accum;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ struct CESIUMGLTF_API ExtensionCesiumPrimitiveOutline final

int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(this->indices);
accum += sizeof(ExtensionCesiumPrimitiveOutline);

return accum;
}
};
Expand Down
5 changes: 2 additions & 3 deletions CesiumGltf/generated/include/CesiumGltf/ExtensionCesiumRTC.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ struct CESIUMGLTF_API ExtensionCesiumRTC final

int64_t getSizeBytes() const {
int64_t accum = 0;
for (const double& value : this->center) {
accum += sizeof(value);
}
accum += sizeof(ExtensionCesiumRTC);
accum += sizeof(double) * this->center.capacity();
return accum;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,8 @@ struct CESIUMGLTF_API ExtensionCesiumTileEdges final

int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(this->left);
accum += sizeof(this->bottom);
accum += sizeof(this->right);
accum += sizeof(this->top);
accum += sizeof(ExtensionCesiumTileEdges);

return accum;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ struct CESIUMGLTF_API ExtensionExtInstanceFeatures final

int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(ExtensionExtInstanceFeatures);
for (const CesiumGltf::ExtensionExtInstanceFeaturesFeatureId& value :
this->featureIds) {
accum += value.getSizeBytes();
accum += value.getSizeBytes() -
sizeof(CesiumGltf::ExtensionExtInstanceFeaturesFeatureId);
}
return accum;
}
Expand Down
Loading

0 comments on commit 03da4c4

Please sign in to comment.