diff options
author | Robert Adams | 2013-07-11 16:57:07 -0700 |
---|---|---|
committer | Robert Adams | 2013-07-11 16:57:07 -0700 |
commit | 1909ee70f8f3df6558ce2abfc8b1d03fc5565a63 (patch) | |
tree | e029c340283dfbd9400a6480e972a63f58da453b /OpenSim/Region/Framework/Scenes | |
parent | Try naming the materials handlers again, this time registering the POST as Re... (diff) | |
download | opensim-SC_OLD-1909ee70f8f3df6558ce2abfc8b1d03fc5565a63.zip opensim-SC_OLD-1909ee70f8f3df6558ce2abfc8b1d03fc5565a63.tar.gz opensim-SC_OLD-1909ee70f8f3df6558ce2abfc8b1d03fc5565a63.tar.bz2 opensim-SC_OLD-1909ee70f8f3df6558ce2abfc8b1d03fc5565a63.tar.xz |
Centralize duplicated code in SceneObjectPart for subscribing to
collision events. Improve logic for knowing when to add processing
routine to physics actor.
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 97 |
1 files changed, 43 insertions, 54 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index f361acb..830fe31 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -4213,31 +4213,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
4213 | AddToPhysics(UsePhysics, SetPhantom, false); | 4213 | AddToPhysics(UsePhysics, SetPhantom, false); |
4214 | pa = PhysActor; | 4214 | pa = PhysActor; |
4215 | 4215 | ||
4216 | |||
4217 | if (pa != null) | 4216 | if (pa != null) |
4218 | { | 4217 | { |
4219 | pa.SetMaterial(Material); | 4218 | pa.SetMaterial(Material); |
4220 | DoPhysicsPropertyUpdate(UsePhysics, true); | 4219 | DoPhysicsPropertyUpdate(UsePhysics, true); |
4221 | 4220 | ||
4222 | if ( | 4221 | SubscribeForCollisionEvents(); |
4223 | ((AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4224 | ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4225 | ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4226 | ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4227 | ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4228 | ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4229 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4230 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4231 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4232 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4233 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4234 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4235 | (CollisionSound != UUID.Zero) | ||
4236 | ) | ||
4237 | { | ||
4238 | pa.OnCollisionUpdate += PhysicsCollision; | ||
4239 | pa.SubscribeEvents(1000); | ||
4240 | } | ||
4241 | } | 4222 | } |
4242 | } | 4223 | } |
4243 | else // it already has a physical representation | 4224 | else // it already has a physical representation |
@@ -4291,6 +4272,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
4291 | // m_log.DebugFormat("[SCENE OBJECT PART]: Updated PrimFlags on {0} {1} to {2}", Name, LocalId, Flags); | 4272 | // m_log.DebugFormat("[SCENE OBJECT PART]: Updated PrimFlags on {0} {1} to {2}", Name, LocalId, Flags); |
4292 | } | 4273 | } |
4293 | 4274 | ||
4275 | // Subscribe for physics collision events if needed for scripts and sounds | ||
4276 | public void SubscribeForCollisionEvents() | ||
4277 | { | ||
4278 | if (PhysActor != null) | ||
4279 | { | ||
4280 | if ( | ||
4281 | ((AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4282 | ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4283 | ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4284 | ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4285 | ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4286 | ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4287 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4288 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4289 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4290 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4291 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4292 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4293 | (CollisionSound != UUID.Zero) | ||
4294 | ) | ||
4295 | { | ||
4296 | if (!PhysActor.SubscribedEvents()) | ||
4297 | { | ||
4298 | // If not already subscribed for event, set up for a collision event. | ||
4299 | PhysActor.OnCollisionUpdate += PhysicsCollision; | ||
4300 | PhysActor.SubscribeEvents(1000); | ||
4301 | } | ||
4302 | } | ||
4303 | else | ||
4304 | { | ||
4305 | // There is no need to be subscribed to collisions so, if subscribed, remove subscription | ||
4306 | if (PhysActor.SubscribedEvents()) | ||
4307 | { | ||
4308 | PhysActor.OnCollisionUpdate -= PhysicsCollision; | ||
4309 | PhysActor.UnSubscribeEvents(); | ||
4310 | } | ||
4311 | } | ||
4312 | } | ||
4313 | } | ||
4314 | |||
4294 | /// <summary> | 4315 | /// <summary> |
4295 | /// Adds this part to the physics scene. | 4316 | /// Adds this part to the physics scene. |
4296 | /// </summary> | 4317 | /// </summary> |
@@ -4680,39 +4701,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4680 | objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop; | 4701 | objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop; |
4681 | } | 4702 | } |
4682 | 4703 | ||
4683 | PhysicsActor pa = PhysActor; | 4704 | SubscribeForCollisionEvents(); |
4684 | |||
4685 | if ( | ||
4686 | ((AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4687 | ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4688 | ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4689 | ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4690 | ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4691 | ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4692 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4693 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4694 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4695 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4696 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4697 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4698 | (CollisionSound != UUID.Zero) | ||
4699 | ) | ||
4700 | { | ||
4701 | // subscribe to physics updates. | ||
4702 | if (pa != null) | ||
4703 | { | ||
4704 | pa.OnCollisionUpdate += PhysicsCollision; | ||
4705 | pa.SubscribeEvents(1000); | ||
4706 | } | ||
4707 | } | ||
4708 | else | ||
4709 | { | ||
4710 | if (pa != null) | ||
4711 | { | ||
4712 | pa.UnSubscribeEvents(); | ||
4713 | pa.OnCollisionUpdate -= PhysicsCollision; | ||
4714 | } | ||
4715 | } | ||
4716 | 4705 | ||
4717 | //if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0) | 4706 | //if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0) |
4718 | //{ | 4707 | //{ |