From 70e0a86601ed33113a87189ee53a40e12790c609 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Fri, 28 Dec 2012 11:56:07 -0800 Subject: BulletSim: fix problem of avatars appearing to walk through walls by moving the movement motor to a pre-step action and out of its questionable previous home in UpdateProperties. --- .../Region/Physics/BulletSPlugin/BSCharacter.cs | 106 +++++++++++---------- 1 file changed, 55 insertions(+), 51 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index 3f7b5e1..90936d0 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs @@ -91,17 +91,7 @@ public sealed class BSCharacter : BSPhysObject if (_size.X == 0f) _size.X = BSParam.AvatarCapsuleDepth; if (_size.Y == 0f) _size.Y = BSParam.AvatarCapsuleWidth; - // A motor to control the acceleration and deceleration of the avatar movement. - // _velocityMotor = new BSVMotor("BSCharacter.Velocity", 3f, 5f, BSMotor.InfiniteVector, 1f); - // _velocityMotor = new BSPIDVMotor("BSCharacter.Velocity", 3f, 5f, BSMotor.InfiniteVector, 1f); - // Infinite decay and timescale values so motor only changes current to target values. - _velocityMotor = new BSVMotor("BSCharacter.Velocity", - 0.2f, // time scale - BSMotor.Infinite, // decay time scale - BSMotor.InfiniteVector, // friction timescale - 1f // efficiency - ); - _velocityMotor.PhysicsScene = PhysicsScene; // DEBUG DEBUG so motor will output detail log messages. + SetupMovementMotor(); _flying = isFlying; _orientation = OMV.Quaternion.Identity; @@ -152,13 +142,12 @@ public sealed class BSCharacter : BSPhysObject ZeroMotion(true); ForcePosition = _position; + // Set the velocity and compute the proper friction - ForceVelocity = _velocity; - // Setting the current and target in the motor will cause it to start computing any deceleration. _velocityMotor.Reset(); - _velocityMotor.SetCurrent(_velocity); _velocityMotor.SetTarget(_velocity); - _velocityMotor.Enabled = false; + _velocityMotor.SetCurrent(_velocity); + ForceVelocity = _velocity; // This will enable or disable the flying buoyancy of the avatar. // Needs to be reset especially when an avatar is recreated after crossing a region boundry. @@ -192,6 +181,48 @@ public sealed class BSCharacter : BSPhysObject PhysBody.ApplyCollisionMask(); } + // The avatar's movement is controlled by this motor that speeds up and slows down + // the avatar seeking to reach the motor's target speed. + // This motor runs as a prestep action for the avatar so it will keep the avatar + // standing as well as moving. Destruction of the avatar will destroy the pre-step action. + private void SetupMovementMotor() + { + + // Someday, use a PID motor for asymmetric speed up and slow down + // _velocityMotor = new BSPIDVMotor("BSCharacter.Velocity", 3f, 5f, BSMotor.InfiniteVector, 1f); + + // Infinite decay and timescale values so motor only changes current to target values. + _velocityMotor = new BSVMotor("BSCharacter.Velocity", + 0.2f, // time scale + BSMotor.Infinite, // decay time scale + BSMotor.InfiniteVector, // friction timescale + 1f // efficiency + ); + // _velocityMotor.PhysicsScene = PhysicsScene; // DEBUG DEBUG so motor will output detail log messages. + + RegisterPreStepAction("BSCharactor.Movement", LocalID, delegate(float timeStep) + { + // TODO: Decide if the step parameters should be changed depending on the avatar's + // state (flying, colliding, ...). There is code in ODE to do this. + + OMV.Vector3 stepVelocity = _velocityMotor.Step(timeStep); + + // If falling, we keep the world's downward vector no matter what the other axis specify. + if (!Flying && !IsColliding) + { + stepVelocity.Z = _velocity.Z; + DetailLog("{0},BSCharacter.MoveMotor,taint,overrideStepZWithWorldZ,stepVel={1}", + LocalID, stepVelocity); + } + + // 'stepVelocity' is now the speed we'd like the avatar to move in. Turn that into an instantanous force. + OMV.Vector3 moveForce = (stepVelocity - _velocity) * Mass / PhysicsScene.LastTimeStep; + DetailLog("{0},BSCharacter.MoveMotor,move,stepVel={1},vel={2},mass={3},moveForce={4}", + LocalID, stepVelocity, _velocity, Mass, moveForce); + AddForce(moveForce, false, true); + }); + } + public override void RequestPhysicsterseUpdate() { base.RequestPhysicsterseUpdate(); @@ -668,7 +699,13 @@ public sealed class BSCharacter : BSPhysObject public override float APIDStrength { set { return; } } public override float APIDDamping { set { return; } } - public override void AddForce(OMV.Vector3 force, bool pushforce) { + public override void AddForce(OMV.Vector3 force, bool pushforce) + { + // Since this force is being applied in only one step, make this a force per second. + OMV.Vector3 addForce = force / PhysicsScene.LastTimeStep; + AddForce(addForce, pushforce, false); + } + private void AddForce(OMV.Vector3 force, bool pushforce, bool inTaintTime) { if (force.IsFinite()) { float magnitude = force.Length(); @@ -678,10 +715,10 @@ public sealed class BSCharacter : BSPhysObject force = force / magnitude * BSParam.MaxAddForceMagnitude; } - OMV.Vector3 addForce = force / PhysicsScene.LastTimeStep; + OMV.Vector3 addForce = force; DetailLog("{0},BSCharacter.addForce,call,force={1}", LocalID, addForce); - PhysicsScene.TaintedObject("BSCharacter.AddForce", delegate() + PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.AddForce", delegate() { // Bullet adds this central force to the total force for this tick DetailLog("{0},BSCharacter.addForce,taint,force={1}", LocalID, addForce); @@ -750,39 +787,6 @@ public sealed class BSCharacter : BSPhysObject // Do some sanity checking for the avatar. Make sure it's above ground and inbounds. PositionSanityCheck(true); - if (_velocityMotor.Enabled) - { - // TODO: Decide if the step parameters should be changed depending on the avatar's - // state (flying, colliding, ...). - - OMV.Vector3 stepVelocity = _velocityMotor.Step(PhysicsScene.LastTimeStep); - - // 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; - BulletSimAPI.SetLinearVelocity2(PhysBody.ptr, _velocity); - } - // remember the current and last set values LastEntityProperties = CurrentEntityProperties; CurrentEntityProperties = entprop; -- cgit v1.1 From 7266eeca6efd10852a062cfc802a50c346b7b119 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Fri, 28 Dec 2012 12:01:57 -0800 Subject: BulletSim: add 'AvatarAlwaysRunFactor' parameter and use in setTargetVelocity to implement the 'always run' feature. --- OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | 6 +++--- OpenSim/Region/Physics/BulletSPlugin/BSParam.cs | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index 90936d0..901f976 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs @@ -464,15 +464,15 @@ public sealed class BSCharacter : BSPhysObject { DetailLog("{0},BSCharacter.setTargetVelocity,call,vel={1}", LocalID, value); OMV.Vector3 targetVel = value; + if (_setAlwaysRun) + targetVel *= BSParam.AvatarAlwaysRunFactor; + PhysicsScene.TaintedObject("BSCharacter.setTargetVelocity", delegate() { _velocityMotor.Reset(); _velocityMotor.SetTarget(targetVel); _velocityMotor.SetCurrent(_velocity); _velocityMotor.Enabled = true; - - // Make sure a property update happens next step so the motor gets incorporated. - BulletSimAPI.PushUpdate2(PhysBody.ptr); }); } } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs index f8f24bd..5c8553a 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs @@ -68,6 +68,7 @@ public static class BSParam // Avatar parameters public static float AvatarFriction { get; private set; } public static float AvatarStandingFriction { get; private set; } + public static float AvatarAlwaysRunFactor { get; private set; } public static float AvatarDensity { get; private set; } public static float AvatarRestitution { get; private set; } public static float AvatarCapsuleWidth { get; private set; } @@ -367,6 +368,11 @@ public static class BSParam (s,cf,p,v) => { AvatarStandingFriction = cf.GetFloat(p, v); }, (s) => { return AvatarStandingFriction; }, (s,p,l,v) => { AvatarStandingFriction = v; } ), + new ParameterDefn("AvatarAlwaysRunFactor", "Speed multiplier if avatar is set to always run", + 1.3f, + (s,cf,p,v) => { AvatarAlwaysRunFactor = cf.GetFloat(p, v); }, + (s) => { return AvatarAlwaysRunFactor; }, + (s,p,l,v) => { AvatarAlwaysRunFactor = v; } ), new ParameterDefn("AvatarDensity", "Density of an avatar. Changed on avatar recreation.", 3.5f, (s,cf,p,v) => { AvatarDensity = cf.GetFloat(p, v); }, -- cgit v1.1 From db6c0363f05db8b2a180eff04db9138a378d227f Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sat, 29 Dec 2012 08:03:57 -0800 Subject: BulletSim: tweeking avatar capsule code in an attempt to have asymmetrical avatar capsule work now that rotation is being passed from the simulator. Turns out the Bullet capsule is just not very functional: it doesn't scale properly, the implementation only half does asymmetry and, in general, is hard to work with. Avatar shape is about what it was before these changes. Added initial data structures for avatar shape mesh. --- .../Region/Physics/BulletSPlugin/BSCharacter.cs | 104 ++++++++++++--------- .../Physics/BulletSPlugin/BSShapeCollection.cs | 6 +- OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs | 13 +++ .../Region/Physics/BulletSPlugin/BulletSimAPI.cs | 4 +- 4 files changed, 81 insertions(+), 46 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index 901f976..9659542 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs @@ -66,7 +66,6 @@ public sealed class BSCharacter : BSPhysObject private float _buoyancy; // The friction and velocity of the avatar is modified depending on whether walking or not. - private OMV.Vector3 _appliedVelocity; // the last velocity applied to the avatar private float _currentFriction; // the friction currently being used (changed by setVelocity). private BSVMotor _velocityMotor; @@ -85,27 +84,27 @@ public sealed class BSCharacter : BSPhysObject _physicsActorType = (int)ActorTypes.Agent; _position = pos; - // Old versions of ScenePresence passed only the height. If width and/or depth are zero, - // replace with the default values. - _size = size; - if (_size.X == 0f) _size.X = BSParam.AvatarCapsuleDepth; - if (_size.Y == 0f) _size.Y = BSParam.AvatarCapsuleWidth; - - SetupMovementMotor(); - _flying = isFlying; _orientation = OMV.Quaternion.Identity; _velocity = OMV.Vector3.Zero; - _appliedVelocity = OMV.Vector3.Zero; _buoyancy = ComputeBuoyancyFromFlying(isFlying); _currentFriction = BSParam.AvatarStandingFriction; _avatarDensity = BSParam.AvatarDensity; - // The dimensions of the avatar capsule are kept in the scale. + // Old versions of ScenePresence passed only the height. If width and/or depth are zero, + // replace with the default values. + _size = size; + if (_size.X == 0f) _size.X = BSParam.AvatarCapsuleDepth; + if (_size.Y == 0f) _size.Y = BSParam.AvatarCapsuleWidth; + + // The dimensions of the physical capsule are kept in the scale. // Physics creates a unit capsule which is scaled by the physics engine. - ComputeAvatarScale(_size); + Scale = ComputeAvatarScale(_size); // set _avatarVolume and _mass based on capsule size, _density and Scale ComputeAvatarVolumeAndMass(); + + SetupMovementMotor(); + DetailLog("{0},BSCharacter.create,call,size={1},scale={2},density={3},volume={4},mass={5}", LocalID, _size, Scale, _avatarDensity, _avatarVolume, RawMass); @@ -217,9 +216,21 @@ public sealed class BSCharacter : BSPhysObject // 'stepVelocity' is now the speed we'd like the avatar to move in. Turn that into an instantanous force. OMV.Vector3 moveForce = (stepVelocity - _velocity) * Mass / PhysicsScene.LastTimeStep; - DetailLog("{0},BSCharacter.MoveMotor,move,stepVel={1},vel={2},mass={3},moveForce={4}", - LocalID, stepVelocity, _velocity, Mass, moveForce); - AddForce(moveForce, false, true); + + // If moveForce is very small, zero things so we don't keep sending microscopic updates to the user + float moveForceMagnitudeSquared = moveForce.LengthSquared(); + if (moveForceMagnitudeSquared < 0.0001) + { + DetailLog("{0},BSCharacter.MoveMotor,zeroMovement,stepVel={1},vel={2},mass={3},magSq={4},moveForce={5}", + LocalID, stepVelocity, _velocity, Mass, moveForceMagnitudeSquared, moveForce); + ForceVelocity = OMV.Vector3.Zero; + } + else + { + DetailLog("{0},BSCharacter.MoveMotor,move,stepVel={1},vel={2},mass={3},moveForce={4}", + LocalID, stepVelocity, _velocity, Mass, moveForce); + AddForce(moveForce, false, true); + } }); } @@ -238,14 +249,13 @@ public sealed class BSCharacter : BSPhysObject } set { - // When an avatar's size is set, only the height is changed. _size = value; // Old versions of ScenePresence passed only the height. If width and/or depth are zero, // replace with the default values. if (_size.X == 0f) _size.X = BSParam.AvatarCapsuleDepth; if (_size.Y == 0f) _size.Y = BSParam.AvatarCapsuleWidth; - ComputeAvatarScale(_size); + Scale = ComputeAvatarScale(_size); ComputeAvatarVolumeAndMass(); DetailLog("{0},BSCharacter.setSize,call,size={1},scale={2},density={3},volume={4},mass={5}", LocalID, _size, Scale, _avatarDensity, _avatarVolume, RawMass); @@ -521,8 +531,6 @@ public sealed class BSCharacter : BSPhysObject BulletSimAPI.SetFriction2(PhysBody.ptr, _currentFriction); } } - // Remember the set velocity so we can suppress the reduction by friction, ... - _appliedVelocity = value; BulletSimAPI.SetLinearVelocity2(PhysBody.ptr, _velocity); BulletSimAPI.Activate2(PhysBody.ptr, true); @@ -554,11 +562,7 @@ public sealed class BSCharacter : BSPhysObject // m_log.DebugFormat("{0}: set orientation to {1}", LogHeader, _orientation); PhysicsScene.TaintedObject("BSCharacter.setOrientation", delegate() { - if (PhysBody.HasPhysicalBody) - { - // _position = BulletSimAPI.GetPosition2(BSBody.ptr); - BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation); - } + ForceOrientation = _orientation; }); } } @@ -573,7 +577,11 @@ public sealed class BSCharacter : BSPhysObject set { _orientation = value; - BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation); + if (PhysBody.HasPhysicalBody) + { + // _position = BulletSimAPI.GetPosition2(BSBody.ptr); + BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation); + } } } public override int PhysicsActorType { @@ -716,7 +724,7 @@ public sealed class BSCharacter : BSPhysObject } OMV.Vector3 addForce = force; - DetailLog("{0},BSCharacter.addForce,call,force={1}", LocalID, addForce); + // DetailLog("{0},BSCharacter.addForce,call,force={1}", LocalID, addForce); PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.AddForce", delegate() { @@ -740,21 +748,31 @@ public sealed class BSCharacter : BSPhysObject public override void SetMomentum(OMV.Vector3 momentum) { } - private void ComputeAvatarScale(OMV.Vector3 size) + private OMV.Vector3 ComputeAvatarScale(OMV.Vector3 size) { - OMV.Vector3 newScale = size; - // newScale.X = PhysicsScene.Params.avatarCapsuleWidth; - // newScale.Y = PhysicsScene.Params.avatarCapsuleDepth; - - // From the total height, remove the capsule half spheres that are at each end - // The 1.15f came from ODE. Not sure what this factors in. - // newScale.Z = (size.Z * 1.15f) - (newScale.X + newScale.Y); + OMV.Vector3 newScale; + + // Bullet's capsule total height is the "passed height + radius * 2"; + // The base capsule is 1 diameter and 2 height (passed radius=0.5, passed height = 1) + // The number we pass in for 'scaling' is the multiplier to get that base + // shape to be the size desired. + // So, when creating the scale for the avatar height, we take the passed height + // (size.Z) and remove the caps. + // Another oddity of the Bullet capsule implementation is that it presumes the Y + // dimension is the radius of the capsule. Even though some of the code allows + // for a asymmetrical capsule, other parts of the code presume it is cylindrical. + + // Scale is multiplier of radius with one of "0.5" + newScale.X = size.X / 2f; + newScale.Y = size.Y / 2f; // The total scale height is the central cylindar plus the caps on the two ends. - newScale.Z = size.Z + (Math.Min(size.X, size.Y) * 2f); + newScale.Z = (size.Z + (Math.Min(size.X, size.Y) * 2)) / 2f; + // If smaller than the endcaps, just fake like we're almost that small + if (newScale.Z < 0) + newScale.Z = 0.1f; - // Convert diameters to radii and height to half height -- the way Bullet expects it. - Scale = newScale / 2f; + return newScale; } // set _avatarVolume and _mass based on capsule size, _density and Scale @@ -762,14 +780,14 @@ public sealed class BSCharacter : BSPhysObject { _avatarVolume = (float)( Math.PI - * Scale.X - * Scale.Y // the area of capsule cylinder - * Scale.Z // times height of capsule cylinder + * Size.X / 2f + * Size.Y / 2f // the area of capsule cylinder + * Size.Z // times height of capsule cylinder + 1.33333333f * Math.PI - * Scale.X - * Math.Min(Scale.X, Scale.Y) - * Scale.Y // plus the volume of the capsule end caps + * Size.X / 2f + * Math.Min(Size.X, Size.Y) / 2 + * Size.Y / 2f // plus the volume of the capsule end caps ); _mass = _avatarDensity * _avatarVolume; } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs index 65ebcaa..0cc51b0 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs @@ -420,8 +420,7 @@ public sealed class BSShapeCollection : IDisposable if (!haveShape && prim.PreferredPhysicalShape == BSPhysicsShapeType.SHAPE_CAPSULE) { // an avatar capsule is close to a native shape (it is not shared) - GetReferenceToNativeShape(prim, BSPhysicsShapeType.SHAPE_CAPSULE, - FixedShapeKey.KEY_CAPSULE, shapeCallback); + GetReferenceToNativeShape(prim, BSPhysicsShapeType.SHAPE_CAPSULE, FixedShapeKey.KEY_CAPSULE, shapeCallback); if (DDetail) DetailLog("{0},BSShapeCollection.CreateGeom,avatarCapsule,shape={1}", prim.LocalID, prim.PhysShape); ret = true; haveShape = true; @@ -573,6 +572,9 @@ public sealed class BSShapeCollection : IDisposable { // The proper scale has been calculated in the prim. newShape = new BulletShape( + // Bullet's capsule total height is the passed "height + (radius * 2)" so, the base + // capsule is radius of 0.5f (1 diameter) and height of two (1.0f + 0.5f * 2)". + // This must be taken into account when computing the scaling of the capsule. BulletSimAPI.BuildCapsuleShape2(PhysicsScene.World.ptr, 1f, 1f, prim.Scale) , shapeType); if (DDetail) DetailLog("{0},BSShapeCollection.BuiletPhysicalNativeShape,capsule,scale={1}", prim.LocalID, prim.Scale); diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs index 96cd55e..c7885c6 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs @@ -205,4 +205,17 @@ public class BSShapeCompound : BSShape } public override void Dereference(BSScene physicsScene) { } } + +public class BSShapeAvatar : BSShape +{ + private static string LogHeader = "[BULLETSIM SHAPE AVATAR]"; + public BSShapeAvatar() : base() + { + } + public static BSShape GetReference(BSPhysObject prim) + { + return new BSShapeNull(); + } + public override void Dereference(BSScene physicsScene) { } +} } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs index eb4d039..b909b38 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs @@ -69,6 +69,7 @@ public enum BSPhysicsShapeType SHAPE_TERRAIN = 21, SHAPE_COMPOUND = 22, SHAPE_HEIGHTMAP = 23, + SHAPE_AVATAR = 24, }; // The native shapes have predefined shape hash keys @@ -79,7 +80,8 @@ public enum FixedShapeKey : ulong KEY_SPHERE = 2, KEY_CONE = 3, KEY_CYLINDER = 4, - KEY_CAPSULE = 5, + KEY_CAPSULE = 5, + KEY_AVATAR = 6, } [StructLayout(LayoutKind.Sequential)] -- cgit v1.1 From 0538096fa3397c52b1171a3ec83dc88489002710 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sat, 29 Dec 2012 08:32:57 -0800 Subject: BulletSim: an 'if' to suppress multiple setting of avatar orientation. Looks like the viewer bombards the server with avatar orientation information (we're talking several hundred a second) when the avatar is being turned or when walking. This change just reduces the number of 'set' calls into unmanaged code. --- OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index 9659542..e19b5b3 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs @@ -558,12 +558,16 @@ public sealed class BSCharacter : BSPhysObject public override OMV.Quaternion Orientation { get { return _orientation; } set { - _orientation = value; - // m_log.DebugFormat("{0}: set orientation to {1}", LogHeader, _orientation); - PhysicsScene.TaintedObject("BSCharacter.setOrientation", delegate() + // Orientation is set zillions of times when an avatar is walking. It's like + // the viewer doesn't trust us. + if (_orientation != value) { - ForceOrientation = _orientation; - }); + _orientation = value; + PhysicsScene.TaintedObject("BSCharacter.setOrientation", delegate() + { + ForceOrientation = _orientation; + }); + } } } // Go directly to Bullet to get/set the value. -- cgit v1.1 From 28a8949b9f315e9257a6c51d8872cd99d00fe556 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sat, 29 Dec 2012 10:19:47 -0800 Subject: BulletSim: remove check for small motor movement because, while it did the right thing for stopping (speed reducing to zero), it prevented movement from starting (speed increasing from zero). Will revisit when the generalize PID motor is debugged. --- OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | 7 +++++-- OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index e19b5b3..3b77e49 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs @@ -217,6 +217,7 @@ public sealed class BSCharacter : BSPhysObject // 'stepVelocity' is now the speed we'd like the avatar to move in. Turn that into an instantanous force. OMV.Vector3 moveForce = (stepVelocity - _velocity) * Mass / PhysicsScene.LastTimeStep; + /* // If moveForce is very small, zero things so we don't keep sending microscopic updates to the user float moveForceMagnitudeSquared = moveForce.LengthSquared(); if (moveForceMagnitudeSquared < 0.0001) @@ -227,10 +228,12 @@ public sealed class BSCharacter : BSPhysObject } else { - DetailLog("{0},BSCharacter.MoveMotor,move,stepVel={1},vel={2},mass={3},moveForce={4}", - LocalID, stepVelocity, _velocity, Mass, moveForce); AddForce(moveForce, false, true); } + */ + DetailLog("{0},BSCharacter.MoveMotor,move,stepVel={1},vel={2},mass={3},moveForce={4}", + LocalID, stepVelocity, _velocity, Mass, moveForce); + AddForce(moveForce, false, true); }); } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs index b909b38..b361498 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs @@ -80,7 +80,7 @@ public enum FixedShapeKey : ulong KEY_SPHERE = 2, KEY_CONE = 3, KEY_CYLINDER = 4, - KEY_CAPSULE = 5, + KEY_CAPSULE = 5, KEY_AVATAR = 6, } -- cgit v1.1