public ISceneEntity DelinkFromGroup(ISceneChildEntity part, bool sendEvents)
{
if (!(part is SceneObjectPart))
return null;
SceneObjectPart linkPart = part as SceneObjectPart;
// MainConsole.Instance.DebugFormat(
// "[SCENE OBJECT GROUP]: Delinking part {0}, {1} from group with root part {2}, {3}",
// linkPart.Name, linkPart.UUID, RootPart.Name, RootPart.UUID);
Quaternion worldRot = linkPart.GetWorldRotation();
// Remove the part from this object
m_scene.SceneGraph.DeLinkPartFromEntity(this, linkPart);
linkPart.SetParentLocalId(0);
linkPart.LinkNum = 0;
if (linkPart.PhysActor != null)
{
m_scene.PhysicsScene.RemovePrim(linkPart.PhysActor);
linkPart.PhysActor = null;
}
// We need to reset the child part's position
// ready for life as a separate object after being a part of another object
Quaternion parentRot = m_rootPart.GetRotationOffset();
Vector3 axPos = linkPart.OffsetPosition;
axPos *= parentRot;
linkPart.SetOffsetPosition(axPos);
linkPart.FixGroupPosition(AbsolutePosition + linkPart.OffsetPosition, false);
linkPart.FixOffsetPosition(Vector3.Zero, false);
linkPart.SetRotationOffset(true, worldRot, true);
SceneObjectGroup objectGroup = new SceneObjectGroup(linkPart, Scene);
m_scene.SceneGraph.DelinkPartToScene(objectGroup);
if (sendEvents)
linkPart.TriggerScriptChangedEvent(Changed.LINK);
linkPart.Rezzed = RootPart.Rezzed;
//This is already set multiple places, no need to do it again
//HasGroupChanged = true;
//We need to send this so that we don't have issues with the client not realizing that the prims were unlinked
ScheduleGroupUpdate(PrimUpdateFlags.ForcedFullUpdate);
m_ValidgrpOOB = false;
return objectGroup;
}