BulletSim: fix buoyancy so it's properly set by a script when an

object is selected.
Update TODO list.
0.7.5-pf-bulletsim
Robert Adams 2012-12-27 13:13:35 -08:00
parent 7230990679
commit e57c0e6731
4 changed files with 44 additions and 15 deletions

View File

@ -5,7 +5,7 @@
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclat simer.
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyrightD
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.

View File

@ -241,8 +241,8 @@ public class BSVMotor : BSMotor
public override string ToString()
{
return String.Format("<{0},curr={1},targ={2},decayTS={3},frictTS={4}>",
UseName, CurrentValue, TargetValue, TargetValueDecayTimeScale, FrictionTimescale);
return String.Format("<{0},curr={1},targ={2},lastErr={3},decayTS={4},frictTS={5}>",
UseName, CurrentValue, TargetValue, LastError, TargetValueDecayTimeScale, FrictionTimescale);
}
}

View File

@ -94,7 +94,7 @@ public sealed class BSPrim : BSPhysObject
_size = size;
Scale = size; // prims are the size the user wants them to be (different for BSCharactes).
_orientation = rotation;
_buoyancy = 1f;
_buoyancy = 0f;
_velocity = OMV.Vector3.Zero;
_rotationalVelocity = OMV.Vector3.Zero;
BaseShape = pbs;
@ -408,12 +408,15 @@ public sealed class BSPrim : BSPhysObject
{
if (IsStatic)
{
BulletSimAPI.SetGravity2(PhysBody.ptr, PhysicsScene.DefaultGravity);
Inertia = OMV.Vector3.Zero;
BulletSimAPI.SetMassProps2(PhysBody.ptr, 0f, Inertia);
BulletSimAPI.UpdateInertiaTensor2(PhysBody.ptr);
}
else
{
OMV.Vector3 grav = ComputeGravity();
if (inWorld)
{
// Changing interesting properties doesn't change proxy and collision cache
@ -422,13 +425,16 @@ public sealed class BSPrim : BSPhysObject
BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, PhysBody.ptr);
}
// The computation of mass props requires gravity to be set on the object.
BulletSimAPI.SetGravity2(PhysBody.ptr, grav);
Inertia = BulletSimAPI.CalculateLocalInertia2(PhysShape.ptr, physMass);
BulletSimAPI.SetMassProps2(PhysBody.ptr, physMass, Inertia);
BulletSimAPI.UpdateInertiaTensor2(PhysBody.ptr);
// center of mass is at the zero of the object
// DEBUG DEBUG BulletSimAPI.SetCenterOfMassByPosRot2(PhysBody.ptr, ForcePosition, ForceOrientation);
DetailLog("{0},BSPrim.UpdateMassProperties,mass={1},localInertia={2},inWorld={3}", LocalID, physMass, Inertia, inWorld);
DetailLog("{0},BSPrim.UpdateMassProperties,mass={1},localInertia={2},grav={3},inWorld={4}", LocalID, physMass, Inertia, grav, inWorld);
if (inWorld)
{
@ -437,13 +443,23 @@ public sealed class BSPrim : BSPhysObject
// Must set gravity after it has been added to the world because, for unknown reasons,
// adding the object resets the object's gravity to world gravity
OMV.Vector3 grav = PhysicsScene.DefaultGravity * (1f - Buoyancy);
BulletSimAPI.SetGravity2(PhysBody.ptr, grav);
}
}
}
// Return what gravity should be set to this very moment
private OMV.Vector3 ComputeGravity()
{
OMV.Vector3 ret = PhysicsScene.DefaultGravity;
if (!IsStatic)
ret *= (1f - Buoyancy);
return ret;
}
// Is this used?
public override OMV.Vector3 CenterOfMass
{
@ -669,7 +685,7 @@ public sealed class BSPrim : BSPhysObject
_isPhysical = value;
PhysicsScene.TaintedObject("BSPrim.setIsPhysical", delegate()
{
// DetailLog("{0},setIsPhysical,taint,isPhys={1}", LocalID, _isPhysical);
DetailLog("{0},setIsPhysical,taint,isPhys={1}", LocalID, _isPhysical);
SetObjectDynamic(true);
// whether phys-to-static or static-to-phys, the object is not moving.
ZeroMotion(true);
@ -726,6 +742,10 @@ public sealed class BSPrim : BSPhysObject
BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, PhysBody.ptr);
// TODO: Fix this. Total kludge because adding object to world resets its gravity to default.
// Replace this when the new AddObjectToWorld function is complete.
BulletSimAPI.SetGravity2(PhysBody.ptr, ComputeGravity());
// Rebuild its shape
BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, PhysBody.ptr);
@ -976,6 +996,7 @@ public sealed class BSPrim : BSPhysObject
_buoyancy = value;
// DetailLog("{0},BSPrim.setForceBuoyancy,taint,buoy={1}", LocalID, _buoyancy);
// Force the recalculation of the various inertia,etc variables in the object
DetailLog("{0},BSPrim.ForceBuoyancy,buoy={1},mass={2}", LocalID, _buoyancy, _mass);
UpdatePhysicalMassProperties(_mass, true);
ActivateIfPhysical(false);
}

View File

@ -1,22 +1,21 @@
CURRENT PRIORITIES
=================================================
Smooth avatar movement with motor (DONE)
Should motor update be all at taint-time? (Yes, DONE)
Fix avatar slowly sliding when standing (zero motion when stopped)
llApplyImpulse()
Compare mass/movement in OS and SL. Calibrate actions.
llSetBuoyancy()
Boats float low in the water
Redo BulletSimAPI to allow native C# implementation of Bullet option.
Avatar movement
flying into a wall doesn't stop avatar who keeps appearing to move through the obsticle
walking up stairs is not calibrated correctly (stairs out of Kepler cabin)
avatar capsule rotation completed
Enable vehicle border crossings (at least as poorly as ODE)
Terrain skirts
Avatar created in previous region and not new region when crossing border
Vehicle recreated in new sim at small Z value (offset from root value?) (DONE)
Add material densities to the material types.
Vehicle movement on terrain smoothness
Vehicle script tuning/debugging
Avanti speed script
Weapon shooter script
limitMotorUp calibration (more down?)
Boats float low in the water
Add material densities to the material types.
CRASHES
=================================================
@ -243,3 +242,12 @@ Should vehicle angular/linear movement friction happen after all the components
What is expected by some vehicles (turning up friction to moderate speed))
Tune terrain/object friction to be closer to SL.
(Resolution: added material type with friction and resolution)
Smooth avatar movement with motor (DONE)
Should motor update be all at taint-time? (Yes, DONE)
Fix avatar slowly sliding when standing (zero motion when stopped) (DONE)
(Resolution: added BSVMotor for avatar starting and stopping)
llApplyImpulse()
Compare mass/movement in OS and SL. Calibrate actions. (DONE)
(Resolution: tested on SL and OS. AddForce scales the force for timestep)
llSetBuoyancy() (DONE)
(Resolution: Bullet resets object gravity when added to world. Moved set gravity)