Skip to content

Commit

Permalink
3rdparty: bullet3: remove getters/setters from btCollisionShape
Browse files Browse the repository at this point in the history
  • Loading branch information
dbartolini committed Jan 31, 2025
1 parent d00997f commit a9951a5
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@ btCollisionAlgorithm* btCollisionDispatcher::findAlgorithm(const btCollisionObje
btCollisionAlgorithm* algo = 0;
if (algoType == BT_CONTACT_POINT_ALGORITHMS)
{
algo = m_doubleDispatchContactPoints[body0Wrap->m_collisionShape->getShapeType()][body1Wrap->m_collisionShape->getShapeType()]->CreateCollisionAlgorithm(ci, body0Wrap, body1Wrap);
algo = m_doubleDispatchContactPoints[body0Wrap->m_collisionShape->m_shapeType][body1Wrap->m_collisionShape->m_shapeType]->CreateCollisionAlgorithm(ci, body0Wrap, body1Wrap);
}
else
{
algo = m_doubleDispatchClosestPoints[body0Wrap->m_collisionShape->getShapeType()][body1Wrap->m_collisionShape->getShapeType()]->CreateCollisionAlgorithm(ci, body0Wrap, body1Wrap);
algo = m_doubleDispatchClosestPoints[body0Wrap->m_collisionShape->m_shapeType][body1Wrap->m_collisionShape->m_shapeType]->CreateCollisionAlgorithm(ci, body0Wrap, body1Wrap);
}

return algo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void btCollisionWorld::refreshBroadphaseProxy(btCollisionObject* collisionObject
btVector3 maxAabb;
collisionObject->m_collisionShape->getAabb(trans, minAabb, maxAabb);

int type = collisionObject->m_collisionShape->getShapeType();
int type = collisionObject->m_collisionShape->m_shapeType;
collisionObject->m_broadphaseHandle = (getBroadphase()->createProxy(
minAabb,
maxAabb,
Expand Down Expand Up @@ -139,7 +139,7 @@ void btCollisionWorld::addCollisionObject(btCollisionObject* collisionObject, in
btVector3 maxAabb;
collisionObject->m_collisionShape->getAabb(trans, minAabb, maxAabb);

int type = collisionObject->m_collisionShape->getShapeType();
int type = collisionObject->m_collisionShape->m_shapeType;
collisionObject->m_broadphaseHandle = (getBroadphase()->createProxy(
minAabb,
maxAabb,
Expand Down Expand Up @@ -388,7 +388,7 @@ void btCollisionWorld::rayTestSingleInternal(const btTransform& rayFromTrans, co
btVector3 rayToLocal = worldTocollisionObject * rayToTrans.m_origin;

// BT_PROFILE("rayTestConcave");
if (collisionShape->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE)
if (collisionShape->m_shapeType == TRIANGLE_MESH_SHAPE_PROXYTYPE)
{
///optimized version for btBvhTriangleMeshShape
btBvhTriangleMeshShape* triangleMesh = (btBvhTriangleMeshShape*)collisionShape;
Expand All @@ -397,7 +397,7 @@ void btCollisionWorld::rayTestSingleInternal(const btTransform& rayFromTrans, co
rcb.m_hitFraction = resultCallback.m_closestHitFraction;
triangleMesh->performRaycast(&rcb, rayFromLocal, rayToLocal);
}
else if (collisionShape->getShapeType() == SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE)
else if (collisionShape->m_shapeType == SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE)
{
///optimized version for btScaledBvhTriangleMeshShape
btScaledBvhTriangleMeshShape* scaledTriangleMesh = (btScaledBvhTriangleMeshShape*)collisionShape;
Expand All @@ -414,7 +414,7 @@ void btCollisionWorld::rayTestSingleInternal(const btTransform& rayFromTrans, co
triangleMesh->performRaycast(&rcb, rayFromLocalScaled, rayToLocalScaled);
}
else if (((resultCallback.m_flags&btTriangleRaycastCallback::kF_DisableHeightfieldAccelerator)==0)
&& collisionShape->getShapeType() == TERRAIN_SHAPE_PROXYTYPE
&& collisionShape->m_shapeType == TERRAIN_SHAPE_PROXYTYPE
)
{
///optimized version for btHeightfieldTerrainShape
Expand Down Expand Up @@ -657,7 +657,7 @@ void btCollisionWorld::objectQuerySingleInternal(const btConvexShape* castShape,
{
if (collisionShape->isConcave())
{
if (collisionShape->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE)
if (collisionShape->m_shapeType == TRIANGLE_MESH_SHAPE_PROXYTYPE)
{
//BT_PROFILE("convexSweepbtBvhTriangleMesh");
btBvhTriangleMeshShape* triangleMesh = (btBvhTriangleMeshShape*)collisionShape;
Expand Down Expand Up @@ -712,7 +712,7 @@ void btCollisionWorld::objectQuerySingleInternal(const btConvexShape* castShape,
}
else
{
if (collisionShape->getShapeType() == STATIC_PLANE_PROXYTYPE)
if (collisionShape->m_shapeType == STATIC_PLANE_PROXYTYPE)
{
btConvexCast::CastResult castResult;
castResult.m_allowedPenetration = allowedPenetration;
Expand Down Expand Up @@ -1305,7 +1305,7 @@ void btCollisionWorld::debugDrawObject(const btTransform& worldTransform, const
getDebugDrawer()->drawTransform(worldTransform, .1);
}

if (shape->getShapeType() == COMPOUND_SHAPE_PROXYTYPE)
if (shape->m_shapeType == COMPOUND_SHAPE_PROXYTYPE)
{
const btCompoundShape* compoundShape = static_cast<const btCompoundShape*>(shape);
for (int i = compoundShape->getNumChildShapes() - 1; i >= 0; i--)
Expand All @@ -1317,7 +1317,7 @@ void btCollisionWorld::debugDrawObject(const btTransform& worldTransform, const
}
else
{
switch (shape->getShapeType())
switch (shape->m_shapeType)
{
case BOX_SHAPE_PROXYTYPE:
{
Expand Down Expand Up @@ -1449,7 +1449,7 @@ void btCollisionWorld::debugDrawObject(const btTransform& worldTransform, const
concaveMesh->processAllTriangles(&drawCallback, aabbMin, aabbMax);
}

if (shape->getShapeType() == CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE)
if (shape->m_shapeType == CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE)
{
btConvexTriangleMeshShape* convexMesh = (btConvexTriangleMeshShape*)shape;
//todo: pass camera for some culling
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ void btConvexConcaveCollisionAlgorithm::processCollision(const btCollisionObject

if (triBodyWrap->m_collisionShape->isConcave())
{
if (triBodyWrap->m_collisionShape->getShapeType() == SDF_SHAPE_PROXYTYPE)
if (triBodyWrap->m_collisionShape->m_shapeType == SDF_SHAPE_PROXYTYPE)
{
btSdfCollisionShape* sdfShape = (btSdfCollisionShape*)triBodyWrap->m_collisionShape;
if (convexBodyWrap->m_collisionShape->isConvex())
Expand All @@ -247,7 +247,7 @@ void btConvexConcaveCollisionAlgorithm::processCollision(const btCollisionObject
}
btScalar maxDist = SIMD_EPSILON;

if (convex->getShapeType() == SPHERE_SHAPE_PROXYTYPE)
if (convex->m_shapeType == SPHERE_SHAPE_PROXYTYPE)
{
queryVertices.push_back(btVector3(0, 0, 0));
btSphereShape* sphere = (btSphereShape*)convex;
Expand All @@ -274,7 +274,7 @@ void btConvexConcaveCollisionAlgorithm::processCollision(const btCollisionObject
normalLocal.safeNormalize();
btVector3 normal = triBodyWrap->m_worldTransform.m_basis * normalLocal;

if (convex->getShapeType() == SPHERE_SHAPE_PROXYTYPE)
if (convex->m_shapeType == SPHERE_SHAPE_PROXYTYPE)
{
btSphereShape* sphere = (btSphereShape*)convex;
dist -= sphere->getRadius();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ void btConvexConvexAlgorithm ::processCollision(const btCollisionObjectWrapper*
btVector3 normalOnB;
btVector3 pointOnBWorld;
#ifndef BT_DISABLE_CAPSULE_CAPSULE_COLLIDER
if ((min0->getShapeType() == CAPSULE_SHAPE_PROXYTYPE) && (min1->getShapeType() == CAPSULE_SHAPE_PROXYTYPE))
if ((min0->m_shapeType == CAPSULE_SHAPE_PROXYTYPE) && (min1->m_shapeType == CAPSULE_SHAPE_PROXYTYPE))
{
//m_manifoldPtr->clearManifold();

Expand All @@ -311,7 +311,7 @@ void btConvexConvexAlgorithm ::processCollision(const btCollisionObjectWrapper*
return;
}

if ((min0->getShapeType() == CAPSULE_SHAPE_PROXYTYPE) && (min1->getShapeType() == SPHERE_SHAPE_PROXYTYPE))
if ((min0->m_shapeType == CAPSULE_SHAPE_PROXYTYPE) && (min1->m_shapeType == SPHERE_SHAPE_PROXYTYPE))
{
//m_manifoldPtr->clearManifold();

Expand All @@ -333,7 +333,7 @@ void btConvexConvexAlgorithm ::processCollision(const btCollisionObjectWrapper*
return;
}

if ((min0->getShapeType() == SPHERE_SHAPE_PROXYTYPE) && (min1->getShapeType() == CAPSULE_SHAPE_PROXYTYPE))
if ((min0->m_shapeType == SPHERE_SHAPE_PROXYTYPE) && (min1->m_shapeType == CAPSULE_SHAPE_PROXYTYPE))
{
//m_manifoldPtr->clearManifold();

Expand Down Expand Up @@ -471,8 +471,8 @@ void btConvexConvexAlgorithm ::processCollision(const btCollisionObjectWrapper*

///btBoxShape is an exception: its vertices are created WITH margin so don't subtract it

btScalar min0Margin = min0->getShapeType() == BOX_SHAPE_PROXYTYPE ? 0.f : min0->getMargin();
btScalar min1Margin = min1->getShapeType() == BOX_SHAPE_PROXYTYPE ? 0.f : min1->getMargin();
btScalar min0Margin = min0->m_shapeType == BOX_SHAPE_PROXYTYPE ? 0.f : min0->getMargin();
btScalar min1Margin = min1->m_shapeType == BOX_SHAPE_PROXYTYPE ? 0.f : min1->getMargin();

btWithoutMarginResult withoutMargin(resultOut, min0Margin, min1Margin);

Expand Down Expand Up @@ -537,7 +537,7 @@ void btConvexConvexAlgorithm ::processCollision(const btCollisionObjectWrapper*
else
{
//we can also deal with convex versus triangle (without connectivity data)
if (dispatchInfo.m_enableSatConvex && polyhedronA->getConvexPolyhedron() && polyhedronB->getShapeType() == TRIANGLE_SHAPE_PROXYTYPE)
if (dispatchInfo.m_enableSatConvex && polyhedronA->getConvexPolyhedron() && polyhedronB->m_shapeType == TRIANGLE_SHAPE_PROXYTYPE)
{
btVertexArray worldSpaceVertices;
btTriangleShape* tri = (btTriangleShape*)polyhedronB;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,14 +485,14 @@ bool btClampNormal(const btVector3& edge, const btVector3& tri_normal_org, const
/// Changes a btManifoldPoint collision normal to the normal from the mesh.
void btAdjustInternalEdgeContacts(btManifoldPoint& cp, const btCollisionObjectWrapper* colObj0Wrap, const btCollisionObjectWrapper* colObj1Wrap, int partId0, int index0, int normalAdjustFlags)
{
//btAssert(colObj0->m_collisionShape->getShapeType() == TRIANGLE_SHAPE_PROXYTYPE);
if (colObj0Wrap->m_collisionShape->getShapeType() != TRIANGLE_SHAPE_PROXYTYPE)
//btAssert(colObj0->m_collisionShape->m_shapeType == TRIANGLE_SHAPE_PROXYTYPE);
if (colObj0Wrap->m_collisionShape->m_shapeType != TRIANGLE_SHAPE_PROXYTYPE)
return;


btTriangleInfoMap* triangleInfoMapPtr = 0;

if (colObj0Wrap->m_collisionObject->m_collisionShape->getShapeType() == TERRAIN_SHAPE_PROXYTYPE)
if (colObj0Wrap->m_collisionObject->m_collisionShape->m_shapeType == TERRAIN_SHAPE_PROXYTYPE)
{
btHeightfieldTerrainShape* heightfield = (btHeightfieldTerrainShape*)colObj0Wrap->m_collisionObject->m_collisionShape;
triangleInfoMapPtr = heightfield->getTriangleInfoMap();
Expand All @@ -517,13 +517,13 @@ void btAdjustInternalEdgeContacts(btManifoldPoint& cp, const btCollisionObjectWr

btBvhTriangleMeshShape* trimesh = 0;

if (colObj0Wrap->m_collisionObject->m_collisionShape->getShapeType() == SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE)
if (colObj0Wrap->m_collisionObject->m_collisionShape->m_shapeType == SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE)
{
trimesh = ((btScaledBvhTriangleMeshShape*)colObj0Wrap->m_collisionObject->m_collisionShape)->getChildShape();
}
else
{
if (colObj0Wrap->m_collisionObject->m_collisionShape->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE)
if (colObj0Wrap->m_collisionObject->m_collisionShape->m_shapeType == TRIANGLE_MESH_SHAPE_PROXYTYPE)
{
trimesh = (btBvhTriangleMeshShape*)colObj0Wrap->m_collisionObject->m_collisionShape;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class btSerializer;
ATTRIBUTE_ALIGNED16(class)
btCollisionShape
{
protected:
public:
int m_shapeType;
void* m_userPointer;
int m_userIndex;
Expand Down Expand Up @@ -59,40 +59,40 @@ btCollisionShape

SIMD_FORCE_INLINE bool isPolyhedral() const
{
return btBroadphaseProxy::isPolyhedral(getShapeType());
return btBroadphaseProxy::isPolyhedral(m_shapeType);
}

SIMD_FORCE_INLINE bool isConvex2d() const
{
return btBroadphaseProxy::isConvex2d(getShapeType());
return btBroadphaseProxy::isConvex2d(m_shapeType);
}

SIMD_FORCE_INLINE bool isConvex() const
{
return btBroadphaseProxy::isConvex(getShapeType());
return btBroadphaseProxy::isConvex(m_shapeType);
}
SIMD_FORCE_INLINE bool isNonMoving() const
{
return btBroadphaseProxy::isNonMoving(getShapeType());
return btBroadphaseProxy::isNonMoving(m_shapeType);
}
SIMD_FORCE_INLINE bool isConcave() const
{
return btBroadphaseProxy::isConcave(getShapeType());
return btBroadphaseProxy::isConcave(m_shapeType);
}
SIMD_FORCE_INLINE bool isCompound() const
{
return btBroadphaseProxy::isCompound(getShapeType());
return btBroadphaseProxy::isCompound(m_shapeType);
}

SIMD_FORCE_INLINE bool isSoftBody() const
{
return btBroadphaseProxy::isSoftBody(getShapeType());
return btBroadphaseProxy::isSoftBody(m_shapeType);
}

///isInfinite is used to catch simulation error (aabb check)
SIMD_FORCE_INLINE bool isInfinite() const
{
return btBroadphaseProxy::isInfinite(getShapeType());
return btBroadphaseProxy::isInfinite(m_shapeType);
}

#ifndef __SPU__
Expand All @@ -104,11 +104,6 @@ btCollisionShape
virtual const char* getName() const = 0;
#endif //__SPU__

int getShapeType() const
{
return m_shapeType;
}

///the getAnisotropicRollingFrictionDirection can be used in combination with setAnisotropicFriction
///See Bullet/Demos/RollingFrictionDemo for an example
virtual btVector3 getAnisotropicRollingFrictionDirection() const
Expand All @@ -118,36 +113,6 @@ btCollisionShape
virtual void setMargin(btScalar margin) = 0;
virtual btScalar getMargin() const = 0;

///optional user data pointer
void setUserPointer(void* userPtr)
{
m_userPointer = userPtr;
}

void* getUserPointer() const
{
return m_userPointer;
}
void setUserIndex(int index)
{
m_userIndex = index;
}

int getUserIndex() const
{
return m_userIndex;
}

void setUserIndex2(int index)
{
m_userIndex2 = index;
}

int getUserIndex2() const
{
return m_userIndex2;
}

virtual int calculateSerializeBufferSize() const;

///fills the dataBuffer and returns the struct name (and 0 on failure)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void btCompoundShape::addChildShape(const btTransform& localTransform, btCollisi
child.m_node = 0;
child.m_transform = localTransform;
child.m_childShape = shape;
child.m_childShapeType = shape->getShapeType();
child.m_childShapeType = shape->m_shapeType;
child.m_childMargin = shape->getMargin();

//extend the local aabbMin/aabbMax
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void btContinuousConvexCollision::computeClosestPoints(const btTransform& transA
if (m_convexB1)
{
m_simplexSolver->reset();
btGjkPairDetector gjk(m_convexA, m_convexB1, m_convexA->getShapeType(), m_convexB1->getShapeType(), m_convexA->getMargin(), m_convexB1->getMargin(), m_simplexSolver, m_penetrationDepthSolver);
btGjkPairDetector gjk(m_convexA, m_convexB1, m_convexA->m_shapeType, m_convexB1->m_shapeType, m_convexA->getMargin(), m_convexB1->getMargin(), m_simplexSolver, m_penetrationDepthSolver);
btGjkPairDetector::ClosestPointInput input;
input.m_transformA = transA;
input.m_transformB = transB;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ btGjkPairDetector::btGjkPairDetector(const btConvexShape *objectA, const btConve
m_simplexSolver(simplexSolver),
m_minkowskiA(objectA),
m_minkowskiB(objectB),
m_shapeTypeA(objectA->getShapeType()),
m_shapeTypeB(objectB->getShapeType()),
m_shapeTypeA(objectA->m_shapeType),
m_shapeTypeB(objectB->m_shapeType),
m_marginA(objectA->getMargin()),
m_marginB(objectB->getMargin()),
m_ignoreMargin(false),
Expand Down Expand Up @@ -949,8 +949,8 @@ void btGjkPairDetector::getClosestPointsNonVirtual(const ClosestPointInput &inpu
m_cachedSeparatingAxis.m_floats[1],
m_cachedSeparatingAxis.m_floats[2],
squaredDistance,
m_minkowskiA->getShapeType(),
m_minkowskiB->getShapeType());
m_minkowskiA->m_shapeType,
m_minkowskiB->m_shapeType);

#endif
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void btSoftBodyTriangleCallback::processTriangle(btVector3* triangle, int partId
btAssert(tm);

//copy over user pointers to temporary shape
tm->setUserPointer(m_triBody->m_collisionShape->getUserPointer());
tm->m_userPointer = (m_triBody->m_collisionShape->m_userPointer);

btCollisionObjectWrapper softBody(0, m_softBody->m_collisionShape, m_softBody, m_softBody->m_worldTransform, -1, -1);
//btCollisionObjectWrapper triBody(0,tm, ob, btTransform::getIdentity());//ob->m_worldTransform);//??
Expand Down Expand Up @@ -146,7 +146,7 @@ void btSoftBodyTriangleCallback::processTriangle(btVector3* triangle, int partId
// tm.setMargin(m_collisionMarginTriangle);

//copy over user pointers to temporary shape
tm->setUserPointer(m_triBody->m_collisionShape->getUserPointer());
tm->m_userPointer = (m_triBody->m_collisionShape->m_userPointer);

btCollisionObjectWrapper softBody(0, m_softBody->m_collisionShape, m_softBody, m_softBody->m_worldTransform, -1, -1);
btCollisionObjectWrapper triBody(0, tm, m_triBody, m_triBody->m_worldTransform, partId, triangleIndex); //btTransform::getIdentity());//??
Expand Down

0 comments on commit a9951a5

Please # to comment.