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.avinationmerge
parent
dbc3f1ff92
commit
6fe4b6fbe8
|
@ -367,6 +367,11 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
|||
|
||||
originalPositions[objectGroup.UUID] = objectGroup.AbsolutePosition;
|
||||
|
||||
// Restore attachment data after trip through the sim
|
||||
if (objectGroup.RootPart.AttachPoint > 0)
|
||||
inventoryStoredPosition = objectGroup.RootPart.AttachOffset;
|
||||
objectGroup.RootPart.Shape.State = objectGroup.RootPart.AttachPoint;
|
||||
|
||||
objectGroup.AbsolutePosition = inventoryStoredPosition;
|
||||
|
||||
// Make sure all bits but the ones we want are clear
|
||||
|
@ -740,6 +745,11 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
|||
if (e == null || attachment) // Single
|
||||
{
|
||||
SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
|
||||
if (!attachment)
|
||||
{
|
||||
g.RootPart.AttachPoint = g.RootPart.Shape.State;
|
||||
g.RootPart.AttachOffset = g.AbsolutePosition;
|
||||
}
|
||||
|
||||
objlist.Add(g);
|
||||
veclist.Add(new Vector3(0, 0, 0));
|
||||
|
@ -769,6 +779,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
|||
foreach (XmlNode n in groups)
|
||||
{
|
||||
SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(n.OuterXml);
|
||||
g.RootPart.AttachPoint = g.RootPart.Shape.State;
|
||||
g.RootPart.AttachOffset = g.AbsolutePosition;
|
||||
|
||||
objlist.Add(g);
|
||||
XmlElement el = (XmlElement)n;
|
||||
|
|
|
@ -2351,6 +2351,11 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
/// <param name="objectGroup">The group of prims which should be linked to this group</param>
|
||||
public void LinkToGroup(SceneObjectGroup objectGroup)
|
||||
{
|
||||
LinkToGroup(objectGroup, false);
|
||||
}
|
||||
|
||||
public void LinkToGroup(SceneObjectGroup objectGroup, bool insert)
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
// "[SCENE OBJECT GROUP]: Linking group with root part {0}, {1} to group with root part {2}, {3}",
|
||||
// objectGroup.RootPart.Name, objectGroup.RootPart.UUID, RootPart.Name, RootPart.UUID);
|
||||
|
@ -2380,7 +2385,20 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
lock (m_parts.SyncRoot)
|
||||
{
|
||||
int linkNum = PrimCount + 1;
|
||||
int linkNum;
|
||||
if (insert)
|
||||
{
|
||||
linkNum = 2;
|
||||
foreach (SceneObjectPart part in Parts)
|
||||
{
|
||||
if (part.LinkNum > 1)
|
||||
part.LinkNum++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
linkNum = PrimCount + 1;
|
||||
}
|
||||
|
||||
m_parts.Add(linkPart.UUID, linkPart);
|
||||
|
||||
|
|
|
@ -2223,11 +2223,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
}
|
||||
else
|
||||
{
|
||||
if (m_host.IsRoot)
|
||||
if (part.IsRoot)
|
||||
{
|
||||
return new LSL_Vector(m_host.AttachedPos.X,
|
||||
m_host.AttachedPos.Y,
|
||||
m_host.AttachedPos.Z);
|
||||
return new LSL_Vector(part.AttachedPos.X,
|
||||
part.AttachedPos.Y,
|
||||
part.AttachedPos.Z);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2971,6 +2971,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
Util.FireAndForget(delegate (object x)
|
||||
{
|
||||
if (Double.IsNaN(rot.x) || Double.IsNaN(rot.y) || Double.IsNaN(rot.z) || Double.IsNaN(rot.s))
|
||||
return;
|
||||
float dist = (float)llVecDist(llGetPos(), pos);
|
||||
|
@ -2996,7 +2998,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
Vector3 llvel = new Vector3((float)vel.x, (float)vel.y, (float)vel.z);
|
||||
|
||||
// need the magnitude later
|
||||
float velmag = (float)Util.GetMagnitude(llvel);
|
||||
// float velmag = (float)Util.GetMagnitude(llvel);
|
||||
|
||||
SceneObjectGroup new_group = World.RezObject(m_host, inv.Value, llpos, Rot2Quaternion(rot), llvel, param);
|
||||
|
||||
|
@ -3007,10 +3009,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
// objects rezzed with this method are die_at_edge by default.
|
||||
new_group.RootPart.SetDieAtEdge(true);
|
||||
|
||||
Util.FireAndForget(delegate (object x)
|
||||
{
|
||||
new_group.ResumeScripts();
|
||||
});
|
||||
|
||||
m_ScriptEngine.PostObjectEvent(m_host.LocalId, new EventParams(
|
||||
"object_rez", new Object[] {
|
||||
|
@ -3026,13 +3025,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
llApplyImpulse(new LSL_Vector(llvel.X * groupmass, llvel.Y * groupmass, llvel.Z * groupmass), 0);
|
||||
}
|
||||
// Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay)
|
||||
ScriptSleep((int)((groupmass * velmag) / 10));
|
||||
ScriptSleep(100);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
llSay(0, "Could not find object " + inventory);
|
||||
});
|
||||
|
||||
//ScriptSleep((int)((groupmass * velmag) / 10));
|
||||
ScriptSleep(100);
|
||||
}
|
||||
|
||||
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
|
|||
|
||||
// Required for linking
|
||||
childPrim.RootPart.ClearUpdateSchedule();
|
||||
parentPrim.LinkToGroup(childPrim);
|
||||
parentPrim.LinkToGroup(childPrim, true);
|
||||
}
|
||||
|
||||
parentPrim.TriggerScriptChangedEvent(Changed.LINK);
|
||||
|
|
Loading…
Reference in New Issue