MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / RayCast

Method RayCast

Source/Engine/Terrain/Terrain.cpp:105–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

103}
104
105bool Terrain::RayCast(const Vector3& origin, const Vector3& direction, float& resultHitDistance, float maxDistance) const
106{
107 float minDistance = MAX_float;
108 bool result = false;
109 const Ray ray(origin, direction);
110
111 for (int32 pathIndex = 0; pathIndex < _patches.Count(); pathIndex++)
112 {
113 const auto patch = _patches[pathIndex];
114 if (patch->HasCollision() &&
115 patch->_bounds.Intersects(ray) &&
116 patch->RayCast(origin, direction, resultHitDistance, maxDistance) &&
117 resultHitDistance < minDistance)
118 {
119 minDistance = resultHitDistance;
120 result = true;
121 }
122 }
123
124 resultHitDistance = minDistance;
125 return result;
126}
127
128bool Terrain::RayCast(const Vector3& origin, const Vector3& direction, float& resultHitDistance, TerrainChunk*& resultChunk, float maxDistance) const
129{

Callers 1

IntersectsItselfMethod · 0.45

Calls 5

GetXMethod · 0.80
GetPatchMethod · 0.80
GetZMethod · 0.80
CountMethod · 0.45
IntersectsMethod · 0.45

Tested by

no test coverage detected