From 3ffad76b0da68733474fc5a525060cba46693c63 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Wed, 7 Aug 2013 11:13:53 -0700 Subject: BulletSim: initial implementation of physChangeLinkFixed that resets a linkset's link back to a fixed, non-moving connection. --- .../Scripting/ExtendedPhysics/ExtendedPhysics.cs | 82 +++++++++++++++++++++- 1 file changed, 81 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 4455df4..decb61a 100755 --- a/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ExtendedPhysics/ExtendedPhysics.cs @@ -61,6 +61,10 @@ public class ExtendedPhysics : INonSharedRegionModule // Per prim functions. See BSPrim. public const string PhysFunctGetLinksetType = "BulletSim.GetLinksetType"; public const string PhysFunctSetLinksetType = "BulletSim.SetLinksetType"; + public const string PhysFunctChangeLinkFixed = "BulletSim.ChangeLinkFixed"; + public const string PhysFunctChangeLinkHinge = "BulletSim.ChangeLinkHinge"; + public const string PhysFunctChangeLinkSpring = "BulletSim.ChangeLinkSpring"; + public const string PhysFunctChangeLinkSlider = "BulletSim.ChangeLinkSlider"; // ============================================================= @@ -250,7 +254,6 @@ public class ExtendedPhysics : INonSharedRegionModule public int physGetLinksetType(UUID hostID, UUID scriptID) { int ret = -1; - if (!Enabled) return ret; // The part that is requesting the change. @@ -287,5 +290,82 @@ public class ExtendedPhysics : INonSharedRegionModule } return ret; } + + [ScriptInvocation] + public int physChangeLinkFixed(UUID hostID, UUID scriptID, int linkNum) + { + int ret = -1; + if (!Enabled) return ret; + + // The part that is requesting the change. + SceneObjectPart requestingPart = BaseScene.GetSceneObjectPart(hostID); + + if (requestingPart != null) + { + // The type is is always on the root of a linkset. + SceneObjectGroup containingGroup = requestingPart.ParentGroup; + SceneObjectPart rootPart = containingGroup.RootPart; + + if (rootPart != null) + { + Physics.Manager.PhysicsActor rootPhysActor = rootPart.PhysActor; + if (rootPhysActor != null) + { + SceneObjectPart linkPart = containingGroup.GetLinkNumPart(linkNum); + if (linkPart != null) + { + Physics.Manager.PhysicsActor linkPhysActor = linkPart.PhysActor; + if (linkPhysActor != null) + { + ret = (int)rootPhysActor.Extension(PhysFunctChangeLinkFixed, linkNum, linkPhysActor); + } + else + { + m_log.WarnFormat("{0} physChangeLinkFixed: Link part has no physical actor. rootName={1}, hostID={2}, linknum={3}", + LogHeader, rootPart.Name, hostID, linkNum); + } + } + else + { + m_log.WarnFormat("{0} physChangeLinkFixed: Could not find linknum part. rootName={1}, hostID={2}, linknum={3}", + LogHeader, rootPart.Name, hostID, linkNum); + } + } + else + { + m_log.WarnFormat("{0} physChangeLinkFixed: Root part does not have a physics actor. rootName={1}, hostID={2}", + LogHeader, rootPart.Name, hostID); + } + } + else + { + m_log.WarnFormat("{0} physChangeLinkFixed: Root part does not exist. RequestingPartName={1}, hostID={2}", + LogHeader, requestingPart.Name, hostID); + } + } + else + { + m_log.WarnFormat("{0} physGetLinsetType: cannot find script object in scene. hostID={1}", LogHeader, hostID); + } + return ret; + } + + [ScriptInvocation] + public int physChangeLinkHinge(UUID hostID, UUID scriptID, int linkNum) + { + return 0; + } + + [ScriptInvocation] + public int physChangeLinkSpring(UUID hostID, UUID scriptID, int linkNum) + { + return 0; + } + + [ScriptInvocation] + public int physChangeLinkSlider(UUID hostID, UUID scriptID, int linkNum) + { + return 0; + } } } -- cgit v1.1