From 240e8646dac402068930065c1fb792e647f1ce4b Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Tue, 6 May 2008 00:23:19 +0000 Subject: * If you llApplyImpulse on an attachment, it applies impulse on the avatar, not the attachment. --- .../Region/Environment/Scenes/SceneObjectGroup.cs | 17 ++++++++++++++--- OpenSim/Region/Environment/Scenes/ScenePresence.cs | 8 ++++++++ .../BasicPhysicsPlugin/BasicPhysicsPlugin.cs | 2 +- .../Region/Physics/BulletXPlugin/BulletXPlugin.cs | 10 +++++----- OpenSim/Region/Physics/Manager/PhysicsActor.cs | 4 ++-- OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 21 ++++++++++++++++----- OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 2 +- OpenSim/Region/Physics/POSPlugin/POSPlugin.cs | 4 ++-- OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs | 4 ++-- 9 files changed, 51 insertions(+), 21 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index 2e44c54..2bc7fd3 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs @@ -1301,8 +1301,19 @@ namespace OpenSim.Region.Environment.Scenes { if (rootpart.PhysActor != null) { - rootpart.PhysActor.AddForce(impulse); - m_scene.PhysicsScene.AddPhysicsActorTaint(rootpart.PhysActor); + if (rootpart.m_IsAttachment) + { + ScenePresence avatar = m_scene.GetScenePresence(rootpart.m_attachedAvatar); + if (avatar != null) + { + avatar.PushForce(impulse); + } + } + else + { + rootpart.PhysActor.AddForce(impulse,true); + m_scene.PhysicsScene.AddPhysicsActorTaint(rootpart.PhysActor); + } } } } @@ -1909,7 +1920,7 @@ namespace OpenSim.Region.Environment.Scenes 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_rootPart.PhysActor.AddForce(grabforce,true); m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); } else diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index fcd93d8..aefecd0 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -2389,5 +2389,13 @@ namespace OpenSim.Region.Environment.Scenes info.AddValue("m_knownPrimUUID", knownPrimUUID_work); } + + internal void PushForce(PhysicsVector impulse) + { + if (PhysicsActor != null) + { + PhysicsActor.AddForce(impulse,true); + } + } } } diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs index 0d54dad..eecd115 100644 --- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs +++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs @@ -384,7 +384,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin _acceleration = accel; } - public override void AddForce(PhysicsVector force) + public override void AddForce(PhysicsVector force, bool pushforce) { } diff --git a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs index 9bd5f08..8a79dd6 100644 --- a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs +++ b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs @@ -917,7 +917,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin set { } } - public override void AddForce(PhysicsVector force) + public override void AddForce(PhysicsVector force, bool pushforce) { } @@ -1134,9 +1134,9 @@ namespace OpenSim.Region.Physics.BulletXPlugin base.SetAcceleration(accel); } - public override void AddForce(PhysicsVector force) + public override void AddForce(PhysicsVector force, bool pushforce) { - base.AddForce(force); + base.AddForce(force, pushforce); } public override void SetMomentum(PhysicsVector momentum) @@ -1343,9 +1343,9 @@ namespace OpenSim.Region.Physics.BulletXPlugin } } - public override void AddForce(PhysicsVector force) + public override void AddForce(PhysicsVector force, bool pushforce) { - base.AddForce(force); + base.AddForce(force,pushforce); } public override void SetMomentum(PhysicsVector momentum) diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index 046c285..c1dc91b 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs @@ -196,7 +196,7 @@ namespace OpenSim.Region.Physics.Manager public abstract float PIDTau { set; } - public abstract void AddForce(PhysicsVector force); + public abstract void AddForce(PhysicsVector force, bool pushforce); public abstract void SetMomentum(PhysicsVector momentum); public abstract void SubscribeEvents(int ms); public abstract void UnSubscribeEvents(); @@ -365,7 +365,7 @@ namespace OpenSim.Region.Physics.Manager { } - public override void AddForce(PhysicsVector force) + public override void AddForce(PhysicsVector force, bool pushforce) { } diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index 3d0855f..17e041d 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs @@ -610,13 +610,24 @@ namespace OpenSim.Region.Physics.OdePlugin /// The PID controller takes this target velocity and tries to make it a reality /// /// - public override void AddForce(PhysicsVector force) + public override void AddForce(PhysicsVector force, bool pushforce) { - m_pidControllerActive = true; - _target_velocity.X += force.X; - _target_velocity.Y += force.Y; - _target_velocity.Z += force.Z; + if (pushforce) + { + m_pidControllerActive = false; + doForce(force); + //_target_velocity.X += force.X; + // _target_velocity.Y += force.Y; + //_target_velocity.Z += force.Z; + } + else + { + m_pidControllerActive = true; + _target_velocity.X += force.X; + _target_velocity.Y += force.Y; + _target_velocity.Z += force.Z; + } //m_lastUpdateSent = false; } diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index 4e1696d..cf9dc5d 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs @@ -1884,7 +1884,7 @@ namespace OpenSim.Region.Physics.OdePlugin _acceleration = accel; } - public override void AddForce(PhysicsVector force) + public override void AddForce(PhysicsVector force, bool pushforce) { m_forcelist.Add(force); m_taintforce = true; diff --git a/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs b/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs index 836e620..96e67d1 100644 --- a/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs +++ b/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs @@ -513,7 +513,7 @@ namespace OpenSim.Region.Physics.POSPlugin _acceleration = accel; } - public override void AddForce(PhysicsVector force) + public override void AddForce(PhysicsVector force, bool pushforce) { } @@ -686,7 +686,7 @@ namespace OpenSim.Region.Physics.POSPlugin _acceleration = accel; } - public override void AddForce(PhysicsVector force) + public override void AddForce(PhysicsVector force, bool pushforce) { } diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs index 49fe1b5..712d10e 100644 --- a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs +++ b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs @@ -378,7 +378,7 @@ namespace OpenSim.Region.Physics.PhysXPlugin _acceleration = accel; } - public override void AddForce(PhysicsVector force) + public override void AddForce(PhysicsVector force, bool pushforce) { } @@ -625,7 +625,7 @@ namespace OpenSim.Region.Physics.PhysXPlugin _acceleration = accel; } - public override void AddForce(PhysicsVector force) + public override void AddForce(PhysicsVector force, bool pushforce) { } -- cgit v1.1