From 376441e5507052b36279279f64896542d44ec12a Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Wed, 15 Aug 2012 16:27:30 -0700 Subject: BulletSim: make it so objects in a linkset do not generate collisions with each other. --- OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSScene.cs') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index a31c578..0a0e27e 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -78,10 +78,16 @@ public class BSScene : PhysicsScene, IPhysicsParameters public string BulletSimVersion = "?"; private Dictionary m_avatars = new Dictionary(); + public Dictionary Characters { get { return m_avatars; } } + private Dictionary m_prims = new Dictionary(); + public Dictionary Prims { get { return m_prims; } } + private HashSet m_avatarsWithCollisions = new HashSet(); private HashSet m_primsWithCollisions = new HashSet(); + private List m_vehicles = new List(); + private float[] m_heightMap; private float m_waterLevel; private uint m_worldID; @@ -429,13 +435,13 @@ public class BSScene : PhysicsScene, IPhysicsParameters { numSubSteps = BulletSimAPI.PhysicsStep(m_worldID, timeStep, m_maxSubSteps, m_fixedTimeStep, out updatedEntityCount, out updatedEntitiesPtr, out collidersCount, out collidersPtr); - // DetailLog("{0},Simulate,call, substeps={1}, updates={2}, colliders={3}", DetailLogZero, numSubSteps, updatedEntityCount, collidersCount); + DetailLog("{0},Simulate,call, substeps={1}, updates={2}, colliders={3}", DetailLogZero, numSubSteps, updatedEntityCount, collidersCount); } catch (Exception e) { m_log.WarnFormat("{0},PhysicsStep Exception: substeps={1}, updates={2}, colliders={3}, e={4}", LogHeader, numSubSteps, updatedEntityCount, collidersCount, e); // DetailLog("{0},PhysicsStepException,call, substeps={1}, updates={2}, colliders={3}", DetailLogZero, numSubSteps, updatedEntityCount, collidersCount); - // updatedEntityCount = 0; + updatedEntityCount = 0; collidersCount = 0; } @@ -534,6 +540,8 @@ public class BSScene : PhysicsScene, IPhysicsParameters else if (m_avatars.ContainsKey(collidingWith)) type = ActorTypes.Agent; + DetailLog("{0},BSScene.SendCollision,collide,id={1},with={2}", DetailLogZero, localID, collidingWith); + BSPrim prim; if (m_prims.TryGetValue(localID, out prim)) { prim.Collide(collidingWith, type, collidePoint, collideNormal, penitration); -- cgit v1.1 From ccc69d66a135e149dbe9c6b70df0c8efe1265f65 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Fri, 17 Aug 2012 10:40:34 -0700 Subject: BulletSim: add parameters and functionality to specify the mesh level of detail for large meshes. Remove parameter and code for DetailLog (conditional logging into regular log file). --- OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 54 ++++++++++++------------- 1 file changed, 26 insertions(+), 28 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSScene.cs') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 0a0e27e..d901ff0 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -73,8 +73,6 @@ public class BSScene : PhysicsScene, IPhysicsParameters private static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly string LogHeader = "[BULLETS SCENE]"; - public void DebugLog(string mm, params Object[] xx) { if (ShouldDebugLog) m_log.DebugFormat(mm, xx); } - public string BulletSimVersion = "?"; private Dictionary m_avatars = new Dictionary(); @@ -101,16 +99,11 @@ public class BSScene : PhysicsScene, IPhysicsParameters private int m_detailedStatsStep = 0; public IMesher mesher; - private float m_meshLOD; - public float MeshLOD - { - get { return m_meshLOD; } - } - private float m_sculptLOD; - public float SculptLOD - { - get { return m_sculptLOD; } - } + // Level of Detail values kept as float because that's what the Meshmerizer wants + public float MeshLOD { get; private set; } + public float MeshMegaPrimLOD { get; private set; } + public float MeshMegaPrimThreshold { get; private set; } + public float SculptLOD { get; private set; } private BulletSim m_worldSim; public BulletSim World @@ -185,8 +178,9 @@ public class BSScene : PhysicsScene, IPhysicsParameters ConfigurationParameters[] m_params; GCHandle m_paramsHandle; - public bool ShouldDebugLog { get; private set; } - + // Handle to the callback used by the unmanaged code to call into the managed code. + // Used for debug logging. + // Need to store the handle in a persistant variable so it won't be freed. private BulletSimAPI.DebugLogCallback m_DebugLogCallbackHandle; // Sometimes you just have to log everything. @@ -905,16 +899,26 @@ public class BSScene : PhysicsScene, IPhysicsParameters (s) => { return s.NumericBool(s._forceSimplePrimMeshing); }, (s,p,l,v) => { s._forceSimplePrimMeshing = s.BoolNumeric(v); } ), - new ParameterDefn("MeshLOD", "Level of detail to render meshes (32, 16, 8 or 4. 32=most detailed)", + new ParameterDefn("MeshLevelOfDetail", "Level of detail to render meshes (32, 16, 8 or 4. 32=most detailed)", 8f, - (s,cf,p,v) => { s.m_meshLOD = cf.GetInt(p, (int)v); }, - (s) => { return (float)s.m_meshLOD; }, - (s,p,l,v) => { s.m_meshLOD = (int)v; } ), - new ParameterDefn("SculptLOD", "Level of detail to render sculpties (32, 16, 8 or 4. 32=most detailed)", + (s,cf,p,v) => { s.MeshLOD = (float)cf.GetInt(p, (int)v); }, + (s) => { return s.MeshLOD; }, + (s,p,l,v) => { s.MeshLOD = v; } ), + new ParameterDefn("MeshLevelOfDetailMegaPrim", "Level of detail to render meshes larger than threshold meters", + 16f, + (s,cf,p,v) => { s.MeshMegaPrimLOD = (float)cf.GetInt(p, (int)v); }, + (s) => { return s.MeshMegaPrimLOD; }, + (s,p,l,v) => { s.MeshMegaPrimLOD = v; } ), + new ParameterDefn("MeshLevelOfDetailMegaPrimThreshold", "Size (in meters) of a mesh before using MeshMegaPrimLOD", + 10f, + (s,cf,p,v) => { s.MeshMegaPrimThreshold = (float)cf.GetInt(p, (int)v); }, + (s) => { return s.MeshMegaPrimThreshold; }, + (s,p,l,v) => { s.MeshMegaPrimThreshold = v; } ), + new ParameterDefn("SculptLevelOfDetail", "Level of detail to render sculpties (32, 16, 8 or 4. 32=most detailed)", 32f, - (s,cf,p,v) => { s.m_sculptLOD = cf.GetInt(p, (int)v); }, - (s) => { return (float)s.m_sculptLOD; }, - (s,p,l,v) => { s.m_sculptLOD = (int)v; } ), + (s,cf,p,v) => { s.SculptLOD = (float)cf.GetInt(p, (int)v); }, + (s) => { return s.SculptLOD; }, + (s,p,l,v) => { s.SculptLOD = v; } ), new ParameterDefn("MaxSubStep", "In simulation step, maximum number of substeps", 10f, @@ -1145,12 +1149,6 @@ public class BSScene : PhysicsScene, IPhysicsParameters (s,cf,p,v) => { s.m_detailedStatsStep = cf.GetInt(p, (int)v); }, (s) => { return (float)s.m_detailedStatsStep; }, (s,p,l,v) => { s.m_detailedStatsStep = (int)v; } ), - new ParameterDefn("ShouldDebugLog", "Enables detailed DEBUG log statements", - ConfigurationParameters.numericFalse, - (s,cf,p,v) => { s.ShouldDebugLog = cf.GetBoolean(p, s.BoolNumeric(v)); }, - (s) => { return s.NumericBool(s.ShouldDebugLog); }, - (s,p,l,v) => { s.ShouldDebugLog = s.BoolNumeric(v); } ), - }; // Convert a boolean to our numeric true and false values -- cgit v1.1 From 03d76e94034bbaa82d1872284d1fadbaa263411d Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Fri, 17 Aug 2012 13:30:46 -0700 Subject: BulletSim: restore most of the Detail logging statements. Will have no effect on non-logging running. Capture region name that is passed to the physics engine and use it for detail logging file name prefix. Fix problem with avatars dropping when flying across region boundries. --- OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSScene.cs') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index d901ff0..56924aa 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -73,6 +73,9 @@ public class BSScene : PhysicsScene, IPhysicsParameters private static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly string LogHeader = "[BULLETS SCENE]"; + // The name of the region we're working for. + public string RegionName { get; private set; } + public string BulletSimVersion = "?"; private Dictionary m_avatars = new Dictionary(); @@ -196,6 +199,8 @@ public class BSScene : PhysicsScene, IPhysicsParameters public BSScene(string identifier) { m_initialized = false; + // we are passed the name of the region we're working for. + RegionName = identifier; } public override void Initialise(IMesher meshmerizer, IConfigSource config) @@ -281,10 +286,13 @@ public class BSScene : PhysicsScene, IPhysicsParameters // Very detailed logging for physics debugging m_physicsLoggingEnabled = pConfig.GetBoolean("PhysicsLoggingEnabled", false); m_physicsLoggingDir = pConfig.GetString("PhysicsLoggingDir", "."); - m_physicsLoggingPrefix = pConfig.GetString("PhysicsLoggingPrefix", "physics-"); + m_physicsLoggingPrefix = pConfig.GetString("PhysicsLoggingPrefix", "physics-%REGIONNAME%-"); m_physicsLoggingFileMinutes = pConfig.GetInt("PhysicsLoggingFileMinutes", 5); // Very detailed logging for vehicle debugging m_vehicleLoggingEnabled = pConfig.GetBoolean("VehicleLoggingEnabled", false); + + // Do any replacements in the parameters + m_physicsLoggingPrefix = m_physicsLoggingPrefix.Replace("%REGIONNAME%", RegionName); } } } @@ -362,7 +370,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters BSPrim bsprim = prim as BSPrim; if (bsprim != null) { - // DetailLog("{0},RemovePrim,call", bsprim.LocalID); + DetailLog("{0},RemovePrim,call", bsprim.LocalID); // m_log.DebugFormat("{0}: RemovePrim. id={1}/{2}", LogHeader, bsprim.Name, bsprim.LocalID); try { @@ -388,7 +396,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters if (!m_initialized) return null; - // DetailLog("{0},AddPrimShape,call", localID); + DetailLog("{0},AddPrimShape,call", localID); BSPrim prim = new BSPrim(localID, primName, this, position, size, rotation, pbs, isPhysical); lock (m_prims) m_prims.Add(localID, prim); @@ -534,7 +542,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters else if (m_avatars.ContainsKey(collidingWith)) type = ActorTypes.Agent; - DetailLog("{0},BSScene.SendCollision,collide,id={1},with={2}", DetailLogZero, localID, collidingWith); + // DetailLog("{0},BSScene.SendCollision,collide,id={1},with={2}", DetailLogZero, localID, collidingWith); BSPrim prim; if (m_prims.TryGetValue(localID, out prim)) { -- cgit v1.1