diff options
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 43 |
1 files changed, 32 insertions, 11 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 4771934..fdb2925 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |||
@@ -96,7 +96,7 @@ public class BSPrim : BSPhysObject | |||
96 | _isVolumeDetect = false; | 96 | _isVolumeDetect = false; |
97 | 97 | ||
98 | // Add a dynamic vehicle to our set of actors that can move this prim. | 98 | // Add a dynamic vehicle to our set of actors that can move this prim. |
99 | PhysicalActors.Add(VehicleActorName, new BSDynamics(PhysScene, this, VehicleActorName)); | 99 | // PhysicalActors.Add(VehicleActorName, new BSDynamics(PhysScene, this, VehicleActorName)); |
100 | 100 | ||
101 | _mass = CalculateMass(); | 101 | _mass = CalculateMass(); |
102 | 102 | ||
@@ -497,7 +497,7 @@ public class BSPrim : BSPhysObject | |||
497 | 497 | ||
498 | // Find and return a handle to the current vehicle actor. | 498 | // Find and return a handle to the current vehicle actor. |
499 | // Return 'null' if there is no vehicle actor. | 499 | // Return 'null' if there is no vehicle actor. |
500 | public BSDynamics GetVehicleActor() | 500 | public BSDynamics GetVehicleActor(bool createIfNone) |
501 | { | 501 | { |
502 | BSDynamics ret = null; | 502 | BSDynamics ret = null; |
503 | BSActor actor; | 503 | BSActor actor; |
@@ -505,13 +505,21 @@ public class BSPrim : BSPhysObject | |||
505 | { | 505 | { |
506 | ret = actor as BSDynamics; | 506 | ret = actor as BSDynamics; |
507 | } | 507 | } |
508 | else | ||
509 | { | ||
510 | if (createIfNone) | ||
511 | { | ||
512 | ret = new BSDynamics(PhysScene, this, VehicleActorName); | ||
513 | PhysicalActors.Add(ret.ActorName, ret); | ||
514 | } | ||
515 | } | ||
508 | return ret; | 516 | return ret; |
509 | } | 517 | } |
510 | 518 | ||
511 | public override int VehicleType { | 519 | public override int VehicleType { |
512 | get { | 520 | get { |
513 | int ret = (int)Vehicle.TYPE_NONE; | 521 | int ret = (int)Vehicle.TYPE_NONE; |
514 | BSDynamics vehicleActor = GetVehicleActor(); | 522 | BSDynamics vehicleActor = GetVehicleActor(false /* createIfNone */); |
515 | if (vehicleActor != null) | 523 | if (vehicleActor != null) |
516 | ret = (int)vehicleActor.Type; | 524 | ret = (int)vehicleActor.Type; |
517 | return ret; | 525 | return ret; |
@@ -525,11 +533,24 @@ public class BSPrim : BSPhysObject | |||
525 | // change all the parameters. Like a plane changing to CAR when on the | 533 | // change all the parameters. Like a plane changing to CAR when on the |
526 | // ground. In this case, don't want to zero motion. | 534 | // ground. In this case, don't want to zero motion. |
527 | // ZeroMotion(true /* inTaintTime */); | 535 | // ZeroMotion(true /* inTaintTime */); |
528 | BSDynamics vehicleActor = GetVehicleActor(); | 536 | if (type == Vehicle.TYPE_NONE) |
529 | if (vehicleActor != null) | ||
530 | { | 537 | { |
531 | vehicleActor.ProcessTypeChange(type); | 538 | // Vehicle type is 'none' so get rid of any actor that may have been allocated. |
532 | ActivateIfPhysical(false); | 539 | BSDynamics vehicleActor = GetVehicleActor(false /* createIfNone */); |
540 | if (vehicleActor != null) | ||
541 | { | ||
542 | PhysicalActors.RemoveAndRelease(vehicleActor.ActorName); | ||
543 | } | ||
544 | } | ||
545 | else | ||
546 | { | ||
547 | // Vehicle type is not 'none' so create an actor and set it running. | ||
548 | BSDynamics vehicleActor = GetVehicleActor(true /* createIfNone */); | ||
549 | if (vehicleActor != null) | ||
550 | { | ||
551 | vehicleActor.ProcessTypeChange(type); | ||
552 | ActivateIfPhysical(false); | ||
553 | } | ||
533 | } | 554 | } |
534 | }); | 555 | }); |
535 | } | 556 | } |
@@ -538,7 +559,7 @@ public class BSPrim : BSPhysObject | |||
538 | { | 559 | { |
539 | PhysScene.TaintedObject("BSPrim.VehicleFloatParam", delegate() | 560 | PhysScene.TaintedObject("BSPrim.VehicleFloatParam", delegate() |
540 | { | 561 | { |
541 | BSDynamics vehicleActor = GetVehicleActor(); | 562 | BSDynamics vehicleActor = GetVehicleActor(true /* createIfNone */); |
542 | if (vehicleActor != null) | 563 | if (vehicleActor != null) |
543 | { | 564 | { |
544 | vehicleActor.ProcessFloatVehicleParam((Vehicle)param, value); | 565 | vehicleActor.ProcessFloatVehicleParam((Vehicle)param, value); |
@@ -550,7 +571,7 @@ public class BSPrim : BSPhysObject | |||
550 | { | 571 | { |
551 | PhysScene.TaintedObject("BSPrim.VehicleVectorParam", delegate() | 572 | PhysScene.TaintedObject("BSPrim.VehicleVectorParam", delegate() |
552 | { | 573 | { |
553 | BSDynamics vehicleActor = GetVehicleActor(); | 574 | BSDynamics vehicleActor = GetVehicleActor(true /* createIfNone */); |
554 | if (vehicleActor != null) | 575 | if (vehicleActor != null) |
555 | { | 576 | { |
556 | vehicleActor.ProcessVectorVehicleParam((Vehicle)param, value); | 577 | vehicleActor.ProcessVectorVehicleParam((Vehicle)param, value); |
@@ -562,7 +583,7 @@ public class BSPrim : BSPhysObject | |||
562 | { | 583 | { |
563 | PhysScene.TaintedObject("BSPrim.VehicleRotationParam", delegate() | 584 | PhysScene.TaintedObject("BSPrim.VehicleRotationParam", delegate() |
564 | { | 585 | { |
565 | BSDynamics vehicleActor = GetVehicleActor(); | 586 | BSDynamics vehicleActor = GetVehicleActor(true /* createIfNone */); |
566 | if (vehicleActor != null) | 587 | if (vehicleActor != null) |
567 | { | 588 | { |
568 | vehicleActor.ProcessRotationVehicleParam((Vehicle)param, rotation); | 589 | vehicleActor.ProcessRotationVehicleParam((Vehicle)param, rotation); |
@@ -574,7 +595,7 @@ public class BSPrim : BSPhysObject | |||
574 | { | 595 | { |
575 | PhysScene.TaintedObject("BSPrim.VehicleFlags", delegate() | 596 | PhysScene.TaintedObject("BSPrim.VehicleFlags", delegate() |
576 | { | 597 | { |
577 | BSDynamics vehicleActor = GetVehicleActor(); | 598 | BSDynamics vehicleActor = GetVehicleActor(true /* createIfNone */); |
578 | if (vehicleActor != null) | 599 | if (vehicleActor != null) |
579 | { | 600 | { |
580 | vehicleActor.ProcessVehicleFlags(param, remove); | 601 | vehicleActor.ProcessVehicleFlags(param, remove); |