예제 #1
0
        /// <summary>
        /// Set up a scene. If it's more then one scene, use the same CommunicationsManager to link regions
        /// or a different, to get a brand new scene with new shared region modules.
        /// </summary>
        /// <param name="name">Name of the region</param>
        /// <param name="id">ID of the region</param>
        /// <param name="x">X co-ordinate of the region</param>
        /// <param name="y">Y co-ordinate of the region</param>
        /// <param name="cm">This should be the same if simulating two scenes within a standalone</param>
        /// <returns></returns>
        public static TestScene SetupScene(string name, UUID id, uint x, uint y, CoreAssetCache cache)
        {
            Console.WriteLine("Setting up test scene {0}", name);

            // We must set up a console otherwise setup of some modules may fail
            MainConsole.Instance = new MockConsole("TEST PROMPT");

            RegionInfo regInfo = new RegionInfo(x, y, new IPEndPoint(IPAddress.Loopback, 9000), "127.0.0.1");

            regInfo.RegionName = name;
            regInfo.RegionID   = id;

            AgentCircuitManager       acm = new AgentCircuitManager();
            SceneCommunicationService scs = new SceneCommunicationService();

            ISimulationDataService simDataService    = OpenSim.Server.Base.ServerUtils.LoadPlugin <ISimulationDataService>("OpenSim.Tests.Common.dll", null);
            IEstateDataService     estateDataService = null;
            IConfigSource          configSource      = new IniConfigSource();

            TestScene testScene = new TestScene(
                regInfo, acm, scs, simDataService, estateDataService, null, false, configSource, null);

            IRegionModule godsModule = new GodsModule();

            godsModule.Initialise(testScene, new IniConfigSource());
            testScene.AddModule(godsModule.Name, godsModule);

            LocalAssetServicesConnector assetService = StartAssetService(testScene, cache);

            StartAuthenticationService(testScene);
            LocalInventoryServicesConnector inventoryService = StartInventoryService(testScene);

            StartGridService(testScene);
            LocalUserAccountServicesConnector userAccountService = StartUserAccountService(testScene);
            LocalPresenceServicesConnector    presenceService    = StartPresenceService(testScene);

            inventoryService.PostInitialise();
            assetService.PostInitialise();
            userAccountService.PostInitialise();
            presenceService.PostInitialise();

            testScene.RegionInfo.EstateSettings.EstateOwner = UUID.Random();
            testScene.SetModuleInterfaces();

            testScene.LandChannel = new TestLandChannel(testScene);
            testScene.LoadWorldMap();

            PhysicsPluginManager physicsPluginManager = new PhysicsPluginManager();

            physicsPluginManager.LoadPluginsFromAssembly("Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll");
            testScene.PhysicsScene
                = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", new IniConfigSource(), "test");

            testScene.RegionInfo.EstateSettings = new EstateSettings();
            testScene.LoginsDisabled            = false;
            testScene.RegisterRegionWithGrid();

            return(testScene);
        }
예제 #2
0
 public TestScene(
     RegionInfo regInfo, AgentCircuitManager authen, PhysicsScene physicsScene,
     SceneCommunicationService sceneGridService, ISimulationDataService simDataService, IEstateDataService estateDataService,
     IConfigSource config, string simulatorVersion)
     : base(regInfo, authen, physicsScene, sceneGridService, simDataService, estateDataService,
            config, simulatorVersion)
 {
 }
예제 #3
0
 protected override Scene CreateScene(RegionInfo regionInfo, ISimulationDataService simDataService,
                                      IEstateDataService estateDataService, AgentCircuitManager circuitManager)
 {
     return(new Scene(
                regionInfo, circuitManager,
                simDataService, estateDataService,
                Config, m_version));
 }
예제 #4
0
 public TestScene(
     RegionInfo regInfo, AgentCircuitManager authen,
     ISimulationDataService simDataService, IEstateDataService estateDataService,
     IConfigSource config, string simulatorVersion)
     : base(regInfo, authen, simDataService, estateDataService,
            config, simulatorVersion)
 {
 }
예제 #5
0
 public TestScene(
     RegionInfo regInfo, AgentCircuitManager authen, PhysicsScene physicsScene,
     SceneCommunicationService sceneGridService, ISimulationDataService simDataService, IEstateDataService estateDataService,
     IConfigSource config, string simulatorVersion)
     : base(regInfo, authen, physicsScene, sceneGridService, simDataService, estateDataService,
            config, simulatorVersion)
 {
 }
예제 #6
0
 public TestScene(
     RegionInfo regInfo, AgentCircuitManager authen, 
     ISimulationDataService simDataService, IEstateDataService estateDataService,
     IConfigSource config, string simulatorVersion)
     : base(regInfo, authen, simDataService, estateDataService,
            config, simulatorVersion)
 {
 }
예제 #7
0
        private void EventManager_OnBackup(ISimulationDataService datastore, bool forcedBackup)
        {
            List <FaceMaterial> toStore;

            lock (materialslock)
            {
                if (m_changed.Count == 0)
                {
                    return;
                }

                if (forcedBackup)
                {
                    toStore = new List <FaceMaterial>(m_changed.Keys);
                    m_changed.Clear();
                }
                else
                {
                    toStore = new List <FaceMaterial>();
                    double storetime = Util.GetTimeStamp() - 60.0;
                    foreach (KeyValuePair <FaceMaterial, double> kvp in m_changed)
                    {
                        if (kvp.Value < storetime)
                        {
                            toStore.Add(kvp.Key);
                        }
                    }
                    foreach (FaceMaterial fm  in toStore)
                    {
                        m_changed.Remove(fm);
                    }
                }
            }

            if (toStore.Count > 0)
            {
                if (forcedBackup)
                {
                    foreach (FaceMaterial fm in toStore)
                    {
                        AssetBase a = MakeAsset(fm, false);
                        m_scene.AssetService.Store(a);
                    }
                }
                else
                {
                    Util.FireAndForget(delegate
                    {
                        foreach (FaceMaterial fm in toStore)
                        {
                            AssetBase a = MakeAsset(fm, false);
                            m_scene.AssetService.Store(a);
                        }
                    });
                }
            }
        }
 public TestScene(
     RegionInfo regInfo, AgentCircuitManager authen,
     SceneCommunicationService sceneGridService, ISimulationDataService simDataService, IEstateDataService estateDataService,
     ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim,
     bool SeeIntoRegionFromNeighbor, IConfigSource config, string simulatorVersion)
     : base(regInfo, authen, sceneGridService, simDataService, estateDataService, moduleLoader,
            dumpAssetsToFile, physicalPrim, SeeIntoRegionFromNeighbor, config, simulatorVersion)
 {
 }
예제 #9
0
 public TestScene(
     RegionInfo regInfo, AgentCircuitManager authen,
     SceneCommunicationService sceneGridService, ISimulationDataService simDataService, IEstateDataService estateDataService,
     ModuleLoader moduleLoader, bool dumpAssetsToFile,
     IConfigSource config, string simulatorVersion)
     : base(regInfo, authen, sceneGridService, simDataService, estateDataService, moduleLoader,
            dumpAssetsToFile, config, simulatorVersion)
 {
 }
예제 #10
0
 /// <summary>
 /// Process inventory backup
 /// </summary>
 /// <param name="datastore"></param>
 public void ProcessInventoryBackup(ISimulationDataService datastore)
 {
     if (HasInventoryChanged)
     {
         HasInventoryChanged = false;
         List <TaskInventoryItem> items = GetInventoryItems();
         datastore.StorePrimInventory(m_part.UUID, items);
     }
 }
        protected override Scene CreateScene(RegionInfo regionInfo, ISimulationDataService simDataService,
                                             IEstateDataService estateDataService, AgentCircuitManager circuitManager)
        {
            SceneCommunicationService sceneGridService = new SceneCommunicationService();

            return(new Scene(
                       regionInfo, circuitManager, sceneGridService,
                       simDataService, estateDataService, m_moduleLoader, false, m_configSettings.PhysicalPrim,
                       m_configSettings.See_into_region_from_neighbor, m_config.Source, m_version));
        }
예제 #12
0
        protected override Scene CreateScene(RegionInfo regionInfo, ISimulationDataService simDataService,
                                             IEstateDataService estateDataService, AgentCircuitManager circuitManager)
        {
            SceneCommunicationService sceneGridService = new SceneCommunicationService();

            return(new Scene(
                       regionInfo, circuitManager, sceneGridService,
                       simDataService, estateDataService, m_moduleLoader, false,
                       m_config.Source, m_version));
        }
예제 #13
0
        private void EventManager_OnBackup(ISimulationDataService datastore, bool forcedBackup)
        {
            List <AssetBase> toStore;
            List <ulong>     hashlist;


            lock (m_Materials)
            {
                if (m_changes.Count == 0)
                {
                    return;
                }

                if (forcedBackup)
                {
                    toStore = new List <AssetBase>(m_changes.Values);
                    m_changes.Clear();
                    m_changesTime.Clear();
                }
                else
                {
                    toStore  = new List <AssetBase>();
                    hashlist = new List <ulong>();
                    double storetime = Util.GetTimeStampMS() - 60000;
                    foreach (KeyValuePair <ulong, double> kvp in m_changesTime)
                    {
                        if (kvp.Value < storetime)
                        {
                            toStore.Add(m_changes[kvp.Key]);
                            hashlist.Add(kvp.Key);
                        }
                    }
                    foreach (ulong u  in hashlist)
                    {
                        m_changesTime.Remove(u);
                        m_changes.Remove(u);
                    }
                }

                if (toStore.Count > 0)
                {
                    Util.FireAndForget(delegate
                    {
                        foreach (AssetBase a in toStore)
                        {
                            a.Local = false;
                            m_scene.AssetService.Store(a);
                        }
                    });
                }
            }
        }
예제 #14
0
        protected override Scene CreateScene(RegionInfo regionInfo, ISimulationDataService simDataService,
                                             IEstateDataService estateDataService, AgentCircuitManager circuitManager)
        {
            Vector3      regionExtent = new Vector3(regionInfo.RegionSizeX, regionInfo.RegionSizeY, regionInfo.RegionSizeZ);
            PhysicsScene physicsScene = GetPhysicsScene(regionInfo.RegionName, regionExtent);

            SceneCommunicationService sceneGridService = new SceneCommunicationService();

            return(new Scene(
                       regionInfo, circuitManager, physicsScene, sceneGridService,
                       simDataService, estateDataService,
                       Config, m_version));
        }
