aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment')
-rw-r--r--OpenSim/Region/Environment/Scenes/ScenePresence.cs67
1 files changed, 58 insertions, 9 deletions
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
index 527eb22..5155b41 100644
--- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
@@ -50,6 +50,8 @@ namespace OpenSim.Region.Environment.Scenes
50 private readonly List<NewForce> m_forcesList = new List<NewForce>(); 50 private readonly List<NewForce> m_forcesList = new List<NewForce>();
51 private short m_updateCount = 0; 51 private short m_updateCount = 0;
52 private uint m_requestedSitTargetID = 0; 52 private uint m_requestedSitTargetID = 0;
53 private LLVector3 m_requestedSitOffset = new LLVector3();
54 private float m_sitAvatarHeight = 2.0f;
53 55
54 private Quaternion bodyRot; 56 private Quaternion bodyRot;
55 private byte[] m_visualParams; 57 private byte[] m_visualParams;
@@ -448,6 +450,14 @@ namespace OpenSim.Region.Environment.Scenes
448 // return; 450 // return;
449 //} 451 //}
450 452
453 // Must check for standing up even when PhysicsActor is null,
454 // since sitting currently removes avatar from physical scene
455 if ((flags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_STAND_UP) != 0)
456 {
457 StandUp();
458 UpdateMovementAnimations(true);
459 }
460
451 if (PhysicsActor == null) 461 if (PhysicsActor == null)
452 { 462 {
453 // Console.WriteLine("DEBUG: HandleAgentUpdate: null PhysicsActor!"); 463 // Console.WriteLine("DEBUG: HandleAgentUpdate: null PhysicsActor!");
@@ -467,12 +477,6 @@ namespace OpenSim.Region.Environment.Scenes
467 update_movementflag = true; 477 update_movementflag = true;
468 } 478 }
469 479
470 if ((flags & (uint) MainAvatar.ControlFlags.AGENT_CONTROL_STAND_UP) != 0)
471 {
472 StandUp();
473 update_movementflag = true;
474 }
475
476 if (q != bodyRot) 480 if (q != bodyRot)
477 { 481 {
478 bodyRot = q; 482 bodyRot = q;
@@ -517,15 +521,56 @@ namespace OpenSim.Region.Environment.Scenes
517 if (m_parentID != 0) 521 if (m_parentID != 0)
518 { 522 {
519 SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID); 523 SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID);
524 LLVector3 pos = new LLVector3();
520 if (part != null) 525 if (part != null)
521 AbsolutePosition = part.AbsolutePosition; 526 pos = part.AbsolutePosition + m_requestedSitOffset + new LLVector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight);
527 MakeRootAgent(pos, false);
522 m_parentID = 0; 528 m_parentID = 0;
523 SendFullUpdateToAllClients(); 529 SendFullUpdateToAllClients();
524 } 530 }
525 } 531 }
526 532
527 public void HandleAgentRequestSit(IClientAPI remoteClient, LLUUID agentID, LLUUID targetID) 533 private void SendSitResponse(IClientAPI remoteClient, LLUUID targetID, LLVector3 offset)
534 {
535 AvatarSitResponsePacket avatarSitResponse = new AvatarSitResponsePacket();
536
537 avatarSitResponse.SitObject.ID = targetID;
538
539 bool autopilot = true;
540 LLVector3 pos = new LLVector3();
541
542 SceneObjectPart part = m_scene.GetSceneObjectPart(targetID);
543 if (part != null)
544 {
545 pos = part.AbsolutePosition + offset;
546
547 double dist = AbsolutePosition.GetDistanceTo(pos);
548
549 if (m_physicsActor != null)
550 {
551 m_sitAvatarHeight = m_physicsActor.Size.Z;
552 }
553
554// this doesn't seem to quite work yet....
555// // if we're close, set the avatar position to the target position and forgo autopilot
556// if (dist < 2.5)
557// {
558// autopilot = false;
559// AbsolutePosition = pos + new LLVector3(0.0f, 0.0f, m_sitAvatarHeight);
560// }
561 }
562
563 avatarSitResponse.SitTransform.AutoPilot = autopilot;
564 avatarSitResponse.SitTransform.SitPosition = offset;
565 avatarSitResponse.SitTransform.SitRotation = new LLQuaternion(0.0f, 0.0f, 0.0f, 1.0f);
566
567 remoteClient.OutPacket(avatarSitResponse);
568 }
569
570 public void HandleAgentRequestSit(IClientAPI remoteClient, LLUUID agentID, LLUUID targetID, LLVector3 offset)
528 { 571 {
572 SendSitResponse(remoteClient, targetID, offset);
573
529 if (m_parentID != 0) 574 if (m_parentID != 0)
530 { 575 {
531 StandUp(); 576 StandUp();
@@ -537,6 +582,7 @@ namespace OpenSim.Region.Environment.Scenes
537 if (part != null) 582 if (part != null)
538 { 583 {
539 m_requestedSitTargetID = part.LocalID; 584 m_requestedSitTargetID = part.LocalID;
585 m_requestedSitOffset = offset;
540 } 586 }
541 else 587 else
542 { 588 {
@@ -546,8 +592,11 @@ namespace OpenSim.Region.Environment.Scenes
546 592
547 public void HandleAgentSit(IClientAPI remoteClient, LLUUID agentID) 593 public void HandleAgentSit(IClientAPI remoteClient, LLUUID agentID)
548 { 594 {
549 AbsolutePosition = new LLVector3(0F, 0F, 0F); 595 // these magic numbers come mostly from experimenting with ODE,
596 // and seeing what looks right
597 AbsolutePosition = m_requestedSitOffset + new LLVector3(m_physicsActor.Size.X / 2.7f, 0f, m_physicsActor.Size.Z / 1.45f);
550 m_parentID = m_requestedSitTargetID; 598 m_parentID = m_requestedSitTargetID;
599 MakeChildAgent();
551 SendAnimPack(Animations.AnimsLLUUID["SIT"], 1); 600 SendAnimPack(Animations.AnimsLLUUID["SIT"], 1);
552 SendFullUpdateToAllClients(); 601 SendFullUpdateToAllClients();
553 } 602 }