From d0123a796b0066a50914c6fae5d86550dcf58636 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Mon, 10 Mar 2008 05:56:58 +0000 Subject: [PATCH] ODEPlugin * Added osSetPrimFloatOnWater(BOOL) to make Physical prim float at the water level. * osSetPrimFloatOnWater(TRUE); or osSetPrimFloatOnWater(FALSE); * By default, prim do not float at the water level. * More work is needed on the floating, but it's a start. --- .../Environment/Scenes/SceneObjectPart.cs | 16 ++++++++++ .../BasicPhysicsPlugin/BasicPhysicsPlugin.cs | 5 +++ .../Physics/BulletXPlugin/BulletXPlugin.cs | 5 +++ .../Region/Physics/Manager/PhysicsActor.cs | 8 +++++ .../Region/Physics/OdePlugin/ODECharacter.cs | 5 +++ OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 32 +++++++++++++++++++ OpenSim/Region/Physics/POSPlugin/POSPlugin.cs | 10 ++++++ .../Region/Physics/PhysXPlugin/PhysXPlugin.cs | 10 ++++++ .../Common/BuiltIn_Commands_BaseClass.cs | 5 +++ .../Common/LSL_BuiltIn_Commands.cs | 14 ++++++++ .../Common/LSL_BuiltIn_Commands_Interface.cs | 1 + 11 files changed, 111 insertions(+) diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index a8f08ecd3d..6ed63beac0 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs @@ -942,6 +942,22 @@ namespace OpenSim.Region.Environment.Scenes } } + public void SetFloatOnWater(int floatYN) + { + if (PhysActor != null) + { + if (floatYN == 1) + { + PhysActor.FloatOnWater = true; + } + else + { + PhysActor.FloatOnWater = false; + } + + } + } + public LLVector3 GetSitTargetPositionLL() { return new LLVector3(m_sitTargetPosition.x, m_sitTargetPosition.y, m_sitTargetPosition.z); diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs index 2b4bbc4cb9..429894d279 100644 --- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs +++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs @@ -254,6 +254,11 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin set { return; } } + public override bool FloatOnWater + { + set { return; } + } + public override bool IsPhysical { get { return false; } diff --git a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs index feb9ca1174..80cc086f05 100644 --- a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs +++ b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs @@ -930,6 +930,11 @@ namespace OpenSim.Region.Physics.BulletXPlugin set { return; } } + public override bool FloatOnWater + { + set { return; } + } + public virtual void SetAcceleration(PhysicsVector accel) { lock (BulletXScene.BulletXLock) diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index 82b7450ba2..2a35d43dd7 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs @@ -204,6 +204,8 @@ namespace OpenSim.Region.Physics.Manager public abstract bool CollidingGround { get; set; } public abstract bool CollidingObj { get; set; } + public abstract bool FloatOnWater { set; } + public abstract PhysicsVector RotationalVelocity { get; set; } public abstract bool Kinematic { get; set; } @@ -256,6 +258,12 @@ namespace OpenSim.Region.Physics.Manager set { return; } } + public override bool FloatOnWater + { + set { return; } + } + + public override bool CollidingGround { get { return false; } diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index 7047ec1037..9bbbb222ea 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs @@ -185,6 +185,11 @@ namespace OpenSim.Region.Physics.OdePlugin set { m_buoyancy = value; } } + public override bool FloatOnWater + { + set { return; } + } + public override bool IsPhysical { get { return false; } diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index 5291cbff60..7cdc558b8e 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs @@ -73,6 +73,7 @@ namespace OpenSim.Region.Physics.OdePlugin public bool m_disabled = false; public bool m_taintadd = false; public bool m_taintselected = false; + public bool m_taintCollidesWater = false; public uint m_localID = 0; @@ -739,6 +740,11 @@ namespace OpenSim.Region.Physics.OdePlugin if (m_taintparent != _parent) changelink(timestep); + + if (m_taintCollidesWater != m_collidesWater) + changefloatonwater(timestep); + + } else { @@ -1333,6 +1339,24 @@ namespace OpenSim.Region.Physics.OdePlugin m_taintsize = _size; } + public void changefloatonwater(float timestep) + { + m_collidesWater = m_taintCollidesWater; + + if (prim_geom != (IntPtr)0) + { + if (m_collidesWater) + { + m_collisionFlags |= CollisionCategories.Water; + } + else + { + m_collisionFlags &= ~CollisionCategories.Water; + } + d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); + } + } + public void changeshape(float timestamp) { @@ -1895,6 +1919,14 @@ namespace OpenSim.Region.Physics.OdePlugin } } + public override bool FloatOnWater + { + set { + m_taintCollidesWater = value; + _parent_scene.AddPhysicsActorTaint(this); + } + } + public override void SetMomentum(PhysicsVector momentum) { } diff --git a/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs b/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs index dd2c0ddde6..d6c8202346 100644 --- a/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs +++ b/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs @@ -383,6 +383,11 @@ namespace OpenSim.Region.Physics.POSPlugin set { return; } } + public override bool FloatOnWater + { + set { return; } + } + public override bool IsPhysical { get { return false; } @@ -622,6 +627,11 @@ namespace OpenSim.Region.Physics.POSPlugin set { return; } } + public override bool FloatOnWater + { + set { return; } + } + public override PhysicsVector Velocity { get { return _velocity; } diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs index b03da3168e..910b2d2513 100644 --- a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs +++ b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs @@ -253,6 +253,11 @@ namespace OpenSim.Region.Physics.PhysXPlugin set { return; } } + public override bool FloatOnWater + { + set { return; } + } + public override bool IsPhysical { get { return false; } @@ -484,6 +489,11 @@ namespace OpenSim.Region.Physics.PhysXPlugin set { return; } } + public override bool FloatOnWater + { + set { return; } + } + public override bool ThrottleUpdates { get { return false; } diff --git a/OpenSim/Region/ScriptEngine/Common/BuiltIn_Commands_BaseClass.cs b/OpenSim/Region/ScriptEngine/Common/BuiltIn_Commands_BaseClass.cs index 79a106b056..05a1a1d617 100644 --- a/OpenSim/Region/ScriptEngine/Common/BuiltIn_Commands_BaseClass.cs +++ b/OpenSim/Region/ScriptEngine/Common/BuiltIn_Commands_BaseClass.cs @@ -1897,6 +1897,11 @@ namespace OpenSim.Region.ScriptEngine.Common m_LSL_Functions.osSetParcelMediaURL(url); } + public void osSetPrimFloatOnWater(int floatYN) + { + m_LSL_Functions.osSetPrimFloatOnWater(floatYN); + } + public double llList2Float(LSL_Types.list src, int index) { return m_LSL_Functions.llList2Float(src, index); diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs index 010961e069..623ac290ff 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs @@ -1508,6 +1508,8 @@ namespace OpenSim.Region.ScriptEngine.Common } } + + public void llSetHoverHeight(double height, int water, double tau) { m_host.AddScriptLPS(1); @@ -4405,6 +4407,18 @@ namespace OpenSim.Region.ScriptEngine.Common return false; } + public void osSetPrimFloatOnWater(int floatYN) + { + m_host.AddScriptLPS(1); + if (m_host.ParentGroup != null) + { + if (m_host.ParentGroup.RootPart != null) + { + m_host.ParentGroup.RootPart.SetFloatOnWater(floatYN); + } + } + } + private void NotImplemented(string command) { m_host.AddScriptLPS(1); diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs index d60d70e908..381ca62f30 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs @@ -648,6 +648,7 @@ namespace OpenSim.Region.ScriptEngine.Common void osRegionNotice(string msg); bool osConsoleCommand(string Command); void osSetParcelMediaURL(string url); + void osSetPrimFloatOnWater(int floatYN); } }