예제 #15
0
        protected override Scene CreateScene(RegionInfo regionInfo, ISimulationDataService simDataService,
                                             IEstateDataService estateDataService, AgentCircuitManager circuitManager)
        {
            if (m_log.IsDebugEnabled)
            {
                m_log.DebugFormat("{0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
            }

            SceneCommunicationService sceneGridService = new SceneCommunicationService();

            return(new Scene(
                       regionInfo, circuitManager, sceneGridService,
                       simDataService, estateDataService,
                       Config, m_version));
        }
예제 #16
0
        public SceneHelpers(CoreAssetCache cache)
        {
            SceneManager = new SceneManager();

            m_assetService          = StartAssetService(cache);
            m_authenticationService = StartAuthenticationService();
            m_inventoryService      = StartInventoryService();
            m_gridService           = StartGridService();
            m_userAccountService    = StartUserAccountService();
            m_presenceService       = StartPresenceService();

            m_inventoryService.PostInitialise();
            m_assetService.PostInitialise();
            m_userAccountService.PostInitialise();
            m_presenceService.PostInitialise();

            m_cache = cache;

            SimDataService
                = OpenSim.Server.Base.ServerUtils.LoadPlugin <ISimulationDataService>("OpenSim.Tests.Common.dll", null);
        }
        /// <summary>
        /// Process inventory backup
        /// </summary>
        /// <param name="datastore"></param>
        public void ProcessInventoryBackup(ISimulationDataService datastore)
        {
            if (HasInventoryChanged)
            {
                HasInventoryChanged = false;
                List<TaskInventoryItem> items = GetInventoryItems();
                datastore.StorePrimInventory(m_part.UUID, items);

            }
        }
예제 #18
0
        protected override Scene CreateScene(RegionInfo regionInfo, ISimulationDataService simDataService,
            IEstateDataService estateDataService, AgentCircuitManager circuitManager)
        {
            Vector3 regionExtent = new Vector3(regionInfo.RegionSizeX, regionInfo.RegionSizeY, regionInfo.RegionSizeZ);
            PhysicsScene physicsScene = GetPhysicsScene(regionInfo.RegionName, regionExtent);

            SceneCommunicationService sceneGridService = new SceneCommunicationService();

            return new Scene(
                regionInfo, circuitManager, physicsScene, sceneGridService,
                simDataService, estateDataService,
                Config, m_version);
        }
예제 #19
0
        public Scene(RegionInfo regInfo, AgentCircuitManager authen, 
                     ISimulationDataService simDataService, IEstateDataService estateDataService,
                     IConfigSource config, string simulatorVersion)
            : this(regInfo)
        {
            m_config = config;
            FrameTime = 0.0908f;
            FrameTimeWarnPercent = 60;
            FrameTimeCritPercent = 40;
            Normalized55FPS = true;
            MinMaintenanceTime = 1;
            SeeIntoRegion = true;

            Random random = new Random();

            m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue / 2)) + (uint)(uint.MaxValue / 4);
            m_authenticateHandler = authen;
            m_sceneGridService = new SceneCommunicationService();
            m_SimulationDataService = simDataService;
            m_EstateDataService = estateDataService;

            m_lastIncoming = 0;
            m_lastOutgoing = 0;

            m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this);
            m_asyncSceneObjectDeleter.Enabled = true;

            m_asyncInventorySender = new AsyncInventorySender(this);

            #region Region Settings

            // Load region settings
            // LoadRegionSettings creates new region settings in persistence if they don't already exist for this region.
            // However, in this case, the default textures are not set in memory properly, so we need to do it here and
            // resave.
            // FIXME: It shouldn't be up to the database plugins to create this data - we should do it when a new
            // region is set up and avoid these gyrations.
            RegionSettings rs = simDataService.LoadRegionSettings(RegionInfo.RegionID);
            m_extraSettings = simDataService.GetExtra(RegionInfo.RegionID);

            bool updatedTerrainTextures = false;
            if (rs.TerrainTexture1 == UUID.Zero)
            {
                rs.TerrainTexture1 = RegionSettings.DEFAULT_TERRAIN_TEXTURE_1;
                updatedTerrainTextures = true;
            }

            if (rs.TerrainTexture2 == UUID.Zero)
            {
                rs.TerrainTexture2 = RegionSettings.DEFAULT_TERRAIN_TEXTURE_2;
                updatedTerrainTextures = true;
            }

            if (rs.TerrainTexture3 == UUID.Zero)
            {
                rs.TerrainTexture3 = RegionSettings.DEFAULT_TERRAIN_TEXTURE_3;
                updatedTerrainTextures = true;
            }

            if (rs.TerrainTexture4 == UUID.Zero)
            {
                rs.TerrainTexture4 = RegionSettings.DEFAULT_TERRAIN_TEXTURE_4;
                updatedTerrainTextures = true;
            }

            if (updatedTerrainTextures)
                rs.Save();

            RegionInfo.RegionSettings = rs;

            if (estateDataService != null)
                RegionInfo.EstateSettings = estateDataService.LoadEstateSettings(RegionInfo.RegionID, false);

            #endregion Region Settings

            //Bind Storage Manager functions to some land manager functions for this scene
            EventManager.OnLandObjectAdded +=
                new EventManager.LandObjectAdded(simDataService.StoreLandObject);
            EventManager.OnLandObjectRemoved +=
                new EventManager.LandObjectRemoved(simDataService.RemoveLandObject);

             RegisterDefaultSceneEvents();

            // XXX: Don't set the public property since we don't want to activate here.  This needs to be handled 
            // better in the future.
            m_scripts_enabled = !RegionInfo.RegionSettings.DisableScripts;

            PhysicsEnabled = !RegionInfo.RegionSettings.DisablePhysics;

            m_simulatorVersion = simulatorVersion + " (" + Util.GetRuntimeInformation() + ")";

            #region Region Config

            // Region config overrides global config
            //
            if (m_config.Configs["Startup"] != null)
            {
                IConfig startupConfig = m_config.Configs["Startup"];

                StartDisabled = startupConfig.GetBoolean("StartDisabled", false);

                m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance", m_defaultDrawDistance);
                m_maxDrawDistance = startupConfig.GetFloat("MaxDrawDistance", m_maxDrawDistance);
                m_maxRegionViewDistance = startupConfig.GetFloat("MaxRegionsViewDistance", m_maxRegionViewDistance);

                LegacySitOffsets = startupConfig.GetBoolean("LegacySitOffsets", LegacySitOffsets);

                if (m_defaultDrawDistance > m_maxDrawDistance)
                    m_defaultDrawDistance = m_maxDrawDistance;

                if (m_maxRegionViewDistance > m_maxDrawDistance)
                    m_maxRegionViewDistance = m_maxDrawDistance;

                UseBackup = startupConfig.GetBoolean("UseSceneBackup", UseBackup);
                if (!UseBackup)
                    m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName);

                //Animation states
                m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);

                SeeIntoRegion = startupConfig.GetBoolean("see_into_region", SeeIntoRegion);

                MaxUndoCount = startupConfig.GetInt("MaxPrimUndos", 20);

                PhysicalPrims = startupConfig.GetBoolean("physical_prim", true);
                CollidablePrims = startupConfig.GetBoolean("collidable_prim", true);
                m_minNonphys = startupConfig.GetFloat("NonPhysicalPrimMin", m_minNonphys);
                if (RegionInfo.NonphysPrimMin > 0)
                {
                    m_minNonphys = RegionInfo.NonphysPrimMin;
                }

                m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys);
                if (RegionInfo.NonphysPrimMax > 0)
                {
                    m_maxNonphys = RegionInfo.NonphysPrimMax;
                }

                m_minPhys = startupConfig.GetFloat("PhysicalPrimMin", m_minPhys);
                if (RegionInfo.PhysPrimMin > 0)
                {
                    m_minPhys = RegionInfo.PhysPrimMin;
                }

                m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys);

                if (RegionInfo.PhysPrimMax > 0)
                {
                    m_maxPhys = RegionInfo.PhysPrimMax;
                }

                m_linksetCapacity = startupConfig.GetInt("LinksetPrims", m_linksetCapacity);
                if (RegionInfo.LinksetCapacity > 0)
                {
                    m_linksetCapacity = RegionInfo.LinksetCapacity;
                }

                m_linksetPhysCapacity = startupConfig.GetInt("LinksetPhysPrims", m_linksetPhysCapacity);


                SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest");
                TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false);

                // Here, if clamping is requested in either global or
                // local config, it will be used
                //
                m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize);
                if (RegionInfo.ClampPrimSize)
                {
                    m_clampPrimSize = true;
                }

                m_clampNegativeZ = startupConfig.GetBoolean("ClampNegativeZ", m_clampNegativeZ);

                m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete",m_useTrashOnDelete);
                m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries);
                m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings);
                m_dontPersistBefore =
                    startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE);
                m_dontPersistBefore *= 10000000;
                m_persistAfter =
                    startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE);
                m_persistAfter *= 10000000;

                m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");
                m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine);

                m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);
                m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion);

                string[] possibleMapConfigSections = new string[] { "Map", "Startup" };

                m_generateMaptiles
                    = Util.GetConfigVarFromSections<bool>(config, "GenerateMaptiles", possibleMapConfigSections, true);

                if (m_generateMaptiles)
                {
                    int maptileRefresh = Util.GetConfigVarFromSections<int>(config, "MaptileRefresh", possibleMapConfigSections, 0);
                    m_log.InfoFormat("[SCENE]: Region {0}, WORLD MAP refresh time set to {1} seconds", RegionInfo.RegionName, maptileRefresh);
                    if (maptileRefresh != 0)
                    {
                        m_mapGenerationTimer.Interval = maptileRefresh * 1000;
                        m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister;
                        m_mapGenerationTimer.AutoReset = true;
                        m_mapGenerationTimer.Start();
                    }
                }
                else
                {
                    string tile
                        = Util.GetConfigVarFromSections<string>(
                            config, "MaptileStaticUUID", possibleMapConfigSections, UUID.Zero.ToString());

                    UUID tileID;

                    if (tile != UUID.Zero.ToString() && UUID.TryParse(tile, out tileID))
                    {
                        RegionInfo.RegionSettings.TerrainImageID = tileID;
                    }
                    else
                    {
                        RegionInfo.RegionSettings.TerrainImageID = RegionInfo.MaptileStaticUUID;
                        m_log.InfoFormat("[SCENE]: Region {0}, maptile set to {1}", RegionInfo.RegionName, RegionInfo.MaptileStaticUUID.ToString());
                    }
                }

                string[] possibleAccessControlConfigSections = new string[] { "Startup", "AccessControl"};

                string grant
                    = Util.GetConfigVarFromSections<string>(
                        config, "AllowedClients", possibleAccessControlConfigSections, string.Empty);

                if (grant.Length > 0)
                {
                    foreach (string viewer in grant.Split(','))
                    {
                        m_AllowedViewers.Add(viewer.Trim().ToLower());
                    }
                }

                grant
                    = Util.GetConfigVarFromSections<string>(
                        config, "DeniedClients", possibleAccessControlConfigSections, String.Empty);
                // Deal with the mess of someone having used a different word at some point
                if (grant == String.Empty)
                    grant = Util.GetConfigVarFromSections<string>(
                            config, "BannedClients", possibleAccessControlConfigSections, String.Empty);

                if (grant.Length > 0)
                {
                    foreach (string viewer in grant.Split(','))
                    {
                        m_BannedViewers.Add(viewer.Trim().ToLower());
                    }
                }

                FrameTime                 = startupConfig.GetFloat( "FrameTime", FrameTime);
                FrameTimeWarnPercent      = startupConfig.GetInt( "FrameTimeWarnPercent", FrameTimeWarnPercent);
                FrameTimeCritPercent      = startupConfig.GetInt( "FrameTimeCritPercent", FrameTimeCritPercent);
                Normalized55FPS           = startupConfig.GetBoolean( "Normalized55FPS", Normalized55FPS);

                m_update_backup           = startupConfig.GetInt("UpdateStorageEveryNFrames",         m_update_backup);
                m_update_coarse_locations = startupConfig.GetInt("UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations);
                m_update_entitymovement   = startupConfig.GetInt("UpdateEntityMovementEveryNFrames",  m_update_entitymovement);
                m_update_events           = startupConfig.GetInt("UpdateEventsEveryNFrames",          m_update_events);
                m_update_objects          = startupConfig.GetInt("UpdateObjectsEveryNFrames",         m_update_objects);
                m_update_physics          = startupConfig.GetInt("UpdatePhysicsEveryNFrames",         m_update_physics);
                m_update_presences        = startupConfig.GetInt("UpdateAgentsEveryNFrames",          m_update_presences);
                m_update_terrain          = startupConfig.GetInt("UpdateTerrainEveryNFrames",         m_update_terrain);
                m_update_temp_cleaning    = startupConfig.GetInt("UpdateTempCleaningEveryNSeconds",   m_update_temp_cleaning);

            }


            // FIXME: Ultimately this should be in a module.
            SendPeriodicAppearanceUpdates = false;

            IConfig appearanceConfig = m_config.Configs["Appearance"];
            if (appearanceConfig != null)
            {
                SendPeriodicAppearanceUpdates
                    = appearanceConfig.GetBoolean("ResendAppearanceUpdates", SendPeriodicAppearanceUpdates);
            }

            #endregion Region Config

            IConfig entityTransferConfig = m_config.Configs["EntityTransfer"];
            if (entityTransferConfig != null)
            {
                AllowAvatarCrossing = entityTransferConfig.GetBoolean("AllowAvatarCrossing", AllowAvatarCrossing);
                DisableObjectTransfer = entityTransferConfig.GetBoolean("DisableObjectTransfer", false);
            }

            #region Interest Management

            IConfig interestConfig = m_config.Configs["InterestManagement"];
            if (interestConfig != null)
            {
                string update_prioritization_scheme = interestConfig.GetString("UpdatePrioritizationScheme", "Time").Trim().ToLower();

                try
                {
                    UpdatePrioritizationScheme = (UpdatePrioritizationSchemes)Enum.Parse(typeof(UpdatePrioritizationSchemes), update_prioritization_scheme, true);
                }
                catch (Exception)
                {
                    m_log.Warn("[PRIORITIZER]: UpdatePrioritizationScheme was not recognized, setting to default prioritizer Time");
                    UpdatePrioritizationScheme = UpdatePrioritizationSchemes.Time;
                }

                IsReprioritizationEnabled
                    = interestConfig.GetBoolean("ReprioritizationEnabled", IsReprioritizationEnabled);
                ReprioritizationInterval
                    = interestConfig.GetFloat("ReprioritizationInterval", ReprioritizationInterval);
                ReprioritizationDistance
                    = interestConfig.GetFloat("RootReprioritizationDistance", ReprioritizationDistance);

                if(ReprioritizationDistance < m_minReprioritizationDistance)
                    ReprioritizationDistance = m_minReprioritizationDistance;

                ObjectsCullingByDistance
                    = interestConfig.GetBoolean("ObjectsCullingByDistance", ObjectsCullingByDistance);


                RootTerseUpdatePeriod = interestConfig.GetInt("RootTerseUpdatePeriod", RootTerseUpdatePeriod);
                ChildTerseUpdatePeriod = interestConfig.GetInt("ChildTerseUpdatePeriod", ChildTerseUpdatePeriod);

                RootPositionUpdateTolerance
                    = interestConfig.GetFloat("RootPositionUpdateTolerance", RootPositionUpdateTolerance);
                RootRotationUpdateTolerance
                    = interestConfig.GetFloat("RootRotationUpdateTolerance", RootRotationUpdateTolerance);
                RootVelocityUpdateTolerance
                    = interestConfig.GetFloat("RootVelocityUpdateTolerance", RootVelocityUpdateTolerance);
            }

            m_log.DebugFormat("[SCENE]: Using the {0} prioritization scheme", UpdatePrioritizationScheme);

            #endregion Interest Management


            StatsReporter = new SimStatsReporter(this);

            StatsReporter.OnSendStatsResult += SendSimStatsPackets;
            StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats;
 
        }
