aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment
diff options
context:
space:
mode:
authorTeravus Ovares2007-12-27 03:25:00 +0000
committerTeravus Ovares2007-12-27 03:25:00 +0000
commit87d55443d3fd3cc86dce0b8efe05a8c304f7d6c8 (patch)
tree69599226423b5a4620ab4308b3e0088328894bde /OpenSim/Region/Environment
parentPrim inventory persistence phase 1: Creation of preliminary table in sqlite. (diff)
downloadopensim-SC_OLD-87d55443d3fd3cc86dce0b8efe05a8c304f7d6c8.zip
opensim-SC_OLD-87d55443d3fd3cc86dce0b8efe05a8c304f7d6c8.tar.gz
opensim-SC_OLD-87d55443d3fd3cc86dce0b8efe05a8c304f7d6c8.tar.bz2
opensim-SC_OLD-87d55443d3fd3cc86dce0b8efe05a8c304f7d6c8.tar.xz
* Added slightly better object sit handling
* Added sit handling for sit targets * Implemented llSitTarget() * Implemented llAvatarOnSitTarget() * Sit targets do not persist sim restart.
Diffstat (limited to 'OpenSim/Region/Environment')
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectPart.cs34
-rw-r--r--OpenSim/Region/Environment/Scenes/ScenePresence.cs110
2 files changed, 130 insertions, 14 deletions
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index 34705db..bcd31c2 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -68,6 +68,11 @@ namespace OpenSim.Region.Environment.Scenes
68 public Int32 CreationDate; 68 public Int32 CreationDate;
69 public uint ParentID = 0; 69 public uint ParentID = 0;
70 70
71 private Vector3 m_sitTargetPosition = new Vector3(0, 0, 0);
72 private Quaternion m_sitTargetOrientation = new Quaternion(0, 0, 0, 1);
73 private LLUUID m_SitTargetAvatar = LLUUID.Zero;
74
75
71 // Main grid has default permissions as follows 76 // Main grid has default permissions as follows
72 // 77 //
73 public uint OwnerMask = FULL_MASK_PERMISSIONS_OWNER; 78 public uint OwnerMask = FULL_MASK_PERMISSIONS_OWNER;
@@ -161,6 +166,8 @@ namespace OpenSim.Region.Environment.Scenes
161 //unkown if this will be kept, added as a way of removing the group position from the group class 166 //unkown if this will be kept, added as a way of removing the group position from the group class
162 protected LLVector3 m_groupPosition; 167 protected LLVector3 m_groupPosition;
163 168
169
170
164 public LLVector3 GroupPosition 171 public LLVector3 GroupPosition
165 { 172 {
166 get 173 get
@@ -774,6 +781,33 @@ namespace OpenSim.Region.Environment.Scenes
774 m_parentGroup = parent; 781 m_parentGroup = parent;
775 } 782 }
776 783
784 public void SetSitTarget(Vector3 offset, Quaternion orientation)
785 {
786 m_sitTargetPosition = offset;
787 m_sitTargetOrientation = orientation;
788 }
789
790 public Vector3 GetSitTargetPosition()
791 {
792 return m_sitTargetPosition;
793 }
794
795 public Quaternion GetSitTargetOrientation()
796 {
797 return m_sitTargetOrientation;
798 }
799
800 public void SetAvatarOnSitTarget(LLUUID avatarID)
801 {
802 m_SitTargetAvatar = avatarID;
803 }
804
805 public LLUUID GetAvatarOnSitTarget()
806 {
807 return m_SitTargetAvatar;
808 }
809
810
777 public LLUUID GetRootPartUUID() 811 public LLUUID GetRootPartUUID()
778 { 812 {
779 if (m_parentGroup != null) 813 if (m_parentGroup != null)
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
index 4b8ca97..9a937a2 100644
--- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
@@ -537,7 +537,7 @@ namespace OpenSim.Region.Environment.Scenes
537 // and send a full object update. 537 // and send a full object update.
538 // There's no message to send the client to tell it to stop flying 538 // There's no message to send the client to tell it to stop flying
539 539
540 // Add 1/2 the avatar's height to it's position so it doesn't shoot into the air 540 // Add 1/6 the avatar's height to it's position so it doesn't shoot into the air
541 // when the avatar stands up 541 // when the avatar stands up
542 542
543 AbsolutePosition = AbsolutePosition + new LLVector3(0, 0, (m_avHeight/6)); 543 AbsolutePosition = AbsolutePosition + new LLVector3(0, 0, (m_avHeight/6));
@@ -748,6 +748,15 @@ namespace OpenSim.Region.Environment.Scenes
748 { 748 {
749 if (m_parentID != 0) 749 if (m_parentID != 0)
750 { 750 {
751
752 SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID);
753 if (part != null)
754 {
755 // Reset sit target.
756 if (part.GetAvatarOnSitTarget() == UUID)
757 part.SetAvatarOnSitTarget(LLUUID.Zero);
758 }
759
751 m_pos += m_parentPosition + new LLVector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); 760 m_pos += m_parentPosition + new LLVector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight);
752 m_parentPosition = new LLVector3(); 761 m_parentPosition = new LLVector3();
753 762
@@ -769,34 +778,82 @@ namespace OpenSim.Region.Environment.Scenes
769 778
770 bool autopilot = true; 779 bool autopilot = true;
771 LLVector3 pos = new LLVector3(); 780 LLVector3 pos = new LLVector3();
781 LLQuaternion sitOrientation = new LLQuaternion(0,0,0,1);
772 782
773 SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); 783 SceneObjectPart part = m_scene.GetSceneObjectPart(targetID);
774 if (part != null) 784 if (part != null)
775 { 785 {
776 // TODO: determine position to sit at based on scene geometry; don't trust offset from client 786 // TODO: determine position to sit at based on scene geometry; don't trust offset from client
777 // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it 787 // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it
788
789
790 // Is a sit target available?
791 Vector3 avSitOffSet = part.GetSitTargetPosition();
792 Quaternion avSitOrientation = part.GetSitTargetOrientation();
793 LLUUID avOnTargetAlready = part.GetAvatarOnSitTarget();
794
795 bool SitTargetUnOccupied = (!(avOnTargetAlready != LLUUID.Zero));
796 bool SitTargetisSet = (!(avSitOffSet.x == 0 && avSitOffSet.y == 0 && avSitOffSet.z == 0 && avSitOrientation.w == 0 && avSitOrientation.x == 0 && avSitOrientation.y == 0 && avSitOrientation.z == 1));
797
798 if (SitTargetisSet && SitTargetUnOccupied)
799 {
800 part.SetAvatarOnSitTarget(UUID);
801 offset = new LLVector3(avSitOffSet.x,avSitOffSet.y,avSitOffSet.z);
802 sitOrientation = new LLQuaternion(avSitOrientation.w,avSitOrientation.x,avSitOrientation.y,avSitOrientation.z);
803 autopilot = false;
804
805 }
806
778 807
779 pos = part.AbsolutePosition + offset; 808 pos = part.AbsolutePosition + offset;
780 809
781 if (m_physicsActor != null) 810 if (m_physicsActor != null)
782 { 811 {
812 //
813 // If we're not using the client autopilot, we're immediately warping the avatar to the location
814 // We can remove the physicsActor until they stand up.
815 //
783 m_sitAvatarHeight = m_physicsActor.Size.Z; 816 m_sitAvatarHeight = m_physicsActor.Size.Z;
784 }
785 817
786 // this doesn't seem to quite work yet.... 818 if (autopilot)
787 // // if we're close, set the avatar position to the target position and forgo autopilot 819 {
788 // if (AbsolutePosition.GetDistanceTo(pos) < 2.5) 820
789 // { 821 if (Util.GetDistanceTo(AbsolutePosition, pos) < 4.5)
790 // autopilot = false; 822 {
791 // AbsolutePosition = pos + new LLVector3(0.0f, 0.0f, m_sitAvatarHeight); 823 autopilot = false;
792 // } 824
793 } 825 RemoveFromPhysicalScene();
826 AbsolutePosition = pos + new LLVector3(0.0f, 0.0f, m_sitAvatarHeight);
827
828 }
829 else
830 {
831
832 }
833 }
834 else
835 {
836 RemoveFromPhysicalScene();
837
838
839 }
840 } // Physactor != null
841 } // part != null
842
794 843
795 avatarSitResponse.SitTransform.AutoPilot = autopilot; 844 avatarSitResponse.SitTransform.AutoPilot = autopilot;
796 avatarSitResponse.SitTransform.SitPosition = offset; 845 avatarSitResponse.SitTransform.SitPosition = offset;
797 avatarSitResponse.SitTransform.SitRotation = new LLQuaternion(0.0f, 0.0f, 0.0f, 1.0f); 846 avatarSitResponse.SitTransform.SitRotation = sitOrientation;
798 847
799 remoteClient.OutPacket(avatarSitResponse, ThrottleOutPacketType.Task); 848 remoteClient.OutPacket(avatarSitResponse, ThrottleOutPacketType.Task);
849
850 // This calls HandleAgentSit twice, once from here, and the client calls
851 // HandleAgentSit itself after it gets to the location
852 // It doesn't get to the location until we've moved them there though
853 // which happens in HandleAgentSit :P
854 if (!autopilot)
855 HandleAgentSit(remoteClient, UUID);
856
800 } 857 }
801 858
802 public void HandleAgentRequestSit(IClientAPI remoteClient, LLUUID agentID, LLUUID targetID, LLVector3 offset) 859 public void HandleAgentRequestSit(IClientAPI remoteClient, LLUUID agentID, LLUUID targetID, LLVector3 offset)
@@ -806,7 +863,7 @@ namespace OpenSim.Region.Environment.Scenes
806 StandUp(); 863 StandUp();
807 } 864 }
808 865
809 SendSitResponse(remoteClient, targetID, offset); 866
810 867
811 SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); 868 SceneObjectPart part = m_scene.GetSceneObjectPart(targetID);
812 869
@@ -819,6 +876,7 @@ namespace OpenSim.Region.Environment.Scenes
819 { 876 {
820 MainLog.Instance.Warn("Sit requested on unknown object: " + targetID.ToString()); 877 MainLog.Instance.Warn("Sit requested on unknown object: " + targetID.ToString());
821 } 878 }
879 SendSitResponse(remoteClient, targetID, offset);
822 } 880 }
823 881
824 public void HandleAgentSit(IClientAPI remoteClient, LLUUID agentID) 882 public void HandleAgentSit(IClientAPI remoteClient, LLUUID agentID)
@@ -827,8 +885,28 @@ namespace OpenSim.Region.Environment.Scenes
827 885
828 if (part != null) 886 if (part != null)
829 { 887 {
830 m_pos -= part.AbsolutePosition; 888 if (part.GetAvatarOnSitTarget() == UUID)
831 m_parentPosition = part.AbsolutePosition; 889 {
890 Vector3 sitTargetPos = part.GetSitTargetPosition();
891 Quaternion sitTargetOrient = part.GetSitTargetOrientation();
892
893 //Quaternion vq = new Quaternion(sitTargetPos.x, sitTargetPos.y+0.2f, sitTargetPos.z+0.2f, 0);
894 //Quaternion nq = new Quaternion(sitTargetOrient.w, -sitTargetOrient.x, -sitTargetOrient.y, -sitTargetOrient.z);
895
896 //Quaternion result = (sitTargetOrient * vq) * nq;
897
898 m_pos = new LLVector3(sitTargetPos.x, sitTargetPos.y, sitTargetPos.z);
899 m_bodyRot = sitTargetOrient;
900 //Rotation = sitTargetOrient;
901 m_parentPosition = part.AbsolutePosition;
902
903 //SendTerseUpdateToAllClients();
904 }
905 else
906 {
907 m_pos -= part.AbsolutePosition;
908 m_parentPosition = part.AbsolutePosition;
909 }
832 } 910 }
833 911
834 m_parentID = m_requestedSitTargetID; 912 m_parentID = m_requestedSitTargetID;
@@ -838,6 +916,10 @@ namespace OpenSim.Region.Environment.Scenes
838 916
839 SetMovementAnimation(Animations.AnimsLLUUID["SIT"], 1); 917 SetMovementAnimation(Animations.AnimsLLUUID["SIT"], 1);
840 SendFullUpdateToAllClients(); 918 SendFullUpdateToAllClients();
919 // This may seem stupid, but Our Full updates don't send avatar rotation :P
920 // So we're also sending a terse update (which has avatar rotation)
921 SendTerseUpdateToAllClients();
922
841 } 923 }
842 924
843 /// <summary> 925 /// <summary>