BulletSim: move logic for IsColliding, CollidingGround and CollidingObj from individual sub-classes and up to parent BSPhysObject class.
parent
5afab9bcfe
commit
7a5f598399
|
@ -584,18 +584,6 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
get { return _throttleUpdates; }
|
get { return _throttleUpdates; }
|
||||||
set { _throttleUpdates = value; }
|
set { _throttleUpdates = value; }
|
||||||
}
|
}
|
||||||
public override bool IsColliding {
|
|
||||||
get { return (CollidingStep == PhysicsScene.SimulationStep); }
|
|
||||||
set { _isColliding = value; }
|
|
||||||
}
|
|
||||||
public override bool CollidingGround {
|
|
||||||
get { return (CollidingGroundStep == PhysicsScene.SimulationStep); }
|
|
||||||
set { CollidingGround = value; }
|
|
||||||
}
|
|
||||||
public override bool CollidingObj {
|
|
||||||
get { return _collidingObj; }
|
|
||||||
set { _collidingObj = value; }
|
|
||||||
}
|
|
||||||
public override bool FloatOnWater {
|
public override bool FloatOnWater {
|
||||||
set {
|
set {
|
||||||
_floatOnWater = value;
|
_floatOnWater = value;
|
||||||
|
@ -769,22 +757,26 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
|
|
||||||
OMV.Vector3 stepVelocity = _velocityMotor.Step(PhysicsScene.LastTimeStep);
|
OMV.Vector3 stepVelocity = _velocityMotor.Step(PhysicsScene.LastTimeStep);
|
||||||
|
|
||||||
// If falling, we keep the world's downward vector no matter what the other axis specify.
|
// Check for cases to turn off the motor.
|
||||||
if (!Flying && !IsColliding)
|
if (
|
||||||
{
|
// If the walking motor is all done, turn it off
|
||||||
stepVelocity.Z = entprop.Velocity.Z;
|
(_velocityMotor.TargetValue.ApproxEquals(OMV.Vector3.Zero, 0.01f) && _velocityMotor.ErrorIsZero) )
|
||||||
DetailLog("{0},BSCharacter.UpdateProperties,taint,overrideStepZWithWorldZ,stepVel={1}", LocalID, stepVelocity);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the user has said stop and we've stopped applying velocity correction,
|
|
||||||
// the motor can be turned off. Set the velocity to zero so the zero motion is sent to the viewer.
|
|
||||||
if (_velocityMotor.TargetValue.ApproxEquals(OMV.Vector3.Zero, 0.01f) && _velocityMotor.ErrorIsZero)
|
|
||||||
{
|
{
|
||||||
ZeroMotion(true);
|
ZeroMotion(true);
|
||||||
stepVelocity = OMV.Vector3.Zero;
|
stepVelocity = OMV.Vector3.Zero;
|
||||||
_velocityMotor.Enabled = false;
|
_velocityMotor.Enabled = false;
|
||||||
DetailLog("{0},BSCharacter.UpdateProperties,taint,disableVelocityMotor,m={1}", LocalID, _velocityMotor);
|
DetailLog("{0},BSCharacter.UpdateProperties,taint,disableVelocityMotor,m={1}", LocalID, _velocityMotor);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// If the motor is not being turned off...
|
||||||
|
// If falling, we keep the world's downward vector no matter what the other axis specify.
|
||||||
|
if (!Flying && !IsColliding)
|
||||||
|
{
|
||||||
|
stepVelocity.Z = entprop.Velocity.Z;
|
||||||
|
DetailLog("{0},BSCharacter.UpdateProperties,taint,overrideStepZWithWorldZ,stepVel={1}", LocalID, stepVelocity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_velocity = stepVelocity;
|
_velocity = stepVelocity;
|
||||||
entprop.Velocity = _velocity;
|
entprop.Velocity = _velocity;
|
||||||
|
|
|
@ -182,9 +182,40 @@ public abstract class BSPhysObject : PhysicsActor
|
||||||
protected long CollidingStep { get; set; }
|
protected long CollidingStep { get; set; }
|
||||||
// The simulation step that last had a collision with the ground
|
// The simulation step that last had a collision with the ground
|
||||||
protected long CollidingGroundStep { get; set; }
|
protected long CollidingGroundStep { get; set; }
|
||||||
|
// The simulation step that last collided with an object
|
||||||
|
protected long CollidingObjectStep { get; set; }
|
||||||
// The collision flags we think are set in Bullet
|
// The collision flags we think are set in Bullet
|
||||||
protected CollisionFlags CurrentCollisionFlags { get; set; }
|
protected CollisionFlags CurrentCollisionFlags { get; set; }
|
||||||
|
|
||||||
|
public override bool IsColliding {
|
||||||
|
get { return (CollidingStep == PhysicsScene.SimulationStep); }
|
||||||
|
set {
|
||||||
|
if (value)
|
||||||
|
CollidingStep = PhysicsScene.SimulationStep;
|
||||||
|
else
|
||||||
|
CollidingStep = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public override bool CollidingGround {
|
||||||
|
get { return (CollidingGroundStep == PhysicsScene.SimulationStep); }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value)
|
||||||
|
CollidingGroundStep = PhysicsScene.SimulationStep;
|
||||||
|
else
|
||||||
|
CollidingGroundStep = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public override bool CollidingObj {
|
||||||
|
get { return (CollidingObjectStep == PhysicsScene.SimulationStep); }
|
||||||
|
set {
|
||||||
|
if (value)
|
||||||
|
CollidingObjectStep = PhysicsScene.SimulationStep;
|
||||||
|
else
|
||||||
|
CollidingObjectStep = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// The collisions that have been collected this tick
|
// The collisions that have been collected this tick
|
||||||
protected CollisionEventUpdate CollisionCollection;
|
protected CollisionEventUpdate CollisionCollection;
|
||||||
|
|
||||||
|
@ -196,12 +227,16 @@ public abstract class BSPhysObject : PhysicsActor
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
// The following lines make IsColliding() and IsCollidingGround() work
|
// The following lines make IsColliding(), CollidingGround() and CollidingObj work
|
||||||
CollidingStep = PhysicsScene.SimulationStep;
|
CollidingStep = PhysicsScene.SimulationStep;
|
||||||
if (collidingWith <= PhysicsScene.TerrainManager.HighestTerrainID)
|
if (collidingWith <= PhysicsScene.TerrainManager.HighestTerrainID)
|
||||||
{
|
{
|
||||||
CollidingGroundStep = PhysicsScene.SimulationStep;
|
CollidingGroundStep = PhysicsScene.SimulationStep;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CollidingObjectStep = PhysicsScene.SimulationStep;
|
||||||
|
}
|
||||||
|
|
||||||
// prims in the same linkset cannot collide with each other
|
// prims in the same linkset cannot collide with each other
|
||||||
if (collidee != null && (this.Linkset.LinksetID == collidee.Linkset.LinksetID))
|
if (collidee != null && (this.Linkset.LinksetID == collidee.Linkset.LinksetID))
|
||||||
|
|
|
@ -915,18 +915,6 @@ public sealed class BSPrim : BSPhysObject
|
||||||
get { return _throttleUpdates; }
|
get { return _throttleUpdates; }
|
||||||
set { _throttleUpdates = value; }
|
set { _throttleUpdates = value; }
|
||||||
}
|
}
|
||||||
public override bool IsColliding {
|
|
||||||
get { return (CollidingStep == PhysicsScene.SimulationStep); }
|
|
||||||
set { _isColliding = value; }
|
|
||||||
}
|
|
||||||
public override bool CollidingGround {
|
|
||||||
get { return (CollidingGroundStep == PhysicsScene.SimulationStep); }
|
|
||||||
set { _collidingGround = value; }
|
|
||||||
}
|
|
||||||
public override bool CollidingObj {
|
|
||||||
get { return _collidingObj; }
|
|
||||||
set { _collidingObj = value; }
|
|
||||||
}
|
|
||||||
public bool IsPhantom {
|
public bool IsPhantom {
|
||||||
get {
|
get {
|
||||||
// SceneObjectPart removes phantom objects from the physics scene
|
// SceneObjectPart removes phantom objects from the physics scene
|
||||||
|
@ -1006,12 +994,12 @@ public sealed class BSPrim : BSPhysObject
|
||||||
public override OMV.Vector3 PIDTarget {
|
public override OMV.Vector3 PIDTarget {
|
||||||
set { _PIDTarget = value; }
|
set { _PIDTarget = value; }
|
||||||
}
|
}
|
||||||
public override bool PIDActive {
|
|
||||||
set { _usePID = value; }
|
|
||||||
}
|
|
||||||
public override float PIDTau {
|
public override float PIDTau {
|
||||||
set { _PIDTau = value; }
|
set { _PIDTau = value; }
|
||||||
}
|
}
|
||||||
|
public override bool PIDActive {
|
||||||
|
set { _usePID = value; }
|
||||||
|
}
|
||||||
|
|
||||||
// Used for llSetHoverHeight and maybe vehicle height
|
// Used for llSetHoverHeight and maybe vehicle height
|
||||||
// Hover Height will override MoveTo target's Z
|
// Hover Height will override MoveTo target's Z
|
||||||
|
|
|
@ -2,9 +2,10 @@ CURRENT PRIORITIES
|
||||||
=================================================
|
=================================================
|
||||||
Redo BulletSimAPI to allow native C# implementation of Bullet option.
|
Redo BulletSimAPI to allow native C# implementation of Bullet option.
|
||||||
Avatar movement
|
Avatar movement
|
||||||
flying into a wall doesn't stop avatar who keeps appearing to move through the obsticle
|
flying into a wall doesn't stop avatar who keeps appearing to move through the obstacle
|
||||||
walking up stairs is not calibrated correctly (stairs out of Kepler cabin)
|
walking up stairs is not calibrated correctly (stairs out of Kepler cabin)
|
||||||
avatar capsule rotation completed
|
avatar capsule rotation completed
|
||||||
|
llMoveToTarget
|
||||||
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
|
||||||
|
|
Loading…
Reference in New Issue