mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-27 03:35:27 +00:00
Restore getCollisions
This commit is contained in:
parent
8b322fcd06
commit
d84990be85
@ -758,9 +758,37 @@ namespace MWPhysics
|
|||||||
return std::make_pair(false, osg::Vec3f());
|
return std::make_pair(false, osg::Vec3f());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> PhysicsSystem::getCollisions(const MWWorld::Ptr &ptr, int collisionGroup, int collisionMask)
|
class ContactTestResultCallback : public btCollisionWorld::ContactResultCallback
|
||||||
{
|
{
|
||||||
return std::vector<std::string>();//mEngine->getCollisions(ptr.getRefData().getBaseNodeOld()->getName(), collisionGroup, collisionMask);
|
public:
|
||||||
|
std::vector<MWWorld::Ptr> mResult;
|
||||||
|
|
||||||
|
virtual btScalar addSingleResult(btManifoldPoint& cp,
|
||||||
|
const btCollisionObjectWrapper* colObj0Wrap,int partId0,int index0,
|
||||||
|
const btCollisionObjectWrapper* colObj1Wrap,int partId1,int index1)
|
||||||
|
{
|
||||||
|
const PtrHolder* holder = static_cast<const PtrHolder*>(colObj0Wrap->m_collisionObject->getUserPointer());
|
||||||
|
if (holder)
|
||||||
|
mResult.push_back(holder->getPtr());
|
||||||
|
return 0.f;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
std::vector<MWWorld::Ptr> PhysicsSystem::getCollisions(const MWWorld::Ptr &ptr, int collisionGroup, int collisionMask)
|
||||||
|
{
|
||||||
|
btCollisionObject* me = NULL;
|
||||||
|
|
||||||
|
ObjectMap::iterator found = mObjects.find(ptr);
|
||||||
|
if (found != mObjects.end())
|
||||||
|
me = found->second->getCollisionObject();
|
||||||
|
else
|
||||||
|
return std::vector<MWWorld::Ptr>();
|
||||||
|
|
||||||
|
ContactTestResultCallback resultCallback;
|
||||||
|
resultCallback.m_collisionFilterGroup = collisionGroup;
|
||||||
|
resultCallback.m_collisionFilterMask = collisionMask;
|
||||||
|
mDynamicsWorld->contactTest(me, resultCallback);
|
||||||
|
return resultCallback.mResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::Vec3f PhysicsSystem::traceDown(const MWWorld::Ptr &ptr, float maxHeight)
|
osg::Vec3f PhysicsSystem::traceDown(const MWWorld::Ptr &ptr, float maxHeight)
|
||||||
|
@ -77,7 +77,7 @@ namespace MWPhysics
|
|||||||
|
|
||||||
void stepSimulation(float dt);
|
void stepSimulation(float dt);
|
||||||
|
|
||||||
std::vector<std::string> getCollisions(const MWWorld::Ptr &ptr, int collisionGroup, int collisionMask); ///< get handles this object collides with
|
std::vector<MWWorld::Ptr> getCollisions(const MWWorld::Ptr &ptr, int collisionGroup, int collisionMask); ///< get handles this object collides with
|
||||||
osg::Vec3f traceDown(const MWWorld::Ptr &ptr, float maxHeight);
|
osg::Vec3f traceDown(const MWWorld::Ptr &ptr, float maxHeight);
|
||||||
|
|
||||||
std::pair<MWWorld::Ptr, osg::Vec3f> getHitContact(const MWWorld::Ptr& actor,
|
std::pair<MWWorld::Ptr, osg::Vec3f> getHitContact(const MWWorld::Ptr& actor,
|
||||||
|
@ -48,6 +48,7 @@
|
|||||||
|
|
||||||
#include "../mwphysics/physicssystem.hpp"
|
#include "../mwphysics/physicssystem.hpp"
|
||||||
#include "../mwphysics/actor.hpp"
|
#include "../mwphysics/actor.hpp"
|
||||||
|
#include "../mwphysics/collisiontype.hpp"
|
||||||
|
|
||||||
#include "player.hpp"
|
#include "player.hpp"
|
||||||
#include "manualref.hpp"
|
#include "manualref.hpp"
|
||||||
@ -1420,7 +1421,6 @@ namespace MWWorld
|
|||||||
|
|
||||||
void World::processDoors(float duration)
|
void World::processDoors(float duration)
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
std::map<MWWorld::Ptr, int>::iterator it = mDoorStates.begin();
|
std::map<MWWorld::Ptr, int>::iterator it = mDoorStates.begin();
|
||||||
while (it != mDoorStates.end())
|
while (it != mDoorStates.end())
|
||||||
{
|
{
|
||||||
@ -1433,19 +1433,18 @@ namespace MWWorld
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
float oldRot = Ogre::Radian(it->first.getRefData().getLocalRotation().rot[2]).valueDegrees();
|
float oldRot = osg::RadiansToDegrees(it->first.getRefData().getLocalRotation().rot[2]);
|
||||||
float diff = duration * 90;
|
float diff = duration * 90.f;
|
||||||
float targetRot = std::min(std::max(0.f, oldRot + diff * (it->second == 1 ? 1 : -1)), 90.f);
|
float targetRot = std::min(std::max(0.f, oldRot + diff * (it->second == 1 ? 1 : -1)), 90.f);
|
||||||
localRotateObject(it->first, 0, 0, targetRot);
|
localRotateObject(it->first, 0, 0, targetRot);
|
||||||
|
|
||||||
bool reached = (targetRot == 90.f && it->second) || targetRot == 0.f;
|
bool reached = (targetRot == 90.f && it->second) || targetRot == 0.f;
|
||||||
|
|
||||||
/// \todo should use convexSweepTest here
|
/// \todo should use convexSweepTest here
|
||||||
std::vector<std::string> collisions = mPhysics->getCollisions(it->first, OEngine::Physic::CollisionType_Actor
|
std::vector<MWWorld::Ptr> collisions = mPhysics->getCollisions(it->first, MWPhysics::CollisionType_Actor, MWPhysics::CollisionType_Actor);
|
||||||
, OEngine::Physic::CollisionType_Actor);
|
for (std::vector<MWWorld::Ptr>::iterator cit = collisions.begin(); cit != collisions.end(); ++cit)
|
||||||
for (std::vector<std::string>::iterator cit = collisions.begin(); cit != collisions.end(); ++cit)
|
|
||||||
{
|
{
|
||||||
MWWorld::Ptr ptr = getPtrViaHandle(*cit);
|
MWWorld::Ptr ptr = *cit;
|
||||||
if (ptr.getClass().isActor())
|
if (ptr.getClass().isActor())
|
||||||
{
|
{
|
||||||
// Collided with actor, ask actor to try to avoid door
|
// Collided with actor, ask actor to try to avoid door
|
||||||
@ -1471,7 +1470,6 @@ namespace MWWorld
|
|||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool World::toggleCollisionMode()
|
bool World::toggleCollisionMode()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user