Shift and Drag copying should now work correctly. [This was one of those stupid little one line bugs that was so much fun to track down that I decided to spend a few hours on it)

Linking groups should now work better than it did, but still a bit of work to do on getting the rotations of all the parts after linking right. 
Added part of dalien's #301 patch (xml loading/saving related parts with some small changes)
afrisby
MW 2007-08-21 16:25:57 +00:00
parent 252b48fb3e
commit b7134c834c
6 changed files with 60 additions and 18 deletions

View File

@ -333,6 +333,8 @@ namespace OpenSim
m_log.Error(" alert [First] [Last] [Message] - send an alert to a user. Case sensitive."); m_log.Error(" alert [First] [Last] [Message] - send an alert to a user. Case sensitive.");
m_log.Error(" alert general [Message] - send an alert to all users."); m_log.Error(" alert general [Message] - send an alert to all users.");
m_log.Error("backup - trigger a simulator backup"); m_log.Error("backup - trigger a simulator backup");
m_log.Error("load-xml [filename] - load prims from XML");
m_log.Error("save-xml [filename] - save prims to XML");
m_log.Error("script - manually trigger scripts? or script commands?"); m_log.Error("script - manually trigger scripts? or script commands?");
m_log.Error("show uptime - show simulator startup and uptime."); m_log.Error("show uptime - show simulator startup and uptime.");
m_log.Error("show users - show info about connected users."); m_log.Error("show users - show info about connected users.");

View File

