Open
Description
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.
We propose the change to calculate minimum size of BoundingBoxes for each primitive component as below image.
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?