diff options
author | David Walter Seikel | 2016-11-03 21:44:39 +1000 |
---|---|---|
committer | David Walter Seikel | 2016-11-03 21:44:39 +1000 |
commit | 134f86e8d5c414409631b25b8c6f0ee45fbd8631 (patch) | |
tree | 216b89d3fb89acfb81be1e440c25c41ab09fa96d /OpenSim/Region/Physics/Manager/PhysicsActor.cs | |
parent | More changing to production grid. Double oops. (diff) | |
download | opensim-SC-134f86e8d5c414409631b25b8c6f0ee45fbd8631.zip opensim-SC-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.gz opensim-SC-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.bz2 opensim-SC-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.xz |
Initial update to OpenSim 0.8.2.1 source code.
Diffstat (limited to 'OpenSim/Region/Physics/Manager/PhysicsActor.cs')
-rw-r--r-- | OpenSim/Region/Physics/Manager/PhysicsActor.cs | 567 |
1 files changed, 0 insertions, 567 deletions
diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs deleted file mode 100644 index d119791..0000000 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ /dev/null | |||
@@ -1,567 +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 | |||
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 abstract PrimitiveBaseShape Shape { set; } | ||
151 | |||
152 | uint m_baseLocalID; | ||
153 | public virtual uint LocalID | ||
154 | { | ||
155 | set { m_baseLocalID = value; } | ||
156 | get { return m_baseLocalID; } | ||
157 | } | ||
158 | |||
159 | public abstract bool Grabbed { set; } | ||
160 | |||
161 | public abstract bool Selected { set; } | ||
162 | |||
163 | /// <summary> | ||
164 | /// Name of this actor. | ||
165 | /// </summary> | ||
166 | /// <remarks> | ||
167 | /// XXX: Bizarrely, this cannot be "Terrain" or "Water" right now unless it really is simulating terrain or | ||
168 | /// water. This is not a problem due to the formatting of names given by prims and avatars. | ||
169 | /// </remarks> | ||
170 | public string Name { get; protected set; } | ||
171 | |||
172 | /// <summary> | ||
173 | /// This is being used by ODE joint code. | ||
174 | /// </summary> | ||
175 | public string SOPName; | ||
176 | |||
177 | public abstract void CrossingFailure(); | ||
178 | |||
179 | public abstract void link(PhysicsActor obj); | ||
180 | |||
181 | public abstract void delink(); | ||
182 | |||
183 | public abstract void LockAngularMotion(Vector3 axis); | ||
184 | |||
185 | public virtual void RequestPhysicsterseUpdate() | ||
186 | { | ||
187 | // Make a temporary copy of the event to avoid possibility of | ||
188 | // a race condition if the last subscriber unsubscribes | ||
189 | // immediately after the null check and before the event is raised. | ||
190 | RequestTerseUpdate handler = OnRequestTerseUpdate; | ||
191 | |||
192 | if (handler != null) | ||
193 | { | ||
194 | handler(); | ||
195 | } | ||
196 | } | ||
197 | |||
198 | public virtual void RaiseOutOfBounds(Vector3 pos) | ||
199 | { | ||
200 | // Make a temporary copy of the event to avoid possibility of | ||
201 | // a race condition if the last subscriber unsubscribes | ||
202 | // immediately after the null check and before the event is raised. | ||
203 | OutOfBounds handler = OnOutOfBounds; | ||
204 | |||
205 | if (handler != null) | ||
206 | { | ||
207 | handler(pos); | ||
208 | } | ||
209 | } | ||
210 | |||
211 | public virtual void SendCollisionUpdate(EventArgs e) | ||
212 | { | ||
213 | CollisionUpdate handler = OnCollisionUpdate; | ||
214 | |||
215 | // m_log.DebugFormat("[PHYSICS ACTOR]: Sending collision for {0}", LocalID); | ||
216 | |||
217 | if (handler != null) | ||
218 | handler(e); | ||
219 | } | ||
220 | |||
221 | public virtual void SetMaterial (int material) | ||
222 | { | ||
223 | } | ||
224 | |||
225 | /// <summary> | ||
226 | /// Position of this actor. | ||
227 | /// </summary> | ||
228 | /// <remarks> | ||
229 | /// Setting this directly moves the actor to a given position. | ||
230 | /// Getting this retrieves the position calculated by physics scene updates, using factors such as velocity and | ||
231 | /// collisions. | ||
232 | /// </remarks> | ||
233 | public abstract Vector3 Position { get; set; } | ||
234 | |||
235 | public abstract float Mass { get; } | ||
236 | public abstract Vector3 Force { get; set; } | ||
237 | |||
238 | public abstract int VehicleType { get; set; } | ||
239 | public abstract void VehicleFloatParam(int param, float value); | ||
240 | public abstract void VehicleVectorParam(int param, Vector3 value); | ||
241 | public abstract void VehicleRotationParam(int param, Quaternion rotation); | ||
242 | public abstract void VehicleFlags(int param, bool remove); | ||
243 | |||
244 | /// <summary> | ||
245 | /// Allows the detection of collisions with inherently non-physical prims. see llVolumeDetect for more | ||
246 | /// </summary> | ||
247 | public abstract void SetVolumeDetect(int param); | ||
248 | |||
249 | public abstract Vector3 GeometricCenter { get; } | ||
250 | public abstract Vector3 CenterOfMass { get; } | ||
251 | |||
252 | /// <summary> | ||
253 | /// The desired velocity of this actor. | ||
254 | /// </summary> | ||
255 | /// <remarks> | ||
256 | /// Setting this provides a target velocity for physics scene updates. | ||
257 | /// Getting this returns the last set target. Fetch Velocity to get the current velocity. | ||
258 | /// </remarks> | ||
259 | protected Vector3 m_targetVelocity; | ||
260 | public virtual Vector3 TargetVelocity | ||
261 | { | ||
262 | get { return m_targetVelocity; } | ||
263 | set { | ||
264 | m_targetVelocity = value; | ||
265 | Velocity = m_targetVelocity; | ||
266 | } | ||
267 | } | ||
268 | |||
269 | public abstract Vector3 Velocity { get; set; } | ||
270 | |||
271 | public abstract Vector3 Torque { get; set; } | ||
272 | public abstract float CollisionScore { get; set;} | ||
273 | public abstract Vector3 Acceleration { get; set; } | ||
274 | public abstract Quaternion Orientation { get; set; } | ||
275 | public abstract int PhysicsActorType { get; set; } | ||
276 | public abstract bool IsPhysical { get; set; } | ||
277 | public abstract bool Flying { get; set; } | ||
278 | public abstract bool SetAlwaysRun { get; set; } | ||
279 | public abstract bool ThrottleUpdates { get; set; } | ||
280 | public abstract bool IsColliding { get; set; } | ||
281 | public abstract bool CollidingGround { get; set; } | ||
282 | public abstract bool CollidingObj { get; set; } | ||
283 | public abstract bool FloatOnWater { set; } | ||
284 | public abstract Vector3 RotationalVelocity { get; set; } | ||
285 | public abstract bool Kinematic { get; set; } | ||
286 | public abstract float Buoyancy { get; set; } | ||
287 | |||
288 | // Used for MoveTo | ||
289 | public abstract Vector3 PIDTarget { set; } | ||
290 | public abstract bool PIDActive { set;} | ||
291 | public abstract float PIDTau { set; } | ||
292 | |||
293 | // Used for llSetHoverHeight and maybe vehicle height | ||
294 | // Hover Height will override MoveTo target's Z | ||
295 | public abstract bool PIDHoverActive { set;} | ||
296 | public abstract float PIDHoverHeight { set;} | ||
297 | public abstract PIDHoverType PIDHoverType { set;} | ||
298 | public abstract float PIDHoverTau { set;} | ||
299 | |||
300 | // For RotLookAt | ||
301 | public abstract Quaternion APIDTarget { set;} | ||
302 | public abstract bool APIDActive { set;} | ||
303 | public abstract float APIDStrength { set;} | ||
304 | public abstract float APIDDamping { set;} | ||
305 | |||
306 | public abstract void AddForce(Vector3 force, bool pushforce); | ||
307 | public abstract void AddAngularForce(Vector3 force, bool pushforce); | ||
308 | public abstract void SetMomentum(Vector3 momentum); | ||
309 | public abstract void SubscribeEvents(int ms); | ||
310 | public abstract void UnSubscribeEvents(); | ||
311 | public abstract bool SubscribedEvents(); | ||
312 | } | ||
313 | |||
314 | public class NullPhysicsActor : PhysicsActor | ||
315 | { | ||
316 | public override bool Stopped | ||
317 | { | ||
318 | get{ return false; } | ||
319 | } | ||
320 | |||
321 | public override Vector3 Position | ||
322 | { | ||
323 | get { return Vector3.Zero; } | ||
324 | set { return; } | ||
325 | } | ||
326 | |||
327 | public override bool SetAlwaysRun | ||
328 | { | ||
329 | get { return false; } | ||
330 | set { return; } | ||
331 | } | ||
332 | |||
333 | public override uint LocalID | ||
334 | { | ||
335 | set { return; } | ||
336 | } | ||
337 | |||
338 | public override bool Grabbed | ||
339 | { | ||
340 | set { return; } | ||
341 | } | ||
342 | |||
343 | public override bool Selected | ||
344 | { | ||
345 | set { return; } | ||
346 | } | ||
347 | |||
348 | public override float Buoyancy | ||
349 | { | ||
350 | get { return 0f; } | ||
351 | set { return; } | ||
352 | } | ||
353 | |||
354 | public override bool FloatOnWater | ||
355 | { | ||
356 | set { return; } | ||
357 | } | ||
358 | |||
359 | public override bool CollidingGround | ||
360 | { | ||
361 | get { return false; } | ||
362 | set { return; } | ||
363 | } | ||
364 | |||
365 | public override bool CollidingObj | ||
366 | { | ||
367 | get { return false; } | ||
368 | set { return; } | ||
369 | } | ||
370 | |||
371 | public override Vector3 Size | ||
372 | { | ||
373 | get { return Vector3.Zero; } | ||
374 | set { return; } | ||
375 | } | ||
376 | |||
377 | public override float Mass | ||
378 | { | ||
379 | get { return 0f; } | ||
380 | } | ||
381 | |||
382 | public override Vector3 Force | ||
383 | { | ||
384 | get { return Vector3.Zero; } | ||
385 | set { return; } | ||
386 | } | ||
387 | |||
388 | public override int VehicleType | ||
389 | { | ||
390 | get { return 0; } | ||
391 | set { return; } | ||
392 | } | ||
393 | |||
394 | public override void VehicleFloatParam(int param, float value) | ||
395 | { | ||
396 | |||
397 | } | ||
398 | |||
399 | public override void VehicleVectorParam(int param, Vector3 value) | ||
400 | { | ||
401 | |||
402 | } | ||
403 | |||
404 | public override void VehicleRotationParam(int param, Quaternion rotation) | ||
405 | { | ||
406 | |||
407 | } | ||
408 | |||
409 | public override void VehicleFlags(int param, bool remove) | ||
410 | { | ||
411 | |||
412 | } | ||
413 | |||
414 | public override void SetVolumeDetect(int param) | ||
415 | { | ||
416 | |||
417 | } | ||
418 | |||
419 | public override void SetMaterial(int material) | ||
420 | { | ||
421 | |||
422 | } | ||
423 | |||
424 | public override Vector3 CenterOfMass | ||
425 | { | ||
426 | get { return Vector3.Zero; } | ||
427 | } | ||
428 | |||
429 | public override Vector3 GeometricCenter | ||
430 | { | ||
431 | get { return Vector3.Zero; } | ||
432 | } | ||
433 | |||
434 | public override PrimitiveBaseShape Shape | ||
435 | { | ||
436 | set { return; } | ||
437 | } | ||
438 | |||
439 | public override Vector3 Velocity | ||
440 | { | ||
441 | get { return Vector3.Zero; } | ||
442 | set { return; } | ||
443 | } | ||
444 | |||
445 | public override Vector3 Torque | ||
446 | { | ||
447 | get { return Vector3.Zero; } | ||
448 | set { return; } | ||
449 | } | ||
450 | |||
451 | public override float CollisionScore | ||
452 | { | ||
453 | get { return 0f; } | ||
454 | set { } | ||
455 | } | ||
456 | |||
457 | public override void CrossingFailure() | ||
458 | { | ||
459 | } | ||
460 | |||
461 | public override Quaternion Orientation | ||
462 | { | ||
463 | get { return Quaternion.Identity; } | ||
464 | set { } | ||
465 | } | ||
466 | |||
467 | public override Vector3 Acceleration | ||
468 | { | ||
469 | get { return Vector3.Zero; } | ||
470 | set { } | ||
471 | } | ||
472 | |||
473 | public override bool IsPhysical | ||
474 | { | ||
475 | get { return false; } | ||
476 | set { return; } | ||
477 | } | ||
478 | |||
479 | public override bool Flying | ||
480 | { | ||
481 | get { return false; } | ||
482 | set { return; } | ||
483 | } | ||
484 | |||
485 | public override bool ThrottleUpdates | ||
486 | { | ||
487 | get { return false; } | ||
488 | set { return; } | ||
489 | } | ||
490 | |||
491 | public override bool IsColliding | ||
492 | { | ||
493 | get { return false; } | ||
494 | set { return; } | ||
495 | } | ||
496 | |||
497 | public override int PhysicsActorType | ||
498 | { | ||
499 | get { return (int) ActorTypes.Unknown; } | ||
500 | set { return; } | ||
501 | } | ||
502 | |||
503 | public override bool Kinematic | ||
504 | { | ||
505 | get { return true; } | ||
506 | set { return; } | ||
507 | } | ||
508 | |||
509 | public override void link(PhysicsActor obj) | ||
510 | { | ||
511 | } | ||
512 | |||
513 | public override void delink() | ||
514 | { | ||
515 | } | ||
516 | |||
517 | public override void LockAngularMotion(Vector3 axis) | ||
518 | { | ||
519 | } | ||
520 | |||
521 | public override void AddForce(Vector3 force, bool pushforce) | ||
522 | { | ||
523 | } | ||
524 | |||
525 | public override void AddAngularForce(Vector3 force, bool pushforce) | ||
526 | { | ||
527 | |||
528 | } | ||
529 | |||
530 | public override Vector3 RotationalVelocity | ||
531 | { | ||
532 | get { return Vector3.Zero; } | ||
533 | set { return; } | ||
534 | } | ||
535 | |||
536 | public override Vector3 PIDTarget { set { return; } } | ||
537 | public override bool PIDActive { set { return; } } | ||
538 | public override float PIDTau { set { return; } } | ||
539 | |||
540 | public override float PIDHoverHeight { set { return; } } | ||
541 | public override bool PIDHoverActive { set { return; } } | ||
542 | public override PIDHoverType PIDHoverType { set { return; } } | ||
543 | public override float PIDHoverTau { set { return; } } | ||
544 | |||
545 | public override Quaternion APIDTarget { set { return; } } | ||
546 | public override bool APIDActive { set { return; } } | ||
547 | public override float APIDStrength { set { return; } } | ||
548 | public override float APIDDamping { set { return; } } | ||
549 | |||
550 | public override void SetMomentum(Vector3 momentum) | ||
551 | { | ||
552 | } | ||
553 | |||
554 | public override void SubscribeEvents(int ms) | ||
555 | { | ||
556 | |||
557 | } | ||
558 | public override void UnSubscribeEvents() | ||
559 | { | ||
560 | |||
561 | } | ||
562 | public override bool SubscribedEvents() | ||
563 | { | ||
564 | return false; | ||
565 | } | ||
566 | } | ||
567 | } | ||