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

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

27 lines
882 B
C++
Raw Normal View History

2020-03-30 18:45:38 +00:00
#include "closestnotmerayresultcallback.hpp"
#include <algorithm>
#include <BulletCollision/CollisionDispatch/btCollisionObject.h>
#include "collisiontype.hpp"
2020-03-30 18:45:38 +00:00
namespace MWPhysics
{
btScalar ClosestNotMeRayResultCallback::addSingleResult(
btCollisionWorld::LocalRayResult& rayResult, bool normalInWorldSpace)
{
const auto* hitObject = rayResult.m_collisionObject;
2024-02-12 15:52:47 +00:00
if (std::find(mIgnoreList.begin(), mIgnoreList.end(), hitObject) != mIgnoreList.end())
2020-03-30 18:45:38 +00:00
return 1.f;
if (hitObject->getBroadphaseHandle()->m_collisionFilterGroup == CollisionType_Actor && !mTargets.empty())
2020-03-30 18:45:38 +00:00
{
if ((std::find(mTargets.begin(), mTargets.end(), hitObject) == mTargets.end()))
return 1.f;
2020-03-30 18:45:38 +00:00
}
return btCollisionWorld::ClosestRayResultCallback::addSingleResult(rayResult, normalInWorldSpace);
2020-03-30 18:45:38 +00:00
}
}