aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
diff options
context:
space:
mode:
authorRobert Adams2011-08-29 10:00:58 -0700
committerMic Bowman2011-08-29 10:10:48 -0700
commit96dce3e16c3c0b861e42e6331f693b6b00a14392 (patch)
tree8910d3e3adf91cc26e9b4c3013b1c7d9a3c098a6 /OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
parentMerge branch 'master' into bulletsim (diff)
downloadopensim-SC_OLD-96dce3e16c3c0b861e42e6331f693b6b00a14392.zip
opensim-SC_OLD-96dce3e16c3c0b861e42e6331f693b6b00a14392.tar.gz
opensim-SC_OLD-96dce3e16c3c0b861e42e6331f693b6b00a14392.tar.bz2
opensim-SC_OLD-96dce3e16c3c0b861e42e6331f693b6b00a14392.tar.xz
Use GetMeshKey from PrimitiveBaseShape.
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs22
1 files changed, 15 insertions, 7 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;