* Begun work on Primitive Duplication. Not hooked up yet, but theoretically could be done so. In practice, more work needs to be done.

Sugilite
Adam Frisby 2007-07-09 15:29:39 +00:00
parent f62b7f3d1e
commit e8acf1cca9
8 changed files with 140 additions and 2 deletions

View File

@ -59,6 +59,7 @@ namespace OpenSim.Framework.Interfaces
public delegate void UpdatePrimRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient); public delegate void UpdatePrimRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient);
public delegate void UpdatePrimSingleRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient); public delegate void UpdatePrimSingleRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient);
public delegate void UpdatePrimGroupRotation(uint localID,LLVector3 pos, LLQuaternion rot, IClientAPI remoteClient); public delegate void UpdatePrimGroupRotation(uint localID,LLVector3 pos, LLQuaternion rot, IClientAPI remoteClient);
public delegate void ObjectDuplicate(uint localID, LLVector3 offset, uint dupeFlags);
public delegate void StatusChange(bool status); public delegate void StatusChange(bool status);
public delegate void NewAvatar(IClientAPI remoteClient, LLUUID agentID, bool status); public delegate void NewAvatar(IClientAPI remoteClient, LLUUID agentID, bool status);
public delegate void UpdateAgent(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation); public delegate void UpdateAgent(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation);
@ -92,6 +93,7 @@ namespace OpenSim.Framework.Interfaces
event UpdateAgent OnAgentUpdate; event UpdateAgent OnAgentUpdate;
event GenericCall OnRequestAvatarsData; event GenericCall OnRequestAvatarsData;
event GenericCall4 OnAddPrim; event GenericCall4 OnAddPrim;
event ObjectDuplicate OnObjectDuplicate;
event UpdateVector OnGrapObject; event UpdateVector OnGrapObject;
event ObjectSelect OnDeGrapObject; event ObjectSelect OnDeGrapObject;
event MoveObject OnGrapUpdate; event MoveObject OnGrapUpdate;

View File

@ -55,6 +55,7 @@ namespace OpenSim.Region.ClientStack
public event LinkObjects OnLinkObjects; public event LinkObjects OnLinkObjects;
public event UpdateVector OnGrapObject; public event UpdateVector OnGrapObject;
public event ObjectSelect OnDeGrapObject; public event ObjectSelect OnDeGrapObject;
public event ObjectDuplicate OnObjectDuplicate;
public event MoveObject OnGrapUpdate; public event MoveObject OnGrapUpdate;
public event GenericCall4 OnAddPrim; public event GenericCall4 OnAddPrim;
public event UpdateShape OnUpdatePrimShape; public event UpdateShape OnUpdatePrimShape;

View File

@ -233,6 +233,18 @@ namespace OpenSim.Region.ClientStack
} }
} }
break; break;
case PacketType.ObjectDuplicate:
ObjectDuplicatePacket dupe = (ObjectDuplicatePacket)Pack;
for (int i = 0; i < dupe.ObjectData.Length; i++)
{
if (OnObjectDuplicate != null)
{
OnObjectDuplicate(dupe.ObjectData[i].ObjectLocalID, dupe.SharedData.Offset, dupe.SharedData.DuplicateFlags);
}
}
break;
case PacketType.ObjectSelect: case PacketType.ObjectSelect:
ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack; ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack;
for (int i = 0; i < incomingselect.ObjectData.Length; i++) for (int i = 0; i < incomingselect.ObjectData.Length; i++)

View File

@ -74,6 +74,7 @@ namespace OpenSim.Region.Environment.Scenes
public uint LocalId public uint LocalId
{ {
get { return m_localId; } get { return m_localId; }
set { m_localId = value; }
} }
/// <summary> /// <summary>
@ -121,6 +122,15 @@ namespace OpenSim.Region.Environment.Scenes
} }
/// <summary>
/// Copies the entity
/// </summary>
/// <returns></returns>
public virtual EntityBase Copy()
{
return (EntityBase)this.MemberwiseClone();
}
/// <summary> /// <summary>
/// Infoms the entity that the land (heightmap) has changed /// Infoms the entity that the land (heightmap) has changed
/// </summary> /// </summary>

View File

@ -141,8 +141,43 @@ namespace OpenSim.Region.Environment.Scenes
this.CreateFromPacket(addPacket, ownerID, localID); this.CreateFromPacket(addPacket, ownerID, localID);
this.rotation = Axiom.Math.Quaternion.Identity; this.rotation = Axiom.Math.Quaternion.Identity;
} }
/// <summary>
///
/// </summary>
/// <remarks>Empty constructor for duplication</remarks>
public Primitive()
{
}
#endregion #endregion
#region Duplication
public Primitive Copy(EntityBase parent, SceneObject rootParent)
{
Primitive dupe = (Primitive)this.MemberwiseClone();
// TODO: Copy this properly.
dupe.inventoryItems = this.inventoryItems;
dupe.m_Parent = parent;
dupe.m_RootParent = rootParent;
// TODO: Copy this properly.
dupe.m_Shape = this.m_Shape;
uint newLocalID = this.m_world.PrimIDAllocate();
dupe.LocalId = newLocalID;
dupe.Scale = new LLVector3(this.Scale.X, this.Scale.Y, this.Scale.Z);
dupe.rotation = new Quaternion(this.rotation.w, this.rotation.x, this.rotation.y, this.rotation.z);
dupe.Pos = new LLVector3(this.Pos.X, this.Pos.Y, this.Pos.Z);
return dupe;
}
#endregion
#region Override from EntityBase #region Override from EntityBase
/// <summary> /// <summary>
/// ///

