Do not modify mesh position when fitting a geom to the mesh AABB.
Also, unify the meaning of fitting a geom to an AABB: it now means to find the smallest geom such that its AABB contains the mesh AABB. Fixes #2881. PiperOrigin-RevId: 817097544 Change-Id: I883c686feffa803bd16ba461db24a474dfec7712
This commit is contained in:
committed by
Copybara-Service
parent
3a299c49ca
commit
98682ae284
@@ -3732,22 +3732,26 @@ void mjCGeom::Compile(void) {
|
||||
|
||||
// save reference in case this is not an mjGEOM_MESH
|
||||
mjCMesh* pmesh = mesh;
|
||||
double center[3] = {0, 0, 0};
|
||||
|
||||
// fit geom if type is not mjGEOM_MESH
|
||||
if (type != mjGEOM_MESH && type != mjGEOM_SDF) {
|
||||
double meshpos[3];
|
||||
mesh->FitGeom(this, meshpos);
|
||||
mesh->FitGeom(this, center);
|
||||
|
||||
// remove reference to mesh
|
||||
meshname_.clear();
|
||||
mesh = nullptr;
|
||||
mjuu_copyvec(pmesh->GetPosPtr(), meshpos, 3);
|
||||
} else if (typeinertia == mjINERTIA_SHELL) {
|
||||
throw mjCError(this, "for mesh geoms, inertia should be specified in the mesh asset");
|
||||
}
|
||||
|
||||
// apply geom pos/quat as offset
|
||||
mjuu_frameaccum(pos, quat, pmesh->GetPosPtr(), pmesh->GetQuatPtr());
|
||||
// rotate center to geom frame and add it to mesh frame
|
||||
double meshpos[3];
|
||||
mjuu_rotVecQuat(meshpos, center, pmesh->GetQuatPtr());
|
||||
mjuu_addtovec(meshpos, pmesh->GetPosPtr(), 3);
|
||||
|
||||
// accumulate mesh frame into geom frame
|
||||
mjuu_frameaccum(pos, quat, meshpos, pmesh->GetQuatPtr());
|
||||
}
|
||||
|
||||
// check size parameters
|
||||
|
||||
Reference in New Issue
Block a user