6 #include "VectorMath.h"
7 #include "CollisionBvhNode.h"
8 #include "CollisionMaterialIndexLookupPair.h"
9 #include "CollisionGroup.h"
10 #include "CollisionMaterialTable.h"
11 #include "AllVertexTypes.h"
25 const v3& quantizationRelativeOrigin,
26 float quantizationScale,
29 CollisionGroup::Type collisionGroup,
30 bool counterClockwiseWinding,
31 const std::vector<Rendering::VertexTypes::ShortPositionVertex>* pPoints,
32 const std::vector<u16>* pTriListIndices,
33 const std::vector<CollisionBvhNode>* pNodes,
34 const std::vector<CollisionMaterialIndexLookupPair>* pMaterialIndexLookupPairs,
39 const dv3& OriginEcef()
const {
return m_originEcef; }
40 const v3& QuantizationRelativeOrigin()
const {
return m_quantizationRelativeOrigin; }
41 float QuantizationScale()
const {
return m_quantizationScale; }
42 CollisionGroup::Type CollisionGroup()
const {
return m_collisionGroup; }
43 bool IsCounterClockwiseWinding()
const {
return m_counterClockwiseWinding; }
44 const std::vector<Rendering::VertexTypes::ShortPositionVertex>& QuantizedPoints()
const {
return *m_pPoints; }
45 const std::vector<u16>& TriListIndices()
const {
return *m_pTriListIndices; }
46 const std::vector<CollisionBvhNode>& Nodes()
const {
return *m_pNodes; }
47 const std::vector<CollisionMaterialIndexLookupPair>& MaterialIndexLookupPairs()
const {
return *m_pMaterialIndexLookupPairs; }
48 int FindMeshIndexForTriangle(
int triangleIndex)
const;
49 const float MinAltitude()
const {
return m_minAltitude; }
50 const float MaxAltitude()
const {
return m_maxAltitude; }
52 inline v3 GetInflatedPoint(
int vertexIndex)
const;
56 std::string CollisionMaterialIdForIndex(
int materialIndex)
const {
return (materialIndex < 0) ? std::string() : m_pCollisionMaterialTable->IdAtIndex(materialIndex); }
58 std::vector<u16> GatherTriListIndicesForMaterialIndex(
const int materialIndex)
const;
62 const dv3 m_originEcef;
63 const v3 m_quantizationRelativeOrigin;
64 const float m_quantizationScale;
65 const float m_minAltitude;
66 const float m_maxAltitude;
67 const CollisionGroup::Type m_collisionGroup;
68 bool m_counterClockwiseWinding;
69 const std::vector<Rendering::VertexTypes::ShortPositionVertex>* m_pPoints;
70 const std::vector<u16>* m_pTriListIndices;
71 const std::vector<CollisionBvhNode>* m_pNodes;
72 const std::vector<CollisionMaterialIndexLookupPair>* m_pMaterialIndexLookupPairs;
76 inline v3 CollisionBvh::GetInflatedPoint(
int vertexIndex)
const
78 Eegeo_ASSERT_SLOW(vertexIndex >= 0 && vertexIndex < m_pPoints->size(),
"vertex index out of range");
82 p *= m_quantizationScale;
83 p += m_quantizationRelativeOrigin;
91 sphere.centre.x = qc.x;
92 sphere.centre.y = qc.y;
93 sphere.centre.z = qc.z;
94 sphere.centre *= m_quantizationScale;
95 sphere.centre += m_quantizationRelativeOrigin;
96 sphere.radius = node.QuantizedSphereRadius()*m_quantizationScale;