View File

@ -212,6 +212,39 @@ namespace OpenSim.Region.Environment.Scenes
} }
/// <summary>
///
/// </summary>
/// <param name="originalPrim"></param>
/// <param name="offset"></param>
/// <param name="flags"></param>
public void DuplicateObject(uint originalPrim, LLVector3 offset, uint flags)
{
SceneObject originPrim = null;
foreach (EntityBase ent in Entities.Values)
{
if (ent is SceneObject)
{
if (((SceneObject)ent).rootLocalID == originalPrim)
{
originPrim = (SceneObject)ent;
break;
}
}
}
if (originPrim != null)
{
//SceneObject copy = originPrim.Copy();
}
else
{
OpenSim.Framework.Console.MainLog.Instance.Warn("Attempted to duplicate nonexistant prim");
}
}
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>

View File

@ -57,6 +57,7 @@ namespace OpenSim.Region.Environment.Scenes
private float timeStep = 0.1f; private float timeStep = 0.1f;
private Random Rand = new Random(); private Random Rand = new Random();
private uint _primCount = 702000; private uint _primCount = 702000;
private System.Threading.Mutex _primAllocateMutex = new Mutex(false);
private int storageCount; private int storageCount;
private Mutex updateLock; private Mutex updateLock;
@ -396,6 +397,22 @@ namespace OpenSim.Region.Environment.Scenes
} }
/// <summary>
/// Returns a new unallocated primitive ID
/// </summary>
/// <returns>A brand new primitive ID</returns>
public uint PrimIDAllocate()
{
uint myID;
_primAllocateMutex.WaitOne();
++_primCount;
myID = _primCount;
_primAllocateMutex.ReleaseMutex();
return myID;
}
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
@ -415,9 +432,8 @@ namespace OpenSim.Region.Environment.Scenes
{ {
try try
{ {
SceneObject sceneOb = new SceneObject(m_regionHandle, this, addPacket, ownerID, this._primCount); SceneObject sceneOb = new SceneObject(m_regionHandle, this, addPacket, ownerID, this.PrimIDAllocate());
this.Entities.Add(sceneOb.rootUUID, sceneOb); this.Entities.Add(sceneOb.rootUUID, sceneOb);
this._primCount++;
// Trigger event for listeners // Trigger event for listeners
// eventManager.TriggerOnNewPrimitive(prim); // eventManager.TriggerOnNewPrimitive(prim);
@ -468,6 +484,7 @@ namespace OpenSim.Region.Environment.Scenes
client.OnObjectDescription += this.PrimDescription; client.OnObjectDescription += this.PrimDescription;
client.OnObjectName += this.PrimName; client.OnObjectName += this.PrimName;
client.OnLinkObjects += this.LinkObjects; client.OnLinkObjects += this.LinkObjects;
client.OnObjectDuplicate += this.DuplicateObject;
/* remoteClient.OnParcelPropertiesRequest += new ParcelPropertiesRequest(parcelManager.handleParcelPropertiesRequest); /* remoteClient.OnParcelPropertiesRequest += new ParcelPropertiesRequest(parcelManager.handleParcelPropertiesRequest);
remoteClient.OnParcelDivideRequest += new ParcelDivideRequest(parcelManager.handleParcelDivideRequest); remoteClient.OnParcelDivideRequest += new ParcelDivideRequest(parcelManager.handleParcelDivideRequest);

View File

@ -75,6 +75,15 @@ namespace OpenSim.Region.Environment.Scenes
this.CreateRootFromPacket(addPacket, ownerID, localID); this.CreateRootFromPacket(addPacket, ownerID, localID);
} }
/// <summary>
///
/// </summary>
/// <remarks>Need a null constructor for duplication</remarks>
public SceneObject()
{
}
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
@ -97,6 +106,25 @@ namespace OpenSim.Region.Environment.Scenes
} }
/// <summary>
///
/// </summary>
/// <returns>A complete copy of the object</returns>
public SceneObject Copy()
{
SceneObject dupe = new SceneObject();
Primitive newRoot = this.rootPrimitive.Copy((EntityBase)dupe, dupe);
foreach (EntityBase child in this.children)
{
EntityBase newChild = child.Copy();
dupe.children.Add(newChild);
}
return dupe;
}
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>