MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / getTerrainUnderWorldPoint

Function getTerrainUnderWorldPoint

Engine/source/terrain/terrData.cpp:95–130  ·  view source on GitHub ↗

RBP - Global function declared in Terrdata.h

Source from the content-addressed store, hash-verified

93
94//RBP - Global function declared in Terrdata.h
95TerrainBlock* getTerrainUnderWorldPoint(const Point3F & wPos)
96{
97 // Cast a ray straight down from the world position and see which
98 // Terrain is the closest to our starting point
99 Point3F startPnt = wPos;
100 Point3F endPnt = wPos + Point3F(0.0f, 0.0f, -10000.0f);
101
102 S32 blockIndex = -1;
103 F32 nearT = 1.0f;
104
105 SimpleQueryList queryList;
106 gServerContainer.findObjects( TerrainObjectType, SimpleQueryList::insertionCallback, &queryList);
107
108 for (U32 i = 0; i < queryList.mList.size(); i++)
109 {
110 Point3F tStartPnt, tEndPnt;
111 TerrainBlock* terrBlock = dynamic_cast<TerrainBlock*>(queryList.mList[i]);
112 terrBlock->getWorldTransform().mulP(startPnt, &tStartPnt);
113 terrBlock->getWorldTransform().mulP(endPnt, &tEndPnt);
114
115 RayInfo ri;
116 if (terrBlock->castRayI(tStartPnt, tEndPnt, &ri, true))
117 {
118 if (ri.t < nearT)
119 {
120 blockIndex = i;
121 nearT = ri.t;
122 }
123 }
124 }
125
126 if (blockIndex > -1)
127 return (TerrainBlock*)(queryList.mList[blockIndex]);
128
129 return NULL;
130}
131
132
133ConsoleDocFragment _getTerrainUnderWorldPoint1(

Callers 2

terrData.cppFile · 0.85
worldToGridMethod · 0.85

Calls 6

findObjectsMethod · 0.80
mulPMethod · 0.80
castRayIMethod · 0.80
Point3FClass · 0.50
sizeMethod · 0.45
getWorldTransformMethod · 0.45

Tested by

no test coverage detected