Change from parent ID to parent pointer in mjCBody.

This is required to have parent body info during attach and during body to frame tranformation for uncompiled models.

PiperOrigin-RevId: 703038426
Change-Id: Ib482059ba419a020860c649d6ea1b1088045f2e1
This commit is contained in:
Alessio Quaglino
2024-12-05 02:31:54 -08:00
committed by Copybara-Service
parent 977fb913cf
commit 10239a673b
4 changed files with 58 additions and 34 deletions
+3 -2
View File
@@ -236,8 +236,9 @@ class mjCBase : public mjCBase_ {
class mjCBody_ : public mjCBase {
protected:
mjCBody* parent;
// variables computed by 'Compile' and 'AddXXX'
int parentid; // parent index in global array
int weldid; // top index of body we are welded to
int dofnum; // number of motion dofs for body
int mocapid; // mocap id, -1: not mocap
@@ -345,7 +346,7 @@ class mjCBody : public mjCBody_, private mjsBody {
mjsFrame* last_attached; // last attached frame to this body
// set parent of this body
void SetParent(const mjCBody* _body) { parentid = _body->id; }
void SetParent(mjCBody* _body) { parent = _body; }
private:
mjCBody(const mjCBody& other, mjCModel* _model); // copy constructor