aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/ScenePresence.cs
diff options
context:
space:
mode:
authorMelanie2012-05-31 03:37:43 +0100
committerMelanie2012-05-31 03:37:43 +0100
commite696d1d95225e3ddf90c823a2309dd8760af935b (patch)
tree8a72f0f86f2e6fd6e2e5d779993699b66f2c8ef9 /OpenSim/Region/Framework/Scenes/ScenePresence.cs
parentMerge branch 'master' into careminster (diff)
parentubitode prim: if makebody() is called already having a body, do a full destru... (diff)
downloadopensim-SC_OLD-e696d1d95225e3ddf90c823a2309dd8760af935b.zip
opensim-SC_OLD-e696d1d95225e3ddf90c823a2309dd8760af935b.tar.gz
opensim-SC_OLD-e696d1d95225e3ddf90c823a2309dd8760af935b.tar.bz2
opensim-SC_OLD-e696d1d95225e3ddf90c823a2309dd8760af935b.tar.xz
Merge branch 'avination' into careminster
Conflicts: OpenSim/Region/Framework/Scenes/ScenePresence.cs
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs324
1 files changed, 162 insertions, 162 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 1adf13e..07b36b3 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -4287,199 +4287,199 @@ namespace OpenSim.Region.Framework.Scenes
4287 } 4287 }
4288 } 4288 }
4289 4289
4290 private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata) 4290 private DetectedObject CreateDetObject(SceneObjectPart obj)
4291 { 4291 {
4292 /* 4292 DetectedObject detobj = new DetectedObject();
4293 lock(m_collisionEventLock) 4293 detobj.keyUUID = obj.UUID;
4294 { 4294 detobj.nameStr = obj.Name;
4295 if (m_collisionEventFlag) 4295 detobj.ownerUUID = obj.OwnerID;
4296 return; 4296 detobj.posVector = obj.AbsolutePosition;
4297 m_collisionEventFlag = true; 4297 detobj.rotQuat = obj.GetWorldRotation();
4298 } 4298 detobj.velVector = obj.Velocity;
4299 detobj.colliderType = 0;
4300 detobj.groupUUID = obj.GroupID;
4299 4301
4300 Util.FireAndForget(delegate(object x) 4302 return detobj;
4303 }
4304
4305 private DetectedObject CreateDetObject(ScenePresence av)
4306 {
4307 DetectedObject detobj = new DetectedObject();
4308 detobj.keyUUID = av.UUID;
4309 detobj.nameStr = av.ControllingClient.Name;
4310 detobj.ownerUUID = av.UUID;
4311 detobj.posVector = av.AbsolutePosition;
4312 detobj.rotQuat = av.Rotation;
4313 detobj.velVector = av.Velocity;
4314 detobj.colliderType = 0;
4315 detobj.groupUUID = av.ControllingClient.ActiveGroupId;
4316
4317 return detobj;
4318 }
4319
4320 private DetectedObject CreateDetObjectForGround()
4321 {
4322 DetectedObject detobj = new DetectedObject();
4323 detobj.keyUUID = UUID.Zero;
4324 detobj.nameStr = "";
4325 detobj.ownerUUID = UUID.Zero;
4326 detobj.posVector = AbsolutePosition;
4327 detobj.rotQuat = Quaternion.Identity;
4328 detobj.velVector = Vector3.Zero;
4329 detobj.colliderType = 0;
4330 detobj.groupUUID = UUID.Zero;
4331
4332 return detobj;
4333 }
4334
4335 private ColliderArgs CreateColliderArgs(SceneObjectPart dest, List<uint> colliders)
4336 {
4337 ColliderArgs colliderArgs = new ColliderArgs();
4338 List<DetectedObject> colliding = new List<DetectedObject>();
4339 foreach (uint localId in colliders)
4301 { 4340 {
4302 */ 4341 if (localId == 0)
4303 try 4342 continue;
4343
4344 SceneObjectPart obj = m_scene.GetSceneObjectPart(localId);
4345 if (obj != null)
4304 { 4346 {
4305 List<uint> thisHitColliders = new List<uint>(); 4347 if (!dest.CollisionFilteredOut(obj.UUID, obj.Name))
4306 List<uint> endedColliders = new List<uint>(); 4348 colliding.Add(CreateDetObject(obj));
4307 List<uint> startedColliders = new List<uint>(); 4349 }
4308 List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>(); 4350 else
4309 CollisionForSoundInfo soundinfo; 4351 {
4310 ContactPoint curcontact; 4352 ScenePresence av = m_scene.GetScenePresence(localId);
4311 4353 if (av != null && (!av.IsChildAgent))
4312 if (coldata.Count == 0)
4313 { 4354 {
4314 if (m_lastColliders.Count == 0) 4355 if (!dest.CollisionFilteredOut(av.UUID, av.Name))
4315 return; // nothing to do 4356 colliding.Add(CreateDetObject(av));
4316
4317 foreach (uint localID in m_lastColliders)
4318 {
4319 endedColliders.Add(localID);
4320 }
4321 m_lastColliders.Clear();
4322 } 4357 }
4358 }
4359 }
4323 4360
4324 else 4361 colliderArgs.Colliders = colliding;
4325 {
4326 foreach (uint id in coldata.Keys)
4327 {
4328 thisHitColliders.Add(id);
4329 if (!m_lastColliders.Contains(id))
4330 {
4331 startedColliders.Add(id);
4332 curcontact = coldata[id];
4333 if (Math.Abs(curcontact.RelativeSpeed) > 0.2)
4334 {
4335 soundinfo = new CollisionForSoundInfo();
4336 soundinfo.colliderID = id;
4337 soundinfo.position = curcontact.Position;
4338 soundinfo.relativeVel = curcontact.RelativeSpeed;
4339 soundinfolist.Add(soundinfo);
4340 }
4341 }
4342 //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString());
4343 }
4344 4362
4345 // calculate things that ended colliding 4363 return colliderArgs;
4346 foreach (uint localID in m_lastColliders) 4364 }
4347 {
4348 if (!thisHitColliders.Contains(localID))
4349 {
4350 endedColliders.Add(localID);
4351 }
4352 }
4353 //add the items that started colliding this time to the last colliders list.
4354 foreach (uint localID in startedColliders)
4355 {
4356 m_lastColliders.Add(localID);
4357 }
4358 // remove things that ended colliding from the last colliders list
4359 foreach (uint localID in endedColliders)
4360 {
4361 m_lastColliders.Remove(localID);
4362 }
4363
4364 if (soundinfolist.Count > 0)
4365 CollisionSounds.AvatarCollisionSound(this, soundinfolist);
4366 4365
4367 // do event notification 4366 private delegate void ScriptCollidingNotification(uint localID, ColliderArgs message);
4368 if (startedColliders.Count > 0)
4369 {
4370 4367
4371 ColliderArgs StartCollidingMessage = new ColliderArgs(); 4368 private void SendCollisionEvent(SceneObjectGroup dest, scriptEvents ev, List<uint> colliders, ScriptCollidingNotification notify)
4372 List<DetectedObject> colliding = new List<DetectedObject>(); 4369 {
4373 foreach (uint localId in startedColliders) 4370 ColliderArgs CollidingMessage;
4374 {
4375 if (localId == 0)
4376 continue;
4377 4371
4378 SceneObjectPart obj = Scene.GetSceneObjectPart(localId); 4372 if (colliders.Count > 0)
4379 string data = ""; 4373 {
4380 if (obj != null) 4374 if ((dest.RootPart.ScriptEvents & ev) != 0)
4381 { 4375 {
4382 DetectedObject detobj = new DetectedObject(); 4376 CollidingMessage = CreateColliderArgs(dest.RootPart, colliders);
4383 detobj.keyUUID = obj.UUID;
4384 detobj.nameStr = obj.Name;
4385 detobj.ownerUUID = obj.OwnerID;
4386 detobj.posVector = obj.AbsolutePosition;
4387 detobj.rotQuat = obj.GetWorldRotation();
4388 detobj.velVector = obj.Velocity;
4389 detobj.colliderType = 0;
4390 detobj.groupUUID = obj.GroupID;
4391 colliding.Add(detobj);
4392 }
4393 }
4394 4377
4395 if (colliding.Count > 0) 4378 if (CollidingMessage.Colliders.Count > 0)
4396 { 4379 notify(dest.RootPart.LocalId, CollidingMessage);
4397 StartCollidingMessage.Colliders = colliding; 4380 }
4381 }
4382 }
4398 4383
4399 foreach (SceneObjectGroup att in GetAttachments()) 4384 private void SendLandCollisionEvent(SceneObjectGroup dest, scriptEvents ev, ScriptCollidingNotification notify)
4400 Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); 4385 {
4401 } 4386 if ((dest.RootPart.ScriptEvents & ev) != 0)
4402 } 4387 {
4403 } 4388 ColliderArgs LandCollidingMessage = new ColliderArgs();
4389 List<DetectedObject> colliding = new List<DetectedObject>();
4404 4390
4405 if (endedColliders.Count > 0) 4391 colliding.Add(CreateDetObjectForGround());
4406 { 4392 LandCollidingMessage.Colliders = colliding;
4407 ColliderArgs EndCollidingMessage = new ColliderArgs();
4408 List<DetectedObject> colliding = new List<DetectedObject>();
4409 foreach (uint localId in endedColliders)
4410 {
4411 if (localId == 0)
4412 continue;
4413 4393
4414 SceneObjectPart obj = Scene.GetSceneObjectPart(localId); 4394 notify(dest.RootPart.LocalId, LandCollidingMessage);
4415 string data = ""; 4395 }
4416 if (obj != null) 4396 }
4417 {
4418 DetectedObject detobj = new DetectedObject();
4419 detobj.keyUUID = obj.UUID;
4420 detobj.nameStr = obj.Name;
4421 detobj.ownerUUID = obj.OwnerID;
4422 detobj.posVector = obj.AbsolutePosition;
4423 detobj.rotQuat = obj.GetWorldRotation();
4424 detobj.velVector = obj.Velocity;
4425 detobj.colliderType = 0;
4426 detobj.groupUUID = obj.GroupID;
4427 colliding.Add(detobj);
4428 }
4429 }
4430 4397
4431 if (colliding.Count > 0) 4398 private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata)
4432 { 4399 {
4433 EndCollidingMessage.Colliders = colliding; 4400 try
4401 {
4402 List<uint> thisHitColliders = new List<uint>();
4403 List<uint> endedColliders = new List<uint>();
4404 List<uint> startedColliders = new List<uint>();
4405 List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>();
4406 CollisionForSoundInfo soundinfo;
4407 ContactPoint curcontact;
4408
4409 if (coldata.Count == 0)
4410 {
4411 if (m_lastColliders.Count == 0)
4412 return; // nothing to do
4434 4413
4435 foreach (SceneObjectGroup att in GetAttachments()) 4414 foreach (uint localID in m_lastColliders)
4436 Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage); 4415 {
4437 } 4416 endedColliders.Add(localID);
4438 } 4417 }
4418 m_lastColliders.Clear();
4419 }
4439 4420
4440 if (thisHitColliders.Count > 0) 4421 else
4422 {
4423 foreach (uint id in coldata.Keys)
4441 { 4424 {
4442 ColliderArgs CollidingMessage = new ColliderArgs(); 4425 thisHitColliders.Add(id);
4443 List<DetectedObject> colliding = new List<DetectedObject>(); 4426 if (!m_lastColliders.Contains(id))
4444 foreach (uint localId in thisHitColliders)
4445 { 4427 {
4446 if (localId == 0) 4428 startedColliders.Add(id);
4447 continue; 4429 curcontact = coldata[id];
4448 4430 if (Math.Abs(curcontact.RelativeSpeed) > 0.2)
4449 SceneObjectPart obj = Scene.GetSceneObjectPart(localId);
4450 string data = "";
4451 if (obj != null)
4452 { 4431 {
4453 DetectedObject detobj = new DetectedObject(); 4432 soundinfo = new CollisionForSoundInfo();
4454 detobj.keyUUID = obj.UUID; 4433 soundinfo.colliderID = id;
4455 detobj.nameStr = obj.Name; 4434 soundinfo.position = curcontact.Position;
4456 detobj.ownerUUID = obj.OwnerID; 4435 soundinfo.relativeVel = curcontact.RelativeSpeed;
4457 detobj.posVector = obj.AbsolutePosition; 4436 soundinfolist.Add(soundinfo);
4458 detobj.rotQuat = obj.GetWorldRotation();
4459 detobj.velVector = obj.Velocity;
4460 detobj.colliderType = 0;
4461 detobj.groupUUID = obj.GroupID;
4462 colliding.Add(detobj);
4463 } 4437 }
4464 } 4438 }
4439 //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString());
4440 }
4465 4441
4466 if (colliding.Count > 0) 4442 // calculate things that ended colliding
4443 foreach (uint localID in m_lastColliders)
4444 {
4445 if (!thisHitColliders.Contains(localID))
4467 { 4446 {
4468 CollidingMessage.Colliders = colliding; 4447 endedColliders.Add(localID);
4469
4470 lock (m_attachments)
4471 {
4472 foreach (SceneObjectGroup att in m_attachments)
4473 Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage);
4474 }
4475 } 4448 }
4476 } 4449 }
4450 //add the items that started colliding this time to the last colliders list.
4451 foreach (uint localID in startedColliders)
4452 {
4453 m_lastColliders.Add(localID);
4454 }
4455 // remove things that ended colliding from the last colliders list
4456 foreach (uint localID in endedColliders)
4457 {
4458 m_lastColliders.Remove(localID);
4459 }
4460
4461 if (soundinfolist.Count > 0)
4462 CollisionSounds.AvatarCollisionSound(this, soundinfolist);
4477 } 4463 }
4478 finally 4464
4465 foreach (SceneObjectGroup att in GetAttachments())
4479 { 4466 {
4480 m_collisionEventFlag = false; 4467 SendCollisionEvent(att, scriptEvents.collision_start, startedColliders, m_scene.EventManager.TriggerScriptCollidingStart);
4468 SendCollisionEvent(att, scriptEvents.collision , m_lastColliders , m_scene.EventManager.TriggerScriptColliding);
4469 SendCollisionEvent(att, scriptEvents.collision_end , endedColliders , m_scene.EventManager.TriggerScriptCollidingEnd);
4470
4471 if (startedColliders.Contains(0))
4472 SendLandCollisionEvent(att, scriptEvents.land_collision_start, m_scene.EventManager.TriggerScriptLandCollidingStart);
4473 if (m_lastColliders.Contains(0))
4474 SendLandCollisionEvent(att, scriptEvents.land_collision, m_scene.EventManager.TriggerScriptLandColliding);
4475 if (endedColliders.Contains(0))
4476 SendLandCollisionEvent(att, scriptEvents.land_collision_end, m_scene.EventManager.TriggerScriptLandCollidingEnd);
4481 } 4477 }
4482// }); 4478 }
4479 finally
4480 {
4481 m_collisionEventFlag = false;
4482 }
4483 } 4483 }
4484 4484
4485 private void TeleportFlagsDebug() { 4485 private void TeleportFlagsDebug() {