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.
0.7.5-pf-bulletsim
Robert Adams 2012-12-26 10:25:50 -08:00
parent d1ede1df3a
commit 225b564573
3 changed files with 19 additions and 1 deletions

View File

@ -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

View File

@ -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;

View File

@ -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
======================================================