Skip to content

Commit 5b763ae

Browse files
committed
--more fixes
1 parent 8e740e5 commit 5b763ae

4 files changed

Lines changed: 19 additions & 19 deletions

File tree

src/esp/physics/bullet/BulletPhysicsManager.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ int BulletPhysicsManager::addArticulatedObjectInternal(
162162
}
163163

164164
// allocate ids for links
165-
ArticulatedLink& rootObject = articulatedObject->getLink(-1);
165+
ArticulatedLink& rootObject = articulatedObject->getLink(BASELINK_ID);
166166
rootObject.node().setBaseObjectId(articulatedObject->getObjectID());
167167
for (int linkIx = 0; linkIx < articulatedObject->btMultiBody_->getNumLinks();
168168
++linkIx) {
@@ -536,7 +536,7 @@ void BulletPhysicsManager::lookUpObjectIdAndLinkId(
536536
CORRADE_INTERNAL_ASSERT(objectId);
537537
CORRADE_INTERNAL_ASSERT(linkId);
538538

539-
*linkId = -1;
539+
*linkId = ID_UNDEFINED;
540540
// If the lookup fails, default to the stage. TODO: better error-handling.
541541
*objectId = RIGID_STAGE_ID;
542542
auto rawColObjIdIter = collisionObjToObjIds_->find(colObj);
@@ -572,10 +572,10 @@ std::vector<ContactPointData> BulletPhysicsManager::getContactPoints() const {
572572
const btPersistentManifold* manifold =
573573
dispatcher->getInternalManifoldPointer()[i];
574574

575-
int objectIdA = ID_UNDEFINED;
576-
int objectIdB = ID_UNDEFINED;
577-
int linkIndexA = -1; // -1 if not a multibody
578-
int linkIndexB = -1;
575+
int objectIdA = RIGID_STAGE_ID - 1;
576+
int objectIdB = RIGID_STAGE_ID - 1;
577+
int linkIndexA = ID_UNDEFINED; // -1 if not a multibody
578+
int linkIndexB = ID_UNDEFINED;
579579

580580
const btCollisionObject* colObj0 = manifold->getBody0();
581581
const btCollisionObject* colObj1 = manifold->getBody1();

src/esp/physics/bullet/BulletURDFImporter.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,9 @@ void BulletURDFImporter::getAllIndices(
194194
int mbIndex = cache->getMbIndexFromUrdfIndex(urdfLinkIndex);
195195
cp.m_mbIndex = mbIndex;
196196
cp.m_parentIndex = parentIndex;
197-
int parentMbIndex =
198-
parentIndex >= 0 ? cache->getMbIndexFromUrdfIndex(parentIndex) : -1;
197+
int parentMbIndex = parentIndex >= 0
198+
? cache->getMbIndexFromUrdfIndex(parentIndex)
199+
: BASELINK_ID;
199200
cp.m_parentMBIndex = parentMbIndex;
200201

201202
allIndices.emplace_back(std::move(cp));
@@ -255,9 +256,8 @@ void BulletURDFImporter::initURDFToBulletCache(
255256
cache->m_urdfLinkIndices2BulletLinkIndices.resize(
256257
numTotalLinksIncludingBase);
257258
cache->m_urdfLinkLocalInertialFrames.resize(numTotalLinksIncludingBase);
258-
259-
cache->m_currentMultiBodyLinkIndex =
260-
-1; // multi body base has 'link' index -1
259+
// multi body base has 'link' index BASELINK_ID
260+
cache->m_currentMultiBodyLinkIndex = BASELINK_ID;
261261

262262
bool maintainLinkOrder = (flags & CUF_MAINTAIN_LINK_ORDER) != 0;
263263
if (maintainLinkOrder) {
@@ -327,7 +327,7 @@ void BulletURDFImporter::convertURDFToBullet(
327327
parentTransforms[urdfLinkIndex] = parentTransformInWorldSpace;
328328
std::vector<childParentIndex> allIndices;
329329

330-
getAllIndices(urdfLinkIndex, -1, allIndices);
330+
getAllIndices(urdfLinkIndex, BASELINK_ID, allIndices);
331331
std::sort(allIndices.begin(), allIndices.end(),
332332
[](const childParentIndex& a, const childParentIndex& b) {
333333
return a.m_index < b.m_index;

src/esp/physics/bullet/BulletURDFImporter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ struct URDFToBulletCached {
5454
std::vector<int> m_urdfLinkIndices2BulletLinkIndices;
5555
std::vector<btTransform> m_urdfLinkLocalInertialFrames;
5656

57-
int m_currentMultiBodyLinkIndex{-1};
57+
int m_currentMultiBodyLinkIndex{BASELINK_ID};
5858

5959
class btMultiBody* m_bulletMultiBody{nullptr};
6060

src/esp/physics/objectWrappers/ManagedArticulatedObject.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ class ManagedArticulatedObject
4848
return 1.0;
4949
}
5050

51-
scene::SceneNode* getLinkSceneNode(int linkId = -1) const {
51+
scene::SceneNode* getLinkSceneNode(int linkId = BASELINK_ID) const {
5252
if (auto sp = getObjectReference()) {
5353
return &const_cast<scene::SceneNode&>(sp->getLinkSceneNode(linkId));
5454
}
5555
return nullptr;
5656
}
5757

5858
std::vector<scene::SceneNode*> getLinkVisualSceneNodes(
59-
int linkId = -1) const {
59+
int linkId = BASELINK_ID) const {
6060
if (auto sp = getObjectReference()) {
6161
return sp->getLinkVisualSceneNodes(linkId);
6262
}
@@ -73,7 +73,7 @@ class ManagedArticulatedObject
7373
if (auto sp = getObjectReference()) {
7474
return sp->getNumLinks();
7575
}
76-
return -1;
76+
return ID_UNDEFINED;
7777
}
7878

7979
std::vector<int> getLinkIds() const {
@@ -94,7 +94,7 @@ class ManagedArticulatedObject
9494
if (auto sp = getObjectReference()) {
9595
return sp->getLinkIdFromName(_name);
9696
}
97-
return -1;
97+
return ID_UNDEFINED;
9898
}
9999

100100
std::unordered_map<int, int> getLinkObjectIds() const {
@@ -237,7 +237,7 @@ class ManagedArticulatedObject
237237
if (auto sp = getObjectReference()) {
238238
return sp->getLinkDoFOffset(linkId);
239239
}
240-
return -1;
240+
return ID_UNDEFINED;
241241
}
242242

243243
int getLinkNumDoFs(int linkId) const {
@@ -251,7 +251,7 @@ class ManagedArticulatedObject
251251
if (auto sp = getObjectReference()) {
252252
return sp->getLinkJointPosOffset(linkId);
253253
}
254-
return -1;
254+
return ID_UNDEFINED;
255255
}
256256

257257
int getLinkNumJointPos(int linkId) const {

0 commit comments

Comments
 (0)