aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs')
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs83
1 files changed, 49 insertions, 34 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index b0711d7..1084b0e 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;
@@ -239,7 +240,7 @@ namespace OpenSim.Region.Physics.OdePlugin
239 240
240 public override bool IsPhysical 241 public override bool IsPhysical
241 { 242 {
242 get { return false; } 243 get { return m_isPhysical; }
243 set { return; } 244 set { return; }
244 } 245 }
245 246
@@ -783,8 +784,6 @@ namespace OpenSim.Region.Physics.OdePlugin
783 784
784 // the Amotor still lets avatar rotation to drift during colisions 785 // the Amotor still lets avatar rotation to drift during colisions
785 // so force it back to identity 786 // so force it back to identity
786
787
788 787
789 d.Quaternion qtmp; 788 d.Quaternion qtmp;
790 qtmp.W = 1; 789 qtmp.W = 1;
@@ -903,6 +902,7 @@ namespace OpenSim.Region.Physics.OdePlugin
903 contact.SurfaceNormal.X = 0f; 902 contact.SurfaceNormal.X = 0f;
904 contact.SurfaceNormal.Y = 0f; 903 contact.SurfaceNormal.Y = 0f;
905 contact.SurfaceNormal.Z = -1f; 904 contact.SurfaceNormal.Z = -1f;
905 contact.RelativeSpeed = -vel.Z;
906 AddCollisionEvent(0, contact); 906 AddCollisionEvent(0, contact);
907 907
908 vec.Z *= 0.5f; 908 vec.Z *= 0.5f;
@@ -1119,47 +1119,71 @@ namespace OpenSim.Region.Physics.OdePlugin
1119 1119
1120 public override void SubscribeEvents(int ms) 1120 public override void SubscribeEvents(int ms)
1121 { 1121 {
1122 m_requestedUpdateFrequency = ms;
1123 m_eventsubscription = ms; 1122 m_eventsubscription = ms;
1124 _parent_scene.AddCollisionEventReporting(this); 1123 m_cureventsubscription = 0;
1125 m_haseventsubscription = true; 1124 if (CollisionEventsThisFrame == null)
1125 CollisionEventsThisFrame = new CollisionEventUpdate();
1126 SentEmptyCollisionsEvent = false;
1126 } 1127 }
1127 1128
1128 public override void UnSubscribeEvents() 1129 public override void UnSubscribeEvents()
1129 { 1130 {
1130 m_haseventsubscription = false; 1131 if (CollisionEventsThisFrame != null)
1131 _parent_scene.RemoveCollisionEventReporting(this); 1132 {
1132 m_requestedUpdateFrequency = 0; 1133 CollisionEventsThisFrame.Clear();
1134 CollisionEventsThisFrame = null;
1135 }
1133 m_eventsubscription = 0; 1136 m_eventsubscription = 0;
1134 } 1137 }
1135 1138
1136 public void AddCollisionEvent(uint CollidedWith, ContactPoint contact) 1139 public void AddCollisionEvent(uint CollidedWith, ContactPoint contact)
1137 { 1140 {
1138 if (m_haseventsubscription) 1141 if (CollisionEventsThisFrame == null)
1139 { 1142 CollisionEventsThisFrame = new CollisionEventUpdate();
1140 // m_log.DebugFormat( 1143 CollisionEventsThisFrame.AddCollider(CollidedWith, contact);
1141 // "[PHYSICS]: Adding collision event for {0}, collidedWith {1}, contact {2}", "", CollidedWith, contact);
1142
1143 CollisionEventsThisFrame.AddCollider(CollidedWith, contact);
1144 }
1145 } 1144 }
1146 1145
1147 public void SendCollisions() 1146 public void SendCollisions()
1148 { 1147 {
1149 if (m_haseventsubscription && m_eventsubscription > m_requestedUpdateFrequency) 1148 if (CollisionEventsThisFrame == null)
1149 return;
1150
1151 if (m_cureventsubscription < m_eventsubscription)
1152 return;
1153
1154 m_cureventsubscription = 0;
1155
1156 int ncolisions = CollisionEventsThisFrame.m_objCollisionList.Count;
1157
1158 if (!SentEmptyCollisionsEvent || ncolisions > 0)
1150 { 1159 {
1151 if (CollisionEventsThisFrame != null) 1160 base.SendCollisionUpdate(CollisionEventsThisFrame);
1161
1162 if (ncolisions == 0)
1152 { 1163 {
1153 base.SendCollisionUpdate(CollisionEventsThisFrame); 1164 SentEmptyCollisionsEvent = true;
1165 _parent_scene.RemoveCollisionEventReporting(this);
1154 } 1166 }
1155 CollisionEventsThisFrame = new CollisionEventUpdate(); 1167 else
1156 m_eventsubscription = 0; 1168 {
1157 } 1169 SentEmptyCollisionsEvent = false;
1170 CollisionEventsThisFrame.Clear();
1171 }
1172 }
1173 }
1174
1175 internal void AddCollisionFrameTime(int t)
1176 {
1177 // protect it from overflow crashing
1178 if (m_cureventsubscription < 50000)
1179 m_cureventsubscription += t;
1158 } 1180 }
1159 1181
1160 public override bool SubscribedEvents() 1182 public override bool SubscribedEvents()
1161 { 1183 {
1162 return m_haseventsubscription; 1184 if (m_eventsubscription > 0)
1185 return true;
1186 return false;
1163 } 1187 }
1164 1188
1165 private void changePhysicsStatus(bool NewStatus) 1189 private void changePhysicsStatus(bool NewStatus)
@@ -1465,14 +1489,5 @@ namespace OpenSim.Region.Physics.OdePlugin
1465 { 1489 {
1466 _parent_scene.AddChange((PhysicsActor)this, what, arg); 1490 _parent_scene.AddChange((PhysicsActor)this, what, arg);
1467 } 1491 }
1468
1469
1470 internal void AddCollisionFrameTime(int p)
1471 {
1472 // protect it from overflow crashing
1473 if (m_eventsubscription + p >= int.MaxValue)
1474 m_eventsubscription = 0;
1475 m_eventsubscription += p;
1476 }
1477 } 1492 }
1478} 1493}