aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorUbitUmarov2012-05-15 15:45:01 +0100
committerUbitUmarov2012-05-15 15:45:01 +0100
commit9d675232359a30c56d2b68d50fe15958374ec773 (patch)
treea869325a755f454c141b2e70767a5a1f8598205f
parentubitODE: fix not reporting land collisions on same cases. (diff)
downloadopensim-SC_OLD-9d675232359a30c56d2b68d50fe15958374ec773.zip
opensim-SC_OLD-9d675232359a30c56d2b68d50fe15958374ec773.tar.gz
opensim-SC_OLD-9d675232359a30c56d2b68d50fe15958374ec773.tar.bz2
opensim-SC_OLD-9d675232359a30c56d2b68d50fe15958374ec773.tar.xz
ubitODE: if stopped having collisions do report zero colisions once, so collision_end event can be triggered. Changed reports rate to the requested rate and not full ode rate.
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs46
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs6
2 files changed, 43 insertions, 9 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 dd912da..ddfdea4 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
@@ -1898,7 +1898,11 @@ namespace OpenSim.Region.Physics.OdePlugin
1898 1898
1899 case ActorTypes.Prim: 1899 case ActorTypes.Prim:
1900 OdePrim pobj = (OdePrim)obj; 1900 OdePrim pobj = (OdePrim)obj;
1901 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 }
1902 break; 1906 break;
1903 } 1907 }
1904 } 1908 }