diff options
-rw-r--r-- | OpenSim/Data/MySQL/MySQLSimulationData.cs | 9 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 174 | ||||
-rw-r--r-- | OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs | 46 | ||||
-rw-r--r-- | OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs | 33 |
4 files changed, 200 insertions, 62 deletions
diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 33c184f..ec7a454 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs | |||
@@ -170,6 +170,7 @@ namespace OpenSim.Data.MySQL | |||
170 | "ParticleSystem, ClickAction, Material, " + | 170 | "ParticleSystem, ClickAction, Material, " + |
171 | "CollisionSound, CollisionSoundVolume, " + | 171 | "CollisionSound, CollisionSoundVolume, " + |
172 | "PassTouches, " + | 172 | "PassTouches, " + |
173 | "PassCollisions, " + | ||
173 | "LinkNumber, MediaURL, KeyframeMotion, " + | 174 | "LinkNumber, MediaURL, KeyframeMotion, " + |
174 | "PhysicsShapeType, Density, GravityModifier, " + | 175 | "PhysicsShapeType, Density, GravityModifier, " + |
175 | "Friction, Restitution) values (" + "?UUID, " + | 176 | "Friction, Restitution) values (" + "?UUID, " + |
@@ -203,7 +204,7 @@ namespace OpenSim.Data.MySQL | |||
203 | "?SaleType, ?ColorR, ?ColorG, " + | 204 | "?SaleType, ?ColorR, ?ColorG, " + |
204 | "?ColorB, ?ColorA, ?ParticleSystem, " + | 205 | "?ColorB, ?ColorA, ?ParticleSystem, " + |
205 | "?ClickAction, ?Material, ?CollisionSound, " + | 206 | "?ClickAction, ?Material, ?CollisionSound, " + |
206 | "?CollisionSoundVolume, ?PassTouches, " + | 207 | "?CollisionSoundVolume, ?PassTouches, ?PassCollisions, " + |
207 | "?LinkNumber, ?MediaURL, ?KeyframeMotion, " + | 208 | "?LinkNumber, ?MediaURL, ?KeyframeMotion, " + |
208 | "?PhysicsShapeType, ?Density, ?GravityModifier, " + | 209 | "?PhysicsShapeType, ?Density, ?GravityModifier, " + |
209 | "?Friction, ?Restitution)"; | 210 | "?Friction, ?Restitution)"; |
@@ -1231,6 +1232,7 @@ namespace OpenSim.Data.MySQL | |||
1231 | prim.CollisionSoundVolume = (float)(double)row["CollisionSoundVolume"]; | 1232 | prim.CollisionSoundVolume = (float)(double)row["CollisionSoundVolume"]; |
1232 | 1233 | ||
1233 | prim.PassTouches = ((sbyte)row["PassTouches"] != 0); | 1234 | prim.PassTouches = ((sbyte)row["PassTouches"] != 0); |
1235 | prim.PassCollisions = ((sbyte)row["PassCollisions"] != 0); | ||
1234 | prim.LinkNum = (int)row["LinkNumber"]; | 1236 | prim.LinkNum = (int)row["LinkNumber"]; |
1235 | 1237 | ||
1236 | if (!(row["MediaURL"] is System.DBNull)) | 1238 | if (!(row["MediaURL"] is System.DBNull)) |
@@ -1605,6 +1607,11 @@ namespace OpenSim.Data.MySQL | |||
1605 | else | 1607 | else |
1606 | cmd.Parameters.AddWithValue("PassTouches", 0); | 1608 | cmd.Parameters.AddWithValue("PassTouches", 0); |
1607 | 1609 | ||
1610 | if (prim.PassCollisions) | ||
1611 | cmd.Parameters.AddWithValue("PassCollisions", 1); | ||
1612 | else | ||
1613 | cmd.Parameters.AddWithValue("PassCollisions", 0); | ||
1614 | |||
1608 | cmd.Parameters.AddWithValue("LinkNumber", prim.LinkNum); | 1615 | cmd.Parameters.AddWithValue("LinkNumber", prim.LinkNum); |
1609 | cmd.Parameters.AddWithValue("MediaURL", prim.MediaUrl); | 1616 | cmd.Parameters.AddWithValue("MediaURL", prim.MediaUrl); |
1610 | 1617 | ||
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; |
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs index 87a7e51..5db4f17 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs | |||
@@ -194,8 +194,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
194 | public int givefakeori = 0; | 194 | public int givefakeori = 0; |
195 | private Quaternion fakeori; | 195 | private Quaternion fakeori; |
196 | 196 | ||
197 | public int m_eventsubscription; | 197 | private int m_eventsubscription; |
198 | private CollisionEventUpdate CollisionEventsThisFrame = new CollisionEventUpdate(); | 198 | private int m_cureventsubscription; |
199 | private CollisionEventUpdate CollisionEventsThisFrame = null; | ||
200 | private bool SentEmptyCollisionsEvent; | ||
199 | 201 | ||
200 | public volatile bool childPrim; | 202 | public volatile bool childPrim; |
201 | 203 | ||
@@ -931,12 +933,21 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
931 | public override void SubscribeEvents(int ms) | 933 | public override void SubscribeEvents(int ms) |
932 | { | 934 | { |
933 | m_eventsubscription = ms; | 935 | m_eventsubscription = ms; |
936 | m_cureventsubscription = 0; | ||
937 | if (CollisionEventsThisFrame == null) | ||
938 | CollisionEventsThisFrame = new CollisionEventUpdate(); | ||
939 | SentEmptyCollisionsEvent = false; | ||
934 | _parent_scene.AddCollisionEventReporting(this); | 940 | _parent_scene.AddCollisionEventReporting(this); |
935 | } | 941 | } |
936 | 942 | ||
937 | public override void UnSubscribeEvents() | 943 | public override void UnSubscribeEvents() |
938 | { | 944 | { |
939 | _parent_scene.RemoveCollisionEventReporting(this); | 945 | _parent_scene.RemoveCollisionEventReporting(this); |
946 | if (CollisionEventsThisFrame != null) | ||
947 | { | ||
948 | CollisionEventsThisFrame.Clear(); | ||
949 | CollisionEventsThisFrame = null; | ||
950 | } | ||
940 | m_eventsubscription = 0; | 951 | m_eventsubscription = 0; |
941 | } | 952 | } |
942 | 953 | ||
@@ -944,7 +955,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
944 | { | 955 | { |
945 | if (CollisionEventsThisFrame == null) | 956 | if (CollisionEventsThisFrame == null) |
946 | CollisionEventsThisFrame = new CollisionEventUpdate(); | 957 | CollisionEventsThisFrame = new CollisionEventUpdate(); |
947 | |||
948 | CollisionEventsThisFrame.AddCollider(CollidedWith, contact); | 958 | CollisionEventsThisFrame.AddCollider(CollidedWith, contact); |
949 | } | 959 | } |
950 | 960 | ||
@@ -953,14 +963,34 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
953 | if (CollisionEventsThisFrame == null) | 963 | if (CollisionEventsThisFrame == null) |
954 | return; | 964 | return; |
955 | 965 | ||
956 | base.SendCollisionUpdate(CollisionEventsThisFrame); | 966 | if (m_cureventsubscription < m_eventsubscription) |
967 | return; | ||
957 | 968 | ||
958 | if (CollisionEventsThisFrame.m_objCollisionList.Count == 0) | 969 | m_cureventsubscription = 0; |
959 | CollisionEventsThisFrame = null; | 970 | |
960 | else | 971 | int ncolisions = CollisionEventsThisFrame.m_objCollisionList.Count; |
961 | CollisionEventsThisFrame = new CollisionEventUpdate(); | 972 | |
973 | if (!SentEmptyCollisionsEvent || ncolisions > 0) | ||
974 | { | ||
975 | base.SendCollisionUpdate(CollisionEventsThisFrame); | ||
976 | |||
977 | if (ncolisions == 0) | ||
978 | SentEmptyCollisionsEvent = true; | ||
979 | else | ||
980 | { | ||
981 | SentEmptyCollisionsEvent = false; | ||
982 | CollisionEventsThisFrame.Clear(); | ||
983 | } | ||
984 | } | ||
962 | } | 985 | } |
963 | 986 | ||
987 | internal void AddCollisionFrameTime(int t) | ||
988 | { | ||
989 | // protect it from overflow crashing | ||
990 | if (m_cureventsubscription + t >= int.MaxValue) | ||
991 | m_cureventsubscription = 0; | ||
992 | m_cureventsubscription += t; | ||
993 | } | ||
964 | public override bool SubscribedEvents() | 994 | public override bool SubscribedEvents() |
965 | { | 995 | { |
966 | if (m_eventsubscription > 0) | 996 | if (m_eventsubscription > 0) |
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs index 7367719..ddfdea4 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs | |||
@@ -620,8 +620,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
620 | return d.JointCreateContactPtr(world, contactgroup, contact); | 620 | return d.JointCreateContactPtr(world, contactgroup, contact); |
621 | } | 621 | } |
622 | 622 | ||
623 | |||
624 | |||
625 | private bool GetCurContactGeom(int index, ref d.ContactGeom newcontactgeom) | 623 | private bool GetCurContactGeom(int index, ref d.ContactGeom newcontactgeom) |
626 | { | 624 | { |
627 | if (ContactgeomsArray == IntPtr.Zero || index >= contactsPerCollision) | 625 | if (ContactgeomsArray == IntPtr.Zero || index >= contactsPerCollision) |
@@ -1153,6 +1151,31 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1153 | } | 1151 | } |
1154 | } | 1152 | } |
1155 | break; | 1153 | break; |
1154 | case ActorTypes.Ground: | ||
1155 | case ActorTypes.Unknown: | ||
1156 | default: | ||
1157 | switch ((ActorTypes)p2.PhysicsActorType) | ||
1158 | { | ||
1159 | case ActorTypes.Agent: | ||
1160 | if (p2 is OdeCharacter) | ||
1161 | { | ||
1162 | cc2 = (OdeCharacter)p2; | ||
1163 | obj2LocalID = cc2.m_localID; | ||
1164 | if (p2events) | ||
1165 | cc2.AddCollisionEvent(0, contact); | ||
1166 | } | ||
1167 | break; | ||
1168 | case ActorTypes.Prim: | ||
1169 | if (p2 is OdePrim) | ||
1170 | { | ||
1171 | cp2 = (OdePrim)p2; | ||
1172 | obj2LocalID = cp2.m_localID; | ||
1173 | if (p2events) | ||
1174 | cp2.AddCollisionEvent(0, contact); | ||
1175 | } | ||
1176 | break; | ||
1177 | } | ||
1178 | break; | ||
1156 | } | 1179 | } |
1157 | } | 1180 | } |
1158 | 1181 | ||
@@ -1875,7 +1898,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1875 | 1898 | ||
1876 | case ActorTypes.Prim: | 1899 | case ActorTypes.Prim: |
1877 | OdePrim pobj = (OdePrim)obj; | 1900 | OdePrim pobj = (OdePrim)obj; |
1878 | pobj.SendCollisions(); | 1901 | if (pobj.Body == IntPtr.Zero || (d.BodyIsEnabled(pobj.Body) && !pobj.m_outbounds)) |
1902 | { | ||
1903 | pobj.AddCollisionFrameTime((int)(ODE_STEPSIZE * 1000.0f)); | ||
1904 | pobj.SendCollisions(); | ||
1905 | } | ||
1879 | break; | 1906 | break; |
1880 | } | 1907 | } |
1881 | } | 1908 | } |