diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs | 394 |
1 files changed, 148 insertions, 246 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs index 2928257..a554897 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs | |||
@@ -203,9 +203,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
203 | private float waterlevel = 0f; | 203 | private float waterlevel = 0f; |
204 | private int framecount = 0; | 204 | private int framecount = 0; |
205 | 205 | ||
206 | private IntPtr WaterGeom = IntPtr.Zero; | 206 | // private IntPtr WaterGeom = IntPtr.Zero; |
207 | private IntPtr WaterHeightmapData = IntPtr.Zero; | 207 | // private IntPtr WaterHeightmapData = IntPtr.Zero; |
208 | private GCHandle WaterMapHandler = new GCHandle(); | 208 | // private GCHandle WaterMapHandler = new GCHandle(); |
209 | 209 | ||
210 | public float avPIDD = 2200f; // make it visible | 210 | public float avPIDD = 2200f; // make it visible |
211 | public float avPIDP = 900f; // make it visible | 211 | public float avPIDP = 900f; // make it visible |
@@ -251,7 +251,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
251 | private List<PhysicsActor> _collisionEventPrimRemove = new List<PhysicsActor>(); | 251 | private List<PhysicsActor> _collisionEventPrimRemove = new List<PhysicsActor>(); |
252 | 252 | ||
253 | private HashSet<OdeCharacter> _badCharacter = new HashSet<OdeCharacter>(); | 253 | private HashSet<OdeCharacter> _badCharacter = new HashSet<OdeCharacter>(); |
254 | public Dictionary<IntPtr, String> geom_name_map = new Dictionary<IntPtr, String>(); | 254 | // public Dictionary<IntPtr, String> geom_name_map = new Dictionary<IntPtr, String>(); |
255 | public Dictionary<IntPtr, PhysicsActor> actor_name_map = new Dictionary<IntPtr, PhysicsActor>(); | 255 | public Dictionary<IntPtr, PhysicsActor> actor_name_map = new Dictionary<IntPtr, PhysicsActor>(); |
256 | 256 | ||
257 | private float contactsurfacelayer = 0.002f; | 257 | private float contactsurfacelayer = 0.002f; |
@@ -274,7 +274,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
274 | 274 | ||
275 | private int m_physicsiterations = 10; | 275 | private int m_physicsiterations = 10; |
276 | private const float m_SkipFramesAtms = 0.40f; // Drop frames gracefully at a 400 ms lag | 276 | private const float m_SkipFramesAtms = 0.40f; // Drop frames gracefully at a 400 ms lag |
277 | private PhysicsActor PANull = new NullPhysicsActor(); | 277 | // private PhysicsActor PANull = new NullPhysicsActor(); |
278 | private float step_time = 0.0f; | 278 | private float step_time = 0.0f; |
279 | 279 | ||
280 | public IntPtr world; | 280 | public IntPtr world; |
@@ -713,6 +713,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
713 | 713 | ||
714 | if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact)) | 714 | if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact)) |
715 | return; | 715 | return; |
716 | |||
716 | if(d.GeomGetCategoryBits(g1) == (uint)CollisionCategories.VolumeDtc || | 717 | if(d.GeomGetCategoryBits(g1) == (uint)CollisionCategories.VolumeDtc || |
717 | d.GeomGetCategoryBits(g1) == (uint)CollisionCategories.VolumeDtc) | 718 | d.GeomGetCategoryBits(g1) == (uint)CollisionCategories.VolumeDtc) |
718 | { | 719 | { |
@@ -738,7 +739,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
738 | return; | 739 | return; |
739 | } | 740 | } |
740 | 741 | ||
741 | // id contacts done | 742 | // contacts done |
742 | if (count == 0) | 743 | if (count == 0) |
743 | return; | 744 | return; |
744 | 745 | ||
@@ -748,12 +749,14 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
748 | 749 | ||
749 | if (!actor_name_map.TryGetValue(g1, out p1)) | 750 | if (!actor_name_map.TryGetValue(g1, out p1)) |
750 | { | 751 | { |
751 | p1 = PANull; | 752 | m_log.WarnFormat("[PHYSICS]: failed actor mapping for geom 1"); |
753 | return; | ||
752 | } | 754 | } |
753 | 755 | ||
754 | if (!actor_name_map.TryGetValue(g2, out p2)) | 756 | if (!actor_name_map.TryGetValue(g2, out p2)) |
755 | { | 757 | { |
756 | p2 = PANull; | 758 | m_log.WarnFormat("[PHYSICS]: failed actor mapping for geom 2"); |
759 | return; | ||
757 | } | 760 | } |
758 | 761 | ||
759 | // update actors collision score | 762 | // update actors collision score |
@@ -765,7 +768,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
765 | p2.CollisionScore = 0; | 768 | p2.CollisionScore = 0; |
766 | p2.CollisionScore += count; | 769 | p2.CollisionScore += count; |
767 | 770 | ||
768 | |||
769 | // get first contact | 771 | // get first contact |
770 | d.ContactGeom curContact = new d.ContactGeom(); | 772 | d.ContactGeom curContact = new d.ContactGeom(); |
771 | if (!GetCurContactGeom(0, ref curContact)) | 773 | if (!GetCurContactGeom(0, ref curContact)) |
@@ -798,7 +800,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
798 | ContactData contactdata1 = new ContactData(0, 0, false); | 800 | ContactData contactdata1 = new ContactData(0, 0, false); |
799 | ContactData contactdata2 = new ContactData(0, 0, false); | 801 | ContactData contactdata2 = new ContactData(0, 0, false); |
800 | 802 | ||
801 | String name = null; | ||
802 | bool dop1foot = false; | 803 | bool dop1foot = false; |
803 | bool dop2foot = false; | 804 | bool dop2foot = false; |
804 | bool ignore = false; | 805 | bool ignore = false; |
@@ -830,34 +831,16 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
830 | switch (p2.PhysicsActorType) | 831 | switch (p2.PhysicsActorType) |
831 | { | 832 | { |
832 | case (int)ActorTypes.Agent: | 833 | case (int)ActorTypes.Agent: |
833 | /* | ||
834 | p1.getContactData(ref contactdata1); | ||
835 | p2.getContactData(ref contactdata2); | ||
836 | |||
837 | mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu); | ||
838 | |||
839 | if ((Math.Abs(p2.Velocity.X - p1.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y - p1.Velocity.Y) > 0.1f)) | ||
840 | mu *= frictionMovementMult; | ||
841 | */ | ||
842 | p1.CollidingObj = true; | 834 | p1.CollidingObj = true; |
843 | p2.CollidingObj = true; | 835 | p2.CollidingObj = true; |
844 | break; | 836 | break; |
845 | case (int)ActorTypes.Prim: | ||
846 | /* | ||
847 | p1.getContactData(ref contactdata1); | ||
848 | p2.getContactData(ref contactdata2); | ||
849 | 837 | ||
850 | 838 | case (int)ActorTypes.Prim: | |
851 | mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu); | ||
852 | |||
853 | if ((Math.Abs(p2.Velocity.X - p1.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y - p1.Velocity.Y) > 0.1f)) | ||
854 | mu *= frictionMovementMult; | ||
855 | */ | ||
856 | if (p2.Velocity.LengthSquared() > 0.0f) | 839 | if (p2.Velocity.LengthSquared() > 0.0f) |
857 | p2.CollidingObj = true; | 840 | p2.CollidingObj = true; |
858 | |||
859 | dop1foot = true; | 841 | dop1foot = true; |
860 | break; | 842 | break; |
843 | |||
861 | default: | 844 | default: |
862 | ignore = true; // avatar to terrain and water ignored | 845 | ignore = true; // avatar to terrain and water ignored |
863 | break; | 846 | break; |
@@ -869,9 +852,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
869 | switch (p2.PhysicsActorType) | 852 | switch (p2.PhysicsActorType) |
870 | { | 853 | { |
871 | case (int)ActorTypes.Agent: | 854 | case (int)ActorTypes.Agent: |
872 | // p1.getContactData(ref contactdata1); | ||
873 | // p2.getContactData(ref contactdata2); | ||
874 | |||
875 | AvanormOverride = true; | 855 | AvanormOverride = true; |
876 | 856 | ||
877 | Vector3 tmp = p2.Position - p1.Position; | 857 | Vector3 tmp = p2.Position - p1.Position; |
@@ -894,16 +874,12 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
894 | bounce = 0; | 874 | bounce = 0; |
895 | mu = 0; | 875 | mu = 0; |
896 | cfm = 0.0001f; | 876 | cfm = 0.0001f; |
897 | /* | ||
898 | mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu); | ||
899 | 877 | ||
900 | if ((Math.Abs(p2.Velocity.X - p1.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y - p1.Velocity.Y) > 0.1f)) | ||
901 | mu *= frictionMovementMult; | ||
902 | */ | ||
903 | dop2foot = true; | 878 | dop2foot = true; |
904 | if (p1.Velocity.LengthSquared() > 0.0f) | 879 | if (p1.Velocity.LengthSquared() > 0.0f) |
905 | p1.CollidingObj = true; | 880 | p1.CollidingObj = true; |
906 | break; | 881 | break; |
882 | |||
907 | case (int)ActorTypes.Prim: | 883 | case (int)ActorTypes.Prim: |
908 | if ((p1.Velocity - p2.Velocity).LengthSquared() > 0.0f) | 884 | if ((p1.Velocity - p2.Velocity).LengthSquared() > 0.0f) |
909 | { | 885 | { |
@@ -933,95 +909,77 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
933 | mu *= frictionMovementMult; | 909 | mu *= frictionMovementMult; |
934 | 910 | ||
935 | break; | 911 | break; |
936 | default: | ||
937 | if (geom_name_map.TryGetValue(g2, out name)) | ||
938 | { | ||
939 | if (name == "Terrain") | ||
940 | { | ||
941 | p1.getContactData(ref contactdata1); | ||
942 | bounce = contactdata1.bounce * TerrainBounce; | ||
943 | mu = (float)Math.Sqrt(contactdata1.mu * TerrainFriction); | ||
944 | if (Math.Abs(p1.Velocity.X) > 0.1f || Math.Abs(p1.Velocity.Y) > 0.1f) | ||
945 | mu *= frictionMovementMult; | ||
946 | p1.CollidingGround = true; | ||
947 | |||
948 | cfm = p1.Mass; | ||
949 | dscale = 10 / cfm; | ||
950 | dscale = (float)Math.Sqrt(dscale); | ||
951 | if (dscale > 1.0f) | ||
952 | dscale = 1.0f; | ||
953 | erpscale = cfm * 0.01f; | ||
954 | cfm = 0.0001f / cfm; | ||
955 | if (cfm > 0.01f) | ||
956 | cfm = 0.01f; | ||
957 | else if (cfm < 0.00001f) | ||
958 | cfm = 0.00001f; | ||
959 | |||
960 | if (d.GeomGetClass(g1) == d.GeomClassID.TriMeshClass) | ||
961 | { | ||
962 | if (curContact.side1 > 0) | ||
963 | IgnoreNegSides = true; | ||
964 | } | ||
965 | |||
966 | } | ||
967 | else if (name == "Water") | ||
968 | { | ||
969 | ignore = true; | ||
970 | } | ||
971 | } | ||
972 | else | ||
973 | ignore = true; | ||
974 | break; | ||
975 | } | ||
976 | break; | ||
977 | |||
978 | default: | ||
979 | if (geom_name_map.TryGetValue(g1, out name)) | ||
980 | { | ||
981 | if (name == "Terrain") | ||
982 | { | ||
983 | if (p2.PhysicsActorType == (int)ActorTypes.Prim) | ||
984 | { | ||
985 | p2.CollidingGround = true; | ||
986 | p2.getContactData(ref contactdata2); | ||
987 | bounce = contactdata2.bounce * TerrainBounce; | ||
988 | mu = (float)Math.Sqrt(contactdata2.mu * TerrainFriction); | ||
989 | 912 | ||
990 | cfm = p2.Mass; | 913 | case (int)ActorTypes.Ground: |
991 | dscale = 10 / cfm; | 914 | p1.getContactData(ref contactdata1); |
992 | dscale = (float)Math.Sqrt(dscale); | 915 | bounce = contactdata1.bounce * TerrainBounce; |
993 | 916 | mu = (float)Math.Sqrt(contactdata1.mu * TerrainFriction); | |
994 | if (dscale > 1.0f) | 917 | if (Math.Abs(p1.Velocity.X) > 0.1f || Math.Abs(p1.Velocity.Y) > 0.1f) |
995 | dscale = 1.0f; | 918 | mu *= frictionMovementMult; |
919 | p1.CollidingGround = true; | ||
996 | 920 | ||
997 | erpscale = cfm * 0.01f; | 921 | cfm = p1.Mass; |
998 | cfm = 0.0001f / cfm; | 922 | dscale = 10 / cfm; |
999 | if (cfm > 0.01f) | 923 | dscale = (float)Math.Sqrt(dscale); |
1000 | cfm = 0.01f; | 924 | if (dscale > 1.0f) |
1001 | else if (cfm < 0.00001f) | 925 | dscale = 1.0f; |
1002 | cfm = 0.00001f; | 926 | erpscale = cfm * 0.01f; |
927 | cfm = 0.0001f / cfm; | ||
928 | if (cfm > 0.01f) | ||
929 | cfm = 0.01f; | ||
930 | else if (cfm < 0.00001f) | ||
931 | cfm = 0.00001f; | ||
1003 | 932 | ||
1004 | if (curContact.side1 > 0) // should be 2 ? | 933 | if (d.GeomGetClass(g1) == d.GeomClassID.TriMeshClass) |
934 | { | ||
935 | if (curContact.side1 > 0) | ||
1005 | IgnoreNegSides = true; | 936 | IgnoreNegSides = true; |
1006 | |||
1007 | if (Math.Abs(p2.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y) > 0.1f) | ||
1008 | mu *= frictionMovementMult; | ||
1009 | } | 937 | } |
1010 | else | 938 | break; |
1011 | ignore = true; | ||
1012 | 939 | ||
1013 | } | 940 | case (int)ActorTypes.Water: |
1014 | else if (name == "Water" && | 941 | default: |
1015 | (p2.PhysicsActorType == (int)ActorTypes.Prim || p2.PhysicsActorType == (int)ActorTypes.Agent)) | ||
1016 | { | ||
1017 | ignore = true; | 942 | ignore = true; |
1018 | } | 943 | break; |
944 | } | ||
945 | break; | ||
946 | |||
947 | case (int)ActorTypes.Ground: | ||
948 | if (p2.PhysicsActorType == (int)ActorTypes.Prim) | ||
949 | { | ||
950 | p2.CollidingGround = true; | ||
951 | p2.getContactData(ref contactdata2); | ||
952 | bounce = contactdata2.bounce * TerrainBounce; | ||
953 | mu = (float)Math.Sqrt(contactdata2.mu * TerrainFriction); | ||
954 | |||
955 | cfm = p2.Mass; | ||
956 | dscale = 10 / cfm; | ||
957 | dscale = (float)Math.Sqrt(dscale); | ||
958 | |||
959 | if (dscale > 1.0f) | ||
960 | dscale = 1.0f; | ||
961 | |||
962 | erpscale = cfm * 0.01f; | ||
963 | cfm = 0.0001f / cfm; | ||
964 | if (cfm > 0.01f) | ||
965 | cfm = 0.01f; | ||
966 | else if (cfm < 0.00001f) | ||
967 | cfm = 0.00001f; | ||
968 | |||
969 | if (curContact.side1 > 0) // should be 2 ? | ||
970 | IgnoreNegSides = true; | ||
971 | |||
972 | if (Math.Abs(p2.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y) > 0.1f) | ||
973 | mu *= frictionMovementMult; | ||
1019 | } | 974 | } |
1020 | else | 975 | else |
1021 | ignore = true; | 976 | ignore = true; |
1022 | break; | 977 | break; |
1023 | } | ||
1024 | 978 | ||
979 | case (int)ActorTypes.Water: | ||
980 | default: | ||
981 | break; | ||
982 | } | ||
1025 | if (ignore) | 983 | if (ignore) |
1026 | return; | 984 | return; |
1027 | 985 | ||
@@ -1162,36 +1120,23 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1162 | 1120 | ||
1163 | } | 1121 | } |
1164 | */ | 1122 | */ |
1165 | } | 1123 | } |
1166 | 1124 | ||
1167 | private void collision_accounting_events(PhysicsActor p1, PhysicsActor p2, ContactPoint contact) | 1125 | private void collision_accounting_events(PhysicsActor p1, PhysicsActor p2, ContactPoint contact) |
1168 | { | 1126 | { |
1169 | |||
1170 | OdeCharacter cc1; | ||
1171 | OdePrim cp1; | ||
1172 | OdeCharacter cc2; | ||
1173 | OdePrim cp2; | ||
1174 | OdePrim cp1Parent; | ||
1175 | OdePrim cp2Parent; | ||
1176 | |||
1177 | uint obj2LocalID = 0; | 1127 | uint obj2LocalID = 0; |
1128 | |||
1178 | bool p1events = p1.SubscribedEvents(); | 1129 | bool p1events = p1.SubscribedEvents(); |
1179 | bool p2events = p2.SubscribedEvents(); | 1130 | bool p2events = p2.SubscribedEvents(); |
1180 | 1131 | ||
1181 | if (p1.IsVolumeDtc) | 1132 | if (p1.IsVolumeDtc) |
1182 | p2events = false; | 1133 | p2events = false; |
1183 | if (p2.IsVolumeDtc) | 1134 | if (p2.IsVolumeDtc) |
1184 | p1events = false; | 1135 | p1events = false; |
1185 | 1136 | ||
1186 | if (!(p2events || p1events)) | 1137 | if (!p2events && !p1events) |
1187 | return; | 1138 | return; |
1188 | 1139 | ||
1189 | if (p1events) | ||
1190 | AddCollisionEventReporting(p1); | ||
1191 | |||
1192 | if (p2events) | ||
1193 | AddCollisionEventReporting(p2); | ||
1194 | |||
1195 | Vector3 vel = Vector3.Zero; | 1140 | Vector3 vel = Vector3.Zero; |
1196 | if (p2 != null && p2.IsPhysical) | 1141 | if (p2 != null && p2.IsPhysical) |
1197 | vel = p2.Velocity; | 1142 | vel = p2.Velocity; |
@@ -1200,71 +1145,22 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1200 | vel -= p1.Velocity; | 1145 | vel -= p1.Velocity; |
1201 | 1146 | ||
1202 | contact.RelativeSpeed = Vector3.Dot(vel, contact.SurfaceNormal); | 1147 | contact.RelativeSpeed = Vector3.Dot(vel, contact.SurfaceNormal); |
1203 | 1148 | ||
1204 | switch ((ActorTypes)p1.PhysicsActorType) | 1149 | switch ((ActorTypes)p1.PhysicsActorType) |
1205 | { | 1150 | { |
1206 | case ActorTypes.Agent: | 1151 | case ActorTypes.Agent: |
1207 | cc1 = (OdeCharacter)p1; | ||
1208 | switch ((ActorTypes)p2.PhysicsActorType) | ||
1209 | { | ||
1210 | case ActorTypes.Agent: | ||
1211 | cc2 = (OdeCharacter)p2; | ||
1212 | obj2LocalID = cc2.LocalID; | ||
1213 | if (p2events) | ||
1214 | cc2.AddCollisionEvent(cc1.LocalID, contact); | ||
1215 | break; | ||
1216 | |||
1217 | case ActorTypes.Prim: | ||
1218 | if (p2 is OdePrim) | ||
1219 | { | ||
1220 | cp2 = (OdePrim)p2; | ||
1221 | if (p2events) | ||
1222 | cp2.AddCollisionEvent(cc1.LocalID, contact); | ||
1223 | cp2 = cp2.Parent; | ||
1224 | obj2LocalID = cp2.LocalID; | ||
1225 | } | ||
1226 | break; | ||
1227 | |||
1228 | case ActorTypes.Ground: | ||
1229 | case ActorTypes.Unknown: | ||
1230 | default: | ||
1231 | obj2LocalID = 0; | ||
1232 | break; | ||
1233 | } | ||
1234 | if (p1events) | ||
1235 | { | ||
1236 | contact.SurfaceNormal = -contact.SurfaceNormal; | ||
1237 | cc1.AddCollisionEvent(obj2LocalID, contact); | ||
1238 | } | ||
1239 | break; | ||
1240 | |||
1241 | case ActorTypes.Prim: | 1152 | case ActorTypes.Prim: |
1242 | 1153 | { | |
1243 | if (p1 is OdePrim) | ||
1244 | { | ||
1245 | cp1 = (OdePrim)p1; | ||
1246 | cp1Parent = cp1.Parent; | ||
1247 | switch ((ActorTypes)p2.PhysicsActorType) | 1154 | switch ((ActorTypes)p2.PhysicsActorType) |
1248 | { | 1155 | { |
1249 | case ActorTypes.Agent: | 1156 | case ActorTypes.Agent: |
1250 | if (p2 is OdeCharacter) | ||
1251 | { | ||
1252 | cc2 = (OdeCharacter)p2; | ||
1253 | obj2LocalID = cc2.LocalID; | ||
1254 | if (p2events) | ||
1255 | cc2.AddCollisionEvent(cp1Parent.LocalID, contact); | ||
1256 | } | ||
1257 | break; | ||
1258 | case ActorTypes.Prim: | 1157 | case ActorTypes.Prim: |
1259 | 1158 | if (p2events) | |
1260 | if (p2 is OdePrim) | 1159 | { |
1261 | { | 1160 | AddCollisionEventReporting(p2); |
1262 | cp2 = (OdePrim)p2; | 1161 | p2.AddCollisionEvent(p1.ParentActor.LocalID, contact); |
1263 | if (p2events) | 1162 | } |
1264 | cp2.AddCollisionEvent(cp1Parent.LocalID, contact); | 1163 | obj2LocalID = p2.ParentActor.LocalID; |
1265 | cp2 = cp2.Parent; | ||
1266 | obj2LocalID = cp2.LocalID; | ||
1267 | } | ||
1268 | break; | 1164 | break; |
1269 | 1165 | ||
1270 | case ActorTypes.Ground: | 1166 | case ActorTypes.Ground: |
@@ -1272,41 +1168,28 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1272 | default: | 1168 | default: |
1273 | obj2LocalID = 0; | 1169 | obj2LocalID = 0; |
1274 | break; | 1170 | break; |
1275 | } | 1171 | } |
1276 | if (p1events) | 1172 | if (p1events) |
1277 | { | 1173 | { |
1278 | contact.SurfaceNormal = -contact.SurfaceNormal; | 1174 | contact.SurfaceNormal = -contact.SurfaceNormal; |
1279 | cp1.AddCollisionEvent(obj2LocalID, contact); | 1175 | AddCollisionEventReporting(p1); |
1280 | } | 1176 | p1.AddCollisionEvent(obj2LocalID, contact); |
1281 | } | 1177 | } |
1282 | break; | 1178 | break; |
1179 | } | ||
1283 | case ActorTypes.Ground: | 1180 | case ActorTypes.Ground: |
1284 | case ActorTypes.Unknown: | 1181 | case ActorTypes.Unknown: |
1285 | default: | 1182 | default: |
1286 | switch ((ActorTypes)p2.PhysicsActorType) | 1183 | { |
1184 | if (p2events && !p2.IsVolumeDtc) | ||
1287 | { | 1185 | { |
1288 | case ActorTypes.Agent: | 1186 | AddCollisionEventReporting(p2); |
1289 | if (p2 is OdeCharacter) | 1187 | p2.AddCollisionEvent(0, contact); |
1290 | { | ||
1291 | cc2 = (OdeCharacter)p2; | ||
1292 | obj2LocalID = cc2.LocalID; | ||
1293 | if (p2events) | ||
1294 | cc2.AddCollisionEvent(0, contact); | ||
1295 | } | ||
1296 | break; | ||
1297 | case ActorTypes.Prim: | ||
1298 | if (p2 is OdePrim) | ||
1299 | { | ||
1300 | cp2 = (OdePrim)p2; | ||
1301 | obj2LocalID = cp2.LocalID; | ||
1302 | if (p2events) | ||
1303 | cp2.AddCollisionEvent(0, contact); | ||
1304 | } | ||
1305 | break; | ||
1306 | } | 1188 | } |
1307 | break; | 1189 | break; |
1308 | } | 1190 | } |
1309 | } | 1191 | } |
1192 | } | ||
1310 | 1193 | ||
1311 | /// <summary> | 1194 | /// <summary> |
1312 | /// This is our collision testing routine in ODE | 1195 | /// This is our collision testing routine in ODE |
@@ -2369,6 +2252,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2369 | RegionTerrain.Remove(pOffset); | 2252 | RegionTerrain.Remove(pOffset); |
2370 | if (GroundGeom != IntPtr.Zero) | 2253 | if (GroundGeom != IntPtr.Zero) |
2371 | { | 2254 | { |
2255 | actor_name_map.Remove(GroundGeom); | ||
2372 | d.GeomDestroy(GroundGeom); | 2256 | d.GeomDestroy(GroundGeom); |
2373 | 2257 | ||
2374 | if (TerrainHeightFieldHeights.ContainsKey(GroundGeom)) | 2258 | if (TerrainHeightFieldHeights.ContainsKey(GroundGeom)) |
@@ -2394,27 +2278,32 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2394 | d.GeomSetCategoryBits(GroundGeom, (uint)(CollisionCategories.Land)); | 2278 | d.GeomSetCategoryBits(GroundGeom, (uint)(CollisionCategories.Land)); |
2395 | d.GeomSetCollideBits(GroundGeom, 0); | 2279 | d.GeomSetCollideBits(GroundGeom, 0); |
2396 | 2280 | ||
2397 | } | 2281 | PhysicsActor pa = new NullPhysicsActor(); |
2398 | geom_name_map[GroundGeom] = "Terrain"; | 2282 | pa.Name = "Terrain"; |
2283 | pa.PhysicsActorType = (int)ActorTypes.Ground; | ||
2284 | actor_name_map[GroundGeom] = pa; | ||
2399 | 2285 | ||
2400 | d.Matrix3 R = new d.Matrix3(); | 2286 | // geom_name_map[GroundGeom] = "Terrain"; |
2401 | 2287 | ||
2402 | Quaternion q1 = Quaternion.CreateFromAxisAngle(new Vector3(1, 0, 0), 1.5707f); | 2288 | d.Matrix3 R = new d.Matrix3(); |
2403 | Quaternion q2 = Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0), 1.5707f); | ||
2404 | |||
2405 | 2289 | ||
2406 | q1 = q1 * q2; | 2290 | Quaternion q1 = Quaternion.CreateFromAxisAngle(new Vector3(1, 0, 0), 1.5707f); |
2407 | 2291 | Quaternion q2 = Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0), 1.5707f); | |
2408 | Vector3 v3; | 2292 | |
2409 | float angle; | 2293 | |
2410 | q1.GetAxisAngle(out v3, out angle); | 2294 | q1 = q1 * q2; |
2411 | 2295 | ||
2412 | d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle); | 2296 | Vector3 v3; |
2413 | d.GeomSetRotation(GroundGeom, ref R); | 2297 | float angle; |
2414 | d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f, 0); | 2298 | q1.GetAxisAngle(out v3, out angle); |
2415 | RegionTerrain.Add(pOffset, GroundGeom); | 2299 | |
2416 | TerrainHeightFieldHeights.Add(GroundGeom, _heightmap); | 2300 | d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle); |
2417 | TerrainHeightFieldHeightsHandlers.Add(GroundGeom, _heightmaphandler); | 2301 | d.GeomSetRotation(GroundGeom, ref R); |
2302 | d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f, 0); | ||
2303 | RegionTerrain.Add(pOffset, GroundGeom); | ||
2304 | TerrainHeightFieldHeights.Add(GroundGeom, _heightmap); | ||
2305 | TerrainHeightFieldHeightsHandlers.Add(GroundGeom, _heightmaphandler); | ||
2306 | } | ||
2418 | } | 2307 | } |
2419 | } | 2308 | } |
2420 | 2309 | ||
@@ -2478,6 +2367,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2478 | RegionTerrain.Remove(pOffset); | 2367 | RegionTerrain.Remove(pOffset); |
2479 | if (GroundGeom != IntPtr.Zero) | 2368 | if (GroundGeom != IntPtr.Zero) |
2480 | { | 2369 | { |
2370 | actor_name_map.Remove(GroundGeom); | ||
2481 | d.GeomDestroy(GroundGeom); | 2371 | d.GeomDestroy(GroundGeom); |
2482 | 2372 | ||
2483 | if (TerrainHeightFieldHeights.ContainsKey(GroundGeom)) | 2373 | if (TerrainHeightFieldHeights.ContainsKey(GroundGeom)) |
@@ -2509,13 +2399,18 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2509 | d.GeomSetCategoryBits(GroundGeom, (uint)(CollisionCategories.Land)); | 2399 | d.GeomSetCategoryBits(GroundGeom, (uint)(CollisionCategories.Land)); |
2510 | d.GeomSetCollideBits(GroundGeom, 0); | 2400 | d.GeomSetCollideBits(GroundGeom, 0); |
2511 | 2401 | ||
2512 | } | 2402 | PhysicsActor pa = new NullPhysicsActor(); |
2513 | geom_name_map[GroundGeom] = "Terrain"; | 2403 | pa.Name = "Terrain"; |
2404 | pa.PhysicsActorType = (int)ActorTypes.Ground; | ||
2405 | actor_name_map[GroundGeom] = pa; | ||
2406 | |||
2407 | // geom_name_map[GroundGeom] = "Terrain"; | ||
2514 | 2408 | ||
2515 | d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f, 0); | 2409 | d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f, 0); |
2516 | RegionTerrain.Add(pOffset, GroundGeom); | 2410 | RegionTerrain.Add(pOffset, GroundGeom); |
2517 | TerrainHeightFieldHeights.Add(GroundGeom, _heightmap); | 2411 | TerrainHeightFieldHeights.Add(GroundGeom, _heightmap); |
2518 | TerrainHeightFieldHeightsHandlers.Add(GroundGeom, _heightmaphandler); | 2412 | TerrainHeightFieldHeightsHandlers.Add(GroundGeom, _heightmaphandler); |
2413 | } | ||
2519 | } | 2414 | } |
2520 | } | 2415 | } |
2521 | 2416 | ||
@@ -2596,9 +2491,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2596 | public override void SetWaterLevel(float baseheight) | 2491 | public override void SetWaterLevel(float baseheight) |
2597 | { | 2492 | { |
2598 | waterlevel = baseheight; | 2493 | waterlevel = baseheight; |
2599 | randomizeWater(waterlevel); | 2494 | // randomizeWater(waterlevel); |
2600 | } | 2495 | } |
2601 | 2496 | /* | |
2602 | public void randomizeWater(float baseheight) | 2497 | public void randomizeWater(float baseheight) |
2603 | { | 2498 | { |
2604 | const uint heightmapWidth = Constants.RegionSize + 2; | 2499 | const uint heightmapWidth = Constants.RegionSize + 2; |
@@ -2632,6 +2527,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2632 | { | 2527 | { |
2633 | if (WaterGeom != IntPtr.Zero) | 2528 | if (WaterGeom != IntPtr.Zero) |
2634 | { | 2529 | { |
2530 | actor_name_map.Remove(WaterGeom); | ||
2635 | d.GeomDestroy(WaterGeom); | 2531 | d.GeomDestroy(WaterGeom); |
2636 | d.GeomHeightfieldDataDestroy(WaterHeightmapData); | 2532 | d.GeomHeightfieldDataDestroy(WaterHeightmapData); |
2637 | WaterGeom = IntPtr.Zero; | 2533 | WaterGeom = IntPtr.Zero; |
@@ -2654,7 +2550,13 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2654 | d.GeomSetCategoryBits(WaterGeom, (uint)(CollisionCategories.Water)); | 2550 | d.GeomSetCategoryBits(WaterGeom, (uint)(CollisionCategories.Water)); |
2655 | d.GeomSetCollideBits(WaterGeom, 0); | 2551 | d.GeomSetCollideBits(WaterGeom, 0); |
2656 | 2552 | ||
2657 | geom_name_map[WaterGeom] = "Water"; | 2553 | |
2554 | PhysicsActor pa = new NullPhysicsActor(); | ||
2555 | pa.Name = "Water"; | ||
2556 | pa.PhysicsActorType = (int)ActorTypes.Water; | ||
2557 | |||
2558 | actor_name_map[WaterGeom] = pa; | ||
2559 | // geom_name_map[WaterGeom] = "Water"; | ||
2658 | 2560 | ||
2659 | d.Matrix3 R = new d.Matrix3(); | 2561 | d.Matrix3 R = new d.Matrix3(); |
2660 | 2562 | ||
@@ -2672,7 +2574,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2672 | } | 2574 | } |
2673 | } | 2575 | } |
2674 | } | 2576 | } |
2675 | 2577 | */ | |
2676 | public override void Dispose() | 2578 | public override void Dispose() |
2677 | { | 2579 | { |
2678 | lock (OdeLock) | 2580 | lock (OdeLock) |
@@ -2722,7 +2624,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2722 | 2624 | ||
2723 | TerrainHeightFieldHeightsHandlers.Clear(); | 2625 | TerrainHeightFieldHeightsHandlers.Clear(); |
2724 | TerrainHeightFieldHeights.Clear(); | 2626 | TerrainHeightFieldHeights.Clear(); |
2725 | 2627 | /* | |
2726 | if (WaterGeom != IntPtr.Zero) | 2628 | if (WaterGeom != IntPtr.Zero) |
2727 | { | 2629 | { |
2728 | d.GeomDestroy(WaterGeom); | 2630 | d.GeomDestroy(WaterGeom); |
@@ -2734,7 +2636,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2734 | if (WaterMapHandler.IsAllocated) | 2636 | if (WaterMapHandler.IsAllocated) |
2735 | WaterMapHandler.Free(); | 2637 | WaterMapHandler.Free(); |
2736 | } | 2638 | } |
2737 | 2639 | */ | |
2738 | if (ContactgeomsArray != IntPtr.Zero) | 2640 | if (ContactgeomsArray != IntPtr.Zero) |
2739 | Marshal.FreeHGlobal(ContactgeomsArray); | 2641 | Marshal.FreeHGlobal(ContactgeomsArray); |
2740 | if (GlobalContactsArray != IntPtr.Zero) | 2642 | if (GlobalContactsArray != IntPtr.Zero) |