From cca94aaefc36fad366e789d6d2e902dda078e3f7 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 6 Mar 2012 05:13:39 +0000 Subject: 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 --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 74 +++++++++++++++++++++- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 5 +- 2 files changed, 74 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index c9ea8e4..b99f80d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -957,12 +957,21 @@ namespace OpenSim.Region.Framework.Scenes /// public void GetAxisAlignedBoundingBoxRaw(out float minX, out float maxX, out float minY, out float maxY, out float minZ, out float maxZ) { + /* ???? maxX = -256f; maxY = -256f; maxZ = -256f; minX = 256f; minY = 256f; 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(); foreach (SceneObjectPart part in parts) @@ -1918,6 +1927,8 @@ namespace OpenSim.Region.Framework.Scenes dupe.IsAttachment = previousAttachmentStatus; } + + dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; @@ -1988,7 +1999,12 @@ namespace OpenSim.Region.Framework.Scenes /// 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) RootPart.Velocity = Vector3.Zero; // In case source is moving } @@ -2191,7 +2207,10 @@ namespace OpenSim.Region.Framework.Scenes /// 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); AddPart(newPart); @@ -2485,6 +2504,11 @@ namespace OpenSim.Region.Framework.Scenes 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; Quaternion oldRootRotation = linkPart.RotationOffset; @@ -2528,6 +2552,13 @@ namespace OpenSim.Region.Framework.Scenes linkPart.SetParent(this); 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++; SceneObjectPart[] ogParts = objectGroup.Parts; @@ -2540,7 +2571,15 @@ namespace OpenSim.Region.Framework.Scenes { SceneObjectPart part = ogParts[i]; if (part.UUID != objectGroup.m_rootPart.UUID) + { 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(); } } @@ -2560,6 +2599,9 @@ namespace OpenSim.Region.Framework.Scenes // unmoved prims! ResetChildPrimPhysicsPositions(); + if (m_rootPart.PhysActor != null) + m_rootPart.PhysActor.Building = false; + //HasGroupChanged = true; //ScheduleGroupForFullUpdate(); } @@ -2612,7 +2654,10 @@ namespace OpenSim.Region.Framework.Scenes // m_log.DebugFormat( // "[SCENE OBJECT GROUP]: Delinking part {0}, {1} from group with root part {2}, {3}", // linkPart.Name, linkPart.UUID, RootPart.Name, RootPart.UUID); - + + if (m_rootPart.PhysActor != null) + m_rootPart.PhysActor.Building = true; + linkPart.ClearUndoState(); 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 // (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; return objectGroup; @@ -3284,6 +3333,10 @@ namespace OpenSim.Region.Framework.Scenes part.StoreUndoState(false); part.IgnoreUndoUpdate = true; +// unlock parts position change + if (m_rootPart.PhysActor != null) + m_rootPart.PhysActor.Building = true; + if (part.UUID == m_rootPart.UUID) { UpdateRootPosition(pos); @@ -3293,6 +3346,9 @@ namespace OpenSim.Region.Framework.Scenes part.UpdateOffSet(pos); } + if (m_rootPart.PhysActor != null) + m_rootPart.PhysActor.Building = false; + HasGroupChanged = true; part.IgnoreUndoUpdate = false; } @@ -3434,6 +3490,9 @@ namespace OpenSim.Region.Framework.Scenes // m_log.DebugFormat( // "[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) { UpdateRootRotation(rot); @@ -3442,6 +3501,9 @@ namespace OpenSim.Region.Framework.Scenes { 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.IgnoreUndoUpdate = true; + if (m_rootPart.PhysActor != null) + m_rootPart.PhysActor.Building = true; + if (part.UUID == m_rootPart.UUID) { UpdateRootRotation(rot); @@ -3482,6 +3547,9 @@ namespace OpenSim.Region.Framework.Scenes part.OffsetPosition = pos; } + if (m_rootPart.PhysActor != null) + m_rootPart.PhysActor.Building = false; + part.IgnoreUndoUpdate = false; } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 1c72b10..b132a19 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1727,8 +1727,6 @@ namespace OpenSim.Region.Framework.Scenes // Move afterwards ResetIDs as it clears the 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. dupe.LastOwnerID = OwnerID; @@ -1749,6 +1747,9 @@ namespace OpenSim.Region.Framework.Scenes dupe.DoPhysicsPropertyUpdate(UsePhysics, true); } + if (dupe.PhysActor != null) + dupe.PhysActor.LocalID = localID; + ParentGroup.Scene.EventManager.TriggerOnSceneObjectPartCopy(dupe, this, userExposed); // m_log.DebugFormat("[SCENE OBJECT PART]: Clone of {0} {1} finished", Name, UUID); -- cgit v1.1 From de03d1ece0f4b4b9337ded53a71fcc68676c77d9 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 6 Mar 2012 09:56:19 +0100 Subject: Removed some whitespace errors - don't be naughty, don't use hard tabs! Also removed commented code block. --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index b99f80d..8809cd0 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -957,15 +957,6 @@ namespace OpenSim.Region.Framework.Scenes /// public void GetAxisAlignedBoundingBoxRaw(out float minX, out float maxX, out float minY, out float maxY, out float minZ, out float maxZ) { - /* ???? - maxX = -256f; - maxY = -256f; - maxZ = -256f; - minX = 256f; - minY = 256f; - minZ = 8192f; - */ - maxX = float.MinValue; maxY = float.MinValue; maxZ = float.MinValue; @@ -1927,8 +1918,6 @@ namespace OpenSim.Region.Framework.Scenes dupe.IsAttachment = previousAttachmentStatus; } - - dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; -- cgit v1.1 From 17b1454d6f3b45618b1007c85fe97242284aff3c Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 6 Mar 2012 20:20:12 +0100 Subject: Null PhysActor on SOP.Copy() to prevent clobbering the original one --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index b132a19..9c06786 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1691,10 +1691,9 @@ namespace OpenSim.Region.Framework.Scenes if (userExposed) dupe.UUID = UUID.Random(); - //memberwiseclone means it also clones the physics actor reference - // This will make physical prim 'bounce' if not set to null. - if (!userExposed) - dupe.PhysActor = null; + // The PhysActor cannot be valid on a copy because the copy is not in the scene yet. + // Null it, the caller has to create a new one once the object is added to a scene + dupe.PhysActor = null; dupe.OwnerID = AgentID; dupe.GroupID = GroupID; -- cgit v1.1