BulletSim: remove the handle to the vehicle actor and cause routines

that need it to look it up.
cpu-performance
Robert Adams 2013-06-30 17:06:27 -07:00
parent 425d2a2a97
commit 9d5ae75950
2 changed files with 69 additions and 31 deletions

View File

@ -70,18 +70,17 @@ public class BSPrim : BSPhysObject
private int CrossingFailures { get; set; }
// Keep a handle to the vehicle actor so it is easy to set parameters on same.
public BSDynamics VehicleActor;
public const string VehicleActorName = "BasicVehicle";
// Parameters for the hover actor
public const string HoverActorName = "HoverActor";
public const string HoverActorName = "BSPrim.HoverActor";
// Parameters for the axis lock actor
public const String LockedAxisActorName = "BSPrim.LockedAxis";
// Parameters for the move to target actor
public const string MoveToTargetActorName = "MoveToTargetActor";
public const string MoveToTargetActorName = "BSPrim.MoveToTargetActor";
// Parameters for the setForce and setTorque actors
public const string SetForceActorName = "SetForceActor";
public const string SetTorqueActorName = "SetTorqueActor";
public const string SetForceActorName = "BSPrim.SetForceActor";
public const string SetTorqueActorName = "BSPrim.SetTorqueActor";
public BSPrim(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size,
OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical)
@ -100,9 +99,8 @@ public class BSPrim : BSPhysObject
_isPhysical = pisPhysical;
_isVolumeDetect = false;
// We keep a handle to the vehicle actor so we can set vehicle parameters later.
VehicleActor = new BSDynamics(PhysScene, this, VehicleActorName);
PhysicalActors.Add(VehicleActorName, VehicleActor);
// Add a dynamic vehicle to our set of actors that can move this prim.
PhysicalActors.Add(VehicleActorName, new BSDynamics(PhysScene, this, VehicleActorName));
_mass = CalculateMass();
@ -505,9 +503,25 @@ public class BSPrim : BSPhysObject
}
}
// Find and return a handle to the current vehicle actor.
// Return 'null' if there is no vehicle actor.
public BSDynamics GetVehicleActor()
{
BSDynamics ret = null;
BSActor actor;
if (PhysicalActors.TryGetActor(VehicleActorName, out actor))
{
ret = actor as BSDynamics;
}
return ret;
}
public override int VehicleType {
get {
return (int)VehicleActor.Type;
int ret = (int)Vehicle.TYPE_NONE;
BSDynamics vehicleActor = GetVehicleActor();
if (vehicleActor != null)
ret = (int)vehicleActor.Type;
return ret;
}
set {
Vehicle type = (Vehicle)value;
@ -518,8 +532,12 @@ public class BSPrim : BSPhysObject
// change all the parameters. Like a plane changing to CAR when on the
// ground. In this case, don't want to zero motion.
// ZeroMotion(true /* inTaintTime */);
VehicleActor.ProcessTypeChange(type);
ActivateIfPhysical(false);
BSDynamics vehicleActor = GetVehicleActor();
if (vehicleActor != null)
{
vehicleActor.ProcessTypeChange(type);
ActivateIfPhysical(false);
}
});
}
}
@ -527,31 +545,47 @@ public class BSPrim : BSPhysObject
{
PhysScene.TaintedObject("BSPrim.VehicleFloatParam", delegate()
{
VehicleActor.ProcessFloatVehicleParam((Vehicle)param, value);
ActivateIfPhysical(false);
BSDynamics vehicleActor = GetVehicleActor();
if (vehicleActor != null)
{
vehicleActor.ProcessFloatVehicleParam((Vehicle)param, value);
ActivateIfPhysical(false);
}
});
}
public override void VehicleVectorParam(int param, OMV.Vector3 value)
{
PhysScene.TaintedObject("BSPrim.VehicleVectorParam", delegate()
{
VehicleActor.ProcessVectorVehicleParam((Vehicle)param, value);
ActivateIfPhysical(false);
BSDynamics vehicleActor = GetVehicleActor();
if (vehicleActor != null)
{
vehicleActor.ProcessVectorVehicleParam((Vehicle)param, value);
ActivateIfPhysical(false);
}
});
}
public override void VehicleRotationParam(int param, OMV.Quaternion rotation)
{
PhysScene.TaintedObject("BSPrim.VehicleRotationParam", delegate()
{
VehicleActor.ProcessRotationVehicleParam((Vehicle)param, rotation);
ActivateIfPhysical(false);
BSDynamics vehicleActor = GetVehicleActor();
if (vehicleActor != null)
{
vehicleActor.ProcessRotationVehicleParam((Vehicle)param, rotation);
ActivateIfPhysical(false);
}
});
}
public override void VehicleFlags(int param, bool remove)
{
PhysScene.TaintedObject("BSPrim.VehicleFlags", delegate()
{
VehicleActor.ProcessVehicleFlags(param, remove);
BSDynamics vehicleActor = GetVehicleActor();
if (vehicleActor != null)
{
vehicleActor.ProcessVehicleFlags(param, remove);
}
});
}

View File

@ -114,21 +114,25 @@ public class BasicVehicles : OpenSimTestCase
// Instead the appropriate values are set and calls are made just the parts of the
// controller we want to exercise. Stepping the physics engine then applies
// the actions of that one feature.
TestVehicle.VehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_EFFICIENCY, efficiency);
TestVehicle.VehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_TIMESCALE, timeScale);
TestVehicle.VehicleActor.enableAngularVerticalAttraction = true;
TestVehicle.IsPhysical = true;
PhysicsScene.ProcessTaints();
// Step the simulator a bunch of times and vertical attraction should orient the vehicle up
for (int ii = 0; ii < simSteps; ii++)
BSDynamics vehicleActor = TestVehicle.GetVehicleActor();
if (vehicleActor != null)
{
TestVehicle.VehicleActor.ForgetKnownVehicleProperties();
TestVehicle.VehicleActor.ComputeAngularVerticalAttraction();
TestVehicle.VehicleActor.PushKnownChanged();
vehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_EFFICIENCY, efficiency);
vehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_TIMESCALE, timeScale);
vehicleActor.enableAngularVerticalAttraction = true;
PhysicsScene.Simulate(simulationTimeStep);
TestVehicle.IsPhysical = true;
PhysicsScene.ProcessTaints();
// Step the simulator a bunch of times and vertical attraction should orient the vehicle up
for (int ii = 0; ii < simSteps; ii++)
{
vehicleActor.ForgetKnownVehicleProperties();
vehicleActor.ComputeAngularVerticalAttraction();
vehicleActor.PushKnownChanged();
PhysicsScene.Simulate(simulationTimeStep);
}
}
TestVehicle.IsPhysical = false;