예제 #20
0
        protected override Scene CreateScene(RegionInfo regionInfo, ISimulationDataService simDataService,
            IEstateDataService estateDataService, AgentCircuitManager circuitManager)
        {
			if (m_log.IsDebugEnabled) {
				m_log.DebugFormat ("{0} called", System.Reflection.MethodBase.GetCurrentMethod ().Name);
			}

            SceneCommunicationService sceneGridService = new SceneCommunicationService();

            return new Scene(
                regionInfo, circuitManager, sceneGridService,
                simDataService, estateDataService,
                Config, m_version);
        }
예제 #21
0
파일: Scene.cs 프로젝트: CCIR/opensim
        public Scene(RegionInfo regInfo, AgentCircuitManager authen,
                     SceneCommunicationService sceneGridService,
                     ISimulationDataService simDataService, IEstateDataService estateDataService,
                     ModuleLoader moduleLoader, bool dumpAssetsToFile,
                     IConfigSource config, string simulatorVersion)
            : this(regInfo)
        {
            m_config = config;
            MinFrameTime = 0.089f;
            MinMaintenanceTime = 1;

            Random random = new Random();

            m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue / 2)) + (uint)(uint.MaxValue / 4);
            m_moduleLoader = moduleLoader;
            m_authenticateHandler = authen;
            m_sceneGridService = sceneGridService;
            m_SimulationDataService = simDataService;
            m_EstateDataService = estateDataService;
            m_regionHandle = RegionInfo.RegionHandle;

            m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this);
            m_asyncSceneObjectDeleter.Enabled = true;

            m_asyncInventorySender = new AsyncInventorySender(this);

            #region Region Settings

            // Load region settings
            // LoadRegionSettings creates new region settings in persistence if they don't already exist for this region.
            // However, in this case, the default textures are not set in memory properly, so we need to do it here and
            // resave.
            // FIXME: It shouldn't be up to the database plugins to create this data - we should do it when a new
            // region is set up and avoid these gyrations.
            RegionSettings rs = simDataService.LoadRegionSettings(RegionInfo.RegionID);
            m_extraSettings = simDataService.GetExtra(RegionInfo.RegionID);

            bool updatedTerrainTextures = false;
            if (rs.TerrainTexture1 == UUID.Zero)
            {
                rs.TerrainTexture1 = RegionSettings.DEFAULT_TERRAIN_TEXTURE_1;
                updatedTerrainTextures = true;
            }

            if (rs.TerrainTexture2 == UUID.Zero)
            {
                rs.TerrainTexture2 = RegionSettings.DEFAULT_TERRAIN_TEXTURE_2;
                updatedTerrainTextures = true;
            }

            if (rs.TerrainTexture3 == UUID.Zero)
            {
                rs.TerrainTexture3 = RegionSettings.DEFAULT_TERRAIN_TEXTURE_3;
                updatedTerrainTextures = true;
            }

            if (rs.TerrainTexture4 == UUID.Zero)
            {
                rs.TerrainTexture4 = RegionSettings.DEFAULT_TERRAIN_TEXTURE_4;
                updatedTerrainTextures = true;
            }

            if (updatedTerrainTextures)
                rs.Save();

            RegionInfo.RegionSettings = rs;

            if (estateDataService != null)
                RegionInfo.EstateSettings = estateDataService.LoadEstateSettings(RegionInfo.RegionID, false);

            #endregion Region Settings

            //Bind Storage Manager functions to some land manager functions for this scene
            EventManager.OnLandObjectAdded +=
                new EventManager.LandObjectAdded(simDataService.StoreLandObject);
            EventManager.OnLandObjectRemoved +=
                new EventManager.LandObjectRemoved(simDataService.RemoveLandObject);

            m_sceneGraph = new SceneGraph(this);

            // If the scene graph has an Unrecoverable error, restart this sim.
            // Currently the only thing that causes it to happen is two kinds of specific
            // Physics based crashes.
            //
            // Out of memory
            // Operating system has killed the plugin
            m_sceneGraph.UnRecoverableError += RestartNow;

            RegisterDefaultSceneEvents();

            DumpAssetsToFile = dumpAssetsToFile;

            m_scripts_enabled = !RegionInfo.RegionSettings.DisableScripts;

            m_physics_enabled = !RegionInfo.RegionSettings.DisablePhysics;

            m_simulatorVersion = simulatorVersion + " (" + Util.GetRuntimeInformation() + ")";

            #region Region Config

            // Region config overrides global config
            //
            if (m_config.Configs["Startup"] != null)
            {
                IConfig startupConfig = m_config.Configs["Startup"];

                StartDisabled = startupConfig.GetBoolean("StartDisabled", false);

                m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance", m_defaultDrawDistance);
                m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup);
                if (!m_useBackup)
                    m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName);
                
                //Animation states
                m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);

                MaxUndoCount = startupConfig.GetInt("MaxPrimUndos", 20);

                PhysicalPrims = startupConfig.GetBoolean("physical_prim", PhysicalPrims);
                CollidablePrims = startupConfig.GetBoolean("collidable_prim", CollidablePrims);

                m_minNonphys = startupConfig.GetFloat("NonPhysicalPrimMin", m_minNonphys);
                if (RegionInfo.NonphysPrimMin > 0)
                {
                    m_minNonphys = RegionInfo.NonphysPrimMin;
                }

                m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys);
                if (RegionInfo.NonphysPrimMax > 0)
                {
                    m_maxNonphys = RegionInfo.NonphysPrimMax;
                }

                m_minPhys = startupConfig.GetFloat("PhysicalPrimMin", m_minPhys);
                if (RegionInfo.PhysPrimMin > 0)
                {
                    m_minPhys = RegionInfo.PhysPrimMin;
                }

                m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys);
                if (RegionInfo.PhysPrimMax > 0)
                {
                    m_maxPhys = RegionInfo.PhysPrimMax;
                }

                // Here, if clamping is requested in either global or
                // local config, it will be used
                //
                m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize);
                if (RegionInfo.ClampPrimSize)
                {
                    m_clampPrimSize = true;
                }

                m_linksetCapacity = startupConfig.GetInt("LinksetPrims", m_linksetCapacity);
                if (RegionInfo.LinksetCapacity > 0)
                {
                    m_linksetCapacity = RegionInfo.LinksetCapacity;
                }

                m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete", m_useTrashOnDelete);
                m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries);
                m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings);
                m_dontPersistBefore =
                  startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE);
                m_dontPersistBefore *= 10000000;
                m_persistAfter =
                  startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE);
                m_persistAfter *= 10000000;

                m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");

                SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest");
                TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false);

                m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);

                m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true);
                if (m_generateMaptiles)
                {
                    int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0);
                    if (maptileRefresh != 0)
                    {
                        m_mapGenerationTimer.Interval = maptileRefresh * 1000;
                        m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister;
                        m_mapGenerationTimer.AutoReset = true;
                        m_mapGenerationTimer.Start();
                    }
                }
                else
                {
                    string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString());
                    UUID tileID;

                    if (UUID.TryParse(tile, out tileID))
                    {
                        RegionInfo.RegionSettings.TerrainImageID = tileID;
                    }
                }

                string grant = startupConfig.GetString("AllowedClients", String.Empty);
                if (grant.Length > 0)
                {
                    foreach (string viewer in grant.Split('|'))
                    {
                        m_AllowedViewers.Add(viewer.Trim().ToLower());
                    }
                }

                grant = startupConfig.GetString("BannedClients", String.Empty);
                if (grant.Length > 0)
                {
                    foreach (string viewer in grant.Split('|'))
                    {
                        m_BannedViewers.Add(viewer.Trim().ToLower());
                    }
                }

                MinFrameTime              = startupConfig.GetFloat( "MinFrameTime",                      MinFrameTime);
                m_update_backup           = startupConfig.GetInt(   "UpdateStorageEveryNFrames",         m_update_backup);
                m_update_coarse_locations = startupConfig.GetInt(   "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations);
                m_update_entitymovement   = startupConfig.GetInt(   "UpdateEntityMovementEveryNFrames",  m_update_entitymovement);
                m_update_events           = startupConfig.GetInt(   "UpdateEventsEveryNFrames",          m_update_events);
                m_update_objects          = startupConfig.GetInt(   "UpdateObjectsEveryNFrames",         m_update_objects);
                m_update_physics          = startupConfig.GetInt(   "UpdatePhysicsEveryNFrames",         m_update_physics);
                m_update_presences        = startupConfig.GetInt(   "UpdateAgentsEveryNFrames",          m_update_presences);
                m_update_terrain          = startupConfig.GetInt(   "UpdateTerrainEveryNFrames",         m_update_terrain);
                m_update_temp_cleaning    = startupConfig.GetInt(   "UpdateTempCleaningEveryNFrames",    m_update_temp_cleaning);
            }

            // FIXME: Ultimately this should be in a module.
            SendPeriodicAppearanceUpdates = true;
            
            IConfig appearanceConfig = m_config.Configs["Appearance"];
            if (appearanceConfig != null)
            {
                SendPeriodicAppearanceUpdates
                    = appearanceConfig.GetBoolean("ResendAppearanceUpdates", SendPeriodicAppearanceUpdates);
            }

            #endregion Region Config

            #region Interest Management

            IConfig interestConfig = m_config.Configs["InterestManagement"];
            if (interestConfig != null)
            {
                string update_prioritization_scheme = interestConfig.GetString("UpdatePrioritizationScheme", "Time").Trim().ToLower();

                try
                {
                    m_priorityScheme = (UpdatePrioritizationSchemes)Enum.Parse(typeof(UpdatePrioritizationSchemes), update_prioritization_scheme, true);
                }
                catch (Exception)
                {
                    m_log.Warn("[PRIORITIZER]: UpdatePrioritizationScheme was not recognized, setting to default prioritizer Time");
                    m_priorityScheme = UpdatePrioritizationSchemes.Time;
                }

                m_reprioritizationEnabled = interestConfig.GetBoolean("ReprioritizationEnabled", true);
                m_reprioritizationInterval = interestConfig.GetDouble("ReprioritizationInterval", 5000.0);
                m_rootReprioritizationDistance = interestConfig.GetDouble("RootReprioritizationDistance", 10.0);
                m_childReprioritizationDistance = interestConfig.GetDouble("ChildReprioritizationDistance", 20.0);
            }

            m_log.DebugFormat("[SCENE]: Using the {0} prioritization scheme", m_priorityScheme);

            #endregion Interest Management

            StatsReporter = new SimStatsReporter(this);
            StatsReporter.OnSendStatsResult += SendSimStatsPackets;
            StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats;
        }
