2020-03-30 21:45:38 +03:00
|
|
|
#include "closestnotmerayresultcallback.hpp"
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
#include <BulletCollision/CollisionDispatch/btCollisionObject.h>
|
|
|
|
|
2021-08-05 10:55:19 +02:00
|
|
|
#include "collisiontype.hpp"
|
2020-03-30 21:45:38 +03:00
|
|
|
|
|
|
|
namespace MWPhysics
|
|
|
|
{
|
2022-09-22 21:26:05 +03:00
|
|
|
btScalar ClosestNotMeRayResultCallback::addSingleResult(
|
|
|
|
btCollisionWorld::LocalRayResult& rayResult, bool normalInWorldSpace)
|
2020-03-30 21:45:38 +03:00
|
|
|
{
|
2021-08-05 10:55:19 +02:00
|
|
|
const auto* hitObject = rayResult.m_collisionObject;
|
2024-02-12 07:52:47 -08:00
|
|
|
if (std::find(mIgnoreList.begin(), mIgnoreList.end(), hitObject) != mIgnoreList.end())
|
2020-03-30 21:45:38 +03:00
|
|
|
return 1.f;
|
2020-12-15 21:34:58 +01:00
|
|
|
|
2021-08-05 10:55:19 +02:00
|
|
|
if (hitObject->getBroadphaseHandle()->m_collisionFilterGroup == CollisionType_Actor && !mTargets.empty())
|
2020-03-30 21:45:38 +03:00
|
|
|
{
|
2021-08-05 10:55:19 +02:00
|
|
|
if ((std::find(mTargets.begin(), mTargets.end(), hitObject) == mTargets.end()))
|
|
|
|
return 1.f;
|
2020-03-30 21:45:38 +03:00
|
|
|
}
|
2019-02-13 11:30:16 +04:00
|
|
|
|
2021-01-07 11:02:53 +01:00
|
|
|
return btCollisionWorld::ClosestRayResultCallback::addSingleResult(rayResult, normalInWorldSpace);
|
2020-03-30 21:45:38 +03:00
|
|
|
}
|
|
|
|
}
|