diff options
author | Tom | 2011-03-28 13:28:59 -0700 |
---|---|---|
committer | Tom | 2011-03-28 13:28:59 -0700 |
commit | c39b391b6ac52e13fddc1e3362cce681cd35b1ec (patch) | |
tree | 6bc6dad433b1965dcc08d7fd4f3984a75cf21a75 /OpenSim/Region/ScriptEngine/Shared | |
parent | Flag root prim changes for persistence (diff) | |
download | opensim-SC-c39b391b6ac52e13fddc1e3362cce681cd35b1ec.zip opensim-SC-c39b391b6ac52e13fddc1e3362cce681cd35b1ec.tar.gz opensim-SC-c39b391b6ac52e13fddc1e3362cce681cd35b1ec.tar.bz2 opensim-SC-c39b391b6ac52e13fddc1e3362cce681cd35b1ec.tar.xz |
Many scripted items use long lists of llSetLinkPrimitiveParams rules to make prims "teleport" or jump large distances. When teleporting to 10,000 meters, this results in 1,000 SetPos calls, which severely rapes the physics and update system. This change modifies this behaviour to only provide one update after all the rules have been executed.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 52 |
1 files changed, 43 insertions, 9 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 559523b..bba0c3b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -2113,13 +2113,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2113 | return end; | 2113 | return end; |
2114 | } | 2114 | } |
2115 | 2115 | ||
2116 | protected void SetPos(SceneObjectPart part, LSL_Vector targetPos) | 2116 | protected LSL_Vector GetSetPosTarget(SceneObjectPart part, LSL_Vector targetPos, LSL_Vector fromPos) |
2117 | { | 2117 | { |
2118 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | 2118 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
2119 | return; | 2119 | return fromPos; |
2120 | 2120 | ||
2121 | // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) | 2121 | // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) |
2122 | LSL_Vector currentPos = GetPartLocalPos(part); | 2122 | |
2123 | 2123 | ||
2124 | float ground = World.GetGroundHeight((float)targetPos.x, (float)targetPos.y); | 2124 | float ground = World.GetGroundHeight((float)targetPos.x, (float)targetPos.y); |
2125 | bool disable_underground_movement = m_ScriptEngine.Config.GetBoolean("DisableUndergroundMovement", true); | 2125 | bool disable_underground_movement = m_ScriptEngine.Config.GetBoolean("DisableUndergroundMovement", true); |
@@ -2128,14 +2128,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2128 | { | 2128 | { |
2129 | if ((targetPos.z < ground) && disable_underground_movement && m_host.AttachmentPoint == 0) | 2129 | if ((targetPos.z < ground) && disable_underground_movement && m_host.AttachmentPoint == 0) |
2130 | targetPos.z = ground; | 2130 | targetPos.z = ground; |
2131 | } | ||
2132 | LSL_Vector real_vec = SetPosAdjust(fromPos, targetPos); | ||
2133 | |||
2134 | return real_vec; | ||
2135 | } | ||
2136 | |||
2137 | protected void SetPos(SceneObjectPart part, LSL_Vector targetPos) | ||
2138 | { | ||
2139 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2140 | return; | ||
2141 | |||
2142 | LSL_Vector currentPos = GetPartLocalPos(part); | ||
2143 | LSL_Vector toPos = GetSetPosTarget(part, targetPos, currentPos); | ||
2144 | |||
2145 | if (part.ParentGroup.RootPart == part) | ||
2146 | { | ||
2131 | SceneObjectGroup parent = part.ParentGroup; | 2147 | SceneObjectGroup parent = part.ParentGroup; |
2132 | LSL_Vector real_vec = SetPosAdjust(currentPos, targetPos); | 2148 | parent.UpdateGroupPosition(new Vector3((float)toPos.x, (float)toPos.y, (float)toPos.z)); |
2133 | parent.UpdateGroupPosition(new Vector3((float)real_vec.x, (float)real_vec.y, (float)real_vec.z)); | ||
2134 | } | 2149 | } |
2135 | else | 2150 | else |
2136 | { | 2151 | { |
2137 | LSL_Vector rel_vec = SetPosAdjust(new LSL_Vector(part.OffsetPosition.X, part.OffsetPosition.Y, part.OffsetPosition.Z), targetPos); | 2152 | part.OffsetPosition = new Vector3((float)toPos.x, (float)toPos.y, (float)toPos.z); |
2138 | part.OffsetPosition = new Vector3((float)rel_vec.x, (float)rel_vec.y, (float)rel_vec.z); | ||
2139 | SceneObjectGroup parent = part.ParentGroup; | 2153 | SceneObjectGroup parent = part.ParentGroup; |
2140 | parent.HasGroupChanged = true; | 2154 | parent.HasGroupChanged = true; |
2141 | parent.ScheduleGroupForTerseUpdate(); | 2155 | parent.ScheduleGroupForTerseUpdate(); |
@@ -7401,6 +7415,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7401 | 7415 | ||
7402 | int idx = 0; | 7416 | int idx = 0; |
7403 | 7417 | ||
7418 | bool positionChanged = false; | ||
7419 | LSL_Vector currentPosition = GetPartLocalPos(part); | ||
7420 | |||
7404 | while (idx < rules.Length) | 7421 | while (idx < rules.Length) |
7405 | { | 7422 | { |
7406 | int code = rules.GetLSLIntegerItem(idx++); | 7423 | int code = rules.GetLSLIntegerItem(idx++); |
@@ -7409,7 +7426,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7409 | 7426 | ||
7410 | int face; | 7427 | int face; |
7411 | LSL_Vector v; | 7428 | LSL_Vector v; |
7412 | 7429 | ||
7413 | switch (code) | 7430 | switch (code) |
7414 | { | 7431 | { |
7415 | case (int)ScriptBaseClass.PRIM_POSITION: | 7432 | case (int)ScriptBaseClass.PRIM_POSITION: |
@@ -7417,7 +7434,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7417 | return; | 7434 | return; |
7418 | 7435 | ||
7419 | v=rules.GetVector3Item(idx++); | 7436 | v=rules.GetVector3Item(idx++); |
7420 | SetPos(part, v); | 7437 | positionChanged = true; |
7438 | currentPosition = GetSetPosTarget(part, v, currentPosition); | ||
7421 | 7439 | ||
7422 | break; | 7440 | break; |
7423 | case (int)ScriptBaseClass.PRIM_SIZE: | 7441 | case (int)ScriptBaseClass.PRIM_SIZE: |
@@ -7785,6 +7803,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7785 | break; | 7803 | break; |
7786 | } | 7804 | } |
7787 | } | 7805 | } |
7806 | |||
7807 | if (positionChanged) | ||
7808 | { | ||
7809 | if (part.ParentGroup.RootPart == part) | ||
7810 | { | ||
7811 | SceneObjectGroup parent = part.ParentGroup; | ||
7812 | parent.UpdateGroupPosition(new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z)); | ||
7813 | } | ||
7814 | else | ||
7815 | { | ||
7816 | part.OffsetPosition = new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z); | ||
7817 | SceneObjectGroup parent = part.ParentGroup; | ||
7818 | parent.HasGroupChanged = true; | ||
7819 | parent.ScheduleGroupForTerseUpdate(); | ||
7820 | } | ||
7821 | } | ||
7788 | } | 7822 | } |
7789 | 7823 | ||
7790 | public LSL_String llStringToBase64(string str) | 7824 | public LSL_String llStringToBase64(string str) |