Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize size of BoundingBox #1045

Open
Project-PLATEAU-Admin opened this issue Feb 23, 2023 · 0 comments
Open

Optimize size of BoundingBox #1045

Project-PLATEAU-Admin opened this issue Feb 23, 2023 · 0 comments
Labels
question Further information is requested

Comments

@Project-PLATEAU-Admin
Copy link
Contributor

The latest (v1.22.0) Cesium for Unreal generates the same BoundingBoxes for all primitives in the glTF according to the
boundingVolume in tileset.json as below image.

CurrentBoundingBox
CurrentBoundingBox

We propose the change to calculate minimum size of BoundingBoxes for each primitive component as below image.

OurFixesBoundingBox
OurFixesBoundingBox

BoundingBoxes are calculated in the loadPrimitive function of CesiumGltfComponent.cpp. We changed this function to calculate min
and max by using the indicesView as bellow and it could generate the smallest BoundingBox for each primitive.

TRACE_CPUPROFILER_EVENT_SCOPE(Cesium::ComputeAABB)

const std::vector<double>& min = positionAccessor.min;
const std::vector<double>& max = positionAccessor.max;
glm::dvec3 minPosition{std::numeric_limits<double>::max()};
glm::dvec3 maxPosition{std::numeric_limits<double>::lowest()};
for (int32_t i = 0; i < indicesView.size(); ++i) {
   const uint32 index = indicesView[i];

   minPosition.x = glm::min<double>(minPosition.x, positionView[index].X);
   minPosition.y = glm::min<double>(minPosition.y, positionView[index].Y);
   minPosition.z = glm::min<double>(minPosition.z, positionView[index].Z);

   maxPosition.x = glm::max<double>(maxPosition.x, positionView[index].X);
   maxPosition.y = glm::max<double>(maxPosition.y, positionView[index].Y);
   maxPosition.z = glm::max<double>(maxPosition.z, positionView[index].Z);
}

#if ENGINE_MAJOR_VERSION >= 5

To make the above enable, we remove the following line in the loadPrimitiveGameThreadPart function.

pMesh->boundingVolume = boundingVolume;

Would you consider adopting the above for BoundingBox optimization?

@kring kring added research Explore an idea or prototype a concept and share the results question Further information is requested and removed research Explore an idea or prototype a concept and share the results labels Jul 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants