Merge branch 'method_Unmangle' into PBR_PR

This commit is contained in:
Azaezel 2018-12-12 14:54:22 -06:00
commit 1eed979a9c
632 changed files with 3935 additions and 3450 deletions

View file

@ -147,7 +147,7 @@ ConsoleDocFragment _getTerrainUnderWorldPoint2(
"bool getTerrainUnderWorldPoint( F32 x, F32 y, F32 z);"
);
DefineConsoleFunction( getTerrainUnderWorldPoint, S32, (const char* ptOrX, const char* y, const char* z), ("", ""),
DefineEngineFunction( 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"
@ -1338,7 +1338,7 @@ ConsoleDocFragment _getTerrainHeight2(
"bool getTerrainHeight( F32 x, F32 y);"
);
DefineConsoleFunction( getTerrainHeight, F32, (const char* ptOrX, const char* y), (""), "(Point2 pos) - gets the terrain height at the specified position."
DefineEngineFunction( 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")
@ -1383,7 +1383,7 @@ ConsoleDocFragment _getTerrainHeightBelowPosition2(
"bool getTerrainHeightBelowPosition( F32 x, F32 y);"
);
DefineConsoleFunction( getTerrainHeightBelowPosition, F32, (const char* ptOrX, const char* y, const char* z), ("", ""),
DefineEngineFunction( 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"

View file

@ -137,7 +137,7 @@ bool TerrainBlock::exportLayerMaps( const UTF8 *filePrefix, const String &format
return true;
}
DefineConsoleMethod( TerrainBlock, exportHeightMap, bool, (const char * fileNameStr, const char * format), ( "png"), "(string filename, [string format]) - export the terrain block's heightmap to a bitmap file (default: png)" )
DefineEngineMethod( TerrainBlock, exportHeightMap, bool, (const char * fileNameStr, const char * format), ( "png"), "(string filename, [string format]) - export the terrain block's heightmap to a bitmap file (default: png)" )
{
UTF8 fileName[1024];
Con::expandScriptFilename( fileName, sizeof( fileName ), fileNameStr );
@ -145,7 +145,7 @@ DefineConsoleMethod( TerrainBlock, exportHeightMap, bool, (const char * fileName
return object->exportHeightMap( fileName, format );
}
DefineConsoleMethod( TerrainBlock, exportLayerMaps, bool, (const char * filePrefixStr, const char * format), ( "png"), "(string filePrefix, [string format]) - export the terrain block's layer maps to bitmap files (default: png)" )
DefineEngineMethod( TerrainBlock, exportLayerMaps, bool, (const char * filePrefixStr, const char * format), ( "png"), "(string filePrefix, [string format]) - export the terrain block's layer maps to bitmap files (default: png)" )
{
UTF8 filePrefix[1024];
Con::expandScriptFilename( filePrefix, sizeof( filePrefix ), filePrefixStr );

View file

@ -33,15 +33,9 @@
using namespace Torque;
ConsoleStaticMethod( TerrainBlock, createNew, S32, 5, 5,
"TerrainBlock.create( String terrainName, U32 resolution, String materialName, bool genNoise )\n"
DefineEngineStaticMethod( TerrainBlock, createNew, S32, (String terrainName, U32 resolution, String materialName, bool genNoise),,
"" )
{
const UTF8 *terrainName = argv[1];
U32 resolution = dAtoi( argv[2] );
const UTF8 *materialName = argv[3];
bool genNoise = dAtob( argv[4] );
Vector<String> materials;
materials.push_back( materialName );
@ -82,17 +76,17 @@ ConsoleStaticMethod( TerrainBlock, createNew, S32, 5, 5,
noise.setSeed( 134208587 );
// Set up some defaults.
F32 octaves = 3.0f;
U32 freq = 4;
F32 roughness = 0.0f;
const F32 octaves = 3.0f;
const U32 freq = 4;
const F32 roughness = 0.0f;
noise.fBm( &floatHeights, blockSize, freq, 1.0f - roughness, octaves );
F32 height = 0;
F32 omax, omin;
noise.getMinMax( &floatHeights, &omin, &omax, blockSize );
F32 terrscale = 300.0f / (omax - omin);
const F32 terrscale = 300.0f / (omax - omin);
for ( S32 y = 0; y < blockSize; y++ )
{
for ( S32 x = 0; x < blockSize; x++ )
@ -111,7 +105,7 @@ ConsoleStaticMethod( TerrainBlock, createNew, S32, 5, 5,
terrain->updateGridMaterials( Point2I::Zero, Point2I( blockSize, blockSize ) );
}
terrain->registerObject( terrainName );
terrain->registerObject( terrainName.c_str() );
// Add to mission group!
SimGroup *missionGroup;
@ -121,21 +115,11 @@ ConsoleStaticMethod( TerrainBlock, createNew, S32, 5, 5,
return terrain->getId();
}
ConsoleStaticMethod( TerrainBlock, import, S32, 7, 8,
"( String terrainName, String heightMap, F32 metersPerPixel, F32 heightScale, String materials, String opacityLayers[, bool flipYAxis=true] )\n"
DefineEngineStaticMethod( TerrainBlock, import, S32, (String terrainName, String heightMapFile, F32 metersPerPixel, F32 heightScale, String opacityLayerFiles, String materialsStr, bool flipYAxis), (true),
"" )
{
// Get the parameters.
const UTF8 *terrainName = argv[1];
const UTF8 *hmap = argv[2];
F32 metersPerPixel = dAtof(argv[3]);
F32 heightScale = dAtof(argv[4]);
const UTF8 *opacityFiles = argv[5];
const UTF8 *materialsStr = argv[6];
bool flipYAxis = argc == 8? dAtob(argv[7]) : true;
// First load the height map and validate it.
Resource<GBitmap> heightmap = GBitmap::load( hmap );
Resource<GBitmap> heightmap = GBitmap::load(heightMapFile);
if ( !heightmap )
{
Con::errorf( "Heightmap failed to load!" );
@ -155,7 +139,7 @@ ConsoleStaticMethod( TerrainBlock, import, S32, 7, 8,
return 0;
}
U32 fileCount = StringUnit::getUnitCount( opacityFiles, "\n" );
U32 fileCount = StringUnit::getUnitCount(opacityLayerFiles, "\n" );
Vector<U8> layerMap;
layerMap.setSize( terrSize * terrSize );
{
@ -163,7 +147,7 @@ ConsoleStaticMethod( TerrainBlock, import, S32, 7, 8,
for ( U32 i = 0; i < fileCount; i++ )
{
String fileNameWithChannel = StringUnit::getUnit( opacityFiles, i, "\n" );
String fileNameWithChannel = StringUnit::getUnit(opacityLayerFiles, i, "\n" );
String fileName = StringUnit::getUnit( fileNameWithChannel, 0, "\t" );
String channel = StringUnit::getUnit( fileNameWithChannel, 1, "\t" );
@ -251,7 +235,7 @@ ConsoleStaticMethod( TerrainBlock, import, S32, 7, 8,
}
// Do we have an existing terrain with that name... then update it!
TerrainBlock *terrain = dynamic_cast<TerrainBlock*>( Sim::findObject( terrainName ) );
TerrainBlock *terrain = dynamic_cast<TerrainBlock*>( Sim::findObject( terrainName.c_str() ) );
if ( terrain )
terrain->import( (*heightmap), heightScale, metersPerPixel, layerMap, materials, flipYAxis );
else