Move the map lookup outside of the mesh processing loop. Change to unordered_map.
PiperOrigin-RevId: 651745837 Change-Id: Ibfcbe4b8cefa53a3dbaa99c4ca68442e2e10bc5d
This commit is contained in:
committed by
Copybara-Service
parent
6e64dd10e8
commit
84108589c4
@@ -1365,6 +1365,8 @@ void mjCMesh::Process() {
|
||||
// find centroid of faces
|
||||
ComputeFaceCentroid(facecen);
|
||||
|
||||
double density = model->def_map[classname]->Geom().density;
|
||||
|
||||
// compute inertial properties for both inertia types
|
||||
for ( const auto type : { mjtGeomInertia::mjINERTIA_VOLUME, mjtGeomInertia::mjINERTIA_SHELL } ) {
|
||||
double CoM[3] = {0, 0, 0};
|
||||
@@ -1423,7 +1425,7 @@ void mjCMesh::Process() {
|
||||
// apply formula, accumulate
|
||||
GetVolumeRef(type) += vol;
|
||||
for (int j=0; j<6; j++) {
|
||||
P[j] += model->def_map[classname]->Geom().density*vol /
|
||||
P[j] += density*vol /
|
||||
(type==mjINERTIA_SHELL ? 12 : 20) * (
|
||||
2*(D[k[j][0]] * D[k[j][1]] +
|
||||
E[k[j][0]] * E[k[j][1]] +
|
||||
@@ -1464,7 +1466,7 @@ void mjCMesh::Process() {
|
||||
}
|
||||
|
||||
// compute sizes of equivalent inertia box
|
||||
double mass = GetVolumeRef(type) * model->def_map[classname]->Geom().density;
|
||||
double mass = GetVolumeRef(type) * density;
|
||||
double* boxsz = GetInertiaBoxPtr(type);
|
||||
boxsz[0] = sqrt(6*(eigval[1]+eigval[2]-eigval[0])/mass)/2;
|
||||
boxsz[1] = sqrt(6*(eigval[0]+eigval[2]-eigval[1])/mass)/2;
|
||||
|
||||
Reference in New Issue
Block a user