예제 #22
0
        /// <summary>
        /// Processes backup.
        /// </summary>
        /// <param name="datastore"></param>
        public virtual void ProcessBackup(ISimulationDataService datastore, bool forcedBackup)
        {
            if (!m_isBackedUp)
            {
//                m_log.DebugFormat(
//                    "[WATER WARS]: Ignoring backup of {0} {1} since object is not marked to be backed up", Name, UUID);
                return;
            }

            if (IsDeleted || UUID == UUID.Zero)
            {
//                m_log.DebugFormat(
//                    "[WATER WARS]: Ignoring backup of {0} {1} since object is marked as already deleted", Name, UUID);
                return;
            }

            // Since this is the top of the section of call stack for backing up a particular scene object, don't let
            // any exception propogate upwards.
            try
            {
                if (!m_scene.ShuttingDown) // if shutting down then there will be nothing to handle the return so leave till next restart
                {
                    ILandObject parcel = m_scene.LandChannel.GetLandObject(
                            m_rootPart.GroupPosition.X, m_rootPart.GroupPosition.Y);

                    if (parcel != null && parcel.LandData != null &&
                            parcel.LandData.OtherCleanTime != 0)
                    {
                        if (parcel.LandData.OwnerID != OwnerID &&
                                (parcel.LandData.GroupID != GroupID ||
                                parcel.LandData.GroupID == UUID.Zero))
                        {
                            if ((DateTime.UtcNow - RootPart.Rezzed).TotalMinutes >
                                    parcel.LandData.OtherCleanTime)
                            {
                                DetachFromBackup();
                                m_log.DebugFormat(
                                    "[SCENE OBJECT GROUP]: Returning object {0} due to parcel autoreturn", 
                                     RootPart.UUID);
                                m_scene.AddReturn(OwnerID == GroupID ? LastOwnerID : OwnerID, Name, AbsolutePosition, "parcel autoreturn");
                                m_scene.DeRezObjects(null, new List<uint>() { RootPart.LocalId }, UUID.Zero,
                                        DeRezAction.Return, UUID.Zero);

                                return;
                            }
                        }
                    }
                }

                if (m_scene.UseBackup && HasGroupChanged)
                {
                    // don't backup while it's selected or you're asking for changes mid stream.
                    if (isTimeToPersist() || forcedBackup)
                    {
//                        m_log.DebugFormat(
//                            "[SCENE]: Storing {0}, {1} in {2}",
//                            Name, UUID, m_scene.RegionInfo.RegionName);

                        SceneObjectGroup backup_group = Copy(false);
                        backup_group.RootPart.Velocity = RootPart.Velocity;
                        backup_group.RootPart.Acceleration = RootPart.Acceleration;
                        backup_group.RootPart.AngularVelocity = RootPart.AngularVelocity;
                        backup_group.RootPart.ParticleSystem = RootPart.ParticleSystem;
                        HasGroupChanged = false;
                        HasGroupChangedDueToDelink = false;

                        m_scene.EventManager.TriggerOnSceneObjectPreSave(backup_group, this);
                        datastore.StoreObject(backup_group, m_scene.RegionInfo.RegionID);

                        backup_group.ForEachPart(delegate(SceneObjectPart part) 
                        { 
                            part.Inventory.ProcessInventoryBackup(datastore); 
                        });

                        backup_group = null;
                    }
//                    else
//                    {
//                        m_log.DebugFormat(
//                            "[SCENE]: Did not update persistence of object {0} {1}, selected = {2}",
//                            Name, UUID, IsSelected);
//                    }
                }
            }
            catch (Exception e)
            {
                m_log.ErrorFormat(
                    "[SCENE]: Storing of {0}, {1} in {2} failed with exception {3}{4}", 
                    Name, UUID, m_scene.RegionInfo.RegionName, e.Message, e.StackTrace);
            }
        }
예제 #23
0
        protected override Scene CreateScene(RegionInfo regionInfo, ISimulationDataService simDataService,
            IEstateDataService estateDataService, AgentCircuitManager circuitManager)
        {
            SceneCommunicationService sceneGridService = new SceneCommunicationService();

            return new Scene(
                regionInfo, circuitManager, sceneGridService,
                simDataService, estateDataService, m_moduleLoader, false, m_configSettings.PhysicalPrim,
                m_configSettings.See_into_region_from_neighbor, m_config.Source, m_version);
        }
예제 #24
0
        /// <summary>
        /// Performs startup specific to the region server, including initialization of the scene 
        /// such as loading configuration from disk.
        /// </summary>
        protected virtual void StartupSpecific()
        {
            #region Console Setup

            if (m_console != null)
            {
                ILoggerRepository repository = LogManager.GetRepository();
                IAppender[] appenders = repository.GetAppenders();

                foreach (IAppender appender in appenders)
                {
                    if (appender.Name == "Console")
                    {
                        m_consoleAppender = (OpenSimAppender)appender;
                        break;
                    }
                }

                if (null == m_consoleAppender)
                {
                    Notice("No appender named Console found (see the log4net config file for this executable)!");
                }
                else
                {
                    m_consoleAppender.Console = m_console;

                    // If there is no threshold set then the threshold is effectively everything.
                    if (null == m_consoleAppender.Threshold)
                        m_consoleAppender.Threshold = Level.All;

                    Notice(String.Format("Console log level is {0}", m_consoleAppender.Threshold));
                }

                m_console.Commands.AddCommand("base", false, "quit",
                        "quit",
                        "Quit the application", HandleQuit);

                m_console.Commands.AddCommand("base", false, "shutdown",
                        "shutdown",
                        "Quit the application", HandleQuit);

                m_console.Commands.AddCommand("base", false, "set log level",
                        "set log level <level>",
                        "Set the console logging level", HandleLogLevel);

                m_console.Commands.AddCommand("base", false, "show info",
                        "show info",
                        "Show general information", HandleShow);

                m_console.Commands.AddCommand("base", false, "show stats",
                        "show stats",
                        "Show statistics", HandleShow);

                m_console.Commands.AddCommand("base", false, "show threads",
                        "show threads",
                        "Show thread status", HandleShow);

                m_console.Commands.AddCommand("base", false, "show uptime",
                        "show uptime",
                        "Show server uptime", HandleShow);

                m_console.Commands.AddCommand("base", false, "show version",
                        "show version",
                        "Show server version", HandleShow);
            }

            #endregion Console Setup

            IConfig startupConfig = m_config.Source.Configs["Startup"];
            if (startupConfig != null)
            {
                string pidFile = startupConfig.GetString("PIDFile", String.Empty);
                if (pidFile != String.Empty)
                    CreatePIDFile(pidFile);
                
                userStatsURI = startupConfig.GetString("Stats_URI", String.Empty);
            }

            // Load the simulation data service
            IConfig simDataConfig = m_config.Source.Configs["SimulationDataStore"];
            if (simDataConfig == null)
                throw new Exception("Configuration file is missing the [SimulationDataStore] section");
            string module = simDataConfig.GetString("LocalServiceModule", String.Empty);
            if (String.IsNullOrEmpty(module))
                throw new Exception("Configuration file is missing the LocalServiceModule parameter in the [SimulationDataStore] section");
            m_simulationDataService = ServerUtils.LoadPlugin<ISimulationDataService>(module, new object[] { m_config.Source });

            // Load the estate data service
            IConfig estateDataConfig = m_config.Source.Configs["EstateDataStore"];
            if (estateDataConfig == null)
                throw new Exception("Configuration file is missing the [EstateDataStore] section");
            module = estateDataConfig.GetString("LocalServiceModule", String.Empty);
            if (String.IsNullOrEmpty(module))
                throw new Exception("Configuration file is missing the LocalServiceModule parameter in the [EstateDataStore] section");
            m_estateDataService = ServerUtils.LoadPlugin<IEstateDataService>(module, new object[] { m_config.Source });

            m_stats = StatsManager.StartCollectingSimExtraStats();

            // Create a ModuleLoader instance
            m_moduleLoader = new ModuleLoader(m_config.Source);

            LoadApplicationPlugins();
            foreach (IApplicationPlugin plugin in m_appPlugins)
                plugin.Initialise(this);
            foreach (IApplicationPlugin plugin in m_appPlugins)
                plugin.PostInitialise();

            AddPluginCommands();
        }
