aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
authorMelanie2012-05-15 21:24:27 +0100
committerMelanie2012-05-15 21:24:27 +0100
commit81ce169dfe4c498d6fda7bb2393bfec56065affc (patch)
treef7ceaf7d145aaf3fa263933bbad847ef42a93c50 /OpenSim/Region/Framework
parentMerge branch 'master' into careminster (diff)
parent use part VolumeDetectActive and not rootPart.VolumeDetectActive to be coeren... (diff)
downloadopensim-SC-81ce169dfe4c498d6fda7bb2393bfec56065affc.zip
opensim-SC-81ce169dfe4c498d6fda7bb2393bfec56065affc.tar.gz
opensim-SC-81ce169dfe4c498d6fda7bb2393bfec56065affc.tar.bz2
opensim-SC-81ce169dfe4c498d6fda7bb2393bfec56065affc.tar.xz
Merge branch 'avination' into careminster
Conflicts: OpenSim/Data/MySQL/MySQLSimulationData.cs OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs174
1 files changed, 124 insertions, 50 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 6064279..f62eef3 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)
@@ -2605,45 +2615,61 @@ namespace OpenSim.Region.Framework.Scenes
2605 List<uint> endedColliders = new List<uint>(); 2615 List<uint> endedColliders = new List<uint>();
2606 List<uint> startedColliders = new List<uint>(); 2616 List<uint> startedColliders = new List<uint>();
2607 2617
2608 // calculate things that started colliding this time 2618 if (collissionswith.Count == 0)
2609 // and build up list of colliders this time
2610 foreach (uint localid in collissionswith.Keys)
2611 { 2619 {
2612 thisHitColliders.Add(localid); 2620 if (m_lastColliders.Count == 0)
2613 if (!m_lastColliders.Contains(localid)) 2621 return; // nothing to do
2614 startedColliders.Add(localid);
2615 }
2616 2622
2617 // calculate things that ended colliding 2623 foreach (uint localID in m_lastColliders)
2618 foreach (uint localID in m_lastColliders) 2624 {
2619 {
2620 if (!thisHitColliders.Contains(localID))
2621 endedColliders.Add(localID); 2625 endedColliders.Add(localID);
2626 }
2627 m_lastColliders.Clear();
2622 } 2628 }
2623 2629
2624 //add the items that started colliding this time to the last colliders list. 2630 else
2625 foreach (uint localID in startedColliders) 2631 {
2626 m_lastColliders.Add(localID);
2627 2632
2628 // remove things that ended colliding from the last colliders list 2633 // calculate things that started colliding this time
2629 foreach (uint localID in endedColliders) 2634 // and build up list of colliders this time
2630 m_lastColliders.Remove(localID); 2635 foreach (uint localid in collissionswith.Keys)
2636 {
2637 thisHitColliders.Add(localid);
2638 if (!m_lastColliders.Contains(localid))
2639 startedColliders.Add(localid);
2640 }
2631 2641
2642 // calculate things that ended colliding
2643 foreach (uint localID in m_lastColliders)
2644 {
2645 if (!thisHitColliders.Contains(localID))
2646 endedColliders.Add(localID);
2647 }
2648
2649 //add the items that started colliding this time to the last colliders list.
2650 foreach (uint localID in startedColliders)
2651 m_lastColliders.Add(localID);
2652
2653 // remove things that ended colliding from the last colliders list
2654 foreach (uint localID in endedColliders)
2655 m_lastColliders.Remove(localID);
2656 }
2632 // play the sound. 2657 // play the sound.
2633 if (startedColliders.Count > 0 && CollisionSound != UUID.Zero && CollisionSoundVolume > 0.0f) 2658
2659 bool IsNotVolumeDtc = !VolumeDetectActive;
2660
2661 if (startedColliders.Count > 0 && CollisionSound != UUID.Zero && CollisionSoundVolume > 0.0f && IsNotVolumeDtc)
2634 SendSound(CollisionSound.ToString(), CollisionSoundVolume, true, (byte)0, 0, false, false); 2662 SendSound(CollisionSound.ToString(), CollisionSoundVolume, true, (byte)0, 0, false, false);
2635 2663
2636 SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); 2664 SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart);
2637 SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding); 2665 if (IsNotVolumeDtc)
2666 SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding);
2638 SendCollisionEvent(scriptEvents.collision_end , endedColliders , ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd); 2667 SendCollisionEvent(scriptEvents.collision_end , endedColliders , ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd);
2639 2668
2640 if (startedColliders.Contains(0)) 2669 if (startedColliders.Contains(0))
2641 { 2670 SendLandCollisionEvent(scriptEvents.land_collision_start, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingStart);
2642 if (m_lastColliders.Contains(0)) 2671 if (m_lastColliders.Contains(0))
2643 SendLandCollisionEvent(scriptEvents.land_collision, ParentGroup.Scene.EventManager.TriggerScriptLandColliding); 2672 SendLandCollisionEvent(scriptEvents.land_collision, ParentGroup.Scene.EventManager.TriggerScriptLandColliding);
2644 else
2645 SendLandCollisionEvent(scriptEvents.land_collision_start, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingStart);
2646 }
2647 if (endedColliders.Contains(0)) 2673 if (endedColliders.Contains(0))
2648 SendLandCollisionEvent(scriptEvents.land_collision_end, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingEnd); 2674 SendLandCollisionEvent(scriptEvents.land_collision_end, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingEnd);
2649 } 2675 }
@@ -4386,26 +4412,28 @@ namespace OpenSim.Region.Framework.Scenes
4386 { 4412 {
4387 if (pa == null) 4413 if (pa == null)
4388 { 4414 {
4389 AddToPhysics(UsePhysics, SetPhantom, building , false); 4415 AddToPhysics(UsePhysics, SetPhantom, building, false);
4390 pa = PhysActor; 4416 pa = PhysActor;
4391 4417 /*
4392 if (pa != null) 4418 if (pa != null)
4393 { 4419 {
4394 if ( 4420 if (
4395// ((AggregateScriptEvents & scriptEvents.collision) != 0) || 4421 // ((AggregateScriptEvents & scriptEvents.collision) != 0) ||
4396// ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || 4422 // ((AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
4397// ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || 4423 // ((AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
4398// ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || 4424 // ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) ||
4399// ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || 4425 // ((AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
4400// ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || 4426 // ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
4401 ((AggregateScriptEvents & PhyscicsNeededSubsEvents) != 0) || ((ParentGroup.RootPart.AggregateScriptEvents & PhyscicsNeededSubsEvents) != 0) || (CollisionSound != UUID.Zero) 4427 ((AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) ||
4402// (CollisionSound != UUID.Zero) 4428 ((ParentGroup.RootPart.AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) ||
4403 ) 4429 (CollisionSound != UUID.Zero)
4404 { 4430 )
4405 pa.OnCollisionUpdate += PhysicsCollision; 4431 {
4406 pa.SubscribeEvents(1000); 4432 pa.OnCollisionUpdate += PhysicsCollision;
4407 } 4433 pa.SubscribeEvents(1000);
4408 } 4434 }
4435 }
4436 */
4409 } 4437 }
4410 else // it already has a physical representation 4438 else // it already has a physical representation
4411 { 4439 {
@@ -4416,9 +4444,13 @@ namespace OpenSim.Region.Framework.Scenes
4416 else 4444 else
4417 pa.SetVolumeDetect(0); 4445 pa.SetVolumeDetect(0);
4418 */ 4446 */
4447
4448
4419 if (pa.Building != building) 4449 if (pa.Building != building)
4420 pa.Building = building; 4450 pa.Building = building;
4421 } 4451 }
4452
4453 UpdatePhysicsSubscribedEvents();
4422 } 4454 }
4423 } 4455 }
4424 4456
@@ -4541,8 +4573,7 @@ namespace OpenSim.Region.Framework.Scenes
4541 /// </summary> 4573 /// </summary>
4542 /// <remarks> 4574 /// <remarks>
4543 /// This isn't the same as turning off physical, since even without being physical the prim has a physics 4575 /// This isn't the same as turning off physical, since even without being physical the prim has a physics
4544 /// representation for collision detection. Rather, this would be used in situations such as making a prim 4576 /// representation for collision detection.
4545 /// phantom.
4546 /// </remarks> 4577 /// </remarks>
4547 public void RemoveFromPhysics() 4578 public void RemoveFromPhysics()
4548 { 4579 {
@@ -4706,6 +4737,46 @@ namespace OpenSim.Region.Framework.Scenes
4706 ScheduleFullUpdate(); 4737 ScheduleFullUpdate();
4707 } 4738 }
4708 4739
4740
4741 private void UpdatePhysicsSubscribedEvents()
4742 {
4743 PhysicsActor pa = PhysActor;
4744 if (pa == null)
4745 return;
4746
4747 pa.OnCollisionUpdate -= PhysicsCollision;
4748
4749 bool hassound = ( CollisionSound != UUID.Zero && CollisionSoundVolume > 0.0f);
4750 scriptEvents CombinedEvents = AggregateScriptEvents;
4751
4752 // merge with root part
4753 if (ParentGroup != null && ParentGroup.RootPart != null)
4754 CombinedEvents |= ParentGroup.RootPart.AggregateScriptEvents;
4755
4756 // submit to this part case
4757 if (VolumeDetectActive)
4758 {
4759 CombinedEvents &= PhyscicsVolumeDtcSubsEvents;
4760 hassound = false;
4761 }
4762 else if ((Flags & PrimFlags.Phantom) != 0)
4763 CombinedEvents &= PhyscicsPhantonSubsEvents;
4764 else
4765 CombinedEvents &= PhysicsNeededSubsEvents;
4766
4767 if (hassound || CombinedEvents != 0)
4768 {
4769 // subscribe to physics updates.
4770 pa.OnCollisionUpdate += PhysicsCollision;
4771 pa.SubscribeEvents(50); // 20 reports per second
4772 }
4773 else
4774 {
4775 pa.UnSubscribeEvents();
4776 }
4777 }
4778
4779
4709 public void aggregateScriptEvents() 4780 public void aggregateScriptEvents()
4710 { 4781 {
4711 if (ParentGroup == null || ParentGroup.RootPart == null) 4782 if (ParentGroup == null || ParentGroup.RootPart == null)
@@ -4742,7 +4813,7 @@ namespace OpenSim.Region.Framework.Scenes
4742 { 4813 {
4743 objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop; 4814 objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop;
4744 } 4815 }
4745 4816/*
4746 PhysicsActor pa = PhysActor; 4817 PhysicsActor pa = PhysActor;
4747 if (pa != null) 4818 if (pa != null)
4748 { 4819 {
@@ -4753,7 +4824,7 @@ namespace OpenSim.Region.Framework.Scenes
4753// ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || 4824// ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) ||
4754// ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || 4825// ((AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
4755// ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || 4826// ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
4756 ((AggregateScriptEvents & PhyscicsNeededSubsEvents) != 0) || ((ParentGroup.RootPart.AggregateScriptEvents & PhyscicsNeededSubsEvents) != 0) || (CollisionSound != UUID.Zero) 4827 ((AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || ((ParentGroup.RootPart.AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || (CollisionSound != UUID.Zero)
4757 ) 4828 )
4758 { 4829 {
4759 // subscribe to physics updates. 4830 // subscribe to physics updates.
@@ -4766,6 +4837,9 @@ namespace OpenSim.Region.Framework.Scenes
4766 pa.OnCollisionUpdate -= PhysicsCollision; 4837 pa.OnCollisionUpdate -= PhysicsCollision;
4767 } 4838 }
4768 } 4839 }
4840 */
4841 UpdatePhysicsSubscribedEvents();
4842
4769 //if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0) 4843 //if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0)
4770 //{ 4844 //{
4771 // ParentGroup.Scene.EventManager.OnScriptTimerEvent += handleTimerAccounting; 4845 // ParentGroup.Scene.EventManager.OnScriptTimerEvent += handleTimerAccounting;