diff options
author | Robert Adams | 2012-10-10 08:02:37 -0700 |
---|---|---|
committer | Robert Adams | 2012-10-11 14:01:10 -0700 |
commit | a791620622dc0a67a6af2c4a9c011d9057360411 (patch) | |
tree | 4a08389e4e166fff4149b3e5f46bba8f64557846 | |
parent | BulletSim: Add Force* operations to objects to allow direct push to engine. (diff) | |
download | opensim-SC_OLD-a791620622dc0a67a6af2c4a9c011d9057360411.zip opensim-SC_OLD-a791620622dc0a67a6af2c4a9c011d9057360411.tar.gz opensim-SC_OLD-a791620622dc0a67a6af2c4a9c011d9057360411.tar.bz2 opensim-SC_OLD-a791620622dc0a67a6af2c4a9c011d9057360411.tar.xz |
BulletSim: cosmetic changes (comments and renaming). Give mass to terrain to improve interactions.
Diffstat (limited to '')
7 files changed, 74 insertions, 52 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index c23ccd5..2e6b2da 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | |||
@@ -263,7 +263,7 @@ public class BSCharacter : BSPhysObject | |||
263 | // A version of the sanity check that also makes sure a new position value is | 263 | // A version of the sanity check that also makes sure a new position value is |
264 | // pushed back to the physics engine. This routine would be used by anyone | 264 | // pushed back to the physics engine. This routine would be used by anyone |
265 | // who is not already pushing the value. | 265 | // who is not already pushing the value. |
266 | private bool PositionSanityCheck2(bool atTaintTime) | 266 | private bool PositionSanityCheck2(bool inTaintTime) |
267 | { | 267 | { |
268 | bool ret = false; | 268 | bool ret = false; |
269 | if (PositionSanityCheck()) | 269 | if (PositionSanityCheck()) |
@@ -275,7 +275,7 @@ public class BSCharacter : BSPhysObject | |||
275 | DetailLog("{0},BSCharacter.PositionSanityCheck,taint,pos={1},orient={2}", LocalID, _position, _orientation); | 275 | DetailLog("{0},BSCharacter.PositionSanityCheck,taint,pos={1},orient={2}", LocalID, _position, _orientation); |
276 | BulletSimAPI.SetObjectTranslation(PhysicsScene.WorldID, LocalID, _position, _orientation); | 276 | BulletSimAPI.SetObjectTranslation(PhysicsScene.WorldID, LocalID, _position, _orientation); |
277 | }; | 277 | }; |
278 | if (atTaintTime) | 278 | if (inTaintTime) |
279 | sanityOperation(); | 279 | sanityOperation(); |
280 | else | 280 | else |
281 | PhysicsScene.TaintedObject("BSCharacter.PositionSanityCheck", sanityOperation); | 281 | PhysicsScene.TaintedObject("BSCharacter.PositionSanityCheck", sanityOperation); |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs index 20db4de..b84ccdc 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs | |||
@@ -160,6 +160,31 @@ public class BSLinkset | |||
160 | return ret; | 160 | return ret; |
161 | } | 161 | } |
162 | 162 | ||
163 | // When physical properties are changed the linkset needs to recalculate | ||
164 | // its internal properties. | ||
165 | // May be called at runtime or taint-time (just pass the appropriate flag). | ||
166 | public void Refresh(BSPhysObject requestor, bool inTaintTime) | ||
167 | { | ||
168 | // If there are no children, there can't be any constraints to recompute | ||
169 | if (!HasAnyChildren) | ||
170 | return; | ||
171 | |||
172 | // Only the root does the recomputation | ||
173 | if (IsRoot(requestor)) | ||
174 | { | ||
175 | BSScene.TaintCallback refreshOperation = delegate() | ||
176 | { | ||
177 | RecomputeLinksetConstraintVariables(); | ||
178 | DetailLog("{0},BSLinkset.Refresh,complete,rBody={1}", | ||
179 | LinksetRoot.LocalID, LinksetRoot.BSBody.ptr.ToString("X")); | ||
180 | }; | ||
181 | if (inTaintTime) | ||
182 | refreshOperation(); | ||
183 | else | ||
184 | PhysicsScene.TaintedObject("BSLinkSet.Refresh", refreshOperation); | ||
185 | } | ||
186 | } | ||
187 | |||
163 | // The object is going dynamic (physical). Do any setup necessary | 188 | // The object is going dynamic (physical). Do any setup necessary |
164 | // for a dynamic linkset. | 189 | // for a dynamic linkset. |
165 | // Only the state of the passed object can be modified. The rest of the linkset | 190 | // Only the state of the passed object can be modified. The rest of the linkset |
@@ -182,24 +207,19 @@ public class BSLinkset | |||
182 | return false; | 207 | return false; |
183 | } | 208 | } |
184 | 209 | ||
185 | // When physical properties are changed the linkset needs to recalculate | 210 | // If the software is handling the movement of all the objects in a linkset |
186 | // its internal properties. | 211 | // (like if one doesn't use constraints for static linksets), this is called |
187 | // Called at runtime. | 212 | // when an update for the root of the linkset is received. |
188 | public void Refresh(BSPhysObject requestor) | 213 | // Called at taint-time!! |
214 | public void UpdateProperties(BSPhysObject physObject) | ||
189 | { | 215 | { |
190 | // If there are no children, there can't be any constraints to recompute | 216 | // The root local properties have been updated. Apply to the children if appropriate. |
191 | if (!HasAnyChildren) | 217 | if (IsRoot(physObject) && HasAnyChildren) |
192 | return; | ||
193 | |||
194 | // Only the root does the recomputation | ||
195 | if (IsRoot(requestor)) | ||
196 | { | 218 | { |
197 | PhysicsScene.TaintedObject("BSLinkSet.Refresh", delegate() | 219 | if (!physObject.IsPhysical) |
198 | { | 220 | { |
199 | RecomputeLinksetConstraintVariables(); | 221 | // TODO: implement software linkset update for static object linksets |
200 | DetailLog("{0},BSLinkset.Refresh,complete,rBody={1}", | 222 | } |
201 | LinksetRoot.LocalID, LinksetRoot.BSBody.ptr.ToString("X")); | ||
202 | }); | ||
203 | } | 223 | } |
204 | } | 224 | } |
205 | 225 | ||
@@ -236,9 +256,8 @@ public class BSLinkset | |||
236 | return ret; | 256 | return ret; |
237 | } | 257 | } |
238 | 258 | ||
239 | // Routine used when rebuilding the body of the root of the linkset | 259 | // Companion to RemoveBodyDependencies(). If RemoveBodyDependencies() returns 'true', |
240 | // This is called after RemoveAllLinksToRoot() to restore all the constraints. | 260 | // this routine will restore the removed constraints. |
241 | // This is called when the root body has been changed. | ||
242 | // Called at taint-time!! | 261 | // Called at taint-time!! |
243 | public void RestoreBodyDependencies(BSPrim child) | 262 | public void RestoreBodyDependencies(BSPrim child) |
244 | { | 263 | { |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index d408be0..b26f049 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |||
@@ -327,7 +327,7 @@ public sealed class BSPrim : BSPhysObject | |||
327 | // A version of the sanity check that also makes sure a new position value is | 327 | // A version of the sanity check that also makes sure a new position value is |
328 | // pushed back to the physics engine. This routine would be used by anyone | 328 | // pushed back to the physics engine. This routine would be used by anyone |
329 | // who is not already pushing the value. | 329 | // who is not already pushing the value. |
330 | private bool PositionSanityCheck2(bool atTaintTime) | 330 | private bool PositionSanityCheck2(bool inTaintTime) |
331 | { | 331 | { |
332 | bool ret = false; | 332 | bool ret = false; |
333 | if (PositionSanityCheck()) | 333 | if (PositionSanityCheck()) |
@@ -339,7 +339,7 @@ public sealed class BSPrim : BSPhysObject | |||
339 | DetailLog("{0},BSPrim.PositionSanityCheck,taint,pos={1},orient={2}", LocalID, _position, _orientation); | 339 | DetailLog("{0},BSPrim.PositionSanityCheck,taint,pos={1},orient={2}", LocalID, _position, _orientation); |
340 | BulletSimAPI.SetObjectTranslation(PhysicsScene.WorldID, LocalID, _position, _orientation); | 340 | BulletSimAPI.SetObjectTranslation(PhysicsScene.WorldID, LocalID, _position, _orientation); |
341 | }; | 341 | }; |
342 | if (atTaintTime) | 342 | if (inTaintTime) |
343 | sanityOperation(); | 343 | sanityOperation(); |
344 | else | 344 | else |
345 | PhysicsScene.TaintedObject("BSPrim.PositionSanityCheck", sanityOperation); | 345 | PhysicsScene.TaintedObject("BSPrim.PositionSanityCheck", sanityOperation); |
@@ -583,7 +583,7 @@ public sealed class BSPrim : BSPhysObject | |||
583 | // Set up the object physicalness (does gravity and collisions move this object) | 583 | // Set up the object physicalness (does gravity and collisions move this object) |
584 | MakeDynamic(IsStatic); | 584 | MakeDynamic(IsStatic); |
585 | 585 | ||
586 | // Update vehicle specific parameters | 586 | // Update vehicle specific parameters (after MakeDynamic() so can change physical parameters) |
587 | _vehicle.Refresh(); | 587 | _vehicle.Refresh(); |
588 | 588 | ||
589 | // Arrange for collision events if the simulator wants them | 589 | // Arrange for collision events if the simulator wants them |
@@ -606,7 +606,7 @@ public sealed class BSPrim : BSPhysObject | |||
606 | // Recompute any linkset parameters. | 606 | // Recompute any linkset parameters. |
607 | // When going from non-physical to physical, this re-enables the constraints that | 607 | // When going from non-physical to physical, this re-enables the constraints that |
608 | // had been automatically disabled when the mass was set to zero. | 608 | // had been automatically disabled when the mass was set to zero. |
609 | Linkset.Refresh(this); | 609 | Linkset.Refresh(this, true); |
610 | 610 | ||
611 | DetailLog("{0},BSPrim.UpdatePhysicalParameters,exit,static={1},solid={2},mass={3},collide={4},cf={5:X},body={6},shape={7}", | 611 | DetailLog("{0},BSPrim.UpdatePhysicalParameters,exit,static={1},solid={2},mass={3},collide={4},cf={5:X},body={6},shape={7}", |
612 | LocalID, IsStatic, IsSolid, _mass, SubscribedEvents(), CurrentCollisionFlags, BSBody, BSShape); | 612 | LocalID, IsStatic, IsSolid, _mass, SubscribedEvents(), CurrentCollisionFlags, BSBody, BSShape); |
@@ -1322,6 +1322,8 @@ public sealed class BSPrim : BSPhysObject | |||
1322 | 1322 | ||
1323 | PositionSanityCheck2(true); | 1323 | PositionSanityCheck2(true); |
1324 | 1324 | ||
1325 | Linkset.UpdateProperties(this); | ||
1326 | |||
1325 | DetailLog("{0},BSPrim.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5}", | 1327 | DetailLog("{0},BSPrim.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5}", |
1326 | LocalID, _position, _orientation, _velocity, _acceleration, _rotationalVelocity); | 1328 | LocalID, _position, _orientation, _velocity, _acceleration, _rotationalVelocity); |
1327 | 1329 | ||
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 33ac116..50091cc 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | |||
@@ -39,7 +39,6 @@ using log4net; | |||
39 | using OpenMetaverse; | 39 | using OpenMetaverse; |
40 | 40 | ||
41 | // TODOs for BulletSim (for BSScene, BSPrim, BSCharacter and BulletSim) | 41 | // TODOs for BulletSim (for BSScene, BSPrim, BSCharacter and BulletSim) |
42 | // Move all logic out of the C++ code and into the C# code for easier future modifications. | ||
43 | // Test sculpties (verified that they don't work) | 42 | // Test sculpties (verified that they don't work) |
44 | // Compute physics FPS reasonably | 43 | // Compute physics FPS reasonably |
45 | // Based on material, set density and friction | 44 | // Based on material, set density and friction |
@@ -493,7 +492,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
493 | int numSubSteps = 0; | 492 | int numSubSteps = 0; |
494 | 493 | ||
495 | // DEBUG | 494 | // DEBUG |
496 | DetailLog("{0},BSScene.Simulate,beforeStep,ntaimts={1},step={2}", DetailLogZero, numTaints, m_simulationStep); | 495 | // DetailLog("{0},BSScene.Simulate,beforeStep,ntaimts={1},step={2}", DetailLogZero, numTaints, m_simulationStep); |
497 | 496 | ||
498 | try | 497 | try |
499 | { | 498 | { |
@@ -503,8 +502,8 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
503 | out updatedEntityCount, out updatedEntitiesPtr, out collidersCount, out collidersPtr); | 502 | out updatedEntityCount, out updatedEntitiesPtr, out collidersCount, out collidersPtr); |
504 | 503 | ||
505 | if (PhysicsLogging.Enabled) simTime = Util.EnvironmentTickCountSubtract(beforeTime); | 504 | if (PhysicsLogging.Enabled) simTime = Util.EnvironmentTickCountSubtract(beforeTime); |
506 | DetailLog("{0},Simulate,call, nTaints={1}, simTime={2}, substeps={3}, updates={4}, colliders={5}", | 505 | DetailLog("{0},Simulate,call, frame={1}, nTaints={2}, simTime={3}, substeps={4}, updates={5}, colliders={6}", |
507 | DetailLogZero, numTaints, simTime, numSubSteps, updatedEntityCount, collidersCount); | 506 | DetailLogZero, m_simulationStep, numTaints, simTime, numSubSteps, updatedEntityCount, collidersCount); |
508 | } | 507 | } |
509 | catch (Exception e) | 508 | catch (Exception e) |
510 | { | 509 | { |
@@ -855,7 +854,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
855 | (s) => { return s.NumericBool(s.ShouldForceSimplePrimMeshing); }, | 854 | (s) => { return s.NumericBool(s.ShouldForceSimplePrimMeshing); }, |
856 | (s,p,l,v) => { s.ShouldForceSimplePrimMeshing = s.BoolNumeric(v); } ), | 855 | (s,p,l,v) => { s.ShouldForceSimplePrimMeshing = s.BoolNumeric(v); } ), |
857 | new ParameterDefn("UseHullsForPhysicalObjects", "If true, create hulls for physical objects", | 856 | new ParameterDefn("UseHullsForPhysicalObjects", "If true, create hulls for physical objects", |
858 | ConfigurationParameters.numericFalse, | 857 | ConfigurationParameters.numericTrue, |
859 | (s,cf,p,v) => { s.ShouldUseHullsForPhysicalObjects = cf.GetBoolean(p, s.BoolNumeric(v)); }, | 858 | (s,cf,p,v) => { s.ShouldUseHullsForPhysicalObjects = cf.GetBoolean(p, s.BoolNumeric(v)); }, |
860 | (s) => { return s.NumericBool(s.ShouldUseHullsForPhysicalObjects); }, | 859 | (s) => { return s.NumericBool(s.ShouldUseHullsForPhysicalObjects); }, |
861 | (s,p,l,v) => { s.ShouldUseHullsForPhysicalObjects = s.BoolNumeric(v); } ), | 860 | (s,p,l,v) => { s.ShouldUseHullsForPhysicalObjects = s.BoolNumeric(v); } ), |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs index e619b48..d5e2172 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs | |||
@@ -67,8 +67,8 @@ public class BSShapeCollection : IDisposable | |||
67 | public DateTime lastReferenced; | 67 | public DateTime lastReferenced; |
68 | } | 68 | } |
69 | 69 | ||
70 | private Dictionary<ulong, MeshDesc> Meshes = new Dictionary<ulong, MeshDesc>(); | 70 | private Dictionary<System.UInt64, MeshDesc> Meshes = new Dictionary<System.UInt64, MeshDesc>(); |
71 | private Dictionary<ulong, HullDesc> Hulls = new Dictionary<ulong, HullDesc>(); | 71 | private Dictionary<System.UInt64, HullDesc> Hulls = new Dictionary<System.UInt64, HullDesc>(); |
72 | private Dictionary<uint, BodyDesc> Bodies = new Dictionary<uint, BodyDesc>(); | 72 | private Dictionary<uint, BodyDesc> Bodies = new Dictionary<uint, BodyDesc>(); |
73 | 73 | ||
74 | public BSShapeCollection(BSScene physScene) | 74 | public BSShapeCollection(BSScene physScene) |
@@ -121,7 +121,7 @@ public class BSShapeCollection : IDisposable | |||
121 | // Track another user of a body | 121 | // Track another user of a body |
122 | // We presume the caller has allocated the body. | 122 | // We presume the caller has allocated the body. |
123 | // Bodies only have one user so the reference count is either 1 or 0. | 123 | // Bodies only have one user so the reference count is either 1 or 0. |
124 | public void ReferenceBody(BulletBody body, bool atTaintTime) | 124 | public void ReferenceBody(BulletBody body, bool inTaintTime) |
125 | { | 125 | { |
126 | lock (m_collectionActivityLock) | 126 | lock (m_collectionActivityLock) |
127 | { | 127 | { |
@@ -147,7 +147,7 @@ public class BSShapeCollection : IDisposable | |||
147 | body.ID, body); | 147 | body.ID, body); |
148 | } | 148 | } |
149 | }; | 149 | }; |
150 | if (atTaintTime) | 150 | if (inTaintTime) |
151 | createOperation(); | 151 | createOperation(); |
152 | else | 152 | else |
153 | PhysicsScene.TaintedObject("BSShapeCollection.ReferenceBody", createOperation); | 153 | PhysicsScene.TaintedObject("BSShapeCollection.ReferenceBody", createOperation); |
@@ -272,7 +272,7 @@ public class BSShapeCollection : IDisposable | |||
272 | 272 | ||
273 | // Release the usage of a shape. | 273 | // Release the usage of a shape. |
274 | // The collisionObject is released since it is a copy of the real collision shape. | 274 | // The collisionObject is released since it is a copy of the real collision shape. |
275 | public void DereferenceShape(BulletShape shape, bool atTaintTime, ShapeDestructionCallback shapeCallback) | 275 | public void DereferenceShape(BulletShape shape, bool inTaintTime, ShapeDestructionCallback shapeCallback) |
276 | { | 276 | { |
277 | if (shape.ptr == IntPtr.Zero) | 277 | if (shape.ptr == IntPtr.Zero) |
278 | return; | 278 | return; |
@@ -294,14 +294,14 @@ public class BSShapeCollection : IDisposable | |||
294 | if (shape.ptr != IntPtr.Zero & shape.isNativeShape) | 294 | if (shape.ptr != IntPtr.Zero & shape.isNativeShape) |
295 | { | 295 | { |
296 | DetailLog("{0},BSShapeCollection.DereferenceShape,deleteNativeShape,ptr={1},taintTime={2}", | 296 | DetailLog("{0},BSShapeCollection.DereferenceShape,deleteNativeShape,ptr={1},taintTime={2}", |
297 | BSScene.DetailLogZero, shape.ptr.ToString("X"), atTaintTime); | 297 | BSScene.DetailLogZero, shape.ptr.ToString("X"), inTaintTime); |
298 | if (shapeCallback != null) shapeCallback(shape); | 298 | if (shapeCallback != null) shapeCallback(shape); |
299 | BulletSimAPI.DeleteCollisionShape2(PhysicsScene.World.ptr, shape.ptr); | 299 | BulletSimAPI.DeleteCollisionShape2(PhysicsScene.World.ptr, shape.ptr); |
300 | } | 300 | } |
301 | break; | 301 | break; |
302 | } | 302 | } |
303 | }; | 303 | }; |
304 | if (atTaintTime) | 304 | if (inTaintTime) |
305 | { | 305 | { |
306 | lock (m_collectionActivityLock) | 306 | lock (m_collectionActivityLock) |
307 | { | 307 | { |
@@ -441,7 +441,7 @@ public class BSShapeCollection : IDisposable | |||
441 | 441 | ||
442 | // Native shapes are always built independently. | 442 | // Native shapes are always built independently. |
443 | newShape = new BulletShape(BulletSimAPI.BuildNativeShape2(PhysicsScene.World.ptr, shapeData), shapeType); | 443 | newShape = new BulletShape(BulletSimAPI.BuildNativeShape2(PhysicsScene.World.ptr, shapeData), shapeType); |
444 | newShape.shapeKey = (ulong)shapeKey; | 444 | newShape.shapeKey = (System.UInt64)shapeKey; |
445 | newShape.isNativeShape = true; | 445 | newShape.isNativeShape = true; |
446 | 446 | ||
447 | // Don't need to do a 'ReferenceShape()' here because native shapes are not tracked. | 447 | // Don't need to do a 'ReferenceShape()' here because native shapes are not tracked. |
@@ -461,7 +461,7 @@ public class BSShapeCollection : IDisposable | |||
461 | BulletShape newShape = new BulletShape(IntPtr.Zero); | 461 | BulletShape newShape = new BulletShape(IntPtr.Zero); |
462 | 462 | ||
463 | float lod; | 463 | float lod; |
464 | ulong newMeshKey = ComputeShapeKey(shapeData, pbs, out lod); | 464 | System.UInt64 newMeshKey = ComputeShapeKey(shapeData, pbs, out lod); |
465 | 465 | ||
466 | // if this new shape is the same as last time, don't recreate the mesh | 466 | // if this new shape is the same as last time, don't recreate the mesh |
467 | if (newMeshKey == prim.BSShape.shapeKey && prim.BSShape.type == ShapeData.PhysicsShapeType.SHAPE_MESH) | 467 | if (newMeshKey == prim.BSShape.shapeKey && prim.BSShape.type == ShapeData.PhysicsShapeType.SHAPE_MESH) |
@@ -484,7 +484,7 @@ public class BSShapeCollection : IDisposable | |||
484 | return true; // 'true' means a new shape has been added to this prim | 484 | return true; // 'true' means a new shape has been added to this prim |
485 | } | 485 | } |
486 | 486 | ||
487 | private BulletShape CreatePhysicalMesh(string objName, ulong newMeshKey, PrimitiveBaseShape pbs, OMV.Vector3 size, float lod) | 487 | private BulletShape CreatePhysicalMesh(string objName, System.UInt64 newMeshKey, PrimitiveBaseShape pbs, OMV.Vector3 size, float lod) |
488 | { | 488 | { |
489 | IMesh meshData = null; | 489 | IMesh meshData = null; |
490 | IntPtr meshPtr; | 490 | IntPtr meshPtr; |
@@ -531,7 +531,7 @@ public class BSShapeCollection : IDisposable | |||
531 | BulletShape newShape; | 531 | BulletShape newShape; |
532 | 532 | ||
533 | float lod; | 533 | float lod; |
534 | ulong newHullKey = ComputeShapeKey(shapeData, pbs, out lod); | 534 | System.UInt64 newHullKey = ComputeShapeKey(shapeData, pbs, out lod); |
535 | 535 | ||
536 | // if the hull hasn't changed, don't rebuild it | 536 | // if the hull hasn't changed, don't rebuild it |
537 | if (newHullKey == prim.BSShape.shapeKey && prim.BSShape.type == ShapeData.PhysicsShapeType.SHAPE_HULL) | 537 | if (newHullKey == prim.BSShape.shapeKey && prim.BSShape.type == ShapeData.PhysicsShapeType.SHAPE_HULL) |
@@ -554,7 +554,7 @@ public class BSShapeCollection : IDisposable | |||
554 | } | 554 | } |
555 | 555 | ||
556 | List<ConvexResult> m_hulls; | 556 | List<ConvexResult> m_hulls; |
557 | private BulletShape CreatePhysicalHull(string objName, ulong newHullKey, PrimitiveBaseShape pbs, OMV.Vector3 size, float lod) | 557 | private BulletShape CreatePhysicalHull(string objName, System.UInt64 newHullKey, PrimitiveBaseShape pbs, OMV.Vector3 size, float lod) |
558 | { | 558 | { |
559 | 559 | ||
560 | IntPtr hullPtr; | 560 | IntPtr hullPtr; |
@@ -667,7 +667,7 @@ public class BSShapeCollection : IDisposable | |||
667 | 667 | ||
668 | // Create a hash of all the shape parameters to be used as a key | 668 | // Create a hash of all the shape parameters to be used as a key |
669 | // for this particular shape. | 669 | // for this particular shape. |
670 | private ulong ComputeShapeKey(ShapeData shapeData, PrimitiveBaseShape pbs, out float retLod) | 670 | private System.UInt64 ComputeShapeKey(ShapeData shapeData, PrimitiveBaseShape pbs, out float retLod) |
671 | { | 671 | { |
672 | // level of detail based on size and type of the object | 672 | // level of detail based on size and type of the object |
673 | float lod = PhysicsScene.MeshLOD; | 673 | float lod = PhysicsScene.MeshLOD; |
@@ -680,10 +680,10 @@ public class BSShapeCollection : IDisposable | |||
680 | lod = PhysicsScene.MeshMegaPrimLOD; | 680 | lod = PhysicsScene.MeshMegaPrimLOD; |
681 | 681 | ||
682 | retLod = lod; | 682 | retLod = lod; |
683 | return (ulong)pbs.GetMeshKey(shapeData.Size, lod); | 683 | return pbs.GetMeshKey(shapeData.Size, lod); |
684 | } | 684 | } |
685 | // For those who don't want the LOD | 685 | // For those who don't want the LOD |
686 | private ulong ComputeShapeKey(ShapeData shapeData, PrimitiveBaseShape pbs) | 686 | private System.UInt64 ComputeShapeKey(ShapeData shapeData, PrimitiveBaseShape pbs) |
687 | { | 687 | { |
688 | float lod; | 688 | float lod; |
689 | return ComputeShapeKey(shapeData, pbs, out lod); | 689 | return ComputeShapeKey(shapeData, pbs, out lod); |
@@ -717,6 +717,7 @@ public class BSShapeCollection : IDisposable | |||
717 | 717 | ||
718 | if (mustRebuild || forceRebuild) | 718 | if (mustRebuild || forceRebuild) |
719 | { | 719 | { |
720 | // Free any old body | ||
720 | DereferenceBody(prim.BSBody, true, bodyCallback); | 721 | DereferenceBody(prim.BSBody, true, bodyCallback); |
721 | 722 | ||
722 | BulletBody aBody; | 723 | BulletBody aBody; |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs index 70aa429..2808603 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs | |||
@@ -201,10 +201,10 @@ public class BSTerrainManager | |||
201 | // The 'doNow' boolean says whether to do all the unmanaged activities right now (like when | 201 | // The 'doNow' boolean says whether to do all the unmanaged activities right now (like when |
202 | // calling this routine from initialization or taint-time routines) or whether to delay | 202 | // calling this routine from initialization or taint-time routines) or whether to delay |
203 | // all the unmanaged activities to taint-time. | 203 | // all the unmanaged activities to taint-time. |
204 | private void UpdateOrCreateTerrain(uint id, float[] heightMap, Vector3 minCoords, Vector3 maxCoords, bool atTaintTime) | 204 | private void UpdateOrCreateTerrain(uint id, float[] heightMap, Vector3 minCoords, Vector3 maxCoords, bool inTaintTime) |
205 | { | 205 | { |
206 | DetailLog("{0},BSTerrainManager.UpdateOrCreateTerrain,call,minC={1},maxC={2},atTaintTime={3}", | 206 | DetailLog("{0},BSTerrainManager.UpdateOrCreateTerrain,call,minC={1},maxC={2},inTaintTime={3}", |
207 | BSScene.DetailLogZero, minCoords, maxCoords, atTaintTime); | 207 | BSScene.DetailLogZero, minCoords, maxCoords, inTaintTime); |
208 | 208 | ||
209 | float minZ = float.MaxValue; | 209 | float minZ = float.MaxValue; |
210 | float maxZ = float.MinValue; | 210 | float maxZ = float.MinValue; |
@@ -320,7 +320,9 @@ public class BSTerrainManager | |||
320 | BulletSimAPI.SetRestitution2(mapInfo.terrainBody.ptr, PhysicsScene.Params.terrainRestitution); | 320 | BulletSimAPI.SetRestitution2(mapInfo.terrainBody.ptr, PhysicsScene.Params.terrainRestitution); |
321 | BulletSimAPI.SetCollisionFlags2(mapInfo.terrainBody.ptr, CollisionFlags.CF_STATIC_OBJECT); | 321 | BulletSimAPI.SetCollisionFlags2(mapInfo.terrainBody.ptr, CollisionFlags.CF_STATIC_OBJECT); |
322 | 322 | ||
323 | BulletSimAPI.SetMassProps2(mapInfo.terrainBody.ptr, 0f, Vector3.Zero); | 323 | float terrainMass = 1000; |
324 | Vector3 localInertia = BulletSimAPI.CalculateLocalInertia2(mapInfo.terrainBody.ptr, terrainMass); | ||
325 | BulletSimAPI.SetMassProps2(mapInfo.terrainBody.ptr, terrainMass, localInertia); | ||
324 | BulletSimAPI.UpdateInertiaTensor2(mapInfo.terrainBody.ptr); | 326 | BulletSimAPI.UpdateInertiaTensor2(mapInfo.terrainBody.ptr); |
325 | 327 | ||
326 | // Return the new terrain to the world of physical objects | 328 | // Return the new terrain to the world of physical objects |
@@ -342,7 +344,7 @@ public class BSTerrainManager | |||
342 | 344 | ||
343 | // There is the option to do the changes now (we're already in 'taint time'), or | 345 | // There is the option to do the changes now (we're already in 'taint time'), or |
344 | // to do the Bullet operations later. | 346 | // to do the Bullet operations later. |
345 | if (atTaintTime) | 347 | if (inTaintTime) |
346 | rebuildOperation(); | 348 | rebuildOperation(); |
347 | else | 349 | else |
348 | PhysicsScene.TaintedObject("BSScene.UpdateOrCreateTerrain:UpdateExisting", rebuildOperation); | 350 | PhysicsScene.TaintedObject("BSScene.UpdateOrCreateTerrain:UpdateExisting", rebuildOperation); |
@@ -381,7 +383,7 @@ public class BSTerrainManager | |||
381 | }; | 383 | }; |
382 | 384 | ||
383 | // If already in taint-time, just call Bullet. Otherwise queue the operations for the safe time. | 385 | // If already in taint-time, just call Bullet. Otherwise queue the operations for the safe time. |
384 | if (atTaintTime) | 386 | if (inTaintTime) |
385 | createOperation(); | 387 | createOperation(); |
386 | else | 388 | else |
387 | PhysicsScene.TaintedObject("BSScene.UpdateOrCreateTerrain:NewTerrain", createOperation); | 389 | PhysicsScene.TaintedObject("BSScene.UpdateOrCreateTerrain:NewTerrain", createOperation); |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs index 7a60afb..e23fe5a 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs | |||
@@ -101,9 +101,8 @@ public struct BulletShape | |||
101 | } | 101 | } |
102 | public IntPtr ptr; | 102 | public IntPtr ptr; |
103 | public ShapeData.PhysicsShapeType type; | 103 | public ShapeData.PhysicsShapeType type; |
104 | public ulong shapeKey; | 104 | public System.UInt64 shapeKey; |
105 | public bool isNativeShape; | 105 | public bool isNativeShape; |
106 | // Hulls have an underlying mesh. A pointer to it is hidden here. | ||
107 | public override string ToString() | 106 | public override string ToString() |
108 | { | 107 | { |
109 | StringBuilder buff = new StringBuilder(); | 108 | StringBuilder buff = new StringBuilder(); |