diff options
Diffstat (limited to 'OpenSim/Region/PhysicsModules')
5 files changed, 84 insertions, 45 deletions
diff --git a/OpenSim/Region/PhysicsModules/BulletS/BSPhysObject.cs b/OpenSim/Region/PhysicsModules/BulletS/BSPhysObject.cs index a70d1b8..bb21f0c 100755 --- a/OpenSim/Region/PhysicsModules/BulletS/BSPhysObject.cs +++ b/OpenSim/Region/PhysicsModules/BulletS/BSPhysObject.cs | |||
@@ -508,7 +508,7 @@ public abstract class BSPhysObject : PhysicsActor | |||
508 | relvel = RawVelocity; | 508 | relvel = RawVelocity; |
509 | if (collidee != null && collidee.IsPhysical) | 509 | if (collidee != null && collidee.IsPhysical) |
510 | relvel -= collidee.RawVelocity; | 510 | relvel -= collidee.RawVelocity; |
511 | newContact.RelativeSpeed = OMV.Vector3.Dot(relvel, contactNormal); | 511 | newContact.RelativeSpeed = -OMV.Vector3.Dot(relvel, contactNormal); |
512 | // DetailLog("{0},{1}.Collision.AddCollider,vel={2},contee.vel={3},relvel={4},relspeed={5}", | 512 | // DetailLog("{0},{1}.Collision.AddCollider,vel={2},contee.vel={3},relvel={4},relspeed={5}", |
513 | // LocalID, TypeName, RawVelocity, (collidee == null ? OMV.Vector3.Zero : collidee.RawVelocity), relvel, newContact.RelativeSpeed); | 513 | // LocalID, TypeName, RawVelocity, (collidee == null ? OMV.Vector3.Zero : collidee.RawVelocity), relvel, newContact.RelativeSpeed); |
514 | 514 | ||
diff --git a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs index 393afae..04ccbf0 100644 --- a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs +++ b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs | |||
@@ -126,9 +126,20 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
126 | m_objCollisionList.Add(localID, contact); | 126 | m_objCollisionList.Add(localID, contact); |
127 | } | 127 | } |
128 | else | 128 | else |
129 | { | 129 | { |
130 | float lastVel = m_objCollisionList[localID].RelativeSpeed; | ||
130 | if (m_objCollisionList[localID].PenetrationDepth < contact.PenetrationDepth) | 131 | if (m_objCollisionList[localID].PenetrationDepth < contact.PenetrationDepth) |
132 | { | ||
133 | if(Math.Abs(lastVel) > Math.Abs(contact.RelativeSpeed)) | ||
134 | contact.RelativeSpeed = lastVel; | ||
131 | m_objCollisionList[localID] = contact; | 135 | m_objCollisionList[localID] = contact; |
136 | } | ||
137 | else if(Math.Abs(lastVel) < Math.Abs(contact.RelativeSpeed)) | ||
138 | { | ||
139 | ContactPoint tmp = m_objCollisionList[localID]; | ||
140 | tmp.RelativeSpeed = contact.RelativeSpeed; | ||
141 | m_objCollisionList[localID] = tmp; | ||
142 | } | ||
132 | } | 143 | } |
133 | } | 144 | } |
134 | 145 | ||
@@ -385,6 +396,7 @@ namespace OpenSim.Region.PhysicsModules.SharedBase | |||
385 | } | 396 | } |
386 | 397 | ||
387 | public abstract Vector3 Velocity { get; set; } | 398 | public abstract Vector3 Velocity { get; set; } |
399 | public virtual Vector3 rootVelocity { get { return Vector3.Zero; } } | ||
388 | 400 | ||
389 | public abstract Vector3 Torque { get; set; } | 401 | public abstract Vector3 Torque { get; set; } |
390 | public abstract float CollisionScore { get; set;} | 402 | public abstract float CollisionScore { get; set;} |
diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs b/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs index 55619c0..7d855f1 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs | |||
@@ -80,6 +80,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
80 | private Vector3 m_rotationalVelocity; | 80 | private Vector3 m_rotationalVelocity; |
81 | private Vector3 m_size; | 81 | private Vector3 m_size; |
82 | private Vector3 m_collideNormal; | 82 | private Vector3 m_collideNormal; |
83 | private Vector3 m_lastFallVel; | ||
83 | private Quaternion m_orientation; | 84 | private Quaternion m_orientation; |
84 | private Quaternion m_orientation2D; | 85 | private Quaternion m_orientation2D; |
85 | private float m_mass = 80f; | 86 | private float m_mass = 80f; |
@@ -109,6 +110,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
109 | private bool m_alwaysRun = false; | 110 | private bool m_alwaysRun = false; |
110 | 111 | ||
111 | private bool _zeroFlag = false; | 112 | private bool _zeroFlag = false; |
113 | private bool m_haveLastFallVel = false; | ||
112 | 114 | ||
113 | 115 | ||
114 | private uint m_localID = 0; | 116 | private uint m_localID = 0; |
@@ -605,6 +607,14 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
605 | set { return; } | 607 | set { return; } |
606 | } | 608 | } |
607 | 609 | ||
610 | public override Vector3 rootVelocity | ||
611 | { | ||
612 | get | ||
613 | { | ||
614 | return _velocity; | ||
615 | } | ||
616 | } | ||
617 | |||
608 | public override Vector3 Velocity | 618 | public override Vector3 Velocity |
609 | { | 619 | { |
610 | get | 620 | get |
@@ -1086,6 +1096,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
1086 | if (ctz.Z < 0) | 1096 | if (ctz.Z < 0) |
1087 | ctz.Z = 0; | 1097 | ctz.Z = 0; |
1088 | 1098 | ||
1099 | if(!m_haveLastFallVel) | ||
1100 | { | ||
1101 | m_lastFallVel = vel; | ||
1102 | m_haveLastFallVel = true; | ||
1103 | } | ||
1104 | |||
1089 | Vector3 n = _parent_scene.GetTerrainNormalAtXY(posch.X, posch.Y); | 1105 | Vector3 n = _parent_scene.GetTerrainNormalAtXY(posch.X, posch.Y); |
1090 | float depth = terrainheight - chrminZ; | 1106 | float depth = terrainheight - chrminZ; |
1091 | 1107 | ||
@@ -1114,7 +1130,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
1114 | 1130 | ||
1115 | m_iscollidingGround = true; | 1131 | m_iscollidingGround = true; |
1116 | 1132 | ||
1117 | |||
1118 | ContactPoint contact = new ContactPoint(); | 1133 | ContactPoint contact = new ContactPoint(); |
1119 | contact.PenetrationDepth = depth; | 1134 | contact.PenetrationDepth = depth; |
1120 | contact.Position.X = localpos.X; | 1135 | contact.Position.X = localpos.X; |
@@ -1123,9 +1138,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
1123 | contact.SurfaceNormal.X = -n.X; | 1138 | contact.SurfaceNormal.X = -n.X; |
1124 | contact.SurfaceNormal.Y = -n.Y; | 1139 | contact.SurfaceNormal.Y = -n.Y; |
1125 | contact.SurfaceNormal.Z = -n.Z; | 1140 | contact.SurfaceNormal.Z = -n.Z; |
1126 | contact.RelativeSpeed = -vel.Z; | 1141 | contact.RelativeSpeed = Vector3.Dot(m_lastFallVel, n); |
1127 | contact.CharacterFeet = true; | 1142 | contact.CharacterFeet = true; |
1128 | AddCollisionEvent(0, contact); | 1143 | AddCollisionEvent(0, contact); |
1144 | m_lastFallVel = vel; | ||
1129 | 1145 | ||
1130 | // vec.Z *= 0.5f; | 1146 | // vec.Z *= 0.5f; |
1131 | } | 1147 | } |
@@ -1143,6 +1159,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
1143 | } | 1159 | } |
1144 | else | 1160 | else |
1145 | { | 1161 | { |
1162 | m_haveLastFallVel = false; | ||
1146 | m_colliderGroundfilter -= 5; | 1163 | m_colliderGroundfilter -= 5; |
1147 | if (m_colliderGroundfilter <= 0) | 1164 | if (m_colliderGroundfilter <= 0) |
1148 | { | 1165 | { |
diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs index 6ed42d9..aaa2203 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs | |||
@@ -542,6 +542,16 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
542 | } | 542 | } |
543 | } | 543 | } |
544 | 544 | ||
545 | public override Vector3 rootVelocity | ||
546 | { | ||
547 | get | ||
548 | { | ||
549 | if(_parent != null) | ||
550 | return ((OdePrim)_parent).Velocity; | ||
551 | return Velocity; | ||
552 | } | ||
553 | } | ||
554 | |||
545 | public override Vector3 Velocity | 555 | public override Vector3 Velocity |
546 | { | 556 | { |
547 | get | 557 | get |
@@ -560,7 +570,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
560 | { | 570 | { |
561 | m_log.WarnFormat("[PHYSICS]: Got NaN Velocity in Object {0}", Name); | 571 | m_log.WarnFormat("[PHYSICS]: Got NaN Velocity in Object {0}", Name); |
562 | } | 572 | } |
563 | |||
564 | } | 573 | } |
565 | } | 574 | } |
566 | 575 | ||
diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs index e0644e3..8d87c30 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs | |||
@@ -874,7 +874,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
874 | break; | 874 | break; |
875 | 875 | ||
876 | case (int)ActorTypes.Prim: | 876 | case (int)ActorTypes.Prim: |
877 | Vector3 relV = p1.Velocity - p2.Velocity; | 877 | Vector3 relV = p1.rootVelocity - p2.rootVelocity; |
878 | float relVlenSQ = relV.LengthSquared(); | 878 | float relVlenSQ = relV.LengthSquared(); |
879 | if (relVlenSQ > 0.0001f) | 879 | if (relVlenSQ > 0.0001f) |
880 | { | 880 | { |
@@ -899,7 +899,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
899 | bounce = contactdata1.bounce * TerrainBounce; | 899 | bounce = contactdata1.bounce * TerrainBounce; |
900 | mu = (float)Math.Sqrt(contactdata1.mu * TerrainFriction); | 900 | mu = (float)Math.Sqrt(contactdata1.mu * TerrainFriction); |
901 | 901 | ||
902 | if (Math.Abs(p1.Velocity.X) > 0.1f || Math.Abs(p1.Velocity.Y) > 0.1f) | 902 | Vector3 v1 = p1.rootVelocity; |
903 | if (Math.Abs(v1.X) > 0.1f || Math.Abs(v1.Y) > 0.1f) | ||
903 | mu *= frictionMovementMult; | 904 | mu *= frictionMovementMult; |
904 | p1.CollidingGround = true; | 905 | p1.CollidingGround = true; |
905 | 906 | ||
@@ -925,8 +926,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
925 | 926 | ||
926 | // if (curContact.side1 > 0) // should be 2 ? | 927 | // if (curContact.side1 > 0) // should be 2 ? |
927 | // IgnoreNegSides = true; | 928 | // IgnoreNegSides = true; |
928 | 929 | Vector3 v2 = p2.rootVelocity; | |
929 | if (Math.Abs(p2.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y) > 0.1f) | 930 | if (Math.Abs(v2.X) > 0.1f || Math.Abs(v2.Y) > 0.1f) |
930 | mu *= frictionMovementMult; | 931 | mu *= frictionMovementMult; |
931 | 932 | ||
932 | if(d.GeomGetClass(g2) == d.GeomClassID.TriMeshClass) | 933 | if(d.GeomGetClass(g2) == d.GeomClassID.TriMeshClass) |
@@ -980,7 +981,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
980 | p1.CollidingObj = true; | 981 | p1.CollidingObj = true; |
981 | p2.CollidingObj = true; | 982 | p2.CollidingObj = true; |
982 | } | 983 | } |
983 | else if (p2.Velocity.LengthSquared() > 0.0f) | 984 | else if (p2.rootVelocity.LengthSquared() > 0.0f) |
984 | p2.CollidingObj = true; | 985 | p2.CollidingObj = true; |
985 | } | 986 | } |
986 | else | 987 | else |
@@ -995,7 +996,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
995 | p1.CollidingObj = true; | 996 | p1.CollidingObj = true; |
996 | p2.CollidingObj = true; | 997 | p2.CollidingObj = true; |
997 | } | 998 | } |
998 | else if (p2.Velocity.LengthSquared() > 0.0f) | 999 | else if (p1.rootVelocity.LengthSquared() > 0.0f) |
999 | p1.CollidingObj = true; | 1000 | p1.CollidingObj = true; |
1000 | } | 1001 | } |
1001 | else | 1002 | else |
@@ -1068,10 +1069,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
1068 | 1069 | ||
1069 | Vector3 vel = Vector3.Zero; | 1070 | Vector3 vel = Vector3.Zero; |
1070 | if (p2 != null && p2.IsPhysical) | 1071 | if (p2 != null && p2.IsPhysical) |
1071 | vel = p2.Velocity; | 1072 | vel = p2.rootVelocity; |
1072 | 1073 | ||
1073 | if (p1 != null && p1.IsPhysical) | 1074 | if (p1 != null && p1.IsPhysical) |
1074 | vel -= p1.Velocity; | 1075 | vel -= p1.rootVelocity; |
1075 | 1076 | ||
1076 | contact.RelativeSpeed = Vector3.Dot(vel, contact.SurfaceNormal); | 1077 | contact.RelativeSpeed = Vector3.Dot(vel, contact.SurfaceNormal); |
1077 | 1078 | ||
@@ -1079,44 +1080,45 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
1079 | { | 1080 | { |
1080 | case ActorTypes.Agent: | 1081 | case ActorTypes.Agent: |
1081 | case ActorTypes.Prim: | 1082 | case ActorTypes.Prim: |
1083 | { | ||
1084 | switch ((ActorTypes)p2.PhysicsActorType) | ||
1082 | { | 1085 | { |
1083 | switch ((ActorTypes)p2.PhysicsActorType) | 1086 | case ActorTypes.Agent: |
1084 | { | 1087 | case ActorTypes.Prim: |
1085 | case ActorTypes.Agent: | 1088 | if (p2events) |
1086 | case ActorTypes.Prim: | 1089 | { |
1087 | if (p2events) | 1090 | AddCollisionEventReporting(p2); |
1088 | { | 1091 | p2.AddCollisionEvent(p1.ParentActor.LocalID, contact); |
1089 | AddCollisionEventReporting(p2); | 1092 | } |
1090 | p2.AddCollisionEvent(p1.ParentActor.LocalID, contact); | 1093 | obj2LocalID = p2.ParentActor.LocalID; |
1091 | } | 1094 | break; |
1092 | obj2LocalID = p2.ParentActor.LocalID; | ||
1093 | break; | ||
1094 | 1095 | ||
1095 | case ActorTypes.Ground: | 1096 | case ActorTypes.Ground: |
1096 | case ActorTypes.Unknown: | 1097 | case ActorTypes.Unknown: |
1097 | default: | 1098 | default: |
1098 | obj2LocalID = 0; | 1099 | obj2LocalID = 0; |
1099 | break; | 1100 | break; |
1100 | } | ||
1101 | if (p1events) | ||
1102 | { | ||
1103 | contact.SurfaceNormal = -contact.SurfaceNormal; | ||
1104 | AddCollisionEventReporting(p1); | ||
1105 | p1.AddCollisionEvent(obj2LocalID, contact); | ||
1106 | } | ||
1107 | break; | ||
1108 | } | 1101 | } |
1102 | if (p1events) | ||
1103 | { | ||
1104 | contact.SurfaceNormal = -contact.SurfaceNormal; | ||
1105 | contact.RelativeSpeed = -contact.RelativeSpeed; | ||
1106 | AddCollisionEventReporting(p1); | ||
1107 | p1.AddCollisionEvent(obj2LocalID, contact); | ||
1108 | } | ||
1109 | break; | ||
1110 | } | ||
1109 | case ActorTypes.Ground: | 1111 | case ActorTypes.Ground: |
1110 | case ActorTypes.Unknown: | 1112 | case ActorTypes.Unknown: |
1111 | default: | 1113 | default: |
1114 | { | ||
1115 | if (p2events && !p2.IsVolumeDtc) | ||
1112 | { | 1116 | { |
1113 | if (p2events && !p2.IsVolumeDtc) | 1117 | AddCollisionEventReporting(p2); |
1114 | { | 1118 | p2.AddCollisionEvent(0, contact); |
1115 | AddCollisionEventReporting(p2); | ||
1116 | p2.AddCollisionEvent(0, contact); | ||
1117 | } | ||
1118 | break; | ||
1119 | } | 1119 | } |
1120 | break; | ||
1121 | } | ||
1120 | } | 1122 | } |
1121 | } | 1123 | } |
1122 | 1124 | ||
@@ -1722,8 +1724,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
1722 | 1724 | ||
1723 | case ActorTypes.Prim: | 1725 | case ActorTypes.Prim: |
1724 | OdePrim pobj = (OdePrim)obj; | 1726 | OdePrim pobj = (OdePrim)obj; |
1725 | if (pobj.Body == IntPtr.Zero || (d.BodyIsEnabled(pobj.Body) && !pobj.m_outbounds)) | 1727 | if (!pobj.m_outbounds && (pobj.Body == IntPtr.Zero || d.BodyIsEnabled(pobj.Body))) |
1726 | if (!pobj.m_outbounds) | ||
1727 | { | 1728 | { |
1728 | pobj.AddCollisionFrameTime((int)(odetimestepMS)); | 1729 | pobj.AddCollisionFrameTime((int)(odetimestepMS)); |
1729 | pobj.SendCollisions(); | 1730 | pobj.SendCollisions(); |