1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-04 02:41:19 +00:00
OpenMW/apps/openmw/mwphysics/contacttestresultcallback.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

30 lines
1.0 KiB
C++
Raw Normal View History

2020-03-30 18:49:47 +00:00
#include "contacttestresultcallback.hpp"
#include <BulletCollision/CollisionDispatch/btCollisionObject.h>
#include "components/misc/convert.hpp"
2020-03-30 18:49:47 +00:00
#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.emplace_back(ContactPoint{ holder->getPtr(), Misc::Convert::toOsg(cp.m_positionWorldOnB),
Misc::Convert::toOsg(cp.m_normalWorldOnB) });
2020-03-30 18:49:47 +00:00
return 0.f;
}
}