6 #include "VectorMath.h"
7 #include "CollisionGroup.h"
8 #include "ICollisionBvhProvider.h"
9 #include "CollisionBvhRayCaster.h"
10 #include "ArrayAllocator.h"
18 template <
size_t CollisionBvhBufferSize,
size_t MaxRayNodeIntersectionResults>
22 #if defined(EEGEO_WIN) && !defined(NDEBUG)
23 typedef std::vector<const CollisionBvh*> CollisionBvhVector;
24 typedef std::vector<RayNodeIntersectionResult> RayNodeIntersectionResultVector;
26 typedef std::vector<const CollisionBvh*, Eegeo::Helpers::ArrayAllocator<const CollisionBvh*, CollisionBvhBufferSize> > CollisionBvhVector;
27 typedef std::vector<RayNodeIntersectionResult, Eegeo::Helpers::ArrayAllocator<RayNodeIntersectionResult, MaxRayNodeIntersectionResults> > RayNodeIntersectionResultVector;
30 : m_collisionBvhProvider(collisionBvhProvider)
35 RayCasterResult FindFirstRayIntersection(
const u32 collidableGroupsMask,
const float environmentFlatteningScale,
const Eegeo::dv3& rayOrigin,
const Eegeo::dv3& rayDirection)
37 m_collisionBvhBuffer.resize(CollisionBvhBufferSize);
39 const size_t totalCount = m_collisionBvhProvider.CopyCollisionBvhsForGroups(collidableGroupsMask, m_collisionBvhBuffer.data(), m_collisionBvhBuffer.size());
40 Eegeo_ASSERT(totalCount <= m_collisionBvhBuffer.capacity(),
"insufficient collisionBvhBuffer size, totalCount %ld", totalCount);
41 m_collisionBvhBuffer.resize(totalCount);
44 return rayCaster.FindFirstRayIntersection(environmentFlatteningScale, rayOrigin, rayDirection);
48 CollisionBvhVector m_collisionBvhBuffer;
49 RayNodeIntersectionResultVector m_rayNodeIntersectionResults;
51 void *
operator new [](size_t)
throw() {
return 0;}
52 void operator delete [] (
void*) {}
53 void *
operator new (size_t)
throw() {
return 0;}
54 void operator delete (
void*) {}