From a7ece8c688a44c0d0b05162dbb1e98a1ea4e95ff Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 19 May 2012 00:17:37 +0100 Subject: add colliders relative velocity projected in collision direction to collisions report information. --- OpenSim/Region/Physics/Manager/PhysicsActor.cs | 2 ++ OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 1 + OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs | 11 ++++++++++- 3 files changed, 13 insertions(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index b66d7f1..fb90887 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs @@ -59,12 +59,14 @@ namespace OpenSim.Region.Physics.Manager public Vector3 Position; public Vector3 SurfaceNormal; public float PenetrationDepth; + public float RelativeSpeed; public ContactPoint(Vector3 position, Vector3 surfaceNormal, float penetrationDepth) { Position = position; SurfaceNormal = surfaceNormal; PenetrationDepth = penetrationDepth; + RelativeSpeed = 0f; // for now let this one be set explicity } } diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs index b0711d7..bfff3d4 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs @@ -903,6 +903,7 @@ namespace OpenSim.Region.Physics.OdePlugin contact.SurfaceNormal.X = 0f; contact.SurfaceNormal.Y = 0f; contact.SurfaceNormal.Z = -1f; + contact.RelativeSpeed = -vel.Z; AddCollisionEvent(0, contact); vec.Z *= 0.5f; diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs index ddfdea4..11638d7 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs @@ -1064,7 +1064,7 @@ namespace OpenSim.Region.Physics.OdePlugin obj2LocalID = 0; bool p1events = p1.SubscribedEvents(); bool p2events = p2.SubscribedEvents(); - + if (p1.IsVolumeDtc) p2events = false; if (p2.IsVolumeDtc) @@ -1073,6 +1073,15 @@ namespace OpenSim.Region.Physics.OdePlugin if (!(p2events || p1events)) return; + Vector3 vel = Vector3.Zero; + if (p2 != null && p2.IsPhysical) + vel = p2.Velocity; + + if (p1 != null && p1.IsPhysical) + vel -= p1.Velocity; + + contact.RelativeSpeed = Vector3.Dot(vel, contact.SurfaceNormal); + switch ((ActorTypes)p1.PhysicsActorType) { case ActorTypes.Agent: -- cgit v1.1