From 8205fe79ceaeebd31509a044005bf27d226dbe07 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sun, 22 Apr 2012 19:51:51 +0100
Subject: Fix bug where setting phantom on a prim would result in a server log
 message rather than setting phantom.

This was an oversight when removing some race conditions from PhysicsActor setting recently.
Regression tests extended to probe this code path.
Extending regression tests required implementation of a BasicPhysicsPrim (there was none before).  However, BasicPhysics plugin is still of no current practical use other than to fill in as a component for other parts of regression testing.
---
 .../Physics/BasicPhysicsPlugin/BasicPhysicsPrim.cs | 344 +++++++++++++++++++++
 .../BasicPhysicsPlugin/BasicPhysicsScene.cs        |  41 +--
 2 files changed, 367 insertions(+), 18 deletions(-)
 create mode 100644 OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPrim.cs

(limited to 'OpenSim/Region/Physics/BasicPhysicsPlugin')

diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPrim.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPrim.cs
new file mode 100644
index 0000000..ba7fe1e
--- /dev/null
+++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPrim.cs
@@ -0,0 +1,344 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of the OpenSimulator Project nor the
+ *       names of its contributors may be used to endorse or promote products
+ *       derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using System;
+using System.Collections.Generic;
+using Nini.Config;
+using OpenMetaverse;
+using OpenSim.Framework;
+using OpenSim.Region.Physics.Manager;
+
+namespace OpenSim.Region.Physics.BasicPhysicsPlugin
+{
+    public class BasicPhysicsPrim : PhysicsActor
+    {
+        private Vector3 _position;
+        private Vector3 _velocity;
+        private Vector3 _acceleration;
+        private Vector3 _size;
+        private PrimitiveBaseShape _shape;
+        private Vector3 m_rotationalVelocity;
+        private bool flying;
+        private bool iscolliding;
+
+        public BasicPhysicsPrim(
+            string name, uint localId, Vector3 position, Vector3 size, Quaternion orientation, PrimitiveBaseShape shape)
+        {
+            Name = name;
+            LocalID = localId;
+            Position = position;
+            Size = size;
+            Orientation = orientation;
+            Shape = shape;
+        }
+
+        public override int PhysicsActorType
+        {
+            get { return (int) ActorTypes.Agent; }
+            set { return; }
+        }
+
+        public override Vector3 RotationalVelocity
+        {
+            get { return m_rotationalVelocity; }
+            set { m_rotationalVelocity = value; }
+        }
+
+        public override bool SetAlwaysRun
+        {
+            get { return false; }
+            set { return; }
+        }
+
+        public override uint LocalID
+        {
+            set { return; }
+        }
+
+        public override bool Grabbed
+        {
+            set { return; }
+        }
+
+        public override bool Selected
+        {
+            set { return; }
+        }
+
+        public override float Buoyancy
+        {
+            get { return 0f; }
+            set { return; }
+        }
+
+        public override bool FloatOnWater
+        {
+            set { return; }
+        }
+
+        public override bool IsPhysical
+        {
+            get { return false; }
+            set { return; }
+        }
+
+        public override bool ThrottleUpdates
+        {
+            get { return false; }
+            set { return; }
+        }
+
+        public override bool Flying
+        {
+            get { return flying; }
+            set { flying = value; }
+        }
+
+        public override bool IsColliding
+        {
+            get { return iscolliding; }
+            set { iscolliding = value; }
+        }
+
+        public override bool CollidingGround
+        {
+            get { return false; }
+            set { return; }
+        }
+
+        public override bool CollidingObj
+        {
+            get { return false; }
+            set { return; }
+        }
+
+        public override bool Stopped
+        {
+            get { return false; }
+        }
+
+        public override Vector3 Position
+        {
+            get { return _position; }
+            set { _position = value; }
+        }
+
+        public override Vector3 Size
+        {
+            get { return _size; }
+            set {
+                  _size = value;
+                  _size.Z = _size.Z / 2.0f;
+                }
+        }
+
+        public override PrimitiveBaseShape Shape
+        {
+            set { _shape = value; }
+        }
+
+        public override float Mass
+        {
+            get { return 0f; }
+        }
+
+        public override Vector3 Force
+        {
+            get { return Vector3.Zero; }
+            set { return; }
+        }
+
+        public override int VehicleType
+        {
+            get { return 0; }
+            set { return; }
+        }
+
+        public override void VehicleFloatParam(int param, float value)
+        {
+
+        }
+
+        public override void VehicleVectorParam(int param, Vector3 value)
+        {
+
+        }
+
+        public override void VehicleRotationParam(int param, Quaternion rotation)
+        {
+
+        }
+
+        public override void VehicleFlags(int param, bool remove)
+        {
+
+        }
+
+        public override void SetVolumeDetect(int param)
+        {
+
+        }
+
+        public override Vector3 CenterOfMass
+        {
+            get { return Vector3.Zero; }
+        }
+
+        public override Vector3 GeometricCenter
+        {
+            get { return Vector3.Zero; }
+        }
+
+        public override Vector3 Velocity
+        {
+            get { return _velocity; }
+            set { _velocity = value; }
+        }
+
+        public override Vector3 Torque
+        {
+            get { return Vector3.Zero; }
+            set { return; }
+        }
+
+        public override float CollisionScore
+        {
+            get { return 0f; }
+            set { }
+        }
+
+        public override Quaternion Orientation { get; set; }
+
+        public override Vector3 Acceleration
+        {
+            get { return _acceleration; }
+            set { _acceleration = value; }
+        }
+
+        public override bool Kinematic
+        {
+            get { return true; }
+            set { }
+        }
+
+        public override void link(PhysicsActor obj)
+        {
+        }
+
+        public override void delink()
+        {
+        }
+
+        public override void LockAngularMotion(Vector3 axis)
+        {
+        }
+
+        public override void AddForce(Vector3 force, bool pushforce)
+        {
+        }
+
+        public override void AddAngularForce(Vector3 force, bool pushforce)
+        {
+        }
+
+        public override void SetMomentum(Vector3 momentum)
+        {
+        }
+
+        public override void CrossingFailure()
+        {
+        }
+
+        public override Vector3 PIDTarget
+        {
+            set { return; }
+        }
+
+        public override bool PIDActive
+        {
+            set { return; }
+        }
+
+        public override float PIDTau
+        {
+            set { return; }
+        }
+
+        public override float PIDHoverHeight
+        {
+            set { return; }
+        }
+
+        public override bool PIDHoverActive
+        {
+            set { return; }
+        }
+
+        public override PIDHoverType PIDHoverType
+        {
+            set { return; }
+        }
+
+        public override float PIDHoverTau
+        {
+            set { return; }
+        }
+
+        public override Quaternion APIDTarget 
+        { 
+            set { return; }
+        }
+        
+        public override bool APIDActive
+        { 
+            set { return; }
+        }
+        
+        public override float APIDStrength
+        { 
+            set { return; }
+        }
+        
+        public override float APIDDamping
+        { 
+            set { return; }
+        }
+
+        public override void SubscribeEvents(int ms)
+        {
+        }
+
+        public override void UnSubscribeEvents()
+        {
+        }
+
+        public override bool SubscribedEvents()
+        {
+            return false;
+        }
+    }
+}
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs
index 2e14216..f5826ed 100644
--- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs
+++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs
@@ -34,9 +34,17 @@ using OpenSim.Region.Physics.Manager;
 
 namespace OpenSim.Region.Physics.BasicPhysicsPlugin
 {
+    /// <summary>
+    /// This is an incomplete extremely basic physics implementation
+    /// </summary>
+    /// <remarks>
+    /// Not useful for anything at the moment apart from some regression testing in other components where some form
+    /// of physics plugin is needed.
+    /// </remarks>
     public class BasicScene : PhysicsScene
     {
         private List<BasicActor> _actors = new List<BasicActor>();
+        private List<BasicPhysicsPrim> _prims = new List<BasicPhysicsPrim>();
         private float[] _heightMap;
 
         //protected internal string sceneIdentifier;
@@ -50,10 +58,19 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
         {
         }
 
-        public override void Dispose()
+        public override void Dispose() {}
+
+        public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
+                                                  Vector3 size, Quaternion rotation, bool isPhysical, uint localid)
         {
+            BasicPhysicsPrim prim = new BasicPhysicsPrim(primName, localid, position, size, rotation, pbs);
+            prim.IsPhysical = isPhysical;
+
+            _prims.Add(prim);
 
+            return prim;
         }
+
         public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying)
         {
             BasicActor act = new BasicActor(size);
@@ -63,30 +80,18 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
             return act;
         }
 
