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 | |
parent | Merge branch 'master' into careminster (diff) | |
download | opensim-SC_OLD-6fe4b6fbe807672ec64700ff8c6307a2a3e4f084.zip opensim-SC_OLD-6fe4b6fbe807672ec64700ff8c6307a2a3e4f084.tar.gz opensim-SC_OLD-6fe4b6fbe807672ec64700ff8c6307a2a3e4f084.tar.bz2 opensim-SC_OLD-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')
3 files changed, 81 insertions, 50 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index 7ebf002..fe75271 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs | |||
@@ -367,6 +367,11 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
367 | 367 | ||
368 | originalPositions[objectGroup.UUID] = objectGroup.AbsolutePosition; | 368 | originalPositions[objectGroup.UUID] = objectGroup.AbsolutePosition; |
369 | 369 | ||
370 | // Restore attachment data after trip through the sim | ||
371 | if (objectGroup.RootPart.AttachPoint > 0) | ||
372 | inventoryStoredPosition = objectGroup.RootPart.AttachOffset; | ||
373 | objectGroup.RootPart.Shape.State = objectGroup.RootPart.AttachPoint; | ||
374 | |||
370 | objectGroup.AbsolutePosition = inventoryStoredPosition; | 375 | objectGroup.AbsolutePosition = inventoryStoredPosition; |
371 | 376 | ||
372 | // Make sure all bits but the ones we want are clear | 377 | // Make sure all bits but the ones we want are clear |
@@ -740,6 +745,11 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
740 | if (e == null || attachment) // Single | 745 | if (e == null || attachment) // Single |
741 | { | 746 | { |
742 | SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); | 747 | SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); |
748 | if (!attachment) | ||
749 | { | ||
750 | g.RootPart.AttachPoint = g.RootPart.Shape.State; | ||
751 | g.RootPart.AttachOffset = g.AbsolutePosition; | ||
752 | } | ||
743 | 753 | ||
744 | objlist.Add(g); | 754 | objlist.Add(g); |
745 | veclist.Add(new Vector3(0, 0, 0)); | 755 | veclist.Add(new Vector3(0, 0, 0)); |
@@ -769,6 +779,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
769 | foreach (XmlNode n in groups) | 779 | foreach (XmlNode n in groups) |
770 | { | 780 | { |
771 | SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(n.OuterXml); | 781 | SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(n.OuterXml); |
782 | g.RootPart.AttachPoint = g.RootPart.Shape.State; | ||
783 | g.RootPart.AttachOffset = g.AbsolutePosition; | ||
772 | 784 | ||
773 | objlist.Add(g); | 785 | objlist.Add(g); |
774 | XmlElement el = (XmlElement)n; | 786 | XmlElement el = (XmlElement)n; |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index c31cbab..6485710 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -2351,6 +2351,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2351 | /// <param name="objectGroup">The group of prims which should be linked to this group</param> | 2351 | /// <param name="objectGroup">The group of prims which should be linked to this group</param> |
2352 | public void LinkToGroup(SceneObjectGroup objectGroup) | 2352 | public void LinkToGroup(SceneObjectGroup objectGroup) |
2353 | { | 2353 | { |
2354 | LinkToGroup(objectGroup, false); | ||
2355 | } | ||
2356 | |||
2357 | public void LinkToGroup(SceneObjectGroup objectGroup, bool insert) | ||
2358 | { | ||
2354 | // m_log.DebugFormat( | 2359 | // m_log.DebugFormat( |
2355 | // "[SCENE OBJECT GROUP]: Linking group with root part {0}, {1} to group with root part {2}, {3}", | 2360 | // "[SCENE OBJECT GROUP]: Linking group with root part {0}, {1} to group with root part {2}, {3}", |
2356 | // objectGroup.RootPart.Name, objectGroup.RootPart.UUID, RootPart.Name, RootPart.UUID); | 2361 | // objectGroup.RootPart.Name, objectGroup.RootPart.UUID, RootPart.Name, RootPart.UUID); |
@@ -2380,7 +2385,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
2380 | 2385 | ||
2381 | lock (m_parts.SyncRoot) | 2386 | lock (m_parts.SyncRoot) |
2382 | { | 2387 | { |
2383 | int linkNum = PrimCount + 1; | 2388 | int linkNum; |
2389 | if (insert) | ||
2390 | { | ||
2391 | linkNum = 2; | ||
2392 | foreach (SceneObjectPart part in Parts) | ||
2393 | { | ||
2394 | if (part.LinkNum > 1) | ||
2395 | part.LinkNum++; | ||
2396 | } | ||
2397 | } | ||
2398 | else | ||
2399 | { | ||
2400 | linkNum = PrimCount + 1; | ||
2401 | } | ||
2384 | 2402 | ||
2385 | m_parts.Add(linkPart.UUID, linkPart); | 2403 | m_parts.Add(linkPart.UUID, linkPart); |
2386 | 2404 | ||
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); |