From c4687116adfdeb5de056000ef3d2dd47b8695339 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Tue, 29 Jan 2008 15:10:18 +0000 Subject: * Implemented grab and throw in ODE. It's a little strong still so toss gently at first to test the waters or you'll lose prim to the pit at the edge of the sim. Make sure the object is physical before trying to toss it or it'll just move to the new location. --- .../Region/Environment/Scenes/SceneObjectGroup.cs | 44 +++++++++++++++++++--- 1 file changed, 38 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/Environment/Scenes') diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index 785ebf7..10395b6 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs @@ -207,7 +207,14 @@ namespace OpenSim.Region.Environment.Scenes public bool IsSelected { get { return m_isSelected; } - set { m_isSelected = value; } + set { + m_isSelected = value; + // Tell physics engine that group is selected + if (m_rootPart.PhysActor != null) + { + m_rootPart.PhysActor.Selected = value; + } + } } // The UUID for the Region this Object is in. @@ -1039,20 +1046,45 @@ namespace OpenSim.Region.Environment.Scenes } /// - /// + /// If object is physical, apply force to move it around + /// If object is not physical, just put it at the resulting location /// - /// - /// + /// Always seems to be 0,0,0, so ignoring + /// New position. We do the math here to turn it into a force /// public void GrabMovement(LLVector3 offset, LLVector3 pos, IClientAPI remoteClient) { + if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) { - AbsolutePosition = pos; - m_rootPart.SendTerseUpdateToAllClients(); + + if (m_rootPart.PhysActor != null) + { + if (m_rootPart.PhysActor.IsPhysical) + { + LLVector3 llmoveforce = pos - AbsolutePosition; + PhysicsVector grabforce = new PhysicsVector(llmoveforce.X, llmoveforce.Y, llmoveforce.Z); + grabforce = (grabforce / 10) * m_rootPart.PhysActor.Mass; + m_rootPart.PhysActor.AddForce(grabforce); + m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); + } + else + { + NonPhysicalGrabMovement(pos); + } + } + else + { + NonPhysicalGrabMovement(pos); + } } } + public void NonPhysicalGrabMovement(LLVector3 pos) + { + AbsolutePosition = pos; + m_rootPart.SendTerseUpdateToAllClients(); + } /// /// /// -- cgit v1.1