BulletSim: remove the handle to the vehicle actor and cause routines
that need it to look it up.cpu-performance
parent
425d2a2a97
commit
9d5ae75950
|
@ -70,18 +70,17 @@ public class BSPrim : BSPhysObject
|
||||||
private int CrossingFailures { get; set; }
|
private int CrossingFailures { get; set; }
|
||||||
|
|
||||||
// Keep a handle to the vehicle actor so it is easy to set parameters on same.
|
// Keep a handle to the vehicle actor so it is easy to set parameters on same.
|
||||||
public BSDynamics VehicleActor;
|
|
||||||
public const string VehicleActorName = "BasicVehicle";
|
public const string VehicleActorName = "BasicVehicle";
|
||||||
|
|
||||||
// Parameters for the hover actor
|
// Parameters for the hover actor
|
||||||
public const string HoverActorName = "HoverActor";
|
public const string HoverActorName = "BSPrim.HoverActor";
|
||||||
// Parameters for the axis lock actor
|
// Parameters for the axis lock actor
|
||||||
public const String LockedAxisActorName = "BSPrim.LockedAxis";
|
public const String LockedAxisActorName = "BSPrim.LockedAxis";
|
||||||
// Parameters for the move to target actor
|
// 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
|
// Parameters for the setForce and setTorque actors
|
||||||
public const string SetForceActorName = "SetForceActor";
|
public const string SetForceActorName = "BSPrim.SetForceActor";
|
||||||
public const string SetTorqueActorName = "SetTorqueActor";
|
public const string SetTorqueActorName = "BSPrim.SetTorqueActor";
|
||||||
|
|
||||||
public BSPrim(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size,
|
public BSPrim(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size,
|
||||||
OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical)
|
OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical)
|
||||||
|
@ -100,9 +99,8 @@ public class BSPrim : BSPhysObject
|
||||||
_isPhysical = pisPhysical;
|
_isPhysical = pisPhysical;
|
||||||
_isVolumeDetect = false;
|
_isVolumeDetect = false;
|
||||||
|
|
||||||
// We keep a handle to the vehicle actor so we can set vehicle parameters later.
|
// Add a dynamic vehicle to our set of actors that can move this prim.
|
||||||
VehicleActor = new BSDynamics(PhysScene, this, VehicleActorName);
|
PhysicalActors.Add(VehicleActorName, new BSDynamics(PhysScene, this, VehicleActorName));
|
||||||
PhysicalActors.Add(VehicleActorName, VehicleActor);
|
|
||||||
|
|
||||||
_mass = CalculateMass();
|
_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 {
|
public override int VehicleType {
|
||||||
get {
|
get {
|
||||||
return (int)VehicleActor.Type;
|
int ret = (int)Vehicle.TYPE_NONE;
|
||||||
|
BSDynamics vehicleActor = GetVehicleActor();
|
||||||
|
if (vehicleActor != null)
|
||||||
|
ret = (int)vehicleActor.Type;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
Vehicle type = (Vehicle)value;
|
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
|
// change all the parameters. Like a plane changing to CAR when on the
|
||||||
// ground. In this case, don't want to zero motion.
|
// ground. In this case, don't want to zero motion.
|
||||||
// ZeroMotion(true /* inTaintTime */);
|
// ZeroMotion(true /* inTaintTime */);
|
||||||
VehicleActor.ProcessTypeChange(type);
|
BSDynamics vehicleActor = GetVehicleActor();
|
||||||
|
if (vehicleActor != null)
|
||||||
|
{
|
||||||
|
vehicleActor.ProcessTypeChange(type);
|
||||||
ActivateIfPhysical(false);
|
ActivateIfPhysical(false);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -527,31 +545,47 @@ public class BSPrim : BSPhysObject
|
||||||
{
|
{
|
||||||
PhysScene.TaintedObject("BSPrim.VehicleFloatParam", delegate()
|
PhysScene.TaintedObject("BSPrim.VehicleFloatParam", delegate()
|
||||||
{
|
{
|
||||||
VehicleActor.ProcessFloatVehicleParam((Vehicle)param, value);
|
BSDynamics vehicleActor = GetVehicleActor();
|
||||||
|
if (vehicleActor != null)
|
||||||
|
{
|
||||||
|
vehicleActor.ProcessFloatVehicleParam((Vehicle)param, value);
|
||||||
ActivateIfPhysical(false);
|
ActivateIfPhysical(false);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
public override void VehicleVectorParam(int param, OMV.Vector3 value)
|
public override void VehicleVectorParam(int param, OMV.Vector3 value)
|
||||||
{
|
{
|
||||||
PhysScene.TaintedObject("BSPrim.VehicleVectorParam", delegate()
|
PhysScene.TaintedObject("BSPrim.VehicleVectorParam", delegate()
|
||||||
{
|
{
|
||||||
VehicleActor.ProcessVectorVehicleParam((Vehicle)param, value);
|
BSDynamics vehicleActor = GetVehicleActor();
|
||||||
|
if (vehicleActor != null)
|
||||||
|
{
|
||||||
|
vehicleActor.ProcessVectorVehicleParam((Vehicle)param, value);
|
||||||
ActivateIfPhysical(false);
|
ActivateIfPhysical(false);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
public override void VehicleRotationParam(int param, OMV.Quaternion rotation)
|
public override void VehicleRotationParam(int param, OMV.Quaternion rotation)
|
||||||
{
|
{
|
||||||
PhysScene.TaintedObject("BSPrim.VehicleRotationParam", delegate()
|
PhysScene.TaintedObject("BSPrim.VehicleRotationParam", delegate()
|
||||||
{
|
{
|
||||||
VehicleActor.ProcessRotationVehicleParam((Vehicle)param, rotation);
|
BSDynamics vehicleActor = GetVehicleActor();
|
||||||
|
if (vehicleActor != null)
|
||||||
|
{
|
||||||
|
vehicleActor.ProcessRotationVehicleParam((Vehicle)param, rotation);
|
||||||
ActivateIfPhysical(false);
|
ActivateIfPhysical(false);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
public override void VehicleFlags(int param, bool remove)
|
public override void VehicleFlags(int param, bool remove)
|
||||||
{
|
{
|
||||||
PhysScene.TaintedObject("BSPrim.VehicleFlags", delegate()
|
PhysScene.TaintedObject("BSPrim.VehicleFlags", delegate()
|
||||||
{
|
{
|
||||||
VehicleActor.ProcessVehicleFlags(param, remove);
|
BSDynamics vehicleActor = GetVehicleActor();
|
||||||
|
if (vehicleActor != null)
|
||||||
|
{
|
||||||
|
vehicleActor.ProcessVehicleFlags(param, remove);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -114,9 +114,12 @@ public class BasicVehicles : OpenSimTestCase
|
||||||
// Instead the appropriate values are set and calls are made just the parts of the
|
// 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
|
// controller we want to exercise. Stepping the physics engine then applies
|
||||||
// the actions of that one feature.
|
// the actions of that one feature.
|
||||||
TestVehicle.VehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_EFFICIENCY, efficiency);
|
BSDynamics vehicleActor = TestVehicle.GetVehicleActor();
|
||||||
TestVehicle.VehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_TIMESCALE, timeScale);
|
if (vehicleActor != null)
|
||||||
TestVehicle.VehicleActor.enableAngularVerticalAttraction = true;
|
{
|
||||||
|
vehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_EFFICIENCY, efficiency);
|
||||||
|
vehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_TIMESCALE, timeScale);
|
||||||
|
vehicleActor.enableAngularVerticalAttraction = true;
|
||||||
|
|
||||||
TestVehicle.IsPhysical = true;
|
TestVehicle.IsPhysical = true;
|
||||||
PhysicsScene.ProcessTaints();
|
PhysicsScene.ProcessTaints();
|
||||||
|
@ -124,12 +127,13 @@ public class BasicVehicles : OpenSimTestCase
|
||||||
// Step the simulator a bunch of times and vertical attraction should orient the vehicle up
|
// Step the simulator a bunch of times and vertical attraction should orient the vehicle up
|
||||||
for (int ii = 0; ii < simSteps; ii++)
|
for (int ii = 0; ii < simSteps; ii++)
|
||||||
{
|
{
|
||||||
TestVehicle.VehicleActor.ForgetKnownVehicleProperties();
|
vehicleActor.ForgetKnownVehicleProperties();
|
||||||
TestVehicle.VehicleActor.ComputeAngularVerticalAttraction();
|
vehicleActor.ComputeAngularVerticalAttraction();
|
||||||
TestVehicle.VehicleActor.PushKnownChanged();
|
vehicleActor.PushKnownChanged();
|
||||||
|
|
||||||
PhysicsScene.Simulate(simulationTimeStep);
|
PhysicsScene.Simulate(simulationTimeStep);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TestVehicle.IsPhysical = false;
|
TestVehicle.IsPhysical = false;
|
||||||
PhysicsScene.ProcessTaints();
|
PhysicsScene.ProcessTaints();
|
||||||
|
|
Loading…
Reference in New Issue