diff options
author | Robert Adams | 2012-12-25 23:55:25 -0800 |
---|---|---|
committer | Robert Adams | 2012-12-25 23:55:25 -0800 |
commit | d1ede1df3a04428c83a9937059a0df00d7f3e281 (patch) | |
tree | c2f9943a0e6a12c432cbd927520e92deb2a4c013 /OpenSim/Region/Physics | |
parent | BulletSim: stop avatar from sliding VERY slowly after walking by (diff) | |
download | opensim-SC_OLD-d1ede1df3a04428c83a9937059a0df00d7f3e281.zip opensim-SC_OLD-d1ede1df3a04428c83a9937059a0df00d7f3e281.tar.gz opensim-SC_OLD-d1ede1df3a04428c83a9937059a0df00d7f3e281.tar.bz2 opensim-SC_OLD-d1ede1df3a04428c83a9937059a0df00d7f3e281.tar.xz |
BulletSim: make llBuoyancy work. For some reason, Bullet resets an
object's individual gravity to the world gravity when the object
is added to the physical world.
Diffstat (limited to 'OpenSim/Region/Physics')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | 3 | ||||
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 12 | ||||
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt | 3 |
3 files changed, 13 insertions, 5 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index 3fde57b..a8edd23 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | |||
@@ -573,6 +573,9 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
573 | BulletSimAPI.SetMassProps2(Prim.PhysBody.ptr, m_vehicleMass, localInertia); | 573 | BulletSimAPI.SetMassProps2(Prim.PhysBody.ptr, m_vehicleMass, localInertia); |
574 | BulletSimAPI.UpdateInertiaTensor2(Prim.PhysBody.ptr); | 574 | BulletSimAPI.UpdateInertiaTensor2(Prim.PhysBody.ptr); |
575 | 575 | ||
576 | Vector3 grav = PhysicsScene.DefaultGravity * (1f - Prim.Buoyancy); | ||
577 | BulletSimAPI.SetGravity2(Prim.PhysBody.ptr, grav); | ||
578 | |||
576 | VDetailLog("{0},BSDynamics.Refresh,mass={1},frict={2},inert={3},aDamp={4}", | 579 | VDetailLog("{0},BSDynamics.Refresh,mass={1},frict={2},inert={3},aDamp={4}", |
577 | Prim.LocalID, m_vehicleMass, friction, localInertia, angularDamping); | 580 | Prim.LocalID, m_vehicleMass, friction, localInertia, angularDamping); |
578 | } | 581 | } |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 159f79f..0d13096 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |||
@@ -422,20 +422,24 @@ public sealed class BSPrim : BSPhysObject | |||
422 | BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, PhysBody.ptr); | 422 | BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, PhysBody.ptr); |
423 | } | 423 | } |
424 | 424 | ||
425 | float grav = PhysicsScene.Params.gravity * (1f - _buoyancy); | ||
426 | BulletSimAPI.SetGravity2(PhysBody.ptr, new OMV.Vector3(0f, 0f, grav)); | ||
427 | |||
428 | Inertia = BulletSimAPI.CalculateLocalInertia2(PhysShape.ptr, physMass); | 425 | Inertia = BulletSimAPI.CalculateLocalInertia2(PhysShape.ptr, physMass); |
429 | BulletSimAPI.SetMassProps2(PhysBody.ptr, physMass, Inertia); | 426 | BulletSimAPI.SetMassProps2(PhysBody.ptr, physMass, Inertia); |
430 | BulletSimAPI.UpdateInertiaTensor2(PhysBody.ptr); | 427 | BulletSimAPI.UpdateInertiaTensor2(PhysBody.ptr); |
428 | |||
431 | // center of mass is at the zero of the object | 429 | // center of mass is at the zero of the object |
432 | // DEBUG DEBUG BulletSimAPI.SetCenterOfMassByPosRot2(PhysBody.ptr, ForcePosition, ForceOrientation); | 430 | // DEBUG DEBUG BulletSimAPI.SetCenterOfMassByPosRot2(PhysBody.ptr, ForcePosition, ForceOrientation); |
433 | DetailLog("{0},BSPrim.UpdateMassProperties,mass={1},localInertia={2}", LocalID, physMass, Inertia); | 431 | DetailLog("{0},BSPrim.UpdateMassProperties,mass={1},localInertia={2},inWorld={3}", LocalID, physMass, Inertia, inWorld); |
434 | 432 | ||
435 | if (inWorld) | 433 | if (inWorld) |
436 | { | 434 | { |
437 | BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, PhysBody.ptr); | 435 | BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, PhysBody.ptr); |
438 | } | 436 | } |
437 | |||
438 | // 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 | ||
440 | OMV.Vector3 grav = PhysicsScene.DefaultGravity * (1f - Buoyancy); | ||
441 | BulletSimAPI.SetGravity2(PhysBody.ptr, grav); | ||
442 | |||
439 | } | 443 | } |
440 | } | 444 | } |
441 | } | 445 | } |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt b/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt index 35cb8f3..9d07d72 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt +++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt | |||
@@ -58,7 +58,6 @@ Incorporate inter-relationship of angular corrections. For instance, angularDefl | |||
58 | 58 | ||
59 | BULLETSIM TODO LIST: | 59 | BULLETSIM TODO LIST: |
60 | ================================================= | 60 | ================================================= |
61 | In SL, perfect spheres don't seem to have rolling friction. Add special case. | ||
62 | Avatar density is WAY off. Compare and calibrate with what's in SL. | 61 | Avatar density is WAY off. Compare and calibrate with what's in SL. |
63 | Revisit CollisionMargin. Builders notice the 0.04 spacing between prims. | 62 | Revisit CollisionMargin. Builders notice the 0.04 spacing between prims. |
64 | Duplicating a physical prim causes old prim to jump away | 63 | Duplicating a physical prim causes old prim to jump away |
@@ -146,6 +145,8 @@ Is there are more efficient method of implementing pre and post step actions? | |||
146 | See http://www.codeproject.com/Articles/29922/Weak-Events-in-C | 145 | See http://www.codeproject.com/Articles/29922/Weak-Events-in-C |
147 | 146 | ||
148 | Physics Arena central pyramid: why is one side permiable? | 147 | Physics Arena central pyramid: why is one side permiable? |
148 | |||
149 | In SL, perfect spheres don't seem to have rolling friction. Add special case. | ||
149 | Enforce physical parameter min/max: | 150 | Enforce physical parameter min/max: |
150 | Gravity: [-1, 28] | 151 | Gravity: [-1, 28] |
151 | Friction: [0, 255] | 152 | Friction: [0, 255] |