diff options
author | UbitUmarov | 2012-06-12 05:57:28 +0100 |
---|---|---|
committer | UbitUmarov | 2012-06-12 05:57:28 +0100 |
commit | 5784b3eb31d5798f996c134f0d3433570dbee736 (patch) | |
tree | db0c41fd03737d3ef32ca99bf0660b18ab8f0aa4 /OpenSim/Region/ScriptEngine/Shared/Api | |
parent | more changes to Get and Get primitiveparams: Let Get remove avatarheight adj... (diff) | |
download | opensim-SC-5784b3eb31d5798f996c134f0d3433570dbee736.zip opensim-SC-5784b3eb31d5798f996c134f0d3433570dbee736.tar.gz opensim-SC-5784b3eb31d5798f996c134f0d3433570dbee736.tar.bz2 opensim-SC-5784b3eb31d5798f996c134f0d3433570dbee736.tar.xz |
fix the try.. finally in SetPrimitiveParams i did mess and add one for the avatars case, so to optimize a bit 'warp' scripts.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 344 |
1 files changed, 156 insertions, 188 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 5760b36..ec4f62f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -7932,205 +7932,193 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7932 | int idx = 0; | 7932 | int idx = 0; |
7933 | SceneObjectPart sitpart = World.GetSceneObjectPart(av.ParentID); // betting this will be used | 7933 | SceneObjectPart sitpart = World.GetSceneObjectPart(av.ParentID); // betting this will be used |
7934 | 7934 | ||
7935 | while (idx < rules.Length) | 7935 | bool positionChanged = false; |
7936 | Vector3 finalPos = Vector3.Zero; | ||
7937 | |||
7938 | try | ||
7936 | { | 7939 | { |
7937 | int code = rules.GetLSLIntegerItem(idx++); | 7940 | while (idx < rules.Length) |
7941 | { | ||
7942 | int code = rules.GetLSLIntegerItem(idx++); | ||
7938 | 7943 | ||
7939 | int remain = rules.Length - idx; | 7944 | int remain = rules.Length - idx; |
7940 | 7945 | ||
7941 | switch (code) | 7946 | switch (code) |
7942 | { | 7947 | { |
7943 | // a avatar is a child | 7948 | // a avatar is a child |
7944 | case (int)ScriptBaseClass.PRIM_POSITION: | 7949 | case (int)ScriptBaseClass.PRIM_POSITION: |
7945 | case (int)ScriptBaseClass.PRIM_POS_LOCAL: | 7950 | case (int)ScriptBaseClass.PRIM_POS_LOCAL: |
7946 | { | ||
7947 | if (remain < 1) | ||
7948 | return; | ||
7949 | LSL_Vector v; | ||
7950 | v = rules.GetVector3Item(idx++); | ||
7951 | |||
7952 | /* use the sitpart | ||
7953 | SceneObjectPart part = World.GetSceneObjectPart(av.ParentID); | ||
7954 | if (part == null) | ||
7955 | break; | ||
7956 | |||
7957 | LSL_Rotation localRot = ScriptBaseClass.ZERO_ROTATION; | ||
7958 | LSL_Vector localPos = ScriptBaseClass.ZERO_VECTOR; | ||
7959 | if (llGetLinkNumber() > 1) | ||
7960 | { | 7951 | { |
7961 | localRot = llGetLocalRot(); | 7952 | if (remain < 1) |
7962 | localPos = llGetLocalPos(); | 7953 | return; |
7963 | } | 7954 | LSL_Vector v; |
7955 | v = rules.GetVector3Item(idx++); | ||
7964 | 7956 | ||
7965 | v -= localPos; | 7957 | if (sitpart == null) |
7966 | v /= localRot; | 7958 | break; |
7967 | */ | ||
7968 | if (sitpart == null) | ||
7969 | break; | ||
7970 | 7959 | ||
7971 | Vector3 pos = new Vector3((float)v.x, (float)v.y, (float)v.z); // requested absolute position | 7960 | Vector3 pos = new Vector3((float)v.x, (float)v.y, (float)v.z); // requested absolute position |
7972 | 7961 | ||
7973 | pos -= sitpart.OffsetPosition; // remove sit part offset | 7962 | pos -= sitpart.OffsetPosition; // remove sit part offset |
7974 | 7963 | ||
7975 | Quaternion rot = sitpart.RotationOffset; | 7964 | Quaternion rot = sitpart.RotationOffset; |
7976 | pos *= Quaternion.Conjugate(rot); // removed sit part rotation | 7965 | pos *= Quaternion.Conjugate(rot); // removed sit part rotation |
7977 | 7966 | ||
7978 | Vector3 sitOffset = (Zrot(av.Rotation)) * (av.Appearance.AvatarHeight * 0.02638f); | 7967 | Vector3 sitOffset = (Zrot(av.Rotation)) * (av.Appearance.AvatarHeight * 0.02638f); |
7968 | pos += sitOffset; | ||
7979 | 7969 | ||
7980 | pos += sitOffset; | 7970 | finalPos = pos; |
7971 | positionChanged = true; | ||
7972 | } | ||
7973 | break; | ||
7981 | 7974 | ||
7982 | av.OffsetPosition = pos; | 7975 | case (int)ScriptBaseClass.PRIM_ROTATION: |
7983 | av.SendAvatarDataToAllAgents(); | 7976 | { |
7984 | } | 7977 | if (remain < 1) |
7985 | break; | 7978 | return; |
7986 | 7979 | ||
7980 | if (sitpart == null) | ||
7981 | break; | ||
7987 | 7982 | ||
7988 | case (int)ScriptBaseClass.PRIM_ROTATION: | 7983 | LSL_Rotation r = rules.GetQuaternionItem(idx++); |
7989 | { | 7984 | Quaternion rot = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); // requested world rotation |
7990 | if (remain < 1) | 7985 | |
7991 | return; | 7986 | Quaternion srot = sitpart.GetWorldRotation(); |
7992 | /* | 7987 | rot *= Quaternion.Conjugate(srot); // removed sit part world rotation |
7993 | LSL_Rotation localRot = ScriptBaseClass.ZERO_ROTATION; | 7988 | |
7994 | LSL_Vector localPos = ScriptBaseClass.ZERO_VECTOR; | 7989 | av.Rotation = rot; |
7995 | if (llGetLinkNumber() > 1) | 7990 | av.SendAvatarDataToAllAgents(); |
7996 | { | ||
7997 | localRot = llGetLocalRot(); | ||
7998 | localPos = llGetLocalPos(); | ||
7999 | } | 7991 | } |
7992 | break; | ||
8000 | 7993 | ||
8001 | LSL_Rotation r; | 7994 | case (int)ScriptBaseClass.PRIM_ROT_LOCAL: |
8002 | r = rules.GetQuaternionItem(idx++); | 7995 | { |
8003 | r = r * llGetRootRotation() / localRot; | 7996 | if (remain < 1) |
8004 | av.Rotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); | 7997 | return; |
8005 | */ | 7998 | |
8006 | if (sitpart == null) | 7999 | if (sitpart == null) |
8007 | break; | 8000 | break; |
8008 | 8001 | ||
8009 | LSL_Rotation r = rules.GetQuaternionItem(idx++); | 8002 | LSL_Rotation r = rules.GetQuaternionItem(idx++); |
8010 | Quaternion rot = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); // requested world rotation | 8003 | Quaternion rot = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); // requested offset rotation |
8011 | |||
8012 | Quaternion srot = sitpart.GetWorldRotation(); | ||
8013 | rot *= Quaternion.Conjugate(srot); // removed sit part world rotation | ||
8014 | 8004 | ||
8015 | av.Rotation = rot; | 8005 | Quaternion srot = sitpart.RotationOffset; |
8016 | av.SendAvatarDataToAllAgents(); | 8006 | rot *= Quaternion.Conjugate(srot); // remove sit part offset rotation |
8017 | } | ||
8018 | break; | ||
8019 | 8007 | ||
8020 | case (int)ScriptBaseClass.PRIM_ROT_LOCAL: | 8008 | av.Rotation = rot; |
8021 | { | 8009 | av.SendAvatarDataToAllAgents(); |
8010 | } | ||
8011 | break; | ||
8012 | |||
8013 | // parse rest doing nothing but number of parameters error check | ||
8014 | case (int)ScriptBaseClass.PRIM_SIZE: | ||
8015 | case (int)ScriptBaseClass.PRIM_MATERIAL: | ||
8016 | case (int)ScriptBaseClass.PRIM_PHANTOM: | ||
8017 | case (int)ScriptBaseClass.PRIM_PHYSICS: | ||
8018 | case (int)ScriptBaseClass.PRIM_PHYSICS_SHAPE_TYPE: | ||
8019 | case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: | ||
8020 | case (int)ScriptBaseClass.PRIM_NAME: | ||
8021 | case (int)ScriptBaseClass.PRIM_DESC: | ||
8022 | if (remain < 1) | 8022 | if (remain < 1) |
8023 | return; | 8023 | return; |
8024 | /* | 8024 | idx++; |
8025 | LSL_Rotation r; | 8025 | break; |
8026 | r = rules.GetQuaternionItem(idx++); | ||
8027 | av.Rotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); | ||
8028 | av.SendAvatarDataToAllAgents(); | ||
8029 | */ | ||
8030 | if (sitpart == null) | ||
8031 | break; | ||
8032 | 8026 | ||
8033 | LSL_Rotation r = rules.GetQuaternionItem(idx++); | 8027 | case (int)ScriptBaseClass.PRIM_GLOW: |
8034 | Quaternion rot = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); // requested offset rotation | 8028 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: |
8029 | case (int)ScriptBaseClass.PRIM_TEXGEN: | ||
8030 | if (remain < 2) | ||
8031 | return; | ||
8032 | idx += 2; | ||
8033 | break; | ||
8035 | 8034 | ||
8036 | Quaternion srot = sitpart.RotationOffset; | 8035 | case (int)ScriptBaseClass.PRIM_TYPE: |
8037 | rot *= Quaternion.Conjugate(srot); // remove sit part offset rotation | 8036 | if (remain < 3) |
8037 | return; | ||
8038 | code = (int)rules.GetLSLIntegerItem(idx++); | ||
8039 | remain = rules.Length - idx; | ||
8040 | switch (code) | ||
8041 | { | ||
8042 | case (int)ScriptBaseClass.PRIM_TYPE_BOX: | ||
8043 | case (int)ScriptBaseClass.PRIM_TYPE_CYLINDER: | ||
8044 | case (int)ScriptBaseClass.PRIM_TYPE_PRISM: | ||
8045 | if (remain < 6) | ||
8046 | return; | ||
8047 | idx += 6; | ||
8048 | break; | ||
8038 | 8049 | ||
8039 | av.Rotation = rot; | 8050 | case (int)ScriptBaseClass.PRIM_TYPE_SPHERE: |
8040 | av.SendAvatarDataToAllAgents(); | 8051 | if (remain < 5) |
8041 | } | 8052 | return; |
8042 | break; | 8053 | idx += 5; |
8054 | break; | ||
8043 | 8055 | ||
8044 | // parse rest doing nothing but number of parameters error check | 8056 | case (int)ScriptBaseClass.PRIM_TYPE_TORUS: |
8045 | case (int)ScriptBaseClass.PRIM_SIZE: | 8057 | case (int)ScriptBaseClass.PRIM_TYPE_TUBE: |
8046 | case (int)ScriptBaseClass.PRIM_MATERIAL: | 8058 | case (int)ScriptBaseClass.PRIM_TYPE_RING: |
8047 | case (int)ScriptBaseClass.PRIM_PHANTOM: | 8059 | if (remain < 11) |
8048 | case (int)ScriptBaseClass.PRIM_PHYSICS: | 8060 | return; |
8049 | case (int)ScriptBaseClass.PRIM_PHYSICS_SHAPE_TYPE: | 8061 | idx += 11; |
8050 | case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: | 8062 | break; |
8051 | case (int)ScriptBaseClass.PRIM_NAME: | ||
8052 | case (int)ScriptBaseClass.PRIM_DESC: | ||
8053 | if (remain < 1) | ||
8054 | return; | ||
8055 | idx++; | ||
8056 | break; | ||
8057 | 8063 | ||
8058 | case (int)ScriptBaseClass.PRIM_GLOW: | 8064 | case (int)ScriptBaseClass.PRIM_TYPE_SCULPT: |
8059 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: | 8065 | if (remain < 2) |
8060 | case (int)ScriptBaseClass.PRIM_TEXGEN: | 8066 | return; |
8061 | if (remain < 2) | 8067 | idx += 2; |
8062 | return; | 8068 | break; |
8063 | idx += 2; | 8069 | } |
8064 | break; | 8070 | break; |
8065 | 8071 | ||
8066 | case (int)ScriptBaseClass.PRIM_TYPE: | 8072 | case (int)ScriptBaseClass.PRIM_COLOR: |
8067 | if (remain < 3) | 8073 | case (int)ScriptBaseClass.PRIM_TEXT: |
8068 | return; | 8074 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: |
8069 | code = (int)rules.GetLSLIntegerItem(idx++); | 8075 | case (int)ScriptBaseClass.PRIM_OMEGA: |
8070 | remain = rules.Length - idx; | 8076 | if (remain < 3) |
8071 | switch (code) | 8077 | return; |
8072 | { | 8078 | idx += 3; |
8073 | case (int)ScriptBaseClass.PRIM_TYPE_BOX: | 8079 | break; |
8074 | case (int)ScriptBaseClass.PRIM_TYPE_CYLINDER: | ||
8075 | case (int)ScriptBaseClass.PRIM_TYPE_PRISM: | ||
8076 | if (remain < 6) | ||
8077 | return; | ||
8078 | idx += 6; | ||
8079 | break; | ||
8080 | 8080 | ||
8081 | case (int)ScriptBaseClass.PRIM_TYPE_SPHERE: | 8081 | case (int)ScriptBaseClass.PRIM_TEXTURE: |
8082 | if (remain < 5) | 8082 | case (int)ScriptBaseClass.PRIM_POINT_LIGHT: |
8083 | return; | 8083 | case (int)ScriptBaseClass.PRIM_PHYSICS_MATERIAL: |
8084 | idx += 5; | 8084 | if (remain < 5) |
8085 | break; | 8085 | return; |
8086 | idx += 5; | ||
8087 | break; | ||
8086 | 8088 | ||
8087 | case (int)ScriptBaseClass.PRIM_TYPE_TORUS: | 8089 | case (int)ScriptBaseClass.PRIM_FLEXIBLE: |
8088 | case (int)ScriptBaseClass.PRIM_TYPE_TUBE: | 8090 | if (remain < 7) |
8089 | case (int)ScriptBaseClass.PRIM_TYPE_RING: | 8091 | return; |
8090 | if (remain < 11) | ||
8091 | return; | ||
8092 | idx += 11; | ||
8093 | break; | ||
8094 | 8092 | ||
8095 | case (int)ScriptBaseClass.PRIM_TYPE_SCULPT: | 8093 | idx += 7; |
8096 | if (remain < 2) | 8094 | break; |
8097 | return; | ||
8098 | idx += 2; | ||
8099 | break; | ||
8100 | } | ||
8101 | break; | ||
8102 | 8095 | ||
8103 | case (int)ScriptBaseClass.PRIM_COLOR: | 8096 | case (int)ScriptBaseClass.PRIM_LINK_TARGET: |
8104 | case (int)ScriptBaseClass.PRIM_TEXT: | 8097 | if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. |
8105 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: | 8098 | return; |
8106 | case (int)ScriptBaseClass.PRIM_OMEGA: | ||
8107 | if (remain < 3) | ||
8108 | return; | ||
8109 | idx += 3; | ||
8110 | break; | ||
8111 | 8099 | ||
8112 | case (int)ScriptBaseClass.PRIM_TEXTURE: | 8100 | if (positionChanged) |
8113 | case (int)ScriptBaseClass.PRIM_POINT_LIGHT: | 8101 | { |
8114 | case (int)ScriptBaseClass.PRIM_PHYSICS_MATERIAL: | 8102 | positionChanged = false; |
8115 | if (remain < 5) | 8103 | av.OffsetPosition = finalPos; |
8116 | return; | 8104 | av.SendAvatarDataToAllAgents(); |
8117 | idx += 5; | 8105 | } |
8118 | break; | ||
8119 | 8106 | ||
8120 | case (int)ScriptBaseClass.PRIM_FLEXIBLE: | 8107 | LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++); |
8121 | if (remain < 7) | 8108 | LSL_List new_rules = rules.GetSublist(idx, -1); |
8109 | setLinkPrimParams((int)new_linknumber, new_rules); | ||
8122 | return; | 8110 | return; |
8111 | } | ||
8112 | } | ||
8113 | } | ||
8123 | 8114 | ||
8124 | idx += 7; | 8115 | finally |
8125 | break; | 8116 | { |
8126 | 8117 | if (positionChanged) | |
8127 | case (int)ScriptBaseClass.PRIM_LINK_TARGET: | 8118 | { |
8128 | if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. | 8119 | av.OffsetPosition = finalPos; |
8129 | return; | 8120 | av.SendAvatarDataToAllAgents(); |
8130 | LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++); | 8121 | positionChanged = false; |
8131 | LSL_List new_rules = rules.GetSublist(idx, -1); | ||
8132 | setLinkPrimParams((int)new_linknumber, new_rules); | ||
8133 | return; | ||
8134 | } | 8122 | } |
8135 | } | 8123 | } |
8136 | } | 8124 | } |
@@ -8166,8 +8154,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8166 | return; | 8154 | return; |
8167 | 8155 | ||
8168 | v=rules.GetVector3Item(idx++); | 8156 | v=rules.GetVector3Item(idx++); |
8169 | positionChanged = true; | ||
8170 | currentPosition = GetSetPosTarget(part, v, currentPosition); | 8157 | currentPosition = GetSetPosTarget(part, v, currentPosition); |
8158 | positionChanged = true; | ||
8171 | 8159 | ||
8172 | break; | 8160 | break; |
8173 | case (int)ScriptBaseClass.PRIM_SIZE: | 8161 | case (int)ScriptBaseClass.PRIM_SIZE: |
@@ -8549,13 +8537,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8549 | LSL_Float gain = rules.GetLSLFloatItem(idx++); | 8537 | LSL_Float gain = rules.GetLSLFloatItem(idx++); |
8550 | TargetOmega(part, axis, (double)spinrate, (double)gain); | 8538 | TargetOmega(part, axis, (double)spinrate, (double)gain); |
8551 | break; | 8539 | break; |
8540 | |||
8552 | case (int)ScriptBaseClass.PRIM_LINK_TARGET: | 8541 | case (int)ScriptBaseClass.PRIM_LINK_TARGET: |
8553 | if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. | 8542 | if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. |
8554 | return; | 8543 | return; |
8555 | 8544 | ||
8556 | // do a pending position change | 8545 | // do a pending position change before jumping to other part/avatar |
8557 | if (positionChanged) | 8546 | if (positionChanged) |
8558 | { | 8547 | { |
8548 | positionChanged = false; | ||
8559 | if (parentgrp == null) | 8549 | if (parentgrp == null) |
8560 | return; | 8550 | return; |
8561 | 8551 | ||
@@ -8584,7 +8574,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8584 | } | 8574 | } |
8585 | finally | 8575 | finally |
8586 | { | 8576 | { |
8587 | /* | ||
8588 | if (positionChanged) | 8577 | if (positionChanged) |
8589 | { | 8578 | { |
8590 | if (part.ParentGroup.RootPart == part) | 8579 | if (part.ParentGroup.RootPart == part) |
@@ -8602,27 +8591,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8602 | parent.ScheduleGroupForTerseUpdate(); | 8591 | parent.ScheduleGroupForTerseUpdate(); |
8603 | } | 8592 | } |
8604 | } | 8593 | } |
8605 | */ | ||
8606 | } | ||
8607 | |||
8608 | if (positionChanged) | ||
8609 | { | ||
8610 | if (parentgrp == null) | ||
8611 | return; | ||
8612 | |||
8613 | if (parentgrp.RootPart == part) | ||
8614 | { | ||
8615 | |||
8616 | Util.FireAndForget(delegate(object x) { | ||
8617 | parentgrp.UpdateGroupPosition(new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z)); | ||
8618 | }); | ||
8619 | } | ||
8620 | else | ||
8621 | { | ||
8622 | part.OffsetPosition = new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z); | ||
8623 | parentgrp.HasGroupChanged = true; | ||
8624 | parentgrp.ScheduleGroupForTerseUpdate(); | ||
8625 | } | ||
8626 | } | 8594 | } |
8627 | } | 8595 | } |
8628 | 8596 | ||