diff options
author | Robert Adams | 2015-10-02 18:35:02 -0700 |
---|---|---|
committer | Robert Adams | 2015-10-02 18:35:02 -0700 |
commit | e1ce04de428f856d92ac21912364320ebbda7b1a (patch) | |
tree | d0807de24a2f0267aa18a791b01eb2a6263247b1 /OpenSim/Region/PhysicsModules | |
parent | reduce some diferences with master (diff) | |
download | opensim-SC-e1ce04de428f856d92ac21912364320ebbda7b1a.zip opensim-SC-e1ce04de428f856d92ac21912364320ebbda7b1a.tar.gz opensim-SC-e1ce04de428f856d92ac21912364320ebbda7b1a.tar.bz2 opensim-SC-e1ce04de428f856d92ac21912364320ebbda7b1a.tar.xz |
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.
Diffstat (limited to 'OpenSim/Region/PhysicsModules')
-rw-r--r-- | OpenSim/Region/PhysicsModules/BulletS/BSPrim.cs | 53 | ||||
-rw-r--r-- | OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs | 52 |
2 files changed, 103 insertions, 2 deletions
diff --git a/OpenSim/Region/PhysicsModules/BulletS/BSPrim.cs b/OpenSim/Region/PhysicsModules/BulletS/BSPrim.cs index c8ac5c5..93e5e53 100644 --- a/OpenSim/Region/PhysicsModules/BulletS/BSPrim.cs +++ b/OpenSim/Region/PhysicsModules/BulletS/BSPrim.cs | |||
@@ -647,6 +647,59 @@ public class BSPrim : BSPhysObject | |||
647 | }); | 647 | }); |
648 | } | 648 | } |
649 | 649 | ||
650 | public override void SetVehicle(object pvdata) | ||
651 | { | ||
652 | PhysScene.TaintedObject(LocalID, "BSPrim.SetVehicle", delegate () | ||
653 | { | ||
654 | BSDynamics vehicleActor = GetVehicleActor(true /* createIfNone */); | ||
655 | if (vehicleActor != null && (pvdata is VehicleData) ) | ||
656 | { | ||
657 | VehicleData vdata = (VehicleData)pvdata; | ||
658 | // vehicleActor.ProcessSetVehicle((VehicleData)vdata); | ||
659 | |||
660 | vehicleActor.ProcessTypeChange(vdata.m_type); | ||
661 | vehicleActor.ProcessVehicleFlags(-1, false); | ||
662 | vehicleActor.ProcessVehicleFlags((int)vdata.m_flags, false); | ||
663 | |||
664 | // Linear properties | ||
665 | vehicleActor.ProcessVectorVehicleParam(Vehicle.LINEAR_MOTOR_DIRECTION, vdata.m_linearMotorDirection); | ||
666 | vehicleActor.ProcessVectorVehicleParam(Vehicle.LINEAR_FRICTION_TIMESCALE, vdata.m_linearFrictionTimescale); | ||
667 | vehicleActor.ProcessFloatVehicleParam(Vehicle.LINEAR_MOTOR_DECAY_TIMESCALE, vdata.m_linearMotorDecayTimescale); | ||
668 | vehicleActor.ProcessFloatVehicleParam(Vehicle.LINEAR_MOTOR_TIMESCALE, vdata.m_linearMotorTimescale); | ||
669 | vehicleActor.ProcessVectorVehicleParam(Vehicle.LINEAR_MOTOR_OFFSET, vdata.m_linearMotorOffset); | ||
670 | |||
671 | //Angular properties | ||
672 | vehicleActor.ProcessVectorVehicleParam(Vehicle.ANGULAR_MOTOR_DIRECTION, vdata.m_angularMotorDirection); | ||
673 | vehicleActor.ProcessFloatVehicleParam(Vehicle.ANGULAR_MOTOR_TIMESCALE, vdata.m_angularMotorTimescale); | ||
674 | vehicleActor.ProcessFloatVehicleParam(Vehicle.ANGULAR_MOTOR_DECAY_TIMESCALE, vdata.m_angularMotorDecayTimescale); | ||
675 | vehicleActor.ProcessVectorVehicleParam(Vehicle.ANGULAR_FRICTION_TIMESCALE, vdata.m_angularFrictionTimescale); | ||
676 | |||
677 | //Deflection properties | ||
678 | vehicleActor.ProcessFloatVehicleParam(Vehicle.ANGULAR_DEFLECTION_EFFICIENCY, vdata.m_angularDeflectionEfficiency); | ||
679 | vehicleActor.ProcessFloatVehicleParam(Vehicle.ANGULAR_DEFLECTION_TIMESCALE, vdata.m_angularDeflectionTimescale); | ||
680 | vehicleActor.ProcessFloatVehicleParam(Vehicle.LINEAR_DEFLECTION_EFFICIENCY, vdata.m_linearDeflectionEfficiency); | ||
681 | vehicleActor.ProcessFloatVehicleParam(Vehicle.LINEAR_DEFLECTION_TIMESCALE, vdata.m_linearDeflectionTimescale); | ||
682 | |||
683 | //Banking properties | ||
684 | vehicleActor.ProcessFloatVehicleParam(Vehicle.BANKING_EFFICIENCY, vdata.m_bankingEfficiency); | ||
685 | vehicleActor.ProcessFloatVehicleParam(Vehicle.BANKING_MIX, vdata.m_bankingMix); | ||
686 | vehicleActor.ProcessFloatVehicleParam(Vehicle.BANKING_TIMESCALE, vdata.m_bankingTimescale); | ||
687 | |||
688 | //Hover and Buoyancy properties | ||
689 | vehicleActor.ProcessFloatVehicleParam(Vehicle.HOVER_HEIGHT, vdata.m_VhoverHeight); | ||
690 | vehicleActor.ProcessFloatVehicleParam(Vehicle.HOVER_EFFICIENCY, vdata.m_VhoverEfficiency); | ||
691 | vehicleActor.ProcessFloatVehicleParam(Vehicle.HOVER_TIMESCALE, vdata.m_VhoverTimescale); | ||
692 | vehicleActor.ProcessFloatVehicleParam(Vehicle.BUOYANCY, vdata.m_VehicleBuoyancy); | ||
693 | |||
694 | //Attractor properties | ||
695 | vehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_EFFICIENCY, vdata.m_verticalAttractionEfficiency); | ||
696 | vehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_TIMESCALE, vdata.m_verticalAttractionTimescale); | ||
697 | |||
698 | vehicleActor.ProcessRotationVehicleParam(Vehicle.REFERENCE_FRAME, vdata.m_referenceFrame); | ||
699 | } | ||
700 | }); | ||
701 | } | ||
702 | |||
650 | // Allows the detection of collisions with inherently non-physical prims. see llVolumeDetect for more | 703 | // Allows the detection of collisions with inherently non-physical prims. see llVolumeDetect for more |
651 | public override void SetVolumeDetect(int param) { | 704 | public override void SetVolumeDetect(int param) { |
652 | bool newValue = (param != 0); | 705 | bool newValue = (param != 0); |
diff --git a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs index 1965dc2..a5c2c0e 100644 --- a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs +++ b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs | |||
@@ -162,8 +162,6 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
162 | /// </summary> | 162 | /// </summary> |
163 | public event CollisionUpdate OnCollisionUpdate; | 163 | public event CollisionUpdate OnCollisionUpdate; |
164 | 164 | ||
165 | public virtual void SetVehicle(object vdata) { } | ||
166 | |||
167 | public event OutOfBounds OnOutOfBounds; | 165 | public event OutOfBounds OnOutOfBounds; |
168 | #pragma warning restore 67 | 166 | #pragma warning restore 67 |
169 | 167 | ||
@@ -295,6 +293,56 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
295 | public abstract void VehicleRotationParam(int param, Quaternion rotation); | 293 | public abstract void VehicleRotationParam(int param, Quaternion rotation); |
296 | public abstract void VehicleFlags(int param, bool remove); | 294 | public abstract void VehicleFlags(int param, bool remove); |
297 | 295 | ||
296 | // This is an overridable version of SetVehicle() that works for all physics engines. | ||
297 | // This is VERY inefficient. It behoves any physics engine to override this and | ||
298 | // implement a more efficient setting of all the vehicle parameters. | ||
299 | public virtual void SetVehicle(object pvdata) | ||
300 | { | ||
301 | VehicleData vdata = (VehicleData)pvdata; | ||
302 | // vehicleActor.ProcessSetVehicle((VehicleData)vdata); | ||
303 | |||
304 | this.VehicleType = (int)vdata.m_type; | ||
305 | this.VehicleFlags(-1, false); // clears all flags | ||
306 | this.VehicleFlags((int)vdata.m_flags, false); | ||
307 | |||
308 | // Linear properties | ||
309 | this.VehicleVectorParam((int)Vehicle.LINEAR_MOTOR_DIRECTION, vdata.m_linearMotorDirection); | ||
310 | this.VehicleVectorParam((int)Vehicle.LINEAR_FRICTION_TIMESCALE, vdata.m_linearFrictionTimescale); | ||
311 | this.VehicleFloatParam((int)Vehicle.LINEAR_MOTOR_DECAY_TIMESCALE, vdata.m_linearMotorDecayTimescale); | ||
312 | this.VehicleFloatParam((int)Vehicle.LINEAR_MOTOR_TIMESCALE, vdata.m_linearMotorTimescale); | ||
313 | this.VehicleVectorParam((int)Vehicle.LINEAR_MOTOR_OFFSET, vdata.m_linearMotorOffset); | ||
314 | |||
315 | //Angular properties | ||
316 | this.VehicleVectorParam((int)Vehicle.ANGULAR_MOTOR_DIRECTION, vdata.m_angularMotorDirection); | ||
317 | this.VehicleFloatParam((int)Vehicle.ANGULAR_MOTOR_TIMESCALE, vdata.m_angularMotorTimescale); | ||
318 | this.VehicleFloatParam((int)Vehicle.ANGULAR_MOTOR_DECAY_TIMESCALE, vdata.m_angularMotorDecayTimescale); | ||
319 | this.VehicleVectorParam((int)Vehicle.ANGULAR_FRICTION_TIMESCALE, vdata.m_angularFrictionTimescale); | ||
320 | |||
321 | //Deflection properties | ||
322 | this.VehicleFloatParam((int)Vehicle.ANGULAR_DEFLECTION_EFFICIENCY, vdata.m_angularDeflectionEfficiency); | ||
323 | this.VehicleFloatParam((int)Vehicle.ANGULAR_DEFLECTION_TIMESCALE, vdata.m_angularDeflectionTimescale); | ||
324 | this.VehicleFloatParam((int)Vehicle.LINEAR_DEFLECTION_EFFICIENCY, vdata.m_linearDeflectionEfficiency); | ||
325 | this.VehicleFloatParam((int)Vehicle.LINEAR_DEFLECTION_TIMESCALE, vdata.m_linearDeflectionTimescale); | ||
326 | |||
327 | //Banking properties | ||
328 | this.VehicleFloatParam((int)Vehicle.BANKING_EFFICIENCY, vdata.m_bankingEfficiency); | ||
329 | this.VehicleFloatParam((int)Vehicle.BANKING_MIX, vdata.m_bankingMix); | ||
330 | this.VehicleFloatParam((int)Vehicle.BANKING_TIMESCALE, vdata.m_bankingTimescale); | ||
331 | |||
332 | //Hover and Buoyancy properties | ||
333 | this.VehicleFloatParam((int)Vehicle.HOVER_HEIGHT, vdata.m_VhoverHeight); | ||
334 | this.VehicleFloatParam((int)Vehicle.HOVER_EFFICIENCY, vdata.m_VhoverEfficiency); | ||
335 | this.VehicleFloatParam((int)Vehicle.HOVER_TIMESCALE, vdata.m_VhoverTimescale); | ||
336 | this.VehicleFloatParam((int)Vehicle.BUOYANCY, vdata.m_VehicleBuoyancy); | ||
337 | |||
338 | //Attractor properties | ||
339 | this.VehicleFloatParam((int)Vehicle.VERTICAL_ATTRACTION_EFFICIENCY, vdata.m_verticalAttractionEfficiency); | ||
340 | this.VehicleFloatParam((int)Vehicle.VERTICAL_ATTRACTION_TIMESCALE, vdata.m_verticalAttractionTimescale); | ||
341 | |||
342 | this.VehicleRotationParam((int)Vehicle.REFERENCE_FRAME, vdata.m_referenceFrame); | ||
343 | } | ||
344 | |||
345 | |||
298 | /// <summary> | 346 | /// <summary> |
299 | /// Allows the detection of collisions with inherently non-physical prims. see llVolumeDetect for more | 347 | /// Allows the detection of collisions with inherently non-physical prims. see llVolumeDetect for more |
300 | /// </summary> | 348 | /// </summary> |