/// <summary> /// Add an object into the scene that has come from storage /// </summary> /// <param name="sceneObject"></param> /// <param name="attachToBackup"> /// If true, changes to the object will be reflected in its persisted data /// If false, the persisted data will not be changed even if the object in the scene is changed /// </param> /// <param name="alreadyPersisted"> /// If true, we won't persist this object until it changes /// If false, we'll persist this object immediately /// </param> /// <param name="sendClientUpdates"> /// If true, we send updates to the client to tell it about this object /// If false, we leave it up to the caller to do this /// </param> /// <returns> /// true if the object was added, false if an object with the same uuid was already in the scene /// </returns> protected internal bool AddRestoredSceneObject( SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) { if (!m_parentScene.CombineRegions) { // temporary checks to remove after varsize suport float regionSizeX = m_parentScene.RegionInfo.RegionSizeX; if (regionSizeX == 0) regionSizeX = Constants.RegionSize; float regionSizeY = m_parentScene.RegionInfo.RegionSizeY; if (regionSizeY == 0) regionSizeY = Constants.RegionSize; // KF: Check for out-of-region, move inside and make static. Vector3 npos = new Vector3(sceneObject.RootPart.GroupPosition.X, sceneObject.RootPart.GroupPosition.Y, sceneObject.RootPart.GroupPosition.Z); if (!(((sceneObject.RootPart.Shape.PCode == (byte)PCode.Prim) && (sceneObject.RootPart.Shape.State != 0))) && (npos.X < 0.0 || npos.Y < 0.0 || npos.Z < 0.0 || npos.X > regionSizeX || npos.Y > regionSizeY)) { if (npos.X < 0.0) npos.X = 1.0f; if (npos.Y < 0.0) npos.Y = 1.0f; if (npos.Z < 0.0) npos.Z = 0.0f; if (npos.X > regionSizeX) npos.X = regionSizeX - 1.0f; if (npos.Y > regionSizeY) npos.Y = regionSizeY - 1.0f; SceneObjectPart rootpart = sceneObject.RootPart; rootpart.GroupPosition = npos; foreach (SceneObjectPart part in sceneObject.Parts) { if (part == rootpart) continue; part.GroupPosition = npos; } rootpart.Velocity = Vector3.Zero; rootpart.AngularVelocity = Vector3.Zero; rootpart.Acceleration = Vector3.Zero; } } bool ret = AddSceneObject(sceneObject, attachToBackup, sendClientUpdates); if (attachToBackup && (!alreadyPersisted)) { sceneObject.ForceInventoryPersistence(); sceneObject.HasGroupChanged = true; } return ret; }
/// <summary> /// Add an object into the scene that has come from storage /// </summary> /// <param name="sceneObject"></param> /// <param name="attachToBackup"> /// If true, changes to the object will be reflected in its persisted data /// If false, the persisted data will not be changed even if the object in the scene is changed /// </param> /// <param name="alreadyPersisted"> /// If true, we won't persist this object until it changes /// If false, we'll persist this object immediately /// </param> /// <returns> /// true if the object was added, false if an object with the same uuid was already in the scene /// </returns> protected internal bool AddRestoredSceneObject( SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted) { if (!alreadyPersisted) { sceneObject.ForceInventoryPersistence(); sceneObject.HasGroupChanged = true; } return AddSceneObject(sceneObject, attachToBackup, true); }
/// <summary> /// Add a newly created object to the scene. This will both update the scene, and send information about the /// new object to all clients interested in the scene. /// </summary> /// <param name="sceneObject"></param> /// <param name="attachToBackup"> /// If true, the object is made persistent into the scene. /// If false, the object will not persist over server restarts /// </param> /// <returns> /// true if the object was added, false if an object with the same uuid was already in the scene /// </returns> protected internal bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) { // Ensure that we persist this new scene object sceneObject.HasGroupChanged = true; sceneObject.ForceInventoryPersistence(); return AddSceneObject(sceneObject, attachToBackup, sendClientUpdates); }