diff options
author | Robert Adams | 2012-12-26 10:25:50 -0800 |
---|---|---|
committer | Robert Adams | 2012-12-26 10:25:50 -0800 |
commit | 225b564573a5ac12ca1b1e592834476feccf8ebb (patch) | |
tree | 4adccb61ae3850d07b458c0c594e83812d7bac4d /OpenSim | |
parent | BulletSim: make llBuoyancy work. For some reason, Bullet resets an (diff) | |
download | opensim-SC-225b564573a5ac12ca1b1e592834476feccf8ebb.zip opensim-SC-225b564573a5ac12ca1b1e592834476feccf8ebb.tar.gz opensim-SC-225b564573a5ac12ca1b1e592834476feccf8ebb.tar.bz2 opensim-SC-225b564573a5ac12ca1b1e592834476feccf8ebb.tar.xz |
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.
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 12 | ||||
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 4 | ||||
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt | 4 |
3 files changed, 19 insertions, 1 deletions
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 | |||
1014 | public override float APIDDamping { set { return; } } | 1014 | public override float APIDDamping { set { return; } } |
1015 | 1015 | ||
1016 | public override void AddForce(OMV.Vector3 force, bool pushforce) { | 1016 | public override void AddForce(OMV.Vector3 force, bool pushforce) { |
1017 | AddForce(force, pushforce, false); | 1017 | // Since this force is being applied in only one step, make this a force per second. |
1018 | OMV.Vector3 addForce = force / PhysicsScene.LastTimeStep; | ||
1019 | AddForce(addForce, pushforce, false); | ||
1018 | } | 1020 | } |
1019 | // Applying a force just adds this to the total force on the object. | 1021 | // Applying a force just adds this to the total force on the object. |
1020 | // This added force will only last the next simulation tick. | 1022 | // This added force will only last the next simulation tick. |
@@ -1022,8 +1024,16 @@ public sealed class BSPrim : BSPhysObject | |||
1022 | // for an object, doesn't matter if force is a pushforce or not | 1024 | // for an object, doesn't matter if force is a pushforce or not |
1023 | if (force.IsFinite()) | 1025 | if (force.IsFinite()) |
1024 | { | 1026 | { |
1027 | float magnitude = force.Length(); | ||
1028 | if (magnitude > 20000f) | ||
1029 | { | ||
1030 | // Force has a limit | ||
1031 | force = force / magnitude * 20000f; | ||
1032 | } | ||
1033 | |||
1025 | OMV.Vector3 addForce = force; | 1034 | OMV.Vector3 addForce = force; |
1026 | DetailLog("{0},BSPrim.addForce,call,force={1}", LocalID, addForce); | 1035 | DetailLog("{0},BSPrim.addForce,call,force={1}", LocalID, addForce); |
1036 | |||
1027 | PhysicsScene.TaintedObject(inTaintTime, "BSPrim.AddForce", delegate() | 1037 | PhysicsScene.TaintedObject(inTaintTime, "BSPrim.AddForce", delegate() |
1028 | { | 1038 | { |
1029 | // Bullet adds this central force to the total force for this tick | 1039 | // 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 | |||
495 | 495 | ||
496 | InTaintTime = false; // Only used for debugging so locking is not necessary. | 496 | InTaintTime = false; // Only used for debugging so locking is not necessary. |
497 | 497 | ||
498 | // The following causes the unmanaged code to output ALL the values found in ALL the objects in the world. | ||
499 | // Only enable this in a limited test world with few objects. | ||
500 | // BulletSimAPI.DumpAllInfo2(World.ptr); // DEBUG DEBUG DEBUG | ||
501 | |||
498 | // step the physical world one interval | 502 | // step the physical world one interval |
499 | m_simulationStep++; | 503 | m_simulationStep++; |
500 | int numSubSteps = 0; | 504 | 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 | |||
35 | Vehicles (Move smoothly) | 35 | Vehicles (Move smoothly) |
36 | Add vehicle collisions so IsColliding is properly reported. | 36 | Add vehicle collisions so IsColliding is properly reported. |
37 | Needed for banking, limitMotorUp, movementLimiting, ... | 37 | Needed for banking, limitMotorUp, movementLimiting, ... |
38 | VehicleAddForce is not scaled by the simulation step but it is only | ||
39 | applied for one step. Should it be scaled? | ||
38 | Some vehicles should not be able to turn if no speed or off ground. | 40 | Some vehicles should not be able to turn if no speed or off ground. |
39 | Cannot edit/move a vehicle being ridden: it jumps back to the origional position. | 41 | Cannot edit/move a vehicle being ridden: it jumps back to the origional position. |
40 | Neb car jiggling left and right | 42 | Neb car jiggling left and right |
@@ -92,6 +94,8 @@ Should the different PID factors have non-equal contributions for different | |||
92 | Selecting and deselecting physical objects causes CPU processing time to jump | 94 | Selecting and deselecting physical objects causes CPU processing time to jump |
93 | http://www.youtube.com/watch?v=Hjg57fWg8yI&hd=1 | 95 | http://www.youtube.com/watch?v=Hjg57fWg8yI&hd=1 |
94 | put thousand physical objects, select and deselect same. CPU time will be large. | 96 | put thousand physical objects, select and deselect same. CPU time will be large. |
97 | Re-implement buoyancy as a separate force on the object rather than diddling gravity. | ||
98 | Register a pre-step event to add the force. | ||
95 | 99 | ||
96 | LINKSETS | 100 | LINKSETS |
97 | ====================================================== | 101 | ====================================================== |