Skip to content

Commit

Permalink
3rdparty: bullet3: remove getters/setters from btTransform
Browse files Browse the repository at this point in the history
  • Loading branch information
dbartolini committed Jan 31, 2025
1 parent 4100142 commit 21c2254
Show file tree
Hide file tree
Showing 88 changed files with 733 additions and 755 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ struct btDbvtBenchmark
static btTransform RandTransform(btScalar cs)
{
btTransform t;
t.setOrigin(RandVector3(cs));
t.m_origin = (RandVector3(cs));
t.setRotation(btQuaternion(RandUnit() * SIMD_PI * 2, RandUnit() * SIMD_PI * 2, RandUnit() * SIMD_PI * 2).normalized());
return (t);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Copyright (c) 2003-2006 Erwin Coumans https://bulletphysics.org
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
Expand Down Expand Up @@ -38,18 +38,18 @@ void SphereTriangleDetector::getClosestPoints(const ClosestPointInput& input, Re
//move sphere into triangle space
btTransform sphereInTr = transformB.inverseTimes(transformA);

if (collide(sphereInTr.getOrigin(), point, normal, depth, timeOfImpact, m_contactBreakingThreshold))
if (collide(sphereInTr.m_origin, point, normal, depth, timeOfImpact, m_contactBreakingThreshold))
{
if (swapResults)
{
btVector3 normalOnB = transformB.getBasis() * normal;
btVector3 normalOnB = transformB.m_basis * normal;
btVector3 normalOnA = -normalOnB;
btVector3 pointOnA = transformB * point + normalOnB * depth;
output.addContactPoint(normalOnA, pointOnA, depth);
}
else
{
output.addContactPoint(transformB.getBasis() * normal, transformB * point, depth);
output.addContactPoint(transformB.m_basis * normal, transformB * point, depth);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Bullet Continuous Collision Detection and Physics Library
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
Expand Down Expand Up @@ -138,8 +138,8 @@ static btScalar EdgeSeparation(const btBox2dShape* poly1, const btTransform& xf1
btAssert(0 <= edge1 && edge1 < poly1->getVertexCount());

// Convert normal from poly1's frame into poly2's frame.
btVector3 normal1World = b2Mul(xf1.getBasis(), normals1[edge1]);
btVector3 normal1 = b2MulT(xf2.getBasis(), normal1World);
btVector3 normal1World = b2Mul(xf1.m_basis, normals1[edge1]);
btVector3 normal1 = b2MulT(xf2.m_basis, normal1World);

// Find support vertex on poly2 for -normal.
int index = 0;
Expand All @@ -164,7 +164,7 @@ static btScalar FindMaxSeparation(int* edgeIndex,

// Vector pointing from the centroid of poly1 to the centroid of poly2.
btVector3 d = b2Mul(xf2, poly2->getCentroid()) - b2Mul(xf1, poly1->getCentroid());
btVector3 dLocal1 = b2MulT(xf1.getBasis(), d);
btVector3 dLocal1 = b2MulT(xf1.m_basis, d);

// Find edge normal on poly1 that has the largest projection onto d.
int edge = 0;
Expand Down Expand Up @@ -259,7 +259,7 @@ static void FindIncidentEdge(ClipVertex c[2],
btAssert(0 <= edge1 && edge1 < poly1->getVertexCount());

// Get the normal of the reference edge in poly2's frame.
btVector3 normal1 = b2MulT(xf2.getBasis(), b2Mul(xf1.getBasis(), normals1[edge1]));
btVector3 normal1 = b2MulT(xf2.m_basis, b2Mul(xf1.m_basis, normals1[edge1]));

// Find the incident edge on poly2.
int index = 0;
Expand Down Expand Up @@ -348,7 +348,7 @@ void b2CollidePolygons(btManifoldResult* manifold,
btVector3 v12 = edge1 + 1 < count1 ? vertices1[edge1 + 1] : vertices1[0];

//btVector3 dv = v12 - v11;
btVector3 sideNormal = b2Mul(xf1.getBasis(), v12 - v11);
btVector3 sideNormal = b2Mul(xf1.m_basis, v12 - v11);
sideNormal.normalize();
btVector3 frontNormal = btCrossS(sideNormal, 1.0f);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
Expand Down Expand Up @@ -740,25 +740,25 @@ void btBoxBoxDetector::getClosestPoints(const ClosestPointInput& input, Result&

for (int j = 0; j < 3; j++)
{
R1[0 + 4 * j] = transformA.getBasis()[j].x();
R2[0 + 4 * j] = transformB.getBasis()[j].x();
R1[0 + 4 * j] = transformA.m_basis[j].x();
R2[0 + 4 * j] = transformB.m_basis[j].x();

R1[1 + 4 * j] = transformA.getBasis()[j].y();
R2[1 + 4 * j] = transformB.getBasis()[j].y();
R1[1 + 4 * j] = transformA.m_basis[j].y();
R2[1 + 4 * j] = transformB.m_basis[j].y();

R1[2 + 4 * j] = transformA.getBasis()[j].z();
R2[2 + 4 * j] = transformB.getBasis()[j].z();
R1[2 + 4 * j] = transformA.m_basis[j].z();
R2[2 + 4 * j] = transformB.m_basis[j].z();
}

btVector3 normal;
btScalar depth;
int return_code;
int maxc = 4;

dBoxBox2(transformA.getOrigin(),
dBoxBox2(transformA.m_origin,
R1,
2.f * m_box1->getHalfExtentsWithMargin(),
transformB.getOrigin(),
transformB.m_origin,
R2,
2.f * m_box2->getHalfExtentsWithMargin(),
normal, &depth, &return_code,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,10 @@ void btCollisionWorld::rayTestSingleInternal(const btTransform& rayFromTrans, co
{
if (castResult.m_fraction < resultCallback.m_closestHitFraction)
{
//todo: figure out what this is about. When is rayFromTest.getBasis() not identity?
//todo: figure out what this is about. When is rayFromTest.m_basis not identity?
#ifdef USE_SUBSIMPLEX_CONVEX_CAST
//rotate normal into worldspace
castResult.m_normal = rayFromTrans.getBasis() * castResult.m_normal;
castResult.m_normal = rayFromTrans.m_basis * castResult.m_normal;
#endif //USE_SUBSIMPLEX_CONVEX_CAST

castResult.m_normal.normalize();
Expand Down Expand Up @@ -371,7 +371,7 @@ void btCollisionWorld::rayTestSingleInternal(const btTransform& rayFromTrans, co
shapeInfo.m_shapePart = partId;
shapeInfo.m_triangleIndex = triangleIndex;

btVector3 hitNormalWorld = m_colObjWorldTransform.getBasis() * hitNormalLocal;
btVector3 hitNormalWorld = m_colObjWorldTransform.m_basis * hitNormalLocal;

btCollisionWorld::LocalRayResult rayResult(m_collisionObject,
&shapeInfo,
Expand All @@ -384,8 +384,8 @@ void btCollisionWorld::rayTestSingleInternal(const btTransform& rayFromTrans, co
};

btTransform worldTocollisionObject = colObjWorldTransform.inverse();
btVector3 rayFromLocal = worldTocollisionObject * rayFromTrans.getOrigin();
btVector3 rayToLocal = worldTocollisionObject * rayToTrans.getOrigin();
btVector3 rayFromLocal = worldTocollisionObject * rayFromTrans.m_origin;
btVector3 rayToLocal = worldTocollisionObject * rayToTrans.m_origin;

// BT_PROFILE("rayTestConcave");
if (collisionShape->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE)
Expand Down Expand Up @@ -413,15 +413,15 @@ void btCollisionWorld::rayTestSingleInternal(const btTransform& rayFromTrans, co
rcb.m_hitFraction = resultCallback.m_closestHitFraction;
triangleMesh->performRaycast(&rcb, rayFromLocalScaled, rayToLocalScaled);
}
else if (((resultCallback.m_flags&btTriangleRaycastCallback::kF_DisableHeightfieldAccelerator)==0)
&& collisionShape->getShapeType() == TERRAIN_SHAPE_PROXYTYPE
else if (((resultCallback.m_flags&btTriangleRaycastCallback::kF_DisableHeightfieldAccelerator)==0)
&& collisionShape->getShapeType() == TERRAIN_SHAPE_PROXYTYPE
)
{
///optimized version for btHeightfieldTerrainShape
btHeightfieldTerrainShape* heightField = (btHeightfieldTerrainShape*)collisionShape;
btTransform worldTocollisionObject = colObjWorldTransform.inverse();
btVector3 rayFromLocal = worldTocollisionObject * rayFromTrans.getOrigin();
btVector3 rayToLocal = worldTocollisionObject * rayToTrans.getOrigin();
btVector3 rayFromLocal = worldTocollisionObject * rayFromTrans.m_origin;
btVector3 rayToLocal = worldTocollisionObject * rayToTrans.m_origin;

BridgeTriangleRaycastCallback rcb(rayFromLocal, rayToLocal, &resultCallback, collisionObjectWrap->getCollisionObject(), heightField, colObjWorldTransform);
rcb.m_hitFraction = resultCallback.m_closestHitFraction;
Expand All @@ -434,8 +434,8 @@ void btCollisionWorld::rayTestSingleInternal(const btTransform& rayFromTrans, co

btTransform worldTocollisionObject = colObjWorldTransform.inverse();

btVector3 rayFromLocal = worldTocollisionObject * rayFromTrans.getOrigin();
btVector3 rayToLocal = worldTocollisionObject * rayToTrans.getOrigin();
btVector3 rayFromLocal = worldTocollisionObject * rayFromTrans.m_origin;
btVector3 rayToLocal = worldTocollisionObject * rayToTrans.m_origin;

//ConvexCast::CastResult

Expand Down Expand Up @@ -463,7 +463,7 @@ void btCollisionWorld::rayTestSingleInternal(const btTransform& rayFromTrans, co
shapeInfo.m_shapePart = partId;
shapeInfo.m_triangleIndex = triangleIndex;

btVector3 hitNormalWorld = m_colObjWorldTransform.getBasis() * hitNormalLocal;
btVector3 hitNormalWorld = m_colObjWorldTransform.m_basis * hitNormalLocal;

btCollisionWorld::LocalRayResult rayResult(m_collisionObject,
&shapeInfo,
Expand Down Expand Up @@ -581,8 +581,8 @@ void btCollisionWorld::rayTestSingleInternal(const btTransform& rayFromTrans, co
#ifndef DISABLE_DBVT_COMPOUNDSHAPE_RAYCAST_ACCELERATION
if (dbvt)
{
btVector3 localRayFrom = colObjWorldTransform.inverseTimes(rayFromTrans).getOrigin();
btVector3 localRayTo = colObjWorldTransform.inverseTimes(rayToTrans).getOrigin();
btVector3 localRayFrom = colObjWorldTransform.inverseTimes(rayFromTrans).m_origin;
btVector3 localRayTo = colObjWorldTransform.inverseTimes(rayToTrans).m_origin;
btDbvt::rayTest(dbvt->m_root, localRayFrom, localRayTo, rayCB);
}
else
Expand Down Expand Up @@ -662,10 +662,10 @@ void btCollisionWorld::objectQuerySingleInternal(const btConvexShape* castShape,
//BT_PROFILE("convexSweepbtBvhTriangleMesh");
btBvhTriangleMeshShape* triangleMesh = (btBvhTriangleMeshShape*)collisionShape;
btTransform worldTocollisionObject = colObjWorldTransform.inverse();
btVector3 convexFromLocal = worldTocollisionObject * convexFromTrans.getOrigin();
btVector3 convexToLocal = worldTocollisionObject * convexToTrans.getOrigin();
btVector3 convexFromLocal = worldTocollisionObject * convexFromTrans.m_origin;
btVector3 convexToLocal = worldTocollisionObject * convexToTrans.m_origin;
// rotation of box in local mesh space = MeshRotation^-1 * ConvexToRotation
btTransform rotationXform = btTransform(worldTocollisionObject.getBasis() * convexToTrans.getBasis());
btTransform rotationXform = btTransform(worldTocollisionObject.m_basis * convexToTrans.m_basis);

//ConvexCast::CastResult
struct BridgeTriangleConvexcastCallback : public btTriangleConvexcastCallback
Expand Down Expand Up @@ -747,10 +747,10 @@ void btCollisionWorld::objectQuerySingleInternal(const btConvexShape* castShape,
//BT_PROFILE("convexSweepConcave");
btConcaveShape* concaveShape = (btConcaveShape*)collisionShape;
btTransform worldTocollisionObject = colObjWorldTransform.inverse();
btVector3 convexFromLocal = worldTocollisionObject * convexFromTrans.getOrigin();
btVector3 convexToLocal = worldTocollisionObject * convexToTrans.getOrigin();
btVector3 convexFromLocal = worldTocollisionObject * convexFromTrans.m_origin;
btVector3 convexToLocal = worldTocollisionObject * convexToTrans.m_origin;
// rotation of box in local mesh space = MeshRotation^-1 * ConvexToRotation
btTransform rotationXform = btTransform(worldTocollisionObject.getBasis() * convexToTrans.getBasis());
btTransform rotationXform = btTransform(worldTocollisionObject.m_basis * convexToTrans.m_basis);

//ConvexCast::CastResult
struct BridgeTriangleConvexcastCallback : public btTriangleConvexcastCallback
Expand Down Expand Up @@ -944,9 +944,9 @@ struct btSingleRayCallback : public btBroadphaseRayCallback
m_resultCallback(resultCallback)
{
m_rayFromTrans.setIdentity();
m_rayFromTrans.setOrigin(m_rayFromWorld);
m_rayFromTrans.m_origin = m_rayFromWorld;
m_rayToTrans.setIdentity();
m_rayToTrans.setOrigin(m_rayToWorld);
m_rayToTrans.m_origin = m_rayToWorld;

btVector3 rayDir = (rayToWorld - rayFromWorld);

Expand Down Expand Up @@ -1035,7 +1035,7 @@ struct btSingleSweepCallback : public btBroadphaseRayCallback
m_allowedCcdPenetration(allowedPenetration),
m_castShape(castShape)
{
btVector3 unnormalizedRayDir = (m_convexToTrans.getOrigin() - m_convexFromTrans.getOrigin());
btVector3 unnormalizedRayDir = (m_convexToTrans.m_origin - m_convexFromTrans.m_origin);
btVector3 rayDir = unnormalizedRayDir.fuzzyZero() ? btVector3(btScalar(0.0), btScalar(0.0), btScalar(0.0)) : unnormalizedRayDir.normalized();
///what about division by zero? --> just set rayDirection[i] to INF/BT_LARGE_FLOAT
m_rayDirectionInverse[0] = rayDir[0] == btScalar(0.0) ? btScalar(BT_LARGE_FLOAT) : btScalar(1.0) / rayDir[0];
Expand Down Expand Up @@ -1099,7 +1099,7 @@ void btCollisionWorld::convexSweepTest(const btConvexShape* castShape, const btT

btSingleSweepCallback convexCB(castShape, convexFromWorld, convexToWorld, this, resultCallback, allowedCcdPenetration);

m_broadphasePairCache->rayTest(convexFromTrans.getOrigin(), convexToTrans.getOrigin(), convexCB, castShapeAabbMin, castShapeAabbMax);
m_broadphasePairCache->rayTest(convexFromTrans.m_origin, convexToTrans.m_origin, convexCB, castShapeAabbMin, castShapeAabbMax);

#else
/// go over all objects, and if the ray intersects their aabb + cast shape aabb,
Expand All @@ -1117,7 +1117,7 @@ void btCollisionWorld::convexSweepTest(const btConvexShape* castShape, const btT
AabbExpand(collisionObjectAabbMin, collisionObjectAabbMax, castShapeAabbMin, castShapeAabbMax);
btScalar hitLambda = btScalar(1.); //could use resultCallback.m_closestHitFraction, but needs testing
btVector3 hitNormal;
if (btRayAabb(convexFromWorld.getOrigin(), convexToWorld.getOrigin(), collisionObjectAabbMin, collisionObjectAabbMax, hitLambda, hitNormal))
if (btRayAabb(convexFromWorld.m_origin, convexToWorld.m_origin, collisionObjectAabbMin, collisionObjectAabbMax, hitLambda, hitNormal))
{
objectQuerySingle(castShape, convexFromTrans, convexToTrans,
collisionObject,
Expand Down Expand Up @@ -1344,7 +1344,7 @@ void btCollisionWorld::debugDrawObject(const btTransform& worldTransform, const

for (int i = multiSphereShape->getSphereCount() - 1; i >= 0; i--)
{
childTransform.setOrigin(multiSphereShape->getSpherePosition(i));
childTransform.m_origin = multiSphereShape->getSpherePosition(i);
getDebugDrawer()->drawSphere(multiSphereShape->getSphereRadius(i), worldTransform * childTransform, color);
}

Expand Down
Loading

0 comments on commit 21c2254

Please sign in to comment.