-        public override void RemovePrim(PhysicsActor prim)
+        public override void RemovePrim(PhysicsActor actor)
         {
+            BasicPhysicsPrim prim = (BasicPhysicsPrim)actor;
+            if (_prims.Contains(prim))
+                _prims.Remove(prim);
         }
 
         public override void RemoveAvatar(PhysicsActor actor)
         {
-            BasicActor act = (BasicActor) actor;
+            BasicActor act = (BasicActor)actor;
             if (_actors.Contains(act))
-            {
                 _actors.Remove(act);
-            }
-        }
-
-/*
-        public override PhysicsActor AddPrim(Vector3 position, Vector3 size, Quaternion rotation)
-        {
-            return null;
-        }
-*/
-
-        public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
-                                                  Vector3 size, Quaternion rotation, bool isPhysical, uint localid)
-        {
-            return null;
         }
 
         public override void AddPhysicsActorTaint(PhysicsActor prim)
-- 
cgit v1.1


From 49ed68e98c34c752fac407aa9359201e244df19f Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sun, 22 Apr 2012 20:28:12 +0100
Subject: refactor: simply some properties code in BasicPhysicsPlugin

---
 .../BasicPhysicsPlugin/BasicPhysicsActor.cs        | 42 ++++------------------
 .../Physics/BasicPhysicsPlugin/BasicPhysicsPrim.cs | 42 ++++------------------
 2 files changed, 12 insertions(+), 72 deletions(-)

