diff options
author | UbitUmarov | 2015-11-17 17:41:09 +0000 |
---|---|---|
committer | UbitUmarov | 2015-11-17 17:41:09 +0000 |
commit | da5aad87bff6c42dc5dc2f8408dbc5a30f6d1abb (patch) | |
tree | a4ffba1b2766f20075c44833cad44013119dc8d0 /OpenSim/Region | |
parent | work around some 'tests' errors: UUID.Zero is a invalid ownerID - missing file (diff) | |
download | opensim-SC-da5aad87bff6c42dc5dc2f8408dbc5a30f6d1abb.zip opensim-SC-da5aad87bff6c42dc5dc2f8408dbc5a30f6d1abb.tar.gz opensim-SC-da5aad87bff6c42dc5dc2f8408dbc5a30f6d1abb.tar.bz2 opensim-SC-da5aad87bff6c42dc5dc2f8408dbc5a30f6d1abb.tar.xz |
start adding LegacySitOffsets option. TRUE will prevent the use of new math for the compensation of SL sittarget bug, and so not break content. (this is the main code change)
Diffstat (limited to 'OpenSim/Region')
-rwxr-xr-x | OpenSim/Region/Framework/Scenes/Scene.cs | 9 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 80 |
2 files changed, 70 insertions, 19 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 837a994..55c4fda 100755 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -228,7 +228,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
228 | public bool m_allowScriptCrossings = true; | 228 | public bool m_allowScriptCrossings = true; |
229 | 229 | ||
230 | /// <summary> | 230 | /// <summary> |
231 | 231 | /// use legacy sittarget offsets to avoid contents breaks | |
232 | /// to compensate for SL bug | ||
233 | /// </summary> | ||
234 | public bool LegacySitOffsets = true; | ||
235 | |||
236 | /// <summary> | ||
232 | /// Can avatars cross from and to this region? | 237 | /// Can avatars cross from and to this region? |
233 | /// </summary> | 238 | /// </summary> |
234 | public bool AllowAvatarCrossing { get; set; } | 239 | public bool AllowAvatarCrossing { get; set; } |
@@ -960,6 +965,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
960 | m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance", m_defaultDrawDistance); | 965 | m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance", m_defaultDrawDistance); |
961 | m_maxDrawDistance = startupConfig.GetFloat("MaxDrawDistance", m_maxDrawDistance); | 966 | m_maxDrawDistance = startupConfig.GetFloat("MaxDrawDistance", m_maxDrawDistance); |
962 | 967 | ||
968 | LegacySitOffsets = startupConfig.GetBoolean("LegacyOpenSimSitOffsets", LegacySitOffsets); | ||
969 | |||
963 | if (m_defaultDrawDistance > m_maxDrawDistance) | 970 | if (m_defaultDrawDistance > m_maxDrawDistance) |
964 | m_defaultDrawDistance = m_maxDrawDistance; | 971 | m_defaultDrawDistance = m_maxDrawDistance; |
965 | 972 | ||
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index c3deeaf..fd647e1 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -144,6 +144,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
144 | /// issue #1716 | 144 | /// issue #1716 |
145 | /// </summary> | 145 | /// </summary> |
146 | public static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.4f); | 146 | public static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.4f); |
147 | public bool LegacySitOffsets = true; | ||
147 | 148 | ||
148 | /// <summary> | 149 | /// <summary> |
149 | /// Movement updates for agents in neighboring regions are sent directly to clients. | 150 | /// Movement updates for agents in neighboring regions are sent directly to clients. |
@@ -1003,6 +1004,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1003 | m_name = String.Format("{0} {1}", Firstname, Lastname); | 1004 | m_name = String.Format("{0} {1}", Firstname, Lastname); |
1004 | m_uuid = client.AgentId; | 1005 | m_uuid = client.AgentId; |
1005 | LocalId = m_scene.AllocateLocalId(); | 1006 | LocalId = m_scene.AllocateLocalId(); |
1007 | LegacySitOffsets = m_scene.LegacySitOffsets; | ||
1006 | 1008 | ||
1007 | UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid); | 1009 | UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid); |
1008 | if (account != null) | 1010 | if (account != null) |
@@ -3211,30 +3213,72 @@ namespace OpenSim.Region.Framework.Scenes | |||
3211 | // "[SCENE PRESENCE]: Sitting {0} at sit target {1}, {2} on {3} {4}", | 3213 | // "[SCENE PRESENCE]: Sitting {0} at sit target {1}, {2} on {3} {4}", |
3212 | // Name, sitTargetPos, sitTargetOrient, part.Name, part.LocalId); | 3214 | // Name, sitTargetPos, sitTargetOrient, part.Name, part.LocalId); |
3213 | 3215 | ||
3214 | //Quaternion vq = new Quaternion(sitTargetPos.X, sitTargetPos.Y+0.2f, sitTargetPos.Z+0.2f, 0); | ||
3215 | //Quaternion nq = new Quaternion(-sitTargetOrient.X, -sitTargetOrient.Y, -sitTargetOrient.Z, sitTargetOrient.w); | ||
3216 | |||
3217 | //Quaternion result = (sitTargetOrient * vq) * nq; | ||
3218 | |||
3219 | double x, y, z, m; | 3216 | double x, y, z, m; |
3220 | 3217 | Vector3 sitOffset; | |
3221 | Quaternion r = sitTargetOrient; | 3218 | Quaternion r = sitTargetOrient; |
3222 | m = r.X * r.X + r.Y * r.Y + r.Z * r.Z + r.W * r.W; | ||
3223 | 3219 | ||
3224 | if (Math.Abs(1.0 - m) > 0.000001) | 3220 | if(LegacySitOffsets) |
3225 | { | 3221 | { |
3226 | m = 1.0 / Math.Sqrt(m); | 3222 | double m1,m2; |
3227 | r.X *= (float)m; | 3223 | |
3228 | r.Y *= (float)m; | 3224 | m1 = r.X * r.X + r.Y * r.Y; |
3229 | r.Z *= (float)m; | 3225 | m2 = r.Z * r.Z + r.W * r.W; |
3230 | r.W *= (float)m; | 3226 | |
3227 | // Rotate the vector <0, 0, 1> | ||
3228 | x = 2 * (r.X * r.Z + r.Y * r.W); | ||
3229 | y = 2 * (-r.X * r.W + r.Y * r.Z); | ||
3230 | z = m2 - m1; | ||
3231 | |||
3232 | // Set m to be the square of the norm of r. | ||
3233 | m = m1 + m2; | ||
3234 | |||
3235 | // This constant is emperically determined to be what is used in SL. | ||
3236 | // See also http://opensimulator.org/mantis/view.php?id=7096 | ||
3237 | double offset = 0.05; | ||
3238 | |||
3239 | // Normally m will be ~ 1, but if someone passed a handcrafted quaternion | ||
3240 | // to llSitTarget with values so small that squaring them is rounded off | ||
3241 | // to zero, then m could be zero. The result of this floating point | ||
3242 | // round off error (causing us to skip this impossible normalization) | ||
3243 | // is only 5 cm. | ||
3244 | if (m > 0.000001) | ||
3245 | { | ||
3246 | offset /= m; | ||
3247 | } | ||
3248 | |||
3249 | Vector3 up = new Vector3((float)x, (float)y, (float)z); | ||
3250 | sitOffset = up * (float)offset; | ||
3231 | } | 3251 | } |
3252 | else | ||
3253 | { | ||
3254 | m = r.X * r.X + r.Y * r.Y + r.Z * r.Z + r.W * r.W; | ||
3255 | |||
3256 | if (Math.Abs(1.0 - m) > 0.000001) | ||
3257 | { | ||
3258 | if(m != 0) | ||
3259 | { | ||
3260 | m = 1.0 / Math.Sqrt(m); | ||
3261 | r.X *= (float)m; | ||
3262 | r.Y *= (float)m; | ||
3263 | r.Z *= (float)m; | ||
3264 | r.W *= (float)m; | ||
3265 | } | ||
3266 | else | ||
3267 | { | ||
3268 | r.X = 0.0f; | ||
3269 | r.Y = 0.0f; | ||
3270 | r.Z = 0.0f; | ||
3271 | r.W = 1.0f; | ||
3272 | m = 1.0f; | ||
3273 | } | ||
3274 | } | ||
3232 | 3275 | ||
3233 | x = 2 * (r.X * r.Z + r.Y * r.W); | 3276 | x = 2 * (r.X * r.Z + r.Y * r.W); |
3234 | y = 2 * (-r.X * r.W + r.Y * r.Z); | 3277 | y = 2 * (-r.X * r.W + r.Y * r.Z); |
3235 | z = -r.X * r.X - r.Y * r.Y + r.Z * r.Z + r.W * r.W; | 3278 | z = -r.X * r.X - r.Y * r.Y + r.Z * r.Z + r.W * r.W; |
3236 | Vector3 up = new Vector3((float)x, (float)y, (float)z); | 3279 | Vector3 up = new Vector3((float)x, (float)y, (float)z); |
3237 | Vector3 sitOffset = up * Appearance.AvatarHeight * 0.02638f; | 3280 | sitOffset = up * Appearance.AvatarHeight * 0.02638f; |
3281 | } | ||
3238 | 3282 | ||
3239 | Vector3 newPos = sitTargetPos + sitOffset + SIT_TARGET_ADJUSTMENT; | 3283 | Vector3 newPos = sitTargetPos + sitOffset + SIT_TARGET_ADJUSTMENT; |
3240 | Quaternion newRot; | 3284 | Quaternion newRot; |