aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorRobert Adams2013-07-16 09:59:52 -0700
committerRobert Adams2013-07-22 10:27:18 -0700
commitacb7b4a09ad564d1dfae3ad12adbb593ca3942c9 (patch)
tree2e878e0abb0811db75d59a11e34f7479196ae1c4 /OpenSim
parentBulletSim: move collision processing for linksets from BSPrimLinkable (diff)
downloadopensim-SC_OLD-acb7b4a09ad564d1dfae3ad12adbb593ca3942c9.zip
opensim-SC_OLD-acb7b4a09ad564d1dfae3ad12adbb593ca3942c9.tar.gz
opensim-SC_OLD-acb7b4a09ad564d1dfae3ad12adbb593ca3942c9.tar.bz2
opensim-SC_OLD-acb7b4a09ad564d1dfae3ad12adbb593ca3942c9.tar.xz
BulletSim: only create vehicle prim actor when vehicles are enabled.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs43
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs2
2 files changed, 33 insertions, 12 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);
diff --git a/OpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs b/OpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs
index 48d3742..48e74eb 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs
@@ -116,7 +116,7 @@ public class BasicVehicles : OpenSimTestCase
116 // Instead the appropriate values are set and calls are made just the parts of the 116 // Instead the appropriate values are set and calls are made just the parts of the
117 // controller we want to exercise. Stepping the physics engine then applies 117 // controller we want to exercise. Stepping the physics engine then applies
118 // the actions of that one feature. 118 // the actions of that one feature.
119 BSDynamics vehicleActor = TestVehicle.GetVehicleActor(); 119 BSDynamics vehicleActor = TestVehicle.GetVehicleActor(true /* createIfNone */);
120 if (vehicleActor != null) 120 if (vehicleActor != null)
121 { 121 {
122 vehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_EFFICIENCY, efficiency); 122 vehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_EFFICIENCY, efficiency);