예제 #25
0
파일: Scene.cs 프로젝트: N3X15/VoxelSim
        public Scene(RegionInfo regInfo, AgentCircuitManager authen,
                     SceneCommunicationService sceneGridService,
                     ISimulationDataService simDataService, IEstateDataService estateDataService,
                     ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim,
                     bool SeeIntoRegionFromNeighbor, IConfigSource config, string simulatorVersion)
        {
            m_config = config;

            Random random = new Random();
            
            BordersLocked = true;

            Border northBorder = new Border();
            northBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, (int)Constants.RegionSize);  //<---
            northBorder.CrossDirection = Cardinals.N;
            NorthBorders.Add(northBorder);

            Border southBorder = new Border();
            southBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, 0);    //--->
            southBorder.CrossDirection = Cardinals.S;
            SouthBorders.Add(southBorder);

            Border eastBorder = new Border();
            eastBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, (int)Constants.RegionSize);   //<---
            eastBorder.CrossDirection = Cardinals.E;
            EastBorders.Add(eastBorder);

            Border westBorder = new Border();
            westBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, 0);     //--->
            westBorder.CrossDirection = Cardinals.W;
            WestBorders.Add(westBorder);

            BordersLocked = false;

            m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue/2))+(uint)(uint.MaxValue/4);
            m_moduleLoader = moduleLoader;
            m_authenticateHandler = authen;
            m_sceneGridService = sceneGridService;
            m_SimulationDataService = simDataService;
            m_EstateDataService = estateDataService;
            m_regInfo = regInfo;
            m_regionHandle = m_regInfo.RegionHandle;
            m_regionName = m_regInfo.RegionName;
            m_datastore = m_regInfo.DataStore;
            m_lastUpdate = Util.EnvironmentTickCount();

            m_physicalPrim = physicalPrim;
            m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor;

            m_eventManager = new EventManager();
            m_permissions = new ScenePermissions(this);

            m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this);
            m_asyncSceneObjectDeleter.Enabled = true;

            #region Region Settings

            // Load region settings
            m_regInfo.RegionSettings = simDataService.LoadRegionSettings(m_regInfo.RegionID);
            if (estateDataService != null)
                m_regInfo.EstateSettings = estateDataService.LoadEstateSettings(m_regInfo.RegionID, false);

            #endregion Region Settings

            MainConsole.Instance.Commands.AddCommand("region", false, "reload estate",
                                          "reload estate",
                                          "Reload the estate data", HandleReloadEstate);

            //Bind Storage Manager functions to some land manager functions for this scene
            EventManager.OnLandObjectAdded +=
                new EventManager.LandObjectAdded(simDataService.StoreLandObject);
            EventManager.OnLandObjectRemoved +=
                new EventManager.LandObjectRemoved(simDataService.RemoveLandObject);

            m_sceneGraph = new SceneGraph(this, m_regInfo);

            // If the scene graph has an Unrecoverable error, restart this sim.
            // Currently the only thing that causes it to happen is two kinds of specific
            // Physics based crashes.
            //
            // Out of memory
            // Operating system has killed the plugin
            m_sceneGraph.UnRecoverableError += RestartNow;

            RegisterDefaultSceneEvents();

            DumpAssetsToFile = dumpAssetsToFile;

            m_scripts_enabled = !RegionInfo.RegionSettings.DisableScripts;

            m_physics_enabled = !RegionInfo.RegionSettings.DisablePhysics;

            StatsReporter = new SimStatsReporter(this);
            StatsReporter.OnSendStatsResult += SendSimStatsPackets;
            StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats;

            // Old
            /*
            m_simulatorVersion = simulatorVersion
                + " (OS " + Util.GetOperatingSystemInformation() + ")"
                + " ChilTasks:" + m_seeIntoRegionFromNeighbor.ToString()
                + " PhysPrim:" + m_physicalPrim.ToString();
            */

            m_simulatorVersion = simulatorVersion + " (" + Util.GetRuntimeInformation() + ")";

            #region Region Config

            try
            {
                // Region config overrides global config
                //
                IConfig startupConfig = m_config.Configs["Startup"];

                //Animation states
                m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
                // TODO: Change default to true once the feature is supported
                m_usePreJump = startupConfig.GetBoolean("enableprejump", false);

                m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys);
                if (RegionInfo.NonphysPrimMax > 0)
                {
                    m_maxNonphys = RegionInfo.NonphysPrimMax;
                }

                m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys);

                if (RegionInfo.PhysPrimMax > 0)
                {
                    m_maxPhys = RegionInfo.PhysPrimMax;
                }

                // Here, if clamping is requested in either global or
                // local config, it will be used
                //
                m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize);
                if (RegionInfo.ClampPrimSize)
                {
                    m_clampPrimSize = true;
                }

                m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries);
                m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings);
                m_dontPersistBefore =
                  startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE);
                m_dontPersistBefore *= 10000000;
                m_persistAfter =
                  startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE);
                m_persistAfter *= 10000000;

                m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");

                IConfig packetConfig = m_config.Configs["PacketPool"];
                if (packetConfig != null)
                {
                    PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true);
                    PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true);
                }

                m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);

                m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true);
                if (m_generateMaptiles)
                {
                    int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0);
                    if (maptileRefresh != 0)
                    {
                        m_mapGenerationTimer.Interval = maptileRefresh * 1000;
                        m_mapGenerationTimer.Elapsed += RegenerateMaptile;
                        m_mapGenerationTimer.AutoReset = true;
                        m_mapGenerationTimer.Start();
                    }
                }
                else
                {
                    string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString());
                    UUID tileID;

                    if (UUID.TryParse(tile, out tileID))
                    {
                        RegionInfo.RegionSettings.TerrainImageID = tileID;
                    }
                }

                Random rnd = new Random();
                GenerationSeed = startupConfig.GetLong("TerragenSeed", (long)rnd.Next());
            }
            catch
            {
                m_log.Warn("[SCENE]: Failed to load StartupConfig");
            }

            #endregion Region Config

            #region Interest Management

            if (m_config != null)
            {
                IConfig interestConfig = m_config.Configs["InterestManagement"];
                if (interestConfig != null)
                {
                    string update_prioritization_scheme = interestConfig.GetString("UpdatePrioritizationScheme", "Time").Trim().ToLower();

                    try
                    {
                        m_priorityScheme = (UpdatePrioritizationSchemes)Enum.Parse(typeof(UpdatePrioritizationSchemes), update_prioritization_scheme, true);
                    }
                    catch (Exception)
                    {
                        m_log.Warn("[PRIORITIZER]: UpdatePrioritizationScheme was not recognized, setting to default prioritizer Time");
                        m_priorityScheme = UpdatePrioritizationSchemes.Time;
                    }

                    m_reprioritizationEnabled = interestConfig.GetBoolean("ReprioritizationEnabled", true);
                    m_reprioritizationInterval = interestConfig.GetDouble("ReprioritizationInterval", 5000.0);
                    m_rootReprioritizationDistance = interestConfig.GetDouble("RootReprioritizationDistance", 10.0);
                    m_childReprioritizationDistance = interestConfig.GetDouble("ChildReprioritizationDistance", 20.0);
                }
            }

            m_log.Info("[SCENE]: Using the " + m_priorityScheme + " prioritization scheme");

            #endregion Interest Management
        }
