diff options
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 52 |
1 files changed, 37 insertions, 15 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index d43448e..e92a1d2 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 | ||
@@ -440,8 +440,8 @@ public class BSPrim : BSPhysObject | |||
440 | Gravity = ComputeGravity(Buoyancy); | 440 | Gravity = ComputeGravity(Buoyancy); |
441 | PhysScene.PE.SetGravity(PhysBody, Gravity); | 441 | PhysScene.PE.SetGravity(PhysBody, Gravity); |
442 | 442 | ||
443 | OMV.Vector3 currentScale = PhysScene.PE.GetLocalScaling(PhysShape.physShapeInfo); // DEBUG DEBUG | 443 | // OMV.Vector3 currentScale = PhysScene.PE.GetLocalScaling(PhysShape.physShapeInfo); // DEBUG DEBUG |
444 | DetailLog("{0},BSPrim.UpdateMassProperties,currentScale{1},shape={2}", LocalID, currentScale, PhysShape.physShapeInfo); // DEBUG DEBUG | 444 | // DetailLog("{0},BSPrim.UpdateMassProperties,currentScale{1},shape={2}", LocalID, currentScale, PhysShape.physShapeInfo); // DEBUG DEBUG |
445 | 445 | ||
446 | Inertia = PhysScene.PE.CalculateLocalInertia(PhysShape.physShapeInfo, physMass); | 446 | Inertia = PhysScene.PE.CalculateLocalInertia(PhysShape.physShapeInfo, physMass); |
447 | PhysScene.PE.SetMassProps(PhysBody, physMass, Inertia); | 447 | PhysScene.PE.SetMassProps(PhysBody, physMass, Inertia); |
@@ -495,9 +495,9 @@ public class BSPrim : BSPhysObject | |||
495 | } | 495 | } |
496 | } | 496 | } |
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,12 +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 | } |
518 | |||
510 | public override int VehicleType { | 519 | public override int VehicleType { |
511 | get { | 520 | get { |
512 | int ret = (int)Vehicle.TYPE_NONE; | 521 | int ret = (int)Vehicle.TYPE_NONE; |
513 | BSDynamics vehicleActor = GetVehicleActor(); | 522 | BSDynamics vehicleActor = GetVehicleActor(false /* createIfNone */); |
514 | if (vehicleActor != null) | 523 | if (vehicleActor != null) |
515 | ret = (int)vehicleActor.Type; | 524 | ret = (int)vehicleActor.Type; |
516 | return ret; | 525 | return ret; |
@@ -524,11 +533,24 @@ public class BSPrim : BSPhysObject | |||
524 | // 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 |
525 | // ground. In this case, don't want to zero motion. | 534 | // ground. In this case, don't want to zero motion. |
526 | // ZeroMotion(true /* inTaintTime */); | 535 | // ZeroMotion(true /* inTaintTime */); |
527 | BSDynamics vehicleActor = GetVehicleActor(); | 536 | if (type == Vehicle.TYPE_NONE) |
528 | if (vehicleActor != null) | ||
529 | { | 537 | { |
530 | vehicleActor.ProcessTypeChange(type); | 538 | // Vehicle type is 'none' so get rid of any actor that may have been allocated. |
531 | 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 | } | ||
532 | } | 554 | } |
533 | }); | 555 | }); |
534 | } | 556 | } |
@@ -537,7 +559,7 @@ public class BSPrim : BSPhysObject | |||
537 | { | 559 | { |
538 | PhysScene.TaintedObject("BSPrim.VehicleFloatParam", delegate() | 560 | PhysScene.TaintedObject("BSPrim.VehicleFloatParam", delegate() |
539 | { | 561 | { |
540 | BSDynamics vehicleActor = GetVehicleActor(); | 562 | BSDynamics vehicleActor = GetVehicleActor(true /* createIfNone */); |
541 | if (vehicleActor != null) | 563 | if (vehicleActor != null) |
542 | { | 564 | { |
543 | vehicleActor.ProcessFloatVehicleParam((Vehicle)param, value); | 565 | vehicleActor.ProcessFloatVehicleParam((Vehicle)param, value); |
@@ -549,7 +571,7 @@ public class BSPrim : BSPhysObject | |||
549 | { | 571 | { |
550 | PhysScene.TaintedObject("BSPrim.VehicleVectorParam", delegate() | 572 | PhysScene.TaintedObject("BSPrim.VehicleVectorParam", delegate() |
551 | { | 573 | { |
552 | BSDynamics vehicleActor = GetVehicleActor(); | 574 | BSDynamics vehicleActor = GetVehicleActor(true /* createIfNone */); |
553 | if (vehicleActor != null) | 575 | if (vehicleActor != null) |
554 | { | 576 | { |
555 | vehicleActor.ProcessVectorVehicleParam((Vehicle)param, value); | 577 | vehicleActor.ProcessVectorVehicleParam((Vehicle)param, value); |
@@ -561,7 +583,7 @@ public class BSPrim : BSPhysObject | |||
561 | { | 583 | { |
562 | PhysScene.TaintedObject("BSPrim.VehicleRotationParam", delegate() | 584 | PhysScene.TaintedObject("BSPrim.VehicleRotationParam", delegate() |
563 | { | 585 | { |
564 | BSDynamics vehicleActor = GetVehicleActor(); | 586 | BSDynamics vehicleActor = GetVehicleActor(true /* createIfNone */); |
565 | if (vehicleActor != null) | 587 | if (vehicleActor != null) |
566 | { | 588 | { |
567 | vehicleActor.ProcessRotationVehicleParam((Vehicle)param, rotation); | 589 | vehicleActor.ProcessRotationVehicleParam((Vehicle)param, rotation); |
@@ -573,7 +595,7 @@ public class BSPrim : BSPhysObject | |||
573 | { | 595 | { |
574 | PhysScene.TaintedObject("BSPrim.VehicleFlags", delegate() | 596 | PhysScene.TaintedObject("BSPrim.VehicleFlags", delegate() |
575 | { | 597 | { |
576 | BSDynamics vehicleActor = GetVehicleActor(); | 598 | BSDynamics vehicleActor = GetVehicleActor(true /* createIfNone */); |
577 | if (vehicleActor != null) | 599 | if (vehicleActor != null) |
578 | { | 600 | { |
579 | vehicleActor.ProcessVehicleFlags(param, remove); | 601 | vehicleActor.ProcessVehicleFlags(param, remove); |