diff options
author | Robert Adams | 2013-01-25 10:17:20 -0800 |
---|---|---|
committer | Robert Adams | 2013-01-27 12:50:04 -0800 |
commit | c44a8e9f925c0195c4754c5e763af06dae657b53 (patch) | |
tree | 36bf371e99fb977be94c40a8d6998aaa5180a03c | |
parent | Prevent items being destroyed by rename operations. Renaming of a wearable also (diff) | |
download | opensim-SC_OLD-c44a8e9f925c0195c4754c5e763af06dae657b53.zip opensim-SC_OLD-c44a8e9f925c0195c4754c5e763af06dae657b53.tar.gz opensim-SC_OLD-c44a8e9f925c0195c4754c5e763af06dae657b53.tar.bz2 opensim-SC_OLD-c44a8e9f925c0195c4754c5e763af06dae657b53.tar.xz |
BulletSim: finish the post step event for physical object actions. Modify vehicle to use post step event for logging.
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | 14 | ||||
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs | 66 | ||||
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 6 |
3 files changed, 73 insertions, 13 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index 7ad7c89..a369c1f 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | |||
@@ -583,6 +583,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
583 | 583 | ||
584 | // Some of the properties of this prim may have changed. | 584 | // Some of the properties of this prim may have changed. |
585 | // Do any updating needed for a vehicle | 585 | // Do any updating needed for a vehicle |
586 | Vector3 m_physicsLinearFactor = new Vector3(0.2f, 0.2f, 0.2f); // DEBUG DEBUG | ||
587 | Vector3 m_physicsAngularFactor = new Vector3(0.2f, 0.2f, 0.2f); // DEBUG DEBUG | ||
586 | public void Refresh() | 588 | public void Refresh() |
587 | { | 589 | { |
588 | if (IsActive) | 590 | if (IsActive) |
@@ -599,6 +601,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
599 | // Maybe compute linear and angular factor and damping from params. | 601 | // Maybe compute linear and angular factor and damping from params. |
600 | float angularDamping = BSParam.VehicleAngularDamping; | 602 | float angularDamping = BSParam.VehicleAngularDamping; |
601 | PhysicsScene.PE.SetAngularDamping(Prim.PhysBody, angularDamping); | 603 | PhysicsScene.PE.SetAngularDamping(Prim.PhysBody, angularDamping); |
604 | PhysicsScene.PE.SetLinearFactor(Prim.PhysBody, m_physicsLinearFactor); // DEBUG DEBUG | ||
605 | PhysicsScene.PE.SetAngularFactorV(Prim.PhysBody, m_physicsAngularFactor); // DEBUG DEBUG | ||
602 | 606 | ||
603 | // Vehicles report collision events so we know when it's on the ground | 607 | // Vehicles report collision events so we know when it's on the ground |
604 | PhysicsScene.PE.AddToCollisionFlags(Prim.PhysBody, CollisionFlags.BS_VEHICLE_COLLISIONS); | 608 | PhysicsScene.PE.AddToCollisionFlags(Prim.PhysBody, CollisionFlags.BS_VEHICLE_COLLISIONS); |
@@ -898,9 +902,6 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
898 | { | 902 | { |
899 | if (!IsActive) return; | 903 | if (!IsActive) return; |
900 | 904 | ||
901 | if (PhysicsScene.VehiclePhysicalLoggingEnabled) | ||
902 | PhysicsScene.PE.DumpRigidBody(PhysicsScene.World, Prim.PhysBody); | ||
903 | |||
904 | ForgetKnownVehicleProperties(); | 905 | ForgetKnownVehicleProperties(); |
905 | 906 | ||
906 | MoveLinear(pTimestep); | 907 | MoveLinear(pTimestep); |
@@ -922,6 +923,13 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
922 | Prim.LocalID, VehiclePosition, m_knownForce, VehicleVelocity, VehicleRotationalVelocity); | 923 | Prim.LocalID, VehiclePosition, m_knownForce, VehicleVelocity, VehicleRotationalVelocity); |
923 | } | 924 | } |
924 | 925 | ||
926 | // Called after the simulation step | ||
927 | internal void PostStep(float pTimestep) | ||
928 | { | ||
929 | if (PhysicsScene.VehiclePhysicalLoggingEnabled) | ||
930 | PhysicsScene.PE.DumpRigidBody(PhysicsScene.World, Prim.PhysBody); | ||
931 | } | ||
932 | |||
925 | // Apply the effect of the linear motor and other linear motions (like hover and float). | 933 | // Apply the effect of the linear motor and other linear motions (like hover and float). |
926 | private void MoveLinear(float pTimestep) | 934 | private void MoveLinear(float pTimestep) |
927 | { | 935 | { |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs index 027c786..285d4a2 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs | |||
@@ -101,6 +101,7 @@ public abstract class BSPhysObject : PhysicsActor | |||
101 | public virtual void Destroy() | 101 | public virtual void Destroy() |
102 | { | 102 | { |
103 | UnRegisterAllPreStepActions(); | 103 | UnRegisterAllPreStepActions(); |
104 | UnRegisterAllPostStepActions(); | ||
104 | } | 105 | } |
105 | 106 | ||
106 | public BSScene PhysicsScene { get; protected set; } | 107 | public BSScene PhysicsScene { get; protected set; } |
@@ -393,17 +394,18 @@ public abstract class BSPhysObject : PhysicsActor | |||
393 | // These actions are optional so, rather than scanning all the physical objects and asking them | 394 | // These actions are optional so, rather than scanning all the physical objects and asking them |
394 | // if they have anything to do, a physical object registers for an event call before the step is performed. | 395 | // if they have anything to do, a physical object registers for an event call before the step is performed. |
395 | // This bookkeeping makes it easy to add, remove and clean up after all these registrations. | 396 | // This bookkeeping makes it easy to add, remove and clean up after all these registrations. |
396 | private Dictionary<string, BSScene.PreStepAction> RegisteredActions = new Dictionary<string, BSScene.PreStepAction>(); | 397 | private Dictionary<string, BSScene.PreStepAction> RegisteredPrestepActions = new Dictionary<string, BSScene.PreStepAction>(); |
398 | private Dictionary<string, BSScene.PostStepAction> RegisteredPoststepActions = new Dictionary<string, BSScene.PostStepAction>(); | ||
397 | protected void RegisterPreStepAction(string op, uint id, BSScene.PreStepAction actn) | 399 | protected void RegisterPreStepAction(string op, uint id, BSScene.PreStepAction actn) |
398 | { | 400 | { |
399 | string identifier = op + "-" + id.ToString(); | 401 | string identifier = op + "-" + id.ToString(); |
400 | 402 | ||
401 | lock (RegisteredActions) | 403 | lock (RegisteredPrestepActions) |
402 | { | 404 | { |
403 | // Clean out any existing action | 405 | // Clean out any existing action |
404 | UnRegisterPreStepAction(op, id); | 406 | UnRegisterPreStepAction(op, id); |
405 | 407 | ||
406 | RegisteredActions[identifier] = actn; | 408 | RegisteredPrestepActions[identifier] = actn; |
407 | } | 409 | } |
408 | PhysicsScene.BeforeStep += actn; | 410 | PhysicsScene.BeforeStep += actn; |
409 | DetailLog("{0},BSPhysObject.RegisterPreStepAction,id={1}", LocalID, identifier); | 411 | DetailLog("{0},BSPhysObject.RegisterPreStepAction,id={1}", LocalID, identifier); |
@@ -414,12 +416,12 @@ public abstract class BSPhysObject : PhysicsActor | |||
414 | { | 416 | { |
415 | string identifier = op + "-" + id.ToString(); | 417 | string identifier = op + "-" + id.ToString(); |
416 | bool removed = false; | 418 | bool removed = false; |
417 | lock (RegisteredActions) | 419 | lock (RegisteredPrestepActions) |
418 | { | 420 | { |
419 | if (RegisteredActions.ContainsKey(identifier)) | 421 | if (RegisteredPrestepActions.ContainsKey(identifier)) |
420 | { | 422 | { |
421 | PhysicsScene.BeforeStep -= RegisteredActions[identifier]; | 423 | PhysicsScene.BeforeStep -= RegisteredPrestepActions[identifier]; |
422 | RegisteredActions.Remove(identifier); | 424 | RegisteredPrestepActions.Remove(identifier); |
423 | removed = true; | 425 | removed = true; |
424 | } | 426 | } |
425 | } | 427 | } |
@@ -428,17 +430,61 @@ public abstract class BSPhysObject : PhysicsActor | |||
428 | 430 | ||
429 | protected void UnRegisterAllPreStepActions() | 431 | protected void UnRegisterAllPreStepActions() |
430 | { | 432 | { |
431 | lock (RegisteredActions) | 433 | lock (RegisteredPrestepActions) |
432 | { | 434 | { |
433 | foreach (KeyValuePair<string, BSScene.PreStepAction> kvp in RegisteredActions) | 435 | foreach (KeyValuePair<string, BSScene.PreStepAction> kvp in RegisteredPrestepActions) |
434 | { | 436 | { |
435 | PhysicsScene.BeforeStep -= kvp.Value; | 437 | PhysicsScene.BeforeStep -= kvp.Value; |
436 | } | 438 | } |
437 | RegisteredActions.Clear(); | 439 | RegisteredPrestepActions.Clear(); |
438 | } | 440 | } |
439 | DetailLog("{0},BSPhysObject.UnRegisterAllPreStepActions,", LocalID); | 441 | DetailLog("{0},BSPhysObject.UnRegisterAllPreStepActions,", LocalID); |
440 | } | 442 | } |
443 | |||
444 | protected void RegisterPostStepAction(string op, uint id, BSScene.PostStepAction actn) | ||
445 | { | ||
446 | string identifier = op + "-" + id.ToString(); | ||
447 | |||
448 | lock (RegisteredPoststepActions) | ||
449 | { | ||
450 | // Clean out any existing action | ||
451 | UnRegisterPostStepAction(op, id); | ||
452 | |||
453 | RegisteredPoststepActions[identifier] = actn; | ||
454 | } | ||
455 | PhysicsScene.AfterStep += actn; | ||
456 | DetailLog("{0},BSPhysObject.RegisterPostStepAction,id={1}", LocalID, identifier); | ||
457 | } | ||
458 | |||
459 | // Unregister a pre step action. Safe to call if the action has not been registered. | ||
460 | protected void UnRegisterPostStepAction(string op, uint id) | ||
461 | { | ||
462 | string identifier = op + "-" + id.ToString(); | ||
463 | bool removed = false; | ||
464 | lock (RegisteredPoststepActions) | ||
465 | { | ||
466 | if (RegisteredPoststepActions.ContainsKey(identifier)) | ||
467 | { | ||
468 | PhysicsScene.AfterStep -= RegisteredPoststepActions[identifier]; | ||
469 | RegisteredPoststepActions.Remove(identifier); | ||
470 | removed = true; | ||
471 | } | ||
472 | } | ||
473 | DetailLog("{0},BSPhysObject.UnRegisterPostStepAction,id={1},removed={2}", LocalID, identifier, removed); | ||
474 | } | ||
441 | 475 | ||
476 | protected void UnRegisterAllPostStepActions() | ||
477 | { | ||
478 | lock (RegisteredPoststepActions) | ||
479 | { | ||
480 | foreach (KeyValuePair<string, BSScene.PostStepAction> kvp in RegisteredPoststepActions) | ||
481 | { | ||
482 | PhysicsScene.AfterStep -= kvp.Value; | ||
483 | } | ||
484 | RegisteredPoststepActions.Clear(); | ||
485 | } | ||
486 | DetailLog("{0},BSPhysObject.UnRegisterAllPostStepActions,", LocalID); | ||
487 | } | ||
442 | 488 | ||
443 | #endregion // Per Simulation Step actions | 489 | #endregion // Per Simulation Step actions |
444 | 490 | ||
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 8b00a33..99903f5 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |||
@@ -527,9 +527,15 @@ public sealed class BSPrim : BSPhysObject | |||
527 | 527 | ||
528 | // If an active vehicle, register the vehicle code to be called before each step | 528 | // If an active vehicle, register the vehicle code to be called before each step |
529 | if (_vehicle.Type == Vehicle.TYPE_NONE) | 529 | if (_vehicle.Type == Vehicle.TYPE_NONE) |
530 | { | ||
530 | UnRegisterPreStepAction("BSPrim.Vehicle", LocalID); | 531 | UnRegisterPreStepAction("BSPrim.Vehicle", LocalID); |
532 | PhysicsScene.AfterStep -= _vehicle.PostStep; | ||
533 | } | ||
531 | else | 534 | else |
535 | { | ||
532 | RegisterPreStepAction("BSPrim.Vehicle", LocalID, _vehicle.Step); | 536 | RegisterPreStepAction("BSPrim.Vehicle", LocalID, _vehicle.Step); |
537 | PhysicsScene.AfterStep += _vehicle.PostStep; | ||
538 | } | ||
533 | }); | 539 | }); |
534 | } | 540 | } |
535 | } | 541 | } |