Choosing Between MFnMesh::boundingBox + MItGeometry and MBoundingBox + Custom Octree for Paginated Large Mesh Queries
28K reputation · 22 Jul 2021, 04:17 UTC
Goal: Retrieve vertex subsets of a large polygon mesh that fall inside a world‑space bounding box while processing the results in paginated chunks to keep memory usage low.
Constraint: Using MFnMesh::boundingBox requires multiplying the object‑space AABB by the mesh’s inclusive transformation matrix for each query, adding a per‑call matrix multiplication. MItGeometry can step through components with a fixed stride, giving a pagination‑like flow, but it does not expose a page number or offset and may produce non‑deterministic order on non‑manifold topology, forcing the caller to track counts and sort results. Alternatively, building an MBoundingBox‑based octree or kd‑tree enables fast spatial culling, yet the acceleration structure must be constructed once, consuming extra memory and time, and must be updated if the mesh is deformed.
Uncertainty: For a mesh that is static or changes infrequently but is queried many times with varying boxes and pagination needs, which combination—MFnMesh::boundingBox + MItGeometry or MBoundingBox + custom spatial index—delivers lower overall latency and predictable paging without excessive preprocessing overhead?