Add mjs_detachBody to C API.
PiperOrigin-RevId: 626947850 Change-Id: I7c897048098ecd4f2247725ef2d378dbd00ef4a0
This commit is contained in:
committed by
Copybara-Service
parent
34a61ae42f
commit
cc78db41f4
@@ -689,6 +689,7 @@ mjCBody& mjCBody::operator=(const mjCBody& other) {
|
||||
sites.clear();
|
||||
cameras.clear();
|
||||
lights.clear();
|
||||
id = other.id;
|
||||
|
||||
// add elements to lists
|
||||
*this += other;
|
||||
@@ -807,6 +808,20 @@ void mjCBody::CopyList(std::vector<T*>& dst, const std::vector<T*>& src,
|
||||
|
||||
|
||||
|
||||
// find and remove subtree
|
||||
mjCBody& mjCBody::operator-=(const mjCBody& subtree) {
|
||||
for (int i=0; i<bodies.size(); i++) {
|
||||
if (bodies[i] == &subtree) {
|
||||
bodies.erase(bodies.begin() + i);
|
||||
break;
|
||||
}
|
||||
*bodies[i] -= subtree;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void mjCBody::PointToLocal() {
|
||||
spec.element = static_cast<mjElement*>(this);
|
||||
spec.name = (mjString)&name;
|
||||
|
||||
Reference in New Issue
Block a user