From 18c959df12983256d73240a86fa0bad12c4e36ce Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Thu, 17 Jan 2008 14:59:05 +0000 Subject: * Added llApplyImpulse in the global frame. The object must be physical before this'll do anything. Be careful with this function as it's easy to loose prim. --- OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs | 10 ++++++++++ OpenSim/Region/Environment/Scenes/SceneObjectPart.cs | 15 +++++++++++++++ 2 files changed, 25 insertions(+) (limited to 'OpenSim/Region/Environment/Scenes') diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index 6447403..5790591 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs @@ -578,6 +578,16 @@ namespace OpenSim.Region.Environment.Scenes SetPartAsRoot(newPart); } + public void applyImpulse(PhysicsVector impulse) + { + SceneObjectPart rootpart = m_rootPart; + if (m_rootPart.PhysActor != null) + { + m_rootPart.PhysActor.AddForce(impulse); + m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); + } + } + public void SetRootPartOwner(SceneObjectPart part, LLUUID cAgentID, LLUUID cGroupID) { part.LastOwnerID = part.OwnerID; diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index 0cb4ae7..ce38bee 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs @@ -520,6 +520,21 @@ namespace OpenSim.Region.Environment.Scenes protected PrimitiveBaseShape m_shape; + /// + /// hook to the physics scene to apply impulse + /// This is sent up to the group, which then finds the root prim + /// and applies the force on the root prim of the group + /// + /// Vector force + public void ApplyImpulse(LLVector3 impulsei) + { + PhysicsVector impulse = new PhysicsVector(impulsei.X, impulsei.Y, impulsei.Z); + if (m_parentGroup != null) + { + m_parentGroup.applyImpulse(impulse); + } + } + public void TriggerScriptChangedEvent(Changed val) { if (m_parentGroup != null) -- cgit v1.1