From 725751fd6c0101b8610e84716d28b6af91e20b61 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 6 Aug 2013 10:32:56 -0700 Subject: BulletSim: fixes for change linkset implementation of physical linksets. --- .../Scripting/ExtendedPhysics/ExtendedPhysics.cs | 29 +++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs index d1d318c..4455df4 100755 --- a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs @@ -29,6 +29,7 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Text; +using System.Threading; using OpenSim.Framework; using OpenSim.Region.CoreModules; @@ -198,7 +199,33 @@ public class ExtendedPhysics : INonSharedRegionModule Physics.Manager.PhysicsActor rootPhysActor = rootPart.PhysActor; if (rootPhysActor != null) { - ret = (int)rootPhysActor.Extension(PhysFunctSetLinksetType, linksetType); + if (rootPhysActor.IsPhysical) + { + // Change a physical linkset by making non-physical, waiting for one heartbeat so all + // the prim and linkset state is updated, changing the type and making the + // linkset physical again. + containingGroup.ScriptSetPhysicsStatus(false); + Thread.Sleep(150); // longer than one heartbeat tick + + // A kludge for the moment. + // Since compound linksets move the children but don't generate position updates to the + // simulator, it is possible for compound linkset children to have out-of-sync simulator + // and physical positions. The following causes the simulator to push the real child positions + // down into the physics engine to get everything synced. + containingGroup.UpdateGroupPosition(containingGroup.AbsolutePosition); + containingGroup.UpdateGroupRotationR(containingGroup.GroupRotation); + + ret = (int)rootPhysActor.Extension(PhysFunctSetLinksetType, linksetType); + Thread.Sleep(150); // longer than one heartbeat tick + + containingGroup.ScriptSetPhysicsStatus(true); + } + else + { + // Non-physical linksets don't have a physical instantiation so there is no state to + // worry about being updated. + ret = (int)rootPhysActor.Extension(PhysFunctSetLinksetType, linksetType); + } } else { -- cgit v1.1