diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index 09e1f0c..494f5a6 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | |||
@@ -40,6 +40,7 @@ public class BSCharacter : PhysicsActor | |||
40 | private static readonly string LogHeader = "[BULLETS CHAR]"; | 40 | private static readonly string LogHeader = "[BULLETS CHAR]"; |
41 | 41 | ||
42 | private BSScene _scene; | 42 | private BSScene _scene; |
43 | public BSScene Scene { get { return _scene; } } | ||
43 | private String _avName; | 44 | private String _avName; |
44 | // private bool _stopped; | 45 | // private bool _stopped; |
45 | private Vector3 _size; | 46 | private Vector3 _size; |
@@ -73,6 +74,12 @@ public class BSCharacter : PhysicsActor | |||
73 | private bool _kinematic; | 74 | private bool _kinematic; |
74 | private float _buoyancy; | 75 | private float _buoyancy; |
75 | 76 | ||
77 | private BulletBody m_body; | ||
78 | public BulletBody Body { | ||
79 | get { return m_body; } | ||
80 | set { m_body = value; } | ||
81 | } | ||
82 | |||
76 | private int _subscribedEventsMs = 0; | 83 | private int _subscribedEventsMs = 0; |
77 | private int _nextCollisionOkTime = 0; | 84 | private int _nextCollisionOkTime = 0; |
78 | 85 | ||
@@ -116,6 +123,10 @@ public class BSCharacter : PhysicsActor | |||
116 | _scene.TaintedObject(delegate() | 123 | _scene.TaintedObject(delegate() |
117 | { | 124 | { |
118 | BulletSimAPI.CreateObject(parent_scene.WorldID, shapeData); | 125 | BulletSimAPI.CreateObject(parent_scene.WorldID, shapeData); |
126 | |||
127 | m_body = new BulletBody(LocalID, BulletSimAPI.GetBodyHandle2(_scene.World.Ptr, LocalID)); | ||
128 | // avatars get all collisions no matter what | ||
129 | BulletSimAPI.AddToCollisionFlags2(Body.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); | ||
119 | }); | 130 | }); |
120 | 131 | ||
121 | return; | 132 | return; |
@@ -124,6 +135,7 @@ public class BSCharacter : PhysicsActor | |||
124 | // called when this character is being destroyed and the resources should be released | 135 | // called when this character is being destroyed and the resources should be released |
125 | public void Destroy() | 136 | public void Destroy() |
126 | { | 137 | { |
138 | // DetailLog("{0},Destroy", LocalID); | ||
127 | _scene.TaintedObject(delegate() | 139 | _scene.TaintedObject(delegate() |
128 | { | 140 | { |
129 | BulletSimAPI.DestroyObject(_scene.WorldID, _localID); | 141 | BulletSimAPI.DestroyObject(_scene.WorldID, _localID); |
@@ -174,6 +186,7 @@ public class BSCharacter : PhysicsActor | |||
174 | _position = value; | 186 | _position = value; |
175 | _scene.TaintedObject(delegate() | 187 | _scene.TaintedObject(delegate() |
176 | { | 188 | { |
189 | DetailLog("{0},SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); | ||
177 | BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation); | 190 | BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation); |
178 | }); | 191 | }); |
179 | } | 192 | } |
@@ -188,9 +201,10 @@ public class BSCharacter : PhysicsActor | |||
188 | set { | 201 | set { |
189 | _force = value; | 202 | _force = value; |
190 | // m_log.DebugFormat("{0}: Force = {1}", LogHeader, _force); | 203 | // m_log.DebugFormat("{0}: Force = {1}", LogHeader, _force); |
191 | _scene.TaintedObject(delegate() | 204 | Scene.TaintedObject(delegate() |
192 | { | 205 | { |
193 | BulletSimAPI.SetObjectForce(_scene.WorldID, _localID, _force); | 206 | DetailLog("{0},setForce,taint,force={1}", LocalID, _force); |
207 | BulletSimAPI.SetObjectForce(Scene.WorldID, LocalID, _force); | ||
194 | }); | 208 | }); |
195 | } | 209 | } |
196 | } | 210 | } |
@@ -216,6 +230,7 @@ public class BSCharacter : PhysicsActor | |||
216 | // m_log.DebugFormat("{0}: set velocity = {1}", LogHeader, _velocity); | 230 | // m_log.DebugFormat("{0}: set velocity = {1}", LogHeader, _velocity); |
217 | _scene.TaintedObject(delegate() | 231 | _scene.TaintedObject(delegate() |
218 | { | 232 | { |
233 | DetailLog("{0},setVelocity,taint,vel={1}", LocalID, _velocity); | ||
219 | BulletSimAPI.SetObjectVelocity(_scene.WorldID, _localID, _velocity); | 234 | BulletSimAPI.SetObjectVelocity(_scene.WorldID, _localID, _velocity); |
220 | }); | 235 | }); |
221 | } | 236 | } |
@@ -305,6 +320,7 @@ public class BSCharacter : PhysicsActor | |||
305 | set { _buoyancy = value; | 320 | set { _buoyancy = value; |
306 | _scene.TaintedObject(delegate() | 321 | _scene.TaintedObject(delegate() |
307 | { | 322 | { |
323 | DetailLog("{0},setBuoyancy,taint,buoy={1}", LocalID, _buoyancy); | ||
308 | BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, LocalID, _buoyancy); | 324 | BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, LocalID, _buoyancy); |
309 | }); | 325 | }); |
310 | } | 326 | } |
@@ -351,7 +367,8 @@ public class BSCharacter : PhysicsActor | |||
351 | // m_log.DebugFormat("{0}: AddForce. adding={1}, newForce={2}", LogHeader, force, _force); | 367 | // m_log.DebugFormat("{0}: AddForce. adding={1}, newForce={2}", LogHeader, force, _force); |
352 | _scene.TaintedObject(delegate() | 368 | _scene.TaintedObject(delegate() |
353 | { | 369 | { |
354 | BulletSimAPI.SetObjectForce(_scene.WorldID, _localID, _force); | 370 | DetailLog("{0},setAddForce,taint,addedForce={1}", LocalID, _force); |
371 | BulletSimAPI.AddObjectForce2(Body.Ptr, _force); | ||
355 | }); | 372 | }); |
356 | } | 373 | } |
357 | else | 374 | else |
@@ -369,11 +386,25 @@ public class BSCharacter : PhysicsActor | |||
369 | // Turn on collision events at a rate no faster than one every the given milliseconds | 386 | // Turn on collision events at a rate no faster than one every the given milliseconds |
370 | public override void SubscribeEvents(int ms) { | 387 | public override void SubscribeEvents(int ms) { |
371 | _subscribedEventsMs = ms; | 388 | _subscribedEventsMs = ms; |
372 | _nextCollisionOkTime = Util.EnvironmentTickCount() - _subscribedEventsMs; // make first collision happen | 389 | if (ms > 0) |
390 | { | ||
391 | // make sure first collision happens | ||
392 | _nextCollisionOkTime = Util.EnvironmentTickCount() - _subscribedEventsMs; | ||
393 | |||
394 | Scene.TaintedObject(delegate() | ||
395 | { | ||
396 | BulletSimAPI.AddToCollisionFlags2(Body.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); | ||
397 | }); | ||
398 | } | ||
373 | } | 399 | } |
374 | // Stop collision events | 400 | // Stop collision events |
375 | public override void UnSubscribeEvents() { | 401 | public override void UnSubscribeEvents() { |
376 | _subscribedEventsMs = 0; | 402 | _subscribedEventsMs = 0; |
403 | // Avatars get all their collision events | ||
404 | // Scene.TaintedObject(delegate() | ||
405 | // { | ||
406 | // BulletSimAPI.RemoveFromCollisionFlags2(Body.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); | ||
407 | // }); | ||
377 | } | 408 | } |
378 | // Return 'true' if someone has subscribed to events | 409 | // Return 'true' if someone has subscribed to events |
379 | public override bool SubscribedEvents() { | 410 | public override bool SubscribedEvents() { |
@@ -480,5 +511,10 @@ public class BSCharacter : PhysicsActor | |||
480 | // End kludge | 511 | // End kludge |
481 | } | 512 | } |
482 | 513 | ||
514 | // Invoke the detailed logger and output something if it's enabled. | ||
515 | private void DetailLog(string msg, params Object[] args) | ||
516 | { | ||
517 | Scene.PhysicsLogging.Write(msg, args); | ||
518 | } | ||
483 | } | 519 | } |
484 | } | 520 | } |