diff options
Diffstat (limited to 'OpenSim/Region/Physics/Manager/PhysicsScene.cs')
-rw-r--r-- | OpenSim/Region/Physics/Manager/PhysicsScene.cs | 171 |
1 files changed, 67 insertions, 104 deletions
diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs index 217d307..514d9ad 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsScene.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsScene.cs | |||
@@ -37,10 +37,31 @@ namespace OpenSim.Region.Physics.Manager | |||
37 | public delegate void physicsCrash(); | 37 | public delegate void physicsCrash(); |
38 | 38 | ||
39 | public delegate void RaycastCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 normal); | 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 | /// <summary> | ||
47 | /// Contact result from a raycast. | ||
48 | /// </summary> | ||
49 | public struct ContactResult | ||
50 | { | ||
51 | public Vector3 Pos; | ||
52 | public float Depth; | ||
53 | public uint ConsumerID; | ||
54 | public Vector3 Normal; | ||
55 | } | ||
40 | 56 | ||
41 | public abstract class PhysicsScene | 57 | public abstract class PhysicsScene |
42 | { | 58 | { |
43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 59 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
60 | |||
61 | /// <summary> | ||
62 | /// Name of this scene. Useful in debug messages to distinguish one OdeScene instance from another. | ||
63 | /// </summary> | ||
64 | public string Name { get; protected set; } | ||
44 | 65 | ||
45 | // The only thing that should register for this event is the SceneGraph | 66 | // The only thing that should register for this event is the SceneGraph |
46 | // Anything else could cause problems. | 67 | // Anything else could cause problems. |
@@ -61,19 +82,51 @@ namespace OpenSim.Region.Physics.Manager | |||
61 | } | 82 | } |
62 | } | 83 | } |
63 | 84 | ||
64 | |||
65 | public abstract void Initialise(IMesher meshmerizer, IConfigSource config); | 85 | public abstract void Initialise(IMesher meshmerizer, IConfigSource config); |
66 | 86 | ||
87 | /// <summary> | ||
88 | /// Add an avatar | ||
89 | /// </summary> | ||
90 | /// <param name="avName"></param> | ||
91 | /// <param name="position"></param> | ||
92 | /// <param name="size"></param> | ||
93 | /// <param name="isFlying"></param> | ||
94 | /// <returns></returns> | ||
67 | public abstract PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying); | 95 | public abstract PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying); |
68 | 96 | ||
97 | /// <summary> | ||
98 | /// Add an avatar | ||
99 | /// </summary> | ||
100 | /// <param name="localID"></param> | ||
101 | /// <param name="avName"></param> | ||
102 | /// <param name="position"></param> | ||
103 | /// <param name="size"></param> | ||
104 | /// <param name="isFlying"></param> | ||
105 | /// <returns></returns> | ||
106 | public virtual PhysicsActor AddAvatar(uint localID, string avName, Vector3 position, Vector3 size, bool isFlying) | ||
107 | { | ||
108 | PhysicsActor ret = AddAvatar(avName, position, size, isFlying); | ||
109 | if (ret != null) ret.LocalID = localID; | ||
110 | return ret; | ||
111 | } | ||
112 | |||
113 | /// <summary> | ||
114 | /// Remove an avatar. | ||
115 | /// </summary> | ||
116 | /// <param name="actor"></param> | ||
69 | public abstract void RemoveAvatar(PhysicsActor actor); | 117 | public abstract void RemoveAvatar(PhysicsActor actor); |
70 | 118 | ||
119 | /// <summary> | ||
120 | /// Remove a prim. | ||
121 | /// </summary> | ||
122 | /// <param name="prim"></param> | ||
71 | public abstract void RemovePrim(PhysicsActor prim); | 123 | public abstract void RemovePrim(PhysicsActor prim); |
72 | 124 | ||
125 | //public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, | ||
126 | // Vector3 size, Quaternion rotation); //To be removed - Actually removed! | ||
127 | |||
73 | public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, | 128 | public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, |
74 | Vector3 size, Quaternion rotation); //To be removed | 129 | Vector3 size, Quaternion rotation, bool isPhysical, uint localid); |
75 | public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, | ||
76 | Vector3 size, Quaternion rotation, bool isPhysical); | ||
77 | 130 | ||
78 | public virtual float TimeDilation | 131 | public virtual float TimeDilation |
79 | { | 132 | { |
@@ -140,7 +193,6 @@ namespace OpenSim.Region.Physics.Manager | |||
140 | public virtual Vector3 GetJointAxis(PhysicsJoint joint) | 193 | public virtual Vector3 GetJointAxis(PhysicsJoint joint) |
141 | { return Vector3.Zero; } | 194 | { return Vector3.Zero; } |
142 | 195 | ||
143 | |||
144 | public abstract void AddPhysicsActorTaint(PhysicsActor prim); | 196 | public abstract void AddPhysicsActorTaint(PhysicsActor prim); |
145 | 197 | ||
146 | public abstract float Simulate(float timeStep); | 198 | public abstract float Simulate(float timeStep); |
@@ -172,15 +224,9 @@ namespace OpenSim.Region.Physics.Manager | |||
172 | return false; | 224 | return false; |
173 | } | 225 | } |
174 | 226 | ||
175 | public virtual void Combine(PhysicsScene pScene, Vector3 offset, Vector3 extents) | 227 | public virtual void Combine(PhysicsScene pScene, Vector3 offset, Vector3 extents) {} |
176 | { | ||
177 | return; | ||
178 | } | ||
179 | 228 | ||
180 | public virtual void UnCombine(PhysicsScene pScene) | 229 | public virtual void UnCombine(PhysicsScene pScene) {} |
181 | { | ||
182 | |||
183 | } | ||
184 | 230 | ||
185 | /// <summary> | 231 | /// <summary> |
186 | /// Queue a raycast against the physics scene. | 232 | /// Queue a raycast against the physics scene. |
@@ -207,98 +253,15 @@ namespace OpenSim.Region.Physics.Manager | |||
207 | retMethod(false, Vector3.Zero, 0, 999999999999f, Vector3.Zero); | 253 | retMethod(false, Vector3.Zero, 0, 999999999999f, Vector3.Zero); |
208 | } | 254 | } |
209 | 255 | ||
210 | private class NullPhysicsScene : PhysicsScene | 256 | public virtual void RaycastWorld(Vector3 position, Vector3 direction, float length, int Count, RayCallback retMethod) |
211 | { | 257 | { |
212 | private static int m_workIndicator; | 258 | if (retMethod != null) |
213 | 259 | retMethod(new List<ContactResult>()); | |
214 | 260 | } | |
215 | public override void Initialise(IMesher meshmerizer, IConfigSource config) | ||
216 | { | ||
217 | // Does nothing right now | ||
218 | } | ||
219 | |||
220 | public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying) | ||
221 | { | ||
222 | m_log.InfoFormat("[PHYSICS]: NullPhysicsScene : AddAvatar({0})", position); | ||
223 | return PhysicsActor.Null; | ||
224 | } | ||
225 | |||
226 | public override void RemoveAvatar(PhysicsActor actor) | ||
227 | { | ||
228 | } | ||
229 | |||
230 | public override void RemovePrim(PhysicsActor prim) | ||
231 | { | ||
232 | } | ||
233 | public override void SetWaterLevel(float baseheight) | ||
234 | { | ||
235 | |||
236 | } | ||
237 | |||
238 | /* | ||
239 | public override PhysicsActor AddPrim(Vector3 position, Vector3 size, Quaternion rotation) | ||
240 | { | ||
241 | m_log.InfoFormat("NullPhysicsScene : AddPrim({0},{1})", position, size); | ||
242 | return PhysicsActor.Null; | ||
243 | } | ||
244 | */ | ||
245 | |||
246 | public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, | ||
247 | Vector3 size, Quaternion rotation) //To be removed | ||
248 | { | ||
249 | return AddPrimShape(primName, pbs, position, size, rotation, false); | ||
250 | } | ||
251 | |||
252 | public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, | ||
253 | Vector3 size, Quaternion rotation, bool isPhysical) | ||
254 | { | ||
255 | m_log.InfoFormat("[PHYSICS]: NullPhysicsScene : AddPrim({0},{1})", position, size); | ||
256 | return PhysicsActor.Null; | ||
257 | } | ||
258 | |||
259 | public override void AddPhysicsActorTaint(PhysicsActor prim) | ||
260 | { | ||
261 | } | ||
262 | |||
263 | public override float Simulate(float timeStep) | ||
264 | { | ||
265 | m_workIndicator = (m_workIndicator + 1) % 10; | ||
266 | |||
267 | return 0f; | ||
268 | } | ||
269 | |||
270 | public override void GetResults() | ||
271 | { | ||
272 | m_log.Info("[PHYSICS]: NullPhysicsScene : GetResults()"); | ||
273 | } | ||
274 | |||
275 | public override void SetTerrain(float[] heightMap) | ||
276 | { | ||
277 | m_log.InfoFormat("[PHYSICS]: NullPhysicsScene : SetTerrain({0} items)", heightMap.Length); | ||
278 | } | ||
279 | |||
280 | public override void DeleteTerrain() | ||
281 | { | ||
282 | } | ||
283 | |||
284 | public override bool IsThreaded | ||
285 | { | ||
286 | get { return false; } | ||
287 | } | ||
288 | |||
289 | public override void Dispose() | ||
290 | { | ||
291 | } | ||
292 | 261 | ||
293 | public override Dictionary<uint,float> GetTopColliders() | 262 | public virtual List<ContactResult> RaycastWorld(Vector3 position, Vector3 direction, float length, int Count) |
294 | { | 263 | { |
295 | Dictionary<uint, float> returncolliders = new Dictionary<uint, float>(); | 264 | return new List<ContactResult>(); |
296 | return returncolliders; | ||
297 | } | ||
298 | |||
299 | } | 265 | } |
300 | } | 266 | } |
301 | public delegate void JointMoved(PhysicsJoint joint); | ||
302 | public delegate void JointDeactivated(PhysicsJoint joint); | ||
303 | public delegate void JointErrorMessage(PhysicsJoint joint, string message); // this refers to an "error message due to a problem", not "amount of joint constraint violation" | ||
304 | } | 267 | } |