Consolidates and standardizes terrain creation between the editor, asset browser and creator panel

Also shifts terrain data importing into the new terrain asset window instead of separate in the File menu
Also removes redundant loadMaterials call that caused duplicates in the Terrain Painter material list
This commit is contained in:
Areloch 2020-12-28 23:43:56 -06:00
parent e9dba74891
commit f7ce1efd62
8 changed files with 104 additions and 125 deletions

View file

@ -117,7 +117,7 @@ DefineEngineStaticMethod( TerrainBlock, createNew, S32, (String terrainName, U32
return terrain->getId();
}
DefineEngineStaticMethod( TerrainBlock, import, S32, (String terrainName, String heightMapFile, F32 metersPerPixel, F32 heightScale, String opacityLayerFiles, String materialsStr, bool flipYAxis), (true),
DefineEngineStaticMethod( TerrainBlock, import, S32, (S32 terrainObjectId, String heightMapFile, F32 metersPerPixel, F32 heightScale, String opacityLayerFiles, String materialsStr, bool flipYAxis), (true),
"" )
{
// First load the height map and validate it.
@ -237,13 +237,12 @@ DefineEngineStaticMethod( TerrainBlock, import, S32, (String terrainName, String
}
// Do we have an existing terrain with that name... then update it!
TerrainBlock *terrain = dynamic_cast<TerrainBlock*>( Sim::findObject( terrainName.c_str() ) );
TerrainBlock *terrain = dynamic_cast<TerrainBlock*>( Sim::findObject( terrainObjectId ) );
if ( terrain )
terrain->import( (*heightmap), heightScale, metersPerPixel, layerMap, materials, flipYAxis );
else
{
terrain = new TerrainBlock();
terrain->assignName( terrainName );
terrain->import( (*heightmap), heightScale, metersPerPixel, layerMap, materials, flipYAxis );
terrain->registerObject();