diff options
author | Diva Canto | 2015-08-30 20:06:53 -0700 |
---|---|---|
committer | Diva Canto | 2015-08-30 20:06:53 -0700 |
commit | 1d6b33bc2da3b312cff1d1802a73aacdf72b0385 (patch) | |
tree | 393736b501aac3b31eb0810bb72d926c7f14fbf8 /OpenSim/Region/PhysicsModules/SharedBase | |
parent | Moved instantiation of SceneCommunicationService object to inside the scene c... (diff) | |
download | opensim-SC_OLD-1d6b33bc2da3b312cff1d1802a73aacdf72b0385.zip opensim-SC_OLD-1d6b33bc2da3b312cff1d1802a73aacdf72b0385.tar.gz opensim-SC_OLD-1d6b33bc2da3b312cff1d1802a73aacdf72b0385.tar.bz2 opensim-SC_OLD-1d6b33bc2da3b312cff1d1802a73aacdf72b0385.tar.xz |
Major renaming of Physics dlls / folders. No functional changes, just renames.
Diffstat (limited to 'OpenSim/Region/PhysicsModules/SharedBase')
13 files changed, 2107 insertions, 0 deletions
diff --git a/OpenSim/Region/PhysicsModules/SharedBase/AssemblyInfo.cs b/OpenSim/Region/PhysicsModules/SharedBase/AssemblyInfo.cs new file mode 100644 index 0000000..33f60e4 --- /dev/null +++ b/OpenSim/Region/PhysicsModules/SharedBase/AssemblyInfo.cs | |||
@@ -0,0 +1,58 @@ | |||
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 | |||
28 | using System.Reflection; | ||
29 | using 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/PhysicsModules/SharedBase/CollisionLocker.cs b/OpenSim/Region/PhysicsModules/SharedBase/CollisionLocker.cs new file mode 100644 index 0000000..cace4e4 --- /dev/null +++ b/OpenSim/Region/PhysicsModules/SharedBase/CollisionLocker.cs | |||
@@ -0,0 +1,73 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | |||
31 | namespace 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/PhysicsModules/SharedBase/IMesher.cs b/OpenSim/Region/PhysicsModules/SharedBase/IMesher.cs new file mode 100644 index 0000000..2e7bb5d --- /dev/null +++ b/OpenSim/Region/PhysicsModules/SharedBase/IMesher.cs | |||
@@ -0,0 +1,71 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using OpenSim.Framework; | ||
31 | using OpenMetaverse; | ||
32 | |||
33 | namespace OpenSim.Region.Physics.Manager | ||
34 | { | ||
35 | public interface IMesher | ||
36 | { | ||
37 | IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod); | ||
38 | IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical); | ||
39 | IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool shouldCache); | ||
40 | } | ||
41 | |||
42 | // Values for level of detail to be passed to the mesher. | ||
43 | // Values origionally chosen for the LOD of sculpties (the sqrt(width*heigth) of sculpt texture) | ||
44 | // Lower level of detail reduces the number of vertices used to represent the meshed shape. | ||
45 | public enum LevelOfDetail | ||
46 | { | ||
47 | High = 32, | ||
48 | Medium = 16, | ||
49 | Low = 8, | ||
50 | VeryLow = 4 | ||
51 | } | ||
52 | |||
53 | public interface IVertex | ||
54 | { | ||
55 | } | ||
56 | |||
57 | public interface IMesh | ||
58 | { | ||
59 | List<Vector3> getVertexList(); | ||
60 | int[] getIndexListAsInt(); | ||
61 | int[] getIndexListAsIntLocked(); | ||
62 | float[] getVertexListAsFloat(); | ||
63 | float[] getVertexListAsFloatLocked(); | ||
64 | void getIndexListAsPtrToIntArray(out IntPtr indices, out int triStride, out int indexCount); | ||
65 | void getVertexListAsPtrToFloatArray(out IntPtr vertexList, out int vertexStride, out int vertexCount); | ||
66 | void releaseSourceMeshData(); | ||
67 | void releasePinned(); | ||
68 | void Append(IMesh newMesh); | ||
69 | void TransformLinear(float[,] matrix, float[] offset); | ||
70 | } | ||
71 | } | ||
diff --git a/OpenSim/Region/PhysicsModules/SharedBase/IPhysicsParameters.cs b/OpenSim/Region/PhysicsModules/SharedBase/IPhysicsParameters.cs new file mode 100755 index 0000000..31a397c --- /dev/null +++ b/OpenSim/Region/PhysicsModules/SharedBase/IPhysicsParameters.cs | |||
@@ -0,0 +1,73 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using OpenSim.Framework; | ||
31 | using OpenMetaverse; | ||
32 | |||
33 | namespace 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/PhysicsModules/SharedBase/NullPhysicsScene.cs b/OpenSim/Region/PhysicsModules/SharedBase/NullPhysicsScene.cs new file mode 100644 index 0000000..b52f1f6 --- /dev/null +++ b/OpenSim/Region/PhysicsModules/SharedBase/NullPhysicsScene.cs | |||
@@ -0,0 +1,122 @@ | |||
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 | |||
28 | using System.Collections.Generic; | ||
29 | using System.Reflection; | ||
30 | using log4net; | ||
31 | using Nini.Config; | ||
32 | using OpenSim.Framework; | ||
33 | using OpenMetaverse; | ||
34 | |||
35 | namespace 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/PhysicsModules/SharedBase/PhysicsActor.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs new file mode 100644 index 0000000..6bc6e23 --- /dev/null +++ b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs | |||
@@ -0,0 +1,584 @@ | |||
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 | |||
28 | using log4net; | ||
29 | using System; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Reflection; | ||
32 | using OpenSim.Framework; | ||
33 | using OpenMetaverse; | ||
34 | |||
35 | namespace 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 | } | ||
48 | |||
49 | public enum PIDHoverType | ||
50 | { | ||
51 | Ground, | ||
52 | GroundAndWater, | ||
53 | Water, | ||
54 | Absolute | ||
55 | } | ||
56 | |||
57 | public struct ContactPoint | ||
58 | { | ||
59 | public Vector3 Position; | ||
60 | public Vector3 SurfaceNormal; | ||
61 | public float PenetrationDepth; | ||
62 | |||
63 | public ContactPoint(Vector3 position, Vector3 surfaceNormal, float penetrationDepth) | ||
64 | { | ||
65 | Position = position; | ||
66 | SurfaceNormal = surfaceNormal; | ||
67 | PenetrationDepth = penetrationDepth; | ||
68 | } | ||
69 | } | ||
70 | |||
71 | /// <summary> | ||
72 | /// Used to pass collision information to OnCollisionUpdate listeners. | ||
73 | /// </summary> | ||
74 | public class CollisionEventUpdate : EventArgs | ||
75 | { | ||
76 | /// <summary> | ||
77 | /// Number of collision events in this update. | ||
78 | /// </summary> | ||
79 | public int Count { get { return m_objCollisionList.Count; } } | ||
80 | |||
81 | public bool CollisionsOnPreviousFrame { get; private set; } | ||
82 | |||
83 | public Dictionary<uint, ContactPoint> m_objCollisionList; | ||
84 | |||
85 | public CollisionEventUpdate(Dictionary<uint, ContactPoint> objCollisionList) | ||
86 | { | ||
87 | m_objCollisionList = objCollisionList; | ||
88 | } | ||
89 | |||
90 | public CollisionEventUpdate() | ||
91 | { | ||
92 | m_objCollisionList = new Dictionary<uint, ContactPoint>(); | ||
93 | } | ||
94 | |||
95 | public void AddCollider(uint localID, ContactPoint contact) | ||
96 | { | ||
97 | if (!m_objCollisionList.ContainsKey(localID)) | ||
98 | { | ||
99 | m_objCollisionList.Add(localID, contact); | ||
100 | } | ||
101 | else | ||
102 | { | ||
103 | if (m_objCollisionList[localID].PenetrationDepth < contact.PenetrationDepth) | ||
104 | m_objCollisionList[localID] = contact; | ||
105 | } | ||
106 | } | ||
107 | |||
108 | /// <summary> | ||
109 | /// Clear added collision events. | ||
110 | /// </summary> | ||
111 | public void Clear() | ||
112 | { | ||
113 | m_objCollisionList.Clear(); | ||
114 | } | ||
115 | } | ||
116 | |||
117 | public abstract class PhysicsActor | ||
118 | { | ||
119 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
120 | |||
121 | public delegate void RequestTerseUpdate(); | ||
122 | public delegate void CollisionUpdate(EventArgs e); | ||
123 | public delegate void OutOfBounds(Vector3 pos); | ||
124 | |||
125 | // disable warning: public events | ||
126 | #pragma warning disable 67 | ||
127 | public event PositionUpdate OnPositionUpdate; | ||
128 | public event VelocityUpdate OnVelocityUpdate; | ||
129 | public event OrientationUpdate OnOrientationUpdate; | ||
130 | public event RequestTerseUpdate OnRequestTerseUpdate; | ||
131 | |||
132 | /// <summary> | ||
133 | /// Subscribers to this event must synchronously handle the dictionary of collisions received, since the event | ||
134 | /// object is reused in subsequent physics frames. | ||
135 | /// </summary> | ||
136 | public event CollisionUpdate OnCollisionUpdate; | ||
137 | |||
138 | public event OutOfBounds OnOutOfBounds; | ||
139 | #pragma warning restore 67 | ||
140 | |||
141 | public static PhysicsActor Null | ||
142 | { | ||
143 | get { return new NullPhysicsActor(); } | ||
144 | } | ||
145 | |||
146 | public abstract bool Stopped { get; } | ||
147 | |||
148 | public abstract Vector3 Size { get; set; } | ||
149 | |||
150 | public virtual byte PhysicsShapeType { get; set; } | ||
151 | |||
152 | public abstract PrimitiveBaseShape Shape { set; } | ||
153 | |||
154 | uint m_baseLocalID; | ||
155 | public virtual uint LocalID | ||
156 | { | ||
157 | set { m_baseLocalID = value; } | ||
158 | get { return m_baseLocalID; } | ||
159 | } | ||
160 | |||
161 | public abstract bool Grabbed { set; } | ||
162 | |||
163 | public abstract bool Selected { set; } | ||
164 | |||
165 | /// <summary> | ||
166 | /// Name of this actor. | ||
167 | /// </summary> | ||
168 | /// <remarks> | ||
169 | /// XXX: Bizarrely, this cannot be "Terrain" or "Water" right now unless it really is simulating terrain or | ||
170 | /// water. This is not a problem due to the formatting of names given by prims and avatars. | ||
171 | /// </remarks> | ||
172 | public string Name { get; protected set; } | ||
173 | |||
174 | /// <summary> | ||
175 | /// This is being used by ODE joint code. | ||
176 | /// </summary> | ||
177 | public string SOPName; | ||
178 | |||
179 | public abstract void CrossingFailure(); | ||
180 | |||
181 | public abstract void link(PhysicsActor obj); | ||
182 | |||
183 | public abstract void delink(); | ||
184 | |||
185 | public abstract void LockAngularMotion(Vector3 axis); | ||
186 | |||
187 | public virtual void RequestPhysicsterseUpdate() | ||
188 | { | ||
189 | // Make a temporary copy of the event to avoid possibility of | ||
190 | // a race condition if the last subscriber unsubscribes | ||
191 | // immediately after the null check and before the event is raised. | ||
192 | RequestTerseUpdate handler = OnRequestTerseUpdate; | ||
193 | |||
194 | if (handler != null) | ||
195 | { | ||
196 | handler(); | ||
197 | } | ||
198 | } | ||
199 | |||
200 | public virtual void RaiseOutOfBounds(Vector3 pos) | ||
201 | { | ||
202 | // Make a temporary copy of the event to avoid possibility of | ||
203 | // a race condition if the last subscriber unsubscribes | ||
204 | // immediately after the null check and before the event is raised. | ||
205 | OutOfBounds handler = OnOutOfBounds; | ||
206 | |||
207 | if (handler != null) | ||
208 | { | ||
209 | handler(pos); | ||
210 | } | ||
211 | } | ||
212 | |||
213 | public virtual void SendCollisionUpdate(EventArgs e) | ||
214 | { | ||
215 | CollisionUpdate handler = OnCollisionUpdate; | ||
216 | |||
217 | // m_log.DebugFormat("[PHYSICS ACTOR]: Sending collision for {0}", LocalID); | ||
218 | |||
219 | if (handler != null) | ||
220 | handler(e); | ||
221 | } | ||
222 | |||
223 | public virtual void SetMaterial (int material) { } | ||
224 | public virtual float Density { get; set; } | ||
225 | public virtual float GravModifier { get; set; } | ||
226 | public virtual float Friction { get; set; } | ||
227 | public virtual float Restitution { get; set; } | ||
228 | |||
229 | /// <summary> | ||
230 | /// Position of this actor. | ||
231 | /// </summary> | ||
232 | /// <remarks> | ||
233 | /// Setting this directly moves the actor to a given position. | ||
234 | /// Getting this retrieves the position calculated by physics scene updates, using factors such as velocity and | ||
235 | /// collisions. | ||
236 | /// </remarks> | ||
237 | public abstract Vector3 Position { get; set; } | ||
238 | |||
239 | public abstract float Mass { get; } | ||
240 | public abstract Vector3 Force { get; set; } | ||
241 | |||
242 | public abstract int VehicleType { get; set; } | ||
243 | public abstract void VehicleFloatParam(int param, float value); | ||
244 | public abstract void VehicleVectorParam(int param, Vector3 value); | ||
245 | public abstract void VehicleRotationParam(int param, Quaternion rotation); | ||
246 | public abstract void VehicleFlags(int param, bool remove); | ||
247 | |||
248 | /// <summary> | ||
249 | /// Allows the detection of collisions with inherently non-physical prims. see llVolumeDetect for more | ||
250 | /// </summary> | ||
251 | public abstract void SetVolumeDetect(int param); | ||
252 | |||
253 | public abstract Vector3 GeometricCenter { get; } | ||
254 | public abstract Vector3 CenterOfMass { get; } | ||
255 | |||
256 | /// <summary> | ||
257 | /// The desired velocity of this actor. | ||
258 | /// </summary> | ||
259 | /// <remarks> | ||
260 | /// Setting this provides a target velocity for physics scene updates. | ||
261 | /// Getting this returns the last set target. Fetch Velocity to get the current velocity. | ||
262 | /// </remarks> | ||
263 | protected Vector3 m_targetVelocity; | ||
264 | public virtual Vector3 TargetVelocity | ||
265 | { | ||
266 | get { return m_targetVelocity; } | ||
267 | set { | ||
268 | m_targetVelocity = value; | ||
269 | Velocity = m_targetVelocity; | ||
270 | } | ||
271 | } | ||
272 | |||
273 | public abstract Vector3 Velocity { get; set; } | ||
274 | |||
275 | public abstract Vector3 Torque { get; set; } | ||
276 | public abstract float CollisionScore { get; set;} | ||
277 | public abstract Vector3 Acceleration { get; set; } | ||
278 | public abstract Quaternion Orientation { get; set; } | ||
279 | public abstract int PhysicsActorType { get; set; } | ||
280 | public abstract bool IsPhysical { get; set; } | ||
281 | public abstract bool Flying { get; set; } | ||
282 | public abstract bool SetAlwaysRun { get; set; } | ||
283 | public abstract bool ThrottleUpdates { get; set; } | ||
284 | public abstract bool IsColliding { get; set; } | ||
285 | public abstract bool CollidingGround { get; set; } | ||
286 | public abstract bool CollidingObj { get; set; } | ||
287 | public abstract bool FloatOnWater { set; } | ||
288 | public abstract Vector3 RotationalVelocity { get; set; } | ||
289 | public abstract bool Kinematic { get; set; } | ||
290 | public abstract float Buoyancy { get; set; } | ||
291 | |||
292 | // Used for MoveTo | ||
293 | public abstract Vector3 PIDTarget { set; } | ||
294 | public abstract bool PIDActive { get; set; } | ||
295 | public abstract float PIDTau { set; } | ||
296 | |||
297 | // Used for llSetHoverHeight and maybe vehicle height | ||
298 | // Hover Height will override MoveTo target's Z | ||
299 | public abstract bool PIDHoverActive { set;} | ||
300 | public abstract float PIDHoverHeight { set;} | ||
301 | public abstract PIDHoverType PIDHoverType { set;} | ||
302 | public abstract float PIDHoverTau { set;} | ||
303 | |||
304 | // For RotLookAt | ||
305 | public abstract Quaternion APIDTarget { set;} | ||
306 | public abstract bool APIDActive { set;} | ||
307 | public abstract float APIDStrength { set;} | ||
308 | public abstract float APIDDamping { set;} | ||
309 | |||
310 | public abstract void AddForce(Vector3 force, bool pushforce); | ||
311 | public abstract void AddAngularForce(Vector3 force, bool pushforce); | ||
312 | public abstract void SetMomentum(Vector3 momentum); | ||
313 | public abstract void SubscribeEvents(int ms); | ||
314 | public abstract void UnSubscribeEvents(); | ||
315 | public abstract bool SubscribedEvents(); | ||
316 | |||
317 | // Extendable interface for new, physics engine specific operations | ||
318 | public virtual object Extension(string pFunct, params object[] pParams) | ||
319 | { | ||
320 | // A NOP of the physics engine does not implement this feature | ||
321 | return null; | ||
322 | } | ||
323 | } | ||
324 | |||
325 | public class NullPhysicsActor : PhysicsActor | ||
326 | { | ||
327 | public override bool Stopped | ||
328 | { | ||
329 | get{ return false; } | ||
330 | } | ||
331 | |||
332 | public override Vector3 Position | ||
333 | { | ||
334 | get { return Vector3.Zero; } | ||
335 | set { return; } | ||
336 | } | ||
337 | |||
338 | public override bool SetAlwaysRun | ||
339 | { | ||
340 | get { return false; } | ||
341 | set { return; } | ||
342 | } | ||
343 | |||
344 | public override uint LocalID | ||
345 | { | ||
346 | set { return; } | ||
347 | } | ||
348 | |||
349 | public override bool Grabbed | ||
350 | { | ||
351 | set { return; } | ||
352 | } | ||
353 | |||
354 | public override bool Selected | ||
355 | { | ||
356 | set { return; } | ||
357 | } | ||
358 | |||
359 | public override float Buoyancy | ||
360 | { | ||
361 | get { return 0f; } | ||
362 | set { return; } | ||
363 | } | ||
364 | |||
365 | public override bool FloatOnWater | ||
366 | { | ||
367 | set { return; } | ||
368 | } | ||
369 | |||
370 | public override bool CollidingGround | ||
371 | { | ||
372 | get { return false; } | ||
373 | set { return; } | ||
374 | } | ||
375 | |||
376 | public override bool CollidingObj | ||
377 | { | ||
378 | get { return false; } | ||
379 | set { return; } | ||
380 | } | ||
381 | |||
382 | public override Vector3 Size | ||
383 | { | ||
384 | get { return Vector3.Zero; } | ||
385 | set { return; } | ||
386 | } | ||
387 | |||
388 | public override float Mass | ||
389 | { | ||
390 | get { return 0f; } | ||
391 | } | ||
392 | |||
393 | public override Vector3 Force | ||
394 | { | ||
395 | get { return Vector3.Zero; } | ||
396 | set { return; } | ||
397 | } | ||
398 | |||
399 | public override int VehicleType | ||
400 | { | ||
401 | get { return 0; } | ||
402 | set { return; } | ||
403 | } | ||
404 | |||
405 | public override void VehicleFloatParam(int param, float value) | ||
406 | { | ||
407 | |||
408 | } | ||
409 | |||
410 | public override void VehicleVectorParam(int param, Vector3 value) | ||
411 | { | ||
412 | |||
413 | } | ||
414 | |||
415 | public override void VehicleRotationParam(int param, Quaternion rotation) | ||
416 | { | ||
417 | |||
418 | } | ||
419 | |||
420 | public override void VehicleFlags(int param, bool remove) | ||
421 | { | ||
422 | |||
423 | } | ||
424 | |||
425 | public override void SetVolumeDetect(int param) | ||
426 | { | ||
427 | |||
428 | } | ||
429 | |||
430 | public override void SetMaterial(int material) | ||
431 | { | ||
432 | |||
433 | } | ||
434 | |||
435 | public override Vector3 CenterOfMass | ||
436 | { | ||
437 | get { return Vector3.Zero; } | ||
438 | } | ||
439 | |||
440 | public override Vector3 GeometricCenter | ||
441 | { | ||
442 | get { return Vector3.Zero; } | ||
443 | } | ||
444 | |||
445 | public override PrimitiveBaseShape Shape | ||
446 | { | ||
447 | set { return; } | ||
448 | } | ||
449 | |||
450 | public override Vector3 Velocity | ||
451 | { | ||
452 | get { return Vector3.Zero; } | ||
453 | set { return; } | ||
454 | } | ||
455 | |||
456 | public override Vector3 Torque | ||
457 | { | ||
458 | get { return Vector3.Zero; } | ||
459 | set { return; } | ||
460 | } | ||
461 | |||
462 | public override float CollisionScore | ||
463 | { | ||
464 | get { return 0f; } | ||
465 | set { } | ||
466 | } | ||
467 | |||
468 | public override void CrossingFailure() | ||
469 | { | ||
470 | } | ||
471 | |||
472 | public override Quaternion Orientation | ||
473 | { | ||
474 | get { return Quaternion.Identity; } | ||
475 | set { } | ||
476 | } | ||
477 | |||
478 | public override Vector3 Acceleration | ||
479 | { | ||
480 | get { return Vector3.Zero; } | ||
481 | set { } | ||
482 | } | ||
483 | |||
484 | public override bool IsPhysical | ||
485 | { | ||
486 | get { return false; } | ||
487 | set { return; } | ||
488 | } | ||
489 | |||
490 | public override bool Flying | ||
491 | { | ||
492 | get { return false; } | ||
493 | set { return; } | ||
494 | } | ||
495 | |||
496 | public override bool ThrottleUpdates | ||
497 | { | ||
498 | get { return false; } | ||
499 | set { return; } | ||
500 | } | ||
501 | |||
502 | public override bool IsColliding | ||
503 | { | ||
504 | get { return false; } | ||
505 | set { return; } | ||
506 | } | ||
507 | |||
508 | public override int PhysicsActorType | ||
509 | { | ||
510 | get { return (int) ActorTypes.Unknown; } | ||
511 | set { return; } | ||
512 | } | ||
513 | |||
514 | public override bool Kinematic | ||
515 | { | ||
516 | get { return true; } | ||
517 | set { return; } | ||
518 | } | ||
519 | |||
520 | public override void link(PhysicsActor obj) | ||
521 | { | ||
522 | } | ||
523 | |||
524 | public override void delink() | ||
525 | { | ||
526 | } | ||
527 | |||
528 | public override void LockAngularMotion(Vector3 axis) | ||
529 | { | ||
530 | } | ||
531 | |||
532 | public override void AddForce(Vector3 force, bool pushforce) | ||
533 | { | ||
534 | } | ||
535 | |||
536 | public override void AddAngularForce(Vector3 force, bool pushforce) | ||
537 | { | ||
538 | |||
539 | } | ||
540 | |||
541 | public override Vector3 RotationalVelocity | ||
542 | { | ||
543 | get { return Vector3.Zero; } | ||
544 | set { return; } | ||
545 | } | ||
546 | |||
547 | public override Vector3 PIDTarget { set { return; } } | ||
548 | |||
549 | public override bool PIDActive | ||
550 | { | ||
551 | get { return false; } | ||
552 | set { return; } | ||
553 | } | ||
554 | |||
555 | public override float PIDTau { set { return; } } | ||
556 | |||
557 | public override float PIDHoverHeight { set { return; } } | ||
558 | public override bool PIDHoverActive { set { return; } } | ||
559 | public override PIDHoverType PIDHoverType { set { return; } } | ||
560 | public override float PIDHoverTau { set { return; } } | ||
561 | |||
562 | public override Quaternion APIDTarget { set { return; } } | ||
563 | public override bool APIDActive { set { return; } } | ||
564 | public override float APIDStrength { set { return; } } | ||
565 | public override float APIDDamping { set { return; } } | ||
566 | |||
567 | public override void SetMomentum(Vector3 momentum) | ||
568 | { | ||
569 | } | ||
570 | |||
571 | public override void SubscribeEvents(int ms) | ||
572 | { | ||
573 | |||
574 | } | ||
575 | public override void UnSubscribeEvents() | ||
576 | { | ||
577 | |||
578 | } | ||
579 | public override bool SubscribedEvents() | ||
580 | { | ||
581 | return false; | ||
582 | } | ||
583 | } | ||
584 | } | ||
diff --git a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsJoint.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsJoint.cs new file mode 100644 index 0000000..b685d04 --- /dev/null +++ b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsJoint.cs | |||
@@ -0,0 +1,55 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using OpenSim.Framework; | ||
31 | using OpenMetaverse; | ||
32 | |||
33 | namespace 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/PhysicsModules/SharedBase/PhysicsPluginManager.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsPluginManager.cs new file mode 100644 index 0000000..d8279b7 --- /dev/null +++ b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsPluginManager.cs | |||
@@ -0,0 +1,242 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.IO; | ||
31 | using System.Reflection; | ||
32 | using Nini.Config; | ||
33 | using log4net; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenMetaverse; | ||
36 | |||
37 | namespace 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 | /// <summary> | ||
64 | /// Get a physics scene for the given physics engine and mesher. | ||
65 | /// </summary> | ||
66 | /// <param name="physEngineName"></param> | ||
67 | /// <param name="meshEngineName"></param> | ||
68 | /// <param name="config"></param> | ||
69 | /// <returns></returns> | ||
70 | public PhysicsScene GetPhysicsScene(string physEngineName, string meshEngineName, | ||
71 | IConfigSource config, string regionName, Vector3 regionExtent) | ||
72 | { | ||
73 | if (String.IsNullOrEmpty(physEngineName)) | ||
74 | { | ||
75 | return PhysicsScene.Null; | ||
76 | } | ||
77 | |||
78 | if (String.IsNullOrEmpty(meshEngineName)) | ||
79 | { | ||
80 | return PhysicsScene.Null; | ||
81 | } | ||
82 | |||
83 | IMesher meshEngine = null; | ||
84 | if (_MeshPlugins.ContainsKey(meshEngineName)) | ||
85 | { | ||
86 | m_log.Info("[PHYSICS]: creating meshing engine " + meshEngineName); | ||
87 | meshEngine = _MeshPlugins[meshEngineName].GetMesher(config); | ||
88 | } | ||
89 | else | ||
90 | { | ||
91 | m_log.WarnFormat("[PHYSICS]: couldn't find meshingEngine: {0}", meshEngineName); | ||
92 | throw new ArgumentException(String.Format("couldn't find meshingEngine: {0}", meshEngineName)); | ||
93 | } | ||
94 | |||
95 | if (_PhysPlugins.ContainsKey(physEngineName)) | ||
96 | { | ||
97 | m_log.Info("[PHYSICS]: creating " + physEngineName); | ||
98 | PhysicsScene result = _PhysPlugins[physEngineName].GetScene(regionName); | ||
99 | result.Initialise(meshEngine, config, regionExtent); | ||
100 | return result; | ||
101 | } | ||
102 | else | ||
103 | { | ||
104 | m_log.WarnFormat("[PHYSICS]: couldn't find physicsEngine: {0}", physEngineName); | ||
105 | throw new ArgumentException(String.Format("couldn't find physicsEngine: {0}", physEngineName)); | ||
106 | } | ||
107 | } | ||
108 | |||
109 | /// <summary> | ||
110 | /// Load all plugins in assemblies at the given path | ||
111 | /// </summary> | ||
112 | /// <param name="pluginsPath"></param> | ||
113 | public void LoadPluginsFromAssemblies(string assembliesPath) | ||
114 | { | ||
115 | // Walk all assemblies (DLLs effectively) and see if they are home | ||
116 | // of a plugin that is of interest for us | ||
117 | string[] pluginFiles = Directory.GetFiles(assembliesPath, "*.dll"); | ||
118 | |||
119 | for (int i = 0; i < pluginFiles.Length; i++) | ||
120 | { | ||
121 | LoadPluginsFromAssembly(pluginFiles[i]); | ||
122 | } | ||
123 | } | ||
124 | |||
125 | /// <summary> | ||
126 | /// Load plugins from an assembly at the given path | ||
127 | /// </summary> | ||
128 | /// <param name="assemblyPath"></param> | ||
129 | public void LoadPluginsFromAssembly(string assemblyPath) | ||
130 | { | ||
131 | // TODO / NOTE | ||
132 | // The assembly named 'OpenSim.Region.Physics.BasicPhysicsPlugin' was loaded from | ||
133 | // 'file:///C:/OpenSim/trunk2/bin/Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll' | ||
134 | // using the LoadFrom context. The use of this context can result in unexpected behavior | ||
135 | // for serialization, casting and dependency resolution. In almost all cases, it is recommended | ||
136 | // that the LoadFrom context be avoided. This can be done by installing assemblies in the | ||
137 | // Global Assembly Cache or in the ApplicationBase directory and using Assembly. | ||
138 | // Load when explicitly loading assemblies. | ||
139 | Assembly pluginAssembly = null; | ||
140 | Type[] types = null; | ||
141 | |||
142 | try | ||
143 | { | ||
144 | pluginAssembly = Assembly.LoadFrom(assemblyPath); | ||
145 | } | ||
146 | catch (Exception ex) | ||
147 | { | ||
148 | m_log.Error("[PHYSICS]: Failed to load plugin from " + assemblyPath, ex); | ||
149 | } | ||
150 | |||
151 | if (pluginAssembly != null) | ||
152 | { | ||
153 | try | ||
154 | { | ||
155 | types = pluginAssembly.GetTypes(); | ||
156 | } | ||
157 | catch (ReflectionTypeLoadException ex) | ||
158 | { | ||
159 | m_log.Error("[PHYSICS]: Failed to enumerate types in plugin from " + assemblyPath + ": " + | ||
160 | ex.LoaderExceptions[0].Message, ex); | ||
161 | } | ||
162 | catch (Exception ex) | ||
163 | { | ||
164 | m_log.Error("[PHYSICS]: Failed to enumerate types in plugin from " + assemblyPath, ex); | ||
165 | } | ||
166 | |||
167 | if (types != null) | ||
168 | { | ||
169 | foreach (Type pluginType in types) | ||
170 | { | ||
171 | if (pluginType.IsPublic) | ||
172 | { | ||
173 | if (!pluginType.IsAbstract) | ||
174 | { | ||
175 | Type physTypeInterface = pluginType.GetInterface("IPhysicsPlugin"); | ||
176 | |||
177 | if (physTypeInterface != null) | ||
178 | { | ||
179 | IPhysicsPlugin plug = | ||
180 | (IPhysicsPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); | ||
181 | plug.Init(); | ||
182 | if (!_PhysPlugins.ContainsKey(plug.GetName())) | ||
183 | { | ||
184 | _PhysPlugins.Add(plug.GetName(), plug); | ||
185 | m_log.Info("[PHYSICS]: Added physics engine: " + plug.GetName()); | ||
186 | } | ||
187 | } | ||
188 | |||
189 | Type meshTypeInterface = pluginType.GetInterface("IMeshingPlugin"); | ||
190 | |||
191 | if (meshTypeInterface != null) | ||
192 | { | ||
193 | IMeshingPlugin plug = | ||
194 | (IMeshingPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); | ||
195 | if (!_MeshPlugins.ContainsKey(plug.GetName())) | ||
196 | { | ||
197 | _MeshPlugins.Add(plug.GetName(), plug); | ||
198 | m_log.Info("[PHYSICS]: Added meshing engine: " + plug.GetName()); | ||
199 | } | ||
200 | } | ||
201 | |||
202 | physTypeInterface = null; | ||
203 | meshTypeInterface = null; | ||
204 | } | ||
205 | } | ||
206 | } | ||
207 | } | ||
208 | } | ||
209 | |||
210 | pluginAssembly = null; | ||
211 | } | ||
212 | |||
213 | //--- | ||
214 | public static void PhysicsPluginMessage(string message, bool isWarning) | ||
215 | { | ||
216 | if (isWarning) | ||
217 | { | ||
218 | m_log.Warn("[PHYSICS]: " + message); | ||
219 | } | ||
220 | else | ||
221 | { | ||
222 | m_log.Info("[PHYSICS]: " + message); | ||
223 | } | ||
224 | } | ||
225 | |||
226 | //--- | ||
227 | } | ||
228 | |||
229 | public interface IPhysicsPlugin | ||
230 | { | ||
231 | bool Init(); | ||
232 | PhysicsScene GetScene(String sceneIdentifier); | ||
233 | string GetName(); | ||
234 | void Dispose(); | ||
235 | } | ||
236 | |||
237 | public interface IMeshingPlugin | ||
238 | { | ||
239 | string GetName(); | ||
240 | IMesher GetMesher(IConfigSource config); | ||
241 | } | ||
242 | } | ||
diff --git a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsScene.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsScene.cs new file mode 100644 index 0000000..9cdedbf --- /dev/null +++ b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsScene.cs | |||
@@ -0,0 +1,361 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | |||
32 | using log4net; | ||
33 | using Nini.Config; | ||
34 | |||
35 | using OpenSim.Framework; | ||
36 | using OpenMetaverse; | ||
37 | |||
38 | namespace 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 | |||
45 | public delegate void JointMoved(PhysicsJoint joint); | ||
46 | public delegate void JointDeactivated(PhysicsJoint joint); | ||
47 | public delegate void JointErrorMessage(PhysicsJoint joint, string message); // this refers to an "error message due to a problem", not "amount of joint constraint violation" | ||
48 | |||
49 | public enum RayFilterFlags : ushort | ||
50 | { | ||
51 | // the flags | ||
52 | water = 0x01, | ||
53 | land = 0x02, | ||
54 | agent = 0x04, | ||
55 | nonphysical = 0x08, | ||
56 | physical = 0x10, | ||
57 | phantom = 0x20, | ||
58 | volumedtc = 0x40, | ||
59 | |||
60 | // ray cast colision control (may only work for meshs) | ||
61 | ContactsUnImportant = 0x2000, | ||
62 | BackFaceCull = 0x4000, | ||
63 | ClosestHit = 0x8000, | ||
64 | |||
65 | // some combinations | ||
66 | LSLPhantom = phantom | volumedtc, | ||
67 | PrimsNonPhantom = nonphysical | physical, | ||
68 | PrimsNonPhantomAgents = nonphysical | physical | agent, | ||
69 | |||
70 | AllPrims = nonphysical | phantom | volumedtc | physical, | ||
71 | AllButLand = agent | nonphysical | physical | phantom | volumedtc, | ||
72 | |||
73 | ClosestAndBackCull = ClosestHit | BackFaceCull, | ||
74 | |||
75 | All = 0x3f | ||
76 | } | ||
77 | |||
78 | public delegate void RequestAssetDelegate(UUID assetID, AssetReceivedDelegate callback); | ||
79 | public delegate void AssetReceivedDelegate(AssetBase asset); | ||
80 | |||
81 | /// <summary> | ||
82 | /// Contact result from a raycast. | ||
83 | /// </summary> | ||
84 | public struct ContactResult | ||
85 | { | ||
86 | public Vector3 Pos; | ||
87 | public float Depth; | ||
88 | public uint ConsumerID; | ||
89 | public Vector3 Normal; | ||
90 | } | ||
91 | |||
92 | public abstract class PhysicsScene | ||
93 | { | ||
94 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
95 | |||
96 | /// <summary> | ||
97 | /// A unique identifying string for this instance of the physics engine. | ||
98 | /// Useful in debug messages to distinguish one OdeScene instance from another. | ||
99 | /// Usually set to include the region name that the physics engine is acting for. | ||
100 | /// </summary> | ||
101 | public string Name { get; protected set; } | ||
102 | |||
103 | /// <summary> | ||
104 | /// A string identifying the family of this physics engine. Most common values returned | ||
105 | /// are "OpenDynamicsEngine" and "BulletSim" but others are possible. | ||
106 | /// </summary> | ||
107 | public string EngineType { get; protected set; } | ||
108 | |||
109 | // The only thing that should register for this event is the SceneGraph | ||
110 | // Anything else could cause problems. | ||
111 | public event physicsCrash OnPhysicsCrash; | ||
112 | |||
113 | public static PhysicsScene Null | ||
114 | { | ||
115 | get { return new NullPhysicsScene(); } | ||
116 | } | ||
117 | |||
118 | public RequestAssetDelegate RequestAssetMethod { get; set; } | ||
119 | |||
120 | public virtual void TriggerPhysicsBasedRestart() | ||
121 | { | ||
122 | physicsCrash handler = OnPhysicsCrash; | ||
123 | if (handler != null) | ||
124 | { | ||
125 | OnPhysicsCrash(); | ||
126 | } | ||
127 | } | ||
128 | |||
129 | // Deprecated. Do not use this for new physics engines. | ||
130 | public abstract void Initialise(IMesher meshmerizer, IConfigSource config); | ||
131 | |||
132 | // For older physics engines that do not implement non-legacy region sizes. | ||
133 | // If the physics engine handles the region extent feature, it overrides this function. | ||
134 | public virtual void Initialise(IMesher meshmerizer, IConfigSource config, Vector3 regionExtent) | ||
135 | { | ||
136 | // If not overridden, call the old initialization entry. | ||
137 | Initialise(meshmerizer, config); | ||
138 | } | ||
139 | |||
140 | /// <summary> | ||
141 | /// Add an avatar | ||
142 | /// </summary> | ||
143 | /// <param name="avName"></param> | ||
144 | /// <param name="position"></param> | ||
145 | /// <param name="velocity"></param> | ||
146 | /// <param name="size"></param> | ||
147 | /// <param name="isFlying"></param> | ||
148 | /// <returns></returns> | ||
149 | public abstract PhysicsActor AddAvatar( | ||
150 | string avName, Vector3 position, Vector3 velocity, Vector3 size, bool isFlying); | ||
151 | |||
152 | /// <summary> | ||
153 | /// Add an avatar | ||
154 | /// </summary> | ||
155 | /// <param name="localID"></param> | ||
156 | /// <param name="avName"></param> | ||
157 | /// <param name="position"></param> | ||
158 | /// <param name="velocity"></param> | ||
159 | /// <param name="size"></param> | ||
160 | /// <param name="isFlying"></param> | ||
161 | /// <returns></returns> | ||
162 | public virtual PhysicsActor AddAvatar( | ||
163 | uint localID, string avName, Vector3 position, Vector3 velocity, Vector3 size, bool isFlying) | ||
164 | { | ||
165 | PhysicsActor ret = AddAvatar(avName, position, velocity, size, isFlying); | ||
166 | |||
167 | if (ret != null) | ||
168 | ret.LocalID = localID; | ||
169 | |||
170 | return ret; | ||
171 | } | ||
172 | |||
173 | /// <summary> | ||
174 | /// Remove an avatar. | ||
175 | /// </summary> | ||
176 | /// <param name="actor"></param> | ||
177 | public abstract void RemoveAvatar(PhysicsActor actor); | ||
178 | |||
179 | /// <summary> | ||
180 | /// Remove a prim. | ||
181 | /// </summary> | ||
182 | /// <param name="prim"></param> | ||
183 | public abstract void RemovePrim(PhysicsActor prim); | ||
184 | |||
185 | public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, | ||
186 | Vector3 size, Quaternion rotation, bool isPhysical, uint localid); | ||
187 | |||
188 | public virtual PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, | ||
189 | Vector3 size, Quaternion rotation, bool isPhysical, bool isPhantom, byte shapetype, uint localid) | ||
190 | { | ||
191 | return AddPrimShape(primName, pbs, position, size, rotation, isPhysical, localid); | ||
192 | } | ||
193 | |||
194 | public virtual float TimeDilation | ||
195 | { | ||
196 | get { return 1.0f; } | ||
197 | } | ||
198 | |||
199 | public virtual bool SupportsNINJAJoints | ||
200 | { | ||
201 | get { return false; } | ||
202 | } | ||
203 | |||
204 | public virtual PhysicsJoint RequestJointCreation(string objectNameInScene, PhysicsJointType jointType, Vector3 position, | ||
205 | Quaternion rotation, string parms, List<string> bodyNames, string trackedBodyName, Quaternion localRotation) | ||
206 | { return null; } | ||
207 | |||
208 | public virtual void RequestJointDeletion(string objectNameInScene) | ||
209 | { return; } | ||
210 | |||
211 | public virtual void RemoveAllJointsConnectedToActorThreadLocked(PhysicsActor actor) | ||
212 | { return; } | ||
213 | |||
214 | public virtual void DumpJointInfo() | ||
215 | { return; } | ||
216 | |||
217 | public event JointMoved OnJointMoved; | ||
218 | |||
219 | protected virtual void DoJointMoved(PhysicsJoint joint) | ||
220 | { | ||
221 | // We need this to allow subclasses (but not other classes) to invoke the event; C# does | ||
222 | // not allow subclasses to invoke the parent class event. | ||
223 | if (OnJointMoved != null) | ||
224 | { | ||
225 | OnJointMoved(joint); | ||
226 | } | ||
227 | } | ||
228 | |||
229 | public event JointDeactivated OnJointDeactivated; | ||
230 | |||
231 | protected virtual void DoJointDeactivated(PhysicsJoint joint) | ||
232 | { | ||
233 | // We need this to allow subclasses (but not other classes) to invoke the event; C# does | ||
234 | // not allow subclasses to invoke the parent class event. | ||
235 | if (OnJointDeactivated != null) | ||
236 | { | ||
237 | OnJointDeactivated(joint); | ||
238 | } | ||
239 | } | ||
240 | |||
241 | public event JointErrorMessage OnJointErrorMessage; | ||
242 | |||
243 | protected virtual void DoJointErrorMessage(PhysicsJoint joint, string message) | ||
244 | { | ||
245 | // We need this to allow subclasses (but not other classes) to invoke the event; C# does | ||
246 | // not allow subclasses to invoke the parent class event. | ||
247 | if (OnJointErrorMessage != null) | ||
248 | { | ||
249 | OnJointErrorMessage(joint, message); | ||
250 | } | ||
251 | } | ||
252 | |||
253 | public virtual Vector3 GetJointAnchor(PhysicsJoint joint) | ||
254 | { return Vector3.Zero; } | ||
255 | |||
256 | public virtual Vector3 GetJointAxis(PhysicsJoint joint) | ||
257 | { return Vector3.Zero; } | ||
258 | |||
259 | public abstract void AddPhysicsActorTaint(PhysicsActor prim); | ||
260 | |||
261 | /// <summary> | ||
262 | /// Perform a simulation of the current physics scene over the given timestep. | ||
263 | /// </summary> | ||
264 | /// <param name="timeStep"></param> | ||
265 | /// <returns>The number of frames simulated over that period.</returns> | ||
266 | public abstract float Simulate(float timeStep); | ||
267 | |||
268 | /// <summary> | ||
269 | /// Get statistics about this scene. | ||
270 | /// </summary> | ||
271 | /// <remarks>This facility is currently experimental and subject to change.</remarks> | ||
272 | /// <returns> | ||
273 | /// A dictionary where the key is the statistic name. If no statistics are supplied then returns null. | ||
274 | /// </returns> | ||
275 | public virtual Dictionary<string, float> GetStats() { return null; } | ||
276 | |||
277 | public abstract void GetResults(); | ||
278 | |||
279 | public abstract void SetTerrain(float[] heightMap); | ||
280 | |||
281 | public abstract void SetWaterLevel(float baseheight); | ||
282 | |||
283 | public abstract void DeleteTerrain(); | ||
284 | |||
285 | public abstract void Dispose(); | ||
286 | |||
287 | public abstract Dictionary<uint, float> GetTopColliders(); | ||
288 | |||
289 | public abstract bool IsThreaded { get; } | ||
290 | |||
291 | /// <summary> | ||
292 | /// True if the physics plugin supports raycasting against the physics scene | ||
293 | /// </summary> | ||
294 | public virtual bool SupportsRayCast() | ||
295 | { | ||
296 | return false; | ||
297 | } | ||
298 | |||
299 | public virtual bool SupportsCombining() | ||
300 | { | ||
301 | return false; | ||
302 | } | ||
303 | |||
304 | public virtual void Combine(PhysicsScene pScene, Vector3 offset, Vector3 extents) {} | ||
305 | |||
306 | public virtual void UnCombine(PhysicsScene pScene) {} | ||
307 | |||
308 | /// <summary> | ||
309 | /// Queue a raycast against the physics scene. | ||
310 | /// The provided callback method will be called when the raycast is complete | ||
311 | /// | ||
312 | /// Many physics engines don't support collision testing at the same time as | ||
313 | /// manipulating the physics scene, so we queue the request up and callback | ||
314 | /// a custom method when the raycast is complete. | ||
315 | /// This allows physics engines that give an immediate result to callback immediately | ||
316 | /// and ones that don't, to callback when it gets a result back. | ||
317 | /// | ||
318 | /// ODE for example will not allow you to change the scene while collision testing or | ||
319 | /// it asserts, 'opteration not valid for locked space'. This includes adding a ray to the scene. | ||
320 | /// | ||
321 | /// This is named RayCastWorld to not conflict with modrex's Raycast method. | ||
322 | /// </summary> | ||
323 | /// <param name="position">Origin of the ray</param> | ||
324 | /// <param name="direction">Direction of the ray</param> | ||
325 | /// <param name="length">Length of ray in meters</param> | ||
326 | /// <param name="retMethod">Method to call when the raycast is complete</param> | ||
327 | public virtual void RaycastWorld(Vector3 position, Vector3 direction, float length, RaycastCallback retMethod) | ||
328 | { | ||
329 | if (retMethod != null) | ||
330 | retMethod(false, Vector3.Zero, 0, 999999999999f, Vector3.Zero); | ||
331 | } | ||
332 | |||
333 | public virtual void RaycastWorld(Vector3 position, Vector3 direction, float length, int Count, RayCallback retMethod) | ||
334 | { | ||
335 | if (retMethod != null) | ||
336 | retMethod(new List<ContactResult>()); | ||
337 | } | ||
338 | |||
339 | public virtual List<ContactResult> RaycastWorld(Vector3 position, Vector3 direction, float length, int Count) | ||
340 | { | ||
341 | return new List<ContactResult>(); | ||
342 | } | ||
343 | |||
344 | public virtual object RaycastWorld(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter) | ||
345 | { | ||
346 | return null; | ||
347 | } | ||
348 | |||
349 | public virtual bool SupportsRaycastWorldFiltered() | ||
350 | { | ||
351 | return false; | ||
352 | } | ||
353 | |||
354 | // Extendable interface for new, physics engine specific operations | ||
355 | public virtual object Extension(string pFunct, params object[] pParams) | ||
356 | { | ||
357 | // A NOP if the extension thing is not implemented by the physics engine | ||
358 | return null; | ||
359 | } | ||
360 | } | ||
361 | } | ||
diff --git a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsSensor.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsSensor.cs new file mode 100644 index 0000000..f480d71 --- /dev/null +++ b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsSensor.cs | |||
@@ -0,0 +1,78 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Timers; | ||
30 | using OpenMetaverse; | ||
31 | |||
32 | namespace 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/PhysicsModules/SharedBase/PhysicsVector.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsVector.cs new file mode 100644 index 0000000..f60a636 --- /dev/null +++ b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsVector.cs | |||
@@ -0,0 +1,186 @@ | |||
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 | |||
28 | using System; | ||
29 | |||
30 | namespace 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/PhysicsModules/SharedBase/VehicleConstants.cs b/OpenSim/Region/PhysicsModules/SharedBase/VehicleConstants.cs new file mode 100644 index 0000000..f0775c1 --- /dev/null +++ b/OpenSim/Region/PhysicsModules/SharedBase/VehicleConstants.cs | |||
@@ -0,0 +1,121 @@ | |||
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 | |||
28 | using System; | ||
29 | |||
30 | namespace OpenSim.Region.Physics.Manager | ||
31 | { | ||
32 | public enum Vehicle : int | ||
33 | { | ||
34 | /// <summary> | ||
35 | /// Turns off Vehicle Support | ||
36 | /// </summary> | ||
37 | TYPE_NONE = 0, | ||
38 | |||
39 | /// <summary> | ||
40 | /// No Angular motor, High Left right friction, No Hover, Linear Deflection 1, no angular deflection | ||
41 | /// no vertical attractor, No banking, Identity rotation frame | ||
42 | /// </summary> | ||
43 | TYPE_SLED = 1, | ||
44 | |||
45 | /// <summary> | ||
46 | /// Needs Motors to be driven by timer or control events High left/right friction, No angular friction | ||
47 | /// Linear Motor wins in a second, decays in 60 seconds. Angular motor wins in a second, decays in 8/10ths of a second | ||
48 | /// linear deflection 2 seconds | ||
49 | /// Vertical Attractor locked UP | ||
50 | /// </summary> | ||
51 | TYPE_CAR = 2, | ||
52 | TYPE_BOAT = 3, | ||
53 | TYPE_AIRPLANE = 4, | ||
54 | TYPE_BALLOON = 5, | ||
55 | LINEAR_FRICTION_TIMESCALE = 16, | ||
56 | /// <summary> | ||
57 | /// vector of timescales for exponential decay of angular velocity about three axis | ||
58 | /// </summary> | ||
59 | ANGULAR_FRICTION_TIMESCALE = 17, | ||
60 | /// <summary> | ||
61 | /// linear velocity vehicle will try for | ||
62 | /// </summary> | ||
63 | LINEAR_MOTOR_DIRECTION = 18, | ||
64 | |||
65 | /// <summary> | ||
66 | /// Offset from center of mass where linear motor forces are added | ||
67 | /// </summary> | ||
68 | LINEAR_MOTOR_OFFSET = 20, | ||
69 | /// <summary> | ||
70 | /// angular velocity that vehicle will try for | ||
71 | /// </summary> | ||
72 | ANGULAR_MOTOR_DIRECTION = 19, | ||
73 | HOVER_HEIGHT = 24, | ||
74 | HOVER_EFFICIENCY = 25, | ||
75 | HOVER_TIMESCALE = 26, | ||
76 | BUOYANCY = 27, | ||
77 | LINEAR_DEFLECTION_EFFICIENCY = 28, | ||
78 | LINEAR_DEFLECTION_TIMESCALE = 29, | ||
79 | LINEAR_MOTOR_TIMESCALE = 30, | ||
80 | LINEAR_MOTOR_DECAY_TIMESCALE = 31, | ||
81 | |||
82 | /// <summary> | ||
83 | /// slide between 0 and 1 | ||
84 | /// </summary> | ||
85 | ANGULAR_DEFLECTION_EFFICIENCY = 32, | ||
86 | ANGULAR_DEFLECTION_TIMESCALE = 33, | ||
87 | ANGULAR_MOTOR_TIMESCALE = 34, | ||
88 | ANGULAR_MOTOR_DECAY_TIMESCALE = 35, | ||
89 | VERTICAL_ATTRACTION_EFFICIENCY = 36, | ||
90 | VERTICAL_ATTRACTION_TIMESCALE = 37, | ||
91 | BANKING_EFFICIENCY = 38, | ||
92 | BANKING_MIX = 39, | ||
93 | BANKING_TIMESCALE = 40, | ||
94 | REFERENCE_FRAME = 44, | ||
95 | BLOCK_EXIT = 45, | ||
96 | ROLL_FRAME = 46 | ||
97 | |||
98 | } | ||
99 | |||
100 | [Flags] | ||
101 | public enum VehicleFlag | ||
102 | { | ||
103 | NO_DEFLECTION_UP = 1, | ||
104 | LIMIT_ROLL_ONLY = 2, | ||
105 | HOVER_WATER_ONLY = 4, | ||
106 | HOVER_TERRAIN_ONLY = 8, | ||
107 | HOVER_GLOBAL_HEIGHT = 16, | ||
108 | HOVER_UP_ONLY = 32, | ||
109 | LIMIT_MOTOR_UP = 64, | ||
110 | MOUSELOOK_STEER = 128, | ||
111 | MOUSELOOK_BANK = 256, | ||
112 | CAMERA_DECOUPLED = 512, | ||
113 | NO_X = 1024, | ||
114 | NO_Y = 2048, | ||
115 | NO_Z = 4096, | ||
116 | LOCK_HOVER_HEIGHT = 8192, | ||
117 | NO_DEFLECTION = 16392, | ||
118 | LOCK_ROTATION = 32784 | ||
119 | } | ||
120 | |||
121 | } | ||
diff --git a/OpenSim/Region/PhysicsModules/SharedBase/ZeroMesher.cs b/OpenSim/Region/PhysicsModules/SharedBase/ZeroMesher.cs new file mode 100644 index 0000000..270d2ec --- /dev/null +++ b/OpenSim/Region/PhysicsModules/SharedBase/ZeroMesher.cs | |||
@@ -0,0 +1,83 @@ | |||
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 | |||
28 | using System; | ||
29 | using OpenSim.Framework; | ||
30 | using OpenMetaverse; | ||
31 | using 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 | |||
44 | namespace 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, false); | ||
68 | } | ||
69 | |||
70 | public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical) | ||
71 | { | ||
72 | return CreateMesh(primName, primShape, size, lod, false, false); | ||
73 | } | ||
74 | |||
75 | public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool shouldCache) | ||
76 | { | ||
77 | // Remove the reference to the encoded JPEG2000 data so it can be GCed | ||
78 | primShape.SculptData = OpenMetaverse.Utils.EmptyBytes; | ||
79 | |||
80 | return null; | ||
81 | } | ||
82 | } | ||
83 | } | ||