BulletSim: fix buoyancy so it's properly set by a script when an
object is selected. Update TODO list.0.7.5-pf-bulletsim
parent
7230990679
commit
e57c0e6731
|
@ -5,7 +5,7 @@
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* * Redistributions of source code must retain the above copyright
|
* * 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
|
* * Redistributions in binary form must reproduce the above copyrightD
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
|
|
@ -241,8 +241,8 @@ public class BSVMotor : BSMotor
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return String.Format("<{0},curr={1},targ={2},decayTS={3},frictTS={4}>",
|
return String.Format("<{0},curr={1},targ={2},lastErr={3},decayTS={4},frictTS={5}>",
|
||||||
UseName, CurrentValue, TargetValue, TargetValueDecayTimeScale, FrictionTimescale);
|
UseName, CurrentValue, TargetValue, LastError, TargetValueDecayTimeScale, FrictionTimescale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ public sealed class BSPrim : BSPhysObject
|
||||||
_size = size;
|
_size = size;
|
||||||
Scale = size; // prims are the size the user wants them to be (different for BSCharactes).
|
Scale = size; // prims are the size the user wants them to be (different for BSCharactes).
|
||||||
_orientation = rotation;
|
_orientation = rotation;
|
||||||
_buoyancy = 1f;
|
_buoyancy = 0f;
|
||||||
_velocity = OMV.Vector3.Zero;
|
_velocity = OMV.Vector3.Zero;
|
||||||
_rotationalVelocity = OMV.Vector3.Zero;
|
_rotationalVelocity = OMV.Vector3.Zero;
|
||||||
BaseShape = pbs;
|
BaseShape = pbs;
|
||||||
|
@ -408,12 +408,15 @@ public sealed class BSPrim : BSPhysObject
|
||||||
{
|
{
|
||||||
if (IsStatic)
|
if (IsStatic)
|
||||||
{
|
{
|
||||||
|
BulletSimAPI.SetGravity2(PhysBody.ptr, PhysicsScene.DefaultGravity);
|
||||||
Inertia = OMV.Vector3.Zero;
|
Inertia = OMV.Vector3.Zero;
|
||||||
BulletSimAPI.SetMassProps2(PhysBody.ptr, 0f, Inertia);
|
BulletSimAPI.SetMassProps2(PhysBody.ptr, 0f, Inertia);
|
||||||
BulletSimAPI.UpdateInertiaTensor2(PhysBody.ptr);
|
BulletSimAPI.UpdateInertiaTensor2(PhysBody.ptr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
OMV.Vector3 grav = ComputeGravity();
|
||||||
|
|
||||||
if (inWorld)
|
if (inWorld)
|
||||||
{
|
{
|
||||||
// Changing interesting properties doesn't change proxy and collision cache
|
// 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);
|
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);
|
Inertia = BulletSimAPI.CalculateLocalInertia2(PhysShape.ptr, physMass);
|
||||||
BulletSimAPI.SetMassProps2(PhysBody.ptr, physMass, Inertia);
|
BulletSimAPI.SetMassProps2(PhysBody.ptr, physMass, Inertia);
|
||||||
BulletSimAPI.UpdateInertiaTensor2(PhysBody.ptr);
|
BulletSimAPI.UpdateInertiaTensor2(PhysBody.ptr);
|
||||||
|
|
||||||
// center of mass is at the zero of the object
|
// center of mass is at the zero of the object
|
||||||
// DEBUG DEBUG BulletSimAPI.SetCenterOfMassByPosRot2(PhysBody.ptr, ForcePosition, ForceOrientation);
|
// 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)
|
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,
|
// 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
|
// adding the object resets the object's gravity to world gravity
|
||||||
OMV.Vector3 grav = PhysicsScene.DefaultGravity * (1f - Buoyancy);
|
|
||||||
BulletSimAPI.SetGravity2(PhysBody.ptr, grav);
|
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?
|
// Is this used?
|
||||||
public override OMV.Vector3 CenterOfMass
|
public override OMV.Vector3 CenterOfMass
|
||||||
{
|
{
|
||||||
|
@ -669,7 +685,7 @@ public sealed class BSPrim : BSPhysObject
|
||||||
_isPhysical = value;
|
_isPhysical = value;
|
||||||
PhysicsScene.TaintedObject("BSPrim.setIsPhysical", delegate()
|
PhysicsScene.TaintedObject("BSPrim.setIsPhysical", delegate()
|
||||||
{
|
{
|
||||||
// DetailLog("{0},setIsPhysical,taint,isPhys={1}", LocalID, _isPhysical);
|
DetailLog("{0},setIsPhysical,taint,isPhys={1}", LocalID, _isPhysical);
|
||||||
SetObjectDynamic(true);
|
SetObjectDynamic(true);
|
||||||
// whether phys-to-static or static-to-phys, the object is not moving.
|
// whether phys-to-static or static-to-phys, the object is not moving.
|
||||||
ZeroMotion(true);
|
ZeroMotion(true);
|
||||||
|
@ -726,6 +742,10 @@ public sealed class BSPrim : BSPhysObject
|
||||||
|
|
||||||
BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, PhysBody.ptr);
|
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
|
// Rebuild its shape
|
||||||
BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, PhysBody.ptr);
|
BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, PhysBody.ptr);
|
||||||
|
|
||||||
|
@ -976,6 +996,7 @@ public sealed class BSPrim : BSPhysObject
|
||||||
_buoyancy = value;
|
_buoyancy = value;
|
||||||
// DetailLog("{0},BSPrim.setForceBuoyancy,taint,buoy={1}", LocalID, _buoyancy);
|
// DetailLog("{0},BSPrim.setForceBuoyancy,taint,buoy={1}", LocalID, _buoyancy);
|
||||||
// Force the recalculation of the various inertia,etc variables in the object
|
// 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);
|
UpdatePhysicalMassProperties(_mass, true);
|
||||||
ActivateIfPhysical(false);
|
ActivateIfPhysical(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +1,21 @@
|
||||||
CURRENT PRIORITIES
|
CURRENT PRIORITIES
|
||||||
=================================================
|
=================================================
|
||||||
Smooth avatar movement with motor (DONE)
|
Redo BulletSimAPI to allow native C# implementation of Bullet option.
|
||||||
Should motor update be all at taint-time? (Yes, DONE)
|
Avatar movement
|
||||||
Fix avatar slowly sliding when standing (zero motion when stopped)
|
flying into a wall doesn't stop avatar who keeps appearing to move through the obsticle
|
||||||
llApplyImpulse()
|
walking up stairs is not calibrated correctly (stairs out of Kepler cabin)
|
||||||
Compare mass/movement in OS and SL. Calibrate actions.
|
avatar capsule rotation completed
|
||||||
llSetBuoyancy()
|
|
||||||
Boats float low in the water
|
|
||||||
Enable vehicle border crossings (at least as poorly as ODE)
|
Enable vehicle border crossings (at least as poorly as ODE)
|
||||||
Terrain skirts
|
Terrain skirts
|
||||||
Avatar created in previous region and not new region when crossing border
|
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)
|
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 movement on terrain smoothness
|
||||||
Vehicle script tuning/debugging
|
Vehicle script tuning/debugging
|
||||||
Avanti speed script
|
Avanti speed script
|
||||||
Weapon shooter script
|
Weapon shooter script
|
||||||
limitMotorUp calibration (more down?)
|
limitMotorUp calibration (more down?)
|
||||||
|
Boats float low in the water
|
||||||
|
Add material densities to the material types.
|
||||||
|
|
||||||
CRASHES
|
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))
|
What is expected by some vehicles (turning up friction to moderate speed))
|
||||||
Tune terrain/object friction to be closer to SL.
|
Tune terrain/object friction to be closer to SL.
|
||||||
(Resolution: added material type with friction and resolution)
|
(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)
|
||||||
|
|
Loading…
Reference in New Issue