Pass the btCollisionObject as const

move
scrawl 9 years ago
parent 004f0d37d5
commit c085e503c6

@ -68,8 +68,8 @@ namespace MWPhysics
return osg::RadiansToDegrees(std::acos(normal * osg::Vec3f(0.f, 0.f, 1.f))); return osg::RadiansToDegrees(std::acos(normal * osg::Vec3f(0.f, 0.f, 1.f)));
} }
static bool stepMove(btCollisionObject *colobj, osg::Vec3f &position, static bool stepMove(const btCollisionObject *colobj, osg::Vec3f &position,
const osg::Vec3f &toMove, float &remainingTime, btCollisionWorld* collisionWorld) const osg::Vec3f &toMove, float &remainingTime, const btCollisionWorld* collisionWorld)
{ {
/* /*
* Slide up an incline or set of stairs. Should be called only after a * Slide up an incline or set of stairs. Should be called only after a
@ -235,7 +235,7 @@ namespace MWPhysics
} }
static osg::Vec3f move(osg::Vec3f position, const MWWorld::Ptr &ptr, Actor* physicActor, const osg::Vec3f &movement, float time, static osg::Vec3f move(osg::Vec3f position, const MWWorld::Ptr &ptr, Actor* physicActor, const osg::Vec3f &movement, float time,
bool isFlying, float waterlevel, float slowFall, btCollisionWorld* collisionWorld, bool isFlying, float waterlevel, float slowFall, const btCollisionWorld* collisionWorld,
std::map<MWWorld::Ptr, MWWorld::Ptr>& standingCollisionTracker) std::map<MWWorld::Ptr, MWWorld::Ptr>& standingCollisionTracker)
{ {
const ESM::Position& refpos = ptr.getRefData().getPosition(); const ESM::Position& refpos = ptr.getRefData().getPosition();
@ -254,7 +254,7 @@ namespace MWPhysics
) * movement * time; ) * movement * time;
} }
btCollisionObject *colobj = physicActor->getCollisionObject(); const btCollisionObject *colobj = physicActor->getCollisionObject();
osg::Vec3f halfExtents = physicActor->getHalfExtents(); osg::Vec3f halfExtents = physicActor->getHalfExtents();
// NOTE: here we don't account for the collision box translation (i.e. physicActor->getPosition() - refpos.pos). // NOTE: here we don't account for the collision box translation (i.e. physicActor->getPosition() - refpos.pos).

@ -16,7 +16,7 @@ namespace MWPhysics
class ClosestNotMeConvexResultCallback : public btCollisionWorld::ClosestConvexResultCallback class ClosestNotMeConvexResultCallback : public btCollisionWorld::ClosestConvexResultCallback
{ {
public: public:
ClosestNotMeConvexResultCallback(btCollisionObject *me, const btVector3 &up, btScalar minSlopeDot) ClosestNotMeConvexResultCallback(const btCollisionObject *me, const btVector3 &up, btScalar minSlopeDot)
: btCollisionWorld::ClosestConvexResultCallback(btVector3(0.0, 0.0, 0.0), btVector3(0.0, 0.0, 0.0)), : btCollisionWorld::ClosestConvexResultCallback(btVector3(0.0, 0.0, 0.0), btVector3(0.0, 0.0, 0.0)),
mMe(me), mUp(up), mMinSlopeDot(minSlopeDot) mMe(me), mUp(up), mMinSlopeDot(minSlopeDot)
{ {
@ -44,13 +44,13 @@ public:
} }
protected: protected:
btCollisionObject *mMe; const btCollisionObject *mMe;
const btVector3 mUp; const btVector3 mUp;
const btScalar mMinSlopeDot; const btScalar mMinSlopeDot;
}; };
void ActorTracer::doTrace(btCollisionObject *actor, const osg::Vec3f& start, const osg::Vec3f& end, btCollisionWorld* world) void ActorTracer::doTrace(const btCollisionObject *actor, const osg::Vec3f& start, const osg::Vec3f& end, const btCollisionWorld* world)
{ {
const btVector3 btstart = toBullet(start); const btVector3 btstart = toBullet(start);
const btVector3 btend = toBullet(end); const btVector3 btend = toBullet(end);
@ -66,9 +66,9 @@ void ActorTracer::doTrace(btCollisionObject *actor, const osg::Vec3f& start, con
newTraceCallback.m_collisionFilterGroup = actor->getBroadphaseHandle()->m_collisionFilterGroup; newTraceCallback.m_collisionFilterGroup = actor->getBroadphaseHandle()->m_collisionFilterGroup;
newTraceCallback.m_collisionFilterMask = actor->getBroadphaseHandle()->m_collisionFilterMask; newTraceCallback.m_collisionFilterMask = actor->getBroadphaseHandle()->m_collisionFilterMask;
btCollisionShape *shape = actor->getCollisionShape(); const btCollisionShape *shape = actor->getCollisionShape();
assert(shape->isConvex()); assert(shape->isConvex());
world->convexSweepTest(static_cast<btConvexShape*>(shape), world->convexSweepTest(static_cast<const btConvexShape*>(shape),
from, to, newTraceCallback); from, to, newTraceCallback);
// Copy the hit data over to our trace results struct: // Copy the hit data over to our trace results struct:
@ -89,7 +89,7 @@ void ActorTracer::doTrace(btCollisionObject *actor, const osg::Vec3f& start, con
} }
} }
void ActorTracer::findGround(const Actor* actor, const osg::Vec3f& start, const osg::Vec3f& end, btCollisionWorld* world) void ActorTracer::findGround(const Actor* actor, const osg::Vec3f& start, const osg::Vec3f& end, const btCollisionWorld* world)
{ {
const btVector3 btstart(start.x(), start.y(), start.z()+1.0f); const btVector3 btstart(start.x(), start.y(), start.z()+1.0f);
const btVector3 btend(end.x(), end.y(), end.z()+1.0f); const btVector3 btend(end.x(), end.y(), end.z()+1.0f);

@ -19,8 +19,8 @@ namespace MWPhysics
float mFraction; float mFraction;
void doTrace(btCollisionObject *actor, const osg::Vec3f& start, const osg::Vec3f& end, btCollisionWorld* world); void doTrace(const btCollisionObject *actor, const osg::Vec3f& start, const osg::Vec3f& end, const btCollisionWorld* world);
void findGround(const Actor* actor, const osg::Vec3f& start, const osg::Vec3f& end, btCollisionWorld* world); void findGround(const Actor* actor, const osg::Vec3f& start, const osg::Vec3f& end, const btCollisionWorld* world);
}; };
} }

Loading…
Cancel
Save