aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs18
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs16
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs27
3 files changed, 45 insertions, 16 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
index a5635ff..494f5a6 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
@@ -125,6 +125,8 @@ public class BSCharacter : PhysicsActor
125 BulletSimAPI.CreateObject(parent_scene.WorldID, shapeData); 125 BulletSimAPI.CreateObject(parent_scene.WorldID, shapeData);
126 126
127 m_body = new BulletBody(LocalID, BulletSimAPI.GetBodyHandle2(_scene.World.Ptr, LocalID)); 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);
128 }); 130 });
129 131
130 return; 132 return;
@@ -384,11 +386,25 @@ public class BSCharacter : PhysicsActor
384 // 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
385 public override void SubscribeEvents(int ms) { 387 public override void SubscribeEvents(int ms) {
386 _subscribedEventsMs = ms; 388 _subscribedEventsMs = ms;
387 _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 }
388 } 399 }
389 // Stop collision events 400 // Stop collision events
390 public override void UnSubscribeEvents() { 401 public override void UnSubscribeEvents() {
391 _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 // });
392 } 408 }
393 // Return 'true' if someone has subscribed to events 409 // Return 'true' if someone has subscribed to events
394 public override bool SubscribedEvents() { 410 public override bool SubscribedEvents() {
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index 22f5995..8e6685b 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -642,11 +642,23 @@ public sealed class BSPrim : PhysicsActor
642 } 642 }
643 public override void SubscribeEvents(int ms) { 643 public override void SubscribeEvents(int ms) {
644 _subscribedEventsMs = ms; 644 _subscribedEventsMs = ms;
645 // make sure first collision happens 645 if (ms > 0)
646 _nextCollisionOkTime = Util.EnvironmentTickCount() - _subscribedEventsMs; 646 {
647 // make sure first collision happens
648 _nextCollisionOkTime = Util.EnvironmentTickCount() - _subscribedEventsMs;
649
650 Scene.TaintedObject(delegate()
651 {
652 BulletSimAPI.AddToCollisionFlags2(Body.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
653 });
654 }
647 } 655 }
648 public override void UnSubscribeEvents() { 656 public override void UnSubscribeEvents() {
649 _subscribedEventsMs = 0; 657 _subscribedEventsMs = 0;
658 Scene.TaintedObject(delegate()
659 {
660 BulletSimAPI.RemoveFromCollisionFlags2(Body.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
661 });
650 } 662 }
651 public override bool SubscribedEvents() { 663 public override bool SubscribedEvents() {
652 return (_subscribedEventsMs > 0); 664 return (_subscribedEventsMs > 0);
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
index 1881e41..4e05df6 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
@@ -179,17 +179,18 @@ public struct ConfigurationParameters
179// Values used by Bullet and BulletSim to control collisions 179// Values used by Bullet and BulletSim to control collisions
180public enum CollisionFlags : uint 180public enum CollisionFlags : uint
181{ 181{
182 STATIC_OBJECT = 1 << 0, 182 CF_STATIC_OBJECT = 1 << 0,
183 KINEMATIC_OBJECT = 1 << 1, 183 CF_KINEMATIC_OBJECT = 1 << 1,
184 NO_CONTACT_RESPONSE = 1 << 2, 184 CF_NO_CONTACT_RESPONSE = 1 << 2,
185 CUSTOM_MATERIAL_CALLBACK = 1 << 3, 185 CF_CUSTOM_MATERIAL_CALLBACK = 1 << 3,
186 CHARACTER_OBJECT = 1 << 4, 186 CF_CHARACTER_OBJECT = 1 << 4,
187 DISABLE_VISUALIZE_OBJECT = 1 << 5, 187 CF_DISABLE_VISUALIZE_OBJECT = 1 << 5,
188 DISABLE_SPU_COLLISION_PROCESS = 1 << 6, 188 CF_DISABLE_SPU_COLLISION_PROCESS = 1 << 6,
189 // Following used by BulletSim to control collisions 189 // Following used by BulletSim to control collisions
190 VOLUME_DETECT_OBJECT = 1 << 10, 190 BS_SUBSCRIBE_COLLISION_EVENTS = 1 << 10,
191 PHANTOM_OBJECT = 1 << 11, 191 BS_VOLUME_DETECT_OBJECT = 1 << 11,
192 PHYSICAL_OBJECT = 1 << 12, 192 BS_PHANTOM_OBJECT = 1 << 12,
193 BS_PHYSICAL_OBJECT = 1 << 13,
193}; 194};
194 195
195// CFM controls the 'hardness' of the constraint. 0=fixed, 0..1=violatable. Default=0 196// CFM controls the 'hardness' of the constraint. 0=fixed, 0..1=violatable. Default=0
@@ -481,13 +482,13 @@ public static extern bool SetLinearVelocity2(IntPtr obj, Vector3 val);
481public static extern bool SetInterpolation2(IntPtr obj, Vector3 lin, Vector3 ang); 482public static extern bool SetInterpolation2(IntPtr obj, Vector3 lin, Vector3 ang);
482 483
483[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 484[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
484public static extern IntPtr SetCollisionFlags2(IntPtr obj, uint flags); 485public static extern IntPtr SetCollisionFlags2(IntPtr obj, CollisionFlags flags);
485 486
486[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 487[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
487public static extern IntPtr AddToCollisionFlags2(IntPtr obj, uint flags); 488public static extern IntPtr AddToCollisionFlags2(IntPtr obj, CollisionFlags flags);
488 489
489[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 490[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
490public static extern IntPtr RemoveFromCollisionFlags2(IntPtr obj, uint flags); 491public static extern IntPtr RemoveFromCollisionFlags2(IntPtr obj, CollisionFlags flags);
491 492
492[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 493[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
493public static extern bool SetMassProps2(IntPtr obj, float mass, Vector3 inertia); 494public static extern bool SetMassProps2(IntPtr obj, float mass, Vector3 inertia);