aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/Manager/PhysicsScene.cs
diff options
context:
space:
mode:
authorDavid Walter Seikel2016-11-03 21:44:39 +1000
committerDavid Walter Seikel2016-11-03 21:44:39 +1000
commit134f86e8d5c414409631b25b8c6f0ee45fbd8631 (patch)
tree216b89d3fb89acfb81be1e440c25c41ab09fa96d /OpenSim/Region/Physics/Manager/PhysicsScene.cs
parentMore changing to production grid. Double oops. (diff)
downloadopensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.zip
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.gz
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.bz2
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.xz
Initial update to OpenSim 0.8.2.1 source code.
Diffstat (limited to 'OpenSim/Region/Physics/Manager/PhysicsScene.cs')
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsScene.cs283
1 files changed, 0 insertions, 283 deletions
diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs
deleted file mode 100644
index 488900e..0000000
--- a/OpenSim/Region/Physics/Manager/PhysicsScene.cs
+++ /dev/null
@@ -1,283 +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 public delegate void physicsCrash();
38
39 public delegate void RaycastCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 normal);
40 public delegate void RayCallback(List<ContactResult> list);
41
42 public delegate void JointMoved(PhysicsJoint joint);
43 public delegate void JointDeactivated(PhysicsJoint joint);
44 public delegate void JointErrorMessage(PhysicsJoint joint, string message); // this refers to an "error message due to a problem", not "amount of joint constraint violation"
45
46 public delegate void RequestAssetDelegate(UUID assetID, AssetReceivedDelegate callback);
47 public delegate void AssetReceivedDelegate(AssetBase asset);
48
49 /// <summary>
50 /// Contact result from a raycast.
51 /// </summary>
52 public struct ContactResult
53 {
54 public Vector3 Pos;
55 public float Depth;
56 public uint ConsumerID;
57 public Vector3 Normal;
58 }
59
60 public abstract class PhysicsScene
61 {
62// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
63
64 /// <summary>
65 /// Name of this scene. Useful in debug messages to distinguish one OdeScene instance from another.
66 /// </summary>
67 public string Name { get; protected set; }
68
69 // The only thing that should register for this event is the SceneGraph
70 // Anything else could cause problems.
71
72 public event physicsCrash OnPhysicsCrash;
73
74 public static PhysicsScene Null
75 {
76 get { return new NullPhysicsScene(); }
77 }
78
79 public RequestAssetDelegate RequestAssetMethod { get; set; }
80
81 public virtual void TriggerPhysicsBasedRestart()
82 {
83 physicsCrash handler = OnPhysicsCrash;
84 if (handler != null)
85 {
86 OnPhysicsCrash();
87 }
88 }
89
90 public abstract void Initialise(IMesher meshmerizer, IConfigSource config);
91
92 /// <summary>
93 /// Add an avatar
94 /// </summary>
95 /// <param name="avName"></param>
96 /// <param name="position"></param>
97 /// <param name="size"></param>
98 /// <param name="isFlying"></param>
99 /// <returns></returns>
100 public abstract PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying);
101
102 /// <summary>
103 /// Add an avatar
104 /// </summary>
105 /// <param name="localID"></param>
106 /// <param name="avName"></param>
107 /// <param name="position"></param>
108 /// <param name="size"></param>
109 /// <param name="isFlying"></param>
110 /// <returns></returns>
111 public virtual PhysicsActor AddAvatar(uint localID, string avName, Vector3 position, Vector3 size, bool isFlying)
112 {
113 PhysicsActor ret = AddAvatar(avName, position, size, isFlying);
114 if (ret != null) ret.LocalID = localID;
115 return ret;
116 }
117
118 /// <summary>
119 /// Remove an avatar.
120 /// </summary>
121 /// <param name="actor"></param>
122 public abstract void RemoveAvatar(PhysicsActor actor);
123
124 /// <summary>
125 /// Remove a prim.
126 /// </summary>
127 /// <param name="prim"></param>
128 public abstract void RemovePrim(PhysicsActor prim);
129
130 public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
131 Vector3 size, Quaternion rotation, bool isPhysical, uint localid);
132
133 public virtual float TimeDilation
134 {
135 get { return 1.0f; }
136 }
137
138 public virtual bool SupportsNINJAJoints
139 {
140 get { return false; }
141 }
142
143 public virtual PhysicsJoint RequestJointCreation(string objectNameInScene, PhysicsJointType jointType, Vector3 position,
144 Quaternion rotation, string parms, List<string> bodyNames, string trackedBodyName, Quaternion localRotation)
145 { return null; }
146
147 public virtual void RequestJointDeletion(string objectNameInScene)
148 { return; }
149
150 public virtual void RemoveAllJointsConnectedToActorThreadLocked(PhysicsActor actor)
151 { return; }
152
153 public virtual void DumpJointInfo()
154 { return; }
155
156 public event JointMoved OnJointMoved;
157
158 protected virtual void DoJointMoved(PhysicsJoint joint)
159 {
160 // We need this to allow subclasses (but not other classes) to invoke the event; C# does
161 // not allow subclasses to invoke the parent class event.
162 if (OnJointMoved != null)
163 {
164 OnJointMoved(joint);
165 }
166 }
167
168 public event JointDeactivated OnJointDeactivated;
169
170 protected virtual void DoJointDeactivated(PhysicsJoint joint)
171 {
172 // We need this to allow subclasses (but not other classes) to invoke the event; C# does
173 // not allow subclasses to invoke the parent class event.
174 if (OnJointDeactivated != null)
175 {
176 OnJointDeactivated(joint);
177 }
178 }
179
180 public event JointErrorMessage OnJointErrorMessage;
181
182 protected virtual void DoJointErrorMessage(PhysicsJoint joint, string message)
183 {
184 // We need this to allow subclasses (but not other classes) to invoke the event; C# does
185 // not allow subclasses to invoke the parent class event.
186 if (OnJointErrorMessage != null)
187 {
188 OnJointErrorMessage(joint, message);
189 }
190 }
191
192 public virtual Vector3 GetJointAnchor(PhysicsJoint joint)
193 { return Vector3.Zero; }
194
195 public virtual Vector3 GetJointAxis(PhysicsJoint joint)
196 { return Vector3.Zero; }
197
198 public abstract void AddPhysicsActorTaint(PhysicsActor prim);
199
200 /// <summary>
201 /// Perform a simulation of the current physics scene over the given timestep.
202 /// </summary>
203 /// <param name="timeStep"></param>
204 /// <returns>The number of frames simulated over that period.</returns>
205 public abstract float Simulate(float timeStep);
206
207 /// <summary>
208 /// Get statistics about this scene.
209 /// </summary>
210 /// <remarks>This facility is currently experimental and subject to change.</remarks>
211 /// <returns>
212 /// A dictionary where the key is the statistic name. If no statistics are supplied then returns null.
213 /// </returns>
214 public virtual Dictionary<string, float> GetStats() { return null; }
215
216 public abstract void GetResults();
217
218 public abstract void SetTerrain(float[] heightMap);
219
220 public abstract void SetWaterLevel(float baseheight);
221
222 public abstract void DeleteTerrain();
223
224 public abstract void Dispose();
225
226 public abstract Dictionary<uint, float> GetTopColliders();
227
228 public abstract bool IsThreaded { get; }
229
230 /// <summary>
231 /// True if the physics plugin supports raycasting against the physics scene
232 /// </summary>
233 public virtual bool SupportsRayCast()
234 {
235 return false;
236 }
237
238 public virtual bool SupportsCombining()
239 {
240 return false;
241 }
242
243 public virtual void Combine(PhysicsScene pScene, Vector3 offset, Vector3 extents) {}
244
245 public virtual void UnCombine(PhysicsScene pScene) {}
246
247 /// <summary>
248 /// Queue a raycast against the physics scene.
249 /// The provided callback method will be called when the raycast is complete
250 ///
251 /// Many physics engines don't support collision testing at the same time as
252 /// manipulating the physics scene, so we queue the request up and callback
253 /// a custom method when the raycast is complete.
254 /// This allows physics engines that give an immediate result to callback immediately
255 /// and ones that don't, to callback when it gets a result back.
256 ///
257 /// ODE for example will not allow you to change the scene while collision testing or
258 /// it asserts, 'opteration not valid for locked space'. This includes adding a ray to the scene.
259 ///
260 /// This is named RayCastWorld to not conflict with modrex's Raycast method.
261 /// </summary>
262 /// <param name="position">Origin of the ray</param>
263 /// <param name="direction">Direction of the ray</param>
264 /// <param name="length">Length of ray in meters</param>
265 /// <param name="retMethod">Method to call when the raycast is complete</param>
266 public virtual void RaycastWorld(Vector3 position, Vector3 direction, float length, RaycastCallback retMethod)
267 {
268 if (retMethod != null)
269 retMethod(false, Vector3.Zero, 0, 999999999999f, Vector3.Zero);
270 }
271
272 public virtual void RaycastWorld(Vector3 position, Vector3 direction, float length, int Count, RayCallback retMethod)
273 {
274 if (retMethod != null)
275 retMethod(new List<ContactResult>());
276 }
277
278 public virtual List<ContactResult> RaycastWorld(Vector3 position, Vector3 direction, float length, int Count)
279 {
280 return new List<ContactResult>();
281 }
282 }
283}