From 225b564573a5ac12ca1b1e592834476feccf8ebb Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Wed, 26 Dec 2012 10:25:50 -0800 Subject: BulletSim: scale the force for external AddForce by the simulation step time so it will be applied completely the next step. The internal AddForce routine does not scale the force. --- OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 12 +++++++++++- OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 4 ++++ OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt | 4 ++++ 3 files changed, 19 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 0d13096..9013414 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs @@ -1014,7 +1014,9 @@ public sealed class BSPrim : BSPhysObject public override float APIDDamping { set { return; } } public override void AddForce(OMV.Vector3 force, bool pushforce) { - AddForce(force, pushforce, false); + // Since this force is being applied in only one step, make this a force per second. + OMV.Vector3 addForce = force / PhysicsScene.LastTimeStep; + AddForce(addForce, pushforce, false); } // Applying a force just adds this to the total force on the object. // This added force will only last the next simulation tick. @@ -1022,8 +1024,16 @@ public sealed class BSPrim : BSPhysObject // for an object, doesn't matter if force is a pushforce or not if (force.IsFinite()) { + float magnitude = force.Length(); + if (magnitude > 20000f) + { + // Force has a limit + force = force / magnitude * 20000f; + } + OMV.Vector3 addForce = force; DetailLog("{0},BSPrim.addForce,call,force={1}", LocalID, addForce); + PhysicsScene.TaintedObject(inTaintTime, "BSPrim.AddForce", delegate() { // Bullet adds this central force to the total force for this tick diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 0022e45..b67c0ed 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -495,6 +495,10 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters InTaintTime = false; // Only used for debugging so locking is not necessary. + // The following causes the unmanaged code to output ALL the values found in ALL the objects in the world. + // Only enable this in a limited test world with few objects. + // BulletSimAPI.DumpAllInfo2(World.ptr); // DEBUG DEBUG DEBUG + // step the physical world one interval m_simulationStep++; int numSubSteps = 0; diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt b/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt index 9d07d72..78cc26c 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt +++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt @@ -35,6 +35,8 @@ Border crossing with linked vehicle causes crash Vehicles (Move smoothly) Add vehicle collisions so IsColliding is properly reported. Needed for banking, limitMotorUp, movementLimiting, ... +VehicleAddForce is not scaled by the simulation step but it is only + applied for one step. Should it be scaled? Some vehicles should not be able to turn if no speed or off ground. Cannot edit/move a vehicle being ridden: it jumps back to the origional position. Neb car jiggling left and right @@ -92,6 +94,8 @@ Should the different PID factors have non-equal contributions for different Selecting and deselecting physical objects causes CPU processing time to jump http://www.youtube.com/watch?v=Hjg57fWg8yI&hd=1 put thousand physical objects, select and deselect same. CPU time will be large. +Re-implement buoyancy as a separate force on the object rather than diddling gravity. + Register a pre-step event to add the force. LINKSETS ====================================================== -- cgit v1.1