Implement an overridable implementation of PhysicsActor.SetVehicle()
that works for all physics engines. BulletSim: implement an optimized version of SetVehicle() that still uses the vehicle code to do bounds checking but does it in one taint operation.avinationmerge
parent
124602c6c2
commit
e1ce04de42
|
@ -647,6 +647,59 @@ public class BSPrim : BSPhysObject
|
|||
});
|
||||
}
|
||||
|
||||
public override void SetVehicle(object pvdata)
|
||||
{
|
||||
PhysScene.TaintedObject(LocalID, "BSPrim.SetVehicle", delegate ()
|
||||
{
|
||||
BSDynamics vehicleActor = GetVehicleActor(true /* createIfNone */);
|
||||
if (vehicleActor != null && (pvdata is VehicleData) )
|
||||
{
|
||||
VehicleData vdata = (VehicleData)pvdata;
|
||||
// vehicleActor.ProcessSetVehicle((VehicleData)vdata);
|
||||
|
||||
vehicleActor.ProcessTypeChange(vdata.m_type);
|
||||
vehicleActor.ProcessVehicleFlags(-1, false);
|
||||
vehicleActor.ProcessVehicleFlags((int)vdata.m_flags, false);
|
||||
|
||||
// Linear properties
|
||||
vehicleActor.ProcessVectorVehicleParam(Vehicle.LINEAR_MOTOR_DIRECTION, vdata.m_linearMotorDirection);
|
||||
vehicleActor.ProcessVectorVehicleParam(Vehicle.LINEAR_FRICTION_TIMESCALE, vdata.m_linearFrictionTimescale);
|
||||
vehicleActor.ProcessFloatVehicleParam(Vehicle.LINEAR_MOTOR_DECAY_TIMESCALE, vdata.m_linearMotorDecayTimescale);
|
||||
vehicleActor.ProcessFloatVehicleParam(Vehicle.LINEAR_MOTOR_TIMESCALE, vdata.m_linearMotorTimescale);
|
||||
vehicleActor.ProcessVectorVehicleParam(Vehicle.LINEAR_MOTOR_OFFSET, vdata.m_linearMotorOffset);
|
||||
|
||||
//Angular properties
|
||||
vehicleActor.ProcessVectorVehicleParam(Vehicle.ANGULAR_MOTOR_DIRECTION, vdata.m_angularMotorDirection);
|
||||
vehicleActor.ProcessFloatVehicleParam(Vehicle.ANGULAR_MOTOR_TIMESCALE, vdata.m_angularMotorTimescale);
|
||||
vehicleActor.ProcessFloatVehicleParam(Vehicle.ANGULAR_MOTOR_DECAY_TIMESCALE, vdata.m_angularMotorDecayTimescale);
|
||||
vehicleActor.ProcessVectorVehicleParam(Vehicle.ANGULAR_FRICTION_TIMESCALE, vdata.m_angularFrictionTimescale);
|
||||
|
||||
//Deflection properties
|
||||
vehicleActor.ProcessFloatVehicleParam(Vehicle.ANGULAR_DEFLECTION_EFFICIENCY, vdata.m_angularDeflectionEfficiency);
|
||||
vehicleActor.ProcessFloatVehicleParam(Vehicle.ANGULAR_DEFLECTION_TIMESCALE, vdata.m_angularDeflectionTimescale);
|
||||
vehicleActor.ProcessFloatVehicleParam(Vehicle.LINEAR_DEFLECTION_EFFICIENCY, vdata.m_linearDeflectionEfficiency);
|
||||
vehicleActor.ProcessFloatVehicleParam(Vehicle.LINEAR_DEFLECTION_TIMESCALE, vdata.m_linearDeflectionTimescale);
|
||||
|
||||
//Banking properties
|
||||
vehicleActor.ProcessFloatVehicleParam(Vehicle.BANKING_EFFICIENCY, vdata.m_bankingEfficiency);
|
||||
vehicleActor.ProcessFloatVehicleParam(Vehicle.BANKING_MIX, vdata.m_bankingMix);
|
||||
vehicleActor.ProcessFloatVehicleParam(Vehicle.BANKING_TIMESCALE, vdata.m_bankingTimescale);
|
||||
|
||||
//Hover and Buoyancy properties
|
||||
vehicleActor.ProcessFloatVehicleParam(Vehicle.HOVER_HEIGHT, vdata.m_VhoverHeight);
|
||||
vehicleActor.ProcessFloatVehicleParam(Vehicle.HOVER_EFFICIENCY, vdata.m_VhoverEfficiency);
|
||||
vehicleActor.ProcessFloatVehicleParam(Vehicle.HOVER_TIMESCALE, vdata.m_VhoverTimescale);
|
||||
vehicleActor.ProcessFloatVehicleParam(Vehicle.BUOYANCY, vdata.m_VehicleBuoyancy);
|
||||
|
||||
//Attractor properties
|
||||
vehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_EFFICIENCY, vdata.m_verticalAttractionEfficiency);
|
||||
vehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_TIMESCALE, vdata.m_verticalAttractionTimescale);
|
||||
|
||||
vehicleActor.ProcessRotationVehicleParam(Vehicle.REFERENCE_FRAME, vdata.m_referenceFrame);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Allows the detection of collisions with inherently non-physical prims. see llVolumeDetect for more
|
||||
public override void SetVolumeDetect(int param) {
|
||||
bool newValue = (param != 0);
|
||||
|
|
|
@ -162,8 +162,6 @@ namespace OpenSim.Region.PhysicsModules.SharedBase
|
|||
/// </summary>
|
||||
public event CollisionUpdate OnCollisionUpdate;
|
||||
|
||||
public virtual void SetVehicle(object vdata) { }
|
||||
|
||||
public event OutOfBounds OnOutOfBounds;
|
||||
#pragma warning restore 67
|
||||
|
||||
|
@ -295,6 +293,56 @@ namespace OpenSim.Region.PhysicsModules.SharedBase
|
|||
public abstract void VehicleRotationParam(int param, Quaternion rotation);
|
||||
public abstract void VehicleFlags(int param, bool remove);
|
||||
|
||||
// This is an overridable version of SetVehicle() that works for all physics engines.
|
||||
// This is VERY inefficient. It behoves any physics engine to override this and
|
||||
// implement a more efficient setting of all the vehicle parameters.
|
||||
public virtual void SetVehicle(object pvdata)
|
||||
{
|
||||
VehicleData vdata = (VehicleData)pvdata;
|
||||
// vehicleActor.ProcessSetVehicle((VehicleData)vdata);
|
||||
|
||||
this.VehicleType = (int)vdata.m_type;
|
||||
this.VehicleFlags(-1, false); // clears all flags
|
||||
this.VehicleFlags((int)vdata.m_flags, false);
|
||||
|
||||
// Linear properties
|
||||
this.VehicleVectorParam((int)Vehicle.LINEAR_MOTOR_DIRECTION, vdata.m_linearMotorDirection);
|
||||
this.VehicleVectorParam((int)Vehicle.LINEAR_FRICTION_TIMESCALE, vdata.m_linearFrictionTimescale);
|
||||
this.VehicleFloatParam((int)Vehicle.LINEAR_MOTOR_DECAY_TIMESCALE, vdata.m_linearMotorDecayTimescale);
|
||||
this.VehicleFloatParam((int)Vehicle.LINEAR_MOTOR_TIMESCALE, vdata.m_linearMotorTimescale);
|
||||
this.VehicleVectorParam((int)Vehicle.LINEAR_MOTOR_OFFSET, vdata.m_linearMotorOffset);
|
||||
|
||||
//Angular properties
|
||||
this.VehicleVectorParam((int)Vehicle.ANGULAR_MOTOR_DIRECTION, vdata.m_angularMotorDirection);
|
||||
this.VehicleFloatParam((int)Vehicle.ANGULAR_MOTOR_TIMESCALE, vdata.m_angularMotorTimescale);
|
||||
this.VehicleFloatParam((int)Vehicle.ANGULAR_MOTOR_DECAY_TIMESCALE, vdata.m_angularMotorDecayTimescale);
|
||||
this.VehicleVectorParam((int)Vehicle.ANGULAR_FRICTION_TIMESCALE, vdata.m_angularFrictionTimescale);
|
||||
|
||||
//Deflection properties
|
||||
this.VehicleFloatParam((int)Vehicle.ANGULAR_DEFLECTION_EFFICIENCY, vdata.m_angularDeflectionEfficiency);
|
||||
this.VehicleFloatParam((int)Vehicle.ANGULAR_DEFLECTION_TIMESCALE, vdata.m_angularDeflectionTimescale);
|
||||
this.VehicleFloatParam((int)Vehicle.LINEAR_DEFLECTION_EFFICIENCY, vdata.m_linearDeflectionEfficiency);
|
||||
this.VehicleFloatParam((int)Vehicle.LINEAR_DEFLECTION_TIMESCALE, vdata.m_linearDeflectionTimescale);
|
||||
|
||||
//Banking properties
|
||||
this.VehicleFloatParam((int)Vehicle.BANKING_EFFICIENCY, vdata.m_bankingEfficiency);
|
||||
this.VehicleFloatParam((int)Vehicle.BANKING_MIX, vdata.m_bankingMix);
|
||||
this.VehicleFloatParam((int)Vehicle.BANKING_TIMESCALE, vdata.m_bankingTimescale);
|
||||
|
||||
//Hover and Buoyancy properties
|
||||
this.VehicleFloatParam((int)Vehicle.HOVER_HEIGHT, vdata.m_VhoverHeight);
|
||||
this.VehicleFloatParam((int)Vehicle.HOVER_EFFICIENCY, vdata.m_VhoverEfficiency);
|
||||
this.VehicleFloatParam((int)Vehicle.HOVER_TIMESCALE, vdata.m_VhoverTimescale);
|
||||
this.VehicleFloatParam((int)Vehicle.BUOYANCY, vdata.m_VehicleBuoyancy);
|
||||
|
||||
//Attractor properties
|
||||
this.VehicleFloatParam((int)Vehicle.VERTICAL_ATTRACTION_EFFICIENCY, vdata.m_verticalAttractionEfficiency);
|
||||
this.VehicleFloatParam((int)Vehicle.VERTICAL_ATTRACTION_TIMESCALE, vdata.m_verticalAttractionTimescale);
|
||||
|
||||
this.VehicleRotationParam((int)Vehicle.REFERENCE_FRAME, vdata.m_referenceFrame);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Allows the detection of collisions with inherently non-physical prims. see llVolumeDetect for more
|
||||
/// </summary>
|
||||
|
|
Loading…
Reference in New Issue