BulletSim: default physical terrain implementation to heightmap.

It originally looked like mesh terrain would perform better for vehicles
but, after much use, heightmap is the clear winner.
Force terrain implementation to heightmap if the physics region is
larger than legacy region size. This solves running out of memory for
very large regions.
0.8.0.3
Robert Adams 2014-01-29 06:44:14 -08:00
parent fbf33ef1de
commit 0842e2e15b
3 changed files with 11 additions and 3 deletions

View File

@ -538,7 +538,7 @@ public static class BSParam
(s,o) => { s.PE.SetContactProcessingThreshold(o.PhysBody, ContactProcessingThreshold); } ), (s,o) => { s.PE.SetContactProcessingThreshold(o.PhysBody, ContactProcessingThreshold); } ),
new ParameterDefn<float>("TerrainImplementation", "Type of shape to use for terrain (0=heightmap, 1=mesh)", new ParameterDefn<float>("TerrainImplementation", "Type of shape to use for terrain (0=heightmap, 1=mesh)",
(float)BSTerrainPhys.TerrainImplementation.Mesh ), (float)BSTerrainPhys.TerrainImplementation.Heightmap ),
new ParameterDefn<int>("TerrainMeshMagnification", "Number of times the 256x256 heightmap is multiplied to create the terrain mesh" , new ParameterDefn<int>("TerrainMeshMagnification", "Number of times the 256x256 heightmap is multiplied to create the terrain mesh" ,
2 ), 2 ),
new ParameterDefn<float>("TerrainFriction", "Factor to reduce movement against terrain surface" , new ParameterDefn<float>("TerrainFriction", "Factor to reduce movement against terrain surface" ,

View File

@ -235,6 +235,14 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
// Set default values for physics parameters plus any overrides from the ini file // Set default values for physics parameters plus any overrides from the ini file
GetInitialParameterValues(config); GetInitialParameterValues(config);
// Force some parameters to values depending on other configurations
// Only use heightmap terrain implementation if terrain larger than legacy size
if ((uint)regionExtent.X > Constants.RegionSize || (uint)regionExtent.Y > Constants.RegionSize)
{
m_log.WarnFormat("{0} Forcing terrain implementation to heightmap for large region", LogHeader);
BSParam.TerrainImplementation = (float)BSTerrainPhys.TerrainImplementation.Heightmap;
}
// Get the connection to the physics engine (could be native or one of many DLLs) // Get the connection to the physics engine (could be native or one of many DLLs)
PE = SelectUnderlyingBulletEngine(BulletEngineName); PE = SelectUnderlyingBulletEngine(BulletEngineName);

View File

@ -1001,10 +1001,10 @@
; Terrain implementation can use either Bullet's heightField or BulletSim can build ; Terrain implementation can use either Bullet's heightField or BulletSim can build
; a mesh. 0=heightField, 1=mesh ; a mesh. 0=heightField, 1=mesh
TerrainImplementation = 1 TerrainImplementation = 0
; For mesh terrain, the detail of the created mesh. '1' gives 256x256 (heightfield ; For mesh terrain, the detail of the created mesh. '1' gives 256x256 (heightfield
; resolution). '2' gives 512x512. Etc. Cannot be larger than '4'. Higher ; resolution). '2' gives 512x512. Etc. Cannot be larger than '4'. Higher
; magnification uses lots of memory. ; magnifications use lots of memory.
TerrainMeshMagnification = 2 TerrainMeshMagnification = 2
; Avatar physics height adjustments. ; Avatar physics height adjustments.