BulletSim: add terrainImplementation parameter with default to Mesh.
parent
2dc7e9d3fa
commit
a59368c4a1
|
@ -1145,6 +1145,11 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
|
||||||
(s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].contactProcessingThreshold, p, l, v); },
|
(s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].contactProcessingThreshold, p, l, v); },
|
||||||
(s,o,v) => { BulletSimAPI.SetContactProcessingThreshold2(o.PhysBody.ptr, v); } ),
|
(s,o,v) => { BulletSimAPI.SetContactProcessingThreshold2(o.PhysBody.ptr, v); } ),
|
||||||
|
|
||||||
|
new ParameterDefn("TerrainImplementation", "Type of shape to use for terrain (0=heightmap, 1=mesh)",
|
||||||
|
(float)BSTerrainPhys.TerrainImplementation.Mesh,
|
||||||
|
(s,cf,p,v) => { s.m_params[0].terrainImplementation = cf.GetFloat(p,v); },
|
||||||
|
(s) => { return s.m_params[0].terrainImplementation; },
|
||||||
|
(s,p,l,v) => { s.m_params[0].terrainImplementation = v; } ),
|
||||||
new ParameterDefn("TerrainFriction", "Factor to reduce movement against terrain surface" ,
|
new ParameterDefn("TerrainFriction", "Factor to reduce movement against terrain surface" ,
|
||||||
0.5f,
|
0.5f,
|
||||||
(s,cf,p,v) => { s.m_params[0].terrainFriction = cf.GetFloat(p, v); },
|
(s,cf,p,v) => { s.m_params[0].terrainFriction = cf.GetFloat(p, v); },
|
||||||
|
|
|
@ -44,6 +44,12 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
||||||
// The physical implementation of the terrain is wrapped in this class.
|
// The physical implementation of the terrain is wrapped in this class.
|
||||||
public abstract class BSTerrainPhys : IDisposable
|
public abstract class BSTerrainPhys : IDisposable
|
||||||
{
|
{
|
||||||
|
public enum TerrainImplementation
|
||||||
|
{
|
||||||
|
Heightmap = 0,
|
||||||
|
Mesh = 1
|
||||||
|
}
|
||||||
|
|
||||||
public BSScene PhysicsScene { get; private set; }
|
public BSScene PhysicsScene { get; private set; }
|
||||||
// Base of the region in world coordinates. Coordinates inside the region are relative to this.
|
// Base of the region in world coordinates. Coordinates inside the region are relative to this.
|
||||||
public Vector3 TerrainBase { get; private set; }
|
public Vector3 TerrainBase { get; private set; }
|
||||||
|
@ -246,12 +252,27 @@ public sealed class BSTerrainManager
|
||||||
// Release any physical memory it may be using.
|
// Release any physical memory it may be using.
|
||||||
terrainPhys.Dispose();
|
terrainPhys.Dispose();
|
||||||
|
|
||||||
|
BSTerrainPhys newTerrainPhys = null; ;
|
||||||
if (MegaRegionParentPhysicsScene == null)
|
if (MegaRegionParentPhysicsScene == null)
|
||||||
{
|
{
|
||||||
// BSTerrainPhys newTerrainPhys = new BSTerrainHeightmap(PhysicsScene, terrainRegionBase, id,
|
// TODO: redo terrain implementation selection to be centralized (there is another
|
||||||
// heightMap, minCoords, maxCoords);
|
// use below) and to accept an asset specification (for a mesh).
|
||||||
BSTerrainPhys newTerrainPhys = new BSTerrainMesh(PhysicsScene, terrainRegionBase, id,
|
switch ((int)PhysicsScene.Params.terrainImplementation)
|
||||||
|
{
|
||||||
|
case (int)BSTerrainPhys.TerrainImplementation.Heightmap:
|
||||||
|
newTerrainPhys = new BSTerrainHeightmap(PhysicsScene, terrainRegionBase, id,
|
||||||
heightMap, minCoords, maxCoords);
|
heightMap, minCoords, maxCoords);
|
||||||
|
break;
|
||||||
|
case (int)BSTerrainPhys.TerrainImplementation.Mesh:
|
||||||
|
newTerrainPhys = new BSTerrainMesh(PhysicsScene, terrainRegionBase, id,
|
||||||
|
heightMap, minCoords, maxCoords);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
PhysicsScene.Logger.ErrorFormat("{0} Bad terrain implementation specified. type={1}/{2}",
|
||||||
|
LogHeader, (int)PhysicsScene.Params.terrainImplementation, PhysicsScene.Params.terrainImplementation);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
m_terrains.Add(terrainRegionBase, newTerrainPhys);
|
m_terrains.Add(terrainRegionBase, newTerrainPhys);
|
||||||
|
|
||||||
m_terrainModified = true;
|
m_terrainModified = true;
|
||||||
|
@ -292,8 +313,22 @@ public sealed class BSTerrainManager
|
||||||
{
|
{
|
||||||
DetailLog("{0},UpdateTerrain:NewTerrain,taint,baseX={1},baseY={2}",
|
DetailLog("{0},UpdateTerrain:NewTerrain,taint,baseX={1},baseY={2}",
|
||||||
BSScene.DetailLogZero, minCoordsX.X, minCoordsX.Y);
|
BSScene.DetailLogZero, minCoordsX.X, minCoordsX.Y);
|
||||||
BSTerrainPhys newTerrainPhys = new BSTerrainHeightmap(PhysicsScene, terrainRegionBase,
|
BSTerrainPhys newTerrainPhys = null;
|
||||||
newTerrainID, heightMapX, minCoordsX, maxCoordsX);
|
switch ((int)PhysicsScene.Params.terrainImplementation)
|
||||||
|
{
|
||||||
|
case (int)BSTerrainPhys.TerrainImplementation.Heightmap:
|
||||||
|
newTerrainPhys = new BSTerrainHeightmap(PhysicsScene, terrainRegionBase, id,
|
||||||
|
heightMap, minCoords, maxCoords);
|
||||||
|
break;
|
||||||
|
case (int)BSTerrainPhys.TerrainImplementation.Mesh:
|
||||||
|
newTerrainPhys = new BSTerrainMesh(PhysicsScene, terrainRegionBase, id,
|
||||||
|
heightMap, minCoords, maxCoords);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
PhysicsScene.Logger.ErrorFormat("{0} Bad terrain implementation specified. type={1}/{2}",
|
||||||
|
LogHeader, (int)PhysicsScene.Params.terrainImplementation, PhysicsScene.Params.terrainImplementation);
|
||||||
|
break;
|
||||||
|
}
|
||||||
m_terrains.Add(terrainRegionBase, newTerrainPhys);
|
m_terrains.Add(terrainRegionBase, newTerrainPhys);
|
||||||
|
|
||||||
m_terrainModified = true;
|
m_terrainModified = true;
|
||||||
|
|
|
@ -283,6 +283,7 @@ public struct ConfigurationParameters
|
||||||
public float ccdSweptSphereRadius;
|
public float ccdSweptSphereRadius;
|
||||||
public float contactProcessingThreshold;
|
public float contactProcessingThreshold;
|
||||||
|
|
||||||
|
public float terrainImplementation;
|
||||||
public float terrainFriction;
|
public float terrainFriction;
|
||||||
public float terrainHitFraction;
|
public float terrainHitFraction;
|
||||||
public float terrainRestitution;
|
public float terrainRestitution;
|
||||||
|
|
Loading…
Reference in New Issue