Separate ContactTestResultCallback
parent
c94cd775bf
commit
5d625c12dc
@ -0,0 +1,27 @@
|
||||
#include "contacttestresultcallback.hpp"
|
||||
|
||||
#include <BulletCollision/CollisionDispatch/btCollisionObject.h>
|
||||
|
||||
#include "ptrholder.hpp"
|
||||
|
||||
namespace MWPhysics
|
||||
{
|
||||
ContactTestResultCallback::ContactTestResultCallback(const btCollisionObject* testedAgainst)
|
||||
: mTestedAgainst(testedAgainst)
|
||||
{
|
||||
}
|
||||
|
||||
btScalar ContactTestResultCallback::addSingleResult(btManifoldPoint& cp,
|
||||
const btCollisionObjectWrapper* col0Wrap,int partId0,int index0,
|
||||
const btCollisionObjectWrapper* col1Wrap,int partId1,int index1)
|
||||
{
|
||||
const btCollisionObject* collisionObject = col0Wrap->m_collisionObject;
|
||||
if (collisionObject == mTestedAgainst)
|
||||
collisionObject = col1Wrap->m_collisionObject;
|
||||
PtrHolder* holder = static_cast<PtrHolder*>(collisionObject->getUserPointer());
|
||||
if (holder)
|
||||
mResult.push_back(holder->getPtr());
|
||||
return 0.f;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
#ifndef OPENMW_MWPHYSICS_CONTACTTESTRESULTCALLBACK_H
|
||||
#define OPENMW_MWPHYSICS_CONTACTTESTRESULTCALLBACK_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <BulletCollision/CollisionDispatch/btCollisionWorld.h>
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
class btCollisionObject;
|
||||
class btCollisionObjectWrapper;
|
||||
|
||||
namespace MWPhysics
|
||||
{
|
||||
class ContactTestResultCallback : public btCollisionWorld::ContactResultCallback
|
||||
{
|
||||
const btCollisionObject* mTestedAgainst;
|
||||
|
||||
public:
|
||||
ContactTestResultCallback(const btCollisionObject* testedAgainst);
|
||||
|
||||
virtual btScalar addSingleResult(btManifoldPoint& cp,
|
||||
const btCollisionObjectWrapper* col0Wrap,int partId0,int index0,
|
||||
const btCollisionObjectWrapper* col1Wrap,int partId1,int index1);
|
||||
|
||||
std::vector<MWWorld::Ptr> mResult;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue