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

Method worldToGrid

Engine/source/gui/worldEditor/terrainEditor.cpp:941–955  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

939}
940
941bool TerrainEditor::worldToGrid(const Point3F & wPos, GridPoint & gPoint)
942{
943 PROFILE_SCOPE( TerrainEditor_WorldToGrid );
944
945 // If the grid point TerrainBlock is NULL then find the closest Terrain underneath that
946 // point - pad a little upward in case our incoming point already lies exactly on the terrain
947 if (!gPoint.terrainBlock)
948 gPoint.terrainBlock = getTerrainUnderWorldPoint(wPos + Point3F(0.0f, 0.0f, 0.05f));
949
950 if (gPoint.terrainBlock == NULL)
951 return false;
952
953 gPoint.gridPos = gPoint.terrainBlock->getGridPos(wPos);
954 return isMainTile(gPoint);
955}
956
957bool TerrainEditor::worldToGrid(const Point3F & wPos, Point2I & gPos, TerrainBlock* terrain)
958{

Callers 2

setPositionMethod · 0.80
rebuildMethod · 0.80

Calls 3

getGridPosMethod · 0.80
Point3FClass · 0.50

Tested by

no test coverage detected