diff options
author | UbitUmarov | 2012-12-11 19:38:44 +0000 |
---|---|---|
committer | UbitUmarov | 2012-12-11 19:38:44 +0000 |
commit | f35e3c6fe04327ad4bc9b9864663910ea2b5d717 (patch) | |
tree | c9217e63b3bece8f435ce6626c2b6cc117cb9fea | |
parent | Merge branch 'avination' into ubitwork (diff) | |
download | opensim-SC_OLD-f35e3c6fe04327ad4bc9b9864663910ea2b5d717.zip opensim-SC_OLD-f35e3c6fe04327ad4bc9b9864663910ea2b5d717.tar.gz opensim-SC_OLD-f35e3c6fe04327ad4bc9b9864663910ea2b5d717.tar.bz2 opensim-SC_OLD-f35e3c6fe04327ad4bc9b9864663910ea2b5d717.tar.xz |
changes on the fast speed avatars collider, collisions from above, etc
-rw-r--r-- | OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 126 |
1 files changed, 64 insertions, 62 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs index b769c88..27a9f1c 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | |||
@@ -970,78 +970,86 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
970 | if (m_collisionException) | 970 | if (m_collisionException) |
971 | return false; | 971 | return false; |
972 | 972 | ||
973 | Vector3 offset; | ||
974 | |||
973 | if (me == bbox) // if moving fast | 975 | if (me == bbox) // if moving fast |
974 | { | 976 | { |
975 | // force a full inelastic collision | 977 | // force a full inelastic collision |
976 | m_collisionException = true; | 978 | m_collisionException = true; |
977 | 979 | ||
978 | Vector3 off = m_size * 0.5f; | 980 | offset = m_size * m_orientation; |
979 | off.X += contact.depth; | 981 | |
980 | off.Y += contact.depth; | 982 | offset.X = (float)Math.Abs(offset.X) * 0.5f + contact.depth; |
981 | off.Z += contact.depth; | 983 | offset.Y = (float)Math.Abs(offset.Y) * 0.5f + contact.depth; |
984 | offset.Z = (float)Math.Abs(offset.Z) * 0.5f + contact.depth; | ||
985 | |||
982 | if (reverse) | 986 | if (reverse) |
983 | { | 987 | { |
984 | off.X *= -contact.normal.X; | 988 | offset.X *= -contact.normal.X; |
985 | off.Y *= -contact.normal.Y; | 989 | offset.Y *= -contact.normal.Y; |
986 | off.Z *= -contact.normal.Z; | 990 | offset.Z *= -contact.normal.Z; |
987 | } | 991 | } |
988 | else | 992 | else |
989 | { | 993 | { |
990 | off.X *= contact.normal.X; | 994 | offset.X *= contact.normal.X; |
991 | off.Y *= contact.normal.Y; | 995 | offset.Y *= contact.normal.Y; |
992 | off.Z *= contact.normal.Z; | 996 | offset.Z *= contact.normal.Z; |
993 | } | 997 | } |
994 | 998 | ||
995 | off.X += contact.pos.X; | 999 | offset.X += contact.pos.X; |
996 | off.Y += contact.pos.Y; | 1000 | offset.Y += contact.pos.Y; |
997 | off.Z += contact.pos.Z; | 1001 | offset.Z += contact.pos.Z; |
998 | 1002 | ||
999 | _position = off; | 1003 | _position = offset; |
1000 | return false; | 1004 | return false; |
1001 | } | 1005 | } |
1002 | 1006 | ||
1003 | if (me == topbox) // keep a box head | 1007 | offset.X = contact.pos.X - _position.X; |
1004 | return true; | 1008 | offset.Y = contact.pos.Y - _position.Y; |
1005 | |||
1006 | float t; | ||
1007 | float offx = contact.pos.X - _position.X; | ||
1008 | float offy = contact.pos.Y - _position.Y; | ||
1009 | 1009 | ||
1010 | if (me == midbox) | 1010 | if (me == topbox) |
1011 | { | 1011 | { |
1012 | if (Math.Abs(contact.normal.Z) > 0.95f) | 1012 | offset.Z = contact.pos.Z - _position.Z; |
1013 | { | ||
1014 | float nz = contact.normal.Z; | ||
1015 | if (!reverse) | ||
1016 | nz = -nz; | ||
1017 | |||
1018 | if (nz > 0) | ||
1019 | return true; // missed head TODO | ||
1020 | 1013 | ||
1021 | // missed feet collision? | 1014 | offset.Normalize(); |
1022 | 1015 | ||
1023 | 1016 | if (reverse) | |
1024 | return true; | 1017 | { |
1018 | contact.normal.X = offset.X; | ||
1019 | contact.normal.Y = offset.Y; | ||
1020 | contact.normal.Z = offset.Z; | ||
1021 | } | ||
1022 | else | ||
1023 | { | ||
1024 | contact.normal.X = -offset.X; | ||
1025 | contact.normal.Y = -offset.Y; | ||
1026 | contact.normal.Z = -offset.Z; | ||
1025 | } | 1027 | } |
1028 | return true; | ||
1029 | } | ||
1026 | 1030 | ||
1027 | t = offx * offx + offy * offy; | 1031 | if (me == midbox) |
1028 | t = (float)Math.Sqrt(t); | 1032 | { |
1029 | t = 1 / t; | 1033 | if (Math.Abs(contact.normal.Z) > 0.95f) |
1030 | offx *= t; | 1034 | offset.Z = contact.pos.Z - _position.Z; |
1031 | offy *= t; | 1035 | else |
1036 | offset.Z = contact.normal.Z; | ||
1037 | |||
1038 | offset.Normalize(); | ||
1032 | 1039 | ||
1033 | if (reverse) | 1040 | if (reverse) |
1034 | { | 1041 | { |
1035 | contact.normal.X = offx; | 1042 | contact.normal.X = offset.X; |
1036 | contact.normal.Y = offy; | 1043 | contact.normal.Y = offset.Y; |
1044 | contact.normal.Z = offset.Z; | ||
1037 | } | 1045 | } |
1038 | else | 1046 | else |
1039 | { | 1047 | { |
1040 | contact.normal.X = -offx; | 1048 | contact.normal.X = -offset.X; |
1041 | contact.normal.Y = -offy; | 1049 | contact.normal.Y = -offset.Y; |
1050 | contact.normal.Z = -offset.Z; | ||
1042 | } | 1051 | } |
1043 | 1052 | ||
1044 | contact.normal.Z = 0; | ||
1045 | return true; | 1053 | return true; |
1046 | } | 1054 | } |
1047 | 1055 | ||
@@ -1063,39 +1071,33 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1063 | return true; | 1071 | return true; |
1064 | } | 1072 | } |
1065 | 1073 | ||
1074 | offset.Z = h - feetOff; // distance from top of feetbox | ||
1066 | 1075 | ||
1067 | float offz = h - feetOff; // distance from top of feetbox | 1076 | if (offset.Z > 0) |
1068 | |||
1069 | if (offz > 0) | ||
1070 | return false; | 1077 | return false; |
1071 | 1078 | ||
1072 | if (offz > -0.01) | 1079 | if (offset.Z > -0.01) |
1073 | { | 1080 | { |
1074 | offx = 0; | 1081 | offset.X = 0; |
1075 | offy = 0; | 1082 | offset.Y = 0; |
1076 | offz = -1.0f; | 1083 | offset.Z = -1.0f; |
1077 | } | 1084 | } |
1078 | else | 1085 | else |
1079 | { | 1086 | { |
1080 | t = offx * offx + offy * offy + offz * offz; | 1087 | offset.Normalize(); |
1081 | t = (float)Math.Sqrt(t); | ||
1082 | t = 1 / t; | ||
1083 | offx *= t; | ||
1084 | offy *= t; | ||
1085 | offz *= t; | ||
1086 | } | 1088 | } |
1087 | 1089 | ||
1088 | if (reverse) | 1090 | if (reverse) |
1089 | { | 1091 | { |
1090 | contact.normal.X = offx; | 1092 | contact.normal.X = offset.X; |
1091 | contact.normal.Y = offy; | 1093 | contact.normal.Y = offset.Y; |
1092 | contact.normal.Z = offz; | 1094 | contact.normal.Z = offset.Z; |
1093 | } | 1095 | } |
1094 | else | 1096 | else |
1095 | { | 1097 | { |
1096 | contact.normal.X = -offx; | 1098 | contact.normal.X = -offset.X; |
1097 | contact.normal.Y = -offy; | 1099 | contact.normal.Y = -offset.Y; |
1098 | contact.normal.Z = -offz; | 1100 | contact.normal.Z = -offset.Z; |
1099 | } | 1101 | } |
1100 | feetcollision = true; | 1102 | feetcollision = true; |
1101 | if (h < boneOff) | 1103 | if (h < boneOff) |
@@ -1125,7 +1127,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1125 | float v = _velocity.Length(); | 1127 | float v = _velocity.Length(); |
1126 | if (v != 0) | 1128 | if (v != 0) |
1127 | { | 1129 | { |
1128 | v = 6.0f / v; | 1130 | v = 5.0f / v; |
1129 | _velocity = _velocity * v; | 1131 | _velocity = _velocity * v; |
1130 | d.BodySetLinearVel(Body, _velocity.X, _velocity.Y, _velocity.Z); | 1132 | d.BodySetLinearVel(Body, _velocity.X, _velocity.Y, _velocity.Z); |
1131 | } | 1133 | } |