From 96dce3e16c3c0b861e42e6331f693b6b00a14392 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Mon, 29 Aug 2011 10:00:58 -0700 Subject: Use GetMeshKey from PrimitiveBaseShape. --- OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 22 +++++++++++++++------- OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 16 ++++++++-------- 2 files changed, 23 insertions(+), 15 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index d1fb576..bb8d601 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs @@ -53,8 +53,11 @@ public sealed class BSPrim : PhysicsActor private String _avName; private uint _localID = 0; - private OMV.Vector3 _size; - private OMV.Vector3 _scale; + // _size is what the user passed. _scale is what we pass to the physics engine with the mesh. + // Often _scale is unity because the meshmerizer will apply _size when creating the mesh. + private OMV.Vector3 _size; // the multiplier for each mesh dimension as passed by the user + private OMV.Vector3 _scale; // the multiplier for each mesh dimension for the mesh as created by the meshmerizer + private bool _stopped; private bool _grabbed; private bool _isSelected; @@ -460,6 +463,7 @@ public sealed class BSPrim : PhysicsActor // no locking here because only called when it is safe private void SetObjectDynamic() { + // m_log.DebugFormat("{0}: ID={1}, SetObjectDynamic: IsStatic={2}, IsSolid={3}", LogHeader, _localID, IsStatic, IsSolid); // non-physical things work best with a mass of zero if (IsStatic) { @@ -474,7 +478,6 @@ public sealed class BSPrim : PhysicsActor } BulletSimAPI.SetObjectProperties(_scene.WorldID, LocalID, IsStatic, IsSolid, SubscribedEvents(), _mass); - // m_log.DebugFormat("{0}: ID={1}, SetObjectDynamic: IsStatic={2}, IsSolid={3}, mass={4}", LogHeader, _localID, IsStatic, IsSolid, _mass); } // prims don't fly @@ -955,7 +958,9 @@ public sealed class BSPrim : PhysicsActor // No locking here because this is done when we know physics is not simulating private void CreateGeomMesh() { - ulong newMeshKey = (ulong)_pbs.GetHashCode(); + float lod = _pbs.SculptEntry ? _scene.SculptLOD : _scene.MeshLOD; + ulong newMeshKey = (ulong)_pbs.GetMeshKey(_size, lod); + // m_log.DebugFormat("{0}: CreateGeomMesh: lID={1}, oldKey={2}, newKey={3}", LogHeader, _localID, _meshKey, newMeshKey); // if this new shape is the same as last time, don't recreate the mesh if (_meshKey == newMeshKey) return; @@ -963,14 +968,13 @@ public sealed class BSPrim : PhysicsActor // Since we're recreating new, get rid of any previously generated shape if (_meshKey != 0) { - // m_log.DebugFormat("{0}: CreateGeom: deleting old hull. Key={1}", LogHeader, _meshKey); + // m_log.DebugFormat("{0}: CreateGeom: deleting old mesh. lID={1}, Key={2}", LogHeader, _localID, _meshKey); BulletSimAPI.DestroyMesh(_scene.WorldID, _meshKey); _mesh = null; _meshKey = 0; } _meshKey = newMeshKey; - int lod = _pbs.SculptEntry ? _scene.SculptLOD : _scene.MeshLOD; // always pass false for physicalness as this creates some sort of bounding box which we don't need _mesh = _scene.mesher.CreateMesh(_avName, _pbs, _size, lod, false); @@ -1001,7 +1005,9 @@ public sealed class BSPrim : PhysicsActor // No locking here because this is done when we know physics is not simulating private void CreateGeomHull() { - ulong newHullKey = (ulong)_pbs.GetHashCode(); + float lod = _pbs.SculptEntry ? _scene.SculptLOD : _scene.MeshLOD; + ulong newHullKey = (ulong)_pbs.GetMeshKey(_size, lod); + // m_log.DebugFormat("{0}: CreateGeomHull: lID={1}, oldKey={2}, newKey={3}", LogHeader, _localID, _hullKey, newHullKey); // if the hull hasn't changed, don't rebuild it if (newHullKey == _hullKey) return; @@ -1136,6 +1142,7 @@ public sealed class BSPrim : PhysicsActor // the mesh or hull must have already been created in Bullet ShapeData shape; FillShapeInfo(out shape); + // m_log.DebugFormat("{0}: CreateObject: lID={1}, shape={2}", LogHeader, _localID, shape.Type); BulletSimAPI.CreateObject(_scene.WorldID, shape); } } @@ -1227,6 +1234,7 @@ public sealed class BSPrim : PhysicsActor // No locking here because this is done when the physics engine is not simulating private void RecreateGeomAndObject() { + // m_log.DebugFormat("{0}: RecreateGeomAndObject. lID={1}", LogHeader, _localID); CreateGeom(true); CreateObject(); return; diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index e91455a..7704002 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -73,13 +73,13 @@ public class BSScene : PhysicsScene, IPhysicsParameters private bool m_initialized = false; public IMesher mesher; - private int m_meshLOD; - public int MeshLOD + private float m_meshLOD; + public float MeshLOD { get { return m_meshLOD; } } - private int m_sculptLOD; - public int SculptLOD + private float m_sculptLOD; + public float SculptLOD { get { return m_sculptLOD; } } @@ -189,8 +189,8 @@ public class BSScene : PhysicsScene, IPhysicsParameters _meshSculptedPrim = true; // mesh sculpted prims _forceSimplePrimMeshing = false; // use complex meshing if called for - m_meshLOD = 8; - m_sculptLOD = 32; + m_meshLOD = 8f; + m_sculptLOD = 32f; m_maxSubSteps = 10; m_fixedTimeStep = 1f / 60f; @@ -231,8 +231,8 @@ public class BSScene : PhysicsScene, IPhysicsParameters _meshSculptedPrim = pConfig.GetBoolean("MeshSculptedPrim", _meshSculptedPrim); _forceSimplePrimMeshing = pConfig.GetBoolean("ForceSimplePrimMeshing", _forceSimplePrimMeshing); - m_meshLOD = pConfig.GetInt("MeshLevelOfDetail", m_meshLOD); - m_sculptLOD = pConfig.GetInt("SculptLevelOfDetail", m_sculptLOD); + m_meshLOD = pConfig.GetFloat("MeshLevelOfDetail", m_meshLOD); + m_sculptLOD = pConfig.GetFloat("SculptLevelOfDetail", m_sculptLOD); m_maxSubSteps = pConfig.GetInt("MaxSubSteps", m_maxSubSteps); m_fixedTimeStep = pConfig.GetFloat("FixedTimeStep", m_fixedTimeStep); -- cgit v1.1