diff options
author | UbitUmarov | 2017-04-04 14:34:25 +0100 |
---|---|---|
committer | UbitUmarov | 2017-04-04 14:34:25 +0100 |
commit | ca250e0b0b564efaaeb5c0b80760126cfd710c5e (patch) | |
tree | 96f82f09fd71d63b380fe732e4e099f4bd4fd5de /OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |
parent | mantis 8130: improve keyframes motion (diff) | |
download | opensim-SC-ca250e0b0b564efaaeb5c0b80760126cfd710c5e.zip opensim-SC-ca250e0b0b564efaaeb5c0b80760126cfd710c5e.tar.gz opensim-SC-ca250e0b0b564efaaeb5c0b80760126cfd710c5e.tar.bz2 opensim-SC-ca250e0b0b564efaaeb5c0b80760126cfd710c5e.tar.xz |
mantis 8740: rename osObjectTeleport as osTeleportObject, replaced the stop parameter by flags, add flags OSTPOBJ_STOPATTARRGET and OSTPOBJ_SETROT
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 24cdc7a..a0d7bfd 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -853,7 +853,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
853 | m_log.DebugFormat("[SCENE OBJECT]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname); | 853 | m_log.DebugFormat("[SCENE OBJECT]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname); |
854 | } | 854 | } |
855 | */ | 855 | */ |
856 | public void ObjectTeleport(UUID sourceID, Vector3 targetPosition, Quaternion rotation, bool stop) | 856 | |
857 | // copy from LSL_constants.cs | ||
858 | const int OSTPOBJ_STOPATTARRGET = 0x1; // stops at destination | ||
859 | const int OSTPOBJ_STOPONFAIL = 0x2; // stops at start if tp fails | ||
860 | const int OSTPOBJ_SETROT = 0x4; // the rotation is the final rotation, otherwise is a added rotation | ||
861 | |||
862 | public void TeleportObject(UUID sourceID, Vector3 targetPosition, Quaternion rotation, int flags) | ||
857 | { | 863 | { |
858 | if(inTransit || IsDeleted || IsAttachmentCheckFull() || IsSelected || Scene == null) | 864 | if(inTransit || IsDeleted || IsAttachmentCheckFull() || IsSelected || Scene == null) |
859 | return; | 865 | return; |
@@ -900,38 +906,44 @@ namespace OpenSim.Region.Framework.Scenes | |||
900 | } | 906 | } |
901 | } | 907 | } |
902 | 908 | ||
909 | bool stop = (flags & OSTPOBJ_STOPATTARRGET) != 0; | ||
910 | bool setrot = (flags & OSTPOBJ_SETROT) != 0; | ||
911 | |||
903 | rotation.Normalize(); | 912 | rotation.Normalize(); |
913 | bool dorot = (Math.Abs(rotation.W) < 0.999); | ||
914 | |||
915 | Quaternion currentRot = RootPart.RotationOffset; | ||
916 | if(dorot && setrot) | ||
917 | rotation = rotation * Quaternion.Conjugate(currentRot); | ||
918 | |||
904 | if(stop) | 919 | if(stop) |
905 | { | 920 | { |
906 | RootPart.Stop(); | 921 | RootPart.Stop(); |
907 | if(Math.Abs(rotation.W) < 0.999) | ||
908 | { | ||
909 | Quaternion rot = RootPart.RotationOffset; | ||
910 | rot *= rotation; | ||
911 | RootPart.RotationOffset = rot; | ||
912 | } | ||
913 | } | 922 | } |
914 | else | 923 | else |
915 | { | 924 | { |
916 | if(Math.Abs(rotation.W) < 0.999) | 925 | if(dorot) |
917 | { | 926 | { |
918 | Quaternion rot = RootPart.RotationOffset; | ||
919 | Vector3 vel = RootPart.Velocity; | 927 | Vector3 vel = RootPart.Velocity; |
920 | Vector3 avel = RootPart.AngularVelocity; | 928 | Vector3 avel = RootPart.AngularVelocity; |
921 | Vector3 acc = RootPart.Acceleration; | 929 | Vector3 acc = RootPart.Acceleration; |
922 | 930 | ||
923 | rot *= rotation; | ||
924 | vel *= rotation; | 931 | vel *= rotation; |
925 | avel *= rotation; | 932 | avel *= rotation; |
926 | acc *= rotation; | 933 | acc *= rotation; |
927 | 934 | ||
928 | RootPart.RotationOffset = rot; | ||
929 | RootPart.Velocity = vel; | 935 | RootPart.Velocity = vel; |
930 | RootPart.AngularVelocity = avel; | 936 | RootPart.AngularVelocity = avel; |
931 | RootPart.Acceleration = acc; | 937 | RootPart.Acceleration = acc; |
932 | } | 938 | } |
933 | } | 939 | } |
934 | 940 | ||
941 | if(dorot) | ||
942 | { | ||
943 | currentRot *= rotation; | ||
944 | RootPart.RotationOffset = currentRot; | ||
945 | } | ||
946 | |||
935 | Vector3 s = RootPart.Scale * RootPart.RotationOffset; | 947 | Vector3 s = RootPart.Scale * RootPart.RotationOffset; |
936 | float h = Scene.GetGroundHeight(posX, posY) + 0.5f * (float)Math.Abs(s.Z) + 0.01f; | 948 | float h = Scene.GetGroundHeight(posX, posY) + 0.5f * (float)Math.Abs(s.Z) + 0.01f; |
937 | if(targetPosition.Z < h) | 949 | if(targetPosition.Z < h) |