예제 #26
0
파일: Scene.cs 프로젝트: shangcheng/Aurora
        public Scene(RegionInfo regInfo, AgentCircuitManager authen,
                     SceneCommunicationService sceneGridService,
            IConfigSource config, string simulatorVersion, ISimulationDataService simDataService, IStatsCollector stats)
        {
            //THIS NEEDS RESET TO FIX RESTARTS
            shuttingdown = false;

            m_stats = stats;
            m_config = config;
            Random random = new Random();
            m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue / 2)) + (uint)(uint.MaxValue / 4);
            m_authenticateHandler = authen;
            m_sceneGridService = sceneGridService;
            m_regInfo = regInfo;
            m_lastUpdate = Util.EnvironmentTickCount();

            
            BordersLocked = true;

            Border northBorder = new Border();
            northBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, (int)Constants.RegionSize);  //<---
            northBorder.CrossDirection = Cardinals.N;
            NorthBorders.Add(northBorder);

            Border southBorder = new Border();
            southBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, 0);    //--->
            southBorder.CrossDirection = Cardinals.S;
            SouthBorders.Add(southBorder);

            Border eastBorder = new Border();
            eastBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, (int)Constants.RegionSize);   //<---
            eastBorder.CrossDirection = Cardinals.E;
            EastBorders.Add(eastBorder);

            Border westBorder = new Border();
            westBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, 0);     //--->
            westBorder.CrossDirection = Cardinals.W;
            WestBorders.Add(westBorder);

            BordersLocked = false;

            AuroraEventManager = new AuroraEventManager();
            m_eventManager = new EventManager();
            m_permissions = new ScenePermissions(this);

            m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this);
            m_asyncSceneObjectDeleter.Enabled = true;

            m_SimulationDataService = simDataService;

            // Load region settings
            m_regInfo.RegionSettings = m_SimulationDataService.LoadRegionSettings(m_regInfo.RegionID);
            FindEstateInfo();

            //Bind Storage Manager functions to some land manager functions for this scene
            IParcelServiceConnector conn = DataManager.RequestPlugin<IParcelServiceConnector>();
            if(conn != null)
            {
                EventManager.OnLandObjectAdded +=
                    new EventManager.LandObjectAdded(conn.StoreLandObject);
                EventManager.OnLandObjectRemoved +=
                    new EventManager.LandObjectRemoved(conn.RemoveLandObject);
            }
            else
            {
                EventManager.OnLandObjectAdded +=
                    new EventManager.LandObjectAdded(SimulationDataService.StoreLandObject);
                EventManager.OnLandObjectRemoved +=
                    new EventManager.LandObjectRemoved(SimulationDataService.RemoveLandObject);
            }

            m_sceneGraph = new SceneGraph(this, m_regInfo);

            StatsReporter = new SimStatsReporter(this);
            StatsReporter.OnSendStatsResult += SendSimStatsPackets;
            StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats;

            m_simulatorVersion = simulatorVersion + " (" + Util.GetRuntimeInformation() + ")";

            #region Region Config

            try
            {
                DirectionsToBlockChildAgents = new bool[3,3];
                DirectionsToBlockChildAgents.Initialize();
                IConfig aurorastartupConfig = m_config.Configs["AuroraStartup"];
                if (aurorastartupConfig != null)
                {
                    RunScriptsInAttachments = aurorastartupConfig.GetBoolean("AllowRunningOfScriptsInAttachments", false);
                    m_UseSelectionParticles = aurorastartupConfig.GetBoolean("UseSelectionParticles", true);
                    EnableFakeRaycasting = aurorastartupConfig.GetBoolean("EnableFakeRaycasting", false);
                    MaxLowValue = aurorastartupConfig.GetFloat("MaxLowValue", -1000);
                    Util.RegionViewSize = aurorastartupConfig.GetInt("RegionSightSize", 1);
                    Util.CloseLocalRegions = aurorastartupConfig.GetBoolean("CloseLocalAgents", true);
                    m_DefaultObjectName = aurorastartupConfig.GetString("DefaultObjectName", m_DefaultObjectName);
                    CheckForObjectCulling = aurorastartupConfig.GetBoolean("CheckForObjectCulling", CheckForObjectCulling);
                    SetObjectCapacity(aurorastartupConfig.GetInt("ObjectCapacity", ObjectCapacity));
                }

                IConfig regionConfig = m_config.Configs[this.RegionInfo.RegionName];
                if (regionConfig != null)
                {
                    #region Block Child Agents config

                    //   [{0,2}, {1, 2}, {2,2}]
                    //   [{0,1}, {1, 1}, {2,1}]  1,1 is the current region
                    //   [{0,0}, {1, 0}, {2,0}]

                    //SouthWest
                    DirectionsToBlockChildAgents[0, 0] = regionConfig.GetBoolean("BlockChildAgentsSouthWest", false);
                    //South
                    DirectionsToBlockChildAgents[1, 0] = regionConfig.GetBoolean("BlockChildAgentsSouth", false);
                    //SouthEast
                    DirectionsToBlockChildAgents[2, 0] = regionConfig.GetBoolean("BlockChildAgentsSouthEast", false);


                    //West
                    DirectionsToBlockChildAgents[0, 1] = regionConfig.GetBoolean("BlockChildAgentsWest", false);
                    //East
                    DirectionsToBlockChildAgents[2, 1] = regionConfig.GetBoolean("BlockChildAgentsEast", false);


                    //NorthWest
                    DirectionsToBlockChildAgents[0, 2] = regionConfig.GetBoolean("BlockChildAgentsNorthWest", false);
                    //North
                    DirectionsToBlockChildAgents[1, 2] = regionConfig.GetBoolean("BlockChildAgentsNorth", false);
                    //NorthEast
                    DirectionsToBlockChildAgents[2, 2] = regionConfig.GetBoolean("BlockChildAgentsNorthEast", false);

                    #endregion
                }
                // Region config overrides global config
                //
                IConfig startupConfig = m_config.Configs["Startup"];

                //Animation states
                IConfig animationConfig = m_config.Configs["Animations"];
                if (animationConfig != null)
                {
                    m_UseNewStyleMovement = animationConfig.GetBoolean("enableNewMovement", m_UseNewStyleMovement);
                    m_usePreJump = animationConfig.GetBoolean("enableprejump", m_usePreJump);
                    m_useSplatAnimation = animationConfig.GetBoolean("enableSplatAnimation", m_useSplatAnimation);
                }
                m_seeIntoRegionFromNeighbor = RegionInfo.SeeIntoThisSimFromNeighbor;
                m_trustBinaries = RegionInfo.TrustBinariesFromForeignSims;
                m_allowScriptCrossings = RegionInfo.AllowScriptCrossing;

                IConfig persistanceConfig = m_config.Configs["Persistance"];
                if (persistanceConfig != null)
                {
                    m_dontPersistBefore =
                        persistanceConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE);
                    m_dontPersistBefore *= 10000000;

                    m_persistAfter =
                        persistanceConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE);
                    m_persistAfter *= 10000000;
                }
                else
                {
                    m_dontPersistBefore = DEFAULT_MIN_TIME_FOR_PERSISTENCE;
                    m_dontPersistBefore *= 10000000;
                    m_persistAfter = DEFAULT_MAX_TIME_FOR_PERSISTENCE;
                    m_persistAfter *= 10000000;
                }
                IConfig scriptEngineConfig = m_config.Configs["ScriptEngines"];
                if (scriptEngineConfig != null)
                    m_defaultScriptEngine = scriptEngineConfig.GetString("DefaultScriptEngine", "AuroraDotNetEngine");

                IConfig packetConfig = m_config.Configs["PacketPool"];
                if (packetConfig != null)
                {
                    PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true);
                    PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true);
                }

                m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);
            }
            catch
            {
                m_log.Warn("[SCENE]: Failed to load StartupConfig");
            }

            #endregion Region Config

            #region Interest Management

            if (m_config != null)
            {
                IConfig interestConfig = m_config.Configs["InterestManagement"];
                if (interestConfig != null)
                {
                    string update_prioritization_scheme = interestConfig.GetString("UpdatePrioritizationScheme", "Time").Trim().ToLower();

                    try
                    {
                        m_priorityScheme = (UpdatePrioritizationSchemes)Enum.Parse(typeof(UpdatePrioritizationSchemes), update_prioritization_scheme, true);
                    }
                    catch (Exception)
                    {
                        m_log.Warn("[PRIORITIZER]: UpdatePrioritizationScheme was not recognized, setting to default prioritizer Time");
                        m_priorityScheme = UpdatePrioritizationSchemes.Time;
                    }

                    m_reprioritizationEnabled = interestConfig.GetBoolean("ReprioritizationEnabled", true);
                    m_reprioritizationInterval = interestConfig.GetDouble("ReprioritizationInterval", 5000.0);
                    m_rootReprioritizationDistance = interestConfig.GetDouble("RootReprioritizationDistance", 10.0);
                    m_childReprioritizationDistance = interestConfig.GetDouble("ChildReprioritizationDistance", 20.0);
                }
            }

            //m_log.Info("[SCENE]: Using the " + m_priorityScheme + " prioritization scheme");

            #endregion Interest Management

            #region Startup Complete config

            EventManager.OnAddToStartupQueue += AddToStartupQueue;
            EventManager.OnFinishedStartup += FinishedStartup;
            EventManager.OnStartupComplete += StartupComplete;

            AddToStartupQueue("Startup");

            #endregion

            LoadWorldMap();

            //Add stats handlers
            MainServer.Instance.AddStreamHandler(new RegionStatsHandler(RegionInfo));
        }
예제 #27
0
 protected abstract Scene CreateScene(RegionInfo regionInfo, ISimulationDataService simDataService, IEstateDataService estateDataService, AgentCircuitManager circuitManager);
