aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorRobert Adams2011-08-29 10:00:58 -0700
committerMic Bowman2011-08-29 10:10:48 -0700
commit96dce3e16c3c0b861e42e6331f693b6b00a14392 (patch)
tree8910d3e3adf91cc26e9b4c3013b1c7d9a3c098a6
parentMerge branch 'master' into bulletsim (diff)
downloadopensim-SC-96dce3e16c3c0b861e42e6331f693b6b00a14392.zip
opensim-SC-96dce3e16c3c0b861e42e6331f693b6b00a14392.tar.gz
opensim-SC-96dce3e16c3c0b861e42e6331f693b6b00a14392.tar.bz2
opensim-SC-96dce3e16c3c0b861e42e6331f693b6b00a14392.tar.xz
Use GetMeshKey from PrimitiveBaseShape.
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs22
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSScene.cs16
2 files changed, 23 insertions, 15 deletions
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
53 private String _avName; 53 private String _avName;
54 private uint _localID = 0; 54 private uint _localID = 0;
55 55
56 private OMV.Vector3 _size; 56 // _size is what the user passed. _scale is what we pass to the physics engine with the mesh.
57 private OMV.Vector3 _scale; 57 // Often _scale is unity because the meshmerizer will apply _size when creating the mesh.
58 private OMV.Vector3 _size; // the multiplier for each mesh dimension as passed by the user
59 private OMV.Vector3 _scale; // the multiplier for each mesh dimension for the mesh as created by the meshmerizer
60
58 private bool _stopped; 61 private bool _stopped;
59 private bool _grabbed; 62 private bool _grabbed;
60 private bool _isSelected; 63 private bool _isSelected;
@@ -460,6 +463,7 @@ public sealed class BSPrim : PhysicsActor
460 // no locking here because only called when it is safe 463 // no locking here because only called when it is safe
461 private void SetObjectDynamic() 464 private void SetObjectDynamic()
462 { 465 {
466 // m_log.DebugFormat("{0}: ID={1}, SetObjectDynamic: IsStatic={2}, IsSolid={3}", LogHeader, _localID, IsStatic, IsSolid);
463 // non-physical things work best with a mass of zero 467 // non-physical things work best with a mass of zero
464 if (IsStatic) 468 if (IsStatic)
465 { 469 {
@@ -474,7 +478,6 @@ public sealed class BSPrim : PhysicsActor
474 478
475 } 479 }
476 BulletSimAPI.SetObjectProperties(_scene.WorldID, LocalID, IsStatic, IsSolid, SubscribedEvents(), _mass); 480 BulletSimAPI.SetObjectProperties(_scene.WorldID, LocalID, IsStatic, IsSolid, SubscribedEvents(), _mass);
477 // m_log.DebugFormat("{0}: ID={1}, SetObjectDynamic: IsStatic={2}, IsSolid={3}, mass={4}", LogHeader, _localID, IsStatic, IsSolid, _mass);
478 } 481 }
479 482
480 // prims don't fly 483 // prims don't fly
@@ -955,7 +958,9 @@ public sealed class BSPrim : PhysicsActor
955 // No locking here because this is done when we know physics is not simulating 958 // No locking here because this is done when we know physics is not simulating
956 private void CreateGeomMesh() 959 private void CreateGeomMesh()
957 { 960 {
958 ulong newMeshKey = (ulong)_pbs.GetHashCode(); 961 float lod = _pbs.SculptEntry ? _scene.SculptLOD : _scene.MeshLOD;
962 ulong newMeshKey = (ulong)_pbs.GetMeshKey(_size, lod);
963 // m_log.DebugFormat("{0}: CreateGeomMesh: lID={1}, oldKey={2}, newKey={3}", LogHeader, _localID, _meshKey, newMeshKey);
959 964
960 // if this new shape is the same as last time, don't recreate the mesh 965 // if this new shape is the same as last time, don't recreate the mesh
961 if (_meshKey == newMeshKey) return; 966 if (_meshKey == newMeshKey) return;
@@ -963,14 +968,13 @@ public sealed class BSPrim : PhysicsActor
963 // Since we're recreating new, get rid of any previously generated shape 968 // Since we're recreating new, get rid of any previously generated shape
964 if (_meshKey != 0) 969 if (_meshKey != 0)
965 { 970 {
966 // m_log.DebugFormat("{0}: CreateGeom: deleting old hull. Key={1}", LogHeader, _meshKey); 971 // m_log.DebugFormat("{0}: CreateGeom: deleting old mesh. lID={1}, Key={2}", LogHeader, _localID, _meshKey);
967 BulletSimAPI.DestroyMesh(_scene.WorldID, _meshKey); 972 BulletSimAPI.DestroyMesh(_scene.WorldID, _meshKey);
968 _mesh = null; 973 _mesh = null;
969 _meshKey = 0; 974 _meshKey = 0;
970 } 975 }
971 976
972 _meshKey = newMeshKey; 977 _meshKey = newMeshKey;
973 int lod = _pbs.SculptEntry ? _scene.SculptLOD : _scene.MeshLOD;
974 // always pass false for physicalness as this creates some sort of bounding box which we don't need 978 // always pass false for physicalness as this creates some sort of bounding box which we don't need
975 _mesh = _scene.mesher.CreateMesh(_avName, _pbs, _size, lod, false); 979 _mesh = _scene.mesher.CreateMesh(_avName, _pbs, _size, lod, false);
976 980
@@ -1001,7 +1005,9 @@ public sealed class BSPrim : PhysicsActor
1001 // No locking here because this is done when we know physics is not simulating 1005 // No locking here because this is done when we know physics is not simulating
1002 private void CreateGeomHull() 1006 private void CreateGeomHull()
1003 { 1007 {
1004 ulong newHullKey = (ulong)_pbs.GetHashCode(); 1008 float lod = _pbs.SculptEntry ? _scene.SculptLOD : _scene.MeshLOD;
1009 ulong newHullKey = (ulong)_pbs.GetMeshKey(_size, lod);
1010 // m_log.DebugFormat("{0}: CreateGeomHull: lID={1}, oldKey={2}, newKey={3}", LogHeader, _localID, _hullKey, newHullKey);
1005 1011
1006 // if the hull hasn't changed, don't rebuild it 1012 // if the hull hasn't changed, don't rebuild it
1007 if (newHullKey == _hullKey) return; 1013 if (newHullKey == _hullKey) return;
@@ -1136,6 +1142,7 @@ public sealed class BSPrim : PhysicsActor
1136 // the mesh or hull must have already been created in Bullet 1142 // the mesh or hull must have already been created in Bullet
1137 ShapeData shape; 1143 ShapeData shape;
1138 FillShapeInfo(out shape); 1144 FillShapeInfo(out shape);
1145 // m_log.DebugFormat("{0}: CreateObject: lID={1}, shape={2}", LogHeader, _localID, shape.Type);
1139 BulletSimAPI.CreateObject(_scene.WorldID, shape); 1146 BulletSimAPI.CreateObject(_scene.WorldID, shape);
1140 } 1147 }
1141 } 1148 }
@@ -1227,6 +1234,7 @@ public sealed class BSPrim : PhysicsActor
1227 // No locking here because this is done when the physics engine is not simulating 1234 // No locking here because this is done when the physics engine is not simulating
1228 private void RecreateGeomAndObject() 1235 private void RecreateGeomAndObject()
1229 { 1236 {
1237 // m_log.DebugFormat("{0}: RecreateGeomAndObject. lID={1}", LogHeader, _localID);
1230 CreateGeom(true); 1238 CreateGeom(true);
1231 CreateObject(); 1239 CreateObject();
1232 return; 1240 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
73 private bool m_initialized = false; 73 private bool m_initialized = false;
74 74
75 public IMesher mesher; 75 public IMesher mesher;
76 private int m_meshLOD; 76 private float m_meshLOD;
77 public int MeshLOD 77 public float MeshLOD
78 { 78 {
79 get { return m_meshLOD; } 79 get { return m_meshLOD; }
80 } 80 }
81 private int m_sculptLOD; 81 private float m_sculptLOD;
82 public int SculptLOD 82 public float SculptLOD
83 { 83 {
84 get { return m_sculptLOD; } 84 get { return m_sculptLOD; }
85 } 85 }
@@ -189,8 +189,8 @@ public class BSScene : PhysicsScene, IPhysicsParameters
189 _meshSculptedPrim = true; // mesh sculpted prims 189 _meshSculptedPrim = true; // mesh sculpted prims
190 _forceSimplePrimMeshing = false; // use complex meshing if called for 190 _forceSimplePrimMeshing = false; // use complex meshing if called for
191 191
192 m_meshLOD = 8; 192 m_meshLOD = 8f;
193 m_sculptLOD = 32; 193 m_sculptLOD = 32f;
194 194
195 m_maxSubSteps = 10; 195 m_maxSubSteps = 10;
196 m_fixedTimeStep = 1f / 60f; 196 m_fixedTimeStep = 1f / 60f;
@@ -231,8 +231,8 @@ public class BSScene : PhysicsScene, IPhysicsParameters
231 _meshSculptedPrim = pConfig.GetBoolean("MeshSculptedPrim", _meshSculptedPrim); 231 _meshSculptedPrim = pConfig.GetBoolean("MeshSculptedPrim", _meshSculptedPrim);
232 _forceSimplePrimMeshing = pConfig.GetBoolean("ForceSimplePrimMeshing", _forceSimplePrimMeshing); 232 _forceSimplePrimMeshing = pConfig.GetBoolean("ForceSimplePrimMeshing", _forceSimplePrimMeshing);
233 233
234 m_meshLOD = pConfig.GetInt("MeshLevelOfDetail", m_meshLOD); 234 m_meshLOD = pConfig.GetFloat("MeshLevelOfDetail", m_meshLOD);
235 m_sculptLOD = pConfig.GetInt("SculptLevelOfDetail", m_sculptLOD); 235 m_sculptLOD = pConfig.GetFloat("SculptLevelOfDetail", m_sculptLOD);
236 236
237 m_maxSubSteps = pConfig.GetInt("MaxSubSteps", m_maxSubSteps); 237 m_maxSubSteps = pConfig.GetInt("MaxSubSteps", m_maxSubSteps);
238 m_fixedTimeStep = pConfig.GetFloat("FixedTimeStep", m_fixedTimeStep); 238 m_fixedTimeStep = pConfig.GetFloat("FixedTimeStep", m_fixedTimeStep);