diff options
Diffstat (limited to 'OpenSim/Region/Physics/Manager/PhysicsActor.cs')
-rw-r--r-- | OpenSim/Region/Physics/Manager/PhysicsActor.cs | 228 |
1 files changed, 142 insertions, 86 deletions
diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index bd806eb..7cd364b 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,41 @@ 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; | ||
64 | public bool CharacterFeet; | ||
62 | 65 | ||
63 | public ContactPoint(Vector3 position, Vector3 surfaceNormal, float penetrationDepth) | 66 | public ContactPoint(Vector3 position, Vector3 surfaceNormal, float penetrationDepth) |
64 | { | 67 | { |
65 | Position = position; | 68 | Position = position; |
66 | SurfaceNormal = surfaceNormal; | 69 | SurfaceNormal = surfaceNormal; |
67 | PenetrationDepth = penetrationDepth; | 70 | PenetrationDepth = penetrationDepth; |
71 | RelativeSpeed = 0f; // for now let this one be set explicity | ||
72 | CharacterFeet = true; // keep other plugins work as before | ||
73 | } | ||
74 | |||
75 | public ContactPoint(Vector3 position, Vector3 surfaceNormal, float penetrationDepth, bool feet) | ||
76 | { | ||
77 | Position = position; | ||
78 | SurfaceNormal = surfaceNormal; | ||
79 | PenetrationDepth = penetrationDepth; | ||
80 | RelativeSpeed = 0f; // for now let this one be set explicity | ||
81 | CharacterFeet = feet; // keep other plugins work as before | ||
68 | } | 82 | } |
69 | } | 83 | } |
70 | 84 | ||
85 | public struct ContactData | ||
86 | { | ||
87 | public float mu; | ||
88 | public float bounce; | ||
89 | public bool softcolide; | ||
90 | |||
91 | public ContactData(float _mu, float _bounce, bool _softcolide) | ||
92 | { | ||
93 | mu = _mu; | ||
94 | bounce = _bounce; | ||
95 | softcolide = _softcolide; | ||
96 | } | ||
97 | } | ||
71 | /// <summary> | 98 | /// <summary> |
72 | /// Used to pass collision information to OnCollisionUpdate listeners. | 99 | /// Used to pass collision information to OnCollisionUpdate listeners. |
73 | /// </summary> | 100 | /// </summary> |
@@ -99,7 +126,7 @@ namespace OpenSim.Region.Physics.Manager | |||
99 | m_objCollisionList.Add(localID, contact); | 126 | m_objCollisionList.Add(localID, contact); |
100 | } | 127 | } |
101 | else | 128 | else |
102 | { | 129 | { |
103 | if (m_objCollisionList[localID].PenetrationDepth < contact.PenetrationDepth) | 130 | if (m_objCollisionList[localID].PenetrationDepth < contact.PenetrationDepth) |
104 | m_objCollisionList[localID] = contact; | 131 | m_objCollisionList[localID] = contact; |
105 | } | 132 | } |
@@ -135,6 +162,8 @@ namespace OpenSim.Region.Physics.Manager | |||
135 | /// </summary> | 162 | /// </summary> |
136 | public event CollisionUpdate OnCollisionUpdate; | 163 | public event CollisionUpdate OnCollisionUpdate; |
137 | 164 | ||
165 | public virtual void SetVehicle(object vdata) { } | ||
166 | |||
138 | public event OutOfBounds OnOutOfBounds; | 167 | public event OutOfBounds OnOutOfBounds; |
139 | #pragma warning restore 67 | 168 | #pragma warning restore 67 |
140 | 169 | ||
@@ -142,11 +171,32 @@ namespace OpenSim.Region.Physics.Manager | |||
142 | { | 171 | { |
143 | get { return new NullPhysicsActor(); } | 172 | get { return new NullPhysicsActor(); } |
144 | } | 173 | } |
174 | |||
175 | public virtual bool Building { get; set; } | ||
176 | |||
177 | public virtual void getContactData(ref ContactData cdata) | ||
178 | { | ||
179 | cdata.mu = 0; | ||
180 | cdata.bounce = 0; | ||
181 | } | ||
145 | 182 | ||
146 | public abstract bool Stopped { get; } | 183 | public abstract bool Stopped { get; } |
147 | 184 | ||
148 | public abstract Vector3 Size { get; set; } | 185 | public abstract Vector3 Size { get; set; } |
149 | 186 | ||
187 | public virtual void setAvatarSize(Vector3 size, float feetOffset) | ||
188 | { | ||
189 | Size = size; | ||
190 | } | ||
191 | |||
192 | public virtual bool Phantom { get; set; } | ||
193 | |||
194 | public virtual bool IsVolumeDtc | ||
195 | { | ||
196 | get { return false; } | ||
197 | set { return; } | ||
198 | } | ||
199 | |||
150 | public virtual byte PhysicsShapeType { get; set; } | 200 | public virtual byte PhysicsShapeType { get; set; } |
151 | 201 | ||
152 | public abstract PrimitiveBaseShape Shape { set; } | 202 | public abstract PrimitiveBaseShape Shape { set; } |
@@ -169,7 +219,7 @@ namespace OpenSim.Region.Physics.Manager | |||
169 | /// XXX: Bizarrely, this cannot be "Terrain" or "Water" right now unless it really is simulating terrain or | 219 | /// 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. | 220 | /// water. This is not a problem due to the formatting of names given by prims and avatars. |
171 | /// </remarks> | 221 | /// </remarks> |
172 | public string Name { get; protected set; } | 222 | public string Name { get; set; } |
173 | 223 | ||
174 | /// <summary> | 224 | /// <summary> |
175 | /// This is being used by ODE joint code. | 225 | /// This is being used by ODE joint code. |
@@ -253,6 +303,51 @@ namespace OpenSim.Region.Physics.Manager | |||
253 | public abstract Vector3 GeometricCenter { get; } | 303 | public abstract Vector3 GeometricCenter { get; } |
254 | public abstract Vector3 CenterOfMass { get; } | 304 | public abstract Vector3 CenterOfMass { get; } |
255 | 305 | ||
306 | public virtual Vector3 OOBsize | ||
307 | { | ||
308 | get | ||
309 | { | ||
310 | Vector3 s=Size; | ||
311 | s.X *=0.5f; | ||
312 | s.Y *=0.5f; | ||
313 | s.Z *=0.5f; | ||
314 | return s; | ||
315 | } | ||
316 | } | ||
317 | |||
318 | public virtual Vector3 OOBoffset | ||
319 | { | ||
320 | get | ||
321 | { | ||
322 | return Vector3.Zero; | ||
323 | } | ||
324 | } | ||
325 | |||
326 | public virtual float OOBRadiusSQ | ||
327 | { | ||
328 | get | ||
329 | { | ||
330 | return Size.LengthSquared() * 0.25f; // ((0.5^2) | ||
331 | } | ||
332 | } | ||
333 | |||
334 | |||
335 | public virtual float PhysicsCost | ||
336 | { | ||
337 | get | ||
338 | { | ||
339 | return 0.1f; | ||
340 | } | ||
341 | } | ||
342 | |||
343 | public virtual float StreamCost | ||
344 | { | ||
345 | get | ||
346 | { | ||
347 | return 1.0f; | ||
348 | } | ||
349 | } | ||
350 | |||
256 | /// <summary> | 351 | /// <summary> |
257 | /// The desired velocity of this actor. | 352 | /// The desired velocity of this actor. |
258 | /// </summary> | 353 | /// </summary> |
@@ -313,13 +408,22 @@ namespace OpenSim.Region.Physics.Manager | |||
313 | public abstract void SubscribeEvents(int ms); | 408 | public abstract void SubscribeEvents(int ms); |
314 | public abstract void UnSubscribeEvents(); | 409 | public abstract void UnSubscribeEvents(); |
315 | public abstract bool SubscribedEvents(); | 410 | public abstract bool SubscribedEvents(); |
411 | |||
412 | public virtual void AddCollisionEvent(uint CollidedWith, ContactPoint contact) { } | ||
413 | |||
414 | // Warning in a parent part it returns itself, not null | ||
415 | public virtual PhysicsActor ParentActor { get { return this; } } | ||
416 | |||
417 | |||
316 | } | 418 | } |
317 | 419 | ||
318 | public class NullPhysicsActor : PhysicsActor | 420 | public class NullPhysicsActor : PhysicsActor |
319 | { | 421 | { |
422 | private ActorTypes m_actorType = ActorTypes.Unknown; | ||
423 | |||
320 | public override bool Stopped | 424 | public override bool Stopped |
321 | { | 425 | { |
322 | get{ return false; } | 426 | get{ return true; } |
323 | } | 427 | } |
324 | 428 | ||
325 | public override Vector3 Position | 429 | public override Vector3 Position |
@@ -336,6 +440,7 @@ namespace OpenSim.Region.Physics.Manager | |||
336 | 440 | ||
337 | public override uint LocalID | 441 | public override uint LocalID |
338 | { | 442 | { |
443 | get { return 0; } | ||
339 | set { return; } | 444 | set { return; } |
340 | } | 445 | } |
341 | 446 | ||
@@ -395,50 +500,17 @@ namespace OpenSim.Region.Physics.Manager | |||
395 | set { return; } | 500 | set { return; } |
396 | } | 501 | } |
397 | 502 | ||
398 | public override void VehicleFloatParam(int param, float value) | 503 | public override void VehicleFloatParam(int param, float value) {} |
399 | { | 504 | public override void VehicleVectorParam(int param, Vector3 value) { } |
400 | 505 | public override void VehicleRotationParam(int param, Quaternion rotation) { } | |
401 | } | 506 | public override void VehicleFlags(int param, bool remove) { } |
402 | 507 | public override void SetVolumeDetect(int param) {} | |
403 | public override void VehicleVectorParam(int param, Vector3 value) | 508 | public override void SetMaterial(int material) {} |
404 | { | 509 | public override Vector3 CenterOfMass { get { return Vector3.Zero; }} |
405 | |||
406 | } | ||
407 | |||
408 | public override void VehicleRotationParam(int param, Quaternion rotation) | ||
409 | { | ||
410 | 510 | ||
411 | } | 511 | public override Vector3 GeometricCenter { get { return Vector3.Zero; }} |
412 | |||
413 | public override void VehicleFlags(int param, bool remove) | ||
414 | { | ||
415 | |||
416 | } | ||
417 | |||
418 | public override void SetVolumeDetect(int param) | ||
419 | { | ||
420 | |||
421 | } | ||
422 | 512 | ||
423 | public override void SetMaterial(int material) | 513 | public override PrimitiveBaseShape Shape { set { return; }} |
424 | { | ||
425 | |||
426 | } | ||
427 | |||
428 | public override Vector3 CenterOfMass | ||
429 | { | ||
430 | get { return Vector3.Zero; } | ||
431 | } | ||
432 | |||
433 | public override Vector3 GeometricCenter | ||
434 | { | ||
435 | get { return Vector3.Zero; } | ||
436 | } | ||
437 | |||
438 | public override PrimitiveBaseShape Shape | ||
439 | { | ||
440 | set { return; } | ||
441 | } | ||
442 | 514 | ||
443 | public override Vector3 Velocity | 515 | public override Vector3 Velocity |
444 | { | 516 | { |
@@ -458,9 +530,7 @@ namespace OpenSim.Region.Physics.Manager | |||
458 | set { } | 530 | set { } |
459 | } | 531 | } |
460 | 532 | ||
461 | public override void CrossingFailure() | 533 | public override void CrossingFailure() {} |
462 | { | ||
463 | } | ||
464 | 534 | ||
465 | public override Quaternion Orientation | 535 | public override Quaternion Orientation |
466 | { | 536 | { |
@@ -500,8 +570,20 @@ namespace OpenSim.Region.Physics.Manager | |||
500 | 570 | ||
501 | public override int PhysicsActorType | 571 | public override int PhysicsActorType |
502 | { | 572 | { |
503 | get { return (int) ActorTypes.Unknown; } | 573 | get { return (int)m_actorType; } |
504 | set { return; } | 574 | set { |
575 | ActorTypes type = (ActorTypes)value; | ||
576 | switch (type) | ||
577 | { | ||
578 | case ActorTypes.Ground: | ||
579 | case ActorTypes.Water: | ||
580 | m_actorType = type; | ||
581 | break; | ||
582 | default: | ||
583 | m_actorType = ActorTypes.Unknown; | ||
584 | break; | ||
585 | } | ||
586 | } | ||
505 | } | 587 | } |
506 | 588 | ||
507 | public override bool Kinematic | 589 | public override bool Kinematic |
@@ -510,26 +592,11 @@ namespace OpenSim.Region.Physics.Manager | |||
510 | set { return; } | 592 | set { return; } |
511 | } | 593 | } |
512 | 594 | ||
513 | public override void link(PhysicsActor obj) | 595 | public override void link(PhysicsActor obj) { } |
514 | { | 596 | public override void delink() { } |
515 | } | 597 | public override void LockAngularMotion(Vector3 axis) { } |
516 | 598 | public override void AddForce(Vector3 force, bool pushforce) { } | |
517 | public override void delink() | 599 | public override void AddAngularForce(Vector3 force, bool pushforce) { } |
518 | { | ||
519 | } | ||
520 | |||
521 | public override void LockAngularMotion(Vector3 axis) | ||
522 | { | ||
523 | } | ||
524 | |||
525 | public override void AddForce(Vector3 force, bool pushforce) | ||
526 | { | ||
527 | } | ||
528 | |||
529 | public override void AddAngularForce(Vector3 force, bool pushforce) | ||
530 | { | ||
531 | |||
532 | } | ||
533 | 600 | ||
534 | public override Vector3 RotationalVelocity | 601 | public override Vector3 RotationalVelocity |
535 | { | 602 | { |
@@ -551,21 +618,10 @@ namespace OpenSim.Region.Physics.Manager | |||
551 | public override float APIDStrength { set { return; } } | 618 | public override float APIDStrength { set { return; } } |
552 | public override float APIDDamping { set { return; } } | 619 | public override float APIDDamping { set { return; } } |
553 | 620 | ||
554 | public override void SetMomentum(Vector3 momentum) | 621 | public override void SetMomentum(Vector3 momentum) { } |
555 | { | ||
556 | } | ||
557 | |||
558 | public override void SubscribeEvents(int ms) | ||
559 | { | ||
560 | |||
561 | } | ||
562 | public override void UnSubscribeEvents() | ||
563 | { | ||
564 | 622 | ||
565 | } | 623 | public override void SubscribeEvents(int ms) { } |
566 | public override bool SubscribedEvents() | 624 | public override void UnSubscribeEvents() { } |
567 | { | 625 | public override bool SubscribedEvents() { return false; } |
568 | return false; | ||
569 | } | ||
570 | } | 626 | } |
571 | } | 627 | } |