mirror of
https://github.com/opensim/opensim.git
synced 2026-08-05 17:05:55 +08:00
Major renaming of Physics dlls / folders. No functional changes, just renames.
This commit is contained in:
58
OpenSim/Region/PhysicsModules/SharedBase/AssemblyInfo.cs
Normal file
58
OpenSim/Region/PhysicsModules/SharedBase/AssemblyInfo.cs
Normal file
@@ -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.*")]
|
||||
73
OpenSim/Region/PhysicsModules/SharedBase/CollisionLocker.cs
Normal file
73
OpenSim/Region/PhysicsModules/SharedBase/CollisionLocker.cs
Normal file
@@ -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<IntPtr> worldlock = new List<IntPtr>();
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
71
OpenSim/Region/PhysicsModules/SharedBase/IMesher.cs
Normal file
71
OpenSim/Region/PhysicsModules/SharedBase/IMesher.cs
Normal file
@@ -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<Vector3> 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);
|
||||
}
|
||||
}
|
||||
73
OpenSim/Region/PhysicsModules/SharedBase/IPhysicsParameters.cs
Executable file
73
OpenSim/Region/PhysicsModules/SharedBase/IPhysicsParameters.cs
Executable file
@@ -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);
|
||||
}
|
||||
}
|
||||
122
OpenSim/Region/PhysicsModules/SharedBase/NullPhysicsScene.cs
Normal file
122
OpenSim/Region/PhysicsModules/SharedBase/NullPhysicsScene.cs
Normal file
@@ -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<uint,float> GetTopColliders()
|
||||
{
|
||||
Dictionary<uint, float> returncolliders = new Dictionary<uint, float>();
|
||||
return returncolliders;
|
||||
}
|
||||
}
|
||||
}
|
||||
584
OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs
Normal file
584
OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used to pass collision information to OnCollisionUpdate listeners.
|
||||
/// </summary>
|
||||
public class CollisionEventUpdate : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Number of collision events in this update.
|
||||
/// </summary>
|
||||
public int Count { get { return m_objCollisionList.Count; } }
|
||||
|
||||
public bool CollisionsOnPreviousFrame { get; private set; }
|
||||
|
||||
public Dictionary<uint, ContactPoint> m_objCollisionList;
|
||||
|
||||
public CollisionEventUpdate(Dictionary<uint, ContactPoint> objCollisionList)
|
||||
{
|
||||
m_objCollisionList = objCollisionList;
|
||||
}
|
||||
|
||||
public CollisionEventUpdate()
|
||||
{
|
||||
m_objCollisionList = new Dictionary<uint, ContactPoint>();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clear added collision events.
|
||||
/// </summary>
|
||||
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;
|
||||
|
||||
/// <summary>
|
||||
/// Subscribers to this event must synchronously handle the dictionary of collisions received, since the event
|
||||
/// object is reused in subsequent physics frames.
|
||||
/// </summary>
|
||||
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; }
|
||||
|
||||
/// <summary>
|
||||
/// Name of this actor.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 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.
|
||||
/// </remarks>
|
||||
public string Name { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// This is being used by ODE joint code.
|
||||
/// </summary>
|
||||
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; }
|
||||
|
||||
/// <summary>
|
||||
/// Position of this actor.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 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.
|
||||
/// </remarks>
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
/// Allows the detection of collisions with inherently non-physical prims. see llVolumeDetect for more
|
||||
/// </summary>
|
||||
public abstract void SetVolumeDetect(int param);
|
||||
|
||||
public abstract Vector3 GeometricCenter { get; }
|
||||
public abstract Vector3 CenterOfMass { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The desired velocity of this actor.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Setting this provides a target velocity for physics scene updates.
|
||||
/// Getting this returns the last set target. Fetch Velocity to get the current velocity.
|
||||
/// </remarks>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
55
OpenSim/Region/PhysicsModules/SharedBase/PhysicsJoint.cs
Normal file
55
OpenSim/Region/PhysicsModules/SharedBase/PhysicsJoint.cs
Normal file
@@ -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<string> BodyNames = new List<string>();
|
||||
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
|
||||
}
|
||||
}
|
||||
242
OpenSim/Region/PhysicsModules/SharedBase/PhysicsPluginManager.cs
Normal file
242
OpenSim/Region/PhysicsModules/SharedBase/PhysicsPluginManager.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Description of MyClass.
|
||||
/// </summary>
|
||||
public class PhysicsPluginManager
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private Dictionary<string, IPhysicsPlugin> _PhysPlugins = new Dictionary<string, IPhysicsPlugin>();
|
||||
private Dictionary<string, IMeshingPlugin> _MeshPlugins = new Dictionary<string, IMeshingPlugin>();
|
||||
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// </summary>
|
||||
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());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a physics scene for the given physics engine and mesher.
|
||||
/// </summary>
|
||||
/// <param name="physEngineName"></param>
|
||||
/// <param name="meshEngineName"></param>
|
||||
/// <param name="config"></param>
|
||||
/// <returns></returns>
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load all plugins in assemblies at the given path
|
||||
/// </summary>
|
||||
/// <param name="pluginsPath"></param>
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load plugins from an assembly at the given path
|
||||
/// </summary>
|
||||
/// <param name="assemblyPath"></param>
|
||||
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);
|
||||
}
|
||||
}
|
||||
361
OpenSim/Region/PhysicsModules/SharedBase/PhysicsScene.cs
Normal file
361
OpenSim/Region/PhysicsModules/SharedBase/PhysicsScene.cs
Normal file
@@ -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<ContactResult> 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);
|
||||
|
||||
/// <summary>
|
||||
/// Contact result from a raycast.
|
||||
/// </summary>
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public string Name { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// A string identifying the family of this physics engine. Most common values returned
|
||||
/// are "OpenDynamicsEngine" and "BulletSim" but others are possible.
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add an avatar
|
||||
/// </summary>
|
||||
/// <param name="avName"></param>
|
||||
/// <param name="position"></param>
|
||||
/// <param name="velocity"></param>
|
||||
/// <param name="size"></param>
|
||||
/// <param name="isFlying"></param>
|
||||
/// <returns></returns>
|
||||
public abstract PhysicsActor AddAvatar(
|
||||
string avName, Vector3 position, Vector3 velocity, Vector3 size, bool isFlying);
|
||||
|
||||
/// <summary>
|
||||
/// Add an avatar
|
||||
/// </summary>
|
||||
/// <param name="localID"></param>
|
||||
/// <param name="avName"></param>
|
||||
/// <param name="position"></param>
|
||||
/// <param name="velocity"></param>
|
||||
/// <param name="size"></param>
|
||||
/// <param name="isFlying"></param>
|
||||
/// <returns></returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove an avatar.
|
||||
/// </summary>
|
||||
/// <param name="actor"></param>
|
||||
public abstract void RemoveAvatar(PhysicsActor actor);
|
||||
|
||||
/// <summary>
|
||||
/// Remove a prim.
|
||||
/// </summary>
|
||||
/// <param name="prim"></param>
|
||||
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<string> 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);
|
||||
|
||||
/// <summary>
|
||||
/// Perform a simulation of the current physics scene over the given timestep.
|
||||
/// </summary>
|
||||
/// <param name="timeStep"></param>
|
||||
/// <returns>The number of frames simulated over that period.</returns>
|
||||
public abstract float Simulate(float timeStep);
|
||||
|
||||
/// <summary>
|
||||
/// Get statistics about this scene.
|
||||
/// </summary>
|
||||
/// <remarks>This facility is currently experimental and subject to change.</remarks>
|
||||
/// <returns>
|
||||
/// A dictionary where the key is the statistic name. If no statistics are supplied then returns null.
|
||||
/// </returns>
|
||||
public virtual Dictionary<string, float> 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<uint, float> GetTopColliders();
|
||||
|
||||
public abstract bool IsThreaded { get; }
|
||||
|
||||
/// <summary>
|
||||
/// True if the physics plugin supports raycasting against the physics scene
|
||||
/// </summary>
|
||||
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) {}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <param name="position">Origin of the ray</param>
|
||||
/// <param name="direction">Direction of the ray</param>
|
||||
/// <param name="length">Length of ray in meters</param>
|
||||
/// <param name="retMethod">Method to call when the raycast is complete</param>
|
||||
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<ContactResult>());
|
||||
}
|
||||
|
||||
public virtual List<ContactResult> RaycastWorld(Vector3 position, Vector3 direction, float length, int Count)
|
||||
{
|
||||
return new List<ContactResult>();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
78
OpenSim/Region/PhysicsModules/SharedBase/PhysicsSensor.cs
Normal file
78
OpenSim/Region/PhysicsModules/SharedBase/PhysicsSensor.cs
Normal file
@@ -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 { } }
|
||||
}
|
||||
}
|
||||
186
OpenSim/Region/PhysicsModules/SharedBase/PhysicsVector.cs
Normal file
186
OpenSim/Region/PhysicsModules/SharedBase/PhysicsVector.cs
Normal file
@@ -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 + ">";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// These routines are the easiest way to store XYZ values in an Vector3 without requiring 3 calls.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
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;
|
||||
}
|
||||
|
||||
}*/
|
||||
}
|
||||
121
OpenSim/Region/PhysicsModules/SharedBase/VehicleConstants.cs
Normal file
121
OpenSim/Region/PhysicsModules/SharedBase/VehicleConstants.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Turns off Vehicle Support
|
||||
/// </summary>
|
||||
TYPE_NONE = 0,
|
||||
|
||||
/// <summary>
|
||||
/// No Angular motor, High Left right friction, No Hover, Linear Deflection 1, no angular deflection
|
||||
/// no vertical attractor, No banking, Identity rotation frame
|
||||
/// </summary>
|
||||
TYPE_SLED = 1,
|
||||
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// </summary>
|
||||
TYPE_CAR = 2,
|
||||
TYPE_BOAT = 3,
|
||||
TYPE_AIRPLANE = 4,
|
||||
TYPE_BALLOON = 5,
|
||||
LINEAR_FRICTION_TIMESCALE = 16,
|
||||
/// <summary>
|
||||
/// vector of timescales for exponential decay of angular velocity about three axis
|
||||
/// </summary>
|
||||
ANGULAR_FRICTION_TIMESCALE = 17,
|
||||
/// <summary>
|
||||
/// linear velocity vehicle will try for
|
||||
/// </summary>
|
||||
LINEAR_MOTOR_DIRECTION = 18,
|
||||
|
||||
/// <summary>
|
||||
/// Offset from center of mass where linear motor forces are added
|
||||
/// </summary>
|
||||
LINEAR_MOTOR_OFFSET = 20,
|
||||
/// <summary>
|
||||
/// angular velocity that vehicle will try for
|
||||
/// </summary>
|
||||
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,
|
||||
|
||||
/// <summary>
|
||||
/// slide between 0 and 1
|
||||
/// </summary>
|
||||
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
|
||||
}
|
||||
|
||||
}
|
||||
83
OpenSim/Region/PhysicsModules/SharedBase/ZeroMesher.cs
Normal file
83
OpenSim/Region/PhysicsModules/SharedBase/ZeroMesher.cs
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user