예제 #28
0
        public Scene(RegionInfo regInfo, AgentCircuitManager authen,
                     SceneCommunicationService sceneGridService,
                     ISimulationDataService simDataService, IEstateDataService estateDataService,
                     ModuleLoader moduleLoader, bool dumpAssetsToFile,
                     IConfigSource config, string simulatorVersion)
            : this(regInfo)
        {
            m_config = config;


            Random random = new Random();

            m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue / 2)) + (uint)(uint.MaxValue / 4);
            m_moduleLoader = moduleLoader;
            m_authenticateHandler = authen;
            m_sceneGridService = sceneGridService;
            m_SimulationDataService = simDataService;
            m_EstateDataService = estateDataService;
            m_regionHandle = m_regInfo.RegionHandle;
            m_regionName = m_regInfo.RegionName;

            m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this);
            m_asyncSceneObjectDeleter.Enabled = true;

            m_asyncInventorySender = new AsyncInventorySender(this);

            #region Region Settings

            // Load region settings
            // LoadRegionSettings creates new region settings in persistence if they don't already exist for this region.
            // However, in this case, the default textures are not set in memory properly, so we need to do it here and
            // resave.
            // FIXME: It shouldn't be up to the database plugins to create this data - we should do it when a new
            // region is set up and avoid these gyrations.
            RegionSettings rs = simDataService.LoadRegionSettings(m_regInfo.RegionID);
            bool updatedTerrainTextures = false;
            if (rs.TerrainTexture1 == UUID.Zero)
            {
                rs.TerrainTexture1 = RegionSettings.DEFAULT_TERRAIN_TEXTURE_1;
                updatedTerrainTextures = true;
            }

            if (rs.TerrainTexture2 == UUID.Zero)
            {
                rs.TerrainTexture2 = RegionSettings.DEFAULT_TERRAIN_TEXTURE_2;
                updatedTerrainTextures = true;
            }

            if (rs.TerrainTexture3 == UUID.Zero)
            {
                rs.TerrainTexture3 = RegionSettings.DEFAULT_TERRAIN_TEXTURE_3;
                updatedTerrainTextures = true;
            }

            if (rs.TerrainTexture4 == UUID.Zero)
            {
                rs.TerrainTexture4 = RegionSettings.DEFAULT_TERRAIN_TEXTURE_4;
                updatedTerrainTextures = true;
            }

            if (updatedTerrainTextures)
                rs.Save();

            m_regInfo.RegionSettings = rs;

            if (estateDataService != null)
                m_regInfo.EstateSettings = estateDataService.LoadEstateSettings(m_regInfo.RegionID, false);

            #endregion Region Settings

            MainConsole.Instance.Commands.AddCommand("region", false, "reload estate",
                                          "reload estate",
                                          "Reload the estate data", HandleReloadEstate);

            MainConsole.Instance.Commands.AddCommand("region", false, "delete object owner",
                                          "delete object owner <UUID>",
                                          "Delete object by owner", HandleDeleteObject);
            MainConsole.Instance.Commands.AddCommand("region", false, "delete object creator",
                                          "delete object creator <UUID>",
                                          "Delete object by creator", HandleDeleteObject);
            MainConsole.Instance.Commands.AddCommand("region", false, "delete object uuid",
                                          "delete object uuid <UUID>",
                                          "Delete object by uuid", HandleDeleteObject);
            MainConsole.Instance.Commands.AddCommand("region", false, "delete object name",
                                          "delete object name <name>",
                                          "Delete object by name", HandleDeleteObject);

            MainConsole.Instance.Commands.AddCommand("region", false, "delete object outside",
                                          "delete object outside",
                                          "Delete all objects outside boundaries", HandleDeleteObject);

            //Bind Storage Manager functions to some land manager functions for this scene
            EventManager.OnLandObjectAdded +=
                new EventManager.LandObjectAdded(simDataService.StoreLandObject);
            EventManager.OnLandObjectRemoved +=
                new EventManager.LandObjectRemoved(simDataService.RemoveLandObject);

            m_sceneGraph = new SceneGraph(this);

            // If the scene graph has an Unrecoverable error, restart this sim.
            // Currently the only thing that causes it to happen is two kinds of specific
            // Physics based crashes.
            //
            // Out of memory
            // Operating system has killed the plugin
            m_sceneGraph.UnRecoverableError += RestartNow;

            RegisterDefaultSceneEvents();

            DumpAssetsToFile = dumpAssetsToFile;

            m_scripts_enabled = !RegionInfo.RegionSettings.DisableScripts;

            m_physics_enabled = !RegionInfo.RegionSettings.DisablePhysics;

            m_simulatorVersion = simulatorVersion + " (" + Util.GetRuntimeInformation() + ")";

            #region Region Config

            try
            {
                // Region config overrides global config
                //
                IConfig startupConfig = m_config.Configs["Startup"];

                m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance", m_defaultDrawDistance);
                m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup);
                if (!m_useBackup)
                    m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName);

                //Animation states
                m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);

                m_physicalPrim = startupConfig.GetBoolean("physical_prim", true);

                m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys);
                if (RegionInfo.NonphysPrimMax > 0)
                {
                    m_maxNonphys = RegionInfo.NonphysPrimMax;
                }

                m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys);

                if (RegionInfo.PhysPrimMax > 0)
                {
                    m_maxPhys = RegionInfo.PhysPrimMax;
                }

                // Here, if clamping is requested in either global or
                // local config, it will be used
                //
                m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize);
                if (RegionInfo.ClampPrimSize)
                {
                    m_clampPrimSize = true;
                }

                m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries);
                m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings);
                m_dontPersistBefore =
                  startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE);
                m_dontPersistBefore *= 10000000;
                m_persistAfter =
                  startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE);
                m_persistAfter *= 10000000;

                m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");


                float fps = startupConfig.GetFloat("SimulationFPS", 45f);
                m_simframetime = 1000.0f / fps;
                // limit it from 10 to 50fps
                if (m_simframetime < 22.0)
                    m_simframetime = 22.0f;
                else if (m_simframetime > 100f)
                    m_simframetime = 100f;

                fps = startupConfig.GetFloat("PhysicsSimulationFPS", 45f);
                // limit it from  2fps to SimulationFPS
                m_simphysframetime = 1000.0f / fps;
                if (m_simphysframetime <= m_simframetime)
                    m_simphysframetime = m_simframetime - 2; // the 2 is bc of my bad coding in timing control
                else if (m_simphysframetime > 500f)
                    m_simphysframetime = 500f;
                IConfig packetConfig = m_config.Configs["PacketPool"];
                if (packetConfig != null)
                {
                    PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true);
                    PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true);
                }

                m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);

                m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true);
                if (m_generateMaptiles)
                {
                    int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0);
                    if (maptileRefresh != 0)
                    {
                        m_mapGenerationTimer.Interval = maptileRefresh * 1000;
                        m_mapGenerationTimer.Elapsed += RegenerateMaptile;
                        m_mapGenerationTimer.AutoReset = true;
                        m_mapGenerationTimer.Start();
                    }
                }
                else
                {
                    string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString());
                    UUID tileID;

                    if (UUID.TryParse(tile, out tileID))
                    {
                        RegionInfo.RegionSettings.TerrainImageID = tileID;
                    }
                }


                m_update_backup           = startupConfig.GetInt(   "UpdateStorageEveryNFrames",         m_update_backup);
                m_update_coarse_locations = startupConfig.GetInt(   "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations);
                m_update_entitymovement   = startupConfig.GetInt(   "UpdateEntityMovementEveryNFrames",  m_update_entitymovement);
                m_update_events           = startupConfig.GetInt(   "UpdateEventsEveryNFrames",          m_update_events);
                m_update_objects          = startupConfig.GetInt(   "UpdateObjectsEveryNFrames",         m_update_objects);
                m_update_physics          = startupConfig.GetInt(   "UpdatePhysicsEveryNFrames",         m_update_physics);
                m_update_presences        = startupConfig.GetInt(   "UpdateAgentsEveryNFrames",          m_update_presences);
                m_update_terrain          = startupConfig.GetInt(   "UpdateTerrainEveryNFrames",         m_update_terrain);
                m_update_temp_cleaning    = startupConfig.GetInt(   "UpdateTempCleaningEveryNFrames",    m_update_temp_cleaning);
            }
            catch
            {
                m_log.Warn("[SCENE]: Failed to load StartupConfig");
            }

            #endregion Region Config

            #region Interest Management

            if (m_config != null)
            {
                IConfig interestConfig = m_config.Configs["InterestManagement"];
                if (interestConfig != null)
                {
                    string update_prioritization_scheme = interestConfig.GetString("UpdatePrioritizationScheme", "Time").Trim().ToLower();

                    try
                    {
                        m_priorityScheme = (UpdatePrioritizationSchemes)Enum.Parse(typeof(UpdatePrioritizationSchemes), update_prioritization_scheme, true);
                    }
                    catch (Exception)
                    {
                        m_log.Warn("[PRIORITIZER]: UpdatePrioritizationScheme was not recognized, setting to default prioritizer Time");
                        m_priorityScheme = UpdatePrioritizationSchemes.Time;
                    }

                    m_reprioritizationEnabled = interestConfig.GetBoolean("ReprioritizationEnabled", true);
                    m_reprioritizationInterval = interestConfig.GetDouble("ReprioritizationInterval", 5000.0);
                    m_rootReprioritizationDistance = interestConfig.GetDouble("RootReprioritizationDistance", 10.0);
                    m_childReprioritizationDistance = interestConfig.GetDouble("ChildReprioritizationDistance", 20.0);
                }
            }

            m_log.Info("[SCENE]: Using the " + m_priorityScheme + " prioritization scheme");

            #endregion Interest Management

            StatsReporter = new SimStatsReporter(this);
            StatsReporter.OnSendStatsResult += SendSimStatsPackets;
            StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats;            
        }
        /// <summary>
        /// Process inventory backup
        /// </summary>
        /// <param name="datastore"></param>
        public void ProcessInventoryBackup(ISimulationDataService datastore)
        {
            // Removed this because linking will cause an immediate delete of the new
            // child prim from the database and the subsequent storing of the prim sees
            // the inventory of it as unchanged and doesn't store it at all. The overhead
            // of storing prim inventory needlessly is much less than the aggravation
            // of prim inventory loss.
            //            if (HasInventoryChanged)
            //            {
                Items.LockItemsForRead(true);
                try
                {
                    datastore.StorePrimInventory(m_part.UUID, Items.Values);
                }
                catch {}

                HasInventoryChanged = false;

                Items.LockItemsForRead(false);

            //            }
        }
예제 #30
0
        private void EventManager_OnBackup(ISimulationDataService datastore, bool forcedBackup)
        {
            List <FaceMaterial> toStore = null;

            lock (materialslock)
            {
                if (m_storeBusy && !forcedBackup)
                {
                    return;
                }

                if (m_changed.Count == 0)
                {
                    if (forcedBackup)
                    {
                        return;
                    }

                    UUID id;
                    int  throttle = 0;
                    while (delayedDelete.Count > 0 && throttle < 5)
                    {
                        id = delayedDelete.Dequeue();
                        if (m_Materials.ContainsKey(id))
                        {
                            if (m_MaterialsRefCount[id] <= 0)
                            {
                                m_Materials.Remove(id);
                                m_MaterialsRefCount.Remove(id);
                                m_cache.Expire(id.ToString());
                                ++throttle;
                            }
                        }
                    }
                    return;
                }

                if (forcedBackup)
                {
                    toStore = new List <FaceMaterial>(m_changed.Keys);
                    m_changed.Clear();
                }
                else
                {
                    toStore = new List <FaceMaterial>();
                    double storetime = Util.GetTimeStamp() - 30.0;
                    foreach (KeyValuePair <FaceMaterial, double> kvp in m_changed)
                    {
                        if (kvp.Value < storetime)
                        {
                            toStore.Add(kvp.Key);
                        }
                    }
                    foreach (FaceMaterial fm in toStore)
                    {
                        m_changed.Remove(fm);
                    }
                }
            }

            if (toStore.Count > 0)
            {
                m_storeBusy = true;
                if (forcedBackup)
                {
                    foreach (FaceMaterial fm in toStore)
                    {
                        AssetBase a = MakeAsset(fm, false);
                        m_scene.AssetService.Store(a);
                    }
                    m_storeBusy = false;
                }
                else
                {
                    Util.FireAndForget(delegate
                    {
                        foreach (FaceMaterial fm in toStore)
                        {
                            AssetBase a = MakeAsset(fm, false);
                            m_scene.AssetService.Store(a);
                        }
                        m_storeBusy = false;
                    });
                }
            }
        }
예제 #31
0
        /// <summary>
        /// Set up a scene. If it's more then one scene, use the same CommunicationsManager to link regions
        /// or a different, to get a brand new scene with new shared region modules.
        /// </summary>
        /// <param name="name">Name of the region</param>
        /// <param name="id">ID of the region</param>
        /// <param name="x">X co-ordinate of the region</param>
        /// <param name="y">Y co-ordinate of the region</param>
        /// <param name="cm">This should be the same if simulating two scenes within a standalone</param>
        /// <param name="realServices">Starts real inventory and asset services, as opposed to mock ones, if true</param>
        /// <returns></returns>
        public static TestScene SetupScene(
            string name, UUID id, uint x, uint y, String realServices)
        {
            bool newScene = false;

            Console.WriteLine("Setting up test scene {0}", name);

            // REFACTORING PROBLEM!
            //// If cm is the same as our last commsManager used, this means the tester wants to link
            //// regions. In this case, don't use the sameshared region modules and dont initialize them again.
            //// Also, no need to start another MainServer and MainConsole instance.
            //if (cm == null || cm != commsManager)
            //{
            //    System.Console.WriteLine("Starting a brand new scene");
            //    newScene = true;
            MainConsole.Instance = new MockConsole("TEST PROMPT");
            //    MainServer.Instance = new BaseHttpServer(980);
            //    commsManager = cm;
            //}

            // We must set up a console otherwise setup of some modules may fail
            RegionInfo regInfo = new RegionInfo(x, y, new IPEndPoint(IPAddress.Loopback, 9000), "127.0.0.1");

            regInfo.RegionName = name;
            regInfo.RegionID   = id;

            AgentCircuitManager       acm = new AgentCircuitManager();
            SceneCommunicationService scs = new SceneCommunicationService();

            ISimulationDataService simDataService    = OpenSim.Server.Base.ServerUtils.LoadPlugin <ISimulationDataService>("OpenSim.Tests.Common.dll", null);
            IEstateDataService     estateDataService = null;
            IConfigSource          configSource      = new IniConfigSource();

            TestScene testScene = new TestScene(
                regInfo, acm, scs, simDataService, estateDataService, null, false, false, false, configSource, null);

            INonSharedRegionModule capsModule = new CapabilitiesModule();

            capsModule.Initialise(new IniConfigSource());
            testScene.AddRegionModule(capsModule.Name, capsModule);
            capsModule.AddRegion(testScene);

            IRegionModule godsModule = new GodsModule();

            godsModule.Initialise(testScene, new IniConfigSource());
            testScene.AddModule(godsModule.Name, godsModule);
            realServices = realServices.ToLower();
            // IConfigSource config = new IniConfigSource();

            // If we have a brand new scene, need to initialize shared region modules
            if ((m_assetService == null && m_inventoryService == null) || newScene)
            {
                if (realServices.Contains("asset"))
                {
                    StartAssetService(testScene, true);
                }
                else
                {
                    StartAssetService(testScene, false);
                }

                // For now, always started a 'real' authentication service
                StartAuthenticationService(testScene, true);

                if (realServices.Contains("inventory"))
                {
                    StartInventoryService(testScene, true);
                }
                else
                {
                    StartInventoryService(testScene, false);
                }

                StartGridService(testScene, true);
                StartUserAccountService(testScene);
                StartPresenceService(testScene);
            }
            // If not, make sure the shared module gets references to this new scene
            else
            {
                m_assetService.AddRegion(testScene);
                m_assetService.RegionLoaded(testScene);
                m_inventoryService.AddRegion(testScene);
                m_inventoryService.RegionLoaded(testScene);
                m_userAccountService.AddRegion(testScene);
                m_userAccountService.RegionLoaded(testScene);
                m_presenceService.AddRegion(testScene);
                m_presenceService.RegionLoaded(testScene);
            }

            m_inventoryService.PostInitialise();
            m_assetService.PostInitialise();
            m_userAccountService.PostInitialise();
            m_presenceService.PostInitialise();
            testScene.RegionInfo.EstateSettings.EstateOwner = UUID.Random();
            testScene.SetModuleInterfaces();

            testScene.LandChannel = new TestLandChannel(testScene);
            testScene.LoadWorldMap();

            PhysicsPluginManager physicsPluginManager = new PhysicsPluginManager();

            physicsPluginManager.LoadPluginsFromAssembly("Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll");
            testScene.PhysicsScene
                = physicsPluginManager.GetPhysicsScene("basicphysics", "MarchingCubes", "ZeroMesher", new IniConfigSource(), "test");

            // It's really not a good idea to use static variables as they carry over between tests, leading to
            // problems that are extremely hard to debug.  Really, these static fields need to be eliminated -
            // tests using multiple regions that need to share modules need to find another solution.
            m_assetService       = null;
            m_inventoryService   = null;
            m_gridService        = null;
            m_userAccountService = null;
            m_presenceService    = null;

            testScene.RegionInfo.EstateSettings = new EstateSettings();
            testScene.LoginsDisabled            = false;

            return(testScene);
        }
