Cache all processed mesh data.

PiperOrigin-RevId: 737576455
Change-Id: I87628ce7842d0d7d0e7fe02eb9afb2ddefa68ff8
This commit is contained in:
Kyle Bayes
2025-03-17 05:19:38 -07:00
committed by Copybara-Service
parent fa1b01360a
commit b10b0b7055
2 changed files with 167 additions and 129 deletions
+5 -6
View File
@@ -190,6 +190,11 @@ class mjCBoundingVolumeHierarchy : public mjCBoundingVolumeHierarchy_ {
int Nodeid(int id) const { return nodeid_[id]; }
const int* Nodeidptr(int id) const { return nodeidptr_[id]; }
const std::vector<int>& Level() const { return level_; }
int Size() const {
return sizeof(mjCBoundingVolume) * bvleaf_.size()
+ sizeof(mjtNum) * bvh_.size() + sizeof(int) * child_.size()
+ sizeof(int) * nodeid_.size() + sizeof(int) * level_.size();
}
private:
// internal class used during BVH construction, for partial sorting of bounding volumes
@@ -1078,12 +1083,6 @@ class mjCMesh: public mjCMesh_, private mjsMesh {
std::vector<double> polygon_normals_; // normals of the polygons
std::vector<std::vector<int>> polygon_map_; // map from vertex to polygon
// for caching purposes
std::vector<int> vertex_index_;
std::vector<int> normal_index_;
std::vector<int> texcoord_index_;
std::vector<face_vertices_type> num_face_vertices_;
// compute the volume and center-of-mass of the mesh given the face centroid
double ComputeVolume(double CoM[3], const double facecen[3]) const;
// compute the surface area and center-of-mass of the mesh given the face centroid