From 1d6b33bc2da3b312cff1d1802a73aacdf72b0385 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 30 Aug 2015 20:06:53 -0700 Subject: Major renaming of Physics dlls / folders. No functional changes, just renames. --- .../PhysicsModules/SharedBase/AssemblyInfo.cs | 58 ++ .../PhysicsModules/SharedBase/CollisionLocker.cs | 73 +++ .../Region/PhysicsModules/SharedBase/IMesher.cs | 71 +++ .../SharedBase/IPhysicsParameters.cs | 73 +++ .../PhysicsModules/SharedBase/NullPhysicsScene.cs | 122 +++++ .../PhysicsModules/SharedBase/PhysicsActor.cs | 584 +++++++++++++++++++++ .../PhysicsModules/SharedBase/PhysicsJoint.cs | 55 ++ .../SharedBase/PhysicsPluginManager.cs | 242 +++++++++ .../PhysicsModules/SharedBase/PhysicsScene.cs | 361 +++++++++++++ .../PhysicsModules/SharedBase/PhysicsSensor.cs | 78 +++ .../PhysicsModules/SharedBase/PhysicsVector.cs | 186 +++++++ .../PhysicsModules/SharedBase/VehicleConstants.cs | 121 +++++ .../Region/PhysicsModules/SharedBase/ZeroMesher.cs | 83 +++ 13 files changed, 2107 insertions(+) create mode 100644 OpenSim/Region/PhysicsModules/SharedBase/AssemblyInfo.cs create mode 100644 OpenSim/Region/PhysicsModules/SharedBase/CollisionLocker.cs create mode 100644 OpenSim/Region/PhysicsModules/SharedBase/IMesher.cs create mode 100755 OpenSim/Region/PhysicsModules/SharedBase/IPhysicsParameters.cs create mode 100644 OpenSim/Region/PhysicsModules/SharedBase/NullPhysicsScene.cs create mode 100644 OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs create mode 100644 OpenSim/Region/PhysicsModules/SharedBase/PhysicsJoint.cs create mode 100644 OpenSim/Region/PhysicsModules/SharedBase/PhysicsPluginManager.cs create mode 100644 OpenSim/Region/PhysicsModules/SharedBase/PhysicsScene.cs create mode 100644 OpenSim/Region/PhysicsModules/SharedBase/PhysicsSensor.cs create mode 100644 OpenSim/Region/PhysicsModules/SharedBase/PhysicsVector.cs create mode 100644 OpenSim/Region/PhysicsModules/SharedBase/VehicleConstants.cs create mode 100644 OpenSim/Region/PhysicsModules/SharedBase/ZeroMesher.cs (limited to 'OpenSim/Region/PhysicsModules/SharedBase') diff --git a/OpenSim/Region/PhysicsModules/SharedBase/AssemblyInfo.cs b/OpenSim/Region/PhysicsModules/SharedBase/AssemblyInfo.cs new file mode 100644 index 0000000..33f60e4 --- /dev/null +++ b/OpenSim/Region/PhysicsModules/SharedBase/AssemblyInfo.cs @@ -0,0 +1,58 @@ +/* + * 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.Reflection; +using System.Runtime.InteropServices; + +// Information about this assembly is defined by the following +// attributes. +// +// change them to the information which is associated with the assembly +// you compile. + +[assembly : AssemblyTitle("PhysicsManager")] +[assembly : AssemblyDescription("")] +[assembly : AssemblyConfiguration("")] +[assembly : AssemblyCompany("http://opensimulator.org")] +[assembly : AssemblyProduct("PhysicsManager")] +[assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers")] +[assembly : AssemblyTrademark("")] +[assembly : AssemblyCulture("")] + +// This sets the default COM visibility of types in the assembly to invisible. +// If you need to expose a type to COM, use [ComVisible(true)] on that type. + +[assembly : ComVisible(false)] + +// The assembly version has following format : +// +// Major.Minor.Build.Revision +// +// You can specify all values by your own or you can build default build and revision +// numbers with the '*' character (the default): + +[assembly : AssemblyVersion("0.8.2.*")] diff --git a/OpenSim/Region/PhysicsModules/SharedBase/CollisionLocker.cs b/OpenSim/Region/PhysicsModules/SharedBase/CollisionLocker.cs new file mode 100644 index 0000000..cace4e4 --- /dev/null +++ b/OpenSim/Region/PhysicsModules/SharedBase/CollisionLocker.cs @@ -0,0 +1,73 @@ +/* + * 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; + +namespace OpenSim.Region.Physics.Manager +{ + public class CollisionLocker + { + private List worldlock = new List(); + + public CollisionLocker() + { + + } + + public void dlock(IntPtr world) + { + lock (worldlock) + { + worldlock.Add(world); + } + + } + + public void dunlock(IntPtr world) + { + lock (worldlock) + { + worldlock.Remove(world); + } + } + + public bool lockquery() + { + return (worldlock.Count > 0); + } + + public void drelease(IntPtr world) + { + lock (worldlock) + { + if (worldlock.Contains(world)) + worldlock.Remove(world); + } + } + } +} diff --git a/OpenSim/Region/PhysicsModules/SharedBase/IMesher.cs b/OpenSim/Region/PhysicsModules/SharedBase/IMesher.cs new file mode 100644 index 0000000..2e7bb5d --- /dev/null +++ b/OpenSim/Region/PhysicsModules/SharedBase/IMesher.cs @@ -0,0 +1,71 @@ +/* + * 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 OpenSim.Framework; +using OpenMetaverse; + +namespace OpenSim.Region.Physics.Manager +{ + public interface IMesher + { + IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod); + IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical); + IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool shouldCache); + } + + // Values for level of detail to be passed to the mesher. + // Values origionally chosen for the LOD of sculpties (the sqrt(width*heigth) of sculpt texture) + // Lower level of detail reduces the number of vertices used to represent the meshed shape. + public enum LevelOfDetail + { + High = 32, + Medium = 16, + Low = 8, + VeryLow = 4 + } + + public interface IVertex + { + } + + public interface IMesh + { + List getVertexList(); + int[] getIndexListAsInt(); + int[] getIndexListAsIntLocked(); + float[] getVertexListAsFloat(); + float[] getVertexListAsFloatLocked(); + void getIndexListAsPtrToIntArray(out IntPtr indices, out int triStride, out int indexCount); + void getVertexListAsPtrToFloatArray(out IntPtr vertexList, out int vertexStride, out int vertexCount); + void releaseSourceMeshData(); + void releasePinned(); + void Append(IMesh newMesh); + void TransformLinear(float[,] matrix, float[] offset); + } +} diff --git a/OpenSim/Region/PhysicsModules/SharedBase/IPhysicsParameters.cs b/OpenSim/Region/PhysicsModules/SharedBase/IPhysicsParameters.cs new file mode 100755 index 0000000..31a397c --- /dev/null +++ b/OpenSim/Region/PhysicsModules/SharedBase/IPhysicsParameters.cs @@ -0,0 +1,73 @@ +/* + * 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 OpenSim.Framework; +using OpenMetaverse; + +namespace OpenSim.Region.Physics.Manager +{ + public struct PhysParameterEntry + { + // flags to say to apply to all or no instances (I wish one could put consts into interfaces) + public const uint APPLY_TO_ALL = 0xfffffff3; + public const uint APPLY_TO_NONE = 0xfffffff4; + + // values that denote true and false values + public const float NUMERIC_TRUE = 1f; + public const float NUMERIC_FALSE = 0f; + + public string name; + public string desc; + + public PhysParameterEntry(string n, string d) + { + name = n; + desc = d; + } + } + + // Interface for a physics scene that implements the runtime setting and getting of physics parameters + public interface IPhysicsParameters + { + // Get the list of parameters this physics engine supports + PhysParameterEntry[] GetParameterList(); + + // Set parameter on a specific or all instances. + // Return 'false' if not able to set the parameter. + bool SetPhysicsParameter(string parm, string value, uint localID); + + // Get parameter. + // Return 'false' if not able to get the parameter. + bool GetPhysicsParameter(string parm, out string value); + + // Get parameter from a particular object + // TODO: + // bool GetPhysicsParameter(string parm, out string value, uint localID); + } +} diff --git a/OpenSim/Region/PhysicsModules/SharedBase/NullPhysicsScene.cs b/OpenSim/Region/PhysicsModules/SharedBase/NullPhysicsScene.cs new file mode 100644 index 0000000..b52f1f6 --- /dev/null +++ b/OpenSim/Region/PhysicsModules/SharedBase/NullPhysicsScene.cs @@ -0,0 +1,122 @@ +/* + * 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.Collections.Generic; +using System.Reflection; +using log4net; +using Nini.Config; +using OpenSim.Framework; +using OpenMetaverse; + +namespace OpenSim.Region.Physics.Manager +{ + class NullPhysicsScene : PhysicsScene + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private static int m_workIndicator; + + public override void Initialise(IMesher meshmerizer, IConfigSource config) + { + // Does nothing right now + } + + public override PhysicsActor AddAvatar( + string avName, Vector3 position, Vector3 velocity, Vector3 size, bool isFlying) + { + m_log.InfoFormat("[PHYSICS]: NullPhysicsScene : AddAvatar({0})", position); + return PhysicsActor.Null; + } + + public override void RemoveAvatar(PhysicsActor actor) + { + } + + public override void RemovePrim(PhysicsActor prim) + { + } + public override void SetWaterLevel(float baseheight) + { + + } + +/* + public override PhysicsActor AddPrim(Vector3 position, Vector3 size, Quaternion rotation) + { + m_log.InfoFormat("NullPhysicsScene : AddPrim({0},{1})", position, size); + return PhysicsActor.Null; + } +*/ + + public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, + Vector3 size, Quaternion rotation, bool isPhysical, uint localid) + { + m_log.InfoFormat("[PHYSICS]: NullPhysicsScene : AddPrim({0},{1})", position, size); + return PhysicsActor.Null; + } + + public override void AddPhysicsActorTaint(PhysicsActor prim) + { + } + + public override float Simulate(float timeStep) + { + m_workIndicator = (m_workIndicator + 1) % 10; + + return 0f; + } + + public override void GetResults() + { + m_log.Info("[PHYSICS]: NullPhysicsScene : GetResults()"); + } + + public override void SetTerrain(float[] heightMap) + { + m_log.InfoFormat("[PHYSICS]: NullPhysicsScene : SetTerrain({0} items)", heightMap.Length); + } + + public override void DeleteTerrain() + { + } + + public override bool IsThreaded + { + get { return false; } + } + + public override void Dispose() + { + } + + public override Dictionary GetTopColliders() + { + Dictionary returncolliders = new Dictionary(); + return returncolliders; + } + } +} \ No newline at end of file diff --git a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs new file mode 100644 index 0000000..6bc6e23 --- /dev/null +++ b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs @@ -0,0 +1,584 @@ +/* + * 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 log4net; +using System; +using System.Collections.Generic; +using System.Reflection; +using OpenSim.Framework; +using OpenMetaverse; + +namespace OpenSim.Region.Physics.Manager +{ + public delegate void PositionUpdate(Vector3 position); + public delegate void VelocityUpdate(Vector3 velocity); + public delegate void OrientationUpdate(Quaternion orientation); + + public enum ActorTypes : int + { + Unknown = 0, + Agent = 1, + Prim = 2, + Ground = 3 + } + + public enum PIDHoverType + { + Ground, + GroundAndWater, + Water, + Absolute + } + + public struct ContactPoint + { + public Vector3 Position; + public Vector3 SurfaceNormal; + public float PenetrationDepth; + + public ContactPoint(Vector3 position, Vector3 surfaceNormal, float penetrationDepth) + { + Position = position; + SurfaceNormal = surfaceNormal; + PenetrationDepth = penetrationDepth; + } + } + + /// + /// Used to pass collision information to OnCollisionUpdate listeners. + /// + public class CollisionEventUpdate : EventArgs + { + /// + /// Number of collision events in this update. + /// + public int Count { get { return m_objCollisionList.Count; } } + + public bool CollisionsOnPreviousFrame { get; private set; } + + public Dictionary m_objCollisionList; + + public CollisionEventUpdate(Dictionary objCollisionList) + { + m_objCollisionList = objCollisionList; + } + + public CollisionEventUpdate() + { + m_objCollisionList = new Dictionary(); + } + + public void AddCollider(uint localID, ContactPoint contact) + { + if (!m_objCollisionList.ContainsKey(localID)) + { + m_objCollisionList.Add(localID, contact); + } + else + { + if (m_objCollisionList[localID].PenetrationDepth < contact.PenetrationDepth) + m_objCollisionList[localID] = contact; + } + } + + /// + /// Clear added collision events. + /// + public void Clear() + { + m_objCollisionList.Clear(); + } + } + + public abstract class PhysicsActor + { +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + public delegate void RequestTerseUpdate(); + public delegate void CollisionUpdate(EventArgs e); + public delegate void OutOfBounds(Vector3 pos); + +// disable warning: public events +#pragma warning disable 67 + public event PositionUpdate OnPositionUpdate; + public event VelocityUpdate OnVelocityUpdate; + public event OrientationUpdate OnOrientationUpdate; + public event RequestTerseUpdate OnRequestTerseUpdate; + + /// + /// Subscribers to this event must synchronously handle the dictionary of collisions received, since the event + /// object is reused in subsequent physics frames. + /// + public event CollisionUpdate OnCollisionUpdate; + + public event OutOfBounds OnOutOfBounds; +#pragma warning restore 67 + + public static PhysicsActor Null + { + get { return new NullPhysicsActor(); } + } + + public abstract bool Stopped { get; } + + public abstract Vector3 Size { get; set; } + + public virtual byte PhysicsShapeType { get; set; } + + public abstract PrimitiveBaseShape Shape { set; } + + uint m_baseLocalID; + public virtual uint LocalID + { + set { m_baseLocalID = value; } + get { return m_baseLocalID; } + } + + public abstract bool Grabbed { set; } + + public abstract bool Selected { set; } + + /// + /// Name of this actor. + /// + /// + /// XXX: Bizarrely, this cannot be "Terrain" or "Water" right now unless it really is simulating terrain or + /// water. This is not a problem due to the formatting of names given by prims and avatars. + /// + public string Name { get; protected set; } + + /// + /// This is being used by ODE joint code. + /// + public string SOPName; + + public abstract void CrossingFailure(); + + public abstract void link(PhysicsActor obj); + + public abstract void delink(); + + public abstract void LockAngularMotion(Vector3 axis); + + public virtual void RequestPhysicsterseUpdate() + { + // Make a temporary copy of the event to avoid possibility of + // a race condition if the last subscriber unsubscribes + // immediately after the null check and before the event is raised. + RequestTerseUpdate handler = OnRequestTerseUpdate; + + if (handler != null) + { + handler(); + } + } + + public virtual void RaiseOutOfBounds(Vector3 pos) + { + // Make a temporary copy of the event to avoid possibility of + // a race condition if the last subscriber unsubscribes + // immediately after the null check and before the event is raised. + OutOfBounds handler = OnOutOfBounds; + + if (handler != null) + { + handler(pos); + } + } + + public virtual void SendCollisionUpdate(EventArgs e) + { + CollisionUpdate handler = OnCollisionUpdate; + +// m_log.DebugFormat("[PHYSICS ACTOR]: Sending collision for {0}", LocalID); + + if (handler != null) + handler(e); + } + + public virtual void SetMaterial (int material) { } + public virtual float Density { get; set; } + public virtual float GravModifier { get; set; } + public virtual float Friction { get; set; } + public virtual float Restitution { get; set; } + + /// + /// Position of this actor. + /// + /// + /// Setting this directly moves the actor to a given position. + /// Getting this retrieves the position calculated by physics scene updates, using factors such as velocity and + /// collisions. + /// + public abstract Vector3 Position { get; set; } + + public abstract float Mass { get; } + public abstract Vector3 Force { get; set; } + + public abstract int VehicleType { get; set; } + public abstract void VehicleFloatParam(int param, float value); + public abstract void VehicleVectorParam(int param, Vector3 value); + public abstract void VehicleRotationParam(int param, Quaternion rotation); + public abstract void VehicleFlags(int param, bool remove); + + /// + /// Allows the detection of collisions with inherently non-physical prims. see llVolumeDetect for more + /// + public abstract void SetVolumeDetect(int param); + + public abstract Vector3 GeometricCenter { get; } + public abstract Vector3 CenterOfMass { get; } + + /// + /// The desired velocity of this actor. + /// + /// + /// Setting this provides a target velocity for physics scene updates. + /// Getting this returns the last set target. Fetch Velocity to get the current velocity. + /// + protected Vector3 m_targetVelocity; + public virtual Vector3 TargetVelocity + { + get { return m_targetVelocity; } + set { + m_targetVelocity = value; + Velocity = m_targetVelocity; + } + } + + public abstract Vector3 Velocity { get; set; } + + public abstract Vector3 Torque { get; set; } + public abstract float CollisionScore { get; set;} + public abstract Vector3 Acceleration { get; set; } + public abstract Quaternion Orientation { get; set; } + public abstract int PhysicsActorType { get; set; } + public abstract bool IsPhysical { get; set; } + public abstract bool Flying { get; set; } + public abstract bool SetAlwaysRun { get; set; } + public abstract bool ThrottleUpdates { get; set; } + public abstract bool IsColliding { get; set; } + public abstract bool CollidingGround { get; set; } + public abstract bool CollidingObj { get; set; } + public abstract bool FloatOnWater { set; } + public abstract Vector3 RotationalVelocity { get; set; } + public abstract bool Kinematic { get; set; } + public abstract float Buoyancy { get; set; } + + // Used for MoveTo + public abstract Vector3 PIDTarget { set; } + public abstract bool PIDActive { get; set; } + public abstract float PIDTau { set; } + + // Used for llSetHoverHeight and maybe vehicle height + // Hover Height will override MoveTo target's Z + public abstract bool PIDHoverActive { set;} + public abstract float PIDHoverHeight { set;} + public abstract PIDHoverType PIDHoverType { set;} + public abstract float PIDHoverTau { set;} + + // For RotLookAt + public abstract Quaternion APIDTarget { set;} + public abstract bool APIDActive { set;} + public abstract float APIDStrength { set;} + public abstract float APIDDamping { set;} + + public abstract void AddForce(Vector3 force, bool pushforce); + public abstract void AddAngularForce(Vector3 force, bool pushforce); + public abstract void SetMomentum(Vector3 momentum); + public abstract void SubscribeEvents(int ms); + public abstract void UnSubscribeEvents(); + public abstract bool SubscribedEvents(); + + // Extendable interface for new, physics engine specific operations + public virtual object Extension(string pFunct, params object[] pParams) + { + // A NOP of the physics engine does not implement this feature + return null; + } + } + + public class NullPhysicsActor : PhysicsActor + { + public override bool Stopped + { + get{ return false; } + } + + public override Vector3 Position + { + get { return Vector3.Zero; } + set { return; } + } + + 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 CollidingGround + { + get { return false; } + set { return; } + } + + public override bool CollidingObj + { + get { return false; } + set { return; } + } + + public override Vector3 Size + { + get { return Vector3.Zero; } + set { return; } + } + + 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 void SetMaterial(int material) + { + + } + + public override Vector3 CenterOfMass + { + get { return Vector3.Zero; } + } + + public override Vector3 GeometricCenter + { + get { return Vector3.Zero; } + } + + public override PrimitiveBaseShape Shape + { + set { return; } + } + + public override Vector3 Velocity + { + get { return Vector3.Zero; } + set { return; } + } + + public override Vector3 Torque + { + get { return Vector3.Zero; } + set { return; } + } + + public override float CollisionScore + { + get { return 0f; } + set { } + } + + public override void CrossingFailure() + { + } + + public override Quaternion Orientation + { + get { return Quaternion.Identity; } + set { } + } + + public override Vector3 Acceleration + { + get { return Vector3.Zero; } + set { } + } + + public override bool IsPhysical + { + get { return false; } + set { return; } + } + + public override bool Flying + { + get { return false; } + set { return; } + } + + public override bool ThrottleUpdates + { + get { return false; } + set { return; } + } + + public override bool IsColliding + { + get { return false; } + set { return; } + } + + public override int PhysicsActorType + { + get { return (int) ActorTypes.Unknown; } + set { return; } + } + + public override bool Kinematic + { + get { return true; } + set { return; } + } + + 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 Vector3 RotationalVelocity + { + get { return Vector3.Zero; } + set { return; } + } + + public override Vector3 PIDTarget { set { return; } } + + public override bool PIDActive + { + get { return false; } + 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 SetMomentum(Vector3 momentum) + { + } + + public override void SubscribeEvents(int ms) + { + + } + public override void UnSubscribeEvents() + { + + } + public override bool SubscribedEvents() + { + return false; + } + } +} diff --git a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsJoint.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsJoint.cs new file mode 100644 index 0000000..b685d04 --- /dev/null +++ b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsJoint.cs @@ -0,0 +1,55 @@ +/* + * 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 OpenSim.Framework; +using OpenMetaverse; + +namespace OpenSim.Region.Physics.Manager +{ + public enum PhysicsJointType : int + { + Ball = 0, + Hinge = 1 + } + + public class PhysicsJoint + { + public virtual bool IsInPhysicsEngine { get { return false; } } // set internally to indicate if this joint has already been passed to the physics engine or is still pending + public PhysicsJointType Type; + public string RawParams; + public List BodyNames = new List(); + public Vector3 Position; // global coords + public Quaternion Rotation; // global coords + public string ObjectNameInScene; // proxy object in scene that represents the joint position/orientation + public string TrackedBodyName; // body name that this joint is attached to (ObjectNameInScene will follow TrackedBodyName) + public Quaternion LocalRotation; // joint orientation relative to one of the involved bodies, the tracked body + public int ErrorMessageCount; // total # of error messages printed for this joint since its creation. if too many, further error messages are suppressed to prevent flooding. + public const int maxErrorMessages = 100; // no more than this # of error messages will be printed for each joint + } +} diff --git a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsPluginManager.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsPluginManager.cs new file mode 100644 index 0000000..d8279b7 --- /dev/null +++ b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsPluginManager.cs @@ -0,0 +1,242 @@ +/* + * 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 System.IO; +using System.Reflection; +using Nini.Config; +using log4net; +using OpenSim.Framework; +using OpenMetaverse; + +namespace OpenSim.Region.Physics.Manager +{ + /// + /// Description of MyClass. + /// + public class PhysicsPluginManager + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private Dictionary _PhysPlugins = new Dictionary(); + private Dictionary _MeshPlugins = new Dictionary(); + + /// + /// Constructor. + /// + public PhysicsPluginManager() + { + // Load "plugins", that are hard coded and not existing in form of an external lib, and hence always + // available + IMeshingPlugin plugHard; + plugHard = new ZeroMesherPlugin(); + _MeshPlugins.Add(plugHard.GetName(), plugHard); + + m_log.Info("[PHYSICS]: Added meshing engine: " + plugHard.GetName()); + } + + /// + /// Get a physics scene for the given physics engine and mesher. + /// + /// + /// + /// + /// + public PhysicsScene GetPhysicsScene(string physEngineName, string meshEngineName, + IConfigSource config, string regionName, Vector3 regionExtent) + { + if (String.IsNullOrEmpty(physEngineName)) + { + return PhysicsScene.Null; + } + + if (String.IsNullOrEmpty(meshEngineName)) + { + return PhysicsScene.Null; + } + + IMesher meshEngine = null; + if (_MeshPlugins.ContainsKey(meshEngineName)) + { + m_log.Info("[PHYSICS]: creating meshing engine " + meshEngineName); + meshEngine = _MeshPlugins[meshEngineName].GetMesher(config); + } + else + { + m_log.WarnFormat("[PHYSICS]: couldn't find meshingEngine: {0}", meshEngineName); + throw new ArgumentException(String.Format("couldn't find meshingEngine: {0}", meshEngineName)); + } + + if (_PhysPlugins.ContainsKey(physEngineName)) + { + m_log.Info("[PHYSICS]: creating " + physEngineName); + PhysicsScene result = _PhysPlugins[physEngineName].GetScene(regionName); + result.Initialise(meshEngine, config, regionExtent); + return result; + } + else + { + m_log.WarnFormat("[PHYSICS]: couldn't find physicsEngine: {0}", physEngineName); + throw new ArgumentException(String.Format("couldn't find physicsEngine: {0}", physEngineName)); + } + } + + /// + /// Load all plugins in assemblies at the given path + /// + /// + public void LoadPluginsFromAssemblies(string assembliesPath) + { + // Walk all assemblies (DLLs effectively) and see if they are home + // of a plugin that is of interest for us + string[] pluginFiles = Directory.GetFiles(assembliesPath, "*.dll"); + + for (int i = 0; i < pluginFiles.Length; i++) + { + LoadPluginsFromAssembly(pluginFiles[i]); + } + } + + /// + /// Load plugins from an assembly at the given path + /// + /// + public void LoadPluginsFromAssembly(string assemblyPath) + { + // TODO / NOTE + // The assembly named 'OpenSim.Region.Physics.BasicPhysicsPlugin' was loaded from + // 'file:///C:/OpenSim/trunk2/bin/Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll' + // using the LoadFrom context. The use of this context can result in unexpected behavior + // for serialization, casting and dependency resolution. In almost all cases, it is recommended + // that the LoadFrom context be avoided. This can be done by installing assemblies in the + // Global Assembly Cache or in the ApplicationBase directory and using Assembly. + // Load when explicitly loading assemblies. + Assembly pluginAssembly = null; + Type[] types = null; + + try + { + pluginAssembly = Assembly.LoadFrom(assemblyPath); + } + catch (Exception ex) + { + m_log.Error("[PHYSICS]: Failed to load plugin from " + assemblyPath, ex); + } + + if (pluginAssembly != null) + { + try + { + types = pluginAssembly.GetTypes(); + } + catch (ReflectionTypeLoadException ex) + { + m_log.Error("[PHYSICS]: Failed to enumerate types in plugin from " + assemblyPath + ": " + + ex.LoaderExceptions[0].Message, ex); + } + catch (Exception ex) + { + m_log.Error("[PHYSICS]: Failed to enumerate types in plugin from " + assemblyPath, ex); + } + + if (types != null) + { + foreach (Type pluginType in types) + { + if (pluginType.IsPublic) + { + if (!pluginType.IsAbstract) + { + Type physTypeInterface = pluginType.GetInterface("IPhysicsPlugin"); + + if (physTypeInterface != null) + { + IPhysicsPlugin plug = + (IPhysicsPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + plug.Init(); + if (!_PhysPlugins.ContainsKey(plug.GetName())) + { + _PhysPlugins.Add(plug.GetName(), plug); + m_log.Info("[PHYSICS]: Added physics engine: " + plug.GetName()); + } + } + + Type meshTypeInterface = pluginType.GetInterface("IMeshingPlugin"); + + if (meshTypeInterface != null) + { + IMeshingPlugin plug = + (IMeshingPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + if (!_MeshPlugins.ContainsKey(plug.GetName())) + { + _MeshPlugins.Add(plug.GetName(), plug); + m_log.Info("[PHYSICS]: Added meshing engine: " + plug.GetName()); + } + } + + physTypeInterface = null; + meshTypeInterface = null; + } + } + } + } + } + + pluginAssembly = null; + } + + //--- + public static void PhysicsPluginMessage(string message, bool isWarning) + { + if (isWarning) + { + m_log.Warn("[PHYSICS]: " + message); + } + else + { + m_log.Info("[PHYSICS]: " + message); + } + } + + //--- + } + + public interface IPhysicsPlugin + { + bool Init(); + PhysicsScene GetScene(String sceneIdentifier); + string GetName(); + void Dispose(); + } + + public interface IMeshingPlugin + { + string GetName(); + IMesher GetMesher(IConfigSource config); + } +} diff --git a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsScene.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsScene.cs new file mode 100644 index 0000000..9cdedbf --- /dev/null +++ b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsScene.cs @@ -0,0 +1,361 @@ +/* + * 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 System.Reflection; + +using log4net; +using Nini.Config; + +using OpenSim.Framework; +using OpenMetaverse; + +namespace OpenSim.Region.Physics.Manager +{ + public delegate void physicsCrash(); + + public delegate void RaycastCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 normal); + public delegate void RayCallback(List list); + + public delegate void JointMoved(PhysicsJoint joint); + public delegate void JointDeactivated(PhysicsJoint joint); + public delegate void JointErrorMessage(PhysicsJoint joint, string message); // this refers to an "error message due to a problem", not "amount of joint constraint violation" + + public enum RayFilterFlags : ushort + { + // the flags + water = 0x01, + land = 0x02, + agent = 0x04, + nonphysical = 0x08, + physical = 0x10, + phantom = 0x20, + volumedtc = 0x40, + + // ray cast colision control (may only work for meshs) + ContactsUnImportant = 0x2000, + BackFaceCull = 0x4000, + ClosestHit = 0x8000, + + // some combinations + LSLPhantom = phantom | volumedtc, + PrimsNonPhantom = nonphysical | physical, + PrimsNonPhantomAgents = nonphysical | physical | agent, + + AllPrims = nonphysical | phantom | volumedtc | physical, + AllButLand = agent | nonphysical | physical | phantom | volumedtc, + + ClosestAndBackCull = ClosestHit | BackFaceCull, + + All = 0x3f + } + + public delegate void RequestAssetDelegate(UUID assetID, AssetReceivedDelegate callback); + public delegate void AssetReceivedDelegate(AssetBase asset); + + /// + /// Contact result from a raycast. + /// + public struct ContactResult + { + public Vector3 Pos; + public float Depth; + public uint ConsumerID; + public Vector3 Normal; + } + + public abstract class PhysicsScene + { +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + /// + /// A unique identifying string for this instance of the physics engine. + /// Useful in debug messages to distinguish one OdeScene instance from another. + /// Usually set to include the region name that the physics engine is acting for. + /// + public string Name { get; protected set; } + + /// + /// A string identifying the family of this physics engine. Most common values returned + /// are "OpenDynamicsEngine" and "BulletSim" but others are possible. + /// + public string EngineType { get; protected set; } + + // The only thing that should register for this event is the SceneGraph + // Anything else could cause problems. + public event physicsCrash OnPhysicsCrash; + + public static PhysicsScene Null + { + get { return new NullPhysicsScene(); } + } + + public RequestAssetDelegate RequestAssetMethod { get; set; } + + public virtual void TriggerPhysicsBasedRestart() + { + physicsCrash handler = OnPhysicsCrash; + if (handler != null) + { + OnPhysicsCrash(); + } + } + + // Deprecated. Do not use this for new physics engines. + public abstract void Initialise(IMesher meshmerizer, IConfigSource config); + + // For older physics engines that do not implement non-legacy region sizes. + // If the physics engine handles the region extent feature, it overrides this function. + public virtual void Initialise(IMesher meshmerizer, IConfigSource config, Vector3 regionExtent) + { + // If not overridden, call the old initialization entry. + Initialise(meshmerizer, config); + } + + /// + /// Add an avatar + /// + /// + /// + /// + /// + /// + /// + public abstract PhysicsActor AddAvatar( + string avName, Vector3 position, Vector3 velocity, Vector3 size, bool isFlying); + + /// + /// Add an avatar + /// + /// + /// + /// + /// + /// + /// + /// + public virtual PhysicsActor AddAvatar( + uint localID, string avName, Vector3 position, Vector3 velocity, Vector3 size, bool isFlying) + { + PhysicsActor ret = AddAvatar(avName, position, velocity, size, isFlying); + + if (ret != null) + ret.LocalID = localID; + + return ret; + } + + /// + /// Remove an avatar. + /// + /// + public abstract void RemoveAvatar(PhysicsActor actor); + + /// + /// Remove a prim. + /// + /// + public abstract void RemovePrim(PhysicsActor prim); + + public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, + Vector3 size, Quaternion rotation, bool isPhysical, uint localid); + + public virtual PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, + Vector3 size, Quaternion rotation, bool isPhysical, bool isPhantom, byte shapetype, uint localid) + { + return AddPrimShape(primName, pbs, position, size, rotation, isPhysical, localid); + } + + public virtual float TimeDilation + { + get { return 1.0f; } + } + + public virtual bool SupportsNINJAJoints + { + get { return false; } + } + + public virtual PhysicsJoint RequestJointCreation(string objectNameInScene, PhysicsJointType jointType, Vector3 position, + Quaternion rotation, string parms, List bodyNames, string trackedBodyName, Quaternion localRotation) + { return null; } + + public virtual void RequestJointDeletion(string objectNameInScene) + { return; } + + public virtual void RemoveAllJointsConnectedToActorThreadLocked(PhysicsActor actor) + { return; } + + public virtual void DumpJointInfo() + { return; } + + public event JointMoved OnJointMoved; + + protected virtual void DoJointMoved(PhysicsJoint joint) + { + // We need this to allow subclasses (but not other classes) to invoke the event; C# does + // not allow subclasses to invoke the parent class event. + if (OnJointMoved != null) + { + OnJointMoved(joint); + } + } + + public event JointDeactivated OnJointDeactivated; + + protected virtual void DoJointDeactivated(PhysicsJoint joint) + { + // We need this to allow subclasses (but not other classes) to invoke the event; C# does + // not allow subclasses to invoke the parent class event. + if (OnJointDeactivated != null) + { + OnJointDeactivated(joint); + } + } + + public event JointErrorMessage OnJointErrorMessage; + + protected virtual void DoJointErrorMessage(PhysicsJoint joint, string message) + { + // We need this to allow subclasses (but not other classes) to invoke the event; C# does + // not allow subclasses to invoke the parent class event. + if (OnJointErrorMessage != null) + { + OnJointErrorMessage(joint, message); + } + } + + public virtual Vector3 GetJointAnchor(PhysicsJoint joint) + { return Vector3.Zero; } + + public virtual Vector3 GetJointAxis(PhysicsJoint joint) + { return Vector3.Zero; } + + public abstract void AddPhysicsActorTaint(PhysicsActor prim); + + /// + /// Perform a simulation of the current physics scene over the given timestep. + /// + /// + /// The number of frames simulated over that period. + public abstract float Simulate(float timeStep); + + /// + /// Get statistics about this scene. + /// + /// This facility is currently experimental and subject to change. + /// + /// A dictionary where the key is the statistic name. If no statistics are supplied then returns null. + /// + public virtual Dictionary GetStats() { return null; } + + public abstract void GetResults(); + + public abstract void SetTerrain(float[] heightMap); + + public abstract void SetWaterLevel(float baseheight); + + public abstract void DeleteTerrain(); + + public abstract void Dispose(); + + public abstract Dictionary GetTopColliders(); + + public abstract bool IsThreaded { get; } + + /// + /// True if the physics plugin supports raycasting against the physics scene + /// + public virtual bool SupportsRayCast() + { + return false; + } + + public virtual bool SupportsCombining() + { + return false; + } + + public virtual void Combine(PhysicsScene pScene, Vector3 offset, Vector3 extents) {} + + public virtual void UnCombine(PhysicsScene pScene) {} + + /// + /// Queue a raycast against the physics scene. + /// The provided callback method will be called when the raycast is complete + /// + /// Many physics engines don't support collision testing at the same time as + /// manipulating the physics scene, so we queue the request up and callback + /// a custom method when the raycast is complete. + /// This allows physics engines that give an immediate result to callback immediately + /// and ones that don't, to callback when it gets a result back. + /// + /// ODE for example will not allow you to change the scene while collision testing or + /// it asserts, 'opteration not valid for locked space'. This includes adding a ray to the scene. + /// + /// This is named RayCastWorld to not conflict with modrex's Raycast method. + /// + /// Origin of the ray + /// Direction of the ray + /// Length of ray in meters + /// Method to call when the raycast is complete + public virtual void RaycastWorld(Vector3 position, Vector3 direction, float length, RaycastCallback retMethod) + { + if (retMethod != null) + retMethod(false, Vector3.Zero, 0, 999999999999f, Vector3.Zero); + } + + public virtual void RaycastWorld(Vector3 position, Vector3 direction, float length, int Count, RayCallback retMethod) + { + if (retMethod != null) + retMethod(new List()); + } + + public virtual List RaycastWorld(Vector3 position, Vector3 direction, float length, int Count) + { + return new List(); + } + + public virtual object RaycastWorld(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter) + { + return null; + } + + public virtual bool SupportsRaycastWorldFiltered() + { + return false; + } + + // Extendable interface for new, physics engine specific operations + public virtual object Extension(string pFunct, params object[] pParams) + { + // A NOP if the extension thing is not implemented by the physics engine + return null; + } + } +} diff --git a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsSensor.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsSensor.cs new file mode 100644 index 0000000..f480d71 --- /dev/null +++ b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsSensor.cs @@ -0,0 +1,78 @@ +/* + * 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.Timers; +using OpenMetaverse; + +namespace OpenSim.Region.Physics.Manager +{ + [Flags] + public enum SenseType : uint + { + NONE = 0, + AGENT = 1, + ACTIVE = 2, + PASSIVE = 3, + SCRIPTED = 4 + } + + public abstract class PhysicsSensor + { + public static PhysicsSensor Null + { + get { return new NullPhysicsSensor(); } + } + public abstract Vector3 Position { get; set; } + public abstract void TimerCallback (object obj, ElapsedEventArgs eea); + public abstract float radianarc {get; set;} + public abstract string targetname {get; set;} + public abstract Guid targetKey{get;set;} + public abstract SenseType sensetype { get;set;} + public abstract float range { get;set;} + public abstract float rateSeconds { get;set;} + } + + public class NullPhysicsSensor : PhysicsSensor + { + public override Vector3 Position + { + get { return Vector3.Zero; } + set { return; } + } + public override void TimerCallback(object obj, ElapsedEventArgs eea) + { + // don't do squat + } + public override float radianarc { get { return 0f; } set { } } + public override string targetname { get { return ""; } set { } } + public override Guid targetKey { get { return Guid.Empty; } set { } } + public override SenseType sensetype { get { return SenseType.NONE; } set { } } + public override float range { get { return 0; } set { } } + public override float rateSeconds { get { return 0; } set { } } + } +} diff --git a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsVector.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsVector.cs new file mode 100644 index 0000000..f60a636 --- /dev/null +++ b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsVector.cs @@ -0,0 +1,186 @@ +/* + * 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; + +namespace OpenSim.Region.Physics.Manager +{ + /*public class PhysicsVector + { + public float X; + public float Y; + public float Z; + + public Vector3() + { + } + + public Vector3(float x, float y, float z) + { + X = x; + Y = y; + Z = z; + } + + public Vector3(Vector3 pv) : this(pv.X, pv.Y, pv.Z) + { + } + + public void setValues(float x, float y, float z) + { + X = x; + Y = y; + Z = z; + } + + public static readonly PhysicsVector Zero = new PhysicsVector(0f, 0f, 0f); + + public override string ToString() + { + return "<" + X + "," + Y + "," + Z + ">"; + } + + /// + /// These routines are the easiest way to store XYZ values in an Vector3 without requiring 3 calls. + /// + /// + public byte[] GetBytes() + { + byte[] byteArray = new byte[12]; + + Buffer.BlockCopy(BitConverter.GetBytes(X), 0, byteArray, 0, 4); + Buffer.BlockCopy(BitConverter.GetBytes(Y), 0, byteArray, 4, 4); + Buffer.BlockCopy(BitConverter.GetBytes(Z), 0, byteArray, 8, 4); + + if (!BitConverter.IsLittleEndian) + { + Array.Reverse(byteArray, 0, 4); + Array.Reverse(byteArray, 4, 4); + Array.Reverse(byteArray, 8, 4); + } + + return byteArray; + } + + public void FromBytes(byte[] byteArray, int pos) + { + byte[] conversionBuffer = null; + if (!BitConverter.IsLittleEndian) + { + // Big endian architecture + if (conversionBuffer == null) + conversionBuffer = new byte[12]; + + Buffer.BlockCopy(byteArray, pos, conversionBuffer, 0, 12); + + Array.Reverse(conversionBuffer, 0, 4); + Array.Reverse(conversionBuffer, 4, 4); + Array.Reverse(conversionBuffer, 8, 4); + + X = BitConverter.ToSingle(conversionBuffer, 0); + Y = BitConverter.ToSingle(conversionBuffer, 4); + Z = BitConverter.ToSingle(conversionBuffer, 8); + } + else + { + // Little endian architecture + X = BitConverter.ToSingle(byteArray, pos); + Y = BitConverter.ToSingle(byteArray, pos + 4); + Z = BitConverter.ToSingle(byteArray, pos + 8); + } + } + + // Operations + public static PhysicsVector operator +(Vector3 a, Vector3 b) + { + return new PhysicsVector(a.X + b.X, a.Y + b.Y, a.Z + b.Z); + } + + public static PhysicsVector operator -(Vector3 a, Vector3 b) + { + return new PhysicsVector(a.X - b.X, a.Y - b.Y, a.Z - b.Z); + } + + public static PhysicsVector cross(Vector3 a, Vector3 b) + { + return new PhysicsVector(a.Y*b.Z - a.Z*b.Y, a.Z*b.X - a.X*b.Z, a.X*b.Y - a.Y*b.X); + } + + public float length() + { + return (float) Math.Sqrt(X*X + Y*Y + Z*Z); + } + + public static float GetDistanceTo(Vector3 a, Vector3 b) + { + float dx = a.X - b.X; + float dy = a.Y - b.Y; + float dz = a.Z - b.Z; + return (float) Math.Sqrt(dx * dx + dy * dy + dz * dz); + } + + public static PhysicsVector operator /(Vector3 v, float f) + { + return new PhysicsVector(v.X/f, v.Y/f, v.Z/f); + } + + public static PhysicsVector operator *(Vector3 v, float f) + { + return new PhysicsVector(v.X*f, v.Y*f, v.Z*f); + } + + public static PhysicsVector operator *(float f, Vector3 v) + { + return v*f; + } + + public static bool isFinite(Vector3 v) + { + if (v == null) + return false; + if (Single.IsInfinity(v.X) || Single.IsNaN(v.X)) + return false; + if (Single.IsInfinity(v.Y) || Single.IsNaN(v.Y)) + return false; + if (Single.IsInfinity(v.Z) || Single.IsNaN(v.Z)) + return false; + + return true; + } + + public virtual bool IsIdentical(Vector3 v, float tolerance) + { + PhysicsVector diff = this - v; + float d = diff.length(); + if (d <= tolerance) + return true; + + return false; + } + + }*/ +} diff --git a/OpenSim/Region/PhysicsModules/SharedBase/VehicleConstants.cs b/OpenSim/Region/PhysicsModules/SharedBase/VehicleConstants.cs new file mode 100644 index 0000000..f0775c1 --- /dev/null +++ b/OpenSim/Region/PhysicsModules/SharedBase/VehicleConstants.cs @@ -0,0 +1,121 @@ +/* + * 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; + +namespace OpenSim.Region.Physics.Manager +{ + public enum Vehicle : int + { + /// + /// Turns off Vehicle Support + /// + TYPE_NONE = 0, + + /// + /// No Angular motor, High Left right friction, No Hover, Linear Deflection 1, no angular deflection + /// no vertical attractor, No banking, Identity rotation frame + /// + TYPE_SLED = 1, + + /// + /// Needs Motors to be driven by timer or control events High left/right friction, No angular friction + /// Linear Motor wins in a second, decays in 60 seconds. Angular motor wins in a second, decays in 8/10ths of a second + /// linear deflection 2 seconds + /// Vertical Attractor locked UP + /// + TYPE_CAR = 2, + TYPE_BOAT = 3, + TYPE_AIRPLANE = 4, + TYPE_BALLOON = 5, + LINEAR_FRICTION_TIMESCALE = 16, + /// + /// vector of timescales for exponential decay of angular velocity about three axis + /// + ANGULAR_FRICTION_TIMESCALE = 17, + /// + /// linear velocity vehicle will try for + /// + LINEAR_MOTOR_DIRECTION = 18, + + /// + /// Offset from center of mass where linear motor forces are added + /// + LINEAR_MOTOR_OFFSET = 20, + /// + /// angular velocity that vehicle will try for + /// + ANGULAR_MOTOR_DIRECTION = 19, + HOVER_HEIGHT = 24, + HOVER_EFFICIENCY = 25, + HOVER_TIMESCALE = 26, + BUOYANCY = 27, + LINEAR_DEFLECTION_EFFICIENCY = 28, + LINEAR_DEFLECTION_TIMESCALE = 29, + LINEAR_MOTOR_TIMESCALE = 30, + LINEAR_MOTOR_DECAY_TIMESCALE = 31, + + /// + /// slide between 0 and 1 + /// + ANGULAR_DEFLECTION_EFFICIENCY = 32, + ANGULAR_DEFLECTION_TIMESCALE = 33, + ANGULAR_MOTOR_TIMESCALE = 34, + ANGULAR_MOTOR_DECAY_TIMESCALE = 35, + VERTICAL_ATTRACTION_EFFICIENCY = 36, + VERTICAL_ATTRACTION_TIMESCALE = 37, + BANKING_EFFICIENCY = 38, + BANKING_MIX = 39, + BANKING_TIMESCALE = 40, + REFERENCE_FRAME = 44, + BLOCK_EXIT = 45, + ROLL_FRAME = 46 + + } + + [Flags] + public enum VehicleFlag + { + NO_DEFLECTION_UP = 1, + LIMIT_ROLL_ONLY = 2, + HOVER_WATER_ONLY = 4, + HOVER_TERRAIN_ONLY = 8, + HOVER_GLOBAL_HEIGHT = 16, + HOVER_UP_ONLY = 32, + LIMIT_MOTOR_UP = 64, + MOUSELOOK_STEER = 128, + MOUSELOOK_BANK = 256, + CAMERA_DECOUPLED = 512, + NO_X = 1024, + NO_Y = 2048, + NO_Z = 4096, + LOCK_HOVER_HEIGHT = 8192, + NO_DEFLECTION = 16392, + LOCK_ROTATION = 32784 + } + +} diff --git a/OpenSim/Region/PhysicsModules/SharedBase/ZeroMesher.cs b/OpenSim/Region/PhysicsModules/SharedBase/ZeroMesher.cs new file mode 100644 index 0000000..270d2ec --- /dev/null +++ b/OpenSim/Region/PhysicsModules/SharedBase/ZeroMesher.cs @@ -0,0 +1,83 @@ +/* + * 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 OpenSim.Framework; +using OpenMetaverse; +using Nini.Config; + +/* + * This is the zero mesher. + * Whatever you want him to mesh, he can't, telling you that by responding with a null pointer. + * Effectivly this is for switching off meshing and for testing as each physics machine should deal + * with the null pointer situation. + * But it's also a convenience thing, as physics machines can rely on having a mesher in any situation, even + * if it's a dump one like this. + * Note, that this mesher is *not* living in a module but in the manager itself, so + * it's always availabe and thus the default in case of configuration errors +*/ + +namespace OpenSim.Region.Physics.Manager +{ + public class ZeroMesherPlugin : IMeshingPlugin + { + public ZeroMesherPlugin() + { + } + + public string GetName() + { + return "ZeroMesher"; + } + + public IMesher GetMesher(IConfigSource config) + { + return new ZeroMesher(); + } + } + + public class ZeroMesher : IMesher + { + public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod) + { + return CreateMesh(primName, primShape, size, lod, false, false); + } + + public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical) + { + return CreateMesh(primName, primShape, size, lod, false, false); + } + + public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool shouldCache) + { + // Remove the reference to the encoded JPEG2000 data so it can be GCed + primShape.SculptData = OpenMetaverse.Utils.EmptyBytes; + + return null; + } + } +} -- cgit v1.1 From 2c0cad6dd3014e9ad363090f5f7872c43daffcbd Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 30 Aug 2015 20:29:31 -0700 Subject: Renamed the namespaces too --- OpenSim/Region/PhysicsModules/SharedBase/CollisionLocker.cs | 2 +- OpenSim/Region/PhysicsModules/SharedBase/IMesher.cs | 2 +- OpenSim/Region/PhysicsModules/SharedBase/IPhysicsParameters.cs | 2 +- OpenSim/Region/PhysicsModules/SharedBase/NullPhysicsScene.cs | 2 +- OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs | 2 +- OpenSim/Region/PhysicsModules/SharedBase/PhysicsJoint.cs | 2 +- OpenSim/Region/PhysicsModules/SharedBase/PhysicsPluginManager.cs | 2 +- OpenSim/Region/PhysicsModules/SharedBase/PhysicsScene.cs | 2 +- OpenSim/Region/PhysicsModules/SharedBase/PhysicsSensor.cs | 2 +- OpenSim/Region/PhysicsModules/SharedBase/PhysicsVector.cs | 2 +- OpenSim/Region/PhysicsModules/SharedBase/VehicleConstants.cs | 2 +- OpenSim/Region/PhysicsModules/SharedBase/ZeroMesher.cs | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region/PhysicsModules/SharedBase') diff --git a/OpenSim/Region/PhysicsModules/SharedBase/CollisionLocker.cs b/OpenSim/Region/PhysicsModules/SharedBase/CollisionLocker.cs index cace4e4..687c4ca 100644 --- a/OpenSim/Region/PhysicsModules/SharedBase/CollisionLocker.cs +++ b/OpenSim/Region/PhysicsModules/SharedBase/CollisionLocker.cs @@ -28,7 +28,7 @@ using System; using System.Collections.Generic; -namespace OpenSim.Region.Physics.Manager +namespace OpenSim.Region.PhysicsModule.SharedBase { public class CollisionLocker { diff --git a/OpenSim/Region/PhysicsModules/SharedBase/IMesher.cs b/OpenSim/Region/PhysicsModules/SharedBase/IMesher.cs index 2e7bb5d..e6cb76e 100644 --- a/OpenSim/Region/PhysicsModules/SharedBase/IMesher.cs +++ b/OpenSim/Region/PhysicsModules/SharedBase/IMesher.cs @@ -30,7 +30,7 @@ using System.Collections.Generic; using OpenSim.Framework; using OpenMetaverse; -namespace OpenSim.Region.Physics.Manager +namespace OpenSim.Region.PhysicsModule.SharedBase { public interface IMesher { diff --git a/OpenSim/Region/PhysicsModules/SharedBase/IPhysicsParameters.cs b/OpenSim/Region/PhysicsModules/SharedBase/IPhysicsParameters.cs index 31a397c..da0054a 100755 --- a/OpenSim/Region/PhysicsModules/SharedBase/IPhysicsParameters.cs +++ b/OpenSim/Region/PhysicsModules/SharedBase/IPhysicsParameters.cs @@ -30,7 +30,7 @@ using System.Collections.Generic; using OpenSim.Framework; using OpenMetaverse; -namespace OpenSim.Region.Physics.Manager +namespace OpenSim.Region.PhysicsModule.SharedBase { public struct PhysParameterEntry { diff --git a/OpenSim/Region/PhysicsModules/SharedBase/NullPhysicsScene.cs b/OpenSim/Region/PhysicsModules/SharedBase/NullPhysicsScene.cs index b52f1f6..d5fc9c6 100644 --- a/OpenSim/Region/PhysicsModules/SharedBase/NullPhysicsScene.cs +++ b/OpenSim/Region/PhysicsModules/SharedBase/NullPhysicsScene.cs @@ -32,7 +32,7 @@ using Nini.Config; using OpenSim.Framework; using OpenMetaverse; -namespace OpenSim.Region.Physics.Manager +namespace OpenSim.Region.PhysicsModule.SharedBase { class NullPhysicsScene : PhysicsScene { diff --git a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs index 6bc6e23..bfa6254 100644 --- a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs +++ b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs @@ -32,7 +32,7 @@ using System.Reflection; using OpenSim.Framework; using OpenMetaverse; -namespace OpenSim.Region.Physics.Manager +namespace OpenSim.Region.PhysicsModule.SharedBase { public delegate void PositionUpdate(Vector3 position); public delegate void VelocityUpdate(Vector3 velocity); diff --git a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsJoint.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsJoint.cs index b685d04..8fc2638 100644 --- a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsJoint.cs +++ b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsJoint.cs @@ -30,7 +30,7 @@ using System.Collections.Generic; using OpenSim.Framework; using OpenMetaverse; -namespace OpenSim.Region.Physics.Manager +namespace OpenSim.Region.PhysicsModule.SharedBase { public enum PhysicsJointType : int { diff --git a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsPluginManager.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsPluginManager.cs index d8279b7..d08b6eb 100644 --- a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsPluginManager.cs +++ b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsPluginManager.cs @@ -34,7 +34,7 @@ using log4net; using OpenSim.Framework; using OpenMetaverse; -namespace OpenSim.Region.Physics.Manager +namespace OpenSim.Region.PhysicsModule.SharedBase { /// /// Description of MyClass. diff --git a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsScene.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsScene.cs index 9cdedbf..be0d6f5 100644 --- a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsScene.cs +++ b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsScene.cs @@ -35,7 +35,7 @@ using Nini.Config; using OpenSim.Framework; using OpenMetaverse; -namespace OpenSim.Region.Physics.Manager +namespace OpenSim.Region.PhysicsModule.SharedBase { public delegate void physicsCrash(); diff --git a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsSensor.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsSensor.cs index f480d71..f0bdd10 100644 --- a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsSensor.cs +++ b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsSensor.cs @@ -29,7 +29,7 @@ using System; using System.Timers; using OpenMetaverse; -namespace OpenSim.Region.Physics.Manager +namespace OpenSim.Region.PhysicsModule.SharedBase { [Flags] public enum SenseType : uint diff --git a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsVector.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsVector.cs index f60a636..fba861b 100644 --- a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsVector.cs +++ b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsVector.cs @@ -27,7 +27,7 @@ using System; -namespace OpenSim.Region.Physics.Manager +namespace OpenSim.Region.PhysicsModule.SharedBase { /*public class PhysicsVector { diff --git a/OpenSim/Region/PhysicsModules/SharedBase/VehicleConstants.cs b/OpenSim/Region/PhysicsModules/SharedBase/VehicleConstants.cs index f0775c1..879e62a 100644 --- a/OpenSim/Region/PhysicsModules/SharedBase/VehicleConstants.cs +++ b/OpenSim/Region/PhysicsModules/SharedBase/VehicleConstants.cs @@ -27,7 +27,7 @@ using System; -namespace OpenSim.Region.Physics.Manager +namespace OpenSim.Region.PhysicsModule.SharedBase { public enum Vehicle : int { diff --git a/OpenSim/Region/PhysicsModules/SharedBase/ZeroMesher.cs b/OpenSim/Region/PhysicsModules/SharedBase/ZeroMesher.cs index 270d2ec..c938252 100644 --- a/OpenSim/Region/PhysicsModules/SharedBase/ZeroMesher.cs +++ b/OpenSim/Region/PhysicsModules/SharedBase/ZeroMesher.cs @@ -41,7 +41,7 @@ using Nini.Config; * it's always availabe and thus the default in case of configuration errors */ -namespace OpenSim.Region.Physics.Manager +namespace OpenSim.Region.PhysicsModule.SharedBase { public class ZeroMesherPlugin : IMeshingPlugin { -- cgit v1.1 From ce2c67876e0ebf4f84420696f660dc77d96dea6b Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 30 Aug 2015 21:05:36 -0700 Subject: More namespace and dll name changes. Still no functional changes. --- OpenSim/Region/PhysicsModules/SharedBase/CollisionLocker.cs | 2 +- OpenSim/Region/PhysicsModules/SharedBase/IMesher.cs | 2 +- OpenSim/Region/PhysicsModules/SharedBase/IPhysicsParameters.cs | 2 +- OpenSim/Region/PhysicsModules/SharedBase/NullPhysicsScene.cs | 2 +- OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs | 2 +- OpenSim/Region/PhysicsModules/SharedBase/PhysicsJoint.cs | 2 +- OpenSim/Region/PhysicsModules/SharedBase/PhysicsPluginManager.cs | 6 +++--- OpenSim/Region/PhysicsModules/SharedBase/PhysicsScene.cs | 2 +- OpenSim/Region/PhysicsModules/SharedBase/PhysicsSensor.cs | 2 +- OpenSim/Region/PhysicsModules/SharedBase/PhysicsVector.cs | 2 +- OpenSim/Region/PhysicsModules/SharedBase/VehicleConstants.cs | 2 +- OpenSim/Region/PhysicsModules/SharedBase/ZeroMesher.cs | 2 +- 12 files changed, 14 insertions(+), 14 deletions(-) (limited to 'OpenSim/Region/PhysicsModules/SharedBase') diff --git a/OpenSim/Region/PhysicsModules/SharedBase/CollisionLocker.cs b/OpenSim/Region/PhysicsModules/SharedBase/CollisionLocker.cs index 687c4ca..6e658b5 100644 --- a/OpenSim/Region/PhysicsModules/SharedBase/CollisionLocker.cs +++ b/OpenSim/Region/PhysicsModules/SharedBase/CollisionLocker.cs @@ -28,7 +28,7 @@ using System; using System.Collections.Generic; -namespace OpenSim.Region.PhysicsModule.SharedBase +namespace OpenSim.Region.PhysicsModules.SharedBase { public class CollisionLocker { diff --git a/OpenSim/Region/PhysicsModules/SharedBase/IMesher.cs b/OpenSim/Region/PhysicsModules/SharedBase/IMesher.cs index e6cb76e..5c75307 100644 --- a/OpenSim/Region/PhysicsModules/SharedBase/IMesher.cs +++ b/OpenSim/Region/PhysicsModules/SharedBase/IMesher.cs @@ -30,7 +30,7 @@ using System.Collections.Generic; using OpenSim.Framework; using OpenMetaverse; -namespace OpenSim.Region.PhysicsModule.SharedBase +namespace OpenSim.Region.PhysicsModules.SharedBase { public interface IMesher { diff --git a/OpenSim/Region/PhysicsModules/SharedBase/IPhysicsParameters.cs b/OpenSim/Region/PhysicsModules/SharedBase/IPhysicsParameters.cs index da0054a..fb0c9e2 100755 --- a/OpenSim/Region/PhysicsModules/SharedBase/IPhysicsParameters.cs +++ b/OpenSim/Region/PhysicsModules/SharedBase/IPhysicsParameters.cs @@ -30,7 +30,7 @@ using System.Collections.Generic; using OpenSim.Framework; using OpenMetaverse; -namespace OpenSim.Region.PhysicsModule.SharedBase +namespace OpenSim.Region.PhysicsModules.SharedBase { public struct PhysParameterEntry { diff --git a/OpenSim/Region/PhysicsModules/SharedBase/NullPhysicsScene.cs b/OpenSim/Region/PhysicsModules/SharedBase/NullPhysicsScene.cs index d5fc9c6..da896a3 100644 --- a/OpenSim/Region/PhysicsModules/SharedBase/NullPhysicsScene.cs +++ b/OpenSim/Region/PhysicsModules/SharedBase/NullPhysicsScene.cs @@ -32,7 +32,7 @@ using Nini.Config; using OpenSim.Framework; using OpenMetaverse; -namespace OpenSim.Region.PhysicsModule.SharedBase +namespace OpenSim.Region.PhysicsModules.SharedBase { class NullPhysicsScene : PhysicsScene { diff --git a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs index bfa6254..c04ff58 100644 --- a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs +++ b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs @@ -32,7 +32,7 @@ using System.Reflection; using OpenSim.Framework; using OpenMetaverse; -namespace OpenSim.Region.PhysicsModule.SharedBase +namespace OpenSim.Region.PhysicsModules.SharedBase { public delegate void PositionUpdate(Vector3 position); public delegate void VelocityUpdate(Vector3 velocity); diff --git a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsJoint.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsJoint.cs index 8fc2638..ce2bf05 100644 --- a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsJoint.cs +++ b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsJoint.cs @@ -30,7 +30,7 @@ using System.Collections.Generic; using OpenSim.Framework; using OpenMetaverse; -namespace OpenSim.Region.PhysicsModule.SharedBase +namespace OpenSim.Region.PhysicsModules.SharedBase { public enum PhysicsJointType : int { diff --git a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsPluginManager.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsPluginManager.cs index d08b6eb..f7992d5 100644 --- a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsPluginManager.cs +++ b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsPluginManager.cs @@ -34,7 +34,7 @@ using log4net; using OpenSim.Framework; using OpenMetaverse; -namespace OpenSim.Region.PhysicsModule.SharedBase +namespace OpenSim.Region.PhysicsModules.SharedBase { /// /// Description of MyClass. @@ -129,8 +129,8 @@ namespace OpenSim.Region.PhysicsModule.SharedBase public void LoadPluginsFromAssembly(string assemblyPath) { // TODO / NOTE - // The assembly named 'OpenSim.Region.Physics.BasicPhysicsPlugin' was loaded from - // 'file:///C:/OpenSim/trunk2/bin/Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll' + // The assembly named 'OpenSim.Region.PhysicsModule.BasicPhysics' was loaded from + // 'file:///C:/OpenSim/trunk2/bin/Physics/OpenSim.Region.PhysicsModule.BasicPhysics.dll' // using the LoadFrom context. The use of this context can result in unexpected behavior // for serialization, casting and dependency resolution. In almost all cases, it is recommended // that the LoadFrom context be avoided. This can be done by installing assemblies in the diff --git a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsScene.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsScene.cs index be0d6f5..0394494 100644 --- a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsScene.cs +++ b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsScene.cs @@ -35,7 +35,7 @@ using Nini.Config; using OpenSim.Framework; using OpenMetaverse; -namespace OpenSim.Region.PhysicsModule.SharedBase +namespace OpenSim.Region.PhysicsModules.SharedBase { public delegate void physicsCrash(); diff --git a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsSensor.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsSensor.cs index f0bdd10..da9c96c 100644 --- a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsSensor.cs +++ b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsSensor.cs @@ -29,7 +29,7 @@ using System; using System.Timers; using OpenMetaverse; -namespace OpenSim.Region.PhysicsModule.SharedBase +namespace OpenSim.Region.PhysicsModules.SharedBase { [Flags] public enum SenseType : uint diff --git a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsVector.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsVector.cs index fba861b..76a82fa 100644 --- a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsVector.cs +++ b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsVector.cs @@ -27,7 +27,7 @@ using System; -namespace OpenSim.Region.PhysicsModule.SharedBase +namespace OpenSim.Region.PhysicsModules.SharedBase { /*public class PhysicsVector { diff --git a/OpenSim/Region/PhysicsModules/SharedBase/VehicleConstants.cs b/OpenSim/Region/PhysicsModules/SharedBase/VehicleConstants.cs index 879e62a..63a8cb8 100644 --- a/OpenSim/Region/PhysicsModules/SharedBase/VehicleConstants.cs +++ b/OpenSim/Region/PhysicsModules/SharedBase/VehicleConstants.cs @@ -27,7 +27,7 @@ using System; -namespace OpenSim.Region.PhysicsModule.SharedBase +namespace OpenSim.Region.PhysicsModules.SharedBase { public enum Vehicle : int { diff --git a/OpenSim/Region/PhysicsModules/SharedBase/ZeroMesher.cs b/OpenSim/Region/PhysicsModules/SharedBase/ZeroMesher.cs index c938252..fe87962 100644 --- a/OpenSim/Region/PhysicsModules/SharedBase/ZeroMesher.cs +++ b/OpenSim/Region/PhysicsModules/SharedBase/ZeroMesher.cs @@ -41,7 +41,7 @@ using Nini.Config; * it's always availabe and thus the default in case of configuration errors */ -namespace OpenSim.Region.PhysicsModule.SharedBase +namespace OpenSim.Region.PhysicsModules.SharedBase { public class ZeroMesherPlugin : IMeshingPlugin { -- cgit v1.1 From 3741edd1c791e87a38805a62530755cbf0c55cab Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 31 Aug 2015 09:21:05 -0700 Subject: Refactored Meshing modules: - Moved ZeroMesher from OpenSim.Region.PhysicsModules.SharedBase to OpenSim.Region.PhysicsModules.Meshing - Created subfolder for all Meshmerizer files, also in the same Meshing dll - Made them both region modules, with ZeroMesher being the default one This compiles but doesn't run yet. --- .../SharedBase/PhysicsPluginManager.cs | 7 -- .../Region/PhysicsModules/SharedBase/ZeroMesher.cs | 83 ---------------------- 2 files changed, 90 deletions(-) delete mode 100644 OpenSim/Region/PhysicsModules/SharedBase/ZeroMesher.cs (limited to 'OpenSim/Region/PhysicsModules/SharedBase') diff --git a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsPluginManager.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsPluginManager.cs index f7992d5..6316463 100644 --- a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsPluginManager.cs +++ b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsPluginManager.cs @@ -51,13 +51,6 @@ namespace OpenSim.Region.PhysicsModules.SharedBase /// public PhysicsPluginManager() { - // Load "plugins", that are hard coded and not existing in form of an external lib, and hence always - // available - IMeshingPlugin plugHard; - plugHard = new ZeroMesherPlugin(); - _MeshPlugins.Add(plugHard.GetName(), plugHard); - - m_log.Info("[PHYSICS]: Added meshing engine: " + plugHard.GetName()); } /// diff --git a/OpenSim/Region/PhysicsModules/SharedBase/ZeroMesher.cs b/OpenSim/Region/PhysicsModules/SharedBase/ZeroMesher.cs deleted file mode 100644 index fe87962..0000000 --- a/OpenSim/Region/PhysicsModules/SharedBase/ZeroMesher.cs +++ /dev/null @@ -1,83 +0,0 @@ -/* - * 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 OpenSim.Framework; -using OpenMetaverse; -using Nini.Config; - -/* - * This is the zero mesher. - * Whatever you want him to mesh, he can't, telling you that by responding with a null pointer. - * Effectivly this is for switching off meshing and for testing as each physics machine should deal - * with the null pointer situation. - * But it's also a convenience thing, as physics machines can rely on having a mesher in any situation, even - * if it's a dump one like this. - * Note, that this mesher is *not* living in a module but in the manager itself, so - * it's always availabe and thus the default in case of configuration errors -*/ - -namespace OpenSim.Region.PhysicsModules.SharedBase -{ - public class ZeroMesherPlugin : IMeshingPlugin - { - public ZeroMesherPlugin() - { - } - - public string GetName() - { - return "ZeroMesher"; - } - - public IMesher GetMesher(IConfigSource config) - { - return new ZeroMesher(); - } - } - - public class ZeroMesher : IMesher - { - public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod) - { - return CreateMesh(primName, primShape, size, lod, false, false); - } - - public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical) - { - return CreateMesh(primName, primShape, size, lod, false, false); - } - - public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool shouldCache) - { - // Remove the reference to the encoded JPEG2000 data so it can be GCed - primShape.SculptData = OpenMetaverse.Utils.EmptyBytes; - - return null; - } - } -} -- cgit v1.1 From 134d4300f0b6e9b0df0326cfe0b5df9f41f42865 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 31 Aug 2015 13:02:51 -0700 Subject: All physics plugins are now region modules. Compiles but doesn't run. --- .../Region/PhysicsModules/SharedBase/NullPhysicsScene.cs | 5 ----- .../PhysicsModules/SharedBase/PhysicsPluginManager.cs | 2 +- OpenSim/Region/PhysicsModules/SharedBase/PhysicsScene.cs | 13 +------------ 3 files changed, 2 insertions(+), 18 deletions(-) (limited to 'OpenSim/Region/PhysicsModules/SharedBase') diff --git a/OpenSim/Region/PhysicsModules/SharedBase/NullPhysicsScene.cs b/OpenSim/Region/PhysicsModules/SharedBase/NullPhysicsScene.cs index da896a3..432708c 100644 --- a/OpenSim/Region/PhysicsModules/SharedBase/NullPhysicsScene.cs +++ b/OpenSim/Region/PhysicsModules/SharedBase/NullPhysicsScene.cs @@ -40,11 +40,6 @@ namespace OpenSim.Region.PhysicsModules.SharedBase private static int m_workIndicator; - public override void Initialise(IMesher meshmerizer, IConfigSource config) - { - // Does nothing right now - } - public override PhysicsActor AddAvatar( string avName, Vector3 position, Vector3 velocity, Vector3 size, bool isFlying) { diff --git a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsPluginManager.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsPluginManager.cs index 6316463..487582c 100644 --- a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsPluginManager.cs +++ b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsPluginManager.cs @@ -89,7 +89,7 @@ namespace OpenSim.Region.PhysicsModules.SharedBase { m_log.Info("[PHYSICS]: creating " + physEngineName); PhysicsScene result = _PhysPlugins[physEngineName].GetScene(regionName); - result.Initialise(meshEngine, config, regionExtent); + //result.Initialise(meshEngine, config, regionExtent); return result; } else diff --git a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsScene.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsScene.cs index 0394494..247f355 100644 --- a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsScene.cs +++ b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsScene.cs @@ -98,7 +98,7 @@ namespace OpenSim.Region.PhysicsModules.SharedBase /// Useful in debug messages to distinguish one OdeScene instance from another. /// Usually set to include the region name that the physics engine is acting for. /// - public string Name { get; protected set; } + public string PhysicsSceneName { get; protected set; } /// /// A string identifying the family of this physics engine. Most common values returned @@ -126,17 +126,6 @@ namespace OpenSim.Region.PhysicsModules.SharedBase } } - // Deprecated. Do not use this for new physics engines. - public abstract void Initialise(IMesher meshmerizer, IConfigSource config); - - // For older physics engines that do not implement non-legacy region sizes. - // If the physics engine handles the region extent feature, it overrides this function. - public virtual void Initialise(IMesher meshmerizer, IConfigSource config, Vector3 regionExtent) - { - // If not overridden, call the old initialization entry. - Initialise(meshmerizer, config); - } - /// /// Add an avatar /// -- cgit v1.1 From 11194209df8a29f5103e6e34104eae7834f3280a Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 31 Aug 2015 14:09:15 -0700 Subject: First commit where physics work as region module. Moved all physics dlls out of Physics and into bin directly, so they can be found by the module loader. Removed call to PhysicsPluginManager. --- OpenSim/Region/PhysicsModules/SharedBase/PhysicsScene.cs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'OpenSim/Region/PhysicsModules/SharedBase') diff --git a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsScene.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsScene.cs index 247f355..32691fc 100644 --- a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsScene.cs +++ b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsScene.cs @@ -117,6 +117,14 @@ namespace OpenSim.Region.PhysicsModules.SharedBase public RequestAssetDelegate RequestAssetMethod { get; set; } + protected void Initialise(RequestAssetDelegate m, float[] terrain, float waterHeight) + { + RequestAssetMethod = m; + SetTerrain(terrain); + SetWaterLevel(waterHeight); + + } + public virtual void TriggerPhysicsBasedRestart() { physicsCrash handler = OnPhysicsCrash; -- cgit v1.1 From 9435405ca1c173963dd6e97116a27b798a211801 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 31 Aug 2015 16:23:43 -0700 Subject: Deleted physics plugin classes. More unit tests fixed. --- .../SharedBase/PhysicsPluginManager.cs | 235 --------------------- 1 file changed, 235 deletions(-) delete mode 100644 OpenSim/Region/PhysicsModules/SharedBase/PhysicsPluginManager.cs (limited to 'OpenSim/Region/PhysicsModules/SharedBase') diff --git a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsPluginManager.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsPluginManager.cs deleted file mode 100644 index 487582c..0000000 --- a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsPluginManager.cs +++ /dev/null @@ -1,235 +0,0 @@ -/* - * 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 System.IO; -using System.Reflection; -using Nini.Config; -using log4net; -using OpenSim.Framework; -using OpenMetaverse; - -namespace OpenSim.Region.PhysicsModules.SharedBase -{ - /// - /// Description of MyClass. - /// - public class PhysicsPluginManager - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private Dictionary _PhysPlugins = new Dictionary(); - private Dictionary _MeshPlugins = new Dictionary(); - - /// - /// Constructor. - /// - public PhysicsPluginManager() - { - } - - /// - /// Get a physics scene for the given physics engine and mesher. - /// - /// - /// - /// - /// - public PhysicsScene GetPhysicsScene(string physEngineName, string meshEngineName, - IConfigSource config, string regionName, Vector3 regionExtent) - { - if (String.IsNullOrEmpty(physEngineName)) - { - return PhysicsScene.Null; - } - - if (String.IsNullOrEmpty(meshEngineName)) - { - return PhysicsScene.Null; - } - - IMesher meshEngine = null; - if (_MeshPlugins.ContainsKey(meshEngineName)) - { - m_log.Info("[PHYSICS]: creating meshing engine " + meshEngineName); - meshEngine = _MeshPlugins[meshEngineName].GetMesher(config); - } - else - { - m_log.WarnFormat("[PHYSICS]: couldn't find meshingEngine: {0}", meshEngineName); - throw new ArgumentException(String.Format("couldn't find meshingEngine: {0}", meshEngineName)); - } - - if (_PhysPlugins.ContainsKey(physEngineName)) - { - m_log.Info("[PHYSICS]: creating " + physEngineName); - PhysicsScene result = _PhysPlugins[physEngineName].GetScene(regionName); - //result.Initialise(meshEngine, config, regionExtent); - return result; - } - else - { - m_log.WarnFormat("[PHYSICS]: couldn't find physicsEngine: {0}", physEngineName); - throw new ArgumentException(String.Format("couldn't find physicsEngine: {0}", physEngineName)); - } - } - - /// - /// Load all plugins in assemblies at the given path - /// - /// - public void LoadPluginsFromAssemblies(string assembliesPath) - { - // Walk all assemblies (DLLs effectively) and see if they are home - // of a plugin that is of interest for us - string[] pluginFiles = Directory.GetFiles(assembliesPath, "*.dll"); - - for (int i = 0; i < pluginFiles.Length; i++) - { - LoadPluginsFromAssembly(pluginFiles[i]); - } - } - - /// - /// Load plugins from an assembly at the given path - /// - /// - public void LoadPluginsFromAssembly(string assemblyPath) - { - // TODO / NOTE - // The assembly named 'OpenSim.Region.PhysicsModule.BasicPhysics' was loaded from - // 'file:///C:/OpenSim/trunk2/bin/Physics/OpenSim.Region.PhysicsModule.BasicPhysics.dll' - // using the LoadFrom context. The use of this context can result in unexpected behavior - // for serialization, casting and dependency resolution. In almost all cases, it is recommended - // that the LoadFrom context be avoided. This can be done by installing assemblies in the - // Global Assembly Cache or in the ApplicationBase directory and using Assembly. - // Load when explicitly loading assemblies. - Assembly pluginAssembly = null; - Type[] types = null; - - try - { - pluginAssembly = Assembly.LoadFrom(assemblyPath); - } - catch (Exception ex) - { - m_log.Error("[PHYSICS]: Failed to load plugin from " + assemblyPath, ex); - } - - if (pluginAssembly != null) - { - try - { - types = pluginAssembly.GetTypes(); - } - catch (ReflectionTypeLoadException ex) - { - m_log.Error("[PHYSICS]: Failed to enumerate types in plugin from " + assemblyPath + ": " + - ex.LoaderExceptions[0].Message, ex); - } - catch (Exception ex) - { - m_log.Error("[PHYSICS]: Failed to enumerate types in plugin from " + assemblyPath, ex); - } - - if (types != null) - { - foreach (Type pluginType in types) - { - if (pluginType.IsPublic) - { - if (!pluginType.IsAbstract) - { - Type physTypeInterface = pluginType.GetInterface("IPhysicsPlugin"); - - if (physTypeInterface != null) - { - IPhysicsPlugin plug = - (IPhysicsPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); - plug.Init(); - if (!_PhysPlugins.ContainsKey(plug.GetName())) - { - _PhysPlugins.Add(plug.GetName(), plug); - m_log.Info("[PHYSICS]: Added physics engine: " + plug.GetName()); - } - } - - Type meshTypeInterface = pluginType.GetInterface("IMeshingPlugin"); - - if (meshTypeInterface != null) - { - IMeshingPlugin plug = - (IMeshingPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); - if (!_MeshPlugins.ContainsKey(plug.GetName())) - { - _MeshPlugins.Add(plug.GetName(), plug); - m_log.Info("[PHYSICS]: Added meshing engine: " + plug.GetName()); - } - } - - physTypeInterface = null; - meshTypeInterface = null; - } - } - } - } - } - - pluginAssembly = null; - } - - //--- - public static void PhysicsPluginMessage(string message, bool isWarning) - { - if (isWarning) - { - m_log.Warn("[PHYSICS]: " + message); - } - else - { - m_log.Info("[PHYSICS]: " + message); - } - } - - //--- - } - - public interface IPhysicsPlugin - { - bool Init(); - PhysicsScene GetScene(String sceneIdentifier); - string GetName(); - void Dispose(); - } - - public interface IMeshingPlugin - { - string GetName(); - IMesher GetMesher(IConfigSource config); - } -} -- cgit v1.1