Compile frames during compilation instead of parsing.
PiperOrigin-RevId: 625717564 Change-Id: Ib82230f6cb423bb3091efd04a7fa0b1411e7cdf1
This commit is contained in:
committed by
Copybara-Service
parent
a4c31c09a8
commit
4a76496533
@@ -3118,7 +3118,7 @@ void mjCModel::TryCompile(mjModel*& m, mjData*& d, const mjVFS* vfs) {
|
|||||||
|
|
||||||
// compile objects in kinematic tree
|
// compile objects in kinematic tree
|
||||||
for (int i=0; i<bodies.size(); i++) {
|
for (int i=0; i<bodies.size(); i++) {
|
||||||
bodies[i]->Compile(); // also compiles joints, geoms, sites, cameras, lights
|
bodies[i]->Compile(); // also compiles joints, geoms, sites, cameras, lights, frames
|
||||||
}
|
}
|
||||||
|
|
||||||
// compile all other objects except for keyframes
|
// compile all other objects except for keyframes
|
||||||
|
|||||||
@@ -628,7 +628,6 @@ void mjCBase::SetFrame(mjCFrame* _frame) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
frame = _frame;
|
frame = _frame;
|
||||||
frame->Compile();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -735,10 +734,19 @@ mjCBody& mjCBody::operator+=(const mjCFrame& other) {
|
|||||||
other.model->prefix = other.prefix;
|
other.model->prefix = other.prefix;
|
||||||
other.model->suffix = other.suffix;
|
other.model->suffix = other.suffix;
|
||||||
|
|
||||||
// map old frames to indices
|
// copy input frame
|
||||||
|
frames.push_back(new mjCFrame(other));
|
||||||
|
frames.back()->body = this;
|
||||||
|
frames.back()->model = model;
|
||||||
|
frames.back()->frame = other.frame;
|
||||||
|
|
||||||
|
// map input frames to index in this->frames
|
||||||
std::map<mjCFrame*, int> fmap;
|
std::map<mjCFrame*, int> fmap;
|
||||||
for (int i=0; i<subtree->frames.size(); i++) {
|
for (auto frame : subtree->frames) {
|
||||||
fmap[subtree->frames[i]] = i;
|
if (frame == static_cast<const mjCFrame*>(&other)) {
|
||||||
|
fmap[frame] = frames.size() - 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy children that are inside the input frame
|
// copy children that are inside the input frame
|
||||||
@@ -1212,6 +1220,11 @@ void mjCBody::MakeInertialExplicit() {
|
|||||||
void mjCBody::Compile(void) {
|
void mjCBody::Compile(void) {
|
||||||
CopyFromSpec();
|
CopyFromSpec();
|
||||||
|
|
||||||
|
// compile all frames
|
||||||
|
for (int i=0; i<frames.size(); i++) {
|
||||||
|
frames[i]->Compile();
|
||||||
|
}
|
||||||
|
|
||||||
// resize userdata
|
// resize userdata
|
||||||
if (userdata_.size() > model->nuser_body) {
|
if (userdata_.size() > model->nuser_body) {
|
||||||
throw mjCError(this, "user has more values than nuser_body in body '%s' (id = %d)",
|
throw mjCError(this, "user has more values than nuser_body in body '%s' (id = %d)",
|
||||||
|
|||||||
Reference in New Issue
Block a user