diff options
author | Robert Adams | 2012-12-27 13:13:35 -0800 |
---|---|---|
committer | Robert Adams | 2012-12-27 22:12:26 -0800 |
commit | e57c0e6731bff376186ecba2530e76b697ab5887 (patch) | |
tree | 1bdd63e70bab1f773d1ceee670f037971dce1d52 /OpenSim/Region/Physics/BulletSPlugin | |
parent | BulletSim: fix odd code that wasn't really recomputing the mass of a (diff) | |
download | opensim-SC_OLD-e57c0e6731bff376186ecba2530e76b697ab5887.zip opensim-SC_OLD-e57c0e6731bff376186ecba2530e76b697ab5887.tar.gz opensim-SC_OLD-e57c0e6731bff376186ecba2530e76b697ab5887.tar.bz2 opensim-SC_OLD-e57c0e6731bff376186ecba2530e76b697ab5887.tar.xz |
BulletSim: fix buoyancy so it's properly set by a script when an
object is selected.
Update TODO list.
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin')
4 files changed, 44 insertions, 15 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs index 4e02904..19ce62b 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs | |||
@@ -5,7 +5,7 @@ | |||
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclat simer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyrightD | 9 | * * Redistributions in binary form must reproduce the above copyrightD |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs b/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs index 9e1a9ba..817a5f7 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs | |||
@@ -241,8 +241,8 @@ public class BSVMotor : BSMotor | |||
241 | 241 | ||
242 | public override string ToString() | 242 | public override string ToString() |
243 | { | 243 | { |
244 | return String.Format("<{0},curr={1},targ={2},decayTS={3},frictTS={4}>", | 244 | return String.Format("<{0},curr={1},targ={2},lastErr={3},decayTS={4},frictTS={5}>", |
245 | UseName, CurrentValue, TargetValue, TargetValueDecayTimeScale, FrictionTimescale); | 245 | UseName, CurrentValue, TargetValue, LastError, TargetValueDecayTimeScale, FrictionTimescale); |
246 | } | 246 | } |
247 | } | 247 | } |
248 | 248 | ||
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index c7a81e0..f804a0f 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |||
@@ -94,7 +94,7 @@ public sealed class BSPrim : BSPhysObject | |||
94 | _size = size; | 94 | _size = size; |
95 | Scale = size; // prims are the size the user wants them to be (different for BSCharactes). | 95 | Scale = size; // prims are the size the user wants them to be (different for BSCharactes). |
96 | _orientation = rotation; | 96 | _orientation = rotation; |
97 | _buoyancy = 1f; | 97 | _buoyancy = 0f; |
98 | _velocity = OMV.Vector3.Zero; | 98 | _velocity = OMV.Vector3.Zero; |
99 | _rotationalVelocity = OMV.Vector3.Zero; | 99 | _rotationalVelocity = OMV.Vector3.Zero; |
100 | BaseShape = pbs; | 100 | BaseShape = pbs; |
@@ -408,12 +408,15 @@ public sealed class BSPrim : BSPhysObject | |||
408 | { | 408 | { |
409 | if (IsStatic) | 409 | if (IsStatic) |
410 | { | 410 | { |
411 | BulletSimAPI.SetGravity2(PhysBody.ptr, PhysicsScene.DefaultGravity); | ||
411 | Inertia = OMV.Vector3.Zero; | 412 | Inertia = OMV.Vector3.Zero; |
412 | BulletSimAPI.SetMassProps2(PhysBody.ptr, 0f, Inertia); | 413 | BulletSimAPI.SetMassProps2(PhysBody.ptr, 0f, Inertia); |
413 | BulletSimAPI.UpdateInertiaTensor2(PhysBody.ptr); | 414 | BulletSimAPI.UpdateInertiaTensor2(PhysBody.ptr); |
414 | } | 415 | } |
415 | else | 416 | else |
416 | { | 417 | { |
418 | OMV.Vector3 grav = ComputeGravity(); | ||
419 | |||
417 | if (inWorld) | 420 | if (inWorld) |
418 | { | 421 | { |
419 | // Changing interesting properties doesn't change proxy and collision cache | 422 | // Changing interesting properties doesn't change proxy and collision cache |
@@ -422,13 +425,16 @@ public sealed class BSPrim : BSPhysObject | |||
422 | BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, PhysBody.ptr); | 425 | BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, PhysBody.ptr); |
423 | } | 426 | } |
424 | 427 | ||
428 | // The computation of mass props requires gravity to be set on the object. | ||
429 | BulletSimAPI.SetGravity2(PhysBody.ptr, grav); | ||
430 | |||
425 | Inertia = BulletSimAPI.CalculateLocalInertia2(PhysShape.ptr, physMass); | 431 | Inertia = BulletSimAPI.CalculateLocalInertia2(PhysShape.ptr, physMass); |
426 | BulletSimAPI.SetMassProps2(PhysBody.ptr, physMass, Inertia); | 432 | BulletSimAPI.SetMassProps2(PhysBody.ptr, physMass, Inertia); |
427 | BulletSimAPI.UpdateInertiaTensor2(PhysBody.ptr); | 433 | BulletSimAPI.UpdateInertiaTensor2(PhysBody.ptr); |
428 | 434 | ||
429 | // center of mass is at the zero of the object | 435 | // center of mass is at the zero of the object |
430 | // DEBUG DEBUG BulletSimAPI.SetCenterOfMassByPosRot2(PhysBody.ptr, ForcePosition, ForceOrientation); | 436 | // DEBUG DEBUG BulletSimAPI.SetCenterOfMassByPosRot2(PhysBody.ptr, ForcePosition, ForceOrientation); |
431 | DetailLog("{0},BSPrim.UpdateMassProperties,mass={1},localInertia={2},inWorld={3}", LocalID, physMass, Inertia, inWorld); | 437 | DetailLog("{0},BSPrim.UpdateMassProperties,mass={1},localInertia={2},grav={3},inWorld={4}", LocalID, physMass, Inertia, grav, inWorld); |
432 | 438 | ||
433 | if (inWorld) | 439 | if (inWorld) |
434 | { | 440 | { |
@@ -437,13 +443,23 @@ public sealed class BSPrim : BSPhysObject | |||
437 | 443 | ||
438 | // Must set gravity after it has been added to the world because, for unknown reasons, | 444 | // Must set gravity after it has been added to the world because, for unknown reasons, |
439 | // adding the object resets the object's gravity to world gravity | 445 | // adding the object resets the object's gravity to world gravity |
440 | OMV.Vector3 grav = PhysicsScene.DefaultGravity * (1f - Buoyancy); | ||
441 | BulletSimAPI.SetGravity2(PhysBody.ptr, grav); | 446 | BulletSimAPI.SetGravity2(PhysBody.ptr, grav); |
442 | 447 | ||
443 | } | 448 | } |
444 | } | 449 | } |
445 | } | 450 | } |
446 | 451 | ||
452 | // Return what gravity should be set to this very moment | ||
453 | private OMV.Vector3 ComputeGravity() | ||
454 | { | ||
455 | OMV.Vector3 ret = PhysicsScene.DefaultGravity; | ||
456 | |||
457 | if (!IsStatic) | ||
458 | ret *= (1f - Buoyancy); | ||
459 | |||
460 | return ret; | ||
461 | } | ||
462 | |||
447 | // Is this used? | 463 | // Is this used? |
448 | public override OMV.Vector3 CenterOfMass | 464 | public override OMV.Vector3 CenterOfMass |
449 | { | 465 | { |
@@ -669,7 +685,7 @@ public sealed class BSPrim : BSPhysObject | |||
669 | _isPhysical = value; | 685 | _isPhysical = value; |
670 | PhysicsScene.TaintedObject("BSPrim.setIsPhysical", delegate() | 686 | PhysicsScene.TaintedObject("BSPrim.setIsPhysical", delegate() |
671 | { | 687 | { |
672 | // DetailLog("{0},setIsPhysical,taint,isPhys={1}", LocalID, _isPhysical); | 688 | DetailLog("{0},setIsPhysical,taint,isPhys={1}", LocalID, _isPhysical); |
673 | SetObjectDynamic(true); | 689 | SetObjectDynamic(true); |
674 | // whether phys-to-static or static-to-phys, the object is not moving. | 690 | // whether phys-to-static or static-to-phys, the object is not moving. |
675 | ZeroMotion(true); | 691 | ZeroMotion(true); |
@@ -726,6 +742,10 @@ public sealed class BSPrim : BSPhysObject | |||
726 | 742 | ||
727 | BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, PhysBody.ptr); | 743 | BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, PhysBody.ptr); |
728 | 744 | ||
745 | // TODO: Fix this. Total kludge because adding object to world resets its gravity to default. | ||
746 | // Replace this when the new AddObjectToWorld function is complete. | ||
747 | BulletSimAPI.SetGravity2(PhysBody.ptr, ComputeGravity()); | ||
748 | |||
729 | // Rebuild its shape | 749 | // Rebuild its shape |
730 | BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, PhysBody.ptr); | 750 | BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, PhysBody.ptr); |
731 | 751 | ||
@@ -976,6 +996,7 @@ public sealed class BSPrim : BSPhysObject | |||
976 | _buoyancy = value; | 996 | _buoyancy = value; |
977 | // DetailLog("{0},BSPrim.setForceBuoyancy,taint,buoy={1}", LocalID, _buoyancy); | 997 | // DetailLog("{0},BSPrim.setForceBuoyancy,taint,buoy={1}", LocalID, _buoyancy); |
978 | // Force the recalculation of the various inertia,etc variables in the object | 998 | // Force the recalculation of the various inertia,etc variables in the object |
999 | DetailLog("{0},BSPrim.ForceBuoyancy,buoy={1},mass={2}", LocalID, _buoyancy, _mass); | ||
979 | UpdatePhysicalMassProperties(_mass, true); | 1000 | UpdatePhysicalMassProperties(_mass, true); |
980 | ActivateIfPhysical(false); | 1001 | ActivateIfPhysical(false); |
981 | } | 1002 | } |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt b/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt index bc6dd7e..a66508a 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt +++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt | |||
@@ -1,22 +1,21 @@ | |||
1 | CURRENT PRIORITIES | 1 | CURRENT PRIORITIES |
2 | ================================================= | 2 | ================================================= |
3 | Smooth avatar movement with motor (DONE) | 3 | Redo BulletSimAPI to allow native C# implementation of Bullet option. |
4 | Should motor update be all at taint-time? (Yes, DONE) | 4 | Avatar movement |
5 | Fix avatar slowly sliding when standing (zero motion when stopped) | 5 | flying into a wall doesn't stop avatar who keeps appearing to move through the obsticle |
6 | llApplyImpulse() | 6 | walking up stairs is not calibrated correctly (stairs out of Kepler cabin) |
7 | Compare mass/movement in OS and SL. Calibrate actions. | 7 | avatar capsule rotation completed |
8 | llSetBuoyancy() | ||
9 | Boats float low in the water | ||
10 | Enable vehicle border crossings (at least as poorly as ODE) | 8 | Enable vehicle border crossings (at least as poorly as ODE) |
11 | Terrain skirts | 9 | Terrain skirts |
12 | Avatar created in previous region and not new region when crossing border | 10 | Avatar created in previous region and not new region when crossing border |
13 | Vehicle recreated in new sim at small Z value (offset from root value?) (DONE) | 11 | Vehicle recreated in new sim at small Z value (offset from root value?) (DONE) |
14 | Add material densities to the material types. | ||
15 | Vehicle movement on terrain smoothness | 12 | Vehicle movement on terrain smoothness |
16 | Vehicle script tuning/debugging | 13 | Vehicle script tuning/debugging |
17 | Avanti speed script | 14 | Avanti speed script |
18 | Weapon shooter script | 15 | Weapon shooter script |
19 | limitMotorUp calibration (more down?) | 16 | limitMotorUp calibration (more down?) |
17 | Boats float low in the water | ||
18 | Add material densities to the material types. | ||
20 | 19 | ||
21 | CRASHES | 20 | CRASHES |
22 | ================================================= | 21 | ================================================= |
@@ -243,3 +242,12 @@ Should vehicle angular/linear movement friction happen after all the components | |||
243 | What is expected by some vehicles (turning up friction to moderate speed)) | 242 | What is expected by some vehicles (turning up friction to moderate speed)) |
244 | Tune terrain/object friction to be closer to SL. | 243 | Tune terrain/object friction to be closer to SL. |
245 | (Resolution: added material type with friction and resolution) | 244 | (Resolution: added material type with friction and resolution) |
245 | Smooth avatar movement with motor (DONE) | ||
246 | Should motor update be all at taint-time? (Yes, DONE) | ||
247 | Fix avatar slowly sliding when standing (zero motion when stopped) (DONE) | ||
248 | (Resolution: added BSVMotor for avatar starting and stopping) | ||
249 | llApplyImpulse() | ||
250 | Compare mass/movement in OS and SL. Calibrate actions. (DONE) | ||
251 | (Resolution: tested on SL and OS. AddForce scales the force for timestep) | ||
252 | llSetBuoyancy() (DONE) | ||
253 | (Resolution: Bullet resets object gravity when added to world. Moved set gravity) | ||