@ -80,7 +80,7 @@ namespace OpenSim.Region.ClientStack
protected bool MultipleObjUpdate(ClientView simClient, Packet packet) protected bool MultipleObjUpdate(ClientView simClient, Packet packet)
{ {
MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet; MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet;
//System.Console.WriteLine("new multi update packet " + multipleupdate.ToString()); // System.Console.WriteLine("new multi update packet " + multipleupdate.ToString());
for (int i = 0; i < multipleupdate.ObjectData.Length; i++) for (int i = 0; i < multipleupdate.ObjectData.Length; i++)
{ {
#region position #region position

View File

@ -132,7 +132,7 @@ namespace OpenSim.Region.Environment.Scenes
ScenePresence fromAvatar = this.Avatars[fromAgentID]; ScenePresence fromAvatar = this.Avatars[fromAgentID];
ScenePresence toAvatar = this.Avatars[toAgentID]; ScenePresence toAvatar = this.Avatars[toAgentID];
string fromName = fromAvatar.Firstname + " " + fromAvatar.Lastname; string fromName = fromAvatar.Firstname + " " + fromAvatar.Lastname;
toAvatar.ControllingClient.SendInstantMessage( fromAgentID, fromAgentSession, message, toAgentID, imSessionID, fromName, dialog, timestamp); toAvatar.ControllingClient.SendInstantMessage(fromAgentID, fromAgentSession, message, toAgentID, imSessionID, fromName, dialog, timestamp);
} }
else else
{ {
@ -508,15 +508,15 @@ namespace OpenSim.Region.Environment.Scenes
public void UpdatePrimSinglePosition(uint localID, LLVector3 pos, IClientAPI remoteClient) public void UpdatePrimSinglePosition(uint localID, LLVector3 pos, IClientAPI remoteClient)
{ {
Primitive prim = null; bool hasPrim = false;
foreach (EntityBase ent in Entities.Values) foreach (EntityBase ent in Entities.Values)
{ {
if (ent is SceneObjectGroup) if (ent is SceneObjectGroup)
{ {
//prim = ((SceneObject)ent).HasChildPrim(localID); hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID);
if (prim != null) if (hasPrim != false)
{ {
prim.UpdateSinglePosition(pos); ((SceneObjectGroup)ent).UpdateSinglePosition(pos, localID);
break; break;
} }
} }

View File

@ -610,6 +610,8 @@ namespace OpenSim.Region.Environment.Scenes
{ {
SceneObjectGroup obj = new SceneObjectGroup(this, SceneObjectGroup obj = new SceneObjectGroup(this,
this.m_regionHandle, aPrimNode.OuterXml); this.m_regionHandle, aPrimNode.OuterXml);
//if we want this to be a import method then we need new uuids for the object to avoid any clashes
//obj.RegenerateFullIDs();
AddEntity(obj); AddEntity(obj);
primCount++; primCount++;
} }

View File

@ -251,11 +251,11 @@ namespace OpenSim.Region.Environment.Scenes
public new SceneObjectGroup Copy() public new SceneObjectGroup Copy()
{ {
SceneObjectGroup dupe = (SceneObjectGroup)this.MemberwiseClone(); SceneObjectGroup dupe = (SceneObjectGroup)this.MemberwiseClone();
dupe.m_parts = new Dictionary<LLUUID, SceneObjectPart>();
dupe.m_parts.Clear(); dupe.m_parts.Clear();
dupe.AbsolutePosition = new LLVector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z); dupe.AbsolutePosition = new LLVector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z);
dupe.m_scene = m_scene; dupe.m_scene = m_scene;
dupe.m_regionHandle = this.m_regionHandle; dupe.m_regionHandle = this.m_regionHandle;
dupe.CopyRootPart(this.m_rootPart); dupe.CopyRootPart(this.m_rootPart);
List<SceneObjectPart> partList = new List<SceneObjectPart>(this.m_parts.Values); List<SceneObjectPart> partList = new List<SceneObjectPart>(this.m_parts.Values);
@ -291,6 +291,7 @@ namespace OpenSim.Region.Environment.Scenes
public void CopyPart(SceneObjectPart part) public void CopyPart(SceneObjectPart part)
{ {
SceneObjectPart newPart = part.Copy(m_scene.PrimIDAllocate()); SceneObjectPart newPart = part.Copy(m_scene.PrimIDAllocate());
newPart.SetParent(this);
this.m_parts.Add(newPart.UUID, newPart); this.m_parts.Add(newPart.UUID, newPart);
this.SetPartAsNonRoot(newPart); this.SetPartAsNonRoot(newPart);
} }
@ -431,6 +432,9 @@ namespace OpenSim.Region.Environment.Scenes
public void LinkToGroup(SceneObjectGroup objectGroup) public void LinkToGroup(SceneObjectGroup objectGroup)
{ {
SceneObjectPart linkPart = objectGroup.m_rootPart; SceneObjectPart linkPart = objectGroup.m_rootPart;
Axiom.Math.Vector3 oldGroupPosition = new Vector3(linkPart.GroupPosition.X, linkPart.GroupPosition.Y, linkPart.GroupPosition.Z);
Axiom.Math.Quaternion oldRootRotation = new Quaternion(linkPart.RotationOffset.W, linkPart.RotationOffset.X, linkPart.RotationOffset.Y, linkPart.RotationOffset.Z);
linkPart.OffsetPosition = linkPart.GroupPosition - this.AbsolutePosition; linkPart.OffsetPosition = linkPart.GroupPosition - this.AbsolutePosition;
linkPart.GroupPosition = this.AbsolutePosition; linkPart.GroupPosition = this.AbsolutePosition;
@ -450,20 +454,39 @@ namespace OpenSim.Region.Environment.Scenes
{ {
if (part.UUID != objectGroup.m_rootPart.UUID) if (part.UUID != objectGroup.m_rootPart.UUID)
{ {
this.LinkNonRootPart(part); this.LinkNonRootPart(part, oldGroupPosition, oldRootRotation);
} }
} }
m_scene.EventManager.OnBackup -= objectGroup.ProcessBackup; m_scene.EventManager.OnBackup -= objectGroup.ProcessBackup;
m_scene.DeleteEntity(objectGroup.UUID); m_scene.DeleteEntity(objectGroup.UUID);
objectGroup.DeleteParts();
this.ScheduleGroupForFullUpdate(); this.ScheduleGroupForFullUpdate();
} }
private void LinkNonRootPart(SceneObjectPart part) private void LinkNonRootPart(SceneObjectPart part, Vector3 oldGroupPosition, Quaternion oldGroupRotation)
{ {
part.SetParent(this); part.SetParent(this);
part.ParentID = this.m_rootPart.LocalID; part.ParentID = this.m_rootPart.LocalID;
this.m_parts.Add(part.UUID, part); this.m_parts.Add(part.UUID, part);
Vector3 axiomOldPos = new Vector3(part.OffsetPosition.X, part.OffsetPosition.Y, part.OffsetPosition.Z);
axiomOldPos = oldGroupRotation * axiomOldPos;
axiomOldPos += oldGroupPosition;
LLVector3 oldAbsolutePosition = new LLVector3(axiomOldPos.x, axiomOldPos.y, axiomOldPos.z);
part.OffsetPosition = oldAbsolutePosition - this.AbsolutePosition;
Quaternion axiomRootRotation = new Quaternion(m_rootPart.RotationOffset.W, m_rootPart.RotationOffset.X, m_rootPart.RotationOffset.Y, m_rootPart.RotationOffset.Z);
Vector3 axiomPos = new Vector3(part.OffsetPosition.X, part.OffsetPosition.Y, part.OffsetPosition.Z);
axiomPos = axiomRootRotation.Inverse() * axiomPos;
part.OffsetPosition = new LLVector3(axiomPos.x, axiomPos.y, axiomPos.z);
Quaternion axiomPartRotation = new Quaternion(part.RotationOffset.W, part.RotationOffset.X, part.RotationOffset.Y, part.RotationOffset.Z);
axiomPartRotation = oldGroupRotation * axiomPartRotation;
axiomPartRotation = axiomRootRotation.Inverse() * axiomPartRotation;
part.RotationOffset = new LLQuaternion(axiomPartRotation.x, axiomPartRotation.y, axiomPartRotation.z, axiomPartRotation.w);
} }
/// <summary> /// <summary>
@ -669,7 +692,7 @@ namespace OpenSim.Region.Environment.Scenes
public void UpdateGroupPosition(LLVector3 pos) public void UpdateGroupPosition(LLVector3 pos)
{ {
this.AbsolutePosition = pos; this.AbsolutePosition = pos;
this.ScheduleGroupForTerseUpdate();
} }
/// <summary> /// <summary>
@ -720,6 +743,7 @@ namespace OpenSim.Region.Environment.Scenes
pos.X = newPos.X; pos.X = newPos.X;
pos.Y = newPos.Y; pos.Y = newPos.Y;
pos.Z = newPos.Z; pos.Z = newPos.Z;
this.ScheduleGroupForTerseUpdate();
} }
#endregion #endregion
@ -859,7 +883,7 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="part"></param> /// <param name="part"></param>
internal void SendPartFullUpdate(IClientAPI remoteClient, SceneObjectPart part) internal void SendPartFullUpdate(IClientAPI remoteClient, SceneObjectPart part)
{ {
if (m_rootPart == part) if (m_rootPart.UUID == part.UUID)
{ {
part.SendFullUpdateToClient(remoteClient, AbsolutePosition); part.SendFullUpdateToClient(remoteClient, AbsolutePosition);
} }
@ -876,7 +900,7 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="part"></param> /// <param name="part"></param>
internal void SendPartTerseUpdate(IClientAPI remoteClient, SceneObjectPart part) internal void SendPartTerseUpdate(IClientAPI remoteClient, SceneObjectPart part)
{ {
if (m_rootPart == part) if (m_rootPart.UUID == part.UUID)
{ {
part.SendTerseUpdateToClient(remoteClient, AbsolutePosition); part.SendTerseUpdateToClient(remoteClient, AbsolutePosition);
} }
@ -932,6 +956,14 @@ namespace OpenSim.Region.Environment.Scenes
} }
} }
public void RegenerateFullIDs()
{
foreach (SceneObjectPart part in this.m_parts.Values)
{
part.UUID = LLUUID.Random();
}
}
public LLUUID GetPartsFullID(uint localID) public LLUUID GetPartsFullID(uint localID)
{ {
SceneObjectPart part = this.GetChildPrim(localID); SceneObjectPart part = this.GetChildPrim(localID);
@ -984,6 +1016,12 @@ namespace OpenSim.Region.Environment.Scenes
} }
} }
public void DeleteParts()
{
this.m_rootPart = null;
this.m_parts.Clear();
}
public override void SetText(string text, Vector3 color, double alpha) public override void SetText(string text, Vector3 color, double alpha)
{ {
Text = text; Text = text;

View File

@ -64,7 +64,7 @@ namespace OpenSim.Region.Environment.Scenes
set { m_name = value; } set { m_name = value; }
} }
protected LLObject.ObjectFlags m_flags = (LLObject.ObjectFlags)32 + 65536 + 131072 + 256 +4 +8 + 268435456 + 128; protected LLObject.ObjectFlags m_flags = (LLObject.ObjectFlags)32 + 65536 + 131072 + 256 + 4 + 8 + 268435456 + 128;
public uint ObjectFlags public uint ObjectFlags
{ {
get { return (uint)m_flags; } get { return (uint)m_flags; }
@ -405,7 +405,7 @@ namespace OpenSim.Region.Environment.Scenes
{ {
if (localID == this.m_localID) if (localID == this.m_localID)
{ {
//client.SendTaskInventory(this.m_uuid, 1, Helpers.StringToField("primInventory2")); //client.SendTaskInventory(this.m_uuid, 1, Helpers.StringToField("primInventory2"));
client.SendTaskInventory(this.m_uuid, 0, new byte[0]); client.SendTaskInventory(this.m_uuid, 0, new byte[0]);
} }
} }
@ -421,7 +421,7 @@ namespace OpenSim.Region.Environment.Scenes
InventoryStringBuilder invString = new InventoryStringBuilder(); InventoryStringBuilder invString = new InventoryStringBuilder();
invString.AddItemStart(); invString.AddItemStart();
invString.AddNameValueLine("item_id", LLUUID.Random().ToStringHyphenated()); invString.AddNameValueLine("item_id", LLUUID.Random().ToStringHyphenated());
invString.AddNameValueLine("parent_id",LLUUID.Zero.ToStringHyphenated()); invString.AddNameValueLine("parent_id", LLUUID.Zero.ToStringHyphenated());
invString.AddPermissionsStart(); invString.AddPermissionsStart();
invString.AddNameValueLine("base_mask", "0x7FFFFFFF"); invString.AddNameValueLine("base_mask", "0x7FFFFFFF");
@ -437,7 +437,7 @@ namespace OpenSim.Region.Environment.Scenes
invString.AddNameValueLine("asset_id", "00000000-0000-2222-3333-000000000001"); invString.AddNameValueLine("asset_id", "00000000-0000-2222-3333-000000000001");
invString.AddNameValueLine("type", "lsltext"); invString.AddNameValueLine("type", "lsltext");
invString.AddNameValueLine("inv_type" , "lsltext"); invString.AddNameValueLine("inv_type", "lsltext");
invString.AddNameValueLine("flags", "0x00"); invString.AddNameValueLine("flags", "0x00");
invString.AddNameValueLine("name", "Test inventory" + "|"); invString.AddNameValueLine("name", "Test inventory" + "|");
invString.AddNameValueLine("desc", "test description" + "|"); invString.AddNameValueLine("desc", "test description" + "|");
@ -447,7 +447,7 @@ namespace OpenSim.Region.Environment.Scenes
byte[] fileInv = Helpers.StringToField(invString.BuildString); byte[] fileInv = Helpers.StringToField(invString.BuildString);
byte[] data = new byte[fileInv.Length + 4]; byte[] data = new byte[fileInv.Length + 4];
Array.Copy(Helpers.IntToBytes(fileInv.Length), 0, data, 0, 4); Array.Copy(Helpers.IntToBytes(fileInv.Length), 0, data, 0, 4);
Array.Copy(fileInv, 0,data , 4, fileInv.Length); Array.Copy(fileInv, 0, data, 4, fileInv.Length);
client.SendXferPacket(xferID, 0 + 0x80000000, data); client.SendXferPacket(xferID, 0 + 0x80000000, data);
} }
#endregion #endregion