diff options
Diffstat (limited to 'OpenSim/Region/Physics/Manager/PhysicsActor.cs')
-rw-r--r-- | OpenSim/Region/Physics/Manager/PhysicsActor.cs | 221 |
1 files changed, 132 insertions, 89 deletions
diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index 34413e5..5af6373 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs | |||
@@ -43,7 +43,8 @@ namespace OpenSim.Region.Physics.Manager | |||
43 | Unknown = 0, | 43 | Unknown = 0, |
44 | Agent = 1, | 44 | Agent = 1, |
45 | Prim = 2, | 45 | Prim = 2, |
46 | Ground = 3 | 46 | Ground = 3, |
47 | Water = 4 | ||
47 | } | 48 | } |
48 | 49 | ||
49 | public enum PIDHoverType | 50 | public enum PIDHoverType |
@@ -59,15 +60,30 @@ namespace OpenSim.Region.Physics.Manager | |||
59 | public Vector3 Position; | 60 | public Vector3 Position; |
60 | public Vector3 SurfaceNormal; | 61 | public Vector3 SurfaceNormal; |
61 | public float PenetrationDepth; | 62 | public float PenetrationDepth; |
63 | public float RelativeSpeed; | ||
62 | 64 | ||
63 | public ContactPoint(Vector3 position, Vector3 surfaceNormal, float penetrationDepth) | 65 | public ContactPoint(Vector3 position, Vector3 surfaceNormal, float penetrationDepth) |
64 | { | 66 | { |
65 | Position = position; | 67 | Position = position; |
66 | SurfaceNormal = surfaceNormal; | 68 | SurfaceNormal = surfaceNormal; |
67 | PenetrationDepth = penetrationDepth; | 69 | PenetrationDepth = penetrationDepth; |
70 | RelativeSpeed = 0f; // for now let this one be set explicity | ||
68 | } | 71 | } |
69 | } | 72 | } |
70 | 73 | ||
74 | public struct ContactData | ||
75 | { | ||
76 | public float mu; | ||
77 | public float bounce; | ||
78 | public bool softcolide; | ||
79 | |||
80 | public ContactData(float _mu, float _bounce, bool _softcolide) | ||
81 | { | ||
82 | mu = _mu; | ||
83 | bounce = _bounce; | ||
84 | softcolide = _softcolide; | ||
85 | } | ||
86 | } | ||
71 | /// <summary> | 87 | /// <summary> |
72 | /// Used to pass collision information to OnCollisionUpdate listeners. | 88 | /// Used to pass collision information to OnCollisionUpdate listeners. |
73 | /// </summary> | 89 | /// </summary> |
@@ -99,7 +115,7 @@ namespace OpenSim.Region.Physics.Manager | |||
99 | m_objCollisionList.Add(localID, contact); | 115 | m_objCollisionList.Add(localID, contact); |
100 | } | 116 | } |
101 | else | 117 | else |
102 | { | 118 | { |
103 | if (m_objCollisionList[localID].PenetrationDepth < contact.PenetrationDepth) | 119 | if (m_objCollisionList[localID].PenetrationDepth < contact.PenetrationDepth) |
104 | m_objCollisionList[localID] = contact; | 120 | m_objCollisionList[localID] = contact; |
105 | } | 121 | } |
@@ -135,6 +151,8 @@ namespace OpenSim.Region.Physics.Manager | |||
135 | /// </summary> | 151 | /// </summary> |
136 | public event CollisionUpdate OnCollisionUpdate; | 152 | public event CollisionUpdate OnCollisionUpdate; |
137 | 153 | ||
154 | public virtual void SetVehicle(object vdata) { } | ||
155 | |||
138 | public event OutOfBounds OnOutOfBounds; | 156 | public event OutOfBounds OnOutOfBounds; |
139 | #pragma warning restore 67 | 157 | #pragma warning restore 67 |
140 | 158 | ||
@@ -142,11 +160,29 @@ namespace OpenSim.Region.Physics.Manager | |||
142 | { | 160 | { |
143 | get { return new NullPhysicsActor(); } | 161 | get { return new NullPhysicsActor(); } |
144 | } | 162 | } |
163 | |||
164 | public virtual bool Building { get; set; } | ||
165 | |||
166 | public virtual void getContactData(ref ContactData cdata) | ||
167 | { | ||
168 | cdata.mu = 0; | ||
169 | cdata.bounce = 0; | ||
170 | } | ||
145 | 171 | ||
146 | public abstract bool Stopped { get; } | 172 | public abstract bool Stopped { get; } |
147 | 173 | ||
148 | public abstract Vector3 Size { get; set; } | 174 | public abstract Vector3 Size { get; set; } |
149 | 175 | ||
176 | public virtual bool Phantom { get; set; } | ||
177 | |||
178 | public virtual bool IsVolumeDtc | ||
179 | { | ||
180 | get { return false; } | ||
181 | set { return; } | ||
182 | } | ||
183 | |||
184 | public virtual byte PhysicsShapeType { get; set; } | ||
185 | |||
150 | public abstract PrimitiveBaseShape Shape { set; } | 186 | public abstract PrimitiveBaseShape Shape { set; } |
151 | 187 | ||
152 | uint m_baseLocalID; | 188 | uint m_baseLocalID; |
@@ -167,7 +203,7 @@ namespace OpenSim.Region.Physics.Manager | |||
167 | /// XXX: Bizarrely, this cannot be "Terrain" or "Water" right now unless it really is simulating terrain or | 203 | /// 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. | 204 | /// water. This is not a problem due to the formatting of names given by prims and avatars. |
169 | /// </remarks> | 205 | /// </remarks> |
170 | public string Name { get; protected set; } | 206 | public string Name { get; set; } |
171 | 207 | ||
172 | /// <summary> | 208 | /// <summary> |
173 | /// This is being used by ODE joint code. | 209 | /// This is being used by ODE joint code. |
@@ -218,9 +254,11 @@ namespace OpenSim.Region.Physics.Manager | |||
218 | handler(e); | 254 | handler(e); |
219 | } | 255 | } |
220 | 256 | ||
221 | public virtual void SetMaterial (int material) | 257 | public virtual void SetMaterial (int material) { } |
222 | { | 258 | public virtual float Density { get; set; } |
223 | } | 259 | public virtual float GravModifier { get; set; } |
260 | public virtual float Friction { get; set; } | ||
261 | public virtual float Bounce { get; set; } | ||
224 | 262 | ||
225 | /// <summary> | 263 | /// <summary> |
226 | /// Position of this actor. | 264 | /// Position of this actor. |
@@ -249,6 +287,51 @@ namespace OpenSim.Region.Physics.Manager | |||
249 | public abstract Vector3 GeometricCenter { get; } | 287 | public abstract Vector3 GeometricCenter { get; } |
250 | public abstract Vector3 CenterOfMass { get; } | 288 | public abstract Vector3 CenterOfMass { get; } |
251 | 289 | ||
290 | public virtual Vector3 OOBsize | ||
291 | { | ||
292 | get | ||
293 | { | ||
294 | Vector3 s=Size; | ||
295 | s.X *=0.5f; | ||
296 | s.Y *=0.5f; | ||
297 | s.Z *=0.5f; | ||
298 | return s; | ||
299 | } | ||
300 | } | ||
301 | |||
302 | public virtual Vector3 OOBoffset | ||
303 | { | ||
304 | get | ||
305 | { | ||
306 | return Vector3.Zero; | ||
307 | } | ||
308 | } | ||
309 | |||
310 | public virtual float OOBRadiusSQ | ||
311 | { | ||
312 | get | ||
313 | { | ||
314 | return Size.LengthSquared() * 0.25f; // ((0.5^2) | ||
315 | } | ||
316 | } | ||
317 | |||
318 | |||
319 | public virtual float PhysicsCost | ||
320 | { | ||
321 | get | ||
322 | { | ||
323 | return 0.1f; | ||
324 | } | ||
325 | } | ||
326 | |||
327 | public virtual float StreamCost | ||
328 | { | ||
329 | get | ||
330 | { | ||
331 | return 1.0f; | ||
332 | } | ||
333 | } | ||
334 | |||
252 | /// <summary> | 335 | /// <summary> |
253 | /// Velocity of this actor. | 336 | /// Velocity of this actor. |
254 | /// </summary> | 337 | /// </summary> |
@@ -306,13 +389,21 @@ namespace OpenSim.Region.Physics.Manager | |||
306 | public abstract void SubscribeEvents(int ms); | 389 | public abstract void SubscribeEvents(int ms); |
307 | public abstract void UnSubscribeEvents(); | 390 | public abstract void UnSubscribeEvents(); |
308 | public abstract bool SubscribedEvents(); | 391 | public abstract bool SubscribedEvents(); |
392 | |||
393 | public virtual void AddCollisionEvent(uint CollidedWith, ContactPoint contact) { } | ||
394 | |||
395 | // Warning in a parent part it returns itself, not null | ||
396 | public virtual PhysicsActor ParentActor { get { return this; } } | ||
397 | |||
309 | } | 398 | } |
310 | 399 | ||
311 | public class NullPhysicsActor : PhysicsActor | 400 | public class NullPhysicsActor : PhysicsActor |
312 | { | 401 | { |
402 | private ActorTypes m_actorType = ActorTypes.Unknown; | ||
403 | |||
313 | public override bool Stopped | 404 | public override bool Stopped |
314 | { | 405 | { |
315 | get{ return false; } | 406 | get{ return true; } |
316 | } | 407 | } |
317 | 408 | ||
318 | public override Vector3 Position | 409 | public override Vector3 Position |
@@ -329,6 +420,7 @@ namespace OpenSim.Region.Physics.Manager | |||
329 | 420 | ||
330 | public override uint LocalID | 421 | public override uint LocalID |
331 | { | 422 | { |
423 | get { return 0; } | ||
332 | set { return; } | 424 | set { return; } |
333 | } | 425 | } |
334 | 426 | ||
@@ -388,50 +480,17 @@ namespace OpenSim.Region.Physics.Manager | |||
388 | set { return; } | 480 | set { return; } |
389 | } | 481 | } |
390 | 482 | ||
391 | public override void VehicleFloatParam(int param, float value) | 483 | public override void VehicleFloatParam(int param, float value) {} |
392 | { | 484 | public override void VehicleVectorParam(int param, Vector3 value) { } |
393 | 485 | public override void VehicleRotationParam(int param, Quaternion rotation) { } | |
394 | } | 486 | public override void VehicleFlags(int param, bool remove) { } |
487 | public override void SetVolumeDetect(int param) {} | ||
488 | public override void SetMaterial(int material) {} | ||
489 | public override Vector3 CenterOfMass { get { return Vector3.Zero; }} | ||
395 | 490 | ||
396 | public override void VehicleVectorParam(int param, Vector3 value) | 491 | public override Vector3 GeometricCenter { get { return Vector3.Zero; }} |
397 | { | ||
398 | 492 | ||
399 | } | 493 | public override PrimitiveBaseShape Shape { set { return; }} |
400 | |||
401 | public override void VehicleRotationParam(int param, Quaternion rotation) | ||
402 | { | ||
403 | |||
404 | } | ||
405 | |||
406 | public override void VehicleFlags(int param, bool remove) | ||
407 | { | ||
408 | |||
409 | } | ||
410 | |||
411 | public override void SetVolumeDetect(int param) | ||
412 | { | ||
413 | |||
414 | } | ||
415 | |||
416 | public override void SetMaterial(int material) | ||
417 | { | ||
418 | |||
419 | } | ||
420 | |||
421 | public override Vector3 CenterOfMass | ||
422 | { | ||
423 | get { return Vector3.Zero; } | ||
424 | } | ||
425 | |||
426 | public override Vector3 GeometricCenter | ||
427 | { | ||
428 | get { return Vector3.Zero; } | ||
429 | } | ||
430 | |||
431 | public override PrimitiveBaseShape Shape | ||
432 | { | ||
433 | set { return; } | ||
434 | } | ||
435 | 494 | ||
436 | public override Vector3 Velocity | 495 | public override Vector3 Velocity |
437 | { | 496 | { |
@@ -451,9 +510,7 @@ namespace OpenSim.Region.Physics.Manager | |||
451 | set { } | 510 | set { } |
452 | } | 511 | } |
453 | 512 | ||
454 | public override void CrossingFailure() | 513 | public override void CrossingFailure() {} |
455 | { | ||
456 | } | ||
457 | 514 | ||
458 | public override Quaternion Orientation | 515 | public override Quaternion Orientation |
459 | { | 516 | { |
@@ -493,8 +550,20 @@ namespace OpenSim.Region.Physics.Manager | |||
493 | 550 | ||
494 | public override int PhysicsActorType | 551 | public override int PhysicsActorType |
495 | { | 552 | { |
496 | get { return (int) ActorTypes.Unknown; } | 553 | get { return (int)m_actorType; } |
497 | set { return; } | 554 | set { |
555 | ActorTypes type = (ActorTypes)value; | ||
556 | switch (type) | ||
557 | { | ||
558 | case ActorTypes.Ground: | ||
559 | case ActorTypes.Water: | ||
560 | m_actorType = type; | ||
561 | break; | ||
562 | default: | ||
563 | m_actorType = ActorTypes.Unknown; | ||
564 | break; | ||
565 | } | ||
566 | } | ||
498 | } | 567 | } |
499 | 568 | ||
500 | public override bool Kinematic | 569 | public override bool Kinematic |
@@ -503,26 +572,11 @@ namespace OpenSim.Region.Physics.Manager | |||
503 | set { return; } | 572 | set { return; } |
504 | } | 573 | } |
505 | 574 | ||
506 | public override void link(PhysicsActor obj) | 575 | public override void link(PhysicsActor obj) { } |
507 | { | 576 | public override void delink() { } |
508 | } | 577 | public override void LockAngularMotion(Vector3 axis) { } |
509 | 578 | public override void AddForce(Vector3 force, bool pushforce) { } | |
510 | public override void delink() | 579 | public override void AddAngularForce(Vector3 force, bool pushforce) { } |
511 | { | ||
512 | } | ||
513 | |||
514 | public override void LockAngularMotion(Vector3 axis) | ||
515 | { | ||
516 | } | ||
517 | |||
518 | public override void AddForce(Vector3 force, bool pushforce) | ||
519 | { | ||
520 | } | ||
521 | |||
522 | public override void AddAngularForce(Vector3 force, bool pushforce) | ||
523 | { | ||
524 | |||
525 | } | ||
526 | 580 | ||
527 | public override Vector3 RotationalVelocity | 581 | public override Vector3 RotationalVelocity |
528 | { | 582 | { |
@@ -544,21 +598,10 @@ namespace OpenSim.Region.Physics.Manager | |||
544 | public override float APIDStrength { set { return; } } | 598 | public override float APIDStrength { set { return; } } |
545 | public override float APIDDamping { set { return; } } | 599 | public override float APIDDamping { set { return; } } |
546 | 600 | ||
547 | public override void SetMomentum(Vector3 momentum) | 601 | public override void SetMomentum(Vector3 momentum) { } |
548 | { | ||
549 | } | ||
550 | |||
551 | public override void SubscribeEvents(int ms) | ||
552 | { | ||
553 | 602 | ||
554 | } | 603 | public override void SubscribeEvents(int ms) { } |
555 | public override void UnSubscribeEvents() | 604 | public override void UnSubscribeEvents() { } |
556 | { | 605 | public override bool SubscribedEvents() { return false; } |
557 | |||
558 | } | ||
559 | public override bool SubscribedEvents() | ||
560 | { | ||
561 | return false; | ||
562 | } | ||
563 | } | 606 | } |
564 | } | 607 | } |