예제 #32
0
        /// <summary>
        /// Process inventory backup
        /// </summary>
        /// <param name="datastore"></param>
        public void ProcessInventoryBackup(ISimulationDataService datastore)
        {
            if (HasInventoryChanged)
            {
				HasInventoryChanged = false;
                List<TaskInventoryItem> items = GetInventoryItems();
                datastore.StorePrimInventory(m_part.UUID, items);
                    IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
                    if (engines != null)
                    {

                        foreach (TaskInventoryItem item in items)
                        {
                            if (item.Type == (int)InventoryType.LSL)
                            {
                                foreach (IScriptModule engine in engines)
                                {
                                    if (engine != null)
                                    {
                                        engine.SaveStateSave(item.ItemID, m_part.UUID);
                                    }
                                }
                            }
                        }
                    }

            }
        }
예제 #33
0
 protected abstract Scene CreateScene(RegionInfo regionInfo, ISimulationDataService simDataService, IEstateDataService estateDataService, AgentCircuitManager circuitManager);
예제 #34
0
        public SceneHelpers(CoreAssetCache cache)
        {
            SceneManager = new SceneManager();

            m_assetService          = StartAssetService(cache);
            m_authenticationService = StartAuthenticationService();
            m_inventoryService      = StartInventoryService();
            m_gridService           = StartGridService();
            m_userAccountService    = StartUserAccountService();
            m_presenceService       = StartPresenceService();

            m_inventoryService.PostInitialise();
            m_assetService.PostInitialise();
            m_userAccountService.PostInitialise();
            m_presenceService.PostInitialise();

            m_cache = cache;

            m_physicsScene = StartPhysicsScene();

            SimDataService 
                = OpenSim.Server.Base.ServerUtils.LoadPlugin<ISimulationDataService>("OpenSim.Tests.Common.dll", null);
        }
예제 #35
0
 public void TriggerOnBackup(ISimulationDataService dstore, bool forced)
 {
     OnBackupDelegate handlerOnAttach = OnBackup;
     if (handlerOnAttach != null)
     {
         foreach (OnBackupDelegate d in handlerOnAttach.GetInvocationList())
         {
             try
             {
                 d(dstore, forced);
             }
             catch (Exception e)
             {
                 m_log.ErrorFormat(
                     "[EVENT MANAGER]: Delegate for TriggerOnBackup failed - continuing.  {0} {1}", 
                     e.Message, e.StackTrace);
             }
         }
     }
 }
예제 #36
0
        /// <summary>
        /// Processes backup.
        /// </summary>
        /// <param name="datastore"></param>
        public virtual bool ProcessBackup(ISimulationDataService datastore, bool forcedBackup)
        {
            //if (!m_isBackedUp)
            //    return true;

            // Since this is the top of the section of call stack for backing up a particular scene object, don't let
            // any exception propogate upwards.

            if (IsDeleted || UUID == UUID.Zero)
                return true;

            try
            {
                if (isTimeToPersist() || forcedBackup) // forced means FORCED, you don't get a choice!
                {
                    if (HasGroupChanged || forcedBackup)
                    {
                        // don't backup while it's selected or you're asking for changes mid stream.
                        //m_log.DebugFormat(
                        //        "[SCENE]: Storing {0}, {1} in {2}",
                        //        Name, UUID, m_scene.RegionInfo.RegionName);

                        SceneObjectGroup backup_group = Copy(OwnerID, GroupID, false, Scene, false);
                        backup_group.RootPart.Velocity = RootPart.Velocity;
                        backup_group.RootPart.Acceleration = RootPart.Acceleration;
                        backup_group.RootPart.AngularVelocity = RootPart.AngularVelocity;
                        backup_group.RootPart.ParticleSystem = RootPart.ParticleSystem;
                        HasGroupChanged = false;

                        datastore.StoreObject(backup_group, m_scene.RegionInfo.RegionID);

                        backup_group.ForEachPart(delegate(SceneObjectPart part)
                        {
                            part.Inventory.ProcessInventoryBackup(datastore);
                        });

                        backup_group = null;
                        return true;
                    }
                }
            }
            catch (Exception e)
            {
                m_log.ErrorFormat(
                    "[SCENE]: Storing of {0}, {1} in {2} failed with exception {3}\n\t{4}",
                    Name, UUID, m_scene.RegionInfo.RegionName, e, e.StackTrace);
            }
            return false;
        }
예제 #37
0
        protected override Scene CreateScene(RegionInfo regionInfo, ISimulationDataService simDataService,
            IEstateDataService estateDataService, AgentCircuitManager circuitManager)
        {
            SceneCommunicationService sceneGridService = new SceneCommunicationService();

            return new Scene(
                regionInfo, circuitManager, sceneGridService,
                simDataService, estateDataService,
                Config, m_version);
        }
예제 #38
0
        /// <summary>
        /// Processes backup.
        /// </summary>
        /// <param name="datastore"></param>
        public virtual void ProcessBackup(ISimulationDataService datastore, bool forcedBackup)
        {
            if (!Backup)
            {
//                m_log.DebugFormat(
//                    "[WATER WARS]: Ignoring backup of {0} {1} since object is not marked to be backed up", Name, UUID);
                return;
            }

            if (IsDeleted || inTransit || UUID == UUID.Zero)
            {
//                m_log.DebugFormat(
//                    "[WATER WARS]: Ignoring backup of {0} {1} since object is marked as already deleted", Name, UUID);
                return;
            }

            if ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0)
                return;

            // Since this is the top of the section of call stack for backing up a particular scene object, don't let
            // any exception propogate upwards.
            try
            {
                if (!m_scene.ShuttingDown || // if shutting down then there will be nothing to handle the return so leave till next restart
                        !m_scene.LoginsEnabled || // We're starting up or doing maintenance, don't mess with things
                        m_scene.LoadingPrims) // Land may not be valid yet
                
                {
                    ILandObject parcel = m_scene.LandChannel.GetLandObject(
                            m_rootPart.GroupPosition.X, m_rootPart.GroupPosition.Y);

                    if (parcel != null && parcel.LandData != null &&
                            parcel.LandData.OtherCleanTime != 0)
                    {
                        if (parcel.LandData.OwnerID != OwnerID &&
                                (parcel.LandData.GroupID != GroupID ||
                                parcel.LandData.GroupID == UUID.Zero))
                        {
                            if ((DateTime.UtcNow - RootPart.Rezzed).TotalMinutes >
                                    parcel.LandData.OtherCleanTime)
                            {
                                // don't autoreturn if we have a sitting avatar
                                // mantis 7828 (but none the provided patchs)

                                if(GetSittingAvatarsCount() > 0)
                                {
                                    // do not respect npcs
                                    List<ScenePresence> sitters = GetSittingAvatars();
                                    foreach(ScenePresence sp in sitters)
                                    {
                                        if(!sp.IsDeleted && !sp.isNPC && sp.IsSatOnObject)
                                            return;
                                    }
                                }

                                DetachFromBackup();
                                m_log.DebugFormat(
                                    "[SCENE OBJECT GROUP]: Returning object {0} due to parcel autoreturn", 
                                     RootPart.UUID);
                                m_scene.AddReturn(OwnerID == GroupID ? LastOwnerID : OwnerID, Name, AbsolutePosition, "parcel autoreturn");
                                m_scene.DeRezObjects(null, new List<uint>() { RootPart.LocalId }, UUID.Zero,
                                        DeRezAction.Return, UUID.Zero);

                                return;
                            }
                        }
                    }

                }

                if (m_scene.UseBackup && HasGroupChanged)
                {
                    // don't backup while it's selected or you're asking for changes mid stream.
                    if (isTimeToPersist() || forcedBackup)
                    {
                        if (m_rootPart.PhysActor != null &&
                            (!m_rootPart.PhysActor.IsPhysical))
                        {
                            // Possible ghost prim
                            if (m_rootPart.PhysActor.Position != m_rootPart.GroupPosition)
                            {
                                foreach (SceneObjectPart part in m_parts.GetArray())
                                {
                                    // Re-set physics actor positions and
                                    // orientations
                                    part.GroupPosition = m_rootPart.GroupPosition;
                                }
                            }
                        }
//                        m_log.DebugFormat(
//                            "[SCENE]: Storing {0}, {1} in {2}",
//                            Name, UUID, m_scene.RegionInfo.RegionName);

                        if (RootPart.Shape.PCode == 9 && RootPart.Shape.State != 0)
                        {
                            RootPart.Shape.LastAttachPoint = RootPart.Shape.State;
                            RootPart.Shape.State = 0;
                            ScheduleGroupForFullUpdate();
                        }

                        SceneObjectGroup backup_group = Copy(false);
                        backup_group.RootPart.Velocity = RootPart.Velocity;
                        backup_group.RootPart.Acceleration = RootPart.Acceleration;
                        backup_group.RootPart.AngularVelocity = RootPart.AngularVelocity;
                        backup_group.RootPart.ParticleSystem = RootPart.ParticleSystem;
                        HasGroupChanged = false;
                        GroupContainsForeignPrims = false;

                        m_scene.EventManager.TriggerOnSceneObjectPreSave(backup_group, this);

                        datastore.StoreObject(backup_group, m_scene.RegionInfo.RegionID);

                        backup_group.ForEachPart(delegate(SceneObjectPart part) 
                        { 
                            part.Inventory.ProcessInventoryBackup(datastore); 

                            if(part.KeyframeMotion != null)
                            {
                                part.KeyframeMotion.Delete();
                                part.KeyframeMotion = null;
                            }
                        });

                        backup_group.Clear();
                        backup_group = null;
                    }
//                    else
//                    {
//                        m_log.DebugFormat(
//                            "[SCENE]: Did not update persistence of object {0} {1}, selected = {2}",
//                            Name, UUID, IsSelected);
//                    }
                }
            }
            catch (Exception e)
            {
                m_log.ErrorFormat(
                    "[SCENE]: Storing of {0}, {1} in {2} failed with exception {3}{4}", 
                    Name, UUID, m_scene.RegionInfo.RegionName, e.Message, e.StackTrace);
            }
        }