From 7a5f598399c7373bd146061b478e6d04cb204879 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Thu, 27 Dec 2012 16:05:11 -0800 Subject: BulletSim: move logic for IsColliding, CollidingGround and CollidingObj from individual sub-classes and up to parent BSPhysObject class. --- .../Region/Physics/BulletSPlugin/BSCharacter.cs | 36 ++++++++------------- .../Region/Physics/BulletSPlugin/BSPhysObject.cs | 37 +++++++++++++++++++++- OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 18 ++--------- .../Region/Physics/BulletSPlugin/BulletSimTODO.txt | 3 +- 4 files changed, 55 insertions(+), 39 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index cbc1772..3f7b5e1 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs @@ -584,18 +584,6 @@ public sealed class BSCharacter : BSPhysObject get { return _throttleUpdates; } 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 { set { _floatOnWater = value; @@ -769,22 +757,26 @@ public sealed class BSCharacter : BSPhysObject OMV.Vector3 stepVelocity = _velocityMotor.Step(PhysicsScene.LastTimeStep); - // 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); - } - - // 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) + // Check for cases to turn off the motor. + if ( + // If the walking motor is all done, turn it off + (_velocityMotor.TargetValue.ApproxEquals(OMV.Vector3.Zero, 0.01f) && _velocityMotor.ErrorIsZero) ) { ZeroMotion(true); stepVelocity = OMV.Vector3.Zero; _velocityMotor.Enabled = false; 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; entprop.Velocity = _velocity; diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs index 4bed535..73b5764 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs @@ -182,9 +182,40 @@ public abstract class BSPhysObject : PhysicsActor protected long CollidingStep { get; set; } // The simulation step that last had a collision with the ground 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 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 protected CollisionEventUpdate CollisionCollection; @@ -196,12 +227,16 @@ public abstract class BSPhysObject : PhysicsActor { bool ret = false; - // The following lines make IsColliding() and IsCollidingGround() work + // The following lines make IsColliding(), CollidingGround() and CollidingObj work CollidingStep = PhysicsScene.SimulationStep; if (collidingWith <= PhysicsScene.TerrainManager.HighestTerrainID) { CollidingGroundStep = PhysicsScene.SimulationStep; } + else + { + CollidingObjectStep = PhysicsScene.SimulationStep; + } // prims in the same linkset cannot collide with each other if (collidee != null && (this.Linkset.LinksetID == collidee.Linkset.LinksetID)) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index f804a0f..06e4ada 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs @@ -915,18 +915,6 @@ public sealed class BSPrim : BSPhysObject get { return _throttleUpdates; } 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 { get { // SceneObjectPart removes phantom objects from the physics scene @@ -1006,12 +994,12 @@ public sealed class BSPrim : BSPhysObject public override OMV.Vector3 PIDTarget { set { _PIDTarget = value; } } - public override bool PIDActive { - set { _usePID = value; } - } public override float PIDTau { set { _PIDTau = value; } } + public override bool PIDActive { + set { _usePID = value; } + } // Used for llSetHoverHeight and maybe vehicle height // Hover Height will override MoveTo target's Z diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt b/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt index a66508a..16131cd 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt +++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt @@ -2,9 +2,10 @@ CURRENT PRIORITIES ================================================= 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 + 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) avatar capsule rotation completed +llMoveToTarget Enable vehicle border crossings (at least as poorly as ODE) Terrain skirts Avatar created in previous region and not new region when crossing border -- cgit v1.1