diff options
Merge branch 'ubitwork' of ssh://3dhosting.de/var/git/careminster into ubitwork
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPart.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 174 |
1 files changed, 124 insertions, 50 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index f7edd31..11d6b57 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -123,11 +123,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
123 | /// </value> | 123 | /// </value> |
124 | public const int ALL_SIDES = -1; | 124 | public const int ALL_SIDES = -1; |
125 | 125 | ||
126 | private const scriptEvents PhyscicsNeededSubsEvents = ( | 126 | private const scriptEvents PhysicsNeededSubsEvents = ( |
127 | scriptEvents.collision | scriptEvents.collision_start | scriptEvents.collision_end | | 127 | scriptEvents.collision | scriptEvents.collision_start | scriptEvents.collision_end | |
128 | scriptEvents.land_collision | scriptEvents.land_collision_start | scriptEvents.land_collision_end | 128 | scriptEvents.land_collision | scriptEvents.land_collision_start | scriptEvents.land_collision_end |
129 | ); | 129 | ); |
130 | 130 | private const scriptEvents PhyscicsPhantonSubsEvents = ( | |
131 | scriptEvents.land_collision | scriptEvents.land_collision_start | scriptEvents.land_collision_end | ||
132 | ); | ||
133 | private const scriptEvents PhyscicsVolumeDtcSubsEvents = ( | ||
134 | scriptEvents.collision_start | scriptEvents.collision_end | ||
135 | ); | ||
136 | |||
131 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 137 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
132 | 138 | ||
133 | /// <value> | 139 | /// <value> |
@@ -1882,7 +1888,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1882 | { | 1888 | { |
1883 | if ((!isPhantom || isPhysical || _VolumeDetectActive) && !ParentGroup.IsAttachment | 1889 | if ((!isPhantom || isPhysical || _VolumeDetectActive) && !ParentGroup.IsAttachment |
1884 | && !(Shape.PathCurve == (byte)Extrusion.Flexible)) | 1890 | && !(Shape.PathCurve == (byte)Extrusion.Flexible)) |
1891 | { | ||
1885 | AddToPhysics(isPhysical, isPhantom, building, isPhysical); | 1892 | AddToPhysics(isPhysical, isPhantom, building, isPhysical); |
1893 | UpdatePhysicsSubscribedEvents(); // not sure if appliable here | ||
1894 | } | ||
1886 | else | 1895 | else |
1887 | PhysActor = null; // just to be sure | 1896 | PhysActor = null; // just to be sure |
1888 | } | 1897 | } |
@@ -1975,6 +1984,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1975 | 1984 | ||
1976 | bool UsePhysics = ((dupe.Flags & PrimFlags.Physics) != 0); | 1985 | bool UsePhysics = ((dupe.Flags & PrimFlags.Physics) != 0); |
1977 | dupe.DoPhysicsPropertyUpdate(UsePhysics, true); | 1986 | dupe.DoPhysicsPropertyUpdate(UsePhysics, true); |
1987 | // dupe.UpdatePhysicsSubscribedEvents(); // not sure... | ||
1978 | } | 1988 | } |
1979 | 1989 | ||
1980 | if (dupe.PhysActor != null) | 1990 | if (dupe.PhysActor != null) |
@@ -2564,7 +2574,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2564 | } | 2574 | } |
2565 | else | 2575 | else |
2566 | { | 2576 | { |
2567 | if ((ParentGroup.RootPart.ScriptEvents & scriptEvents.collision_start) != 0) | 2577 | if ((ParentGroup.RootPart.ScriptEvents & ev) != 0) |
2568 | sendToRoot = true; | 2578 | sendToRoot = true; |
2569 | } | 2579 | } |
2570 | if (sendToRoot && ParentGroup.RootPart != this) | 2580 | if (sendToRoot && ParentGroup.RootPart != this) |
@@ -2602,45 +2612,58 @@ namespace OpenSim.Region.Framework.Scenes | |||
2602 | List<uint> endedColliders = new List<uint>(); | 2612 | List<uint> endedColliders = new List<uint>(); |
2603 | List<uint> startedColliders = new List<uint>(); | 2613 | List<uint> startedColliders = new List<uint>(); |
2604 | 2614 | ||
2605 | // calculate things that started colliding this time | 2615 | if (collissionswith.Count == 0) |
2606 | // and build up list of colliders this time | ||
2607 | foreach (uint localid in collissionswith.Keys) | ||
2608 | { | 2616 | { |
2609 | thisHitColliders.Add(localid); | 2617 | if (m_lastColliders.Count == 0) |
2610 | if (!m_lastColliders.Contains(localid)) | 2618 | return; // nothing to do |
2611 | startedColliders.Add(localid); | ||
2612 | } | ||
2613 | 2619 | ||
2614 | // calculate things that ended colliding | 2620 | foreach (uint localID in m_lastColliders) |
2615 | foreach (uint localID in m_lastColliders) | 2621 | { |
2616 | { | ||
2617 | if (!thisHitColliders.Contains(localID)) | ||
2618 | endedColliders.Add(localID); | 2622 | endedColliders.Add(localID); |
2623 | } | ||
2624 | m_lastColliders.Clear(); | ||
2619 | } | 2625 | } |
2620 | 2626 | ||
2621 | //add the items that started colliding this time to the last colliders list. | 2627 | else |
2622 | foreach (uint localID in startedColliders) | 2628 | { |
2623 | m_lastColliders.Add(localID); | ||
2624 | 2629 | ||
2625 | // remove things that ended colliding from the last colliders list | 2630 | // calculate things that started colliding this time |
2626 | foreach (uint localID in endedColliders) | 2631 | // and build up list of colliders this time |
2627 | m_lastColliders.Remove(localID); | 2632 | foreach (uint localid in collissionswith.Keys) |
2633 | { | ||
2634 | thisHitColliders.Add(localid); | ||
2635 | if (!m_lastColliders.Contains(localid)) | ||
2636 | startedColliders.Add(localid); | ||
2637 | } | ||
2628 | 2638 | ||
2639 | // calculate things that ended colliding | ||
2640 | foreach (uint localID in m_lastColliders) | ||
2641 | { | ||
2642 | if (!thisHitColliders.Contains(localID)) | ||
2643 | endedColliders.Add(localID); | ||
2644 | } | ||
2645 | |||
2646 | //add the items that started colliding this time to the last colliders list. | ||
2647 | foreach (uint localID in startedColliders) | ||
2648 | m_lastColliders.Add(localID); | ||
2649 | |||
2650 | // remove things that ended colliding from the last colliders list | ||
2651 | foreach (uint localID in endedColliders) | ||
2652 | m_lastColliders.Remove(localID); | ||
2653 | } | ||
2629 | // play the sound. | 2654 | // play the sound. |
2630 | if (startedColliders.Count > 0 && CollisionSound != UUID.Zero && CollisionSoundVolume > 0.0f) | 2655 | if (startedColliders.Count > 0 && CollisionSound != UUID.Zero && CollisionSoundVolume > 0.0f) |
2631 | SendSound(CollisionSound.ToString(), CollisionSoundVolume, true, (byte)0, 0, false, false); | 2656 | SendSound(CollisionSound.ToString(), CollisionSoundVolume, true, (byte)0, 0, false, false); |
2632 | 2657 | ||
2633 | SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); | 2658 | SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); |
2634 | SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding); | 2659 | if(!ParentGroup.RootPart.VolumeDetectActive) |
2660 | SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding); | ||
2635 | SendCollisionEvent(scriptEvents.collision_end , endedColliders , ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd); | 2661 | SendCollisionEvent(scriptEvents.collision_end , endedColliders , ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd); |
2636 | 2662 | ||
2637 | if (startedColliders.Contains(0)) | 2663 | if (startedColliders.Contains(0)) |
2638 | { | 2664 | SendLandCollisionEvent(scriptEvents.land_collision_start, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingStart); |
2639 | if (m_lastColliders.Contains(0)) | 2665 | if (m_lastColliders.Contains(0)) |
2640 | SendLandCollisionEvent(scriptEvents.land_collision, ParentGroup.Scene.EventManager.TriggerScriptLandColliding); | 2666 | SendLandCollisionEvent(scriptEvents.land_collision, ParentGroup.Scene.EventManager.TriggerScriptLandColliding); |
2641 | else | ||
2642 | SendLandCollisionEvent(scriptEvents.land_collision_start, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingStart); | ||
2643 | } | ||
2644 | if (endedColliders.Contains(0)) | 2667 | if (endedColliders.Contains(0)) |
2645 | SendLandCollisionEvent(scriptEvents.land_collision_end, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingEnd); | 2668 | SendLandCollisionEvent(scriptEvents.land_collision_end, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingEnd); |
2646 | } | 2669 | } |
@@ -4382,26 +4405,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
4382 | { | 4405 | { |
4383 | if (pa == null) | 4406 | if (pa == null) |
4384 | { | 4407 | { |
4385 | AddToPhysics(UsePhysics, SetPhantom, building , false); | 4408 | AddToPhysics(UsePhysics, SetPhantom, building, false); |
4386 | pa = PhysActor; | 4409 | pa = PhysActor; |
4387 | 4410 | /* | |
4388 | if (pa != null) | 4411 | if (pa != null) |
4389 | { | 4412 | { |
4390 | if ( | 4413 | if ( |
4391 | // ((AggregateScriptEvents & scriptEvents.collision) != 0) || | 4414 | // ((AggregateScriptEvents & scriptEvents.collision) != 0) || |
4392 | // ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || | 4415 | // ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || |
4393 | // ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || | 4416 | // ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || |
4394 | // ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | 4417 | // ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || |
4395 | // ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || | 4418 | // ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || |
4396 | // ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | 4419 | // ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || |
4397 | ((AggregateScriptEvents & PhyscicsNeededSubsEvents) != 0) || ((ParentGroup.RootPart.AggregateScriptEvents & PhyscicsNeededSubsEvents) != 0) || (CollisionSound != UUID.Zero) | 4420 | ((AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || |
4398 | // (CollisionSound != UUID.Zero) | 4421 | ((ParentGroup.RootPart.AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || |
4399 | ) | 4422 | (CollisionSound != UUID.Zero) |
4400 | { | 4423 | ) |
4401 | pa.OnCollisionUpdate += PhysicsCollision; | 4424 | { |
4402 | pa.SubscribeEvents(1000); | 4425 | pa.OnCollisionUpdate += PhysicsCollision; |
4403 | } | 4426 | pa.SubscribeEvents(1000); |
4404 | } | 4427 | } |
4428 | } | ||
4429 | */ | ||
4405 | } | 4430 | } |
4406 | 4431 | ||
4407 | else // it already has a physical representation | 4432 | else // it already has a physical representation |
@@ -4413,9 +4438,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
4413 | else | 4438 | else |
4414 | pa.SetVolumeDetect(0); | 4439 | pa.SetVolumeDetect(0); |
4415 | */ | 4440 | */ |
4441 | |||
4442 | |||
4416 | if (pa.Building != building) | 4443 | if (pa.Building != building) |
4417 | pa.Building = building; | 4444 | pa.Building = building; |
4418 | } | 4445 | } |
4446 | |||
4447 | UpdatePhysicsSubscribedEvents(); | ||
4419 | } | 4448 | } |
4420 | } | 4449 | } |
4421 | 4450 | ||
@@ -4538,8 +4567,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4538 | /// </summary> | 4567 | /// </summary> |
4539 | /// <remarks> | 4568 | /// <remarks> |
4540 | /// This isn't the same as turning off physical, since even without being physical the prim has a physics | 4569 | /// This isn't the same as turning off physical, since even without being physical the prim has a physics |
4541 | /// representation for collision detection. Rather, this would be used in situations such as making a prim | 4570 | /// representation for collision detection. |
4542 | /// phantom. | ||
4543 | /// </remarks> | 4571 | /// </remarks> |
4544 | public void RemoveFromPhysics() | 4572 | public void RemoveFromPhysics() |
4545 | { | 4573 | { |
@@ -4703,8 +4731,51 @@ namespace OpenSim.Region.Framework.Scenes | |||
4703 | ScheduleFullUpdate(); | 4731 | ScheduleFullUpdate(); |
4704 | } | 4732 | } |
4705 | 4733 | ||
4734 | |||
4735 | private void UpdatePhysicsSubscribedEvents() | ||
4736 | { | ||
4737 | PhysicsActor pa = PhysActor; | ||
4738 | if (pa == null) | ||
4739 | return; | ||
4740 | |||
4741 | pa.OnCollisionUpdate -= PhysicsCollision; | ||
4742 | |||
4743 | bool hassound = ( CollisionSound != UUID.Zero && CollisionSoundVolume > 0.0f); | ||
4744 | scriptEvents CombinedEvents = AggregateScriptEvents; | ||
4745 | |||
4746 | // merge with root part | ||
4747 | if (ParentGroup != null && ParentGroup.RootPart != null) | ||
4748 | CombinedEvents |= ParentGroup.RootPart.AggregateScriptEvents; | ||
4749 | |||
4750 | // submit to this part case | ||
4751 | if (VolumeDetectActive) | ||
4752 | { | ||
4753 | CombinedEvents &= PhyscicsVolumeDtcSubsEvents; | ||
4754 | hassound = false; | ||
4755 | } | ||
4756 | else if ((Flags & PrimFlags.Phantom) != 0) | ||
4757 | CombinedEvents &= PhyscicsPhantonSubsEvents; | ||
4758 | else | ||
4759 | CombinedEvents &= PhysicsNeededSubsEvents; | ||
4760 | |||
4761 | if (hassound || CombinedEvents != 0) | ||
4762 | { | ||
4763 | // subscribe to physics updates. | ||
4764 | pa.OnCollisionUpdate += PhysicsCollision; | ||
4765 | pa.SubscribeEvents(50); // 20 reports per second | ||
4766 | } | ||
4767 | else | ||
4768 | { | ||
4769 | pa.UnSubscribeEvents(); | ||
4770 | } | ||
4771 | } | ||
4772 | |||
4773 | |||
4706 | public void aggregateScriptEvents() | 4774 | public void aggregateScriptEvents() |
4707 | { | 4775 | { |
4776 | if (ParentGroup == null || ParentGroup.RootPart == null) | ||
4777 | return; | ||
4778 | |||
4708 | AggregateScriptEvents = 0; | 4779 | AggregateScriptEvents = 0; |
4709 | 4780 | ||
4710 | // Aggregate script events | 4781 | // Aggregate script events |
@@ -4736,7 +4807,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4736 | { | 4807 | { |
4737 | objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop; | 4808 | objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop; |
4738 | } | 4809 | } |
4739 | 4810 | /* | |
4740 | PhysicsActor pa = PhysActor; | 4811 | PhysicsActor pa = PhysActor; |
4741 | if (pa != null) | 4812 | if (pa != null) |
4742 | { | 4813 | { |
@@ -4747,7 +4818,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4747 | // ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | 4818 | // ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || |
4748 | // ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || | 4819 | // ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || |
4749 | // ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | 4820 | // ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || |
4750 | ((AggregateScriptEvents & PhyscicsNeededSubsEvents) != 0) || ((ParentGroup.RootPart.AggregateScriptEvents & PhyscicsNeededSubsEvents) != 0) || (CollisionSound != UUID.Zero) | 4821 | ((AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || ((ParentGroup.RootPart.AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || (CollisionSound != UUID.Zero) |
4751 | ) | 4822 | ) |
4752 | { | 4823 | { |
4753 | // subscribe to physics updates. | 4824 | // subscribe to physics updates. |
@@ -4760,6 +4831,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
4760 | pa.OnCollisionUpdate -= PhysicsCollision; | 4831 | pa.OnCollisionUpdate -= PhysicsCollision; |
4761 | } | 4832 | } |
4762 | } | 4833 | } |
4834 | */ | ||
4835 | UpdatePhysicsSubscribedEvents(); | ||
4836 | |||
4763 | //if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0) | 4837 | //if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0) |
4764 | //{ | 4838 | //{ |
4765 | // ParentGroup.Scene.EventManager.OnScriptTimerEvent += handleTimerAccounting; | 4839 | // ParentGroup.Scene.EventManager.OnScriptTimerEvent += handleTimerAccounting; |