Add mjs_getParent to retrieve the parent body of an object.

PiperOrigin-RevId: 715794859
Change-Id: Ib9792787cdb966f579938dde3f94ebabca8ef1fc
This commit is contained in:
Alessio Quaglino
2025-01-15 07:41:45 -08:00
committed by Copybara-Service
parent 10c7207cea
commit 05d4c3d670
10 changed files with 116 additions and 0 deletions
+7
View File
@@ -347,6 +347,7 @@ class mjCBody : public mjCBody_, private mjsBody {
// set parent of this body
void SetParent(mjCBody* _body) { parent = _body; }
mjCBody* GetParent() const { return parent; }
private:
mjCBody(const mjCBody& other, mjCModel* _model); // copy constructor
@@ -411,6 +412,7 @@ class mjCFrame : public mjCFrame_, private mjsFrame {
void CopyFromSpec(void);
void PointToLocal(void);
void SetParent(mjCBody* _body) { body = _body; }
mjCBody* GetParent() const { return body; }
mjCFrame& operator+=(const mjCBody& other);
@@ -462,6 +464,7 @@ class mjCJoint : public mjCJoint_, private mjsJoint {
void CopyFromSpec(void);
void SetParent(mjCBody* _body) { body = _body; }
mjCBody* GetParent() const { return body; }
// used by mjXWriter and mjCModel
const std::vector<double>& get_userdata() const { return userdata_; }
@@ -543,6 +546,7 @@ class mjCGeom : public mjCGeom_, private mjsGeom {
bool IsVisual(void) const { return visual_; }
void SetNotVisual(void) { visual_ = false; }
void SetParent(mjCBody* _body) { body = _body; }
mjCBody* GetParent() const { return body; }
mjtGeom Type() const { return type; }
// Compute all coefs modeling the interaction with the surrounding fluid.
@@ -608,6 +612,7 @@ class mjCSite : public mjCSite_, private mjsSite {
// site's body
mjCBody* Body() const { return body; }
void SetParent(mjCBody* _body) { body = _body; }
mjCBody* GetParent() const { return body; }
// use strings from mjCBase rather than mjStrings from mjsSite
using mjCBase::name;
@@ -661,6 +666,7 @@ class mjCCamera : public mjCCamera_, private mjsCamera {
const std::vector<double>& get_userdata() const { return userdata_; }
void SetParent(mjCBody* _body) { body = _body; }
mjCBody* GetParent() const { return body; }
private:
void Compile(void); // compiler
@@ -701,6 +707,7 @@ class mjCLight : public mjCLight_, private mjsLight {
const std::string& get_targetbody() const { return targetbody_; }
void SetParent(mjCBody* _body) { body = _body; }
mjCBody* GetParent() const { return body; }
private:
void Compile(void); // compiler