Refactor Default class to use pointers instead of indices.
This in order to make it easier to append the default tree to another tree. PiperOrigin-RevId: 649812975 Change-Id: I2915ac7e37957e45eadc24d6caaf7beea236bf29
This commit is contained in:
committed by
Copybara-Service
parent
9d0812911c
commit
f57dc90669
@@ -807,8 +807,6 @@ mjCDef* mjCModel::FindDefault(string name) {
|
||||
|
||||
// add default class to array
|
||||
mjCDef* mjCModel::AddDefault(string name, mjCDef* parent) {
|
||||
int parentid = parent ? parent->id : 0;
|
||||
|
||||
// check for repeated name
|
||||
int thisid = (int)defaults_.size();
|
||||
for (int i=0; i<thisid; i++) {
|
||||
@@ -823,14 +821,14 @@ mjCDef* mjCModel::AddDefault(string name, mjCDef* parent) {
|
||||
def->id = thisid;
|
||||
|
||||
// initialize contents
|
||||
if (parentid>=0 && parentid<thisid) {
|
||||
defaults_[parentid]->CopyFromSpec();
|
||||
*def = *defaults_[parentid];
|
||||
defaults_[parentid]->childid.push_back(thisid);
|
||||
if (parent && parent->id<thisid) {
|
||||
parent->CopyFromSpec();
|
||||
*def = *parent;
|
||||
parent->child.push_back(def);
|
||||
}
|
||||
def->parentid = parentid;
|
||||
def->parent = parent;
|
||||
def->name = name;
|
||||
def->childid.clear();
|
||||
def->child.clear();
|
||||
|
||||
return def;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user