aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/Manager
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/Manager')
-rw-r--r--OpenSim/Region/Physics/Manager/AssemblyInfo.cs58
-rw-r--r--OpenSim/Region/Physics/Manager/CollisionLocker.cs73
-rw-r--r--OpenSim/Region/Physics/Manager/IMesher.cs98
-rwxr-xr-xOpenSim/Region/Physics/Manager/IPhysicsParameters.cs73
-rw-r--r--OpenSim/Region/Physics/Manager/NullPhysicsScene.cs122
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsActor.cs639
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsJoint.cs55
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs250
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsScene.cs423
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsSensor.cs78
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsVector.cs186
-rw-r--r--OpenSim/Region/Physics/Manager/VehicleConstants.cs164
-rw-r--r--OpenSim/Region/Physics/Manager/ZeroMesher.cs97
13 files changed, 0 insertions, 2316 deletions
diff --git a/OpenSim/Region/Physics/Manager/AssemblyInfo.cs b/OpenSim/Region/Physics/Manager/AssemblyInfo.cs
deleted file mode 100644
index 33f60e4..0000000
--- a/OpenSim/Region/Physics/Manager/AssemblyInfo.cs
+++ /dev/null
@@ -1,58 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System.Reflection;
29using System.Runtime.InteropServices;
30
31// Information about this assembly is defined by the following
32// attributes.
33//
34// change them to the information which is associated with the assembly
35// you compile.
36
37[assembly : AssemblyTitle("PhysicsManager")]
38[assembly : AssemblyDescription("")]
39[assembly : AssemblyConfiguration("")]
40[assembly : AssemblyCompany("http://opensimulator.org")]
41[assembly : AssemblyProduct("PhysicsManager")]
42[assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers")]
43[assembly : AssemblyTrademark("")]
44[assembly : AssemblyCulture("")]
45
46// This sets the default COM visibility of types in the assembly to invisible.
47// If you need to expose a type to COM, use [ComVisible(true)] on that type.
48
49[assembly : ComVisible(false)]
50
51// The assembly version has following format :
52//
53// Major.Minor.Build.Revision
54//
55// You can specify all values by your own or you can build default build and revision
56// numbers with the '*' character (the default):
57
58[assembly : AssemblyVersion("0.8.2.*")]
diff --git a/OpenSim/Region/Physics/Manager/CollisionLocker.cs b/OpenSim/Region/Physics/Manager/CollisionLocker.cs
deleted file mode 100644
index cace4e4..0000000
--- a/OpenSim/Region/Physics/Manager/CollisionLocker.cs
+++ /dev/null
@@ -1,73 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30
31namespace OpenSim.Region.Physics.Manager
32{
33 public class CollisionLocker
34 {
35 private List<IntPtr> worldlock = new List<IntPtr>();
36
37 public CollisionLocker()
38 {
39
40 }
41
42 public void dlock(IntPtr world)
43 {
44 lock (worldlock)
45 {
46 worldlock.Add(world);
47 }
48
49 }
50
51 public void dunlock(IntPtr world)
52 {
53 lock (worldlock)
54 {
55 worldlock.Remove(world);
56 }
57 }
58
59 public bool lockquery()
60 {
61 return (worldlock.Count > 0);
62 }
63
64 public void drelease(IntPtr world)
65 {
66 lock (worldlock)
67 {
68 if (worldlock.Contains(world))
69 worldlock.Remove(world);
70 }
71 }
72 }
73}
diff --git a/OpenSim/Region/Physics/Manager/IMesher.cs b/OpenSim/Region/Physics/Manager/IMesher.cs
deleted file mode 100644
index e290dc9..0000000
--- a/OpenSim/Region/Physics/Manager/IMesher.cs
+++ /dev/null
@@ -1,98 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Runtime.InteropServices;
31using OpenSim.Framework;
32using OpenMetaverse;
33
34namespace OpenSim.Region.Physics.Manager
35{
36 public interface IMesher
37 {
38 IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod);
39 IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical);
40 IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool convex, bool forOde);
41 IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool shouldCache, bool convex, bool forOde);
42 IMesh GetMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool convex);
43 void ReleaseMesh(IMesh mesh);
44 void ExpireReleaseMeshs();
45 void ExpireFileCache();
46 }
47
48 // Values for level of detail to be passed to the mesher.
49 // Values origionally chosen for the LOD of sculpties (the sqrt(width*heigth) of sculpt texture)
50 // Lower level of detail reduces the number of vertices used to represent the meshed shape.
51 public enum LevelOfDetail
52 {
53 High = 32,
54 Medium = 16,
55 Low = 8,
56 VeryLow = 4
57 }
58
59 public interface IVertex
60 {
61 }
62
63 [Serializable()]
64 [StructLayout(LayoutKind.Explicit)]
65 public struct AMeshKey
66 {
67 [FieldOffset(0)]
68 public UUID uuid;
69 [FieldOffset(0)]
70 public ulong hashA;
71 [FieldOffset(8)]
72 public ulong hashB;
73 [FieldOffset(16)]
74 public ulong hashC;
75
76 public override string ToString()
77 {
78 return uuid.ToString() + "-" + hashC.ToString("x") ;
79 }
80 }
81
82 public interface IMesh
83 {
84 List<Vector3> getVertexList();
85 int[] getIndexListAsInt();
86 int[] getIndexListAsIntLocked();
87 float[] getVertexListAsFloat();
88 float[] getVertexListAsFloatLocked();
89 void getIndexListAsPtrToIntArray(out IntPtr indices, out int triStride, out int indexCount);
90 void getVertexListAsPtrToFloatArray(out IntPtr vertexList, out int vertexStride, out int vertexCount);
91 void releaseSourceMeshData();
92 void releasePinned();
93 void Append(IMesh newMesh);
94 void TransformLinear(float[,] matrix, float[] offset);
95 Vector3 GetCentroid();
96 Vector3 GetOBB();
97 }
98}
diff --git a/OpenSim/Region/Physics/Manager/IPhysicsParameters.cs b/OpenSim/Region/Physics/Manager/IPhysicsParameters.cs
deleted file mode 100755
index 31a397c..0000000
--- a/OpenSim/Region/Physics/Manager/IPhysicsParameters.cs
+++ /dev/null
@@ -1,73 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using OpenSim.Framework;
31using OpenMetaverse;
32
33namespace OpenSim.Region.Physics.Manager
34{
35 public struct PhysParameterEntry
36 {
37 // flags to say to apply to all or no instances (I wish one could put consts into interfaces)
38 public const uint APPLY_TO_ALL = 0xfffffff3;
39 public const uint APPLY_TO_NONE = 0xfffffff4;
40
41 // values that denote true and false values
42 public const float NUMERIC_TRUE = 1f;
43 public const float NUMERIC_FALSE = 0f;
44
45 public string name;
46 public string desc;
47
48 public PhysParameterEntry(string n, string d)
49 {
50 name = n;
51 desc = d;
52 }
53 }
54
55 // Interface for a physics scene that implements the runtime setting and getting of physics parameters
56 public interface IPhysicsParameters
57 {
58 // Get the list of parameters this physics engine supports
59 PhysParameterEntry[] GetParameterList();
60
61 // Set parameter on a specific or all instances.
62 // Return 'false' if not able to set the parameter.
63 bool SetPhysicsParameter(string parm, string value, uint localID);
64
65 // Get parameter.
66 // Return 'false' if not able to get the parameter.
67 bool GetPhysicsParameter(string parm, out string value);
68
69 // Get parameter from a particular object
70 // TODO:
71 // bool GetPhysicsParameter(string parm, out string value, uint localID);
72 }
73}
diff --git a/OpenSim/Region/Physics/Manager/NullPhysicsScene.cs b/OpenSim/Region/Physics/Manager/NullPhysicsScene.cs
deleted file mode 100644
index b52f1f6..0000000
--- a/OpenSim/Region/Physics/Manager/NullPhysicsScene.cs
+++ /dev/null
@@ -1,122 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System.Collections.Generic;
29using System.Reflection;
30using log4net;
31using Nini.Config;
32using OpenSim.Framework;
33using OpenMetaverse;
34
35namespace OpenSim.Region.Physics.Manager
36{
37 class NullPhysicsScene : PhysicsScene
38 {
39 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
40
41 private static int m_workIndicator;
42
43 public override void Initialise(IMesher meshmerizer, IConfigSource config)
44 {
45 // Does nothing right now
46 }
47
48 public override PhysicsActor AddAvatar(
49 string avName, Vector3 position, Vector3 velocity, Vector3 size, bool isFlying)
50 {
51 m_log.InfoFormat("[PHYSICS]: NullPhysicsScene : AddAvatar({0})", position);
52 return PhysicsActor.Null;
53 }
54
55 public override void RemoveAvatar(PhysicsActor actor)
56 {
57 }
58
59 public override void RemovePrim(PhysicsActor prim)
60 {
61 }
62 public override void SetWaterLevel(float baseheight)
63 {
64
65 }
66
67/*
68 public override PhysicsActor AddPrim(Vector3 position, Vector3 size, Quaternion rotation)
69 {
70 m_log.InfoFormat("NullPhysicsScene : AddPrim({0},{1})", position, size);
71 return PhysicsActor.Null;
72 }
73*/
74
75 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
76 Vector3 size, Quaternion rotation, bool isPhysical, uint localid)
77 {
78 m_log.InfoFormat("[PHYSICS]: NullPhysicsScene : AddPrim({0},{1})", position, size);
79 return PhysicsActor.Null;
80 }
81
82 public override void AddPhysicsActorTaint(PhysicsActor prim)
83 {
84 }
85
86 public override float Simulate(float timeStep)
87 {
88 m_workIndicator = (m_workIndicator + 1) % 10;
89
90 return 0f;
91 }
92
93 public override void GetResults()
94 {
95 m_log.Info("[PHYSICS]: NullPhysicsScene : GetResults()");
96 }
97
98 public override void SetTerrain(float[] heightMap)
99 {
100 m_log.InfoFormat("[PHYSICS]: NullPhysicsScene : SetTerrain({0} items)", heightMap.Length);
101 }
102
103 public override void DeleteTerrain()
104 {
105 }
106
107 public override bool IsThreaded
108 {
109 get { return false; }
110 }
111
112 public override void Dispose()
113 {
114 }
115
116 public override Dictionary<uint,float> GetTopColliders()
117 {
118 Dictionary<uint, float> returncolliders = new Dictionary<uint, float>();
119 return returncolliders;
120 }
121 }
122} \ No newline at end of file
diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
deleted file mode 100644
index 60f6480..0000000
--- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs
+++ /dev/null
@@ -1,639 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using log4net;
29using System;
30using System.Collections.Generic;
31using System.Reflection;
32using OpenSim.Framework;
33using OpenMetaverse;
34
35namespace OpenSim.Region.Physics.Manager
36{
37 public delegate void PositionUpdate(Vector3 position);
38 public delegate void VelocityUpdate(Vector3 velocity);
39 public delegate void OrientationUpdate(Quaternion orientation);
40
41 public enum ActorTypes : int
42 {
43 Unknown = 0,
44 Agent = 1,
45 Prim = 2,
46 Ground = 3,
47 Water = 4
48 }
49
50 public enum PIDHoverType
51 {
52 Ground,
53 GroundAndWater,
54 Water,
55 Absolute
56 }
57
58 public struct ContactPoint
59 {
60 public Vector3 Position;
61 public Vector3 SurfaceNormal;
62 public float PenetrationDepth;
63 public float RelativeSpeed;
64 public bool CharacterFeet;
65
66 public ContactPoint(Vector3 position, Vector3 surfaceNormal, float penetrationDepth)
67 {
68 Position = position;
69 SurfaceNormal = surfaceNormal;
70 PenetrationDepth = penetrationDepth;
71 RelativeSpeed = 0f; // for now let this one be set explicity
72 CharacterFeet = true; // keep other plugins work as before
73 }
74
75 public ContactPoint(Vector3 position, Vector3 surfaceNormal, float penetrationDepth, bool feet)
76 {
77 Position = position;
78 SurfaceNormal = surfaceNormal;
79 PenetrationDepth = penetrationDepth;
80 RelativeSpeed = 0f; // for now let this one be set explicity
81 CharacterFeet = feet; // keep other plugins work as before
82 }
83 }
84
85 public struct ContactData
86 {
87 public float mu;
88 public float bounce;
89 public bool softcolide;
90
91 public ContactData(float _mu, float _bounce, bool _softcolide)
92 {
93 mu = _mu;
94 bounce = _bounce;
95 softcolide = _softcolide;
96 }
97 }
98 /// <summary>
99 /// Used to pass collision information to OnCollisionUpdate listeners.
100 /// </summary>
101 public class CollisionEventUpdate : EventArgs
102 {
103 /// <summary>
104 /// Number of collision events in this update.
105 /// </summary>
106 public int Count { get { return m_objCollisionList.Count; } }
107
108 public bool CollisionsOnPreviousFrame { get; private set; }
109
110 public Dictionary<uint, ContactPoint> m_objCollisionList;
111
112 public CollisionEventUpdate(Dictionary<uint, ContactPoint> objCollisionList)
113 {
114 m_objCollisionList = objCollisionList;
115 }
116
117 public CollisionEventUpdate()
118 {
119 m_objCollisionList = new Dictionary<uint, ContactPoint>();
120 }
121
122 public void AddCollider(uint localID, ContactPoint contact)
123 {
124 if (!m_objCollisionList.ContainsKey(localID))
125 {
126 m_objCollisionList.Add(localID, contact);
127 }
128 else
129 {
130 if (m_objCollisionList[localID].PenetrationDepth < contact.PenetrationDepth)
131 m_objCollisionList[localID] = contact;
132 }
133 }
134
135 /// <summary>
136 /// Clear added collision events.
137 /// </summary>
138 public void Clear()
139 {
140 m_objCollisionList.Clear();
141 }
142 }
143
144 public abstract class PhysicsActor
145 {
146// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
147
148 public delegate void RequestTerseUpdate();
149 public delegate void CollisionUpdate(EventArgs e);
150 public delegate void OutOfBounds(Vector3 pos);
151
152// disable warning: public events
153#pragma warning disable 67
154 public event PositionUpdate OnPositionUpdate;
155 public event VelocityUpdate OnVelocityUpdate;
156 public event OrientationUpdate OnOrientationUpdate;
157 public event RequestTerseUpdate OnRequestTerseUpdate;
158
159 /// <summary>
160 /// Subscribers to this event must synchronously handle the dictionary of collisions received, since the event
161 /// object is reused in subsequent physics frames.
162 /// </summary>
163 public event CollisionUpdate OnCollisionUpdate;
164
165 public virtual void SetVehicle(object vdata) { }
166
167 public event OutOfBounds OnOutOfBounds;
168#pragma warning restore 67
169
170 public static PhysicsActor Null
171 {
172 get { return new NullPhysicsActor(); }
173 }
174
175 public virtual bool Building { get; set; }
176
177 public virtual void getContactData(ref ContactData cdata)
178 {
179 cdata.mu = 0;
180 cdata.bounce = 0;
181 }
182
183 public abstract bool Stopped { get; }
184
185 public abstract Vector3 Size { get; set; }
186
187 public virtual void setAvatarSize(Vector3 size, float feetOffset)
188 {
189 Size = size;
190 }
191
192 public virtual bool Phantom { get; set; }
193
194 public virtual bool IsVolumeDtc
195 {
196 get { return false; }
197 set { return; }
198 }
199
200 public virtual byte PhysicsShapeType { get; set; }
201
202 public abstract PrimitiveBaseShape Shape { set; }
203
204 uint m_baseLocalID;
205 public virtual uint LocalID
206 {
207 set { m_baseLocalID = value; }
208 get { return m_baseLocalID; }
209 }
210
211 public abstract bool Grabbed { set; }
212
213 public abstract bool Selected { set; }
214
215 /// <summary>
216 /// Name of this actor.
217 /// </summary>
218 /// <remarks>
219 /// XXX: Bizarrely, this cannot be "Terrain" or "Water" right now unless it really is simulating terrain or
220 /// water. This is not a problem due to the formatting of names given by prims and avatars.
221 /// </remarks>
222 public string Name { get; set; }
223
224 /// <summary>
225 /// This is being used by ODE joint code.
226 /// </summary>
227 public string SOPName;
228
229 public abstract void CrossingFailure();
230
231 public abstract void link(PhysicsActor obj);
232
233 public abstract void delink();
234
235 public abstract void LockAngularMotion(Vector3 axis);
236
237 public virtual void RequestPhysicsterseUpdate()
238 {
239 // Make a temporary copy of the event to avoid possibility of
240 // a race condition if the last subscriber unsubscribes
241 // immediately after the null check and before the event is raised.
242 RequestTerseUpdate handler = OnRequestTerseUpdate;
243
244 if (handler != null)
245 {
246 handler();
247 }
248 }
249
250 public virtual void RaiseOutOfBounds(Vector3 pos)
251 {
252 // Make a temporary copy of the event to avoid possibility of
253 // a race condition if the last subscriber unsubscribes
254 // immediately after the null check and before the event is raised.
255 OutOfBounds handler = OnOutOfBounds;
256
257 if (handler != null)
258 {
259 handler(pos);
260 }
261 }
262
263 public virtual void SendCollisionUpdate(EventArgs e)
264 {
265 CollisionUpdate handler = OnCollisionUpdate;
266
267// m_log.DebugFormat("[PHYSICS ACTOR]: Sending collision for {0}", LocalID);
268
269 if (handler != null)
270 handler(e);
271 }
272
273 public virtual void SetMaterial (int material) { }
274 public virtual float Density { get; set; }
275 public virtual float GravModifier { get; set; }
276 public virtual float Friction { get; set; }
277 public virtual float Restitution { get; set; }
278
279 /// <summary>
280 /// Position of this actor.
281 /// </summary>
282 /// <remarks>
283 /// Setting this directly moves the actor to a given position.
284 /// Getting this retrieves the position calculated by physics scene updates, using factors such as velocity and
285 /// collisions.
286 /// </remarks>
287 public abstract Vector3 Position { get; set; }
288
289 public abstract float Mass { get; }
290 public abstract Vector3 Force { get; set; }
291
292 public abstract int VehicleType { get; set; }
293 public abstract void VehicleFloatParam(int param, float value);
294 public abstract void VehicleVectorParam(int param, Vector3 value);
295 public abstract void VehicleRotationParam(int param, Quaternion rotation);
296 public abstract void VehicleFlags(int param, bool remove);
297
298 /// <summary>
299 /// Allows the detection of collisions with inherently non-physical prims. see llVolumeDetect for more
300 /// </summary>
301 public abstract void SetVolumeDetect(int param);
302
303 public abstract Vector3 GeometricCenter { get; }
304 public abstract Vector3 CenterOfMass { get; }
305
306 public virtual Vector3 OOBsize
307 {
308 get
309 {
310 Vector3 s=Size;
311 s.X *=0.5f;
312 s.Y *=0.5f;
313 s.Z *=0.5f;
314 return s;
315 }
316 }
317
318 public virtual Vector3 OOBoffset
319 {
320 get
321 {
322 return Vector3.Zero;
323 }
324 }
325
326 public virtual float OOBRadiusSQ
327 {
328 get
329 {
330 return Size.LengthSquared() * 0.25f; // ((0.5^2)
331 }
332 }
333
334
335 public virtual float PhysicsCost
336 {
337 get
338 {
339 return 0.1f;
340 }
341 }
342
343 public virtual float StreamCost
344 {
345 get
346 {
347 return 1.0f;
348 }
349 }
350
351 /// <summary>
352 /// The desired velocity of this actor.
353 /// </summary>
354 /// <remarks>
355 /// Setting this provides a target velocity for physics scene updates.
356 /// Getting this returns the last set target. Fetch Velocity to get the current velocity.
357 /// </remarks>
358 protected Vector3 m_targetVelocity;
359 public virtual Vector3 TargetVelocity
360 {
361 get { return m_targetVelocity; }
362 set {
363 m_targetVelocity = value;
364 Velocity = m_targetVelocity;
365 }
366 }
367
368 public abstract Vector3 Velocity { get; set; }
369
370 public abstract Vector3 Torque { get; set; }
371 public abstract float CollisionScore { get; set;}
372 public abstract Vector3 Acceleration { get; set; }
373 public abstract Quaternion Orientation { get; set; }
374 public abstract int PhysicsActorType { get; set; }
375 public abstract bool IsPhysical { get; set; }
376 public abstract bool Flying { get; set; }
377 public abstract bool SetAlwaysRun { get; set; }
378 public abstract bool ThrottleUpdates { get; set; }
379 public abstract bool IsColliding { get; set; }
380 public abstract bool CollidingGround { get; set; }
381 public abstract bool CollidingObj { get; set; }
382 public abstract bool FloatOnWater { set; }
383 public abstract Vector3 RotationalVelocity { get; set; }
384 public abstract bool Kinematic { get; set; }
385 public abstract float Buoyancy { get; set; }
386
387 // Used for MoveTo
388 public abstract Vector3 PIDTarget { set; }
389 public abstract bool PIDActive { get; set; }
390 public abstract float PIDTau { set; }
391
392 // Used for llSetHoverHeight and maybe vehicle height
393 // Hover Height will override MoveTo target's Z
394 public abstract bool PIDHoverActive { set;}
395 public abstract float PIDHoverHeight { set;}
396 public abstract PIDHoverType PIDHoverType { set;}
397 public abstract float PIDHoverTau { set;}
398
399 // For RotLookAt
400 public abstract Quaternion APIDTarget { set;}
401 public abstract bool APIDActive { set;}
402 public abstract float APIDStrength { set;}
403 public abstract float APIDDamping { set;}
404
405 public abstract void AddForce(Vector3 force, bool pushforce);
406 public abstract void AddAngularForce(Vector3 force, bool pushforce);
407 public abstract void SetMomentum(Vector3 momentum);
408 public abstract void SubscribeEvents(int ms);
409 public abstract void UnSubscribeEvents();
410 public abstract bool SubscribedEvents();
411
412 public virtual void AddCollisionEvent(uint CollidedWith, ContactPoint contact) { }
413
414 // Warning in a parent part it returns itself, not null
415 public virtual PhysicsActor ParentActor { get { return this; } }
416
417
418 // Extendable interface for new, physics engine specific operations
419 public virtual object Extension(string pFunct, params object[] pParams)
420 {
421 // A NOP of the physics engine does not implement this feature
422 return null;
423 }
424 }
425
426 public class NullPhysicsActor : PhysicsActor
427 {
428 private ActorTypes m_actorType = ActorTypes.Unknown;
429
430 public override bool Stopped
431 {
432 get{ return true; }
433 }
434
435 public override Vector3 Position
436 {
437 get { return Vector3.Zero; }
438 set { return; }
439 }
440
441 public override bool SetAlwaysRun
442 {
443 get { return false; }
444 set { return; }
445 }
446
447 public override uint LocalID
448 {
449 get { return 0; }
450 set { return; }
451 }
452
453 public override bool Grabbed
454 {
455 set { return; }
456 }
457
458 public override bool Selected
459 {
460 set { return; }
461 }
462
463 public override float Buoyancy
464 {
465 get { return 0f; }
466 set { return; }
467 }
468
469 public override bool FloatOnWater
470 {
471 set { return; }
472 }
473
474 public override bool CollidingGround
475 {
476 get { return false; }
477 set { return; }
478 }
479
480 public override bool CollidingObj
481 {
482 get { return false; }
483 set { return; }
484 }
485
486 public override Vector3 Size
487 {
488 get { return Vector3.Zero; }
489 set { return; }
490 }
491
492 public override float Mass
493 {
494 get { return 0f; }
495 }
496
497 public override Vector3 Force
498 {
499 get { return Vector3.Zero; }
500 set { return; }
501 }
502
503 public override int VehicleType
504 {
505 get { return 0; }
506 set { return; }
507 }
508
509 public override void VehicleFloatParam(int param, float value) {}
510 public override void VehicleVectorParam(int param, Vector3 value) { }
511 public override void VehicleRotationParam(int param, Quaternion rotation) { }
512 public override void VehicleFlags(int param, bool remove) { }
513 public override void SetVolumeDetect(int param) {}
514 public override void SetMaterial(int material) {}
515 public override Vector3 CenterOfMass { get { return Vector3.Zero; }}
516
517 public override Vector3 GeometricCenter { get { return Vector3.Zero; }}
518
519 public override PrimitiveBaseShape Shape { set { return; }}
520
521 public override Vector3 Velocity
522 {
523 get { return Vector3.Zero; }
524 set { return; }
525 }
526
527 public override Vector3 Torque
528 {
529 get { return Vector3.Zero; }
530 set { return; }
531 }
532
533 public override float CollisionScore
534 {
535 get { return 0f; }
536 set { }
537 }
538
539 public override void CrossingFailure() {}
540
541 public override Quaternion Orientation
542 {
543 get { return Quaternion.Identity; }
544 set { }
545 }
546
547 public override Vector3 Acceleration
548 {
549 get { return Vector3.Zero; }
550 set { }
551 }
552
553 public override bool IsPhysical
554 {
555 get { return false; }
556 set { return; }
557 }
558
559 public override bool Flying
560 {
561 get { return false; }
562 set { return; }
563 }
564
565 public override bool ThrottleUpdates
566 {
567 get { return false; }
568 set { return; }
569 }
570
571 public override bool IsColliding
572 {
573 get { return false; }
574 set { return; }
575 }
576
577 public override int PhysicsActorType
578 {
579 get { return (int)m_actorType; }
580 set {
581 ActorTypes type = (ActorTypes)value;
582 switch (type)
583 {
584 case ActorTypes.Ground:
585 case ActorTypes.Water:
586 m_actorType = type;
587 break;
588 default:
589 m_actorType = ActorTypes.Unknown;
590 break;
591 }
592 }
593 }
594
595 public override bool Kinematic
596 {
597 get { return true; }
598 set { return; }
599 }
600
601 public override void link(PhysicsActor obj) { }
602 public override void delink() { }
603 public override void LockAngularMotion(Vector3 axis) { }
604 public override void AddForce(Vector3 force, bool pushforce) { }
605 public override void AddAngularForce(Vector3 force, bool pushforce) { }
606
607 public override Vector3 RotationalVelocity
608 {
609 get { return Vector3.Zero; }
610 set { return; }
611 }
612
613 public override Vector3 PIDTarget { set { return; } }
614
615 public override bool PIDActive
616 {
617 get { return false; }
618 set { return; }
619 }
620
621 public override float PIDTau { set { return; } }
622
623 public override float PIDHoverHeight { set { return; } }
624 public override bool PIDHoverActive { set { return; } }
625 public override PIDHoverType PIDHoverType { set { return; } }
626 public override float PIDHoverTau { set { return; } }
627
628 public override Quaternion APIDTarget { set { return; } }
629 public override bool APIDActive { set { return; } }
630 public override float APIDStrength { set { return; } }
631 public override float APIDDamping { set { return; } }
632
633 public override void SetMomentum(Vector3 momentum) { }
634
635 public override void SubscribeEvents(int ms) { }
636 public override void UnSubscribeEvents() { }
637 public override bool SubscribedEvents() { return false; }
638 }
639}
diff --git a/OpenSim/Region/Physics/Manager/PhysicsJoint.cs b/OpenSim/Region/Physics/Manager/PhysicsJoint.cs
deleted file mode 100644
index b685d04..0000000
--- a/OpenSim/Region/Physics/Manager/PhysicsJoint.cs
+++ /dev/null
@@ -1,55 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using OpenSim.Framework;
31using OpenMetaverse;
32
33namespace OpenSim.Region.Physics.Manager
34{
35 public enum PhysicsJointType : int
36 {
37 Ball = 0,
38 Hinge = 1
39 }
40
41 public class PhysicsJoint
42 {
43 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
44 public PhysicsJointType Type;
45 public string RawParams;
46 public List<string> BodyNames = new List<string>();
47 public Vector3 Position; // global coords
48 public Quaternion Rotation; // global coords
49 public string ObjectNameInScene; // proxy object in scene that represents the joint position/orientation
50 public string TrackedBodyName; // body name that this joint is attached to (ObjectNameInScene will follow TrackedBodyName)
51 public Quaternion LocalRotation; // joint orientation relative to one of the involved bodies, the tracked body
52 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.
53 public const int maxErrorMessages = 100; // no more than this # of error messages will be printed for each joint
54 }
55}
diff --git a/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs b/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs
deleted file mode 100644
index ddbe80b..0000000
--- a/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs
+++ /dev/null
@@ -1,250 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.IO;
31using System.Reflection;
32using Nini.Config;
33using log4net;
34using OpenSim.Framework;
35using OpenMetaverse;
36
37namespace OpenSim.Region.Physics.Manager
38{
39 /// <summary>
40 /// Description of MyClass.
41 /// </summary>
42 public class PhysicsPluginManager
43 {
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45
46 private Dictionary<string, IPhysicsPlugin> _PhysPlugins = new Dictionary<string, IPhysicsPlugin>();
47 private Dictionary<string, IMeshingPlugin> _MeshPlugins = new Dictionary<string, IMeshingPlugin>();
48
49 /// <summary>
50 /// Constructor.
51 /// </summary>
52 public PhysicsPluginManager()
53 {
54 // Load "plugins", that are hard coded and not existing in form of an external lib, and hence always
55 // available
56 IMeshingPlugin plugHard;
57 plugHard = new ZeroMesherPlugin();
58 _MeshPlugins.Add(plugHard.GetName(), plugHard);
59
60 m_log.Info("[PHYSICS]: Added meshing engine: " + plugHard.GetName());
61 }
62
63 // Legacy method for simulators before extent was passed
64 public PhysicsScene GetPhysicsScene(string physEngineName, string meshEngineName,
65 IConfigSource config, string regionName)
66 {
67 Vector3 extent = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight);
68 return GetPhysicsScene(physEngineName, meshEngineName, config, regionName, extent);
69 }
70
71 /// <summary>
72 /// Get a physics scene for the given physics engine and mesher.
73 /// </summary>
74 /// <param name="physEngineName"></param>
75 /// <param name="meshEngineName"></param>
76 /// <param name="config"></param>
77 /// <returns></returns>
78 public PhysicsScene GetPhysicsScene(string physEngineName, string meshEngineName,
79 IConfigSource config, string regionName, Vector3 regionExtent)
80 {
81 if (String.IsNullOrEmpty(physEngineName))
82 {
83 return PhysicsScene.Null;
84 }
85
86 if (String.IsNullOrEmpty(meshEngineName))
87 {
88 return PhysicsScene.Null;
89 }
90
91 IMesher meshEngine = null;
92 if (_MeshPlugins.ContainsKey(meshEngineName))
93 {
94 m_log.Info("[PHYSICS]: creating meshing engine " + meshEngineName);
95 meshEngine = _MeshPlugins[meshEngineName].GetMesher(config);
96 }
97 else
98 {
99 m_log.WarnFormat("[PHYSICS]: couldn't find meshingEngine: {0}", meshEngineName);
100 throw new ArgumentException(String.Format("couldn't find meshingEngine: {0}", meshEngineName));
101 }
102
103 if (_PhysPlugins.ContainsKey(physEngineName))
104 {
105 m_log.Info("[PHYSICS]: creating " + physEngineName);
106 PhysicsScene result = _PhysPlugins[physEngineName].GetScene(regionName);
107 result.Initialise(meshEngine, config, regionExtent);
108 return result;
109 }
110 else
111 {
112 m_log.WarnFormat("[PHYSICS]: couldn't find physicsEngine: {0}", physEngineName);
113 throw new ArgumentException(String.Format("couldn't find physicsEngine: {0}", physEngineName));
114 }
115 }
116
117 /// <summary>
118 /// Load all plugins in assemblies at the given path
119 /// </summary>
120 /// <param name="pluginsPath"></param>
121 public void LoadPluginsFromAssemblies(string assembliesPath)
122 {
123 // Walk all assemblies (DLLs effectively) and see if they are home
124 // of a plugin that is of interest for us
125 string[] pluginFiles = Directory.GetFiles(assembliesPath, "*.dll");
126
127 for (int i = 0; i < pluginFiles.Length; i++)
128 {
129 LoadPluginsFromAssembly(pluginFiles[i]);
130 }
131 }
132
133 /// <summary>
134 /// Load plugins from an assembly at the given path
135 /// </summary>
136 /// <param name="assemblyPath"></param>
137 public void LoadPluginsFromAssembly(string assemblyPath)
138 {
139 // TODO / NOTE
140 // The assembly named 'OpenSim.Region.Physics.BasicPhysicsPlugin' was loaded from
141 // 'file:///C:/OpenSim/trunk2/bin/Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll'
142 // using the LoadFrom context. The use of this context can result in unexpected behavior
143 // for serialization, casting and dependency resolution. In almost all cases, it is recommended
144 // that the LoadFrom context be avoided. This can be done by installing assemblies in the
145 // Global Assembly Cache or in the ApplicationBase directory and using Assembly.
146 // Load when explicitly loading assemblies.
147 Assembly pluginAssembly = null;
148 Type[] types = null;
149
150 try
151 {
152 pluginAssembly = Assembly.LoadFrom(assemblyPath);
153 }
154 catch (Exception ex)
155 {
156 m_log.Error("[PHYSICS]: Failed to load plugin from " + assemblyPath, ex);
157 }
158
159 if (pluginAssembly != null)
160 {
161 try
162 {
163 types = pluginAssembly.GetTypes();
164 }
165 catch (ReflectionTypeLoadException ex)
166 {
167 m_log.Error("[PHYSICS]: Failed to enumerate types in plugin from " + assemblyPath + ": " +
168 ex.LoaderExceptions[0].Message, ex);
169 }
170 catch (Exception ex)
171 {
172 m_log.Error("[PHYSICS]: Failed to enumerate types in plugin from " + assemblyPath, ex);
173 }
174
175 if (types != null)
176 {
177 foreach (Type pluginType in types)
178 {
179 if (pluginType.IsPublic)
180 {
181 if (!pluginType.IsAbstract)
182 {
183 Type physTypeInterface = pluginType.GetInterface("IPhysicsPlugin");
184
185 if (physTypeInterface != null)
186 {
187 IPhysicsPlugin plug =
188 (IPhysicsPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
189 plug.Init();
190 if (!_PhysPlugins.ContainsKey(plug.GetName()))
191 {
192 _PhysPlugins.Add(plug.GetName(), plug);
193 m_log.Info("[PHYSICS]: Added physics engine: " + plug.GetName());
194 }
195 }
196
197 Type meshTypeInterface = pluginType.GetInterface("IMeshingPlugin");
198
199 if (meshTypeInterface != null)
200 {
201 IMeshingPlugin plug =
202 (IMeshingPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
203 if (!_MeshPlugins.ContainsKey(plug.GetName()))
204 {
205 _MeshPlugins.Add(plug.GetName(), plug);
206 m_log.Info("[PHYSICS]: Added meshing engine: " + plug.GetName());
207 }
208 }
209
210 physTypeInterface = null;
211 meshTypeInterface = null;
212 }
213 }
214 }
215 }
216 }
217
218 pluginAssembly = null;
219 }
220
221 //---
222 public static void PhysicsPluginMessage(string message, bool isWarning)
223 {
224 if (isWarning)
225 {
226 m_log.Warn("[PHYSICS]: " + message);
227 }
228 else
229 {
230 m_log.Info("[PHYSICS]: " + message);
231 }
232 }
233
234 //---
235 }
236
237 public interface IPhysicsPlugin
238 {
239 bool Init();
240 PhysicsScene GetScene(String sceneIdentifier);
241 string GetName();
242 void Dispose();
243 }
244
245 public interface IMeshingPlugin
246 {
247 string GetName();
248 IMesher GetMesher(IConfigSource config);
249 }
250}
diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs
deleted file mode 100644
index a9b30e1..0000000
--- a/OpenSim/Region/Physics/Manager/PhysicsScene.cs
+++ /dev/null
@@ -1,423 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31
32using log4net;
33using Nini.Config;
34
35using OpenSim.Framework;
36using OpenMetaverse;
37
38namespace OpenSim.Region.Physics.Manager
39{
40 public delegate void physicsCrash();
41
42 public delegate void RaycastCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 normal);
43 public delegate void RayCallback(List<ContactResult> list);
44 public delegate void ProbeBoxCallback(List<ContactResult> list);
45 public delegate void ProbeSphereCallback(List<ContactResult> list);
46 public delegate void ProbePlaneCallback(List<ContactResult> list);
47 public delegate void SitAvatarCallback(int status, uint partID, Vector3 offset, Quaternion Orientation);
48
49 public delegate void JointMoved(PhysicsJoint joint);
50 public delegate void JointDeactivated(PhysicsJoint joint);
51 public delegate void JointErrorMessage(PhysicsJoint joint, string message); // this refers to an "error message due to a problem", not "amount of joint constraint violation"
52
53 public enum RayFilterFlags : ushort
54 {
55 // the flags
56 water = 0x01,
57 land = 0x02,
58 agent = 0x04,
59 nonphysical = 0x08,
60 physical = 0x10,
61 phantom = 0x20,
62 volumedtc = 0x40,
63
64 // ray cast colision control (may only work for meshs)
65 ContactsUnImportant = 0x2000,
66 BackFaceCull = 0x4000,
67 ClosestHit = 0x8000,
68
69 // some combinations
70 LSLPhantom = phantom | volumedtc,
71 PrimsNonPhantom = nonphysical | physical,
72 PrimsNonPhantomAgents = nonphysical | physical | agent,
73
74 AllPrims = nonphysical | phantom | volumedtc | physical,
75 AllButLand = agent | nonphysical | physical | phantom | volumedtc,
76
77 ClosestAndBackCull = ClosestHit | BackFaceCull,
78
79 All = 0x3f
80 }
81
82 public delegate void RequestAssetDelegate(UUID assetID, AssetReceivedDelegate callback);
83 public delegate void AssetReceivedDelegate(AssetBase asset);
84
85 /// <summary>
86 /// Contact result from a raycast.
87 /// </summary>
88 public struct ContactResult
89 {
90 public Vector3 Pos;
91 public float Depth;
92 public uint ConsumerID;
93 public Vector3 Normal;
94 }
95
96
97
98 public abstract class PhysicsScene
99 {
100// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
101
102 /// <summary>
103 /// A unique identifying string for this instance of the physics engine.
104 /// Useful in debug messages to distinguish one OdeScene instance from another.
105 /// Usually set to include the region name that the physics engine is acting for.
106 /// </summary>
107 public string Name { get; protected set; }
108
109 /// <summary>
110 /// A string identifying the family of this physics engine. Most common values returned
111 /// are "OpenDynamicsEngine" and "BulletSim" but others are possible.
112 /// </summary>
113 public string EngineType { get; protected set; }
114
115 // The only thing that should register for this event is the SceneGraph
116 // Anything else could cause problems.
117 public event physicsCrash OnPhysicsCrash;
118
119 public static PhysicsScene Null
120 {
121 get { return new NullPhysicsScene(); }
122 }
123
124 public RequestAssetDelegate RequestAssetMethod { get; set; }
125
126 public virtual void TriggerPhysicsBasedRestart()
127 {
128 physicsCrash handler = OnPhysicsCrash;
129 if (handler != null)
130 {
131 OnPhysicsCrash();
132 }
133 }
134
135 // Deprecated. Do not use this for new physics engines.
136 public abstract void Initialise(IMesher meshmerizer, IConfigSource config);
137
138 // For older physics engines that do not implement non-legacy region sizes.
139 // If the physics engine handles the region extent feature, it overrides this function.
140 public virtual void Initialise(IMesher meshmerizer, IConfigSource config, Vector3 regionExtent)
141 {
142 // If not overridden, call the old initialization entry.
143 Initialise(meshmerizer, config);
144 }
145
146 /// <summary>
147 /// Add an avatar
148 /// </summary>
149 /// <param name="avName"></param>
150 /// <param name="position"></param>
151 /// <param name="velocity"></param>
152 /// <param name="size"></param>
153 /// <param name="isFlying"></param>
154 /// <returns></returns>
155
156 public abstract PhysicsActor AddAvatar(
157 string avName, Vector3 position, Vector3 velocity, Vector3 size, bool isFlying);
158
159 /// <summary>
160 /// Add an avatar
161 /// </summary>
162 /// <param name="localID"></param>
163 /// <param name="avName"></param>
164 /// <param name="position"></param>
165 /// <param name="velocity"></param>
166 /// <param name="size"></param>
167 /// <param name="isFlying"></param>
168 /// <returns></returns>
169 public virtual PhysicsActor AddAvatar(
170 uint localID, string avName, Vector3 position, Vector3 velocity, Vector3 size, bool isFlying)
171 {
172 PhysicsActor ret = AddAvatar(avName, position, velocity, size, isFlying);
173
174 if (ret != null)
175 ret.LocalID = localID;
176
177 return ret;
178 }
179
180 public virtual PhysicsActor AddAvatar(
181 uint localID, string avName, Vector3 position, Vector3 size, bool isFlying)
182 {
183 PhysicsActor ret = AddAvatar(localID, avName, position, Vector3.Zero, size, isFlying);
184 return ret;
185 }
186
187 public virtual PhysicsActor AddAvatar(
188 uint localID, string avName, Vector3 position, Vector3 size, float feetOffset, bool isFlying)
189 {
190 PhysicsActor ret = AddAvatar(localID, avName, position, Vector3.Zero, size, isFlying);
191 return ret;
192 }
193
194 /// <summary>
195 /// Remove an avatar.
196 /// </summary>
197 /// <param name="actor"></param>
198 public abstract void RemoveAvatar(PhysicsActor actor);
199
200 /// <summary>
201 /// Remove a prim.
202 /// </summary>
203 /// <param name="prim"></param>
204 public abstract void RemovePrim(PhysicsActor prim);
205
206 public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
207 Vector3 size, Quaternion rotation, bool isPhysical, uint localid);
208
209 public virtual PhysicsActor AddPrimShape(string primName, PhysicsActor parent, PrimitiveBaseShape pbs, Vector3 position,
210 uint localid, byte[] sdata)
211 {
212 return null;
213 }
214
215 public virtual PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
216 Vector3 size, Quaternion rotation, bool isPhysical, bool isPhantom, uint localid)
217 {
218 return AddPrimShape(primName, pbs, position, size, rotation, isPhysical, localid);
219 }
220
221
222 public virtual PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
223 Vector3 size, Quaternion rotation, bool isPhysical, bool isPhantom, byte shapetype, uint localid)
224 {
225 return AddPrimShape(primName, pbs, position, size, rotation, isPhysical, localid);
226 }
227
228 public virtual float TimeDilation
229 {
230 get { return 1.0f; }
231 }
232
233 public virtual bool SupportsNINJAJoints
234 {
235 get { return false; }
236 }
237
238 public virtual PhysicsJoint RequestJointCreation(string objectNameInScene, PhysicsJointType jointType, Vector3 position,
239 Quaternion rotation, string parms, List<string> bodyNames, string trackedBodyName, Quaternion localRotation)
240 { return null; }
241
242 public virtual void RequestJointDeletion(string objectNameInScene)
243 { return; }
244
245 public virtual void RemoveAllJointsConnectedToActorThreadLocked(PhysicsActor actor)
246 { return; }
247
248 public virtual void DumpJointInfo()
249 { return; }
250
251 public event JointMoved OnJointMoved;
252
253 protected virtual void DoJointMoved(PhysicsJoint joint)
254 {
255 // We need this to allow subclasses (but not other classes) to invoke the event; C# does
256 // not allow subclasses to invoke the parent class event.
257 if (OnJointMoved != null)
258 {
259 OnJointMoved(joint);
260 }
261 }
262
263 public event JointDeactivated OnJointDeactivated;
264
265 protected virtual void DoJointDeactivated(PhysicsJoint joint)
266 {
267 // We need this to allow subclasses (but not other classes) to invoke the event; C# does
268 // not allow subclasses to invoke the parent class event.
269 if (OnJointDeactivated != null)
270 {
271 OnJointDeactivated(joint);
272 }
273 }
274
275 public event JointErrorMessage OnJointErrorMessage;
276
277 protected virtual void DoJointErrorMessage(PhysicsJoint joint, string message)
278 {
279 // We need this to allow subclasses (but not other classes) to invoke the event; C# does
280 // not allow subclasses to invoke the parent class event.
281 if (OnJointErrorMessage != null)
282 {
283 OnJointErrorMessage(joint, message);
284 }
285 }
286
287 public virtual Vector3 GetJointAnchor(PhysicsJoint joint)
288 { return Vector3.Zero; }
289
290 public virtual Vector3 GetJointAxis(PhysicsJoint joint)
291 { return Vector3.Zero; }
292
293 public abstract void AddPhysicsActorTaint(PhysicsActor prim);
294
295
296 public virtual void PrepareSimulation() { }
297
298 /// <summary>
299 /// Perform a simulation of the current physics scene over the given timestep.
300 /// </summary>
301 /// <param name="timeStep"></param>
302 /// <returns>The number of frames simulated over that period.</returns>
303 public abstract float Simulate(float timeStep);
304
305 /// <summary>
306 /// Get statistics about this scene.
307 /// </summary>
308 /// <remarks>This facility is currently experimental and subject to change.</remarks>
309 /// <returns>
310 /// A dictionary where the key is the statistic name. If no statistics are supplied then returns null.
311 /// </returns>
312 public virtual Dictionary<string, float> GetStats() { return null; }
313
314 public abstract void GetResults();
315
316 public abstract void SetTerrain(float[] heightMap);
317
318 public abstract void SetWaterLevel(float baseheight);
319
320 public abstract void DeleteTerrain();
321
322 public abstract void Dispose();
323
324 public abstract Dictionary<uint, float> GetTopColliders();
325
326 public abstract bool IsThreaded { get; }
327
328 /// <summary>
329 /// True if the physics plugin supports raycasting against the physics scene
330 /// </summary>
331 public virtual bool SupportsRayCast()
332 {
333 return false;
334 }
335
336 public virtual bool SupportsCombining()
337 {
338 return false;
339 }
340
341 public virtual void Combine(PhysicsScene pScene, Vector3 offset, Vector3 extents) {}
342 public virtual void CombineTerrain(float[] heightMap, Vector3 pOffset) {}
343 public virtual void UnCombine(PhysicsScene pScene) {}
344
345 /// <summary>
346 /// Queue a raycast against the physics scene.
347 /// The provided callback method will be called when the raycast is complete
348 ///
349 /// Many physics engines don't support collision testing at the same time as
350 /// manipulating the physics scene, so we queue the request up and callback
351 /// a custom method when the raycast is complete.
352 /// This allows physics engines that give an immediate result to callback immediately
353 /// and ones that don't, to callback when it gets a result back.
354 ///
355 /// ODE for example will not allow you to change the scene while collision testing or
356 /// it asserts, 'opteration not valid for locked space'. This includes adding a ray to the scene.
357 ///
358 /// This is named RayCastWorld to not conflict with modrex's Raycast method.
359 /// </summary>
360 /// <param name="position">Origin of the ray</param>
361 /// <param name="direction">Direction of the ray</param>
362 /// <param name="length">Length of ray in meters</param>
363 /// <param name="retMethod">Method to call when the raycast is complete</param>
364 public virtual void RaycastWorld(Vector3 position, Vector3 direction, float length, RaycastCallback retMethod)
365 {
366 if (retMethod != null)
367 retMethod(false, Vector3.Zero, 0, 999999999999f, Vector3.Zero);
368 }
369
370 public virtual void RaycastWorld(Vector3 position, Vector3 direction, float length, int Count, RayCallback retMethod)
371 {
372 if (retMethod != null)
373 retMethod(new List<ContactResult>());
374 }
375
376 public virtual List<ContactResult> RaycastWorld(Vector3 position, Vector3 direction, float length, int Count)
377 {
378 return new List<ContactResult>();
379 }
380
381 public virtual object RaycastWorld(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter)
382 {
383 return null;
384 }
385
386 public virtual bool SupportsRaycastWorldFiltered()
387 {
388 return false;
389 }
390
391 public virtual List<ContactResult> RaycastActor(PhysicsActor actor, Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags flags)
392 {
393 return new List<ContactResult>();
394 }
395
396 public virtual List<ContactResult> BoxProbe(Vector3 position, Vector3 size, Quaternion orientation, int Count, RayFilterFlags flags)
397 {
398 return new List<ContactResult>();
399 }
400
401 public virtual List<ContactResult> SphereProbe(Vector3 position, float radius, int Count, RayFilterFlags flags)
402 {
403 return new List<ContactResult>();
404 }
405
406 public virtual List<ContactResult> PlaneProbe(PhysicsActor actor, Vector4 plane, int Count, RayFilterFlags flags)
407 {
408 return new List<ContactResult>();
409 }
410
411 public virtual int SitAvatar(PhysicsActor actor, Vector3 AbsolutePosition, Vector3 CameraPosition, Vector3 offset, Vector3 AvatarSize, SitAvatarCallback PhysicsSitResponse)
412 {
413 return 0;
414 }
415
416 // Extendable interface for new, physics engine specific operations
417 public virtual object Extension(string pFunct, params object[] pParams)
418 {
419 // A NOP if the extension thing is not implemented by the physics engine
420 return null;
421 }
422 }
423}
diff --git a/OpenSim/Region/Physics/Manager/PhysicsSensor.cs b/OpenSim/Region/Physics/Manager/PhysicsSensor.cs
deleted file mode 100644
index f480d71..0000000
--- a/OpenSim/Region/Physics/Manager/PhysicsSensor.cs
+++ /dev/null
@@ -1,78 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Timers;
30using OpenMetaverse;
31
32namespace OpenSim.Region.Physics.Manager
33{
34 [Flags]
35 public enum SenseType : uint
36 {
37 NONE = 0,
38 AGENT = 1,
39 ACTIVE = 2,
40 PASSIVE = 3,
41 SCRIPTED = 4
42 }
43
44 public abstract class PhysicsSensor
45 {
46 public static PhysicsSensor Null
47 {
48 get { return new NullPhysicsSensor(); }
49 }
50 public abstract Vector3 Position { get; set; }
51 public abstract void TimerCallback (object obj, ElapsedEventArgs eea);
52 public abstract float radianarc {get; set;}
53 public abstract string targetname {get; set;}
54 public abstract Guid targetKey{get;set;}
55 public abstract SenseType sensetype { get;set;}
56 public abstract float range { get;set;}
57 public abstract float rateSeconds { get;set;}
58 }
59
60 public class NullPhysicsSensor : PhysicsSensor
61 {
62 public override Vector3 Position
63 {
64 get { return Vector3.Zero; }
65 set { return; }
66 }
67 public override void TimerCallback(object obj, ElapsedEventArgs eea)
68 {
69 // don't do squat
70 }
71 public override float radianarc { get { return 0f; } set { } }
72 public override string targetname { get { return ""; } set { } }
73 public override Guid targetKey { get { return Guid.Empty; } set { } }
74 public override SenseType sensetype { get { return SenseType.NONE; } set { } }
75 public override float range { get { return 0; } set { } }
76 public override float rateSeconds { get { return 0; } set { } }
77 }
78}
diff --git a/OpenSim/Region/Physics/Manager/PhysicsVector.cs b/OpenSim/Region/Physics/Manager/PhysicsVector.cs
deleted file mode 100644
index f60a636..0000000
--- a/OpenSim/Region/Physics/Manager/PhysicsVector.cs
+++ /dev/null
@@ -1,186 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29
30namespace OpenSim.Region.Physics.Manager
31{
32 /*public class PhysicsVector
33 {
34 public float X;
35 public float Y;
36 public float Z;
37
38 public Vector3()
39 {
40 }
41
42 public Vector3(float x, float y, float z)
43 {
44 X = x;
45 Y = y;
46 Z = z;
47 }
48
49 public Vector3(Vector3 pv) : this(pv.X, pv.Y, pv.Z)
50 {
51 }
52
53 public void setValues(float x, float y, float z)
54 {
55 X = x;
56 Y = y;
57 Z = z;
58 }
59
60 public static readonly PhysicsVector Zero = new PhysicsVector(0f, 0f, 0f);
61
62 public override string ToString()
63 {
64 return "<" + X + "," + Y + "," + Z + ">";
65 }
66
67 /// <summary>
68 /// These routines are the easiest way to store XYZ values in an Vector3 without requiring 3 calls.
69 /// </summary>
70 /// <returns></returns>
71 public byte[] GetBytes()
72 {
73 byte[] byteArray = new byte[12];
74
75 Buffer.BlockCopy(BitConverter.GetBytes(X), 0, byteArray, 0, 4);
76 Buffer.BlockCopy(BitConverter.GetBytes(Y), 0, byteArray, 4, 4);
77 Buffer.BlockCopy(BitConverter.GetBytes(Z), 0, byteArray, 8, 4);
78
79 if (!BitConverter.IsLittleEndian)
80 {
81 Array.Reverse(byteArray, 0, 4);
82 Array.Reverse(byteArray, 4, 4);
83 Array.Reverse(byteArray, 8, 4);
84 }
85
86 return byteArray;
87 }
88
89 public void FromBytes(byte[] byteArray, int pos)
90 {
91 byte[] conversionBuffer = null;
92 if (!BitConverter.IsLittleEndian)
93 {
94 // Big endian architecture
95 if (conversionBuffer == null)
96 conversionBuffer = new byte[12];
97
98 Buffer.BlockCopy(byteArray, pos, conversionBuffer, 0, 12);
99
100 Array.Reverse(conversionBuffer, 0, 4);
101 Array.Reverse(conversionBuffer, 4, 4);
102 Array.Reverse(conversionBuffer, 8, 4);
103
104 X = BitConverter.ToSingle(conversionBuffer, 0);
105 Y = BitConverter.ToSingle(conversionBuffer, 4);
106 Z = BitConverter.ToSingle(conversionBuffer, 8);
107 }
108 else
109 {
110 // Little endian architecture
111 X = BitConverter.ToSingle(byteArray, pos);
112 Y = BitConverter.ToSingle(byteArray, pos + 4);
113 Z = BitConverter.ToSingle(byteArray, pos + 8);
114 }
115 }
116
117 // Operations
118 public static PhysicsVector operator +(Vector3 a, Vector3 b)
119 {
120 return new PhysicsVector(a.X + b.X, a.Y + b.Y, a.Z + b.Z);
121 }
122
123 public static PhysicsVector operator -(Vector3 a, Vector3 b)
124 {
125 return new PhysicsVector(a.X - b.X, a.Y - b.Y, a.Z - b.Z);
126 }
127
128 public static PhysicsVector cross(Vector3 a, Vector3 b)
129 {
130 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);
131 }
132
133 public float length()
134 {
135 return (float) Math.Sqrt(X*X + Y*Y + Z*Z);
136 }
137
138 public static float GetDistanceTo(Vector3 a, Vector3 b)
139 {
140 float dx = a.X - b.X;
141 float dy = a.Y - b.Y;
142 float dz = a.Z - b.Z;
143 return (float) Math.Sqrt(dx * dx + dy * dy + dz * dz);
144 }
145
146 public static PhysicsVector operator /(Vector3 v, float f)
147 {
148 return new PhysicsVector(v.X/f, v.Y/f, v.Z/f);
149 }
150
151 public static PhysicsVector operator *(Vector3 v, float f)
152 {
153 return new PhysicsVector(v.X*f, v.Y*f, v.Z*f);
154 }
155
156 public static PhysicsVector operator *(float f, Vector3 v)
157 {
158 return v*f;
159 }
160
161 public static bool isFinite(Vector3 v)
162 {
163 if (v == null)
164 return false;
165 if (Single.IsInfinity(v.X) || Single.IsNaN(v.X))
166 return false;
167 if (Single.IsInfinity(v.Y) || Single.IsNaN(v.Y))
168 return false;
169 if (Single.IsInfinity(v.Z) || Single.IsNaN(v.Z))
170 return false;
171
172 return true;
173 }
174
175 public virtual bool IsIdentical(Vector3 v, float tolerance)
176 {
177 PhysicsVector diff = this - v;
178 float d = diff.length();
179 if (d <= tolerance)
180 return true;
181
182 return false;
183 }
184
185 }*/
186}
diff --git a/OpenSim/Region/Physics/Manager/VehicleConstants.cs b/OpenSim/Region/Physics/Manager/VehicleConstants.cs
deleted file mode 100644
index 8e24b4c..0000000
--- a/OpenSim/Region/Physics/Manager/VehicleConstants.cs
+++ /dev/null
@@ -1,164 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using OpenMetaverse;
30
31namespace OpenSim.Region.Physics.Manager
32{
33 public enum Vehicle : int
34 {
35 /// <summary>
36 /// Turns off Vehicle Support
37 /// </summary>
38 TYPE_NONE = 0,
39
40 /// <summary>
41 /// No Angular motor, High Left right friction, No Hover, Linear Deflection 1, no angular deflection
42 /// no vertical attractor, No banking, Identity rotation frame
43 /// </summary>
44 TYPE_SLED = 1,
45
46 /// <summary>
47 /// Needs Motors to be driven by timer or control events High left/right friction, No angular friction
48 /// Linear Motor wins in a second, decays in 60 seconds. Angular motor wins in a second, decays in 8/10ths of a second
49 /// linear deflection 2 seconds
50 /// Vertical Attractor locked UP
51 /// </summary>
52 TYPE_CAR = 2,
53 TYPE_BOAT = 3,
54 TYPE_AIRPLANE = 4,
55 TYPE_BALLOON = 5,
56 LINEAR_FRICTION_TIMESCALE = 16,
57 /// <summary>
58 /// vector of timescales for exponential decay of angular velocity about three axis
59 /// </summary>
60 ANGULAR_FRICTION_TIMESCALE = 17,
61 /// <summary>
62 /// linear velocity vehicle will try for
63 /// </summary>
64 LINEAR_MOTOR_DIRECTION = 18,
65
66 /// <summary>
67 /// Offset from center of mass where linear motor forces are added
68 /// </summary>
69 LINEAR_MOTOR_OFFSET = 20,
70 /// <summary>
71 /// angular velocity that vehicle will try for
72 /// </summary>
73 ANGULAR_MOTOR_DIRECTION = 19,
74 HOVER_HEIGHT = 24,
75 HOVER_EFFICIENCY = 25,
76 HOVER_TIMESCALE = 26,
77 BUOYANCY = 27,
78 LINEAR_DEFLECTION_EFFICIENCY = 28,
79 LINEAR_DEFLECTION_TIMESCALE = 29,
80 LINEAR_MOTOR_TIMESCALE = 30,
81 LINEAR_MOTOR_DECAY_TIMESCALE = 31,
82
83 /// <summary>
84 /// slide between 0 and 1
85 /// </summary>
86 ANGULAR_DEFLECTION_EFFICIENCY = 32,
87 ANGULAR_DEFLECTION_TIMESCALE = 33,
88 ANGULAR_MOTOR_TIMESCALE = 34,
89 ANGULAR_MOTOR_DECAY_TIMESCALE = 35,
90 VERTICAL_ATTRACTION_EFFICIENCY = 36,
91 VERTICAL_ATTRACTION_TIMESCALE = 37,
92 BANKING_EFFICIENCY = 38,
93 BANKING_MIX = 39,
94 BANKING_TIMESCALE = 40,
95 REFERENCE_FRAME = 44,
96 BLOCK_EXIT = 45,
97 ROLL_FRAME = 46
98
99 }
100
101 [Flags]
102 public enum VehicleFlag
103 {
104 NO_DEFLECTION_UP = 1,
105 LIMIT_ROLL_ONLY = 2,
106 HOVER_WATER_ONLY = 4,
107 HOVER_TERRAIN_ONLY = 8,
108 HOVER_GLOBAL_HEIGHT = 16,
109 HOVER_UP_ONLY = 32,
110 LIMIT_MOTOR_UP = 64,
111 MOUSELOOK_STEER = 128,
112 MOUSELOOK_BANK = 256,
113 CAMERA_DECOUPLED = 512,
114 NO_X = 1024,
115 NO_Y = 2048,
116 NO_Z = 4096,
117 LOCK_HOVER_HEIGHT = 8192,
118 NO_DEFLECTION = 16392,
119 LOCK_ROTATION = 32784
120 }
121
122 public struct VehicleData
123 {
124 public Vehicle m_type;
125 public VehicleFlag m_flags;
126
127 // Linear properties
128 public Vector3 m_linearMotorDirection;
129 public Vector3 m_linearFrictionTimescale;
130 public float m_linearMotorDecayTimescale;
131 public float m_linearMotorTimescale;
132 public Vector3 m_linearMotorOffset;
133
134 //Angular properties
135 public Vector3 m_angularMotorDirection;
136 public float m_angularMotorTimescale;
137 public float m_angularMotorDecayTimescale;
138 public Vector3 m_angularFrictionTimescale;
139
140 //Deflection properties
141 public float m_angularDeflectionEfficiency;
142 public float m_angularDeflectionTimescale;
143 public float m_linearDeflectionEfficiency;
144 public float m_linearDeflectionTimescale;
145
146 //Banking properties
147 public float m_bankingEfficiency;
148 public float m_bankingMix;
149 public float m_bankingTimescale;
150
151 //Hover and Buoyancy properties
152 public float m_VhoverHeight;
153 public float m_VhoverEfficiency;
154 public float m_VhoverTimescale;
155 public float m_VehicleBuoyancy;
156
157 //Attractor properties
158 public float m_verticalAttractionEfficiency;
159 public float m_verticalAttractionTimescale;
160
161 // Axis
162 public Quaternion m_referenceFrame;
163 }
164}
diff --git a/OpenSim/Region/Physics/Manager/ZeroMesher.cs b/OpenSim/Region/Physics/Manager/ZeroMesher.cs
deleted file mode 100644
index 890951f..0000000
--- a/OpenSim/Region/Physics/Manager/ZeroMesher.cs
+++ /dev/null
@@ -1,97 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using OpenSim.Framework;
30using OpenMetaverse;
31using Nini.Config;
32
33/*
34 * This is the zero mesher.
35 * Whatever you want him to mesh, he can't, telling you that by responding with a null pointer.
36 * Effectivly this is for switching off meshing and for testing as each physics machine should deal
37 * with the null pointer situation.
38 * But it's also a convenience thing, as physics machines can rely on having a mesher in any situation, even
39 * if it's a dump one like this.
40 * Note, that this mesher is *not* living in a module but in the manager itself, so
41 * it's always availabe and thus the default in case of configuration errors
42*/
43
44namespace OpenSim.Region.Physics.Manager
45{
46 public class ZeroMesherPlugin : IMeshingPlugin
47 {
48 public ZeroMesherPlugin()
49 {
50 }
51
52 public string GetName()
53 {
54 return "ZeroMesher";
55 }
56
57 public IMesher GetMesher(IConfigSource config)
58 {
59 return new ZeroMesher();
60 }
61 }
62
63 public class ZeroMesher : IMesher
64 {
65 public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod)
66 {
67 return CreateMesh(primName, primShape, size, lod, false);
68 }
69
70 public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool shouldCache, bool convex, bool forOde)
71 {
72 return CreateMesh(primName, primShape, size, lod, false);
73 }
74
75 public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool convex,bool forOde)
76 {
77 return CreateMesh(primName, primShape, size, lod, false);
78 }
79
80 public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical)
81 {
82 // Remove the reference to the encoded JPEG2000 data so it can be GCed
83 primShape.SculptData = OpenMetaverse.Utils.EmptyBytes;
84
85 return null;
86 }
87
88 public IMesh GetMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool convex)
89 {
90 return null;
91 }
92
93 public void ReleaseMesh(IMesh mesh) { }
94 public void ExpireReleaseMeshs() { }
95 public void ExpireFileCache() { }
96 }
97}