add colliders relative velocity projected in collision direction to collisions report information.

avinationmerge
UbitUmarov 2012-05-19 00:17:37 +01:00
parent 0d0c472181
commit a7ece8c688
3 changed files with 13 additions and 1 deletions

View File

@ -59,12 +59,14 @@ namespace OpenSim.Region.Physics.Manager
public Vector3 Position; public Vector3 Position;
public Vector3 SurfaceNormal; public Vector3 SurfaceNormal;
public float PenetrationDepth; public float PenetrationDepth;
public float RelativeSpeed;
public ContactPoint(Vector3 position, Vector3 surfaceNormal, float penetrationDepth) public ContactPoint(Vector3 position, Vector3 surfaceNormal, float penetrationDepth)
{ {
Position = position; Position = position;
SurfaceNormal = surfaceNormal; SurfaceNormal = surfaceNormal;
PenetrationDepth = penetrationDepth; PenetrationDepth = penetrationDepth;
RelativeSpeed = 0f; // for now let this one be set explicity
} }
} }

View File

@ -903,6 +903,7 @@ namespace OpenSim.Region.Physics.OdePlugin
contact.SurfaceNormal.X = 0f; contact.SurfaceNormal.X = 0f;
contact.SurfaceNormal.Y = 0f; contact.SurfaceNormal.Y = 0f;
contact.SurfaceNormal.Z = -1f; contact.SurfaceNormal.Z = -1f;
contact.RelativeSpeed = -vel.Z;
AddCollisionEvent(0, contact); AddCollisionEvent(0, contact);
vec.Z *= 0.5f; vec.Z *= 0.5f;

View File

@ -1073,6 +1073,15 @@ namespace OpenSim.Region.Physics.OdePlugin
if (!(p2events || p1events)) if (!(p2events || p1events))
return; 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) switch ((ActorTypes)p1.PhysicsActorType)
{ {
case ActorTypes.Agent: case ActorTypes.Agent: