mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-24 14:49:27 +00:00
Fixes after feedback from Luis.
* Made use of dStrIsEmpty in more locations (and fixed it :P) * Removed commented-out code * Corrected default params * Fixed some console warning formats * Removed tabs * Corrected setExtent API
This commit is contained in:
parent
04ff04a95f
commit
3ab048c5b0
30 changed files with 130 additions and 110 deletions
|
|
@ -142,22 +142,28 @@ ConsoleDocFragment _getTerrainUnderWorldPoint2(
|
|||
"bool getTerrainUnderWorldPoint( F32 x, F32 y, F32 z);"
|
||||
);
|
||||
|
||||
DefineConsoleFunction( getTerrainUnderWorldPoint, S32, (Point3F position), ,
|
||||
DefineConsoleFunction( getTerrainUnderWorldPoint, S32, (const char* ptOrX, const char* y, const char* z), ("", ""),
|
||||
"(Point3F x/y/z) Gets the terrain block that is located under the given world point.\n"
|
||||
"@param x/y/z The world coordinates (floating point values) you wish to query at. "
|
||||
"These can be formatted as either a string (\"x y z\") or separately as (x, y, z)\n"
|
||||
"@return Returns the ID of the requested terrain block (0 if not found).\n\n"
|
||||
"@hide")
|
||||
"@hide")
|
||||
{
|
||||
|
||||
TerrainBlock* terrain = getTerrainUnderWorldPoint(position);
|
||||
Point3F pos;
|
||||
if(!dStrIsEmpty(ptOrX) && dStrIsEmpty(y) && dStrIsEmpty(z))
|
||||
dSscanf(ptOrX, "%f %f %f", &pos.x, &pos.y, &pos.z);
|
||||
else if(!dStrIsEmpty(ptOrX) && !dStrIsEmpty(y) && !dStrIsEmpty(z))
|
||||
{
|
||||
pos.x = dAtof(ptOrX);
|
||||
pos.y = dAtof(y);
|
||||
pos.z = dAtof(z);
|
||||
}
|
||||
TerrainBlock* terrain = getTerrainUnderWorldPoint(pos);
|
||||
if(terrain != NULL)
|
||||
{
|
||||
return terrain->getId();
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1313,24 +1319,31 @@ ConsoleDocFragment _getTerrainHeight2(
|
|||
"bool getTerrainHeight( F32 x, F32 y);"
|
||||
);
|
||||
|
||||
DefineConsoleFunction( getTerrainHeight, F32, (Point2F pos), , "(Point2 pos) - gets the terrain height at the specified position."
|
||||
DefineConsoleFunction( getTerrainHeight, F32, (const char* ptOrX, const char* y), (""), "(Point2 pos) - gets the terrain height at the specified position."
|
||||
"@param pos The world space point, minus the z (height) value\n Can be formatted as either (\"x y\") or (x,y)\n"
|
||||
"@return Returns the terrain height at the given point as an F32 value.\n"
|
||||
"@hide")
|
||||
{
|
||||
F32 height = 0.0f;
|
||||
F32 height = 0.0f;
|
||||
|
||||
Point2F pos;
|
||||
if(!dStrIsEmpty(ptOrX) && dStrIsEmpty(y))
|
||||
dSscanf(ptOrX, "%f %f", &pos.x, &pos.y);
|
||||
else if(!dStrIsEmpty(ptOrX) && !dStrIsEmpty(y))
|
||||
{
|
||||
pos.x = dAtof(ptOrX);
|
||||
pos.y = dAtof(y);
|
||||
}
|
||||
|
||||
TerrainBlock * terrain = getTerrainUnderWorldPoint(Point3F(pos.x, pos.y, 5000.0f));
|
||||
if(terrain)
|
||||
if(terrain->isServerObject())
|
||||
{
|
||||
Point3F offset;
|
||||
terrain->getTransform().getColumn(3, &offset);
|
||||
pos -= Point2F(offset.x, offset.y);
|
||||
terrain->getHeight(pos, &height);
|
||||
}
|
||||
return height;
|
||||
TerrainBlock * terrain = getTerrainUnderWorldPoint(Point3F(pos.x, pos.y, 5000.0f));
|
||||
if(terrain && terrain->isServerObject())
|
||||
{
|
||||
Point3F offset;
|
||||
terrain->getTransform().getColumn(3, &offset);
|
||||
pos -= Point2F(offset.x, offset.y);
|
||||
terrain->getHeight(pos, &height);
|
||||
}
|
||||
return height;
|
||||
}
|
||||
|
||||
ConsoleDocFragment _getTerrainHeightBelowPosition1(
|
||||
|
|
@ -1351,7 +1364,7 @@ ConsoleDocFragment _getTerrainHeightBelowPosition2(
|
|||
"bool getTerrainHeightBelowPosition( F32 x, F32 y);"
|
||||
);
|
||||
|
||||
DefineConsoleFunction( getTerrainHeightBelowPosition, F32, (Point3F pos), ,
|
||||
DefineConsoleFunction( getTerrainHeightBelowPosition, F32, (const char* ptOrX, const char* y, const char* z), ("", ""),
|
||||
"(Point3F pos) - gets the terrain height at the specified position."
|
||||
"@param pos The world space point. Can be formatted as either (\"x y z\") or (x,y,z)\n"
|
||||
"@note This function is useful if you simply want to grab the terrain height underneath an object.\n"
|
||||
|
|
@ -1360,6 +1373,15 @@ DefineConsoleFunction( getTerrainHeightBelowPosition, F32, (Point3F pos), ,
|
|||
{
|
||||
F32 height = 0.0f;
|
||||
|
||||
Point3F pos;
|
||||
if(!dStrIsEmpty(ptOrX) && dStrIsEmpty(y) && dStrIsEmpty(z))
|
||||
dSscanf(ptOrX, "%f %f %f", &pos.x, &pos.y, &pos.z);
|
||||
else if(!dStrIsEmpty(ptOrX) && !dStrIsEmpty(y) && !dStrIsEmpty(z))
|
||||
{
|
||||
pos.x = dAtof(ptOrX);
|
||||
pos.y = dAtof(y);
|
||||
pos.z = dAtof(z);
|
||||
}
|
||||
|
||||
TerrainBlock * terrain = getTerrainUnderWorldPoint(pos);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue