aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics')
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs46
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs33
2 files changed, 68 insertions, 11 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
index 87a7e51..5db4f17 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
@@ -194,8 +194,10 @@ namespace OpenSim.Region.Physics.OdePlugin
194 public int givefakeori = 0; 194 public int givefakeori = 0;
195 private Quaternion fakeori; 195 private Quaternion fakeori;
196 196
197 public int m_eventsubscription; 197 private int m_eventsubscription;
198 private CollisionEventUpdate CollisionEventsThisFrame = new CollisionEventUpdate(); 198 private int m_cureventsubscription;
199 private CollisionEventUpdate CollisionEventsThisFrame = null;
200 private bool SentEmptyCollisionsEvent;
199 201
200 public volatile bool childPrim; 202 public volatile bool childPrim;
201 203
@@ -931,12 +933,21 @@ namespace OpenSim.Region.Physics.OdePlugin
931 public override void SubscribeEvents(int ms) 933 public override void SubscribeEvents(int ms)
932 { 934 {
933 m_eventsubscription = ms; 935 m_eventsubscription = ms;
936 m_cureventsubscription = 0;
937 if (CollisionEventsThisFrame == null)
938 CollisionEventsThisFrame = new CollisionEventUpdate();
939 SentEmptyCollisionsEvent = false;
934 _parent_scene.AddCollisionEventReporting(this); 940 _parent_scene.AddCollisionEventReporting(this);
935 } 941 }
936 942
937 public override void UnSubscribeEvents() 943 public override void UnSubscribeEvents()
938 { 944 {
939 _parent_scene.RemoveCollisionEventReporting(this); 945 _parent_scene.RemoveCollisionEventReporting(this);
946 if (CollisionEventsThisFrame != null)
947 {
948 CollisionEventsThisFrame.Clear();
949 CollisionEventsThisFrame = null;
950 }
940 m_eventsubscription = 0; 951 m_eventsubscription = 0;
941 } 952 }
942 953
@@ -944,7 +955,6 @@ namespace OpenSim.Region.Physics.OdePlugin
944 { 955 {
945 if (CollisionEventsThisFrame == null) 956 if (CollisionEventsThisFrame == null)
946 CollisionEventsThisFrame = new CollisionEventUpdate(); 957 CollisionEventsThisFrame = new CollisionEventUpdate();
947
948 CollisionEventsThisFrame.AddCollider(CollidedWith, contact); 958 CollisionEventsThisFrame.AddCollider(CollidedWith, contact);
949 } 959 }
950 960
@@ -953,14 +963,34 @@ namespace OpenSim.Region.Physics.OdePlugin
953 if (CollisionEventsThisFrame == null) 963 if (CollisionEventsThisFrame == null)
954 return; 964 return;
955 965
956 base.SendCollisionUpdate(CollisionEventsThisFrame); 966 if (m_cureventsubscription < m_eventsubscription)
967 return;
957 968
958 if (CollisionEventsThisFrame.m_objCollisionList.Count == 0) 969 m_cureventsubscription = 0;
959 CollisionEventsThisFrame = null; 970
960 else 971 int ncolisions = CollisionEventsThisFrame.m_objCollisionList.Count;
961 CollisionEventsThisFrame = new CollisionEventUpdate(); 972
973 if (!SentEmptyCollisionsEvent || ncolisions > 0)
974 {
975 base.SendCollisionUpdate(CollisionEventsThisFrame);
976
977 if (ncolisions == 0)
978 SentEmptyCollisionsEvent = true;
979 else
980 {
981 SentEmptyCollisionsEvent = false;
982 CollisionEventsThisFrame.Clear();
983 }
984 }
962 } 985 }
963 986
987 internal void AddCollisionFrameTime(int t)
988 {
989 // protect it from overflow crashing
990 if (m_cureventsubscription + t >= int.MaxValue)
991 m_cureventsubscription = 0;
992 m_cureventsubscription += t;
993 }
964 public override bool SubscribedEvents() 994 public override bool SubscribedEvents()
965 { 995 {
966 if (m_eventsubscription > 0) 996 if (m_eventsubscription > 0)
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
index 7367719..ddfdea4 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
@@ -620,8 +620,6 @@ namespace OpenSim.Region.Physics.OdePlugin
620 return d.JointCreateContactPtr(world, contactgroup, contact); 620 return d.JointCreateContactPtr(world, contactgroup, contact);
621 } 621 }
622 622
623
624
625 private bool GetCurContactGeom(int index, ref d.ContactGeom newcontactgeom) 623 private bool GetCurContactGeom(int index, ref d.ContactGeom newcontactgeom)
626 { 624 {
627 if (ContactgeomsArray == IntPtr.Zero || index >= contactsPerCollision) 625 if (ContactgeomsArray == IntPtr.Zero || index >= contactsPerCollision)
@@ -1153,6 +1151,31 @@ namespace OpenSim.Region.Physics.OdePlugin
1153 } 1151 }
1154 } 1152 }
1155 break; 1153 break;
1154 case ActorTypes.Ground:
1155 case ActorTypes.Unknown:
1156 default:
1157 switch ((ActorTypes)p2.PhysicsActorType)
1158 {
1159 case ActorTypes.Agent:
1160 if (p2 is OdeCharacter)
1161 {
1162 cc2 = (OdeCharacter)p2;
1163 obj2LocalID = cc2.m_localID;
1164 if (p2events)
1165 cc2.AddCollisionEvent(0, contact);
1166 }
1167 break;
1168 case ActorTypes.Prim:
1169 if (p2 is OdePrim)
1170 {
1171 cp2 = (OdePrim)p2;
1172 obj2LocalID = cp2.m_localID;
1173 if (p2events)
1174 cp2.AddCollisionEvent(0, contact);
1175 }
1176 break;
1177 }
1178 break;
1156 } 1179 }
1157 } 1180 }
1158 1181
@@ -1875,7 +1898,11 @@ namespace OpenSim.Region.Physics.OdePlugin
1875 1898
1876 case ActorTypes.Prim: 1899 case ActorTypes.Prim:
1877 OdePrim pobj = (OdePrim)obj; 1900 OdePrim pobj = (OdePrim)obj;
1878 pobj.SendCollisions(); 1901 if (pobj.Body == IntPtr.Zero || (d.BodyIsEnabled(pobj.Body) && !pobj.m_outbounds))
1902 {
1903 pobj.AddCollisionFrameTime((int)(ODE_STEPSIZE * 1000.0f));
1904 pobj.SendCollisions();
1905 }
1879 break; 1906 break;
1880 } 1907 }
1881 } 1908 }