RBP - Global function declared in Terrdata.h
| 93 | |
| 94 | //RBP - Global function declared in Terrdata.h |
| 95 | TerrainBlock* 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 | |
| 133 | ConsoleDocFragment _getTerrainUnderWorldPoint1( |
no test coverage detected