From 0c971d148cbee691136a8e6f6c0b3dd40ba4e78a Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Wed, 5 Jun 2013 07:09:43 -0700 Subject: BulletSim: fix corner case when rebuilding a compound linkset while a mesh/hull while a mesh or hull is being rebuilt when its asset is fetched. This fixes a 'pure virtual function' crash when changing physical state of complex linksets that include many meshes. --- OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs | 57 +++++++++++++++++++----- 1 file changed, 46 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region/Physics') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs index 81edc12..867d2ab 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs @@ -389,9 +389,21 @@ public class BSShapeMesh : BSShape } public override BSShape GetReference(BSScene pPhysicsScene, BSPhysObject pPrim) { - // Another reference to this shape is just counted. - IncrementReference(); - return this; + BSShape ret = null; + // If the underlying shape is native, the actual shape has not been build (waiting for asset) + // and we must create a copy of the native shape since they are never shared. + if (physShapeInfo.HasPhysicalShape && physShapeInfo.isNativeShape) + { + // TODO: decide when the native shapes should be freed. Check in Dereference? + ret = BSShapeNative.GetReference(pPhysicsScene, pPrim, BSPhysicsShapeType.SHAPE_BOX, FixedShapeKey.KEY_BOX); + } + else + { + // Another reference to this shape is just counted. + IncrementReference(); + ret = this; + } + return ret; } public override void Dereference(BSScene physicsScene) { @@ -560,9 +572,21 @@ public class BSShapeHull : BSShape } public override BSShape GetReference(BSScene pPhysicsScene, BSPhysObject pPrim) { - // Another reference to this shape is just counted. - IncrementReference(); - return this; + BSShape ret = null; + // If the underlying shape is native, the actual shape has not been build (waiting for asset) + // and we must create a copy of the native shape since they are never shared. + if (physShapeInfo.HasPhysicalShape && physShapeInfo.isNativeShape) + { + // TODO: decide when the native shapes should be freed. Check in Dereference? + ret = BSShapeNative.GetReference(pPhysicsScene, pPrim, BSPhysicsShapeType.SHAPE_BOX, FixedShapeKey.KEY_BOX); + } + else + { + // Another reference to this shape is just counted. + IncrementReference(); + ret = this; + } + return ret; } public override void Dereference(BSScene physicsScene) { @@ -1075,12 +1099,23 @@ public class BSShapeGImpact : BSShape (w, iC, i, vC, v) => physicsScene.PE.CreateGImpactShape(w, iC, i, vC, v) ); } - public override BSShape GetReference(BSScene physicsScene, BSPhysObject prim) + public override BSShape GetReference(BSScene pPhysicsScene, BSPhysObject pPrim) { - // Calling this reference means we want another handle to an existing shape - // (usually linksets) so return this copy. - IncrementReference(); - return this; + BSShape ret = null; + // If the underlying shape is native, the actual shape has not been build (waiting for asset) + // and we must create a copy of the native shape since they are never shared. + if (physShapeInfo.HasPhysicalShape && physShapeInfo.isNativeShape) + { + // TODO: decide when the native shapes should be freed. Check in Dereference? + ret = BSShapeNative.GetReference(pPhysicsScene, pPrim, BSPhysicsShapeType.SHAPE_BOX, FixedShapeKey.KEY_BOX); + } + else + { + // Another reference to this shape is just counted. + IncrementReference(); + ret = this; + } + return ret; } // Dereferencing a compound shape releases the hold on all the child shapes. public override void Dereference(BSScene physicsScene) -- cgit v1.1 From b5d0ac4c42629812523f5af4384f61dee00ef495 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Wed, 5 Jun 2013 07:12:14 -0700 Subject: BulletSim: default PhysicsTimeStep to same as the simulator's heartbeat timestep when running the physics engine on a separate thread. This reduces the occurance of heartbeats that happen when there is no physics step which is seen as vehicle jerkyness. --- OpenSim/Region/Physics/BulletSPlugin/BSParam.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Physics') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs index afd547a..aad1108 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs @@ -360,7 +360,7 @@ public static class BSParam new ParameterDefn("UseSeparatePhysicsThread", "If 'true', the physics engine runs independent from the simulator heartbeat", false ), new ParameterDefn("PhysicsTimeStep", "If separate thread, seconds to simulate each interval", - 0.1f ), + 0.089f ), new ParameterDefn("MeshSculptedPrim", "Whether to create meshes for sculpties", true, -- cgit v1.1