Allow an Object to be specified as ignore parameter for castRay

move
scrawl 9 years ago
parent 76b47c6d5d
commit 910e41e3c4

@ -557,6 +557,11 @@ namespace MWPhysics
return mCollisionObject.get(); return mCollisionObject.get();
} }
const btCollisionObject* getCollisionObject() const
{
return mCollisionObject.get();
}
/// Return solid flag. Not used by the object itself, true by default. /// Return solid flag. Not used by the object itself, true by default.
bool isSolid() const bool isSolid() const
{ {
@ -883,6 +888,12 @@ namespace MWPhysics
const Actor* actor = getActor(ignore); const Actor* actor = getActor(ignore);
if (actor) if (actor)
me = actor->getCollisionObject(); me = actor->getCollisionObject();
else
{
const Object* object = getObject(ignore);
if (object)
me = object->getCollisionObject();
}
} }
ClosestNotMeRayResultCallback resultCallback(me, btFrom, btTo); ClosestNotMeRayResultCallback resultCallback(me, btFrom, btTo);
@ -1174,6 +1185,14 @@ namespace MWPhysics
return NULL; return NULL;
} }
const Object* PhysicsSystem::getObject(const MWWorld::ConstPtr &ptr) const
{
ObjectMap::const_iterator found = mObjects.find(ptr);
if (found != mObjects.end())
return found->second;
return NULL;
}
void PhysicsSystem::updateScale(const MWWorld::Ptr &ptr) void PhysicsSystem::updateScale(const MWWorld::Ptr &ptr)
{ {
ObjectMap::iterator found = mObjects.find(ptr); ObjectMap::iterator found = mObjects.find(ptr);

@ -70,6 +70,8 @@ namespace MWPhysics
Actor* getActor(const MWWorld::Ptr& ptr); Actor* getActor(const MWWorld::Ptr& ptr);
const Actor* getActor(const MWWorld::ConstPtr& ptr) const; const Actor* getActor(const MWWorld::ConstPtr& ptr) const;
const Object* getObject(const MWWorld::ConstPtr& ptr) const;
// Object or Actor // Object or Actor
void remove (const MWWorld::Ptr& ptr); void remove (const MWWorld::Ptr& ptr);

Loading…
Cancel
Save