diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 178 |
1 files changed, 165 insertions, 13 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 065d3df..c3d4306 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -7905,7 +7905,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7905 | protected void SetPrimParams(ScenePresence av, LSL_List rules) | 7905 | protected void SetPrimParams(ScenePresence av, LSL_List rules) |
7906 | { | 7906 | { |
7907 | //This is a special version of SetPrimParams to deal with avatars which are sat on the linkset. | 7907 | //This is a special version of SetPrimParams to deal with avatars which are sat on the linkset. |
7908 | //We only support PRIM_POSITION and PRIM_ROTATION | ||
7909 | 7908 | ||
7910 | int idx = 0; | 7909 | int idx = 0; |
7911 | 7910 | ||
@@ -7940,7 +7939,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7940 | v /= localRot; | 7939 | v /= localRot; |
7941 | 7940 | ||
7942 | LSL_Vector sitOffset = (llRot2Up(new LSL_Rotation(av.Rotation.X, av.Rotation.Y, av.Rotation.Z, av.Rotation.W)) * av.Appearance.AvatarHeight * 0.02638f); | 7941 | LSL_Vector sitOffset = (llRot2Up(new LSL_Rotation(av.Rotation.X, av.Rotation.Y, av.Rotation.Z, av.Rotation.W)) * av.Appearance.AvatarHeight * 0.02638f); |
7943 | 7942 | ||
7944 | v = v + 2 * sitOffset; | 7943 | v = v + 2 * sitOffset; |
7945 | 7944 | ||
7946 | av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z); | 7945 | av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z); |
@@ -7949,6 +7948,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7949 | } | 7948 | } |
7950 | break; | 7949 | break; |
7951 | 7950 | ||
7951 | case (int)ScriptBaseClass.PRIM_POS_LOCAL: | ||
7952 | { | ||
7953 | if (remain < 1) | ||
7954 | return; | ||
7955 | LSL_Vector v; | ||
7956 | v = rules.GetVector3Item(idx++); | ||
7957 | |||
7958 | SceneObjectPart part = World.GetSceneObjectPart(av.ParentID); | ||
7959 | if (part == null) | ||
7960 | break; | ||
7961 | |||
7962 | LSL_Vector sitOffset = (llRot2Up(new LSL_Rotation(av.Rotation.X, av.Rotation.Y, av.Rotation.Z, av.Rotation.W)) * av.Appearance.AvatarHeight * 0.02638f); | ||
7963 | |||
7964 | v += 2 * sitOffset; | ||
7965 | |||
7966 | av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z); | ||
7967 | av.SendAvatarDataToAllAgents(); | ||
7968 | |||
7969 | } | ||
7970 | break; | ||
7971 | |||
7952 | case (int)ScriptBaseClass.PRIM_ROTATION: | 7972 | case (int)ScriptBaseClass.PRIM_ROTATION: |
7953 | { | 7973 | { |
7954 | if (remain < 1) | 7974 | if (remain < 1) |
@@ -7969,6 +7989,109 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7969 | av.SendAvatarDataToAllAgents(); | 7989 | av.SendAvatarDataToAllAgents(); |
7970 | } | 7990 | } |
7971 | break; | 7991 | break; |
7992 | |||
7993 | case (int)ScriptBaseClass.PRIM_ROT_LOCAL: | ||
7994 | { | ||
7995 | if (remain < 1) | ||
7996 | return; | ||
7997 | |||
7998 | LSL_Rotation r; | ||
7999 | r = rules.GetQuaternionItem(idx++); | ||
8000 | av.Rotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); | ||
8001 | av.SendAvatarDataToAllAgents(); | ||
8002 | } | ||
8003 | break; | ||
8004 | |||
8005 | // parse rest doing nothing but number of parameters error check | ||
8006 | case (int)ScriptBaseClass.PRIM_SIZE: | ||
8007 | case (int)ScriptBaseClass.PRIM_MATERIAL: | ||
8008 | case (int)ScriptBaseClass.PRIM_PHANTOM: | ||
8009 | case (int)ScriptBaseClass.PRIM_PHYSICS: | ||
8010 | case (int)ScriptBaseClass.PRIM_PHYSICS_SHAPE_TYPE: | ||
8011 | case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: | ||
8012 | case (int)ScriptBaseClass.PRIM_NAME: | ||
8013 | case (int)ScriptBaseClass.PRIM_DESC: | ||
8014 | if (remain < 1) | ||
8015 | return; | ||
8016 | idx++; | ||
8017 | break; | ||
8018 | |||
8019 | case (int)ScriptBaseClass.PRIM_GLOW: | ||
8020 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: | ||
8021 | case (int)ScriptBaseClass.PRIM_TEXGEN: | ||
8022 | if (remain < 2) | ||
8023 | return; | ||
8024 | idx += 2; | ||
8025 | break; | ||
8026 | |||
8027 | case (int)ScriptBaseClass.PRIM_TYPE: | ||
8028 | if (remain < 3) | ||
8029 | return; | ||
8030 | code = (int)rules.GetLSLIntegerItem(idx++); | ||
8031 | remain = rules.Length - idx; | ||
8032 | switch (code) | ||
8033 | { | ||
8034 | case (int)ScriptBaseClass.PRIM_TYPE_BOX: | ||
8035 | case (int)ScriptBaseClass.PRIM_TYPE_CYLINDER: | ||
8036 | case (int)ScriptBaseClass.PRIM_TYPE_PRISM: | ||
8037 | if (remain < 6) | ||
8038 | return; | ||
8039 | idx += 6; | ||
8040 | break; | ||
8041 | |||
8042 | case (int)ScriptBaseClass.PRIM_TYPE_SPHERE: | ||
8043 | if (remain < 5) | ||
8044 | return; | ||
8045 | idx += 5; | ||
8046 | break; | ||
8047 | |||
8048 | case (int)ScriptBaseClass.PRIM_TYPE_TORUS: | ||
8049 | case (int)ScriptBaseClass.PRIM_TYPE_TUBE: | ||
8050 | case (int)ScriptBaseClass.PRIM_TYPE_RING: | ||
8051 | if (remain < 11) | ||
8052 | return; | ||
8053 | idx += 11; | ||
8054 | break; | ||
8055 | |||
8056 | case (int)ScriptBaseClass.PRIM_TYPE_SCULPT: | ||
8057 | if (remain < 2) | ||
8058 | return; | ||
8059 | idx += 2; | ||
8060 | break; | ||
8061 | } | ||
8062 | break; | ||
8063 | |||
8064 | case (int)ScriptBaseClass.PRIM_COLOR: | ||
8065 | case (int)ScriptBaseClass.PRIM_TEXT: | ||
8066 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: | ||
8067 | case (int)ScriptBaseClass.PRIM_OMEGA: | ||
8068 | if (remain < 3) | ||
8069 | return; | ||
8070 | idx += 3; | ||
8071 | break; | ||
8072 | |||
8073 | case (int)ScriptBaseClass.PRIM_TEXTURE: | ||
8074 | case (int)ScriptBaseClass.PRIM_POINT_LIGHT: | ||
8075 | case (int)ScriptBaseClass.PRIM_PHYSICS_MATERIAL: | ||
8076 | if (remain < 5) | ||
8077 | return; | ||
8078 | idx += 5; | ||
8079 | break; | ||
8080 | |||
8081 | case (int)ScriptBaseClass.PRIM_FLEXIBLE: | ||
8082 | if (remain < 7) | ||
8083 | return; | ||
8084 | |||
8085 | idx += 7; | ||
8086 | break; | ||
8087 | |||
8088 | case (int)ScriptBaseClass.PRIM_LINK_TARGET: | ||
8089 | if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. | ||
8090 | return; | ||
8091 | LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++); | ||
8092 | LSL_List new_rules = rules.GetSublist(idx, -1); | ||
8093 | setLinkPrimParams((int)new_linknumber, new_rules); | ||
8094 | return; | ||
7972 | } | 8095 | } |
7973 | } | 8096 | } |
7974 | } | 8097 | } |
@@ -7980,6 +8103,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7980 | 8103 | ||
7981 | int idx = 0; | 8104 | int idx = 0; |
7982 | 8105 | ||
8106 | SceneObjectGroup parentgrp = part.ParentGroup; | ||
8107 | |||
7983 | bool positionChanged = false; | 8108 | bool positionChanged = false; |
7984 | LSL_Vector currentPosition = GetPartLocalPos(part); | 8109 | LSL_Vector currentPosition = GetPartLocalPos(part); |
7985 | 8110 | ||
@@ -8019,8 +8144,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8019 | return; | 8144 | return; |
8020 | 8145 | ||
8021 | LSL_Rotation q = rules.GetQuaternionItem(idx++); | 8146 | LSL_Rotation q = rules.GetQuaternionItem(idx++); |
8147 | SceneObjectPart rootPart = parentgrp.RootPart; | ||
8022 | // try to let this work as in SL... | 8148 | // try to let this work as in SL... |
8023 | if (part.ParentID == 0) | 8149 | if (rootPart == part) |
8024 | { | 8150 | { |
8025 | // special case: If we are root, rotate complete SOG to new rotation | 8151 | // special case: If we are root, rotate complete SOG to new rotation |
8026 | SetRot(part, Rot2Quaternion(q)); | 8152 | SetRot(part, Rot2Quaternion(q)); |
@@ -8028,7 +8154,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8028 | else | 8154 | else |
8029 | { | 8155 | { |
8030 | // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask. | 8156 | // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask. |
8031 | SceneObjectPart rootPart = part.ParentGroup.RootPart; | 8157 | // sounds like sl bug that we need to replicate |
8032 | SetRot(part, rootPart.RotationOffset * Rot2Quaternion(q)); | 8158 | SetRot(part, rootPart.RotationOffset * Rot2Quaternion(q)); |
8033 | } | 8159 | } |
8034 | 8160 | ||
@@ -8281,7 +8407,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8281 | return; | 8407 | return; |
8282 | 8408 | ||
8283 | string ph = rules.Data[idx++].ToString(); | 8409 | string ph = rules.Data[idx++].ToString(); |
8284 | m_host.ParentGroup.ScriptSetPhantomStatus(ph.Equals("1")); | 8410 | parentgrp.ScriptSetPhantomStatus(ph.Equals("1")); |
8285 | 8411 | ||
8286 | break; | 8412 | break; |
8287 | 8413 | ||
@@ -8334,7 +8460,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8334 | return; | 8460 | return; |
8335 | string temp = rules.Data[idx++].ToString(); | 8461 | string temp = rules.Data[idx++].ToString(); |
8336 | 8462 | ||
8337 | m_host.ParentGroup.ScriptSetTemporaryStatus(temp.Equals("1")); | 8463 | parentgrp.ScriptSetTemporaryStatus(temp.Equals("1")); |
8338 | 8464 | ||
8339 | break; | 8465 | break; |
8340 | 8466 | ||
@@ -8387,16 +8513,39 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8387 | case (int)ScriptBaseClass.PRIM_LINK_TARGET: | 8513 | case (int)ScriptBaseClass.PRIM_LINK_TARGET: |
8388 | if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. | 8514 | if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. |
8389 | return; | 8515 | return; |
8516 | |||
8517 | // do a pending position change | ||
8518 | if (positionChanged) | ||
8519 | { | ||
8520 | if (parentgrp == null) | ||
8521 | return; | ||
8522 | |||
8523 | if (parentgrp.RootPart == part) | ||
8524 | { | ||
8525 | |||
8526 | Util.FireAndForget(delegate(object x) | ||
8527 | { | ||
8528 | parentgrp.UpdateGroupPosition(new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z)); | ||
8529 | }); | ||
8530 | } | ||
8531 | else | ||
8532 | { | ||
8533 | part.OffsetPosition = new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z); | ||
8534 | parentgrp.HasGroupChanged = true; | ||
8535 | parentgrp.ScheduleGroupForTerseUpdate(); | ||
8536 | } | ||
8537 | } | ||
8538 | |||
8390 | LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++); | 8539 | LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++); |
8391 | LSL_List new_rules = rules.GetSublist(idx, -1); | 8540 | LSL_List new_rules = rules.GetSublist(idx, -1); |
8392 | setLinkPrimParams((int)new_linknumber, new_rules); | 8541 | setLinkPrimParams((int)new_linknumber, new_rules); |
8393 | |||
8394 | return; | 8542 | return; |
8395 | } | 8543 | } |
8396 | } | 8544 | } |
8397 | } | 8545 | } |
8398 | finally | 8546 | finally |
8399 | { | 8547 | { |
8548 | /* | ||
8400 | if (positionChanged) | 8549 | if (positionChanged) |
8401 | { | 8550 | { |
8402 | if (part.ParentGroup.RootPart == part) | 8551 | if (part.ParentGroup.RootPart == part) |
@@ -8414,23 +8563,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8414 | parent.ScheduleGroupForTerseUpdate(); | 8563 | parent.ScheduleGroupForTerseUpdate(); |
8415 | } | 8564 | } |
8416 | } | 8565 | } |
8566 | */ | ||
8417 | } | 8567 | } |
8418 | 8568 | ||
8419 | if (positionChanged) | 8569 | if (positionChanged) |
8420 | { | 8570 | { |
8421 | if (part.ParentGroup.RootPart == part) | 8571 | if (parentgrp == null) |
8572 | return; | ||
8573 | |||
8574 | if (parentgrp.RootPart == part) | ||
8422 | { | 8575 | { |
8423 | SceneObjectGroup parent = part.ParentGroup; | 8576 | |
8424 | Util.FireAndForget(delegate(object x) { | 8577 | Util.FireAndForget(delegate(object x) { |
8425 | parent.UpdateGroupPosition(new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z)); | 8578 | parentgrp.UpdateGroupPosition(new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z)); |
8426 | }); | 8579 | }); |
8427 | } | 8580 | } |
8428 | else | 8581 | else |
8429 | { | 8582 | { |
8430 | part.OffsetPosition = new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z); | 8583 | part.OffsetPosition = new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z); |
8431 | SceneObjectGroup parent = part.ParentGroup; | 8584 | parentgrp.HasGroupChanged = true; |
8432 | parent.HasGroupChanged = true; | 8585 | parentgrp.ScheduleGroupForTerseUpdate(); |
8433 | parent.ScheduleGroupForTerseUpdate(); | ||
8434 | } | 8586 | } |
8435 | } | 8587 | } |
8436 | } | 8588 | } |