make copied parts have diferent LocalIds than original. More building control for ubitODE. for all let physics know about linking of physical parts. Assume UNTESTED

avinationmerge
UbitUmarov 2012-03-06 05:13:39 +00:00
parent f33654b62f
commit cca94aaefc
2 changed files with 74 additions and 5 deletions

View File

@ -957,12 +957,21 @@ namespace OpenSim.Region.Framework.Scenes
/// <returns></returns> /// <returns></returns>
public void GetAxisAlignedBoundingBoxRaw(out float minX, out float maxX, out float minY, out float maxY, out float minZ, out float maxZ) public void GetAxisAlignedBoundingBoxRaw(out float minX, out float maxX, out float minY, out float maxY, out float minZ, out float maxZ)
{ {
/* ????
maxX = -256f; maxX = -256f;
maxY = -256f; maxY = -256f;
maxZ = -256f; maxZ = -256f;
minX = 256f; minX = 256f;
minY = 256f; minY = 256f;
minZ = 8192f; minZ = 8192f;
*/
maxX = float.MinValue;
maxY = float.MinValue;
maxZ = float.MinValue;
minX = float.MaxValue;
minY = float.MaxValue;
minZ = float.MaxValue;
SceneObjectPart[] parts = m_parts.GetArray(); SceneObjectPart[] parts = m_parts.GetArray();
foreach (SceneObjectPart part in parts) foreach (SceneObjectPart part in parts)
@ -1918,6 +1927,8 @@ namespace OpenSim.Region.Framework.Scenes
dupe.IsAttachment = previousAttachmentStatus; dupe.IsAttachment = previousAttachmentStatus;
} }
dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed);
dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; dupe.m_rootPart.LinkNum = m_rootPart.LinkNum;
@ -1988,7 +1999,12 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="cGroupID"></param> /// <param name="cGroupID"></param>
public void CopyRootPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) public void CopyRootPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed)
{ {
SetRootPart(part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, 0, userExposed)); // SetRootPart(part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, 0, userExposed));
// give newpart a new local ID lettng old part keep same
SceneObjectPart newpart = part.Copy(part.LocalId, OwnerID, GroupID, 0, userExposed);
newpart.LocalId = m_scene.AllocateLocalId();
SetRootPart(newpart);
if (userExposed) if (userExposed)
RootPart.Velocity = Vector3.Zero; // In case source is moving RootPart.Velocity = Vector3.Zero; // In case source is moving
} }
@ -2191,7 +2207,10 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="cGroupID"></param> /// <param name="cGroupID"></param>
public SceneObjectPart CopyPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) public SceneObjectPart CopyPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed)
{ {
SceneObjectPart newPart = part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, m_parts.Count, userExposed); // give new ID to the new part, letting old keep original
// SceneObjectPart newPart = part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, m_parts.Count, userExposed);
SceneObjectPart newPart = part.Copy(part.LocalId, OwnerID, GroupID, m_parts.Count, userExposed);
newPart.LocalId = m_scene.AllocateLocalId();
newPart.SetParent(this); newPart.SetParent(this);
AddPart(newPart); AddPart(newPart);
@ -2485,6 +2504,11 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectPart linkPart = objectGroup.m_rootPart; SceneObjectPart linkPart = objectGroup.m_rootPart;
if (m_rootPart.PhysActor != null)
m_rootPart.PhysActor.Building = true;
if (linkPart.PhysActor != null)
linkPart.PhysActor.Building = true;
Vector3 oldGroupPosition = linkPart.GroupPosition; Vector3 oldGroupPosition = linkPart.GroupPosition;
Quaternion oldRootRotation = linkPart.RotationOffset; Quaternion oldRootRotation = linkPart.RotationOffset;
@ -2528,6 +2552,13 @@ namespace OpenSim.Region.Framework.Scenes
linkPart.SetParent(this); linkPart.SetParent(this);
linkPart.CreateSelected = true; linkPart.CreateSelected = true;
// let physics know
if (linkPart.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical)
{
linkPart.PhysActor.link(m_rootPart.PhysActor);
this.Scene.PhysicsScene.AddPhysicsActorTaint(linkPart.PhysActor);
}
linkPart.LinkNum = linkNum++; linkPart.LinkNum = linkNum++;
SceneObjectPart[] ogParts = objectGroup.Parts; SceneObjectPart[] ogParts = objectGroup.Parts;
@ -2540,7 +2571,15 @@ namespace OpenSim.Region.Framework.Scenes
{ {
SceneObjectPart part = ogParts[i]; SceneObjectPart part = ogParts[i];
if (part.UUID != objectGroup.m_rootPart.UUID) if (part.UUID != objectGroup.m_rootPart.UUID)
{
LinkNonRootPart(part, oldGroupPosition, oldRootRotation, linkNum++); LinkNonRootPart(part, oldGroupPosition, oldRootRotation, linkNum++);
// let physics know
if (part.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical)
{
part.PhysActor.link(m_rootPart.PhysActor);
this.Scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor);
}
}
part.ClearUndoState(); part.ClearUndoState();
} }
} }
@ -2560,6 +2599,9 @@ namespace OpenSim.Region.Framework.Scenes
// unmoved prims! // unmoved prims!
ResetChildPrimPhysicsPositions(); ResetChildPrimPhysicsPositions();
if (m_rootPart.PhysActor != null)
m_rootPart.PhysActor.Building = false;
//HasGroupChanged = true; //HasGroupChanged = true;
//ScheduleGroupForFullUpdate(); //ScheduleGroupForFullUpdate();
} }
@ -2612,7 +2654,10 @@ namespace OpenSim.Region.Framework.Scenes
// m_log.DebugFormat( // m_log.DebugFormat(
// "[SCENE OBJECT GROUP]: Delinking part {0}, {1} from group with root part {2}, {3}", // "[SCENE OBJECT GROUP]: Delinking part {0}, {1} from group with root part {2}, {3}",
// linkPart.Name, linkPart.UUID, RootPart.Name, RootPart.UUID); // linkPart.Name, linkPart.UUID, RootPart.Name, RootPart.UUID);
if (m_rootPart.PhysActor != null)
m_rootPart.PhysActor.Building = true;
linkPart.ClearUndoState(); linkPart.ClearUndoState();
Quaternion worldRot = linkPart.GetWorldRotation(); Quaternion worldRot = linkPart.GetWorldRotation();
@ -2672,6 +2717,10 @@ namespace OpenSim.Region.Framework.Scenes
// When we delete a group, we currently have to force persist to the database if the object id has changed // When we delete a group, we currently have to force persist to the database if the object id has changed
// (since delete works by deleting all rows which have a given object id) // (since delete works by deleting all rows which have a given object id)
if (m_rootPart.PhysActor != null)
m_rootPart.PhysActor.Building = false;
objectGroup.HasGroupChangedDueToDelink = true; objectGroup.HasGroupChangedDueToDelink = true;
return objectGroup; return objectGroup;
@ -3284,6 +3333,10 @@ namespace OpenSim.Region.Framework.Scenes
part.StoreUndoState(false); part.StoreUndoState(false);
part.IgnoreUndoUpdate = true; part.IgnoreUndoUpdate = true;
// unlock parts position change
if (m_rootPart.PhysActor != null)
m_rootPart.PhysActor.Building = true;
if (part.UUID == m_rootPart.UUID) if (part.UUID == m_rootPart.UUID)
{ {
UpdateRootPosition(pos); UpdateRootPosition(pos);
@ -3293,6 +3346,9 @@ namespace OpenSim.Region.Framework.Scenes
part.UpdateOffSet(pos); part.UpdateOffSet(pos);
} }
if (m_rootPart.PhysActor != null)
m_rootPart.PhysActor.Building = false;
HasGroupChanged = true; HasGroupChanged = true;
part.IgnoreUndoUpdate = false; part.IgnoreUndoUpdate = false;
} }
@ -3434,6 +3490,9 @@ namespace OpenSim.Region.Framework.Scenes
// m_log.DebugFormat( // m_log.DebugFormat(
// "[SCENE OBJECT GROUP]: Updating single rotation of {0} {1} to {2}", part.Name, part.LocalId, rot); // "[SCENE OBJECT GROUP]: Updating single rotation of {0} {1} to {2}", part.Name, part.LocalId, rot);
if (m_rootPart.PhysActor != null)
m_rootPart.PhysActor.Building = true;
if (part.UUID == m_rootPart.UUID) if (part.UUID == m_rootPart.UUID)
{ {
UpdateRootRotation(rot); UpdateRootRotation(rot);
@ -3442,6 +3501,9 @@ namespace OpenSim.Region.Framework.Scenes
{ {
part.UpdateRotation(rot); part.UpdateRotation(rot);
} }
if (m_rootPart.PhysActor != null)
m_rootPart.PhysActor.Building = false;
} }
} }
@ -3462,6 +3524,9 @@ namespace OpenSim.Region.Framework.Scenes
part.StoreUndoState(); part.StoreUndoState();
part.IgnoreUndoUpdate = true; part.IgnoreUndoUpdate = true;
if (m_rootPart.PhysActor != null)
m_rootPart.PhysActor.Building = true;
if (part.UUID == m_rootPart.UUID) if (part.UUID == m_rootPart.UUID)
{ {
UpdateRootRotation(rot); UpdateRootRotation(rot);
@ -3482,6 +3547,9 @@ namespace OpenSim.Region.Framework.Scenes
part.OffsetPosition = pos; part.OffsetPosition = pos;
} }
if (m_rootPart.PhysActor != null)
m_rootPart.PhysActor.Building = false;
part.IgnoreUndoUpdate = false; part.IgnoreUndoUpdate = false;
} }
} }

View File

@ -1727,8 +1727,6 @@ namespace OpenSim.Region.Framework.Scenes
// Move afterwards ResetIDs as it clears the localID // Move afterwards ResetIDs as it clears the localID
dupe.LocalId = localID; dupe.LocalId = localID;
if(dupe.PhysActor != null)
dupe.PhysActor.LocalID = localID;
// This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated.
dupe.LastOwnerID = OwnerID; dupe.LastOwnerID = OwnerID;
@ -1749,6 +1747,9 @@ namespace OpenSim.Region.Framework.Scenes
dupe.DoPhysicsPropertyUpdate(UsePhysics, true); dupe.DoPhysicsPropertyUpdate(UsePhysics, true);
} }
if (dupe.PhysActor != null)
dupe.PhysActor.LocalID = localID;
ParentGroup.Scene.EventManager.TriggerOnSceneObjectPartCopy(dupe, this, userExposed); ParentGroup.Scene.EventManager.TriggerOnSceneObjectPartCopy(dupe, this, userExposed);
// m_log.DebugFormat("[SCENE OBJECT PART]: Clone of {0} {1} finished", Name, UUID); // m_log.DebugFormat("[SCENE OBJECT PART]: Clone of {0} {1} finished", Name, UUID);