diff options
author | Melanie | 2012-02-02 02:51:59 +0100 |
---|---|---|
committer | Melanie | 2012-02-02 02:51:59 +0100 |
commit | 6fe4b6fbe807672ec64700ff8c6307a2a3e4f084 (patch) | |
tree | 03387054e20ad64ab2513446c4b7736c0975b63a /OpenSim/Region/ScriptEngine/Shared/Api | |
parent | Merge branch 'master' into careminster (diff) | |
download | opensim-SC-6fe4b6fbe807672ec64700ff8c6307a2a3e4f084.zip opensim-SC-6fe4b6fbe807672ec64700ff8c6307a2a3e4f084.tar.gz opensim-SC-6fe4b6fbe807672ec64700ff8c6307a2a3e4f084.tar.bz2 opensim-SC-6fe4b6fbe807672ec64700ff8c6307a2a3e4f084.tar.xz |
Fix remembering attachment point and position when an item is rezzed in world.
Also fix PRIM_LOCAL_POS returning 0 when used on child prims from a script
in the root.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 99 |
1 files changed, 50 insertions, 49 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 7ed41f2..3e9529f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -2223,11 +2223,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2223 | } | 2223 | } |
2224 | else | 2224 | else |
2225 | { | 2225 | { |
2226 | if (m_host.IsRoot) | 2226 | if (part.IsRoot) |
2227 | { | 2227 | { |
2228 | return new LSL_Vector(m_host.AttachedPos.X, | 2228 | return new LSL_Vector(part.AttachedPos.X, |
2229 | m_host.AttachedPos.Y, | 2229 | part.AttachedPos.Y, |
2230 | m_host.AttachedPos.Z); | 2230 | part.AttachedPos.Z); |
2231 | } | 2231 | } |
2232 | else | 2232 | else |
2233 | { | 2233 | { |
@@ -2971,68 +2971,69 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2971 | { | 2971 | { |
2972 | m_host.AddScriptLPS(1); | 2972 | m_host.AddScriptLPS(1); |
2973 | 2973 | ||
2974 | if (Double.IsNaN(rot.x) || Double.IsNaN(rot.y) || Double.IsNaN(rot.z) || Double.IsNaN(rot.s)) | 2974 | Util.FireAndForget(delegate (object x) |
2975 | return; | 2975 | { |
2976 | float dist = (float)llVecDist(llGetPos(), pos); | 2976 | if (Double.IsNaN(rot.x) || Double.IsNaN(rot.y) || Double.IsNaN(rot.z) || Double.IsNaN(rot.s)) |
2977 | return; | ||
2978 | float dist = (float)llVecDist(llGetPos(), pos); | ||
2977 | 2979 | ||
2978 | if (dist > m_ScriptDistanceFactor * 10.0f) | 2980 | if (dist > m_ScriptDistanceFactor * 10.0f) |
2979 | return; | 2981 | return; |
2980 | 2982 | ||
2981 | //Clone is thread-safe | 2983 | //Clone is thread-safe |
2982 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 2984 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
2983 | 2985 | ||
2984 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) | 2986 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) |
2985 | { | ||
2986 | if (inv.Value.Name == inventory) | ||
2987 | { | 2987 | { |
2988 | // make sure we're an object. | 2988 | if (inv.Value.Name == inventory) |
2989 | if (inv.Value.InvType != (int)InventoryType.Object) | ||
2990 | { | 2989 | { |
2991 | llSay(0, "Unable to create requested object. Object is missing from database."); | 2990 | // make sure we're an object. |
2992 | return; | 2991 | if (inv.Value.InvType != (int)InventoryType.Object) |
2993 | } | 2992 | { |
2993 | llSay(0, "Unable to create requested object. Object is missing from database."); | ||
2994 | return; | ||
2995 | } | ||
2994 | 2996 | ||
2995 | Vector3 llpos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z); | 2997 | Vector3 llpos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z); |
2996 | Vector3 llvel = new Vector3((float)vel.x, (float)vel.y, (float)vel.z); | 2998 | Vector3 llvel = new Vector3((float)vel.x, (float)vel.y, (float)vel.z); |
2997 | 2999 | ||
2998 | // need the magnitude later | 3000 | // need the magnitude later |
2999 | float velmag = (float)Util.GetMagnitude(llvel); | 3001 | // float velmag = (float)Util.GetMagnitude(llvel); |
3000 | 3002 | ||
3001 | SceneObjectGroup new_group = World.RezObject(m_host, inv.Value, llpos, Rot2Quaternion(rot), llvel, param); | 3003 | SceneObjectGroup new_group = World.RezObject(m_host, inv.Value, llpos, Rot2Quaternion(rot), llvel, param); |
3002 | 3004 | ||
3003 | // If either of these are null, then there was an unknown error. | 3005 | // If either of these are null, then there was an unknown error. |
3004 | if (new_group == null) | 3006 | if (new_group == null) |
3005 | continue; | 3007 | continue; |
3006 | 3008 | ||
3007 | // objects rezzed with this method are die_at_edge by default. | 3009 | // objects rezzed with this method are die_at_edge by default. |
3008 | new_group.RootPart.SetDieAtEdge(true); | 3010 | new_group.RootPart.SetDieAtEdge(true); |
3009 | 3011 | ||
3010 | Util.FireAndForget(delegate (object x) | ||
3011 | { | ||
3012 | new_group.ResumeScripts(); | 3012 | new_group.ResumeScripts(); |
3013 | }); | ||
3014 | 3013 | ||
3015 | m_ScriptEngine.PostObjectEvent(m_host.LocalId, new EventParams( | 3014 | m_ScriptEngine.PostObjectEvent(m_host.LocalId, new EventParams( |
3016 | "object_rez", new Object[] { | 3015 | "object_rez", new Object[] { |
3017 | new LSL_String( | 3016 | new LSL_String( |
3018 | new_group.RootPart.UUID.ToString()) }, | 3017 | new_group.RootPart.UUID.ToString()) }, |
3019 | new DetectParams[0])); | 3018 | new DetectParams[0])); |
3020 | 3019 | ||
3021 | float groupmass = new_group.GetMass(); | 3020 | float groupmass = new_group.GetMass(); |
3022 | 3021 | ||
3023 | if (new_group.RootPart.PhysActor != null && new_group.RootPart.PhysActor.IsPhysical && llvel != Vector3.Zero) | 3022 | if (new_group.RootPart.PhysActor != null && new_group.RootPart.PhysActor.IsPhysical && llvel != Vector3.Zero) |
3024 | { | 3023 | { |
3025 | //Recoil. | 3024 | //Recoil. |
3026 | llApplyImpulse(new LSL_Vector(llvel.X * groupmass, llvel.Y * groupmass, llvel.Z * groupmass), 0); | 3025 | llApplyImpulse(new LSL_Vector(llvel.X * groupmass, llvel.Y * groupmass, llvel.Z * groupmass), 0); |
3026 | } | ||
3027 | // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay) | ||
3028 | return; | ||
3027 | } | 3029 | } |
3028 | // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay) | ||
3029 | ScriptSleep((int)((groupmass * velmag) / 10)); | ||
3030 | ScriptSleep(100); | ||
3031 | return; | ||
3032 | } | 3030 | } |
3033 | } | ||
3034 | 3031 | ||
3035 | llSay(0, "Could not find object " + inventory); | 3032 | llSay(0, "Could not find object " + inventory); |
3033 | }); | ||
3034 | |||
3035 | //ScriptSleep((int)((groupmass * velmag) / 10)); | ||
3036 | ScriptSleep(100); | ||
3036 | } | 3037 | } |
3037 | 3038 | ||
3038 | public void llRezObject(string inventory, LSL_Vector pos, LSL_Vector vel, LSL_Rotation rot, int param) | 3039 | public void llRezObject(string inventory, LSL_Vector pos, LSL_Vector vel, LSL_Rotation rot, int param) |
@@ -3938,7 +3939,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3938 | 3939 | ||
3939 | // Required for linking | 3940 | // Required for linking |
3940 | childPrim.RootPart.ClearUpdateSchedule(); | 3941 | childPrim.RootPart.ClearUpdateSchedule(); |
3941 | parentPrim.LinkToGroup(childPrim); | 3942 | parentPrim.LinkToGroup(childPrim, true); |
3942 | } | 3943 | } |
3943 | 3944 | ||
3944 | parentPrim.TriggerScriptChangedEvent(Changed.LINK); | 3945 | parentPrim.TriggerScriptChangedEvent(Changed.LINK); |