1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-01 12:01:51 +00:00
OpenMW/apps/openmw/mwphysics/closestnotmerayresultcallback.cpp
elsid 506824cb9d
Cleanup physics callbacks
* Do not copy with allocations.
* Remove unused DeepestNotMeContactTestResultCallback.
* Avoid using pointers which should not be nullptr.
* Move constructors implementation to headers.
* Move types defined in .cpp are to unnamed namespace.
* Comment unused arguments.
* Avoid C-style casts.
2024-02-07 22:04:34 +01:00

27 lines
817 B
C++

#include "closestnotmerayresultcallback.hpp"
#include <algorithm>
#include <BulletCollision/CollisionDispatch/btCollisionObject.h>
#include "collisiontype.hpp"
namespace MWPhysics
{
btScalar ClosestNotMeRayResultCallback::addSingleResult(
btCollisionWorld::LocalRayResult& rayResult, bool normalInWorldSpace)
{
const auto* hitObject = rayResult.m_collisionObject;
if (hitObject == mMe)
return 1.f;
if (hitObject->getBroadphaseHandle()->m_collisionFilterGroup == CollisionType_Actor && !mTargets.empty())
{
if ((std::find(mTargets.begin(), mTargets.end(), hitObject) == mTargets.end()))
return 1.f;
}
return btCollisionWorld::ClosestRayResultCallback::addSingleResult(rayResult, normalInWorldSpace);
}
}