Update contype and conaffinity if fusestatic is true. Fixes #1577.
PiperOrigin-RevId: 628073529 Change-Id: I2fe88736d12ec16d72bbd4dce5d349b930147b50
This commit is contained in:
committed by
Copybara-Service
parent
027c26a153
commit
d6553ed192
@@ -2955,6 +2955,15 @@ void mjCModel::FuseStatic(void) {
|
|||||||
sites.clear();
|
sites.clear();
|
||||||
FuseReindex(bodies[0]);
|
FuseReindex(bodies[0]);
|
||||||
|
|
||||||
|
// recompute parent contype, conaffinity, and margin
|
||||||
|
par->contype = par->conaffinity = 0;
|
||||||
|
par->margin = 0;
|
||||||
|
for (const auto& geom : geoms) {
|
||||||
|
par->contype |= geom->contype;
|
||||||
|
par->conaffinity |= geom->conaffinity;
|
||||||
|
par->margin = mju_max(par->margin, geom->margin);
|
||||||
|
}
|
||||||
|
|
||||||
//------------- delete body (without deleting children)
|
//------------- delete body (without deleting children)
|
||||||
|
|
||||||
// delete allocation
|
// delete allocation
|
||||||
|
|||||||
@@ -248,9 +248,9 @@ TEST_F(FuseStaticTest, FuseStaticEquivalent) {
|
|||||||
<worldbody>
|
<worldbody>
|
||||||
<body>
|
<body>
|
||||||
<joint axis="1 0 0"/>
|
<joint axis="1 0 0"/>
|
||||||
<geom size="0.5" pos="1 0 0"/>
|
<geom size="0.5" pos="1 0 0" contype="0" conaffinity="0"/>
|
||||||
<body>
|
<body>
|
||||||
<geom size="0.5" pos="0 1 0"/>
|
<geom size="0.5" pos="0 1 0" contype="1" conaffinity="1"/>
|
||||||
</body>
|
</body>
|
||||||
</body>
|
</body>
|
||||||
</worldbody>
|
</worldbody>
|
||||||
@@ -268,6 +268,11 @@ TEST_F(FuseStaticTest, FuseStaticEquivalent) {
|
|||||||
EXPECT_EQ(m_fuse->nbody, 2) << "Expecting a world body and one other body";
|
EXPECT_EQ(m_fuse->nbody, 2) << "Expecting a world body and one other body";
|
||||||
EXPECT_EQ(m_no_fuse->nbody, 3) << "Expecting a world body and two others";
|
EXPECT_EQ(m_no_fuse->nbody, 3) << "Expecting a world body and two others";
|
||||||
|
|
||||||
|
EXPECT_EQ(m_no_fuse->body_contype[2], 1);
|
||||||
|
EXPECT_EQ(m_no_fuse->body_conaffinity[2], 1);
|
||||||
|
EXPECT_EQ(m_fuse->body_contype[1], 1);
|
||||||
|
EXPECT_EQ(m_fuse->body_conaffinity[1], 1);
|
||||||
|
|
||||||
mjData* d_fuse = mj_makeData(m_fuse);
|
mjData* d_fuse = mj_makeData(m_fuse);
|
||||||
mjData* d_no_fuse = mj_makeData(m_no_fuse);
|
mjData* d_no_fuse = mj_makeData(m_no_fuse);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user