* Rex merge, SceneObjectGroup looked like it merged OK

afrisby-3
Adam Frisby 2008-02-23 03:59:02 +00:00
parent 7fdd23d249
commit e22f84ee60
1 changed files with 1822 additions and 1675 deletions

View File

@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products * names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission. * derived from this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
@ -54,8 +54,14 @@ namespace OpenSim.Region.Environment.Scenes
protected ulong m_regionHandle; protected ulong m_regionHandle;
public event PrimCountTaintedDelegate OnPrimCountTainted; public event PrimCountTaintedDelegate OnPrimCountTainted;
private PrimCountTaintedDelegate handler001 = null;
/// <summary>
/// Signal whether the non-inventory attributes of any prims in the group have changed
/// since the group's last persistent backup
/// </summary>
public bool HasGroupChanged = false;
public bool HasChanged = false;
public bool TemporaryPrim = false; // rex public bool TemporaryPrim = false; // rex
private LLVector3 lastPhysGroupPos; private LLVector3 lastPhysGroupPos;
@ -122,23 +128,11 @@ namespace OpenSim.Region.Environment.Scenes
set set
{ {
LLVector3 val = value; LLVector3 val = value;
if (val.X > 255.6f) if (val.X > 257f || val.X < -1f || val.Y > 257f || val.Y < -1f)
{ {
val.X = 255.6f; m_scene.CrossPrimGroupIntoNewRegion(val, this);
}
else if (val.X < 0.4f)
{
val.X = 0.4f;
} }
if (val.Y > 255.6f)
{
val.Y = 255.6f;
}
else if (val.Y < 0.4f)
{
val.Y = 0.4f;
}
lock (m_parts) lock (m_parts)
{ {
@ -147,13 +141,13 @@ namespace OpenSim.Region.Environment.Scenes
part.GroupPosition = val; part.GroupPosition = val;
} }
} }
if (m_rootPart.PhysActor != null) //if (m_rootPart.PhysActor != null)
{ //{
m_rootPart.PhysActor.Position = //m_rootPart.PhysActor.Position =
new PhysicsVector(m_rootPart.GroupPosition.X, m_rootPart.GroupPosition.Y, //new PhysicsVector(m_rootPart.GroupPosition.X, m_rootPart.GroupPosition.Y,
m_rootPart.GroupPosition.Z); //m_rootPart.GroupPosition.Z);
m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); //m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor);
} //}
} }
} }
@ -204,7 +198,14 @@ namespace OpenSim.Region.Environment.Scenes
public bool IsSelected public bool IsSelected
{ {
get { return m_isSelected; } get { return m_isSelected; }
set { m_isSelected = value; } set {
m_isSelected = value;
// Tell physics engine that group is selected
if (m_rootPart.PhysActor != null)
{
m_rootPart.PhysActor.Selected = value;
}
}
} }
// The UUID for the Region this Object is in. // The UUID for the Region this Object is in.
@ -250,7 +251,7 @@ namespace OpenSim.Region.Environment.Scenes
AttachToBackup(); AttachToBackup();
ApplyPhysics(); ApplyPhysics(scene.m_physicalPrim);
ScheduleGroupForFullUpdate(); ScheduleGroupForFullUpdate();
} }
@ -285,7 +286,7 @@ namespace OpenSim.Region.Environment.Scenes
AddPart(part); AddPart(part);
part.RegionHandle = m_regionHandle; part.RegionHandle = m_regionHandle;
part.ApplySanePermissions(); part.TrimPermissions();
} }
break; break;
case XmlNodeType.EndElement: case XmlNodeType.EndElement:
@ -303,7 +304,7 @@ namespace OpenSim.Region.Environment.Scenes
AttachToBackup(); AttachToBackup();
ApplyPhysics(); ApplyPhysics(scene.m_physicalPrim);
ScheduleGroupForFullUpdate(); ScheduleGroupForFullUpdate();
} }
@ -353,8 +354,6 @@ namespace OpenSim.Region.Environment.Scenes
sr.Close(); sr.Close();
UpdateParentIDs(); UpdateParentIDs();
ScheduleGroupForFullUpdate();
} }
private void AttachToBackup() private void AttachToBackup()
@ -376,8 +375,9 @@ namespace OpenSim.Region.Environment.Scenes
foreach (SceneObjectPart part in m_parts.Values) foreach (SceneObjectPart part in m_parts.Values)
{ {
Vector3 partPosition = // Temporary commented to stop compiler warning
new Vector3(part.AbsolutePosition.X, part.AbsolutePosition.Y, part.AbsolutePosition.Z); //Vector3 partPosition =
// new Vector3(part.AbsolutePosition.X, part.AbsolutePosition.Y, part.AbsolutePosition.Z);
Quaternion parentrotation = Quaternion parentrotation =
new Quaternion(GroupRotation.W, GroupRotation.X, GroupRotation.Y, GroupRotation.Z); new Quaternion(GroupRotation.W, GroupRotation.X, GroupRotation.Y, GroupRotation.Z);
@ -387,7 +387,7 @@ namespace OpenSim.Region.Environment.Scenes
// This may need to be updated to the maximum draw distance possible.. // This may need to be updated to the maximum draw distance possible..
// We might (and probably will) be checking for prim creation from other sims // We might (and probably will) be checking for prim creation from other sims
// when the camera crosses the border. // when the camera crosses the border.
float idist = 256f; float idist = (float)Constants.RegionSize;
if (inter.HitTF) if (inter.HitTF)
@ -407,14 +407,6 @@ namespace OpenSim.Region.Environment.Scenes
return returnresult; return returnresult;
} }
/// <summary>
///
/// </summary>
public SceneObjectGroup(byte[] data)
{
}
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
@ -434,7 +426,7 @@ namespace OpenSim.Region.Environment.Scenes
AttachToBackup(); AttachToBackup();
ApplyPhysics(); //ApplyPhysics(scene.m_physicalPrim);
} }
/// <summary> /// <summary>
@ -537,7 +529,7 @@ namespace OpenSim.Region.Environment.Scenes
dupe.m_regionHandle = m_regionHandle; dupe.m_regionHandle = m_regionHandle;
dupe.CopyRootPart(m_rootPart, OwnerID, GroupID); dupe.CopyRootPart(m_rootPart, OwnerID, GroupID);
dupe.m_rootPart.ApplySanePermissions(); dupe.m_rootPart.TrimPermissions();
/// may need to create a new Physics actor. /// may need to create a new Physics actor.
if (dupe.RootPart.PhysActor != null) if (dupe.RootPart.PhysActor != null)
@ -589,13 +581,28 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="part"></param> /// <param name="part"></param>
public void CopyRootPart(SceneObjectPart part, LLUUID cAgentID, LLUUID cGroupID) public void CopyRootPart(SceneObjectPart part, LLUUID cAgentID, LLUUID cGroupID)
{ {
SceneObjectPart newPart = part.Copy(m_scene.PrimIDAllocate(), OwnerID, GroupID); SceneObjectPart newPart = part.Copy(m_scene.PrimIDAllocate(), OwnerID, GroupID, m_parts.Count);
newPart.SetParent(this); newPart.SetParent(this);
newPart.LinkNum = m_parts.Count;
m_parts.Add(newPart.UUID, newPart); m_parts.Add(newPart.UUID, newPart);
SetPartAsRoot(newPart); SetPartAsRoot(newPart);
} }
public void applyImpulse(PhysicsVector impulse)
{
// We check if rootpart is null here because scripts don't delete if you delete the host.
// This means that unfortunately, we can pass a null physics actor to Simulate!
// Make sure we don't do that!
SceneObjectPart rootpart = m_rootPart;
if (rootpart != null)
{
if (rootpart.PhysActor != null)
{
rootpart.PhysActor.AddForce(impulse);
m_scene.PhysicsScene.AddPhysicsActorTaint(rootpart.PhysActor);
}
}
}
public void SetRootPartOwner(SceneObjectPart part, LLUUID cAgentID, LLUUID cGroupID) public void SetRootPartOwner(SceneObjectPart part, LLUUID cAgentID, LLUUID cGroupID)
{ {
part.LastOwnerID = part.OwnerID; part.LastOwnerID = part.OwnerID;
@ -619,22 +626,25 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="part"></param> /// <param name="part"></param>
public void CopyPart(SceneObjectPart part, LLUUID cAgentID, LLUUID cGroupID) public void CopyPart(SceneObjectPart part, LLUUID cAgentID, LLUUID cGroupID)
{ {
SceneObjectPart newPart = part.Copy(m_scene.PrimIDAllocate(), OwnerID, GroupID); SceneObjectPart newPart = part.Copy(m_scene.PrimIDAllocate(), OwnerID, GroupID, m_parts.Count);
newPart.SetParent(this); newPart.SetParent(this);
newPart.LinkNum = m_parts.Count;
m_parts.Add(newPart.UUID, newPart); m_parts.Add(newPart.UUID, newPart);
SetPartAsNonRoot(newPart); SetPartAsNonRoot(newPart);
} }
/// <summary>
public void GenerateNewIDs() /// Reset the LLUUIDs for all the prims that make up this group.
///
/// This is called by methods which want to add a new group to an existing scene, in order
/// to ensure that there are no clashes with groups already present.
/// </summary>
public void ResetIDs()
{ {
List<SceneObjectPart> partsList = new List<SceneObjectPart>(m_parts.Values); List<SceneObjectPart> partsList = new List<SceneObjectPart>(m_parts.Values);
m_parts.Clear(); m_parts.Clear();
foreach (SceneObjectPart part in partsList) foreach (SceneObjectPart part in partsList)
{ {
part.UUID = LLUUID.Random(); part.ResetIDs(m_parts.Count);
part.LinkNum = m_parts.Count;
m_parts.Add(part.UUID, part); m_parts.Add(part.UUID, part);
} }
} }
@ -738,7 +748,7 @@ namespace OpenSim.Region.Environment.Scenes
/// </summary> /// </summary>
public void ScheduleGroupForFullUpdate() public void ScheduleGroupForFullUpdate()
{ {
HasChanged = true; HasGroupChanged = true;
foreach (SceneObjectPart part in m_parts.Values) foreach (SceneObjectPart part in m_parts.Values)
{ {
part.ScheduleFullUpdate(); part.ScheduleFullUpdate();
@ -750,7 +760,7 @@ namespace OpenSim.Region.Environment.Scenes
/// </summary> /// </summary>
public void ScheduleGroupForTerseUpdate() public void ScheduleGroupForTerseUpdate()
{ {
HasChanged = true; HasGroupChanged = true;
foreach (SceneObjectPart part in m_parts.Values) foreach (SceneObjectPart part in m_parts.Values)
{ {
part.ScheduleTerseUpdate(); part.ScheduleTerseUpdate();
@ -762,19 +772,24 @@ namespace OpenSim.Region.Environment.Scenes
/// </summary> /// </summary>
public void SendGroupFullUpdate() public void SendGroupFullUpdate()
{ {
HasChanged = true; HasGroupChanged = true;
foreach (SceneObjectPart part in m_parts.Values) foreach (SceneObjectPart part in m_parts.Values)
{ {
part.SendFullUpdateToAllClients(); part.SendFullUpdateToAllClients();
} }
} }
public void QueueForUpdateCheck()
{
m_scene.m_innerScene.AddToUpdateList(this);
}
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public void SendGroupTerseUpdate() public void SendGroupTerseUpdate()
{ {
HasChanged = true; HasGroupChanged = true;
foreach (SceneObjectPart part in m_parts.Values) foreach (SceneObjectPart part in m_parts.Values)
{ {
part.SendTerseUpdateToAllClients(); part.SendTerseUpdateToAllClients();
@ -842,10 +857,8 @@ namespace OpenSim.Region.Environment.Scenes
/// <returns></returns> /// <returns></returns>
public bool HasChildPrim(LLUUID primID) public bool HasChildPrim(LLUUID primID)
{ {
SceneObjectPart childPart = null;
if (m_parts.ContainsKey(primID)) if (m_parts.ContainsKey(primID))
{ {
childPart = m_parts[primID];
return true; return true;
} }
return false; return false;
@ -874,12 +887,13 @@ namespace OpenSim.Region.Environment.Scenes
#region Packet Handlers #region Packet Handlers
/// <summary> /// <summary>
/// /// Link the prims in a given group to this group
/// </summary> /// </summary>
/// <param name="objectGroup"></param> /// <param name="objectGroup">The group of prims which should be linked to this group</param>
public void LinkToGroup(SceneObjectGroup objectGroup) public void LinkToGroup(SceneObjectGroup objectGroup)
{ {
SceneObjectPart linkPart = objectGroup.m_rootPart; SceneObjectPart linkPart = objectGroup.m_rootPart;
Vector3 oldGroupPosition = Vector3 oldGroupPosition =
new Vector3(linkPart.GroupPosition.X, linkPart.GroupPosition.Y, linkPart.GroupPosition.Z); new Vector3(linkPart.GroupPosition.X, linkPart.GroupPosition.Y, linkPart.GroupPosition.Z);
Quaternion oldRootRotation = Quaternion oldRootRotation =
@ -888,29 +902,32 @@ namespace OpenSim.Region.Environment.Scenes
linkPart.OffsetPosition = linkPart.GroupPosition - AbsolutePosition; linkPart.OffsetPosition = linkPart.GroupPosition - AbsolutePosition;
linkPart.GroupPosition = AbsolutePosition; linkPart.GroupPosition = AbsolutePosition;
Vector3 axPos = new Vector3(linkPart.OffsetPosition.X, linkPart.OffsetPosition.Y, linkPart.OffsetPosition.Z); Vector3 axPos = new Vector3(linkPart.OffsetPosition.X, linkPart.OffsetPosition.Y, linkPart.OffsetPosition.Z);
Quaternion parentRot = Quaternion parentRot =
new Quaternion(m_rootPart.RotationOffset.W, m_rootPart.RotationOffset.X, m_rootPart.RotationOffset.Y, new Quaternion(m_rootPart.RotationOffset.W, m_rootPart.RotationOffset.X, m_rootPart.RotationOffset.Y,
m_rootPart.RotationOffset.Z); m_rootPart.RotationOffset.Z);
axPos = parentRot.Inverse()*axPos; axPos = parentRot.Inverse()*axPos;
linkPart.OffsetPosition = new LLVector3(axPos.x, axPos.y, axPos.z); linkPart.OffsetPosition = new LLVector3(axPos.x, axPos.y, axPos.z);
Quaternion oldRot = Quaternion oldRot =
new Quaternion(linkPart.RotationOffset.W, linkPart.RotationOffset.X, linkPart.RotationOffset.Y, new Quaternion(linkPart.RotationOffset.W, linkPart.RotationOffset.X, linkPart.RotationOffset.Y,
linkPart.RotationOffset.Z); linkPart.RotationOffset.Z);
Quaternion newRot = parentRot.Inverse()*oldRot; Quaternion newRot = parentRot.Inverse()*oldRot;
linkPart.RotationOffset = new LLQuaternion(newRot.x, newRot.y, newRot.z, newRot.w); linkPart.RotationOffset = new LLQuaternion(newRot.x, newRot.y, newRot.z, newRot.w);
linkPart.ParentID = m_rootPart.LocalID; linkPart.ParentID = m_rootPart.LocalID;
linkPart.LinkNum = m_parts.Count; linkPart.LinkNum = m_parts.Count;
m_parts.Add(linkPart.UUID, linkPart); m_parts.Add(linkPart.UUID, linkPart);
linkPart.SetParent(this); linkPart.SetParent(this);
if (linkPart.PhysActor != null) //if (linkPart.PhysActor != null)
{ //{
m_scene.PhysicsScene.RemovePrim(linkPart.PhysActor); // m_scene.PhysicsScene.RemovePrim(linkPart.PhysActor);
linkPart.PhysActor = null; //linkPart.PhysActor = null;
} //}
//TODO: rest of parts //TODO: rest of parts
foreach (SceneObjectPart part in objectGroup.Children.Values) foreach (SceneObjectPart part in objectGroup.Children.Values)
@ -926,6 +943,7 @@ namespace OpenSim.Region.Environment.Scenes
m_scene.DeleteEntity(objectGroup.UUID); m_scene.DeleteEntity(objectGroup.UUID);
objectGroup.DeleteParts(); objectGroup.DeleteParts();
AbsolutePosition = AbsolutePosition;
ScheduleGroupForFullUpdate(); ScheduleGroupForFullUpdate();
} }
@ -940,8 +958,16 @@ namespace OpenSim.Region.Environment.Scenes
if (null != linkPart) if (null != linkPart)
{ {
LLQuaternion worldRot = linkPart.GetWorldRotation();
// Remove the part from this object // Remove the part from this object
m_parts.Remove(linkPart.UUID); m_parts.Remove(linkPart.UUID);
linkPart.ParentID = 0;
if (linkPart.PhysActor != null)
{
m_scene.PhysicsScene.RemovePrim(linkPart.PhysActor);
}
// We need to reset the child part's position // We need to reset the child part's position
// ready for life as a separate object after being a part of another object // ready for life as a separate object after being a part of another object
@ -963,6 +989,10 @@ namespace OpenSim.Region.Environment.Scenes
linkPart.GroupPosition = AbsolutePosition + linkPart.OffsetPosition; linkPart.GroupPosition = AbsolutePosition + linkPart.OffsetPosition;
linkPart.OffsetPosition = new LLVector3(0, 0, 0); linkPart.OffsetPosition = new LLVector3(0, 0, 0);
linkPart.RotationOffset = worldRot;
// This chunk is probably unnecesary now - delete later on
/*
Quaternion oldRot Quaternion oldRot
= new Quaternion( = new Quaternion(
linkPart.RotationOffset.W, linkPart.RotationOffset.W,
@ -971,23 +1001,24 @@ namespace OpenSim.Region.Environment.Scenes
linkPart.RotationOffset.Z); linkPart.RotationOffset.Z);
Quaternion newRot = parentRot*oldRot; Quaternion newRot = parentRot*oldRot;
linkPart.RotationOffset = new LLQuaternion(newRot.x, newRot.y, newRot.z, newRot.w); linkPart.RotationOffset = new LLQuaternion(newRot.x, newRot.y, newRot.z, newRot.w);
*/
// Add physics information back to delinked part if appropriate // Add physics information back to delinked part if appropriate
// XXX This is messy and should be refactorable with the similar section in // XXX This is messy and should be refactorable with the similar section in
// SceneObjectPart.UpdatePrimFlags() // SceneObjectPart.UpdatePrimFlags()
if (m_rootPart.PhysActor != null) //if (m_rootPart.PhysActor != null)
{ //{
linkPart.PhysActor = m_scene.PhysicsScene.AddPrimShape( //linkPart.PhysActor = m_scene.PhysicsScene.AddPrimShape(
linkPart.Name, //linkPart.Name,
linkPart.Shape, //linkPart.Shape,
new PhysicsVector(linkPart.AbsolutePosition.X, linkPart.AbsolutePosition.Y, //new PhysicsVector(linkPart.AbsolutePosition.X, linkPart.AbsolutePosition.Y,
linkPart.AbsolutePosition.Z), //linkPart.AbsolutePosition.Z),
new PhysicsVector(linkPart.Scale.X, linkPart.Scale.Y, linkPart.Scale.Z), //new PhysicsVector(linkPart.Scale.X, linkPart.Scale.Y, linkPart.Scale.Z),
new Quaternion(linkPart.RotationOffset.W, linkPart.RotationOffset.X, //new Quaternion(linkPart.RotationOffset.W, linkPart.RotationOffset.X,
linkPart.RotationOffset.Y, linkPart.RotationOffset.Z), //linkPart.RotationOffset.Y, linkPart.RotationOffset.Z),
m_rootPart.PhysActor.IsPhysical, linkPart.LocalID); //m_rootPart.PhysActor.IsPhysical);
m_rootPart.DoPhysicsPropertyUpdate(m_rootPart.PhysActor.IsPhysical, true); //m_rootPart.DoPhysicsPropertyUpdate(m_rootPart.PhysActor.IsPhysical, true);
} //}
SceneObjectGroup objectGroup = new SceneObjectGroup(m_scene, m_regionHandle, linkPart); SceneObjectGroup objectGroup = new SceneObjectGroup(m_scene, m_regionHandle, linkPart);
@ -997,7 +1028,7 @@ namespace OpenSim.Region.Environment.Scenes
} }
else else
{ {
MainLog.Instance.Verbose("SCENE", m_log.InfoFormat("[SCENE]: " +
"DelinkFromGroup(): Child prim local id {0} not found in object with root prim id {1}", "DelinkFromGroup(): Child prim local id {0} not found in object with root prim id {1}",
partID, LocalId); partID, LocalId);
} }
@ -1040,25 +1071,50 @@ namespace OpenSim.Region.Environment.Scenes
} }
/// <summary> /// <summary>
/// /// If object is physical, apply force to move it around
/// If object is not physical, just put it at the resulting location
/// </summary> /// </summary>
/// <param name="offset"></param> /// <param name="offset">Always seems to be 0,0,0, so ignoring</param>
/// <param name="pos"></param> /// <param name="pos">New position. We do the math here to turn it into a force</param>
/// <param name="remoteClient"></param> /// <param name="remoteClient"></param>
public void GrabMovement(LLVector3 offset, LLVector3 pos, IClientAPI remoteClient) public void GrabMovement(LLVector3 offset, LLVector3 pos, IClientAPI remoteClient)
{ {
if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) if (m_scene.EventManager.TriggerGroupMove(UUID, pos))
{
if (m_rootPart.PhysActor != null)
{
if (m_rootPart.PhysActor.IsPhysical)
{
LLVector3 llmoveforce = pos - AbsolutePosition;
PhysicsVector grabforce = new PhysicsVector(llmoveforce.X, llmoveforce.Y, llmoveforce.Z);
grabforce = (grabforce / 10) * m_rootPart.PhysActor.Mass;
m_rootPart.PhysActor.AddForce(grabforce);
m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor);
}
else
{
NonPhysicalGrabMovement(pos);
}
}
else
{
NonPhysicalGrabMovement(pos);
}
}
}
public void NonPhysicalGrabMovement(LLVector3 pos)
{ {
AbsolutePosition = pos; AbsolutePosition = pos;
m_rootPart.SendTerseUpdateToAllClients(); m_rootPart.SendTerseUpdateToAllClients();
}
}
}
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
/// <param name="client"></param> /// <param name="client"></param>
public void GetProperites(IClientAPI client) public void GetProperties(IClientAPI client)
{ {
ObjectPropertiesPacket proper = (ObjectPropertiesPacket) PacketPool.Instance.GetPacket(PacketType.ObjectProperties); ObjectPropertiesPacket proper = (ObjectPropertiesPacket) PacketPool.Instance.GetPacket(PacketType.ObjectProperties);
// TODO: don't create new blocks if recycling an old packet // TODO: don't create new blocks if recycling an old packet
@ -1090,12 +1146,12 @@ namespace OpenSim.Region.Environment.Scenes
} }
/// <summary> /// <summary>
/// /// Set the name of a prim
/// </summary> /// </summary>
/// <param name="name"></param> /// <param name="name"></param>
/// <param name="localID"></param>
public void SetPartName(string name, uint localID) public void SetPartName(string name, uint localID)
{ {
name = name.Remove(name.Length - 1, 1);
SceneObjectPart part = GetChildPart(localID); SceneObjectPart part = GetChildPart(localID);
if (part != null) if (part != null)
{ {
@ -1137,7 +1193,7 @@ namespace OpenSim.Region.Environment.Scenes
{ {
return part.Name; return part.Name;
} }
return ""; return String.Empty;
} }
public string GetPartDescription(uint localID) public string GetPartDescription(uint localID)
@ -1147,7 +1203,7 @@ namespace OpenSim.Region.Environment.Scenes
{ {
return part.Description; return part.Description;
} }
return ""; return String.Empty;
} }
/// <summary> /// <summary>
@ -1162,10 +1218,21 @@ namespace OpenSim.Region.Environment.Scenes
{ {
SceneObjectPart part = GetChildPart(localID); SceneObjectPart part = GetChildPart(localID);
if (part != null) if (part != null)
{
// If we have children
if (m_parts.Count > 1)
{
foreach (SceneObjectPart parts in m_parts.Values)
{
parts.UpdatePrimFlags(type, inUse, data);
}
}
else
{ {
part.UpdatePrimFlags(type, inUse, data); part.UpdatePrimFlags(type, inUse, data);
} }
} }
}
public void UpdateExtraParam(uint localID, ushort type, bool inUse, byte[] data) public void UpdateExtraParam(uint localID, ushort type, bool inUse, byte[] data)
{ {
@ -1175,6 +1242,13 @@ namespace OpenSim.Region.Environment.Scenes
part.UpdateExtraParam(type, inUse, data); part.UpdateExtraParam(type, inUse, data);
} }
} }
public SceneObjectPart[] GetParts()
{
int numParts = Children.Count;
SceneObjectPart[] partArray = new SceneObjectPart[numParts];
Children.Values.CopyTo(partArray, 0);
return partArray;
}
/// <summary> /// <summary>
/// ///
@ -1226,7 +1300,10 @@ namespace OpenSim.Region.Environment.Scenes
bool UsePhysics = ((m_rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) != 0); bool UsePhysics = ((m_rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) != 0);
m_rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); m_rootPart.DoPhysicsPropertyUpdate(UsePhysics, true);
if (part.PhysActor != null)
m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor);
} }
} }
#endregion #endregion
@ -1244,15 +1321,24 @@ namespace OpenSim.Region.Environment.Scenes
if (part != null) if (part != null)
{ {
part.Resize(scale); part.Resize(scale);
if (part.UUID == m_rootPart.UUID) if (part.PhysActor != null)
{ {
if (m_rootPart.PhysActor != null) part.PhysActor.Size =
{ new PhysicsVector(scale.X, scale.Y, scale.Z);
m_rootPart.PhysActor.Size = m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor);
new PhysicsVector(m_rootPart.Scale.X, m_rootPart.Scale.Y, m_rootPart.Scale.Z);
m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor);
}
} }
if (part.UUID != m_rootPart.UUID)
ScheduleGroupForFullUpdate();
//if (part.UUID == m_rootPart.UUID)
//{
//if (m_rootPart.PhysActor != null)
//{
//m_rootPart.PhysActor.Size =
//new PhysicsVector(m_rootPart.Scale.X, m_rootPart.Scale.Y, m_rootPart.Scale.Z);
//m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor);
//}
//}
} }
} }
@ -1328,6 +1414,11 @@ namespace OpenSim.Region.Environment.Scenes
ScheduleGroupForTerseUpdate(); ScheduleGroupForTerseUpdate();
} }
public void OffsetForNewRegion(LLVector3 offset)
{
m_rootPart.GroupPosition = offset;
}
#endregion #endregion
#region Rotation #region Rotation
@ -1465,9 +1556,10 @@ namespace OpenSim.Region.Environment.Scenes
/// </summary> /// </summary>
public void TriggerTainted() public void TriggerTainted()
{ {
if (OnPrimCountTainted != null) handler001 = OnPrimCountTainted;
if (handler001 != null)
{ {
OnPrimCountTainted(); handler001();
} }
} }
@ -1486,8 +1578,10 @@ namespace OpenSim.Region.Environment.Scenes
if (HasChanged) if (HasChanged)
{ {
datastore.StoreObject(this, m_scene.RegionInfo.RegionID); datastore.StoreObject(this, m_scene.RegionInfo.RegionID);
HasChanged = false; HasGroupChanged = false;
} }
ForEachPart(delegate(SceneObjectPart part) { part.ProcessInventoryBackup(datastore); });
} }
#endregion #endregion
@ -1547,10 +1641,11 @@ namespace OpenSim.Region.Environment.Scenes
{ {
part.UpdateMovement(); part.UpdateMovement();
} }
base.UpdateMovement();
} }
public float GetTimeDilation()
{
return m_scene.TimeDilation;
}
/// <summary> /// <summary>
/// Added as a way for the storage provider to reset the scene, /// Added as a way for the storage provider to reset the scene,
/// most likely a better way to do this sort of thing but for now... /// most likely a better way to do this sort of thing but for now...
@ -1595,6 +1690,12 @@ namespace OpenSim.Region.Environment.Scenes
} }
} }
public void ResetChildPrimPhysicsPositions()
{
AbsolutePosition = AbsolutePosition;
HasGroupChanged = false;
}
public LLUUID GetPartsFullID(uint localID) public LLUUID GetPartsFullID(uint localID)
{ {
SceneObjectPart part = GetChildPart(localID); SceneObjectPart part = GetChildPart(localID);
@ -1658,6 +1759,18 @@ namespace OpenSim.Region.Environment.Scenes
m_parts.Clear(); m_parts.Clear();
} }
public void AddScriptLPS(int count)
{
InnerScene d = m_scene.m_innerScene;
d.AddToScriptLPS(count);
}
public void AddActiveScriptCount(int count)
{
InnerScene d = m_scene.m_innerScene;
d.AddActiveScripts(count);
}
public override void SetText(string text, Vector3 color, double alpha) public override void SetText(string text, Vector3 color, double alpha)
{ {
Color = Color.FromArgb(0xff - (int) (alpha*0xff), Color = Color.FromArgb(0xff - (int) (alpha*0xff),
@ -1667,9 +1780,43 @@ namespace OpenSim.Region.Environment.Scenes
Text = text; Text = text;
} }
public void ApplyPhysics() public void ApplyPhysics(bool m_physicalPrim)
{ {
m_rootPart.ApplyPhysics(); if (m_parts.Count > 1)
{
lock (m_parts)
{
foreach (SceneObjectPart part in m_parts.Values)
{
part.ApplyPhysics(m_rootPart.ObjectFlags, m_physicalPrim);
// Hack to get the physics scene geometries in the right spot
ResetChildPrimPhysicsPositions();
}
}
}
else
{
m_rootPart.ApplyPhysics(m_rootPart.ObjectFlags, m_physicalPrim);
}
}
public void SetOwnerId(LLUUID userId)
{
ForEachPart(delegate(SceneObjectPart part)
{ part.OwnerID = userId; });
}
public void ForEachPart(Action<SceneObjectPart> whatToDo)
{
lock (m_parts)
{
foreach (SceneObjectPart part in m_parts.Values)
{
whatToDo(part);
}
}
} }
} }
} }