aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs79
1 files changed, 48 insertions, 31 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index b36b933..ca294b8 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -128,9 +128,10 @@ namespace OpenSim.Region.Physics.OdePlugin
128 public d.Mass ShellMass; 128 public d.Mass ShellMass;
129// public bool collidelock = false; 129// public bool collidelock = false;
130 130
131 private bool m_haseventsubscription = false;
132 public int m_eventsubscription = 0; 131 public int m_eventsubscription = 0;
133 private CollisionEventUpdate CollisionEventsThisFrame = new CollisionEventUpdate(); 132 private int m_cureventsubscription = 0;
133 private CollisionEventUpdate CollisionEventsThisFrame = null;
134 private bool SentEmptyCollisionsEvent;
134 135
135 // unique UUID of this character object 136 // unique UUID of this character object
136 public UUID m_uuid; 137 public UUID m_uuid;
@@ -1120,47 +1121,72 @@ namespace OpenSim.Region.Physics.OdePlugin
1120 1121
1121 public override void SubscribeEvents(int ms) 1122 public override void SubscribeEvents(int ms)
1122 { 1123 {
1123 m_requestedUpdateFrequency = ms;
1124 m_eventsubscription = ms; 1124 m_eventsubscription = ms;
1125 _parent_scene.AddCollisionEventReporting(this); 1125 m_cureventsubscription = 0;
1126 m_haseventsubscription = true; 1126 if (CollisionEventsThisFrame == null)
1127 CollisionEventsThisFrame = new CollisionEventUpdate();
1128 SentEmptyCollisionsEvent = false;
1127 } 1129 }
1128 1130
1129 public override void UnSubscribeEvents() 1131 public override void UnSubscribeEvents()
1130 { 1132 {
1131 m_haseventsubscription = false; 1133 if (CollisionEventsThisFrame != null)
1132 _parent_scene.RemoveCollisionEventReporting(this); 1134 {
1133 m_requestedUpdateFrequency = 0; 1135 CollisionEventsThisFrame.Clear();
1136 CollisionEventsThisFrame = null;
1137 }
1134 m_eventsubscription = 0; 1138 m_eventsubscription = 0;
1135 } 1139 }
1136 1140
1137 public void AddCollisionEvent(uint CollidedWith, ContactPoint contact) 1141 public void AddCollisionEvent(uint CollidedWith, ContactPoint contact)
1138 { 1142 {
1139 if (m_haseventsubscription) 1143 if (CollisionEventsThisFrame == null)
1140 { 1144 CollisionEventsThisFrame = new CollisionEventUpdate();
1141 // m_log.DebugFormat( 1145 CollisionEventsThisFrame.AddCollider(CollidedWith, contact);
1142 // "[PHYSICS]: Adding collision event for {0}, collidedWith {1}, contact {2}", "", CollidedWith, contact);
1143
1144 CollisionEventsThisFrame.AddCollider(CollidedWith, contact);
1145 }
1146 } 1146 }
1147 1147
1148 public void SendCollisions() 1148 public void SendCollisions()
1149 { 1149 {
1150 if (m_haseventsubscription && m_eventsubscription > m_requestedUpdateFrequency) 1150 if (CollisionEventsThisFrame == null)
1151 return;
1152
1153 if (m_cureventsubscription < m_eventsubscription)
1154 return;
1155
1156 m_cureventsubscription = 0;
1157
1158 int ncolisions = CollisionEventsThisFrame.m_objCollisionList.Count;
1159
1160 if (!SentEmptyCollisionsEvent || ncolisions > 0)
1151 { 1161 {
1152 if (CollisionEventsThisFrame != null) 1162 base.SendCollisionUpdate(CollisionEventsThisFrame);
1163
1164 if (ncolisions == 0)
1153 { 1165 {
1154 base.SendCollisionUpdate(CollisionEventsThisFrame); 1166 SentEmptyCollisionsEvent = true;
1167 _parent_scene.RemoveCollisionEventReporting(this);
1155 } 1168 }
1156 CollisionEventsThisFrame = new CollisionEventUpdate(); 1169 else
1157 m_eventsubscription = 0; 1170 {
1158 } 1171 SentEmptyCollisionsEvent = false;
1172 CollisionEventsThisFrame.Clear();
1173 }
1174 }
1175 }
1176
1177 internal void AddCollisionFrameTime(int t)
1178 {
1179 // protect it from overflow crashing
1180 if (m_cureventsubscription + t >= int.MaxValue)
1181 m_cureventsubscription = 0;
1182 m_cureventsubscription += t;
1159 } 1183 }
1160 1184
1161 public override bool SubscribedEvents() 1185 public override bool SubscribedEvents()
1162 { 1186 {
1163 return m_haseventsubscription; 1187 if (m_eventsubscription > 0)
1188 return true;
1189 return false;
1164 } 1190 }
1165 1191
1166 private void changePhysicsStatus(bool NewStatus) 1192 private void changePhysicsStatus(bool NewStatus)
@@ -1466,14 +1492,5 @@ namespace OpenSim.Region.Physics.OdePlugin
1466 { 1492 {
1467 _parent_scene.AddChange((PhysicsActor)this, what, arg); 1493 _parent_scene.AddChange((PhysicsActor)this, what, arg);
1468 } 1494 }
1469
1470
1471 internal void AddCollisionFrameTime(int p)
1472 {
1473 // protect it from overflow crashing
1474 if (m_eventsubscription + p >= int.MaxValue)
1475 m_eventsubscription = 0;
1476 m_eventsubscription += p;
1477 }
1478 } 1495 }
1479} 1496}