From 33af41905021e6ab2e51873a75b585044e445974 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 19 Jan 2016 22:09:51 -0800 Subject: [PATCH] BulletSim: make collision sounds work most of the time. Seems that collisions usually stop the collider so velocity is often small. Also remove some chatty debug messages. --- .../PhysicsModules/BulletS/BSActorAvatarMove.cs | 2 +- OpenSim/Region/PhysicsModules/BulletS/BSCharacter.cs | 1 + OpenSim/Region/PhysicsModules/BulletS/BSPhysObject.cs | 11 +++++++---- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/OpenSim/Region/PhysicsModules/BulletS/BSActorAvatarMove.cs b/OpenSim/Region/PhysicsModules/BulletS/BSActorAvatarMove.cs index 35823ae49d..79ee00f4ca 100755 --- a/OpenSim/Region/PhysicsModules/BulletS/BSActorAvatarMove.cs +++ b/OpenSim/Region/PhysicsModules/BulletS/BSActorAvatarMove.cs @@ -140,7 +140,7 @@ public class BSActorAvatarMove : BSActor 1f // efficiency ); m_velocityMotor.ErrorZeroThreshold = BSParam.AvatarStopZeroThreshold; - m_velocityMotor.PhysicsScene = m_controllingPrim.PhysScene; // DEBUG DEBUG so motor will output detail log messages. + // m_velocityMotor.PhysicsScene = m_controllingPrim.PhysScene; // DEBUG DEBUG so motor will output detail log messages. SetVelocityAndTarget(m_controllingPrim.RawVelocity, m_controllingPrim.TargetVelocity, true /* inTaintTime */); m_physicsScene.BeforeStep += Mover; diff --git a/OpenSim/Region/PhysicsModules/BulletS/BSCharacter.cs b/OpenSim/Region/PhysicsModules/BulletS/BSCharacter.cs index 4b75e32db6..6d5589fd9b 100644 --- a/OpenSim/Region/PhysicsModules/BulletS/BSCharacter.cs +++ b/OpenSim/Region/PhysicsModules/BulletS/BSCharacter.cs @@ -89,6 +89,7 @@ public sealed class BSCharacter : BSPhysObject _buoyancy = ComputeBuoyancyFromFlying(isFlying); Friction = BSParam.AvatarStandingFriction; Density = BSParam.AvatarDensity; + _isPhysical = true; // Old versions of ScenePresence passed only the height. If width and/or depth are zero, // replace with the default values. diff --git a/OpenSim/Region/PhysicsModules/BulletS/BSPhysObject.cs b/OpenSim/Region/PhysicsModules/BulletS/BSPhysObject.cs index ff6baca149..a70d1b80da 100755 --- a/OpenSim/Region/PhysicsModules/BulletS/BSPhysObject.cs +++ b/OpenSim/Region/PhysicsModules/BulletS/BSPhysObject.cs @@ -505,17 +505,20 @@ public abstract class BSPhysObject : PhysicsActor // Collision sound requires a velocity to know it should happen. This is a lot of computation for a little used feature. OMV.Vector3 relvel = OMV.Vector3.Zero; if (IsPhysical) - relvel = Velocity; + relvel = RawVelocity; if (collidee != null && collidee.IsPhysical) - relvel -= collidee.Velocity; + relvel -= collidee.RawVelocity; newContact.RelativeSpeed = OMV.Vector3.Dot(relvel, contactNormal); + // DetailLog("{0},{1}.Collision.AddCollider,vel={2},contee.vel={3},relvel={4},relspeed={5}", + // LocalID, TypeName, RawVelocity, (collidee == null ? OMV.Vector3.Zero : collidee.RawVelocity), relvel, newContact.RelativeSpeed); lock (PhysScene.CollisionLock) { CollisionCollection.AddCollider(collideeLocalID, newContact); } - DetailLog("{0},{1}.Collision.AddCollider,call,with={2},point={3},normal={4},depth={5},colliderMoving={6}", - LocalID, TypeName, collideeLocalID, contactPoint, contactNormal, pentrationDepth, ColliderIsMoving); + DetailLog("{0},{1}.Collision.AddCollider,call,with={2},point={3},normal={4},depth={5},speed={6},colliderMoving={7}", + LocalID, TypeName, collideeLocalID, contactPoint, contactNormal, pentrationDepth, + newContact.RelativeSpeed, ColliderIsMoving); ret = true; }