(limited to 'OpenSim/Region/Physics/BasicPhysicsPlugin')

diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs
index b1a3ff9..e43136a 100644
--- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs
+++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs
@@ -36,13 +36,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
 {
     public class BasicActor : PhysicsActor
     {
-        private Vector3 _position;
-        private Vector3 _velocity;
-        private Vector3 _acceleration;
         private Vector3 _size;
-        private Vector3 m_rotationalVelocity;
-        private bool flying;
-        private bool iscolliding;
 
         public BasicActor(Vector3 size)
         {
@@ -55,11 +49,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
             set { return; }
         }
 
-        public override Vector3 RotationalVelocity
-        {
-            get { return m_rotationalVelocity; }
-            set { m_rotationalVelocity = value; }
-        }
+        public override Vector3 RotationalVelocity { get; set; }
 
         public override bool SetAlwaysRun
         {
@@ -105,17 +95,9 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
             set { return; }
         }
 
-        public override bool Flying
-        {
-            get { return flying; }
-            set { flying = value; }
-        }
+        public override bool Flying { get; set; }
 
-        public override bool IsColliding
-        {
-            get { return iscolliding; }
-            set { iscolliding = value; }
-        }
+        public override bool IsColliding { get; set; }
 
         public override bool CollidingGround
         {
@@ -134,11 +116,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
             get { return false; }
         }
 
-        public override Vector3 Position
-        {
-            get { return _position; }
-            set { _position = value; }
-        }
+        public override Vector3 Position { get; set; }
 
         public override Vector3 Size
         {
@@ -206,11 +184,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
             get { return Vector3.Zero; }
         }
 
-        public override Vector3 Velocity
-        {
-            get { return _velocity; }
-            set { _velocity = value; }
-        }
+        public override Vector3 Velocity { get; set; }
 
         public override Vector3 Torque
         {
@@ -230,11 +204,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
             set { }
         }
 
-        public override Vector3 Acceleration
-        {
-            get { return _acceleration; }
-            set { _acceleration = value; }
-        }
+        public override Vector3 Acceleration { get; set; }
 
         public override bool Kinematic
         {
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPrim.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPrim.cs
index ba7fe1e..b89eeed 100644
--- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPrim.cs
+++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPrim.cs
@@ -36,14 +36,8 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
 {
     public class BasicPhysicsPrim : PhysicsActor
     {
-        private Vector3 _position;
-        private Vector3 _velocity;
-        private Vector3 _acceleration;
         private Vector3 _size;
         private PrimitiveBaseShape _shape;
-        private Vector3 m_rotationalVelocity;
-        private bool flying;
-        private bool iscolliding;
 
         public BasicPhysicsPrim(
             string name, uint localId, Vector3 position, Vector3 size, Quaternion orientation, PrimitiveBaseShape shape)
@@ -62,11 +56,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
             set { return; }
         }
 
-        public override Vector3 RotationalVelocity
-        {
-            get { return m_rotationalVelocity; }
-            set { m_rotationalVelocity = value; }
-        }
+        public override Vector3 RotationalVelocity { get; set; }
 
         public override bool SetAlwaysRun
         {
@@ -112,17 +102,9 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
             set { return; }
         }
 
-        public override bool Flying
-        {
-            get { return flying; }
-            set { flying = value; }
-        }
+        public override bool Flying { get; set; }
 
-        public override bool IsColliding
-        {
-            get { return iscolliding; }
-            set { iscolliding = value; }
-        }
+        public override bool IsColliding { get; set; }
 
         public override bool CollidingGround
         {
@@ -141,11 +123,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
             get { return false; }
         }
 
-        public override Vector3 Position
-        {
-            get { return _position; }
-            set { _position = value; }
-        }
+        public override Vector3 Position { get; set; }
 
         public override Vector3 Size
         {
@@ -213,11 +191,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
             get { return Vector3.Zero; }
         }
 
-        public override Vector3 Velocity
-        {
-            get { return _velocity; }
-            set { _velocity = value; }
-        }
+        public override Vector3 Velocity { get; set; }
 
         public override Vector3 Torque
         {
@@ -233,11 +207,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
 
         public override Quaternion Orientation { get; set; }
 
-        public override Vector3 Acceleration
-        {
-            get { return _acceleration; }
-            set { _acceleration = value; }
-        }
+        public override Vector3 Acceleration { get; set; }
 
         public override bool Kinematic
         {
-- 
cgit v1.1


From 1926de5a0599051c27c065fb06da3dc536e6784a Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sat, 30 Jun 2012 01:25:27 +0100
Subject: Remove some mono compiler warnings

---
 OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPrim.cs | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

(limited to 'OpenSim/Region/Physics/BasicPhysicsPlugin')

diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPrim.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPrim.cs
index b89eeed..47d7df3 100644
--- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPrim.cs
+++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPrim.cs
@@ -37,7 +37,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
     public class BasicPhysicsPrim : PhysicsActor
     {
         private Vector3 _size;
-        private PrimitiveBaseShape _shape;
+//        private PrimitiveBaseShape _shape;
 
         public BasicPhysicsPrim(
             string name, uint localId, Vector3 position, Vector3 size, Quaternion orientation, PrimitiveBaseShape shape)
@@ -136,7 +136,8 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
 
         public override PrimitiveBaseShape Shape
         {
-            set { _shape = value; }
+//            set { _shape = value; }
+            set {}
         }
 
         public override float Mass
-- 
cgit v1.1