diff options
author | Robert Adams | 2012-09-26 09:25:56 -0700 |
---|---|---|
committer | Robert Adams | 2012-09-27 22:01:47 -0700 |
commit | 4589bc84a32366c6aae68b67f1fc7a2ee08be86d (patch) | |
tree | e635ab006f40e85eeb7b49870c04e6b2ca572dee | |
parent | BulletSim: btGhostObjects working to make 'volume detect' work. (diff) | |
download | opensim-SC-4589bc84a32366c6aae68b67f1fc7a2ee08be86d.zip opensim-SC-4589bc84a32366c6aae68b67f1fc7a2ee08be86d.tar.gz opensim-SC-4589bc84a32366c6aae68b67f1fc7a2ee08be86d.tar.bz2 opensim-SC-4589bc84a32366c6aae68b67f1fc7a2ee08be86d.tar.xz |
BulletSim: Terrain sets proper collision flags on creation.
Static objects are set to ISLAND_SLEEPING rather than DISABLE_SIMULATION.
Might reconsider this and, alternatively, have dynamic objects force activation.
Clean up use of DetailLog().
4 files changed, 56 insertions, 52 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs index 3458477..4f83adc 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs | |||
@@ -121,8 +121,8 @@ public abstract class BSPhysObject : PhysicsActor | |||
121 | // if someone has subscribed for collision events.... | 121 | // if someone has subscribed for collision events.... |
122 | if (SubscribedEvents()) { | 122 | if (SubscribedEvents()) { |
123 | CollisionCollection.AddCollider(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth)); | 123 | CollisionCollection.AddCollider(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth)); |
124 | DetailLog("{0},{1}.Collison.AddCollider,call,with={2},point={3},normal={4},depth={5}", | 124 | // DetailLog("{0},{1}.Collison.AddCollider,call,with={2},point={3},normal={4},depth={5}", |
125 | LocalID, TypeName, collidingWith, contactPoint, contactNormal, pentrationDepth); | 125 | // LocalID, TypeName, collidingWith, contactPoint, contactNormal, pentrationDepth); |
126 | 126 | ||
127 | ret = true; | 127 | ret = true; |
128 | } | 128 | } |
@@ -151,7 +151,7 @@ public abstract class BSPhysObject : PhysicsActor | |||
151 | PhysicsScene.ObjectsWithNoMoreCollisions.Add(this); | 151 | PhysicsScene.ObjectsWithNoMoreCollisions.Add(this); |
152 | } | 152 | } |
153 | 153 | ||
154 | DetailLog("{0},{1}.SendCollisionUpdate,call,numCollisions={2}", LocalID, TypeName, CollisionCollection.Count); | 154 | // DetailLog("{0},{1}.SendCollisionUpdate,call,numCollisions={2}", LocalID, TypeName, CollisionCollection.Count); |
155 | base.SendCollisionUpdate(CollisionCollection); | 155 | base.SendCollisionUpdate(CollisionCollection); |
156 | 156 | ||
157 | // The collisionCollection structure is passed around in the simulator. | 157 | // The collisionCollection structure is passed around in the simulator. |
@@ -163,7 +163,7 @@ public abstract class BSPhysObject : PhysicsActor | |||
163 | // Subscribe for collision events. | 163 | // Subscribe for collision events. |
164 | // Parameter is the millisecond rate the caller wishes collision events to occur. | 164 | // Parameter is the millisecond rate the caller wishes collision events to occur. |
165 | public override void SubscribeEvents(int ms) { | 165 | public override void SubscribeEvents(int ms) { |
166 | DetailLog("{0},{1}.SubscribeEvents,subscribing,ms={2}", LocalID, TypeName, ms); | 166 | // DetailLog("{0},{1}.SubscribeEvents,subscribing,ms={2}", LocalID, TypeName, ms); |
167 | SubscribedEventsMs = ms; | 167 | SubscribedEventsMs = ms; |
168 | if (ms > 0) | 168 | if (ms > 0) |
169 | { | 169 | { |
@@ -182,7 +182,7 @@ public abstract class BSPhysObject : PhysicsActor | |||
182 | } | 182 | } |
183 | } | 183 | } |
184 | public override void UnSubscribeEvents() { | 184 | public override void UnSubscribeEvents() { |
185 | DetailLog("{0},{1}.UnSubscribeEvents,unsubscribing", LocalID, TypeName); | 185 | // DetailLog("{0},{1}.UnSubscribeEvents,unsubscribing", LocalID, TypeName); |
186 | SubscribedEventsMs = 0; | 186 | SubscribedEventsMs = 0; |
187 | PhysicsScene.TaintedObject(TypeName+".UnSubscribeEvents", delegate() | 187 | PhysicsScene.TaintedObject(TypeName+".UnSubscribeEvents", delegate() |
188 | { | 188 | { |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 1c6d476..68a153e 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |||
@@ -174,7 +174,7 @@ public sealed class BSPrim : BSPhysObject | |||
174 | // Since _size changed, the mesh needs to be rebuilt. If rebuilt, all the correct | 174 | // Since _size changed, the mesh needs to be rebuilt. If rebuilt, all the correct |
175 | // scale and margins are set. | 175 | // scale and margins are set. |
176 | CreateGeomAndObject(true); | 176 | CreateGeomAndObject(true); |
177 | DetailLog("{0},BSPrim.setSize,size={1},scale={2},mass={3},physical={4}", LocalID, _size, _scale, _mass, IsPhysical); | 177 | // DetailLog("{0},BSPrim.setSize,size={1},scale={2},mass={3},physical={4}", LocalID, _size, _scale, _mass, IsPhysical); |
178 | }); | 178 | }); |
179 | } | 179 | } |
180 | } | 180 | } |
@@ -204,6 +204,7 @@ public sealed class BSPrim : BSPhysObject | |||
204 | _isSelected = value; | 204 | _isSelected = value; |
205 | PhysicsScene.TaintedObject("BSPrim.setSelected", delegate() | 205 | PhysicsScene.TaintedObject("BSPrim.setSelected", delegate() |
206 | { | 206 | { |
207 | // DetailLog("{0},BSPrim.selected,taint,selected={1}", LocalID, _isSelected); | ||
207 | SetObjectDynamic(false); | 208 | SetObjectDynamic(false); |
208 | }); | 209 | }); |
209 | } | 210 | } |
@@ -279,7 +280,7 @@ public sealed class BSPrim : BSPhysObject | |||
279 | // TODO: what does it mean to set the position of a child prim?? Rebuild the constraint? | 280 | // TODO: what does it mean to set the position of a child prim?? Rebuild the constraint? |
280 | PhysicsScene.TaintedObject("BSPrim.setPosition", delegate() | 281 | PhysicsScene.TaintedObject("BSPrim.setPosition", delegate() |
281 | { | 282 | { |
282 | DetailLog("{0},BSPrim.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); | 283 | // DetailLog("{0},BSPrim.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); |
283 | BulletSimAPI.SetTranslation2(BSBody.ptr, _position, _orientation); | 284 | BulletSimAPI.SetTranslation2(BSBody.ptr, _position, _orientation); |
284 | }); | 285 | }); |
285 | } | 286 | } |
@@ -317,7 +318,7 @@ public sealed class BSPrim : BSPhysObject | |||
317 | _force = value; | 318 | _force = value; |
318 | PhysicsScene.TaintedObject("BSPrim.setForce", delegate() | 319 | PhysicsScene.TaintedObject("BSPrim.setForce", delegate() |
319 | { | 320 | { |
320 | DetailLog("{0},BSPrim.setForce,taint,force={1}", LocalID, _force); | 321 | // DetailLog("{0},BSPrim.setForce,taint,force={1}", LocalID, _force); |
321 | BulletSimAPI.SetObjectForce2(BSBody.ptr, _force); | 322 | BulletSimAPI.SetObjectForce2(BSBody.ptr, _force); |
322 | }); | 323 | }); |
323 | } | 324 | } |
@@ -385,7 +386,7 @@ public sealed class BSPrim : BSPhysObject | |||
385 | _isVolumeDetect = newValue; | 386 | _isVolumeDetect = newValue; |
386 | PhysicsScene.TaintedObject("BSPrim.SetVolumeDetect", delegate() | 387 | PhysicsScene.TaintedObject("BSPrim.SetVolumeDetect", delegate() |
387 | { | 388 | { |
388 | DetailLog("{0},setVolumeDetect,taint,volDetect={1}", LocalID, _isVolumeDetect); | 389 | // DetailLog("{0},setVolumeDetect,taint,volDetect={1}", LocalID, _isVolumeDetect); |
389 | SetObjectDynamic(true); | 390 | SetObjectDynamic(true); |
390 | }); | 391 | }); |
391 | } | 392 | } |
@@ -398,7 +399,7 @@ public sealed class BSPrim : BSPhysObject | |||
398 | _velocity = value; | 399 | _velocity = value; |
399 | PhysicsScene.TaintedObject("BSPrim.setVelocity", delegate() | 400 | PhysicsScene.TaintedObject("BSPrim.setVelocity", delegate() |
400 | { | 401 | { |
401 | DetailLog("{0},BSPrim.SetVelocity,taint,vel={1}", LocalID, _velocity); | 402 | // DetailLog("{0},BSPrim.SetVelocity,taint,vel={1}", LocalID, _velocity); |
402 | BulletSimAPI.SetLinearVelocity2(BSBody.ptr, _velocity); | 403 | BulletSimAPI.SetLinearVelocity2(BSBody.ptr, _velocity); |
403 | }); | 404 | }); |
404 | } | 405 | } |
@@ -406,7 +407,7 @@ public sealed class BSPrim : BSPhysObject | |||
406 | public override OMV.Vector3 Torque { | 407 | public override OMV.Vector3 Torque { |
407 | get { return _torque; } | 408 | get { return _torque; } |
408 | set { _torque = value; | 409 | set { _torque = value; |
409 | DetailLog("{0},BSPrim.SetTorque,call,torque={1}", LocalID, _torque); | 410 | // DetailLog("{0},BSPrim.SetTorque,call,torque={1}", LocalID, _torque); |
410 | } | 411 | } |
411 | } | 412 | } |
412 | public override float CollisionScore { | 413 | public override float CollisionScore { |
@@ -433,7 +434,7 @@ public sealed class BSPrim : BSPhysObject | |||
433 | PhysicsScene.TaintedObject("BSPrim.setOrientation", delegate() | 434 | PhysicsScene.TaintedObject("BSPrim.setOrientation", delegate() |
434 | { | 435 | { |
435 | // _position = BulletSimAPI.GetObjectPosition2(PhysicsScene.World.ptr, BSBody.ptr); | 436 | // _position = BulletSimAPI.GetObjectPosition2(PhysicsScene.World.ptr, BSBody.ptr); |
436 | DetailLog("{0},BSPrim.setOrientation,taint,pos={1},orient={2}", LocalID, _position, _orientation); | 437 | // DetailLog("{0},BSPrim.setOrientation,taint,pos={1},orient={2}", LocalID, _position, _orientation); |
437 | BulletSimAPI.SetTranslation2(BSBody.ptr, _position, _orientation); | 438 | BulletSimAPI.SetTranslation2(BSBody.ptr, _position, _orientation); |
438 | }); | 439 | }); |
439 | } | 440 | } |
@@ -450,7 +451,7 @@ public sealed class BSPrim : BSPhysObject | |||
450 | _isPhysical = value; | 451 | _isPhysical = value; |
451 | PhysicsScene.TaintedObject("BSPrim.setIsPhysical", delegate() | 452 | PhysicsScene.TaintedObject("BSPrim.setIsPhysical", delegate() |
452 | { | 453 | { |
453 | DetailLog("{0},setIsPhysical,taint,isPhys={1}", LocalID, _isPhysical); | 454 | // DetailLog("{0},setIsPhysical,taint,isPhys={1}", LocalID, _isPhysical); |
454 | SetObjectDynamic(true); | 455 | SetObjectDynamic(true); |
455 | }); | 456 | }); |
456 | } | 457 | } |
@@ -470,12 +471,7 @@ public sealed class BSPrim : BSPhysObject | |||
470 | } | 471 | } |
471 | 472 | ||
472 | // Make gravity work if the object is physical and not selected | 473 | // Make gravity work if the object is physical and not selected |
473 | // No locking here because only called when it is safe (called at taint-time). | 474 | // Called at taint-time!! |
474 | // There are four flags we're interested in: | ||
475 | // IsStatic: Object does not move, otherwise the object has mass and moves | ||
476 | // isSolid: other objects bounce off of this object | ||
477 | // isVolumeDetect: other objects pass through but can generate collisions | ||
478 | // collisionEvents: whether this object returns collision events | ||
479 | private void SetObjectDynamic(bool forceRebuild) | 475 | private void SetObjectDynamic(bool forceRebuild) |
480 | { | 476 | { |
481 | #if CSHARP_BODY_MANAGEMENT | 477 | #if CSHARP_BODY_MANAGEMENT |
@@ -488,11 +484,17 @@ public sealed class BSPrim : BSPhysObject | |||
488 | #endif // CSHARP_BODY_MANAGEMENT | 484 | #endif // CSHARP_BODY_MANAGEMENT |
489 | } | 485 | } |
490 | 486 | ||
487 | // Convert the simulator's physical properties into settings on BulletSim objects. | ||
488 | // There are four flags we're interested in: | ||
489 | // IsStatic: Object does not move, otherwise the object has mass and moves | ||
490 | // isSolid: other objects bounce off of this object | ||
491 | // isVolumeDetect: other objects pass through but can generate collisions | ||
492 | // collisionEvents: whether this object returns collision events | ||
491 | private void UpdatePhysicalParameters() | 493 | private void UpdatePhysicalParameters() |
492 | { | 494 | { |
493 | DetailLog("{0},BSPrim.UpdatePhysicalParameters,entry,body={1},shape={2}", LocalID, BSBody, BSShape); | 495 | // DetailLog("{0},BSPrim.UpdatePhysicalParameters,entry,body={1},shape={2}", LocalID, BSBody, BSShape); |
494 | 496 | ||
495 | // Mangling all the physical properties requires the object to be out of the physical world. | 497 | // Mangling all the physical properties requires the object not be in the physical world. |
496 | // This is a NOOP if the object is not in the world (BulletSim and Bullet ignore objects not found). | 498 | // This is a NOOP if the object is not in the world (BulletSim and Bullet ignore objects not found). |
497 | BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, BSBody.ptr); | 499 | BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, BSBody.ptr); |
498 | 500 | ||
@@ -505,7 +507,7 @@ public sealed class BSPrim : BSPhysObject | |||
505 | // Set up the object physicalness (does gravity and collisions move this object) | 507 | // Set up the object physicalness (does gravity and collisions move this object) |
506 | MakeDynamic(IsStatic); | 508 | MakeDynamic(IsStatic); |
507 | 509 | ||
508 | // Arrange for collisions events if the simulator wants them | 510 | // Arrange for collision events if the simulator wants them |
509 | EnableCollisions(SubscribedEvents()); | 511 | EnableCollisions(SubscribedEvents()); |
510 | 512 | ||
511 | #if CSHARP_BODY_MANAGEMENT | 513 | #if CSHARP_BODY_MANAGEMENT |
@@ -522,8 +524,6 @@ public sealed class BSPrim : BSPhysObject | |||
522 | if (BSBody.collisionFilter != 0 || BSBody.collisionMask != 0) | 524 | if (BSBody.collisionFilter != 0 || BSBody.collisionMask != 0) |
523 | { | 525 | { |
524 | BulletSimAPI.SetCollisionFilterMask2(BSBody.ptr, (uint)BSBody.collisionFilter, (uint)BSBody.collisionMask); | 526 | BulletSimAPI.SetCollisionFilterMask2(BSBody.ptr, (uint)BSBody.collisionFilter, (uint)BSBody.collisionMask); |
525 | DetailLog("{0},BSPrim.UpdatePhysicalParameters,setCollisionFilterMask,filter={1},mask={2}", | ||
526 | LocalID, BSBody.collisionFilter.ToString("X"), BSBody.collisionMask.ToString("X")); | ||
527 | } | 527 | } |
528 | 528 | ||
529 | // Recompute any linkset parameters. | 529 | // Recompute any linkset parameters. |
@@ -557,8 +557,8 @@ public sealed class BSPrim : BSPhysObject | |||
557 | // There can be special things needed for implementing linksets | 557 | // There can be special things needed for implementing linksets |
558 | Linkset.MakeStatic(this); | 558 | Linkset.MakeStatic(this); |
559 | // The activation state is 'sleeping' so Bullet will not try to act on it | 559 | // The activation state is 'sleeping' so Bullet will not try to act on it |
560 | // BulletSimAPI.ForceActivationState2(BSBody.ptr, ActivationState.ISLAND_SLEEPING); | 560 | BulletSimAPI.ForceActivationState2(BSBody.ptr, ActivationState.ISLAND_SLEEPING); |
561 | BulletSimAPI.ForceActivationState2(BSBody.ptr, ActivationState.DISABLE_SIMULATION); | 561 | // BulletSimAPI.ForceActivationState2(BSBody.ptr, ActivationState.DISABLE_SIMULATION); |
562 | 562 | ||
563 | BSBody.collisionFilter = CollisionFilterGroups.StaticObjectFilter; | 563 | BSBody.collisionFilter = CollisionFilterGroups.StaticObjectFilter; |
564 | BSBody.collisionMask = CollisionFilterGroups.StaticObjectMask; | 564 | BSBody.collisionMask = CollisionFilterGroups.StaticObjectMask; |
@@ -571,16 +571,14 @@ public sealed class BSPrim : BSPhysObject | |||
571 | // Set various physical properties so internal dynamic properties will get computed correctly as they are set | 571 | // Set various physical properties so internal dynamic properties will get computed correctly as they are set |
572 | BulletSimAPI.SetFriction2(BSBody.ptr, PhysicsScene.Params.defaultFriction); | 572 | BulletSimAPI.SetFriction2(BSBody.ptr, PhysicsScene.Params.defaultFriction); |
573 | BulletSimAPI.SetRestitution2(BSBody.ptr, PhysicsScene.Params.defaultRestitution); | 573 | BulletSimAPI.SetRestitution2(BSBody.ptr, PhysicsScene.Params.defaultRestitution); |
574 | |||
574 | // per http://www.bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=3382 | 575 | // per http://www.bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=3382 |
575 | BulletSimAPI.SetInterpolationLinearVelocity2(BSBody.ptr, OMV.Vector3.Zero); | 576 | BulletSimAPI.ClearAllForces2(BSBody.ptr); |
576 | BulletSimAPI.SetInterpolationAngularVelocity2(BSBody.ptr, OMV.Vector3.Zero); | ||
577 | BulletSimAPI.SetInterpolationVelocity2(BSBody.ptr, OMV.Vector3.Zero, OMV.Vector3.Zero); | ||
578 | 577 | ||
579 | // A dynamic object has mass | 578 | // A dynamic object has mass |
580 | IntPtr collisionShapePtr = BulletSimAPI.GetCollisionShape2(BSBody.ptr); | 579 | IntPtr collisionShapePtr = BulletSimAPI.GetCollisionShape2(BSBody.ptr); |
581 | OMV.Vector3 inertia = BulletSimAPI.CalculateLocalInertia2(collisionShapePtr, Linkset.LinksetMass); | 580 | OMV.Vector3 inertia = BulletSimAPI.CalculateLocalInertia2(collisionShapePtr, Linkset.LinksetMass); |
582 | BulletSimAPI.SetMassProps2(BSBody.ptr, _mass, inertia); | 581 | BulletSimAPI.SetMassProps2(BSBody.ptr, _mass, inertia); |
583 | // Inertia is based on our new mass | ||
584 | BulletSimAPI.UpdateInertiaTensor2(BSBody.ptr); | 582 | BulletSimAPI.UpdateInertiaTensor2(BSBody.ptr); |
585 | 583 | ||
586 | // Various values for simulation limits | 584 | // Various values for simulation limits |
@@ -645,7 +643,7 @@ public sealed class BSPrim : BSPhysObject | |||
645 | 643 | ||
646 | // Create the new body with the shape | 644 | // Create the new body with the shape |
647 | BSBody = new BulletBody(LocalID, BulletSimAPI.CreateBodyFromShape2(PhysicsScene.World.Ptr, BSShape.Ptr, _position, _orientation)); | 645 | BSBody = new BulletBody(LocalID, BulletSimAPI.CreateBodyFromShape2(PhysicsScene.World.Ptr, BSShape.Ptr, _position, _orientation)); |
648 | BulletSimAPI.RemoveFromCollisionFlags2(BSBody.Ptr, CollisionFlags.CF_NO_CONTACT_RESPONSE); | 646 | CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(BSBody.Ptr, CollisionFlags.CF_NO_CONTACT_RESPONSE); |
649 | DetailLog("{0},BSPrim.MakeSolid:rigidBody,body={1},shape={2}", LocalID, BSBody, BSShape); | 647 | DetailLog("{0},BSPrim.MakeSolid:rigidBody,body={1},shape={2}", LocalID, BSBody, BSShape); |
650 | } | 648 | } |
651 | } | 649 | } |
@@ -741,7 +739,7 @@ public sealed class BSPrim : BSPhysObject | |||
741 | // m_log.DebugFormat("{0}: RotationalVelocity={1}", LogHeader, _rotationalVelocity); | 739 | // m_log.DebugFormat("{0}: RotationalVelocity={1}", LogHeader, _rotationalVelocity); |
742 | PhysicsScene.TaintedObject("BSPrim.setRotationalVelocity", delegate() | 740 | PhysicsScene.TaintedObject("BSPrim.setRotationalVelocity", delegate() |
743 | { | 741 | { |
744 | DetailLog("{0},BSPrim.SetRotationalVel,taint,rotvel={1}", LocalID, _rotationalVelocity); | 742 | // DetailLog("{0},BSPrim.SetRotationalVel,taint,rotvel={1}", LocalID, _rotationalVelocity); |
745 | BulletSimAPI.SetAngularVelocity2(BSBody.ptr, _rotationalVelocity); | 743 | BulletSimAPI.SetAngularVelocity2(BSBody.ptr, _rotationalVelocity); |
746 | }); | 744 | }); |
747 | } | 745 | } |
@@ -758,7 +756,7 @@ public sealed class BSPrim : BSPhysObject | |||
758 | _buoyancy = value; | 756 | _buoyancy = value; |
759 | PhysicsScene.TaintedObject("BSPrim.setBuoyancy", delegate() | 757 | PhysicsScene.TaintedObject("BSPrim.setBuoyancy", delegate() |
760 | { | 758 | { |
761 | DetailLog("{0},BSPrim.SetBuoyancy,taint,buoy={1}", LocalID, _buoyancy); | 759 | // DetailLog("{0},BSPrim.SetBuoyancy,taint,buoy={1}", LocalID, _buoyancy); |
762 | // Buoyancy is faked by changing the gravity applied to the object | 760 | // Buoyancy is faked by changing the gravity applied to the object |
763 | float grav = PhysicsScene.Params.gravity * (1f - _buoyancy); | 761 | float grav = PhysicsScene.Params.gravity * (1f - _buoyancy); |
764 | BulletSimAPI.SetGravity2(BSBody.ptr, new OMV.Vector3(0f, 0f, grav)); | 762 | BulletSimAPI.SetGravity2(BSBody.ptr, new OMV.Vector3(0f, 0f, grav)); |
@@ -823,18 +821,18 @@ public sealed class BSPrim : BSPhysObject | |||
823 | } | 821 | } |
824 | m_accumulatedForces.Clear(); | 822 | m_accumulatedForces.Clear(); |
825 | } | 823 | } |
826 | DetailLog("{0},BSPrim.AddObjectForce,taint,force={1}", LocalID, fSum); | 824 | // DetailLog("{0},BSPrim.AddObjectForce,taint,force={1}", LocalID, fSum); |
827 | // For unknown reasons, "ApplyCentralForce" adds this force to the total force on the object. | 825 | // For unknown reasons, "ApplyCentralForce" adds this force to the total force on the object. |
828 | BulletSimAPI.ApplyCentralForce2(BSBody.ptr, fSum); | 826 | BulletSimAPI.ApplyCentralForce2(BSBody.ptr, fSum); |
829 | }); | 827 | }); |
830 | } | 828 | } |
831 | 829 | ||
832 | public override void AddAngularForce(OMV.Vector3 force, bool pushforce) { | 830 | public override void AddAngularForce(OMV.Vector3 force, bool pushforce) { |
833 | DetailLog("{0},BSPrim.AddAngularForce,call,angForce={1},push={2}", LocalID, force, pushforce); | 831 | // DetailLog("{0},BSPrim.AddAngularForce,call,angForce={1},push={2}", LocalID, force, pushforce); |
834 | // m_log.DebugFormat("{0}: AddAngularForce. f={1}, push={2}", LogHeader, force, pushforce); | 832 | // m_log.DebugFormat("{0}: AddAngularForce. f={1}, push={2}", LogHeader, force, pushforce); |
835 | } | 833 | } |
836 | public override void SetMomentum(OMV.Vector3 momentum) { | 834 | public override void SetMomentum(OMV.Vector3 momentum) { |
837 | DetailLog("{0},BSPrim.SetMomentum,call,mom={1}", LocalID, momentum); | 835 | // DetailLog("{0},BSPrim.SetMomentum,call,mom={1}", LocalID, momentum); |
838 | } | 836 | } |
839 | #region Mass Calculation | 837 | #region Mass Calculation |
840 | 838 | ||
@@ -1452,7 +1450,7 @@ public sealed class BSPrim : BSPhysObject | |||
1452 | } | 1450 | } |
1453 | // Rebuild the geometry and object. | 1451 | // Rebuild the geometry and object. |
1454 | // This is called when the shape changes so we need to recreate the mesh/hull. | 1452 | // This is called when the shape changes so we need to recreate the mesh/hull. |
1455 | // No locking here because this is done when the physics engine is not simulating (taint-time). | 1453 | // Called at taint-time!!! |
1456 | private void CreateGeomAndObject(bool forceRebuild) | 1454 | private void CreateGeomAndObject(bool forceRebuild) |
1457 | { | 1455 | { |
1458 | #if CSHARP_BODY_MANAGEMENT | 1456 | #if CSHARP_BODY_MANAGEMENT |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs index 7fce8c9..aadb8d6 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs | |||
@@ -344,7 +344,10 @@ public class BSShapeCollection : IDisposable | |||
344 | if (pbs.ProfileShape == ProfileShape.HalfCircle && pbs.PathCurve == (byte)Extrusion.Curve1) | 344 | if (pbs.ProfileShape == ProfileShape.HalfCircle && pbs.PathCurve == (byte)Extrusion.Curve1) |
345 | { | 345 | { |
346 | haveShape = true; | 346 | haveShape = true; |
347 | if (forceRebuild || (prim.BSShape.type != ShapeData.PhysicsShapeType.SHAPE_SPHERE)) | 347 | if (forceRebuild |
348 | || prim.Scale != shapeData.Size | ||
349 | || prim.BSShape.type != ShapeData.PhysicsShapeType.SHAPE_SPHERE | ||
350 | ) | ||
348 | { | 351 | { |
349 | ret = GetReferenceToNativeShape(prim, shapeData, | 352 | ret = GetReferenceToNativeShape(prim, shapeData, |
350 | ShapeData.PhysicsShapeType.SHAPE_SPHERE, ShapeData.FixedShapeKey.KEY_SPHERE); | 353 | ShapeData.PhysicsShapeType.SHAPE_SPHERE, ShapeData.FixedShapeKey.KEY_SPHERE); |
@@ -355,7 +358,10 @@ public class BSShapeCollection : IDisposable | |||
355 | else | 358 | else |
356 | { | 359 | { |
357 | haveShape = true; | 360 | haveShape = true; |
358 | if (forceRebuild || (prim.BSShape.type != ShapeData.PhysicsShapeType.SHAPE_BOX)) | 361 | if (forceRebuild |
362 | || prim.Scale != shapeData.Size | ||
363 | || prim.BSShape.type != ShapeData.PhysicsShapeType.SHAPE_BOX | ||
364 | ) | ||
359 | { | 365 | { |
360 | ret = GetReferenceToNativeShape( | 366 | ret = GetReferenceToNativeShape( |
361 | prim, shapeData, ShapeData.PhysicsShapeType.SHAPE_BOX, ShapeData.FixedShapeKey.KEY_BOX); | 367 | prim, shapeData, ShapeData.PhysicsShapeType.SHAPE_BOX, ShapeData.FixedShapeKey.KEY_BOX); |
@@ -406,7 +412,7 @@ public class BSShapeCollection : IDisposable | |||
406 | newShape.isNativeShape = true; | 412 | newShape.isNativeShape = true; |
407 | 413 | ||
408 | // Don't need to do a 'ReferenceShape()' here because native shapes are not tracked. | 414 | // Don't need to do a 'ReferenceShape()' here because native shapes are not tracked. |
409 | DetailLog("{0},BSShapeCollection.AddNativeShapeToPrim,create,newshape={1}", shapeData.ID, newShape); | 415 | // DetailLog("{0},BSShapeCollection.AddNativeShapeToPrim,create,newshape={1}", shapeData.ID, newShape); |
410 | 416 | ||
411 | prim.BSShape = newShape; | 417 | prim.BSShape = newShape; |
412 | return true; | 418 | return true; |
@@ -683,13 +689,13 @@ public class BSShapeCollection : IDisposable | |||
683 | { | 689 | { |
684 | bodyPtr = BulletSimAPI.CreateBodyFromShape2(sim.ptr, shape.ptr, | 690 | bodyPtr = BulletSimAPI.CreateBodyFromShape2(sim.ptr, shape.ptr, |
685 | shapeData.ID, shapeData.Position, shapeData.Rotation); | 691 | shapeData.ID, shapeData.Position, shapeData.Rotation); |
686 | DetailLog("{0},BSShapeCollection.CreateBody,mesh,ptr={1}", prim.LocalID, bodyPtr.ToString("X")); | 692 | // DetailLog("{0},BSShapeCollection.CreateBody,mesh,ptr={1}", prim.LocalID, bodyPtr.ToString("X")); |
687 | } | 693 | } |
688 | else | 694 | else |
689 | { | 695 | { |
690 | bodyPtr = BulletSimAPI.CreateGhostFromShape2(sim.ptr, shape.ptr, | 696 | bodyPtr = BulletSimAPI.CreateGhostFromShape2(sim.ptr, shape.ptr, |
691 | shapeData.ID, shapeData.Position, shapeData.Rotation); | 697 | shapeData.ID, shapeData.Position, shapeData.Rotation); |
692 | DetailLog("{0},BSShapeCollection.CreateBody,ghost,ptr={1}", prim.LocalID, bodyPtr.ToString("X")); | 698 | // DetailLog("{0},BSShapeCollection.CreateBody,ghost,ptr={1}", prim.LocalID, bodyPtr.ToString("X")); |
693 | } | 699 | } |
694 | aBody = new BulletBody(shapeData.ID, bodyPtr); | 700 | aBody = new BulletBody(shapeData.ID, bodyPtr); |
695 | 701 | ||
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs index 5d5d9cb..50638d6 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs | |||
@@ -201,10 +201,10 @@ public class BSTerrainManager | |||
201 | // The 'doNow' boolean says whether to do all the unmanaged activities right now (like when | 201 | // The 'doNow' boolean says whether to do all the unmanaged activities right now (like when |
202 | // calling this routine from initialization or taint-time routines) or whether to delay | 202 | // calling this routine from initialization or taint-time routines) or whether to delay |
203 | // all the unmanaged activities to taint-time. | 203 | // all the unmanaged activities to taint-time. |
204 | private void UpdateOrCreateTerrain(uint id, float[] heightMap, Vector3 minCoords, Vector3 maxCoords, bool doNow) | 204 | private void UpdateOrCreateTerrain(uint id, float[] heightMap, Vector3 minCoords, Vector3 maxCoords, bool atTaintTime) |
205 | { | 205 | { |
206 | DetailLog("{0},BSTerrainManager.UpdateOrCreateTerrain,call,minC={1},maxC={2},doNow={3}", | 206 | DetailLog("{0},BSTerrainManager.UpdateOrCreateTerrain,call,minC={1},maxC={2},atTaintTime={3}", |
207 | BSScene.DetailLogZero, minCoords, maxCoords, doNow); | 207 | BSScene.DetailLogZero, minCoords, maxCoords, atTaintTime); |
208 | 208 | ||
209 | float minZ = float.MaxValue; | 209 | float minZ = float.MaxValue; |
210 | float maxZ = float.MinValue; | 210 | float maxZ = float.MinValue; |
@@ -308,11 +308,7 @@ public class BSTerrainManager | |||
308 | 308 | ||
309 | mapInfo.terrainBody = new BulletBody(mapInfo.ID, | 309 | mapInfo.terrainBody = new BulletBody(mapInfo.ID, |
310 | BulletSimAPI.CreateBodyWithDefaultMotionState2(mapInfo.terrainShape.ptr, | 310 | BulletSimAPI.CreateBodyWithDefaultMotionState2(mapInfo.terrainShape.ptr, |
311 | id, centerPos, Quaternion.Identity)); | 311 | id, centerPos, Quaternion.Identity)); |
312 | |||
313 | BulletSimAPI.SetCollisionFilterMask2(mapInfo.terrainBody.ptr, | ||
314 | (uint)CollisionFilterGroups.TerrainFilter, | ||
315 | (uint)CollisionFilterGroups.TerrainMask); | ||
316 | } | 312 | } |
317 | 313 | ||
318 | // Make sure the entry is in the heightmap table | 314 | // Make sure the entry is in the heightmap table |
@@ -333,6 +329,10 @@ public class BSTerrainManager | |||
333 | // redo its bounding box now that it is in the world | 329 | // redo its bounding box now that it is in the world |
334 | BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, mapInfo.terrainBody.ptr); | 330 | BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, mapInfo.terrainBody.ptr); |
335 | 331 | ||
332 | BulletSimAPI.SetCollisionFilterMask2(mapInfo.terrainBody.ptr, | ||
333 | (uint)CollisionFilterGroups.TerrainFilter, | ||
334 | (uint)CollisionFilterGroups.TerrainMask); | ||
335 | |||
336 | // Make sure the new shape is processed. | 336 | // Make sure the new shape is processed. |
337 | BulletSimAPI.Activate2(mapInfo.terrainBody.ptr, true); | 337 | BulletSimAPI.Activate2(mapInfo.terrainBody.ptr, true); |
338 | 338 | ||
@@ -341,7 +341,7 @@ public class BSTerrainManager | |||
341 | 341 | ||
342 | // There is the option to do the changes now (we're already in 'taint time'), or | 342 | // There is the option to do the changes now (we're already in 'taint time'), or |
343 | // to do the Bullet operations later. | 343 | // to do the Bullet operations later. |
344 | if (doNow) | 344 | if (atTaintTime) |
345 | rebuildOperation(); | 345 | rebuildOperation(); |
346 | else | 346 | else |
347 | PhysicsScene.TaintedObject("BSScene.UpdateOrCreateTerrain:UpdateExisting", rebuildOperation); | 347 | PhysicsScene.TaintedObject("BSScene.UpdateOrCreateTerrain:UpdateExisting", rebuildOperation); |
@@ -380,7 +380,7 @@ public class BSTerrainManager | |||
380 | }; | 380 | }; |
381 | 381 | ||
382 | // If already in taint-time, just call Bullet. Otherwise queue the operations for the safe time. | 382 | // If already in taint-time, just call Bullet. Otherwise queue the operations for the safe time. |
383 | if (doNow) | 383 | if (atTaintTime) |
384 | createOperation(); | 384 | createOperation(); |
385 | else | 385 | else |
386 | PhysicsScene.TaintedObject("BSScene.UpdateOrCreateTerrain:NewTerrain", createOperation); | 386 | PhysicsScene.TaintedObject("BSScene.UpdateOrCreateTerrain:NewTerrain", createOperation); |