29 using System.Collections.Generic;
30 using System.Diagnostics;
32 using System.Drawing.Imaging;
35 using System.Threading;
40 using OpenMetaverse.Packets;
41 using OpenMetaverse.Imaging;
42 using OpenMetaverse.StructuredData;
43 using OpenSim.Framework;
44 using OpenSim.Framework.Monitoring;
45 using OpenSim.Services.Interfaces;
46 using OpenSim.Framework.Console;
47 using OpenSim.Region.Framework.Interfaces;
48 using OpenSim.Region.Framework.Scenes.Scripting;
49 using OpenSim.Region.Framework.Scenes.Serialization;
50 using OpenSim.Region.PhysicsModules.SharedBase;
56 namespace OpenSim.
Region.Framework.Scenes
62 private const long DEFAULT_MIN_TIME_FOR_PERSISTENCE = 60L;
63 private const long DEFAULT_MAX_TIME_FOR_PERSISTENCE = 600L;
66 public delegate
void SynchronizeSceneHandler(
Scene scene);
70 public bool EmergencyMonitoring =
false;
75 public bool DebugAnimations {
get; set; }
80 public bool DebugTeleporting {
get; set; }
85 public bool DebugUpdates {
get; set; }
96 public bool PeriodicBackup {
get; set; }
102 public bool UseBackup {
get; set; }
108 public bool PhysicsEnabled
112 return m_physicsEnabled;
117 m_physicsEnabled = value;
123 if (physScene != null)
124 physScene.SetPhysicsParameter(
130 private bool m_physicsEnabled;
135 public bool ScriptsEnabled
137 get {
return m_scripts_enabled; }
140 if (m_scripts_enabled != value)
144 m_log.Info(
"Stopping all Scripts in Scene");
146 EntityBase[] entities = Entities.GetEntities();
150 ((SceneObjectGroup)ent).RemoveScriptInstances(
false);
155 m_log.Info(
"Starting all Scripts in Scene");
157 EntityBase[] entities = Entities.GetEntities();
162 SceneObjectGroup sog = (SceneObjectGroup)ent;
163 sog.CreateScriptInstances(0,
false, DefaultScriptEngine, 0);
169 m_scripts_enabled = value;
173 private bool m_scripts_enabled;
177 public bool ClampNegativeZ
179 get {
return m_clampNegativeZ; }
182 private bool m_clampNegativeZ =
false;
187 private object m_removeClientLock =
new object();
198 public bool PhysicalPrims {
get;
private set; }
206 public bool CollidablePrims {
get;
private set; }
211 public float m_minNonphys = 0.001f;
216 public float m_maxNonphys = 256;
221 public float m_minPhys = 0.01f;
226 public float m_maxPhys = 10;
231 public int m_linksetCapacity = 0;
235 public bool m_allowScriptCrossings =
true;
241 public bool LegacySitOffsets =
true;
246 public bool AllowAvatarCrossing {
get; set; }
251 public int m_linksetPhysCapacity = 0;
254 public bool m_useTrashOnDelete =
true;
259 public bool SendPeriodicAppearanceUpdates {
get; set; }
264 public float RootPositionUpdateTolerance {
get; set; }
269 public float RootRotationUpdateTolerance {
get; set; }
274 public float RootVelocityUpdateTolerance {
get; set; }
279 public int RootTerseUpdatePeriod {
get; set; }
284 public int ChildTerseUpdatePeriod {
get; set; }
286 protected float m_defaultDrawDistance = 255f;
287 public float DefaultDrawDistance
289 get {
return m_defaultDrawDistance; }
292 protected float m_maxDrawDistance = 512.0f;
294 public float MaxDrawDistance
296 get {
return m_maxDrawDistance; }
299 protected float m_maxRegionViewDistance = 255f;
300 public float MaxRegionViewDistance
302 get {
return m_maxRegionViewDistance; }
305 private List<string> m_AllowedViewers =
new List<string>();
306 private List<string> m_BannedViewers =
new List<string>();
310 public bool m_strictAccessControl =
true;
311 public bool m_seeIntoBannedRegion =
false;
312 public int MaxUndoCount = 5;
314 public bool SeeIntoRegion {
get; set; }
317 public bool LoginLock =
false;
319 public bool StartDisabled =
false;
324 public long m_dontPersistBefore = DEFAULT_MIN_TIME_FOR_PERSISTENCE * 10000000L;
326 public long m_persistAfter = DEFAULT_MAX_TIME_FOR_PERSISTENCE * 10000000L;
331 protected List<RegionInfo> m_regionRestartNotifyList =
new List<RegionInfo>();
332 protected List<RegionInfo> m_neighbours =
new List<RegionInfo>();
333 protected string m_simulatorVersion =
"OpenSimulator Server";
362 private Dictionary<string, string> m_extraSettings;
376 public uint MaintenanceRun {
get;
private set; }
381 public float FrameTime {
get;
private set; }
382 public int FrameTimeWarnPercent {
get;
private set; }
383 public int FrameTimeCritPercent {
get;
private set; }
387 public bool Normalized55FPS {
get;
private set; }
395 public float MinMaintenanceTime {
get;
private set; }
397 private int m_update_physics = 1;
398 private int m_update_entitymovement = 1;
399 private int m_update_objects = 1;
400 private int m_update_presences = 1;
401 private int m_update_events = 1;
402 private int m_update_backup = 200;
404 private int m_update_terrain = 1000;
405 private int m_update_land = 10;
407 private int m_update_coarse_locations = 50;
408 private int m_update_temp_cleaning = 180;
410 private float agentMS;
411 private float frameMS;
412 private float physicsMS2;
413 private float physicsMS;
414 private float otherMS;
415 private float tempOnRezMS;
416 private float eventMS;
417 private float backupMS;
418 private float terrainMS;
419 private float landMS;
424 private int m_lastFrameTick;
426 public bool CombineRegions =
false;
430 private int m_lastMaintenanceTick;
435 private long m_scriptExecutionTime = 0;
441 private bool m_cleaningTemps =
false;
446 private ManualResetEvent m_updateWaitEvent =
new ManualResetEvent(
false);
451 private ManualResetEvent m_maintenanceWaitEvent =
new ManualResetEvent(
false);
455 private readonly
Timer m_restartTimer =
new Timer(15000);
456 private volatile bool m_backingup;
457 private Dictionary<UUID, ReturnInfo> m_returns =
new Dictionary<UUID, ReturnInfo>();
458 private Dictionary<UUID, int> m_groupsWithTargets =
new Dictionary<UUID, int>();
460 private string m_defaultScriptEngine;
462 private int m_unixStartTime;
463 public int UnixStartTime
465 get {
return m_unixStartTime; }
471 private int m_LastLogin;
473 private int m_lastIncoming;
474 private int m_lastOutgoing;
475 private int m_hbRestarts = 0;
481 private Thread m_heartbeatThread;
486 public bool ShuttingDown
488 get {
return m_shuttingDown; }
490 private volatile bool m_shuttingDown;
502 get {
return m_active; }
518 private volatile bool m_active;
523 public bool IsRunning {
get {
return m_isRunning; } }
524 private volatile bool m_isRunning;
527 private bool m_firstHeartbeat =
true;
536 private Timer m_mapGenerationTimer =
new Timer();
537 private bool m_generateMaptiles;
544 public int SplitRegionID
546 get {
return m_splitRegionID; }
547 set { m_splitRegionID = value; }
550 public new float TimeDilation
552 get {
return m_sceneGraph.PhysicsScene.TimeDilation; }
559 StatsReporter.SetThreadCount(inUseThreads);
564 get {
return m_sceneGridService; }
571 if (m_snmpService == null)
573 m_snmpService = RequestModuleInterface<ISnmpModule>();
576 return m_snmpService;
584 if (m_SimulationDataService == null)
586 m_SimulationDataService = RequestModuleInterface<ISimulationDataService>();
588 if (m_SimulationDataService == null)
590 throw new Exception(
"No ISimulationDataService available.");
594 return m_SimulationDataService;
602 if (m_EstateDataService == null)
604 m_EstateDataService = RequestModuleInterface<IEstateDataService>();
606 if (m_EstateDataService == null)
608 throw new Exception(
"No IEstateDataService available.");
612 return m_EstateDataService;
620 if (m_AssetService == null)
622 m_AssetService = RequestModuleInterface<IAssetService>();
624 if (m_AssetService == null)
626 throw new Exception(
"No IAssetService available.");
630 return m_AssetService;
638 if (m_AuthorizationService == null)
640 m_AuthorizationService = RequestModuleInterface<IAuthorizationService>();
649 return m_AuthorizationService;
657 if (m_InventoryService == null)
659 m_InventoryService = RequestModuleInterface<IInventoryService>();
661 if (m_InventoryService == null)
663 throw new Exception(
"No IInventoryService available. This could happen if the config_include folder doesn't exist or if the OpenSim.ini [Architecture] section isn't set. Please also check that you have the correct version of your inventory service dll. Sometimes old versions of this dll will still exist. Do a clean checkout and re-create the opensim.ini from the opensim.ini.example.");
667 return m_InventoryService;
675 if (m_GridService == null)
677 m_GridService = RequestModuleInterface<IGridService>();
679 if (m_GridService == null)
681 throw new Exception(
"No IGridService available. This could happen if the config_include folder doesn't exist or if the OpenSim.ini [Architecture] section isn't set. Please also check that you have the correct version of your inventory service dll. Sometimes old versions of this dll will still exist. Do a clean checkout and re-create the opensim.ini from the opensim.ini.example.");
685 return m_GridService;
693 if (m_LibraryService == null)
694 m_LibraryService = RequestModuleInterface<ILibraryService>();
696 return m_LibraryService;
704 if (m_simulationService == null)
705 m_simulationService = RequestModuleInterface<ISimulationService>();
707 return m_simulationService;
715 if (m_AuthenticationService == null)
716 m_AuthenticationService = RequestModuleInterface<IAuthenticationService>();
717 return m_AuthenticationService;
725 if (m_PresenceService == null)
726 m_PresenceService = RequestModuleInterface<IPresenceService>();
727 return m_PresenceService;
735 if (m_UserAccountService == null)
736 m_UserAccountService = RequestModuleInterface<IUserAccountService>();
737 return m_UserAccountService;
745 if (m_AvatarService == null)
746 m_AvatarService = RequestModuleInterface<IAvatarService>();
747 return m_AvatarService;
755 if (m_GridUserService == null)
756 m_GridUserService = RequestModuleInterface<IGridUserService>();
757 return m_GridUserService;
765 if (m_AgentPreferencesService == null)
766 m_AgentPreferencesService = RequestModuleInterface<IAgentPreferencesService>();
767 return m_AgentPreferencesService;
778 get {
return m_AvatarFactory; }
783 get {
return m_capsModule; }
786 public int MonitorFrameTime {
get {
return (
int)frameMS; } }
787 public int MonitorPhysicsUpdateTime {
get {
return (
int)physicsMS; } }
788 public int MonitorPhysicsSyncTime {
get {
return (
int)physicsMS2; } }
789 public int MonitorOtherTime {
get {
return (
int)otherMS; } }
790 public int MonitorTempOnRezTime {
get {
return (
int)tempOnRezMS; } }
791 public int MonitorEventTime {
get {
return (
int)eventMS; } }
792 public int MonitorBackupTime {
get {
return (
int)backupMS; } }
793 public int MonitorTerrainTime {
get {
return (
int)terrainMS; } }
794 public int MonitorLandTime {
get {
return (
int)landMS; } }
795 public int MonitorLastFrameTick {
get {
return m_lastFrameTick; } }
798 public bool IsReprioritizationEnabled {
get; set; }
799 public float ReprioritizationInterval {
get; set; }
800 public float RootReprioritizationDistance {
get; set; }
801 public float ChildReprioritizationDistance {
get; set; }
802 private float m_minReprioritizationDistance = 32f;
806 get {
return m_authenticateHandler; }
812 get {
return m_sceneGraph.PhysicsScene; }
820 PhysicsScene.OnJointMoved -= jointMoved;
821 PhysicsScene.OnJointDeactivated -= jointDeactivated;
822 PhysicsScene.OnJointErrorMessage -= jointErrorMessage;
825 m_sceneGraph.PhysicsScene = value;
830 PhysicsScene.OnJointMoved += jointMoved;
831 PhysicsScene.OnJointDeactivated += jointDeactivated;
832 PhysicsScene.OnJointErrorMessage += jointErrorMessage;
837 public string DefaultScriptEngine
839 get {
return m_defaultScriptEngine; }
844 get {
return m_sceneGraph.Entities; }
849 private int m_SpawnPoint;
851 public string SpawnPointRouting
857 public bool TelehubAllowLandmarks
863 #endregion Properties
869 IConfigSource config,
string simulatorVersion)
874 FrameTimeWarnPercent = 60;
875 FrameTimeCritPercent = 40;
876 Normalized55FPS =
true;
877 MinMaintenanceTime = 1;
878 SeeIntoRegion =
true;
880 Random random =
new Random();
882 m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue / 2)) + (uint)(uint.MaxValue / 4);
883 m_authenticateHandler = authen;
885 m_SimulationDataService = simDataService;
886 m_EstateDataService = estateDataService;
892 m_asyncSceneObjectDeleter.Enabled =
true;
896 #region Region Settings
904 RegionSettings rs = simDataService.LoadRegionSettings(RegionInfo.RegionID);
905 m_extraSettings = simDataService.GetExtra(RegionInfo.RegionID);
907 bool updatedTerrainTextures =
false;
910 rs.TerrainTexture1 = RegionSettings.DEFAULT_TERRAIN_TEXTURE_1;
911 updatedTerrainTextures =
true;
916 rs.TerrainTexture2 = RegionSettings.DEFAULT_TERRAIN_TEXTURE_2;
917 updatedTerrainTextures =
true;
922 rs.TerrainTexture3 = RegionSettings.DEFAULT_TERRAIN_TEXTURE_3;
923 updatedTerrainTextures =
true;
928 rs.TerrainTexture4 = RegionSettings.DEFAULT_TERRAIN_TEXTURE_4;
929 updatedTerrainTextures =
true;
932 if (updatedTerrainTextures)
935 RegionInfo.RegionSettings = rs;
937 if (estateDataService != null)
938 RegionInfo.EstateSettings = estateDataService.LoadEstateSettings(RegionInfo.RegionID,
false);
940 #endregion Region Settings
943 EventManager.OnLandObjectAdded +=
944 new EventManager.LandObjectAdded(simDataService.StoreLandObject);
945 EventManager.OnLandObjectRemoved +=
946 new EventManager.LandObjectRemoved(simDataService.RemoveLandObject);
948 RegisterDefaultSceneEvents();
952 m_scripts_enabled = !RegionInfo.RegionSettings.DisableScripts;
954 PhysicsEnabled = !RegionInfo.RegionSettings.DisablePhysics;
956 m_simulatorVersion = simulatorVersion +
" (" + Util.GetRuntimeInformation() +
")";
958 #region Region Config
962 if (m_config.Configs[
"Startup"] != null)
964 IConfig startupConfig = m_config.Configs[
"Startup"];
966 StartDisabled = startupConfig.GetBoolean(
"StartDisabled",
false);
968 m_defaultDrawDistance = startupConfig.GetFloat(
"DefaultDrawDistance", m_defaultDrawDistance);
969 m_maxDrawDistance = startupConfig.GetFloat(
"MaxDrawDistance", m_maxDrawDistance);
970 m_maxRegionViewDistance = startupConfig.GetFloat(
"MaxRegionsViewDistance", m_maxRegionViewDistance);
972 LegacySitOffsets = startupConfig.GetBoolean(
"LegacyOpenSimSitOffsets", LegacySitOffsets);
974 if (m_defaultDrawDistance > m_maxDrawDistance)
975 m_defaultDrawDistance = m_maxDrawDistance;
977 if (m_maxRegionViewDistance > m_maxDrawDistance)
978 m_maxRegionViewDistance = m_maxDrawDistance;
980 UseBackup = startupConfig.GetBoolean(
"UseSceneBackup", UseBackup);
982 m_log.InfoFormat(
"[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName);
985 m_useFlySlow = startupConfig.GetBoolean(
"enableflyslow",
false);
987 SeeIntoRegion = startupConfig.GetBoolean(
"see_into_region", SeeIntoRegion);
989 MaxUndoCount = startupConfig.GetInt(
"MaxPrimUndos", 20);
991 PhysicalPrims = startupConfig.GetBoolean(
"physical_prim",
true);
992 CollidablePrims = startupConfig.GetBoolean(
"collidable_prim",
true);
993 m_minNonphys = startupConfig.GetFloat(
"NonPhysicalPrimMin", m_minNonphys);
996 m_minNonphys = RegionInfo.NonphysPrimMin;
999 m_maxNonphys = startupConfig.GetFloat(
"NonPhysicalPrimMax", m_maxNonphys);
1002 m_maxNonphys = RegionInfo.NonphysPrimMax;
1005 m_minPhys = startupConfig.GetFloat(
"PhysicalPrimMin", m_minPhys);
1008 m_minPhys = RegionInfo.PhysPrimMin;
1011 m_maxPhys = startupConfig.GetFloat(
"PhysicalPrimMax", m_maxPhys);
1015 m_maxPhys = RegionInfo.PhysPrimMax;
1018 m_linksetCapacity = startupConfig.GetInt(
"LinksetPrims", m_linksetCapacity);
1021 m_linksetCapacity = RegionInfo.LinksetCapacity;
1024 m_linksetPhysCapacity = startupConfig.GetInt(
"LinksetPhysPrims", m_linksetPhysCapacity);
1027 SpawnPointRouting = startupConfig.GetString(
"SpawnPointRouting",
"closest");
1028 TelehubAllowLandmarks = startupConfig.GetBoolean(
"TelehubAllowLandmark",
false);
1033 m_clampPrimSize = startupConfig.GetBoolean(
"ClampPrimSize", m_clampPrimSize);
1036 m_clampPrimSize =
true;
1039 m_clampNegativeZ = startupConfig.GetBoolean(
"ClampNegativeZ", m_clampNegativeZ);
1041 m_useTrashOnDelete = startupConfig.GetBoolean(
"UseTrashOnDelete",m_useTrashOnDelete);
1042 m_trustBinaries = startupConfig.GetBoolean(
"TrustBinaries", m_trustBinaries);
1043 m_allowScriptCrossings = startupConfig.GetBoolean(
"AllowScriptCrossing", m_allowScriptCrossings);
1044 m_dontPersistBefore =
1045 startupConfig.GetLong(
"MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE);
1046 m_dontPersistBefore *= 10000000;
1048 startupConfig.GetLong(
"MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE);
1049 m_persistAfter *= 10000000;
1051 m_defaultScriptEngine = startupConfig.GetString(
"DefaultScriptEngine",
"XEngine");
1052 m_log.InfoFormat(
"[SCENE]: Default script engine {0}", m_defaultScriptEngine);
1054 m_strictAccessControl = startupConfig.GetBoolean(
"StrictAccessControl", m_strictAccessControl);
1055 m_seeIntoBannedRegion = startupConfig.GetBoolean(
"SeeIntoBannedRegion", m_seeIntoBannedRegion);
1056 CombineRegions = startupConfig.GetBoolean(
"CombineContiguousRegions",
false);
1058 string[] possibleMapConfigSections =
new string[] {
"Map",
"Startup" };
1061 = Util.GetConfigVarFromSections<
bool>(config,
"GenerateMaptiles", possibleMapConfigSections,
true);
1063 if (m_generateMaptiles)
1065 int maptileRefresh = Util.GetConfigVarFromSections<
int>(config,
"MaptileRefresh", possibleMapConfigSections, 0);
1066 m_log.InfoFormat(
"[SCENE]: Region {0}, WORLD MAP refresh time set to {1} seconds", RegionInfo.RegionName, maptileRefresh);
1067 if (maptileRefresh != 0)
1069 m_mapGenerationTimer.Interval = maptileRefresh * 1000;
1070 m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister;
1071 m_mapGenerationTimer.AutoReset =
true;
1072 m_mapGenerationTimer.Start();
1078 = Util.GetConfigVarFromSections<
string>(
1079 config,
"MaptileStaticUUID", possibleMapConfigSections, UUID.Zero.ToString());
1083 if (tile !=
UUID.Zero.ToString() && UUID.TryParse(tile, out tileID))
1085 RegionInfo.RegionSettings.TerrainImageID = tileID;
1089 RegionInfo.RegionSettings.TerrainImageID = RegionInfo.MaptileStaticUUID;
1090 m_log.InfoFormat(
"[SCENE]: Region {0}, maptile set to {1}", RegionInfo.RegionName, RegionInfo.MaptileStaticUUID.ToString());
1094 string[] possibleAccessControlConfigSections =
new string[] {
"Startup",
"AccessControl"};
1097 = Util.GetConfigVarFromSections<
string>(
1098 config,
"AllowedClients", possibleAccessControlConfigSections, string.Empty);
1100 if (grant.Length > 0)
1102 foreach (
string viewer
in grant.Split(
','))
1104 m_AllowedViewers.Add(viewer.Trim().ToLower());
1109 = Util.GetConfigVarFromSections<
string>(
1110 config,
"DeniedClients", possibleAccessControlConfigSections, String.Empty);
1112 if (grant ==
String.Empty)
1113 grant = Util.GetConfigVarFromSections<
string>(
1114 config,
"BannedClients", possibleAccessControlConfigSections, String.Empty);
1116 if (grant.Length > 0)
1118 foreach (
string viewer
in grant.Split(
','))
1120 m_BannedViewers.Add(viewer.Trim().ToLower());
1124 FrameTime = startupConfig.GetFloat(
"FrameTime", FrameTime);
1125 FrameTimeWarnPercent = startupConfig.GetInt(
"FrameTimeWarnPercent", FrameTimeWarnPercent);
1126 FrameTimeCritPercent = startupConfig.GetInt(
"FrameTimeCritPercent", FrameTimeCritPercent);
1127 Normalized55FPS = startupConfig.GetBoolean(
"Normalized55FPS", Normalized55FPS);
1129 m_update_backup = startupConfig.GetInt(
"UpdateStorageEveryNFrames", m_update_backup);
1130 m_update_coarse_locations = startupConfig.GetInt(
"UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations);
1131 m_update_entitymovement = startupConfig.GetInt(
"UpdateEntityMovementEveryNFrames", m_update_entitymovement);
1132 m_update_events = startupConfig.GetInt(
"UpdateEventsEveryNFrames", m_update_events);
1133 m_update_objects = startupConfig.GetInt(
"UpdateObjectsEveryNFrames", m_update_objects);
1134 m_update_physics = startupConfig.GetInt(
"UpdatePhysicsEveryNFrames", m_update_physics);
1135 m_update_presences = startupConfig.GetInt(
"UpdateAgentsEveryNFrames", m_update_presences);
1136 m_update_terrain = startupConfig.GetInt(
"UpdateTerrainEveryNFrames", m_update_terrain);
1137 m_update_temp_cleaning = startupConfig.GetInt(
"UpdateTempCleaningEveryNSeconds", m_update_temp_cleaning);
1143 SendPeriodicAppearanceUpdates =
false;
1145 IConfig appearanceConfig = m_config.Configs[
"Appearance"];
1146 if (appearanceConfig != null)
1148 SendPeriodicAppearanceUpdates
1149 = appearanceConfig.GetBoolean(
"ResendAppearanceUpdates", SendPeriodicAppearanceUpdates);
1152 #endregion Region Config
1154 IConfig entityTransferConfig = m_config.Configs[
"EntityTransfer"];
1155 if (entityTransferConfig != null)
1157 AllowAvatarCrossing = entityTransferConfig.GetBoolean(
"AllowAvatarCrossing", AllowAvatarCrossing);
1160 #region Interest Management
1162 IConfig interestConfig = m_config.Configs[
"InterestManagement"];
1163 if (interestConfig != null)
1165 string update_prioritization_scheme = interestConfig.GetString(
"UpdatePrioritizationScheme",
"Time").Trim().ToLower();
1173 m_log.Warn(
"[PRIORITIZER]: UpdatePrioritizationScheme was not recognized, setting to default prioritizer Time");
1174 UpdatePrioritizationScheme = UpdatePrioritizationSchemes.Time;
1177 IsReprioritizationEnabled
1178 = interestConfig.GetBoolean(
"ReprioritizationEnabled", IsReprioritizationEnabled);
1179 ReprioritizationInterval
1180 = interestConfig.GetFloat(
"ReprioritizationInterval", ReprioritizationInterval);
1181 RootReprioritizationDistance
1182 = interestConfig.GetFloat(
"RootReprioritizationDistance", RootReprioritizationDistance);
1183 ChildReprioritizationDistance
1184 = interestConfig.GetFloat(
"ChildReprioritizationDistance", ChildReprioritizationDistance);
1186 if(RootReprioritizationDistance < m_minReprioritizationDistance)
1187 RootReprioritizationDistance = m_minReprioritizationDistance;
1188 if(ChildReprioritizationDistance < m_minReprioritizationDistance)
1189 ChildReprioritizationDistance = m_minReprioritizationDistance;
1191 RootTerseUpdatePeriod = interestConfig.GetInt(
"RootTerseUpdatePeriod", RootTerseUpdatePeriod);
1192 ChildTerseUpdatePeriod = interestConfig.GetInt(
"ChildTerseUpdatePeriod", ChildTerseUpdatePeriod);
1194 RootPositionUpdateTolerance
1195 = interestConfig.GetFloat(
"RootPositionUpdateTolerance", RootPositionUpdateTolerance);
1196 RootRotationUpdateTolerance
1197 = interestConfig.GetFloat(
"RootRotationUpdateTolerance", RootRotationUpdateTolerance);
1198 RootVelocityUpdateTolerance
1199 = interestConfig.GetFloat(
"RootVelocityUpdateTolerance", RootVelocityUpdateTolerance);
1202 m_log.DebugFormat(
"[SCENE]: Using the {0} prioritization scheme", UpdatePrioritizationScheme);
1204 #endregion Interest Management
1209 StatsReporter.OnSendStatsResult += SendSimStatsPackets;
1210 StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats;
1225 m_sceneGraph.UnRecoverableError
1228 m_log.ErrorFormat(
"[SCENE]: Restarting region {0} due to unrecoverable physics crash", Name);
1232 PhysicalPrims =
true;
1233 CollidablePrims =
true;
1234 PhysicsEnabled =
true;
1236 AllowAvatarCrossing =
true;
1238 PeriodicBackup =
true;
1241 IsReprioritizationEnabled =
true;
1242 UpdatePrioritizationScheme = UpdatePrioritizationSchemes.Time;
1243 ReprioritizationInterval = 5000;
1245 RootRotationUpdateTolerance = 0.1f;
1246 RootVelocityUpdateTolerance = 0.001f;
1247 RootPositionUpdateTolerance = 0.05f;
1248 RootReprioritizationDistance = m_minReprioritizationDistance;
1249 ChildReprioritizationDistance = m_minReprioritizationDistance;
1259 #region Startup / Close Methods
1267 get {
return m_sceneGraph; }
1280 m_eventManager.OnPermissionError += dm.SendAlertToUser;
1289 openSimExtras =
new OSDMap();
1291 float statisticsFPSfactor = 1.0f;
1293 statisticsFPSfactor = 55.0f * FrameTime;
1295 openSimExtrasMap = (
OSDMap)openSimExtras;
1296 openSimExtrasMap[
"SimulatorFPS"] = OSD.FromReal(1.0f / FrameTime);
1297 openSimExtrasMap[
"SimulatorFPSFactor"] = OSD.FromReal(statisticsFPSfactor);
1298 openSimExtrasMap[
"SimulatorFPSWarnPercent"] = OSD.FromInteger(FrameTimeWarnPercent);
1299 openSimExtrasMap[
"SimulatorFPSCritPercent"] = OSD.FromInteger(FrameTimeCritPercent);
1301 fm.AddFeature(
"OpenSimExtras", openSimExtrasMap);
1312 return m_simulatorVersion;
1331 if (isNeighborRegion(otherRegion))
1334 m_eventManager.TriggerOnRegionUp(otherRegion);
1343 List<ulong> old =
new List<ulong>();
1344 old.Add(otherRegion.RegionHandle);
1345 agent.DropOldNeighbours(old);
1347 EntityTransferModule.EnableChildAgent(agent, otherRegion);
1350 catch (NullReferenceException)
1354 m_log.Error(
"[SCENE]: Couldn't inform client of regionup because we got a null reference exception");
1360 "[SCENE]: Got notice about far away Region: {0} at ({1}, {2})",
1361 otherRegion.RegionName, otherRegion.RegionLocX, otherRegion.RegionLocY);
1385 if (!CheckNeighborRegion(region))
1387 m_neighbours.Add(region);
1419 IConfig startupConfig = m_config.Configs[
"Startup"];
1420 if (startupConfig != null)
1422 if (startupConfig.GetBoolean(
"InworldRestartShutsDown",
false))
1424 MainConsole.Instance.RunCommand(
"shutdown");
1429 m_log.InfoFormat(
"[REGION]: Restarting region {0}", Name);
1443 m_restartWaitTimer.Stop();
1444 lock (m_regionRestartNotifyList)
1446 foreach (
RegionInfo region
in m_regionRestartNotifyList)
1454 EntityTransferModule.EnableChildAgent(agent, r);
1457 catch (NullReferenceException)
1465 m_regionRestartNotifyList.Clear();
1471 return m_neighbours.Count;
1479 m_log.WarnFormat(
"[SCENE]: Ignoring close request because already closing {0}", Name);
1483 m_log.InfoFormat(
"[SCENE]: Closing down the single simulator: {0}", RegionInfo.RegionName);
1486 StatsReporter.Close();
1487 m_restartTimer.Stop();
1488 m_restartTimer.Close();
1491 m_log.WarnFormat(
"[SCENE]: Deregister from grid failed for region {0}", Name);
1496 avatar.RemoveNeighbourRegion(RegionInfo.RegionHandle);
1499 avatar.ControllingClient.Kick(
"The simulator is going down.");
1501 avatar.ControllingClient.SendShutdownConnectionNotice();
1505 m_shuttingDown =
true;
1513 ForEachScenePresence(delegate(
ScenePresence avatar) { CloseAgent(avatar.
UUID,
false); });
1515 m_log.Debug(
"[SCENE]: TriggerSceneShuttingDown");
1516 EventManager.TriggerSceneShuttingDown(
this);
1518 m_log.Debug(
"[SCENE]: Persisting changed objects");
1521 m_sceneGraph.Close();
1530 m_log.Debug(
"[SCENE]: Dispose Physics");
1558 m_unixStartTime = Util.UnixTimeSinceEpoch();
1560 if (m_heartbeatThread != null)
1563 if(m_hbRestarts > 10)
1564 Environment.Exit(1);
1565 m_log.ErrorFormat(
"[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName);
1576 m_heartbeatThread.Abort();
1577 Watchdog.AbortThread(m_heartbeatThread.ManagedThreadId);
1578 m_heartbeatThread = null;
1583 m_sceneGraph.ProcessPhysicsPreSimulation();
1586 = WorkManager.StartThread(
1587 Heartbeat, string.Format(
"Heartbeat-({0})", RegionInfo.RegionName.Replace(
" ",
"_")), ThreadPriority.Normal,
false,
false);
1597 m_xmlrpcModule = RequestModuleInterface<IXMLRPC>();
1598 m_worldCommModule = RequestModuleInterface<IWorldComm>();
1599 XferManager = RequestModuleInterface<IXfer>();
1600 m_AvatarFactory = RequestModuleInterface<IAvatarFactoryModule>();
1601 AttachmentsModule = RequestModuleInterface<IAttachmentsModule>();
1602 m_serialiser = RequestModuleInterface<IRegionSerialiserModule>();
1603 m_dialogModule = RequestModuleInterface<IDialogModule>();
1604 m_capsModule = RequestModuleInterface<ICapabilitiesModule>();
1605 EntityTransferModule = RequestModuleInterface<IEntityTransferModule>();
1606 m_groupsModule = RequestModuleInterface<IGroupsModule>();
1607 AgentTransactionsModule = RequestModuleInterface<IAgentAssetTransactions>();
1608 UserManagementModule = RequestModuleInterface<IUserManagement>();
1613 #region Update Methods
1618 private void Heartbeat()
1620 m_eventManager.TriggerOnRegionStarted(
this);
1627 WorkManager.StartThread(
1628 Maintenance, string.Format(
"Maintenance ({0})", RegionInfo.RegionName), ThreadPriority.Normal,
false,
true);
1630 Watchdog.GetCurrentThreadInfo().AlarmIfTimeout =
true;
1631 m_lastFrameTick = Util.EnvironmentTickCount();
1634 Watchdog.RemoveThread();
1637 private void Maintenance()
1641 Watchdog.RemoveThread();
1646 long? endRun = null;
1648 int previousMaintenanceTick;
1651 endRun = MaintenanceRun + runs;
1653 List<Vector3> coarseLocations;
1654 List<UUID> avatarUUIDs;
1656 while (!m_shuttingDown && ((endRun == null && Active) || MaintenanceRun < endRun))
1658 runtc = Util.EnvironmentTickCount();
1664 if (MaintenanceRun % (m_update_coarse_locations / 10) == 0)
1666 SceneGraph.GetCoarseLocations(out coarseLocations, out avatarUUIDs, 60);
1670 presence.SendCoarseLocations(coarseLocations, avatarUUIDs);
1674 if (SendPeriodicAppearanceUpdates && MaintenanceRun % 60 == 0)
1678 if (AvatarFactory != null)
1680 ForEachRootScenePresence(sp => AvatarFactory.SendAppearance(sp.UUID));
1685 if (MaintenanceRun % m_update_temp_cleaning == 0 && !m_cleaningTemps)
1688 tmpMS = Util.EnvironmentTickCount();
1689 m_cleaningTemps =
true;
1691 WorkManager.RunInThread(
1692 delegate { CleanTempObjects(); m_cleaningTemps =
false; },
1694 string.Format(
"CleanTempObjects ({0})", Name));
1696 tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpMS);
1699 Watchdog.UpdateThread();
1701 previousMaintenanceTick = m_lastMaintenanceTick;
1702 m_lastMaintenanceTick = Util.EnvironmentTickCount();
1703 runtc = Util.EnvironmentTickCountSubtract(m_lastMaintenanceTick, runtc);
1704 runtc = (int)(MinMaintenanceTime * 1000) - runtc;
1707 m_maintenanceWaitEvent.WaitOne(runtc);
1711 && Util.EnvironmentTickCountSubtract(
1712 m_lastMaintenanceTick, previousMaintenanceTick) > (int)(MinMaintenanceTime * 1000 * 2))
1714 "[SCENE]: Maintenance took {0} ms (desired max {1} ms) in {2}",
1715 Util.EnvironmentTickCountSubtract(m_lastMaintenanceTick, previousMaintenanceTick),
1716 MinMaintenanceTime * 1000,
1717 RegionInfo.RegionName);
1723 long? endFrame = null;
1726 endFrame = Frame + frames;
1728 float physicsFPS = 0f;
1729 float frameTimeMS = FrameTime * 1000.0f;
1731 int previousFrameTick;
1737 float sleepError = 0;
1739 while (!m_shuttingDown && ((endFrame == null && Active) || Frame < endFrame))
1741 framestart = Util.GetTimeStampMS();
1746 agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0f;
1750 EventManager.TriggerRegionHeartbeatStart(
this);
1754 tmpMS = Util.GetTimeStampMS();
1758 CheckTerrainUpdates();
1761 if (Frame % m_update_terrain == 0)
1766 tmpMS2 = Util.GetTimeStampMS();
1767 terrainMS = (float)(tmpMS2 - tmpMS);
1770 if (PhysicsEnabled && Frame % m_update_physics == 0)
1771 m_sceneGraph.UpdatePreparePhysics();
1773 tmpMS2 = Util.GetTimeStampMS();
1774 physicsMS2 = (float)(tmpMS2 - tmpMS);
1778 if (Frame % m_update_entitymovement == 0)
1779 m_sceneGraph.UpdateScenePresenceMovement();
1783 tmpMS2 = Util.GetTimeStampMS();
1784 agentMS = (float)(tmpMS2 - tmpMS);
1789 if (Frame % m_update_physics == 0)
1792 physicsFPS = m_sceneGraph.UpdatePhysics(FrameTime);
1794 if (SynchronizeScene != null)
1795 SynchronizeScene(
this);
1798 tmpMS2 = Util.GetTimeStampMS();
1799 physicsMS = (float)(tmpMS2 - tmpMS);
1807 if (Frame % m_update_objects == 0)
1808 m_sceneGraph.UpdateObjectGroups();
1812 if (Frame % m_update_presences == 0)
1813 m_sceneGraph.UpdatePresences();
1815 tmpMS2 = Util.GetTimeStampMS();
1816 agentMS += (float)(tmpMS2 - tmpMS);
1820 if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps)
1822 m_cleaningTemps =
true;
1823 Util.FireAndForget(delegate { CleanTempObjects(); m_cleaningTemps =
false; });
1824 tmpMS2 = Util.GetTimeStampMS();
1825 tempOnRezMS = (float)(tmpMS2 - tmpMS);
1829 if (Frame % m_update_events == 0)
1833 tmpMS2 = Util.GetTimeStampMS();
1834 eventMS = (float)(tmpMS2 - tmpMS);
1838 if (PeriodicBackup && Frame % m_update_backup == 0)
1840 UpdateStorageBackup();
1842 tmpMS2 = Util.GetTimeStampMS();
1843 backupMS = (float)(tmpMS2 - tmpMS);
1854 if (!LoginsEnabled && Frame == 20)
1867 m_log.InfoFormat(
"[REGION]: Enabling logins for {0}", RegionInfo.RegionName);
1868 LoginsEnabled =
true;
1871 m_sceneGridService.InformNeighborsThatRegionisUp(
1872 RequestModuleInterface<INeighbourService>(),
RegionInfo);
1880 if (m_sceneGraph.GetActiveScriptsCount() == 0)
1888 rrm.TriggerRegionReady(
this);
1896 "[SCENE]: Failed on region {0} with exception {1}{2}",
1897 RegionInfo.RegionName, e.Message, e.StackTrace);
1900 EventManager.TriggerRegionHeartbeatEnd(
this);
1901 m_firstHeartbeat =
false;
1902 Watchdog.UpdateThread();
1904 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
1906 tmpMS = Util.GetTimeStampMS();
1908 previousFrameTick = m_lastFrameTick;
1909 m_lastFrameTick = (int)(tmpMS + 0.5);
1912 tmpMS2 = tmpMS - framestart;
1913 tmpMS2 = (double)frameTimeMS - tmpMS2 - sleepError;
1916 frameMS = (float)tmpMS2;
1921 Thread.Sleep((int)(tmpMS2 + 0.5));
1923 tmpMS2 = Util.GetTimeStampMS();
1924 sleepMS = (float)(tmpMS2 - tmpMS);
1925 sleepError = sleepMS - frameMS;
1926 Util.Clamp(sleepError, 0.0f, 20f);
1927 frameMS = (float)(tmpMS2 - framestart);
1931 tmpMS2 = Util.GetTimeStampMS();
1932 frameMS = (float)(tmpMS2 - framestart);
1938 float scriptTimeMS = GetAndResetScriptExecutionTime();
1939 StatsReporter.AddFrameStats(TimeDilation, physicsFPS, agentMS,
1940 physicsMS + physicsMS2, otherMS , sleepMS, frameMS, scriptTimeMS);
1949 && Util.EnvironmentTickCountSubtract(
1950 m_lastFrameTick, previousFrameTick) > (int)(FrameTime * 1000 * 2))
1953 "[SCENE]: Frame took {0} ms (desired max {1} ms) in {2}",
1954 Util.EnvironmentTickCountSubtract(m_lastFrameTick, previousFrameTick),
1957 RegionInfo.RegionName);
1967 StatsReporter.addScriptEvents(1);
1968 Interlocked.Add(ref m_scriptExecutionTime, ticks);
1981 long ticks = Interlocked.Exchange(ref m_scriptExecutionTime, 0);
1982 return (ticks * 1000L) / Stopwatch.Frequency;
1987 lock (m_groupsWithTargets)
1988 m_groupsWithTargets[grp.UUID] = 0;
1993 lock (m_groupsWithTargets)
1994 m_groupsWithTargets.Remove(grp.UUID);
1997 private void CheckAtTargets()
1999 List<UUID> objs = null;
2001 lock (m_groupsWithTargets)
2003 if (m_groupsWithTargets.Count != 0)
2004 objs =
new List<UUID>(m_groupsWithTargets.Keys);
2009 foreach (UUID entry
in objs)
2011 SceneObjectGroup grp = GetSceneObjectGroup(entry);
2013 m_groupsWithTargets.Remove(entry);
2015 grp.checkAtTargets();
2024 private void SendSimStatsPackets(
SimStats stats)
2026 ForEachRootClient(delegate(
IClientAPI client)
2028 client.SendSimStats(stats);
2035 private void UpdateTerrain()
2037 EventManager.TriggerTerrainTick();
2040 private void CheckTerrainUpdates()
2042 EventManager.TriggerTerrainCheckUpdates();
2048 private void UpdateStorageBackup()
2053 WorkManager.RunInThread(o => Backup(
false), null, string.Format(
"BackupWaitCallback ({0})", Name));
2060 private void UpdateEvents()
2062 m_eventManager.TriggerOnFrame();
2081 EventManager.TriggerOnBackup(SimulationDataService, forced);
2082 m_backingup =
false;
2084 foreach (KeyValuePair<UUID, ReturnInfo> ret
in m_returns)
2086 UUID transaction = UUID.Random();
2089 msg.fromAgentID =
new Guid(
UUID.Zero.ToString());
2090 msg.toAgentID =
new Guid(ret.Key.ToString());
2091 msg.imSessionID =
new Guid(transaction.ToString());
2092 msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
2093 msg.fromAgentName =
"Server";
2094 msg.dialog = (byte)19;
2095 msg.fromGroup =
false;
2096 msg.offline = (byte)1;
2097 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID;
2098 msg.Position = Vector3.Zero;
2099 msg.RegionID = RegionInfo.RegionID.Guid;
2102 msg.binaryBucket = Util.StringToBytes256(
"\0");
2103 if (ret.Value.count > 1)
2104 msg.message = string.Format(
"Your {0} objects were returned from {1} in region {2} due to {3}", ret.Value.count, ret.Value.location.ToString(),
RegionInfo.
RegionName, ret.Value.reason);
2106 msg.message = string.Format(
"Your object {0} was returned from {1} in region {2} due to {3}", ret.Value.objectName, ret.Value.location.ToString(),
RegionInfo.
RegionName, ret.Value.reason);
2110 tr.SendInstantMessage(msg, delegate(
bool success) { });
2124 group.HasGroupChanged =
true;
2125 group.ProcessBackup(SimulationDataService,
true);
2139 public void AddReturn(UUID agentID,
string objectName, Vector3 location,
string reason)
2143 if (m_returns.ContainsKey(agentID))
2147 m_returns[agentID] = info;
2153 info.objectName = objectName;
2154 info.location = location;
2155 info.reason = reason;
2156 m_returns[agentID] = info;
2163 #region Load Terrain
2175 RegionInfo.WindlightSettings = wl;
2176 SimulationDataService.StoreRegionWindlightSettings(wl);
2177 m_eventManager.TriggerOnSaveNewWindlightProfile();
2182 RegionInfo.WindlightSettings = SimulationDataService.LoadRegionWindlightSettings(RegionInfo.RegionID);
2183 m_eventManager.TriggerOnSaveNewWindlightProfile();
2198 IConfig terrainConfig = m_config.Configs[
"Terrain"];
2199 String m_InitialTerrain =
"pinhead-island";
2200 if (terrainConfig != null)
2201 m_InitialTerrain = terrainConfig.GetString(
"InitialTerrain", m_InitialTerrain);
2203 m_log.InfoFormat(
"[TERRAIN]: No default terrain. Generating a new terrain {0}.", m_InitialTerrain);
2213 catch (IOException e)
2216 "[TERRAIN]: Scene.cs: LoadWorldMap() - Regenerating as failed with exception {0}{1}",
2217 e.Message, e.StackTrace);
2220 #pragma warning disable 0162
2221 if ((
int)Constants.RegionSize != 256)
2231 "[TERRAIN]: Scene.cs: LoadWorldMap() - Failed with exception {0}{1}", e.Message, e.StackTrace);
2241 m_sceneGridService.SetScene(
this);
2247 if (m_generateMaptiles)
2248 RegenerateMaptile();
2251 string error = GridService.RegisterRegion(RegionInfo.ScopeID, region);
2258 if (error !=
String.Empty)
2259 throw new Exception(error);
2272 m_log.Info(
"[SCENE]: Loading land objects from storage");
2273 List<LandData> landData = SimulationDataService.LoadLandObjects(regionID);
2275 if (LandChannel != null)
2277 if (landData.Count == 0)
2279 EventManager.TriggerNoticeNoLandDataFromStorage();
2283 EventManager.TriggerIncomingLandDataFromStorage(landData);
2288 m_log.Error(
"[SCENE]: Land Channel is not defined. Cannot load from storage!");
2294 #region Primitives Methods
2302 LoadingPrims =
true;
2303 m_log.Info(
"[SCENE]: Loading objects from datastore");
2305 List<SceneObjectGroup> PrimsFromDB = SimulationDataService.LoadObjects(regionID);
2307 m_log.InfoFormat(
"[SCENE]: Loaded {0} objects from the datastore", PrimsFromDB.Count);
2311 AddRestoredSceneObject(group,
true,
true);
2312 EventManager.TriggerOnSceneObjectLoaded(group);
2315 rootPart.TrimPermissions();
2321 LoadingPrims =
false;
2322 EventManager.TriggerPrimsLoaded(
this);
2329 return PhysicsScene.SupportsRaycastWorldFiltered();
2336 return PhysicsScene.RaycastWorld(position, direction, length, Count, filter);
2352 public Vector3
GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection,
bool frontFacesOnly, Vector3 scale,
bool FaceCenter)
2355 Vector3 dir = RayEnd - RayStart;
2358 Vector3 wpos = Vector3.Zero;
2360 if ((RayStart.Z > wheight) && (RayEnd.Z < wheight))
2362 float ratio = (wheight - RayStart.Z) / dir.Z;
2363 wpos.X = RayStart.X + (ratio * dir.X);
2364 wpos.Y = RayStart.Y + (ratio * dir.Y);
2368 Vector3 pos = Vector3.Zero;
2370 if (RayEndIsIntersection != (byte)1)
2372 float dist = dir.Length();
2375 Vector3 direction = dir * (1 / dist);
2379 if (SupportsRayCastFiltered())
2382 rayfilter |= RayFilterFlags.land;
2383 rayfilter |= RayFilterFlags.physical;
2384 rayfilter |= RayFilterFlags.nonphysical;
2385 rayfilter |= RayFilterFlags.LSLPhantom;
2390 List<ContactResult> physresults =
2391 (List<ContactResult>)RayCastFiltered(RayStart, direction, dist, physcount, rayfilter);
2392 if (physresults != null && physresults.Count > 0)
2395 if(RayTargetID ==
UUID.Zero)
2401 pos = r.Normal * scale;
2405 if (wpos.Z > pos.Z) pos = wpos;
2417 if (part.
UUID == RayTargetID)
2419 pos = r.Normal * scale;
2423 if (wpos.Z > pos.Z) pos = wpos;
2429 pos = physresults[0].Normal * scale;
2431 pos = physresults[0].Pos + pos;
2439 if (RayTargetID !=
UUID.Zero)
2443 Ray NewRay =
new Ray(RayStart, direction);
2447 pos = target.AbsolutePosition;
2450 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter);
2454 float ScaleOffset = 0.5f;
2459 Vector3 scaleComponent = ei.AAfaceNormal;
2460 if (scaleComponent.X != 0) ScaleOffset = scale.X;
2461 if (scaleComponent.Y != 0) ScaleOffset = scale.Y;
2462 if (scaleComponent.Z != 0) ScaleOffset = scale.Z;
2463 ScaleOffset = Math.Abs(ScaleOffset);
2464 Vector3 intersectionpoint = ei.ipoint;
2465 Vector3 normal = ei.normal;
2467 Vector3 offset = (normal * (ScaleOffset / 2f));
2468 pos = (intersectionpoint + offset);
2475 if (wpos.Z > pos.Z) pos = wpos;
2482 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(NewRay,
true,
false);
2497 if (wpos.Z > pos.Z) pos = wpos;
2509 pos.Z += scale.Z / 2f;
2512 if (wpos.Z > pos.Z) pos = wpos;
2530 byte bypassRaycast, Vector3 RayStart, UUID RayTargetID,
2531 byte RayEndIsIntersection)
2533 Vector3 pos = GetNewRezLocation(RayStart, RayEnd, RayTargetID, rot, bypassRaycast, RayEndIsIntersection,
true,
new Vector3(0.5f, 0.5f, 0.5f),
false);
2535 if (Permissions.CanRezObject(1, ownerID, pos))
2540 AddNewPrim(ownerID, groupID, pos, rot, shape);
2545 if (TryGetClient(ownerID, out client))
2546 client.SendAlertMessage(
"You cannot create objects here.");
2559 if (m_entityCreators.ContainsKey((PCode)shape.
PCode))
2561 sceneObject = m_entityCreators[(PCode)shape.
PCode].CreateEntity(ownerID, groupID, pos, rot, shape);
2567 AddNewSceneObject(sceneObject,
true);
2568 sceneObject.SetGroup(groupID, null);
2571 if (UserManagementModule != null)
2572 sceneObject.RootPart.CreatorIdentification = UserManagementModule.GetUserUUI(ownerID);
2574 sceneObject.ScheduleGroupForFullUpdate();
2600 SceneObjectGroup sceneObject,
bool attachToBackup,
bool alreadyPersisted,
bool sendClientUpdates)
2602 if (m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates))
2604 sceneObject.IsDeleted =
false;
2605 EventManager.TriggerObjectAddedToScene(sceneObject);
2631 return AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted,
true);
2645 return AddNewSceneObject(sceneObject, attachToBackup,
true);
2663 if (m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, sendClientUpdates))
2665 EventManager.TriggerObjectAddedToScene(sceneObject);
2685 SceneObjectGroup sceneObject,
bool attachToBackup, Vector3? pos, Quaternion? rot, Vector3 vel)
2687 if (m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, pos, rot, vel))
2689 EventManager.TriggerObjectAddedToScene(sceneObject);
2701 DeleteAllSceneObjects(
false);
2709 List<SceneObjectGroup> toReturn =
new List<SceneObjectGroup>();
2712 EntityBase[] entities = Entities.GetEntities();
2717 SceneObjectGroup sog = (SceneObjectGroup)e;
2722 DeleteSceneObject((SceneObjectGroup)e,
false);
2726 toReturn.Add((SceneObjectGroup)e);
2732 if (toReturn.Count > 0)
2734 returnObjects(toReturn.ToArray(), UUID.Zero);
2748 DeleteSceneObject(group, silent,
true);
2762 group.RemoveScriptInstances(
true);
2764 group.StopScriptInstances();
2766 List<ScenePresence> avatars = group.GetSittingAvatars();
2779 part.KeyframeMotion.Delete();
2780 part.KeyframeMotion = null;
2783 if (part.
IsJoint() && ((part.Flags & PrimFlags.Physics) != 0))
2785 PhysicsScene.RequestJointDeletion(part.Name);
2789 part.RemoveFromPhysics();
2793 if (UnlinkSceneObject(group,
false))
2795 EventManager.TriggerObjectBeingRemovedFromScene(group);
2796 EventManager.TriggerParcelPrimCountTainted();
2799 group.DeleteGroupFromScene(silent);
2801 SendKillObject(
new List<uint>() { group.LocalId });
2819 if (m_sceneGraph.DeleteSceneObject(so.
UUID, softDelete))
2827 ForceSceneObjectBackup(so);
2829 so.DetachFromBackup();
2830 SimulationDataService.RemoveObject(so.UUID, RegionInfo.RegionID);
2834 so.IsDeleted =
true;
2845 m_sceneGraph.updateScenePartGroup(part, grp);
2906 int xx = (int)Math.Floor(pos.X);
2907 int yy = (int)Math.Floor(pos.Y);
2908 if (xx < 0 || yy < 0)
2912 if (regionCombinerModule == null)
2921 ret = regionCombinerModule.PositionIsInMegaregion(this.RegionInfo.RegionID, xx, yy);
2943 m_log.WarnFormat(
"[INTERREGION]: Problem casting object, exception {0}{1}", e.Message, e.StackTrace);
2952 m_log.InfoFormat(
"[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID);
2956 if (newPosition != Vector3.Zero)
2957 newObject.RootPart.GroupPosition = newPosition;
2959 if (!AddSceneObject(newObject))
2962 "[INTERREGION]: Problem adding scene object {0} in {1} ", newObject.UUID, RegionInfo.RegionName);
2974 m_log.Info(
"[INTERREGION]: Denied prim crossing because of parcel settings");
2976 DeleteSceneObject(newObject,
false);
2983 newObject.RootPart.ParentGroup.CreateScriptInstances(0,
false, DefaultScriptEngine, GetStateSource(newObject));
2984 newObject.ResumeScripts();
2995 EventManager.TriggerOnIncomingSceneObject(newObject);
3011 m_log.ErrorFormat(
"[SCENE]: Owner ID for {0} was zero", sceneObject.UUID);
3018 int flags = GetUserFlags(sceneObject.
OwnerID);
3021 m_log.InfoFormat(
"[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID);
3029 for (
int i = 0; i < parts.Length; i++)
3030 parts[i].LocalId = 0;
3034 sceneObject.RootPart.AddFlag(PrimFlags.TemporaryOnRez);
3039 AddRestoredSceneObject(sceneObject,
false,
false,
false);
3056 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
3061 if (AttachmentsModule != null)
3062 AttachmentsModule.AttachObject(sp, grp, 0,
false,
false,
true);
3066 m_log.DebugFormat(
"[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID);
3072 m_log.ErrorFormat(
"[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID);
3080 m_log.ErrorFormat(
"[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID);
3083 AddRestoredSceneObject(sceneObject,
true,
false);
3096 return sp.GetStateSource();
3113 UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user);
3116 return uac.UserFlags;
3122 #region Add/Remove Avatar Methods
3128 bool reallyNew =
true;
3131 StatsReporter.UpdateUsersLoggingIn(
true);
3137 AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode);
3159 sp = GetScenePresence(client.
AgentId);
3168 "[SCENE]: Adding new child scene presence {0} {1} to scene {2} at pos {3}, tpflags: {4}",
3169 client.Name, client.AgentId, RegionInfo.RegionName, client.StartPos,
3170 ((
TPFlags)aCircuit.teleportFlags).ToString());
3172 m_clientManager.Add(client);
3173 SubscribeToClientEvents(client);
3175 sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type);
3177 sp.TeleportFlags = (
TPFlags)aCircuit.teleportFlags;
3188 m_eventManager.TriggerOnNewPresence(sp);
3200 "[SCENE]: Already found {0} scene presence for {1} in {2} when asked to add new scene presence",
3201 sp.IsChildAgent ?
"child" :
"root", sp.Name, RegionInfo.RegionName);
3205 client.SceneAgent = sp;
3210 CacheUserName(sp, aCircuit);
3213 EventManager.TriggerOnNewClient(client);
3216 EventManager.TriggerOnClientLogin(client);
3221 StatsReporter.UpdateUsersLoggingIn(
false);
3223 m_LastLogin = Util.EnvironmentTickCount();
3233 AgentCircuitData circuit = AuthenticateHandler.GetAgentCircuitData(agentID);
3247 if (UserManagementModule != null)
3249 string first = aCircuit.firstname, last = aCircuit.lastname;
3253 UserManagementModule.AddUser(aCircuit.AgentID, first, last);
3257 string homeURL = string.Empty;
3260 homeURL = aCircuit.
ServiceURLs[
"HomeURI"].ToString();
3262 if (aCircuit.
lastname.StartsWith(
"@"))
3264 string[] parts = aCircuit.firstname.Split(
'.');
3265 if (parts.Length >= 2)
3272 UserManagementModule.AddUser(aCircuit.AgentID, first, last, homeURL);
3277 private bool VerifyClient(
AgentCircuitData aCircuit, System.Net.IPEndPoint ep, out
bool vialogin)
3284 m_log.DebugFormat(
"[SCENE]: Incoming client {0} {1} in region {2} via HG login", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName);
3287 if (userVerification != null && ep != null)
3289 if (!userVerification.
VerifyClient(aCircuit, ep.Address.ToString()))
3292 m_log.DebugFormat(
"[SCENE]: User Client Verification for {0} {1} in {2} returned false", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName);
3296 m_log.DebugFormat(
"[SCENE]: User Client Verification for {0} {1} in {2} returned true", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName);
3301 else if ((aCircuit.
teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0)
3303 m_log.DebugFormat(
"[SCENE]: Incoming client {0} {1} in region {2} via regular login. Client IP verification not performed.",
3304 aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName);
3312 public override bool CheckClient(UUID agentID, System.Net.IPEndPoint ep)
3314 AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(agentID);
3315 if (aCircuit != null)
3317 bool vialogin =
false;
3318 if (!VerifyClient(aCircuit, ep, out vialogin))
3328 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
3330 CloseAgent(sp.
UUID,
false);
3334 m_authenticateHandler.RemoveCircuit(agentID);
3340 m_log.DebugFormat(
"[SCENE]: Exception while closing aborted client: {0}", e.StackTrace);
3356 SubscribeToClientTerrainEvents(client);
3357 SubscribeToClientPrimEvents(client);
3358 SubscribeToClientPrimRezEvents(client);
3359 SubscribeToClientInventoryEvents(client);
3360 SubscribeToClientTeleportEvents(client);
3361 SubscribeToClientScriptEvents(client);
3362 SubscribeToClientParcelEvents(client);
3363 SubscribeToClientGridEvents(client);
3364 SubscribeToClientNetworkEvents(client);
3374 client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition;
3375 client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition;
3384 client.OnUpdatePrimScale += m_sceneGraph.UpdatePrimScale;
3385 client.OnUpdatePrimGroupScale += m_sceneGraph.UpdatePrimGroupScale;
3386 client.OnUpdateExtraParams += m_sceneGraph.UpdateExtraParam;
3387 client.OnUpdatePrimShape += m_sceneGraph.UpdatePrimShape;
3389 client.OnObjectRequest += RequestPrim;
3390 client.OnObjectSelect += SelectPrim;
3391 client.OnObjectDeselect += DeselectPrim;
3395 client.OnDeRezObject += DeRezObjects;
3397 client.OnObjectName += m_sceneGraph.PrimName;
3398 client.OnObjectClickAction += m_sceneGraph.PrimClickAction;
3399 client.OnObjectMaterial += m_sceneGraph.PrimMaterial;
3402 client.OnObjectDuplicate += DuplicateObject;
3403 client.OnObjectDuplicateOnRay += doObjectDuplicateOnRay;
3406 client.OnObjectPermissions += HandleObjectPermissionsUpdate;
3407 client.OnGrabObject += ProcessObjectGrab;
3408 client.OnGrabUpdate += ProcessObjectGrabUpdate;
3409 client.OnDeGrabObject += ProcessObjectDeGrab;
3410 client.OnUndo += m_sceneGraph.HandleUndo;
3411 client.OnRedo += m_sceneGraph.HandleRedo;
3412 client.OnObjectDescription += m_sceneGraph.PrimDescription;
3413 client.OnObjectIncludeInSearch += m_sceneGraph.MakeObjectSearchable;
3415 client.OnObjectGroupRequest += HandleObjectGroupUpdate;
3426 client.OnLinkInventoryItem += HandleLinkInventoryItem;
3427 client.OnCreateNewInventoryFolder += HandleCreateInventoryFolder;
3428 client.OnUpdateInventoryFolder += HandleUpdateInventoryFolder;
3429 client.OnMoveInventoryFolder += HandleMoveInventoryFolder;
3430 client.OnFetchInventoryDescendents += HandleFetchInventoryDescendents;
3431 client.OnPurgeInventoryDescendents += HandlePurgeInventoryDescendents;
3432 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory;
3433 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
3435 client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy;
3443 client.OnMoveTaskItem += ClientMoveTaskInventoryItem;
3448 client.OnTeleportLocationRequest += RequestTeleportLocation;
3453 client.OnScriptReset += ProcessScriptReset;
3460 client.OnParcelReturnObjectsRequest += LandChannel.ReturnObjectsInParcel;
3461 client.OnParcelSetOtherCleanTime += LandChannel.SetParcelOtherCleanTime;
3462 client.OnParcelBuy += ProcessParcelBuy;
3468 client.OnMoneyTransferRequest += ProcessMoneyTransferRequest;
3473 client.OnNetworkStatsUpdate += StatsReporter.AddPacketsStats;
3474 client.OnViewerEffect += ProcessViewerEffect;
3484 UnSubscribeToClientTerrainEvents(client);
3485 UnSubscribeToClientPrimEvents(client);
3486 UnSubscribeToClientPrimRezEvents(client);
3487 UnSubscribeToClientInventoryEvents(client);
3488 UnSubscribeToClientTeleportEvents(client);
3489 UnSubscribeToClientScriptEvents(client);
3490 UnSubscribeToClientParcelEvents(client);
3491 UnSubscribeToClientGridEvents(client);
3492 UnSubscribeToClientNetworkEvents(client);
3502 client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition;
3503 client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition;
3512 client.OnUpdatePrimScale -= m_sceneGraph.UpdatePrimScale;
3513 client.OnUpdatePrimGroupScale -= m_sceneGraph.UpdatePrimGroupScale;
3514 client.OnUpdateExtraParams -= m_sceneGraph.UpdateExtraParam;
3515 client.OnUpdatePrimShape -= m_sceneGraph.UpdatePrimShape;
3517 client.OnObjectRequest -= RequestPrim;
3518 client.OnObjectSelect -= SelectPrim;
3519 client.OnObjectDeselect -= DeselectPrim;
3523 client.OnDeRezObject -= DeRezObjects;
3524 client.OnObjectName -= m_sceneGraph.PrimName;
3525 client.OnObjectClickAction -= m_sceneGraph.PrimClickAction;
3526 client.OnObjectMaterial -= m_sceneGraph.PrimMaterial;
3529 client.OnObjectDuplicate -= DuplicateObject;
3530 client.OnObjectDuplicateOnRay -= doObjectDuplicateOnRay;
3533 client.OnObjectPermissions -= HandleObjectPermissionsUpdate;
3534 client.OnGrabObject -= ProcessObjectGrab;
3535 client.OnDeGrabObject -= ProcessObjectDeGrab;
3536 client.OnUndo -= m_sceneGraph.HandleUndo;
3537 client.OnRedo -= m_sceneGraph.HandleRedo;
3538 client.OnObjectDescription -= m_sceneGraph.PrimDescription;
3539 client.OnObjectIncludeInSearch -= m_sceneGraph.MakeObjectSearchable;
3551 client.OnCreateNewInventoryFolder -= HandleCreateInventoryFolder;
3552 client.OnUpdateInventoryFolder -= HandleUpdateInventoryFolder;
3553 client.OnMoveInventoryFolder -= HandleMoveInventoryFolder;
3554 client.OnFetchInventoryDescendents -= HandleFetchInventoryDescendents;
3555 client.OnPurgeInventoryDescendents -= HandlePurgeInventoryDescendents;
3556 client.OnFetchInventory -= m_asyncInventorySender.HandleFetchInventory;
3557 client.OnUpdateInventoryItem -= UpdateInventoryItemAsset;
3566 client.OnMoveTaskItem -= ClientMoveTaskInventoryItem;
3571 client.OnTeleportLocationRequest -= RequestTeleportLocation;
3578 client.OnScriptReset -= ProcessScriptReset;
3585 client.OnParcelReturnObjectsRequest -= LandChannel.ReturnObjectsInParcel;
3586 client.OnParcelSetOtherCleanTime -= LandChannel.SetParcelOtherCleanTime;
3587 client.OnParcelBuy -= ProcessParcelBuy;
3593 client.OnMoneyTransferRequest -= ProcessMoneyTransferRequest;
3598 client.OnNetworkStatsUpdate -= StatsReporter.AddPacketsStats;
3599 client.OnViewerEffect -= ProcessViewerEffect;
3609 if (EntityTransferModule != null)
3611 return EntityTransferModule.TeleportHome(agentId, client);
3615 m_log.DebugFormat(
"[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
3616 client.SendTeleportFailed(
"Unable to perform teleports on this simulator.");
3629 public void DuplicateObject(uint originalPrim, Vector3 offset, uint flags, UUID AgentID, UUID GroupID)
3631 SceneObjectGroup copy = SceneGraph.DuplicateObject(originalPrim, offset, flags, AgentID, GroupID, Quaternion.Identity);
3633 EventManager.TriggerObjectAddedToScene(copy);
3652 UUID RayTargetObj, Vector3 RayEnd, Vector3 RayStart,
3653 bool BypassRaycast,
bool RayEndIsIntersection,
bool CopyCenters,
bool CopyRotates)
3656 const bool frontFacesOnly =
true;
3661 if (target != null && target2 != null)
3663 Vector3 direction = Vector3.Normalize(RayEnd - RayStart);
3665 pos = target2.AbsolutePosition;
3671 Ray NewRay =
new Ray(RayStart,direction);
3674 EntityIntersection ei = target2.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, CopyCenters);
3678 float ScaleOffset = 0.5f;
3683 Vector3 scale = target.Scale;
3684 Vector3 scaleComponent = ei.AAfaceNormal;
3685 if (scaleComponent.X != 0) ScaleOffset = scale.X;
3686 if (scaleComponent.Y != 0) ScaleOffset = scale.Y;
3687 if (scaleComponent.Z != 0) ScaleOffset = scale.Z;
3688 ScaleOffset = Math.Abs(ScaleOffset);
3689 Vector3 intersectionpoint = ei.ipoint;
3690 Vector3 normal = ei.normal;
3691 Vector3 offset = normal * (ScaleOffset / 2f);
3692 pos = intersectionpoint + offset;
3695 pos = pos - target.ParentGroup.AbsolutePosition;
3699 Quaternion worldRot = target2.GetWorldRotation();
3702 copy = m_sceneGraph.DuplicateObject(localID, pos, target.GetEffectiveObjectFlags(), AgentID, GroupID, worldRot);
3708 copy = m_sceneGraph.DuplicateObject(localID, pos, target.GetEffectiveObjectFlags(), AgentID, GroupID, Quaternion.Identity);
3712 EventManager.TriggerObjectAddedToScene(copy);
3724 AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode);
3726 if (aCircuit == null)
3728 m_log.DebugFormat(
"[APPEARANCE] Client did not supply a circuit. Non-Linden? Creating default appearance.");
3733 appearance = aCircuit.Appearance;
3734 if (appearance == null)
3736 m_log.DebugFormat(
"[APPEARANCE]: Appearance not found in {0}, returning default", RegionInfo.RegionName);
3755 private object m_removeClientPrivLock =
new Object();
3767 "[SCENE]: No agent circuit found for {0} in {1}, aborting Scene.RemoveClient", agentID, Name);
3773 lock (m_removeClientPrivLock)
3775 bool isChildAgent =
false;
3785 "[SCENE]: Called RemoveClient() with agent ID {0} but no such presence is in the scene.", agentID);
3786 m_authenticateHandler.RemoveCircuit(agentID);
3793 isChildAgent = avatar.IsChildAgent;
3796 "[SCENE]: Removing {0} agent {1} {2} from {3}",
3797 isChildAgent ?
"child" :
"root", avatar.Name, agentID, Name);
3800 if (closeChildAgents && isChildAgent)
3804 avatar.ControllingClient.SendShutdownConnectionNotice();
3813 m_sceneGraph.removeUserCount(!isChildAgent);
3817 if (closeChildAgents && CapsModule != null)
3818 CapsModule.RemoveCaps(agentID, avatar.ControllingClient.CircuitCode);
3820 if (closeChildAgents && !isChildAgent)
3822 List<ulong> regions = avatar.KnownRegionHandles;
3823 regions.Remove(RegionInfo.RegionHandle);
3826 m_sceneGridService.SendCloseChildAgentConnections(agentID, acd.SessionID.ToString(), regions);
3829 m_eventManager.TriggerClientClosed(agentID,
this);
3831 m_eventManager.TriggerOnRemovePresence(agentID);
3836 if (AttachmentsModule != null)
3839 AttachmentsModule.DeRezAttachments(avatar);
3847 try { client.SendKillObject(
new List<uint> { avatar.LocalId }); }
3848 catch (NullReferenceException) { }
3853 if (AgentTransactionsModule != null)
3856 AgentTransactionsModule.RemoveAgentAssetTransactions(agentID);
3858 m_log.Debug(
"[Scene] The avatar has left the building");
3863 string.Format(
"[SCENE]: Exception removing {0} from {1}. Cleaning up. Exception ", avatar.Name, Name), e);
3872 m_authenticateHandler.RemoveCircuit(agentID);
3873 m_sceneGraph.RemoveScenePresence(agentID);
3874 m_clientManager.Remove(agentID);
3881 string.Format(
"[SCENE]: Exception in final clean up of {0} in {1}. Exception ", avatar.Name, Name), e);
3903 for (
int i = 0; i < regionslst.Count; i++)
3905 av.RemoveNeighbourRegion(regionslst[i]);
3917 List<uint> deleteIDs =
new List<uint>();
3919 foreach (uint localID
in localIDs)
3930 deleteIDs.Add(localID);
3933 ForEachClient(c => c.SendKillObject(deleteIDs));
3951 return NewUserConnection(agent, teleportFlags, source, out reason,
true);
3978 private object m_newUserConnLock =
new object();
3982 bool vialogin = ((teleportFlags & (uint)
TPFlags.ViaLogin) != 0 ||
3983 (teleportFlags & (uint)
TPFlags.ViaHGLogin) != 0);
3984 bool viahome = ((teleportFlags & (uint)
TPFlags.ViaHome) != 0);
3985 bool godlike = ((teleportFlags & (uint)
TPFlags.Godlike) != 0);
3987 reason = String.Empty;
3997 string curViewer = Util.GetViewerName(acd);
3999 "[SCENE]: Region {0} told of incoming {1} agent {2} {3} {4} (circuit code {5}, IP {6}, viewer {7}, teleportflags ({8}), position {9}. {10}",
4000 RegionInfo.RegionName,
4001 (acd.child ?
"child" :
"root"),
4008 ((
TPFlags)teleportFlags).ToString(),
4010 (source == null) ?
"" :
string.Format(
"From region {0} ({1}){2}", source.RegionName, source.RegionID, (source.RawServerURI == null) ?
"" :
" @ " + source.ServerURI)
4017 reason =
"Logins Disabled";
4023 bool ViewerDenied =
true;
4026 if (m_AllowedViewers.Count > 0)
4028 foreach (
string viewer
in m_AllowedViewers)
4030 if (viewer == curViewer.Substring(0, Math.Min(viewer.Length, curViewer.Length)).Trim().ToLower())
4032 ViewerDenied =
false;
4039 ViewerDenied =
false;
4043 if (m_BannedViewers.Count > 0)
4045 foreach (
string viewer
in m_BannedViewers)
4047 if (viewer == curViewer.Substring(0, Math.Min(viewer.Length, curViewer.Length)).Trim().ToLower())
4049 ViewerDenied =
true;
4058 "[SCENE]: Access denied for {0} {1} using {2}",
4059 acd.firstname, acd.lastname, curViewer);
4060 reason =
"Access denied, your viewer is banned by the region owner";
4066 lock (m_removeClientLock)
4068 sp = GetScenePresence(acd.
AgentID);
4077 "[SCENE]: Reusing existing child scene presence for {0}, state {1} in {2}",
4078 sp.Name, sp.LifecycleState, Name);
4100 sp.LifecycleState = ScenePresenceState.Running;
4102 if (EntityTransferModule.IsInTransit(sp.
UUID))
4104 sp.DoNotCloseAfterTeleport =
true;
4107 "[SCENE]: Set DoNotCloseAfterTeleport for child scene presence {0} in {1} because this region will attempt end-of-teleport close from a previous close.",
4117 const int polls = 10;
4118 const int pollInterval = 1000;
4119 int pollsLeft = polls;
4122 Thread.Sleep(pollInterval);
4127 "[SCENE]: Agent {0} in {1} was still being removed after {2}s. Aborting NewUserConnection.",
4128 sp.Name, Name, polls * pollInterval / 1000);
4132 else if (polls != pollsLeft)
4135 "[SCENE]: NewUserConnection for agent {0} in {1} had to wait {2}s for in-progress removal to complete on an old presence.",
4136 sp.Name, Name, polls * pollInterval / 1000);
4141 lock (m_newUserConnLock)
4146 if (!EntityTransferModule.IsInTransit(sp.
UUID))
4152 "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.",
4153 sp.Name, sp.UUID, RegionInfo.RegionName);
4156 CloseAgent(sp.
UUID,
true);
4167 acd.teleportFlags = teleportFlags;
4173 cache.Remove(acd.firstname +
" " + acd.lastname);
4177 m_authenticateHandler.RemoveCircuit(acd.AgentID);
4180 m_authenticateHandler.AddNewCircuit(acd.circuitcode, acd);
4184 if (requirePresenceLookup)
4188 if (!VerifyUserPresence(acd, out reason))
4190 m_authenticateHandler.RemoveCircuit(acd.circuitcode);
4197 "[SCENE]: Exception verifying presence {0}{1}", e.Message, e.StackTrace);
4199 m_authenticateHandler.RemoveCircuit(acd.circuitcode);
4206 if (!AuthorizeUser(acd, (vialogin ?
false : SeeIntoRegion), out reason))
4208 m_authenticateHandler.RemoveCircuit(acd.circuitcode);
4215 "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace);
4217 m_authenticateHandler.RemoveCircuit(acd.circuitcode);
4222 "[SCENE]: Region {0} authenticated and authorized incoming {1} agent {2} {3} {4} (circuit code {5})",
4226 if (CapsModule != null)
4228 CapsModule.SetAgentCapsSeeds(acd);
4229 CapsModule.CreateCaps(acd.AgentID, acd.circuitcode);
4236 sp.TeleportFlags = (
TPFlags)teleportFlags;
4241 "[SCENE]: Adjusting known seeds for existing agent {0} in {1}",
4242 acd.AgentID, RegionInfo.RegionName);
4244 if (CapsModule != null)
4246 CapsModule.SetAgentCapsSeeds(acd);
4247 CapsModule.CreateCaps(acd.AgentID, acd.circuitcode);
4250 sp.AdjustKnownSeeds();
4257 CacheUserName(null, acd);
4260 if (CapsModule != null)
4262 CapsModule.ActivateCaps(acd.circuitcode);
4272 acd.startpos.X = 1f;
4274 acd.startpos.X = RegionInfo.RegionSizeX - 1f;
4276 acd.startpos.Y = 1f;
4278 acd.startpos.Y = RegionInfo.RegionSizeY - 1f;
4282 if(!godlike && teleportFlags != (uint) TPFlags.Default)
4287 if((teleportFlags & (uint)
TPFlags.ViaHome) != 0
4288 || (teleportFlags & (uint)
TPFlags.ViaLure) != 0)
4289 checkTeleHub =
false;
4291 checkTeleHub = vialogin
4292 || (TelehubAllowLandmarks ==
true ?
false : ((teleportFlags & (uint)
TPFlags.ViaLandmark) != 0 ))
4293 || (teleportFlags & (uint)
TPFlags.ViaLocation) != 0;
4295 if(!CheckLandPositionAccess(acd.
AgentID,
true, checkTeleHub, acd.
startpos, out reason))
4297 m_authenticateHandler.RemoveCircuit(acd.circuitcode);
4305 private bool IsPositionAllowed(UUID agentID, Vector3 pos, ref
string reason)
4313 reason =
"You are banned from the region.";
4326 posX = RegionInfo.RegionSizeX - 0.5f;
4330 posY = RegionInfo.RegionSizeY - 0.5f;
4332 reason = String.Empty;
4333 if (Permissions.IsGod(agentID))
4336 ILandObject land = LandChannel.GetLandObject(posX, posY);
4340 bool banned = land.IsBannedFromLand(agentID);
4341 bool restricted = land.IsRestrictedFromLand(agentID);
4343 if (banned || restricted)
4345 ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY);
4346 if (nearestParcel != null)
4349 Vector2 newPosition = GetParcelSafeCorner(nearestParcel);
4350 posX = newPosition.X;
4351 posY = newPosition.Y;
4357 reason =
"Cannot regioncross into banned parcel.";
4361 reason = String.Format(
"Denied access to private region {0}: You are not on the access list for that region.",
4362 RegionInfo.RegionName);
4380 reason = String.Empty;
4383 if (presence == null)
4385 reason = String.Format(
"Failed to verify user presence in the grid for {0} {1} in region {2}. Presence service does not exist.", agent.firstname, agent.lastname, RegionInfo.RegionName);
4393 reason = String.Format(
"Failed to verify user presence in the grid for {0} {1}, access denied to region {2}.", agent.firstname, agent.lastname, RegionInfo.RegionName);
4409 reason = String.Empty;
4411 if (!m_strictAccessControl)
4413 if (Permissions.IsGod(agent.
AgentID))
4416 if (AuthorizationService != null)
4418 if (!AuthorizationService.IsAuthorizedForRegion(
4419 agent.
AgentID.ToString(), agent.firstname, agent.lastname, RegionInfo.RegionID.ToString(), out reason))
4421 m_log.WarnFormat(
"[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because: {4}",
4422 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName, reason);
4432 if (!bypassAccessControl)
4437 m_log.ErrorFormat(
"[CONNECTION BEGIN]: Estate Settings is null!");
4442 int flags = GetUserFlags(agent.
AgentID);
4445 m_log.WarnFormat(
"[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist",
4446 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
4447 reason = String.Format(
"Denied access to region {0}: You have been banned from that region.",
4448 RegionInfo.RegionName);
4461 bool groupAccess =
false;
4464 if(m_groupsModule == null)
4465 goto Label_GroupsDone;
4467 UUID[] estateGroups = RegionInfo.EstateSettings.EstateGroups;
4469 if(estateGroups == null)
4471 m_log.ErrorFormat(
"[CONNECTION BEGIN]: Estate GroupMembership is null!");
4472 goto Label_GroupsDone;
4475 if(estateGroups.Length == 0)
4476 goto Label_GroupsDone;
4478 List<UUID> agentGroups =
new List<UUID>();
4481 if(GroupMembership == null)
4483 m_log.ErrorFormat(
"[CONNECTION BEGIN]: GroupMembership is null!");
4484 goto Label_GroupsDone;
4487 if(GroupMembership.Length == 0)
4488 goto Label_GroupsDone;
4490 for(
int i = 0;i < GroupMembership.Length;i++)
4491 agentGroups.Add(GroupMembership[i].GroupID);
4493 foreach(
UUID group
in estateGroups)
4495 if(agentGroups.Contains(group))
4505 m_log.WarnFormat(
"[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the estate",
4506 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
4507 reason = String.Format(
"Denied access to private region {0}: You are do not have access to that region.",
4508 RegionInfo.RegionName);
4522 m_authenticateHandler.UpdateAgentData(data);
4533 return m_authenticateHandler.TryChangeCiruitCode(oldcc, newcc);
4610 "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName);
4616 "[SCENE]: update for {0} in {1} refused: Logins Disabled", cAgentData.AgentID, RegionInfo.RegionName);
4621 int flags = GetUserFlags(cAgentData.
AgentID);
4624 m_log.DebugFormat(
"[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID);
4630 if (nearestParcel == null)
4633 "[SCENE]: Denying root agent entry to {0} in {1}: no allowed parcel",
4634 cAgentData.AgentID, RegionInfo.RegionName);
4649 m_log.WarnFormat(
"[SCENE]: Ignoring a child update on a root agent {0} {1} in {2}",
4650 sp.Name, sp.UUID, Name);
4656 "[SCENE]: Attempt to update agent {0} with invalid session id {1} (possibly from simulator in older version; tell them to update).",
4657 sp.UUID, cAgentData.SessionID);
4659 Console.WriteLine(String.Format(
"[SCENE]: Attempt to update agent {0} ({1}) with invalid session id {2}",
4660 sp.UUID, sp.ControllingClient.SessionId, cAgentData.SessionID));
4663 sp.UpdateChildAgent(cAgentData);
4673 "[SCENE]: Found presence {0} {1} unexpectedly still child in {2}",
4674 sp.Name, sp.UUID, Name);
4677 "[SCENE]: Found presence {0} {1} as root in {2} after {3} waits",
4678 sp.Name, sp.UUID, Name, 20 - ntimes);
4703 if (childAgentUpdate != null)
4715 uint rRegionY = (((uint)(cAgentData.
RegionHandle)) >> 8);
4716 uint tRegionX = RegionInfo.RegionLocX;
4717 uint tRegionY = RegionInfo.RegionLocY;
4719 childAgentUpdate.UpdateChildAgent(cAgentData, tRegionX, tRegionY, rRegionX, rRegionY);
4739 while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0))
4744 "[SCENE PRESENCE]: Did not find presence with id {0} in {1} before timeout",
4745 agentID, RegionInfo.RegionName);
4757 public bool CloseAgent(UUID agentID,
bool force,
string auth_token)
4767 "[SCENE]: Request to close agent {0} but no such agent in scene {1}. May have been closed previously.",
4773 if (acd.
SessionID.ToString() == auth_token)
4775 return CloseAgent(agentID, force);
4780 "[SCENE]: Request to close agent {0} with invalid authorization token {1} in {2}",
4781 agentID, auth_token, Name);
4809 lock (m_removeClientLock)
4817 "[SCENE]: Not pre-closing {0} agent {1} in {2} since another simulator has re-established the child connection",
4818 sp.IsChildAgent ?
"child" :
"root", sp.Name, Name);
4821 sp.DoNotCloseAfterTeleport =
false;
4829 "[SCENE]: Called IncomingPreCloseAgent() for {0} in {1} but presence is already in state {2}",
4830 sp.Name, Name, sp.LifecycleState);
4835 sp.LifecycleState = ScenePresenceState.PreRemove;
4853 lock (m_removeClientLock)
4855 sp = GetScenePresence(agentID);
4865 if (m_clientManager.TryGetValue(agentID, out client))
4867 m_clientManager.Remove(agentID);
4868 if (CapsModule != null)
4869 CapsModule.RemoveCaps(agentID, 0);
4870 m_log.DebugFormat(
"[SCENE]: Dead client for agent ID {0} was cleaned up in {1}", agentID, Name);
4874 "[SCENE]: Called CloseClient() with agent ID {0} but no such presence is in {1}",
4883 "[SCENE]: Called CloseClient() for {0} in {1} but presence is already in state {2}",
4884 sp.Name, Name, sp.LifecycleState);
4895 "[SCENE]: Not closing {0} agent {1} in {2} since another simulator has re-established the child connection",
4896 sp.IsChildAgent ?
"child" :
"root", sp.Name, Name);
4899 sp.DoNotCloseAfterTeleport =
false;
4904 sp.LifecycleState = ScenePresenceState.Removing;
4909 sp.ControllingClient.Close(force, force);
4928 Vector3 lookat, uint teleportFlags)
4930 GridRegion region = GridService.GetRegionByName(RegionInfo.ScopeID, regionName);
4935 remoteClient.SendTeleportFailed(
"The region '" + regionName +
"' could not be found.");
4939 RequestTeleportLocation(remoteClient, region.
RegionHandle, position, lookat, teleportFlags);
4951 Vector3 lookAt, uint teleportFlags)
4956 if (EntityTransferModule != null)
4958 EntityTransferModule.Teleport(sp, regionHandle, position, lookAt, teleportFlags);
4962 m_log.DebugFormat(
"[SCENE]: Unable to perform teleports: no AgentTransferModule is active");
4963 sp.ControllingClient.SendTeleportFailed(
"Unable to perform teleports on this simulator.");
4970 if (EntityTransferModule != null)
4972 return EntityTransferModule.Cross(agent, isFlying);
4976 m_log.DebugFormat(
"[SCENE]: Unable to cross agent to neighbouring region, because there is no AgentTransferModule");
4984 m_sceneGridService.SendChildAgentDataUpdate(cadu, presence);
4989 #region Other Methods
5001 if ((controller.
SessionId == sessionID) && (controller.
AgentId == agentID))
5007 if (chObjectGroup != null)
5009 chObjectGroup.UpdatePermissions(agentID, field, localId, mask, set);
5025 ((SceneObjectGroup)ent).ScheduleGroupForFullUpdate();
5037 m_log.DebugFormat(
"Searching for Primitive: '{0}'", cmdparams[2]);
5044 SceneObjectPart part = ((SceneObjectGroup)ent).GetPart(((SceneObjectGroup)ent).UUID);
5047 if (part.
Name == cmdparams[2])
5050 new Vector3(Convert.ToSingle(cmdparams[3]), Convert.ToSingle(cmdparams[4]),
5051 Convert.ToSingle(cmdparams[5])));
5053 m_log.DebugFormat(
"Edited scale of Primitive: {0}", part.Name);
5060 #region Script Handling Methods
5068 m_eventManager.TriggerOnPluginConsole(args);
5073 ILandObject parcel = LandChannel.GetLandObject(x, y);
5076 return parcel.LandData;
5086 return GetLandData(pos.X, pos.Y);
5091 m_log.DebugFormat(
"[SCENE]: returning land for {0},{1}", x, y);
5092 ILandObject parcel = LandChannel.GetLandObject((int)x, (
int)y);
5095 return parcel.LandData;
5100 #region Script Engine
5104 ILandObject parcel = LandChannel.GetLandObject(pos.X, pos.Y);
5109 if ((parcel.
LandData.
Flags & (uint)ParcelFlags.AllowOtherScripts) != 0)
5117 else if (((parcel.
LandData.
Flags & (uint)ParcelFlags.AllowGroupScripts) != 0)
5154 return ScriptDanger(part, pos);
5179 #region SceneGraph wrapper methods
5188 return m_sceneGraph.ConvertLocalIDToFullID(localID);
5193 m_sceneGraph.SwapRootChildAgent(rootChildChildRootTF);
5198 m_sceneGraph.AddPhysicalPrim(num);
5203 m_sceneGraph.RemovePhysicalPrim(num);
5208 return m_sceneGraph.GetRootAgentCount();
5213 return m_sceneGraph.GetChildAgentCount();
5223 return m_sceneGraph.GetScenePresence(agentID);
5234 return m_sceneGraph.GetScenePresence(firstName, lastName);
5244 return m_sceneGraph.GetScenePresence(localID);
5261 return new List<ScenePresence>(m_sceneGraph.GetScenePresences());
5271 m_sceneGraph.ForEachAvatar(action);
5280 m_sceneGraph.ForEachScenePresence(action);
5291 return m_sceneGraph.GetSceneObjectGroups();
5301 return m_sceneGraph.GetSceneObjectGroup(fullID);
5312 return m_sceneGraph.GetSceneObjectGroup(localID);
5323 return m_sceneGraph.GetSceneObjectGroup(name);
5334 sog = GetSceneObjectGroup(fullID);
5346 return m_sceneGraph.GetSceneObjectPart(name);
5356 return m_sceneGraph.GetSceneObjectPart(localID);
5366 return m_sceneGraph.GetSceneObjectPart(fullID);
5377 sop = GetSceneObjectPart(fullID);
5388 return m_sceneGraph.GetGroupByPrim(localID);
5398 return m_sceneGraph.GetGroupByPrim(fullID);
5403 return m_sceneGraph.TryGetScenePresence(agentID, out sp);
5408 return m_sceneGraph.TryGetAvatarByName(avatarName, out avatar);
5429 m_clientManager.ForEachSync(action);
5434 return m_clientManager.TryGetValue(avatarID, out client);
5439 return m_clientManager.TryGetValue(remoteEndPoint, out client);
5444 m_sceneGraph.ForEachSOG(action);
5454 return m_sceneGraph.GetEntities();
5477 SceneObjectGroup grp = (SceneObjectGroup)obj;
5484 DeleteSceneObject(grp,
false);
5494 SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID);
5519 message = String.Empty;
5523 if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0))
5531 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000)
5537 if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000)
5543 if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000)
5550 int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
5551 System.Diagnostics.Process proc =
new System.Diagnostics.Process();
5552 proc.EnableRaisingEvents=
false;
5553 proc.StartInfo.FileName =
"/bin/kill";
5554 proc.StartInfo.Arguments =
"-QUIT " + pid.ToString();
5558 Environment.Exit(1);
5566 if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000)
5586 if (jointProxyObject == null)
5588 jointErrorMessage(joint,
"WARNING, joint proxy not found, name " + joint.
ObjectNameInScene);
5593 SceneObjectPart trackedBody = GetSceneObjectPart(joint.
TrackedBodyName);
5594 if (trackedBody == null)
return;
5595 jointProxyObject.Velocity = trackedBody.Velocity;
5596 jointProxyObject.AngularVelocity = trackedBody.AngularVelocity;
5599 case PhysicsJointType.Ball:
5601 Vector3 jointAnchor = PhysicsScene.GetJointAnchor(joint);
5602 Vector3 proxyPos = jointAnchor;
5603 jointProxyObject.ParentGroup.UpdateGroupPosition(proxyPos);
5607 case PhysicsJointType.Hinge:
5609 Vector3 jointAnchor = PhysicsScene.GetJointAnchor(joint);
5624 jointErrorMessage(joint,
"joint.TrackedBodyName is null, joint " + joint.
ObjectNameInScene);
5627 Vector3 proxyPos = jointAnchor;
5628 Quaternion q = trackedBody.RotationOffset * joint.LocalRotation;
5630 jointProxyObject.ParentGroup.UpdateGroupPosition(proxyPos);
5631 jointProxyObject.ParentGroup.UpdateGroupRotationR(q);
5644 protected internal void jointDeactivated(
PhysicsJoint joint)
5648 if (jointProxyObject == null)
5650 jointErrorMessage(joint,
"WARNING, trying to deactivate (stop interpolation of) joint proxy, but not found, name " + joint.
ObjectNameInScene);
5655 bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0);
5656 if (wasUsingPhysics)
5658 jointProxyObject.UpdatePrimFlags(
false,
false,
true,
false,
false);
5677 if (jointProxyObject != null)
5679 SimChat(
Utils.StringToBytes(
"[NINJA]: " + message),
5680 ChatTypeEnum.DebugChannel,
5682 jointProxyObject.AbsolutePosition,
5683 jointProxyObject.Name,
5684 jointProxyObject.UUID,
5687 joint.ErrorMessageCount++;
5691 SimChat(
Utils.StringToBytes(
"[NINJA]: Too many messages for this joint, suppressing further messages."),
5692 ChatTypeEnum.DebugChannel,
5694 jointProxyObject.AbsolutePosition,
5695 jointProxyObject.Name,
5696 jointProxyObject.UUID,
5712 return (Scene)MainConsole.Instance.ConsoleScene;
5724 if (x >= Heightmap.Width)
5725 x = Heightmap.Width - 1;
5728 if (y >= Heightmap.Height)
5729 y = Heightmap.Height - 1;
5731 Vector3 p0 =
new Vector3(x, y, (
float)Heightmap[(
int)x, (
int)y]);
5736 if (p1.X < Heightmap.Width)
5737 p1.Z = (float)Heightmap[(
int)p1.X, (int)p1.Y];
5740 if (p2.Y < Heightmap.Height)
5741 p2.Z = (float)Heightmap[(
int)p2.X, (int)p2.Y];
5743 Vector3 v0 =
new Vector3(p1.X - p0.X, p1.Y - p0.Y, p1.Z - p0.Z);
5744 Vector3 v1 =
new Vector3(p2.X - p0.X, p2.Y - p0.Y, p2.Z - p0.Z);
5749 Vector3 vsn =
new Vector3();
5750 vsn.X = (v0.Y * v1.Z) - (v0.Z * v1.Y);
5751 vsn.Y = (v0.Z * v1.X) - (v0.X * v1.Z);
5752 vsn.Z = (v0.X * v1.Y) - (v0.Y * v1.X);
5755 float xdiff = x - (float)((
int)x);
5756 float ydiff = y - (float)((
int)y);
5758 return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z;
5761 private void CheckHeartbeat()
5763 if (m_firstHeartbeat)
5766 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) > 5000)
5772 return SceneObjectSerializer.FromXml2Format(representation);
5775 public override bool AllowScriptCrossings
5777 get {
return m_allowScriptCrossings; }
5782 return GetNearestAllowedPosition(avatar, null);
5787 Vector3 pos = avatar.AbsolutePosition;
5789 ILandObject nearestParcel = GetNearestAllowedParcel(avatar.
UUID, pos.X, pos.Y, excludeParcel);
5791 if (nearestParcel != null)
5793 Vector2? nearestPoint = null;
5794 Vector3 dir = -avatar.Velocity;
5795 float dirlen = dir.Length();
5798 nearestPoint = nearestParcel.GetNearestPointAlongDirection(pos, dir);
5800 if (nearestPoint == null)
5801 nearestPoint = nearestParcel.GetNearestPoint(pos);
5803 if (nearestPoint != null)
5805 return GetPositionAtAvatarHeightOrGroundHeight(avatar,
5806 nearestPoint.Value.X, nearestPoint.Value.Y);
5809 ILandObject dest = LandChannel.GetLandObject(avatar.lastKnownAllowedPosition.X, avatar.lastKnownAllowedPosition.Y);
5810 if (dest != excludeParcel)
5814 m_log.Debug(
"Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString());
5815 return avatar.lastKnownAllowedPosition;
5822 Vector3 nearestRegionEdgePoint = GetNearestRegionEdgePosition(avatar);
5825 return nearestRegionEdgePoint;
5828 private Vector3 GetParcelCenterAtGround(
ILandObject parcel)
5830 Vector2 center = parcel.CenterPoint;
5831 return GetPositionAtGround(center.X, center.Y);
5836 return GetNearestAllowedParcel(avatarId, x, y, null);
5841 if(LandChannel == null)
5844 List<ILandObject> all = LandChannel.AllParcels();
5846 if(all == null || all.Count == 0)
5849 float minParcelDistanceSQ = float.MaxValue;
5852 float parcelDistanceSQ;
5854 foreach (var parcel
in all)
5856 if (parcel != excludeParcel && !parcel.IsEitherBannedOrRestricted(avatarId))
5858 curCenter = parcel.CenterPoint;
5861 parcelDistanceSQ = curCenter.LengthSquared();
5862 if (parcelDistanceSQ < minParcelDistanceSQ)
5864 minParcelDistanceSQ = parcelDistanceSQ;
5865 nearestParcel = parcel;
5870 return nearestParcel;
5873 private Vector2 GetParcelSafeCorner(
ILandObject parcel)
5875 Vector2 place = parcel.StartPoint;
5881 private Vector3 GetNearestRegionEdgePosition(ScenePresence avatar)
5883 float posX = avatar.AbsolutePosition.X;
5884 float posY = avatar.AbsolutePosition.Y;
5885 float regionSizeX = RegionInfo.RegionSizeX;
5886 float halfRegionSizeX = regionSizeX * 0.5f;
5887 float regionSizeY = RegionInfo.RegionSizeY;
5888 float halfRegionSizeY = regionSizeY * 0.5f;
5890 float xdistance = posX < halfRegionSizeX ? posX : regionSizeX - posX;
5891 float ydistance = posY < halfRegionSizeY ? posY : regionSizeY - posY;
5894 if (xdistance < ydistance)
5896 if (posX < halfRegionSizeX)
5897 return GetPositionAtAvatarHeightOrGroundHeight(avatar, 0.5f, posY);
5899 return GetPositionAtAvatarHeightOrGroundHeight(avatar, regionSizeX - 0.5f, posY);
5904 if (posY < halfRegionSizeY)
5905 return GetPositionAtAvatarHeightOrGroundHeight(avatar, posX, 0.5f);
5907 return GetPositionAtAvatarHeightOrGroundHeight(avatar, posX, regionSizeY - 0.5f);
5911 private Vector3 GetPositionAtAvatarHeightOrGroundHeight(ScenePresence avatar,
float x,
float y)
5913 Vector3 ground = GetPositionAtGround(x, y);
5914 if(avatar.Appearance != null)
5915 ground.Z += avatar.Appearance.AvatarHeight * 0.5f;
5919 if (avatar.AbsolutePosition.Z > ground.Z)
5921 ground.Z = avatar.AbsolutePosition.Z;
5926 private Vector3 GetPositionAtGround(
float x,
float y)
5928 return new Vector3(x, y, GetGroundHeight(x, y));
5934 if (estateDataService == null)
5935 return new List<UUID>(0);
5937 return estateDataService.GetRegions(estateID);
5943 if (estateDataService != null)
5945 RegionInfo.EstateSettings = estateDataService.LoadEstateSettings(RegionInfo.RegionID,
false);
5946 TriggerEstateSunUpdate();
5952 EventManager.TriggerEstateToolsSunUpdate(RegionInfo.RegionHandle);
5955 private void HandleReloadEstate(
string module,
string[] cmd)
5977 List<SceneObjectGroup> objects,
5978 out
float minX, out
float maxX, out
float minY, out
float maxY, out
float minZ, out
float maxZ)
5980 minX = float.MaxValue;
5981 maxX = float.MinValue;
5982 minY = float.MaxValue;
5983 maxY = float.MinValue;
5984 minZ = float.MaxValue;
5985 maxZ = float.MinValue;
5987 List<Vector3> offsets =
new List<Vector3>();
5991 float ominX, ominY, ominZ, omaxX, omaxY, omaxZ;
5993 Vector3 vec = g.AbsolutePosition;
5995 g.GetAxisAlignedBoundingBoxRaw(out ominX, out omaxX, out ominY, out omaxY, out ominZ, out omaxZ);
6024 Vector3 vec = g.AbsolutePosition;
6032 return offsets.ToArray();
6040 private void RegenerateMaptile()
6042 IWorldMapModule mapModule = RequestModuleInterface<IWorldMapModule>();
6043 if (mapModule != null)
6044 mapModule.GenerateMaptile();
6087 m_lastIncoming = Util.EnvironmentTickCount();
6090 m_lastOutgoing = Util.EnvironmentTickCount();
6097 RegenerateMaptile();
6102 if (error !=
string.Empty)
6103 throw new Exception(error);
6122 public bool QueryAccess(UUID agentID,
string agentHomeURI,
bool viaTeleport, Vector3 position, List<UUID> features, out
string reason)
6124 reason = string.Empty;
6126 if (Permissions.IsGod(agentID))
6129 if (!AllowAvatarCrossing && !viaTeleport)
6131 reason =
"Region Crossing not allowed";
6135 bool isAdmin = Permissions.IsAdministrator(agentID);
6136 bool isManager = Permissions.IsEstateManager(agentID);
6140 m_sceneGraph.RecalculateStats();
6142 int num = m_sceneGraph.GetRootAgentCount();
6146 if (!(isAdmin || isManager))
6148 reason =
"The region is full";
6151 "[SCENE]: Denying presence with id {0} entry into {1} since region is at agent limit of {2}",
6152 agentID, RegionInfo.RegionName, RegionInfo.RegionSettings.AgentLimit);
6162 if (presence != null)
6164 client = presence.ControllingClient;
6166 aCircuit = client.RequestClientInfo();
6174 aCircuit.AgentID = agentID;
6175 aCircuit.firstname = String.Empty;
6176 aCircuit.lastname = String.Empty;
6181 if (!AuthorizeUser(aCircuit,
false, out reason))
6190 m_log.DebugFormat(
"[SCENE]: Exception authorizing agent: {0} " + e.StackTrace, e.Message);
6191 reason =
"Error authorizing agent: " + e.Message;
6197 return CheckLandPositionAccess(agentID, viaTeleport,
true, position, out reason);
6203 reason = string.Empty;
6205 if (Permissions.IsGod(agentID))
6208 bool isAdmin = Permissions.IsAdministrator(agentID);
6213 bool isManager = Permissions.IsEstateManager(agentID);
6225 bool validTelehub =
false;
6226 List<SpawnPoint> spawnPoints = RegionInfo.RegionSettings.SpawnPoints();
6229 Vector3 telehubPosition = telehub.AbsolutePosition;
6231 if(spawnPoints.Count == 0)
6235 spawnPoint = telehubPosition;
6236 land = LandChannel.GetLandObject(spawnPoint.X, spawnPoint.Y);
6240 validTelehub =
true;
6245 Quaternion telehubRotation = telehub.GroupRotation;
6248 spawnPoint = spawn.GetLocation(telehubPosition, telehubRotation);
6249 land = LandChannel.GetLandObject(spawnPoint.X, spawnPoint.Y);
6252 validTelehub =
true;
6253 if (!land.IsEitherBannedOrRestricted(agentID))
6265 reason =
"No suitable landing point found";
6275 float posX = position.X;
6276 float posY = position.Y;
6279 if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY))
6282 reason =
"You dont have access to the region parcels";
6289 ILandObject land = LandChannel.GetLandObject(position.X, position.Y);
6292 reason =
"No parcel found";
6296 bool banned = land.IsBannedFromLand(agentID);
6297 bool restricted = land.IsRestrictedFromLand(agentID);
6299 if (banned || restricted)
6302 reason =
"You are banned from the parcel";
6304 reason =
"The parcel is restricted";
6314 m_timerWatchdog.Interval = 1000;
6315 m_timerWatchdog.Elapsed += TimerWatchdog;
6316 m_timerWatchdog.AutoReset =
true;
6317 m_timerWatchdog.Start();
6393 int spawnpoints = RegionInfo.RegionSettings.SpawnPoints().Count;
6395 if (spawnpoints == 0)
6399 if (m_SpawnPoint > spawnpoints)
6401 return m_SpawnPoint - 1;
6404 private void HandleGcCollect(
string module,
string[] args)
6422 AssetService.Get(assetID.ToString(), callback, PhysicsAssetReceived);
6425 private void PhysicsAssetReceived(
string id, Object sender,
AssetBase asset)
6434 if (m_extraSettings == null)
6435 return String.Empty;
6439 if (!m_extraSettings.TryGetValue(name, out val))
6447 if (m_extraSettings == null)
6452 if (m_extraSettings.TryGetValue(name, out oldVal))
6458 m_extraSettings[name] = val;
6460 m_SimulationDataService.SaveExtra(RegionInfo.RegionID, name, val);
6462 m_eventManager.TriggerExtraSettingChanged(
this, name, val);
6467 if (m_extraSettings == null)
6470 if (!m_extraSettings.ContainsKey(name))
6473 m_extraSettings.Remove(name);
6475 m_SimulationDataService.RemoveExtra(RegionInfo.RegionID, name);
6477 m_eventManager.TriggerExtraSettingChanged(
this, name, String.Empty);
delegate void RezScript(IClientAPI remoteClient, InventoryItemBase item, UUID transactionID, uint localID)
uint GetEffectivePermissions()
virtual void SubscribeToClientEvents(IClientAPI client)
Register for events from the client
void Backup(bool forced)
Backup the scene.
bool ScriptDanger(uint localID, Vector3 pos)
override void OtherRegionUp(GridRegion otherRegion)
Process the fact that a neighbouring region has come up.
string lastname
Agent's account last name
LandData GetLandData(uint x, uint y)
delegate void UpdatePrimSingleRotationPosition(uint localID, Quaternion rot, Vector3 pos, IClientAPI remoteClient)
EstateSettings EstateSettings
IAuthenticationService m_AuthenticationService
bool CrossAgentToNewRegion(ScenePresence agent, bool isFlying)
delegate void UpdatePrimGroupRotation(uint localID, Vector3 pos, Quaternion rot, IClientAPI remoteClient)
IClientAPI ControllingClient
virtual SceneObjectGroup AddNewPrim(UUID ownerID, UUID groupID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape)
uint circuitcode
Number given to the client when they log-in that they provide as credentials to the UDP server ...
override void Update(int frames)
Called to update the scene loop by a number of frames and until shutdown.
delegate void RemoveInventoryItem(IClientAPI remoteClient, List< UUID > itemIDs)
delegate void UpdatePrimSingleRotation(uint localID, Quaternion rot, IClientAPI remoteClient)
bool IncomingCreateObject(Vector3 newPosition, ISceneObject sog)
Called when objects or attachments cross the border, or teleport, between regions.
void AddPhysicalPrim(int num)
void DeleteAllSceneObjects()
Delete every object from the scene. This does not include attachments worn by avatars.
void RequestTeleportLocation(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint teleportFlags)
Tries to teleport agent to other region.
OpenSim.Services.Interfaces.GridRegion GridRegion
bool NewUserConnection(AgentCircuitData acd, uint teleportFlags, GridRegion source, out string reason, bool requirePresenceLookup)
delegate bool FilterAvatarList(ScenePresence avatar)
void DeleteSceneObject(SceneObjectGroup group, bool silent)
Synchronously delete the given object from the scene.
OpenSim.Framework.Constants.TeleportFlags TeleportFlags
bool TryGetSceneObjectGroup(UUID fullID, out SceneObjectGroup sog)
Attempt to get the SOG via its UUID
delegate void UpdateTaskInventory(IClientAPI remoteClient, UUID transactionID, TaskInventoryItem item, uint localID)
void AddNeighborRegion(RegionInfo region)
bool QueryAccess(UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, List< UUID > features, out string reason)
This method is called across the simulation connector to determine if a given agent is allowed in thi...
SceneObjectPart GetSceneObjectPart(UUID fullID)
Get a prim via its UUID
ScenePresence GetScenePresence(string firstName, string lastName)
Request the scene presence by name.
override bool CloseAgent(UUID agentID, bool force)
Tell a single agent to disconnect from the region.
virtual ScenePresence WaitGetScenePresence(UUID agentID)
Poll until the requested ScenePresence appears or we timeout.
bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, Vector3?pos, Quaternion?rot, Vector3 vel)
Add a newly created object to the scene.
delegate void RequestTaskInventory(IClientAPI remoteClient, uint localID)
float GetGroundHeight(float x, float y)
virtual void RegisterDefaultSceneEvents()
void jointErrorMessage(PhysicsJoint joint, string message)
void SaveTerrain()
Store the terrain in the persistant data store
void DoMaintenance(int runs)
bool VerifyClient(AgentCircuitData aCircuit, string token)
void loadAllLandObjectsFromStorage(UUID regionID)
Loads all Parcel data from the datastore for region identified by regionID
EntityBase[] GetEntities()
Returns a list of the entities in the scene. This is a new list so operations perform on the list its...
OpenSim.Server.Handlers.Simulation.Utils Utils
Class that Region communications runs through
LandData GetLandData(Vector3 pos)
Get LandData by position.
SynchronizeSceneHandler SynchronizeScene
Vector3 GetNearestAllowedPosition(ScenePresence avatar)
const int maxErrorMessages
Send FetchInventoryReply information to clients asynchronously on a single thread rather than asynchr...
bool SenderWantsToWaitForRoot
Signal on a V2 teleport that Scene.IncomingChildAgentDataUpdate(AgentData ad) should wait for the sce...
IGridService m_GridService
SceneObjectGroup GetSceneObjectGroup(string name)
Get a group by name from the scene (will return the first found, if there are more than one prim with...
void StartTimerWatchdog()
delegate void UpdatePrimFlags(uint localID, bool UsePhysics, bool IsTemporary, bool IsPhantom, ExtraPhysicsData PhysData, IClientAPI remoteClient)
delegate void RezObject(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart, UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, bool RezSelected, bool RemoveItem, UUID fromTaskID)
virtual bool AuthorizeUser(AgentCircuitData agent, bool bypassAccessControl, out string reason)
Verify if the user can connect to this region. Checks the banlist and ensures that the region is set ...
uint RegionSizeX
X dimension of the region.
Contains the Avatar's Appearance and methods to manipulate the appearance.
void RemoveGroupTarget(SceneObjectGroup grp)
void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e)
ScenePresenceState
The possible states that a scene presence can be in. This is currently orthagonal to whether a scene ...
ISimulationService m_simulationService
delegate void ClientChangeObject(uint localID, object data, IClientAPI remoteClient)
IGroupsModule m_groupsModule
override bool CheckClient(UUID agentID, System.Net.IPEndPoint ep)
delegate void DelinkObjects(List< uint > primIds, IClientAPI client)
SceneObjectPart GetSceneObjectPart(uint localID)
Get a prim via its local id
uint RegionSizeY
X dimension of the region.
OpenMetaverse.StructuredData.OSDMap OSDMap
bool TryGetAvatarByName(string avatarName, out ScenePresence avatar)
Asynchronously derez objects. This is used to derez large number of objects to inventory without hold...
bool IsBanned(UUID avatarID)
IGridUserService m_GridUserService
Vector3 startpos
Position the Agent's Avatar starts in the region
override void LoadWorldMap()
Loads the World heightmap
A scene object group is conceptually an object in the scene. The object is constituted of SceneObject...
Add remove or retrieve Simulator Features that will be given to a viewer via the SimulatorFeatures ca...
PrimFlags Flags
Property flags. See OpenMetaverse.PrimFlags
void RemovePhysicalPrim(int num)
IDialogModule m_dialogModule
void DeleteAllSceneObjects(bool exceptNoCopy)
Delete every object from the scene. This does not include attachments worn by avatars.
Dictionary< string, object > ServiceURLs
void ForEachSOG(Action< SceneObjectGroup > action)
SceneObjectGroup GetGroupByPrim(UUID fullID)
Get a scene object group that contains the prim with the given uuid
void ForEachRootClient(Action< IClientAPI > action)
Perform an action on all clients with an avatar in this scene (root only)
RegionSettings RegionSettings
delegate void UpdatePrimTexture(uint localID, byte[] texture, IClientAPI remoteClient)
void DeleteSceneObject(SceneObjectGroup group, bool silent, bool removeScripts)
Synchronously delete the given object from the scene.
delegate void AddNewPrim(UUID ownerID, UUID groupID, Vector3 RayEnd, Quaternion rot, PrimitiveBaseShape shape, byte bypassRaycast, Vector3 RayStart, UUID RayTargetID, byte RayEndIsIntersection)
int GetUserFlags(UUID user)
Vector3 GetNearestAllowedPosition(ScenePresence avatar, ILandObject excludeParcel)
virtual void UnSubscribeToClientTerrainEvents(IClientAPI client)
Enapsulate statistics for a simulator/scene.
string IPAddress
The client's IP address, as captured by the login service
virtual void SubscribeToClientTeleportEvents(IClientAPI client)
delegate void CopyInventoryItem(IClientAPI remoteClient, uint callbackID, UUID oldAgentID, UUID oldItemID, UUID newFolderID, string newName)
bool IsEitherBannedOrRestricted(UUID avatar)
PresenceType
Indicate the type of ScenePresence.
bool TryGetFeature(string name, out OSD value)
System.Timers.Timer Timer
bool DoNotCloseAfterTeleport
Used by the entity transfer module to signal when the presence should not be closed because a subsequ...
ScenePresence GetScenePresence(UUID agentID)
Request a scene presence by UUID. Fast, indexed lookup.
virtual void UnSubscribeToClientPrimRezEvents(IClientAPI client)
SceneCommunicationService m_sceneGridService
UUID SessionID
Non secure Session ID
ILibraryService m_LibraryService
bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates)
Add a newly created object to the scene
void SwapRootAgentCount(bool rootChildChildRootTF)
System.Timers.Timer Timer
bool IsDeleted
Signals whether this entity was in a scene but has since been removed from it.
Asset class. All Assets are reference by this class or a class derived from this class ...
void AddReturn(UUID agentID, string objectName, Vector3 location, string reason)
Tell an agent that their object has been returned.
void RequestTeleportLocation(IClientAPI remoteClient, string regionName, Vector3 position, Vector3 lookat, uint teleportFlags)
Tries to teleport agent to another region.
IPresenceService m_PresenceService
IWorldComm m_worldCommModule
virtual void UnSubscribeToClientScriptEvents(IClientAPI client)
virtual void UnSubscribeToClientEvents(IClientAPI client)
Unsubscribe the client from events.
string firstname
Agent's account first name
bool isNeighborRegion(GridRegion otherRegion)
bool IsBannedFromLand(UUID avatar)
void updateScenePartGroup(SceneObjectPart part, SceneObjectGroup grp)
OpenSim.Framework.Constants.TeleportFlags TPFlags
void PhysicsRequestAsset(UUID assetID, AssetReceivedDelegate callback)
Wrappers to get physics modules retrieve assets.
IAvatarService m_AvatarService
delegate void AssetReceivedDelegate(AssetBase asset)
LandData GetLandData(float x, float y)
virtual bool IncomingUpdateChildAgent(AgentData cAgentData)
We've got an update about an agent that sees into this region, send it to ScenePresence for processin...
bool HasAccess(UUID user)
delegate void MoveObject(UUID objectID, Vector3 offset, Vector3 grapPos, IClientAPI remoteClient, List< SurfaceTouchEventArgs > surfaceArgs)
override void Close()
Tidy before shutdown
bool IsAttachmentCheckFull()
Check both the attachment property and the relevant properties of the underlying root part...
virtual void SubscribeToClientParcelEvents(IClientAPI client)
void LoadWindlightProfile()
IUserAccountService m_UserAccountService
SceneObjectGroup GetSceneObjectGroup(UUID fullID)
Get a group via its UUID
SceneObjectGroup GetGroupByPrim(uint localID)
Get a scene object group that contains the prim with the given local id
UUID GroupID
Unique ID of the Group that owns
void HandleRemoveKnownRegionsFromAvatar(UUID avatarID, List< ulong > regionslst)
Removes region from an avatar's known region list. This coincides with child agents. For each child agent, there will be a known region entry.
void AllModulesLoaded()
Called by the module loader when all modules are loaded, after each module's RegionLoaded hook is cal...
int GetInaccurateNeighborCount()
void StoreWindlightProfile(RegionLightShareData wl)
virtual void SubscribeToClientGridEvents(IClientAPI client)
GridRegion IncomingHelloNeighbour(RegionInfo neighbour)
override string GetSimulatorVersion()
void TriggerEstateSunUpdate()
Circuit data for an agent. Connection information shared between regions that accept UDP connections ...
IRegionSerialiserModule m_serialiser
List< UUID > GetEstateRegions(int estateID)
static ICommandConsole Instance
bool TryGetSceneObjectPart(UUID fullID, out SceneObjectPart sop)
Attempt to get a prim via its UUID
virtual void LoadPrimsFromStorage(UUID regionID)
Loads the World's objects
Details of a Parcel of land
delegate void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID)
void RegisterRegionWithGrid()
Register this region with a grid service
delegate void ObjectOwner(IClientAPI remoteClient, UUID ownerID, UUID groupID, List< uint > localIDs)
bool SupportsRayCastFiltered()
ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y, ILandObject excludeParcel)
bool NewUserConnection(AgentCircuitData agent, uint teleportFlags, GridRegion source, out string reason)
Do the work necessary to initiate a new user connection for a particular scene.
void ForceSceneObjectBackup(SceneObjectGroup group)
Synchronous force backup. For deletes and links/unlinks
Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter)
Gets a new rez location based on the raycast and the size of the object that is being rezzed...
ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y)
PhysicsActor PhysActor
The representation of this part in the physics scene.
OpenMetaverse.StructuredData.OSD OSD
virtual bool IncomingUpdateChildAgent(AgentPosition cAgentData)
We've got an update about an agent that sees into this region, send it to ScenePresence for processin...
void TimerWatchdog(object sender, ElapsedEventArgs e)
virtual void SubscribeToClientPrimEvents(IClientAPI client)
SceneObjectPart GetSceneObjectPart(string name)
Get a prim by name from the scene (will return the first found, if there are more than one prim with ...
virtual void UnSubscribeToClientInventoryEvents(IClientAPI client)
override ISceneObject DeserializeObject(string representation)
void StoreExtraSetting(string name, string val)
delegate void MoveInventoryItem(IClientAPI remoteClient, List< InventoryItemBase > items)
Replacement for ChildAgentDataUpdate. Used over RESTComms and LocalComms.
static Vector3[] GetCombinedBoundingBox(List< SceneObjectGroup > objects, out float minX, out float maxX, out float minY, out float maxY, out float minZ, out float maxZ)
Get the volume of space that will encompass all the given objects.
AgentCircuitManager m_authenticateHandler
void AddScriptExecutionTime(long ticks)
Adds the execution time of one script to the total scripts execution time for this region...
delegate void LinkObjects(IClientAPI remoteClient, uint parent, List< uint > children)
void setThreadCount(int inUseThreads)
bool PipeEventsForScript(uint localID)
SceneObjectGroup GetSceneObjectGroup(uint localID)
Get a group via its local ID
void HandleObjectPermissionsUpdate(IClientAPI controller, UUID agentID, UUID sessionID, byte field, uint localId, uint mask, byte set)
override bool TryGetScenePresence(UUID agentID, out ScenePresence sp)
Try to get a scene presence from the scene
A class for triggering remote scene events.
Collect statistics from the scene to send to the client and for access by other monitoring tools...
virtual void UnSubscribeToClientPrimEvents(IClientAPI client)
void SendOutChildAgentUpdates(AgentPosition cadu, ScenePresence presence)
PresenceType PresenceType
bool IncomingPreCloseClient(ScenePresence sp)
Tell a single client to prepare to close.
void ThreadAlive(int threadCode)
delegate void SpinStart(UUID objectID, IClientAPI remoteClient)
void RestartNotifyWaitElapsed(object sender, ElapsedEventArgs e)
delegate void SpinObject(UUID objectID, Quaternion rotation, IClientAPI remoteClient)
SceneObjectGroup ParentGroup
virtual void SubscribeToClientTerrainEvents(IClientAPI client)
bool UnlinkSceneObject(SceneObjectGroup so, bool softDelete)
Unlink the given object from the scene. Unlike delete, this just removes the record of the object - t...
ISimulationDataService m_SimulationDataService
UUID ConvertLocalIDToFullID(uint localID)
OpenSim.Framework.PermissionMask PermissionMask
virtual void AddNewPrim(UUID ownerID, UUID groupID, Vector3 RayEnd, Quaternion rot, PrimitiveBaseShape shape, byte bypassRaycast, Vector3 RayStart, UUID RayTargetID, byte RayEndIsIntersection)
Create a New SceneObjectGroup/Part by raycasting
virtual void SubscribeToClientNetworkEvents(IClientAPI client)
void SendCommandToPlugins(string[] args)
Console command handler to send script command to script engine.
IAvatarFactoryModule m_AvatarFactory
virtual void UnSubscribeToClientGridEvents(IClientAPI client)
bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY)
string GetExtraSetting(string name)
void Start(bool startScripts)
Start the scene
string GetAgentHomeURI(UUID agentID)
Returns the Home URI of the agent, or null if unknown.
List< SceneObjectGroup > GetSceneObjectGroups()
Get all the scene object groups.
UUID TelehubObject
Connected Telehub object
bool PositionIsInCurrentRegion(Vector3 pos)
bool CheckLandPositionAccess(UUID agentID, bool NotCrossing, bool checkTeleHub, Vector3 position, out string reason)
IEstateDataService m_EstateDataService
override Vector3 AbsolutePosition
The absolute position of this scene object in the scene
int GetSittingAvatarsCount()
Gets the number of sitting avatars.
bool AddRestoredSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted)
Add an object into the scene that has come from storage
void RemoveClient(UUID agentID, bool closeChildAgents)
List< ScenePresence > GetScenePresences()
Gets all the scene presences in this scene.
uint Flags
Parcel settings. Access flags, Fly, NoPush, Voice, Scripts allowed, etc. ParcelFlags ...
virtual bool SupportsNINJAJoints
delegate void SetScriptRunning(IClientAPI remoteClient, UUID objectID, UUID itemID, bool running)
UUID AgentID
Avatar Unique Agent Identifier
bool ChangeCircuitCode(uint oldcc, uint newcc)
Change the Circuit Code for the user's Circuit Data
void ForEachRootScenePresence(Action< ScenePresence > action)
Performs action on all avatars in the scene (root scene presences) Avatars may be an NPC or a 'real' ...
A new version of the old Channel class, simplified
override void Start()
Start the scene and associated scripts within it.
IAgentPreferencesService m_AgentPreferencesService
delegate void RemoveInventoryFolder(IClientAPI remoteClient, List< UUID > folderIDs)
void RemoveExtraSetting(string name)
int GetHealth(out int flags, out string message)
bool TryGetClient(System.Net.IPEndPoint remoteEndPoint, out IClientAPI client)
void ForceClientUpdate()
Causes all clients to get a full object update on all of the objects in the scene.
void HandleEditCommand(string[] cmdparams)
This is currently only used for scale (to scale to MegaPrim size) There is a console command that cal...
KeyframeMotion KeyframeMotion
virtual void UnSubscribeToClientParcelEvents(IClientAPI client)
void SendKillObject(List< uint > localIDs)
uint RegionSizeZ
Z dimension of the region.
override IConfigSource GetConfig()
void doObjectDuplicateOnRay(uint localID, uint dupeFlags, UUID AgentID, UUID GroupID, UUID RayTargetObj, Vector3 RayEnd, Vector3 RayStart, bool BypassRaycast, bool RayEndIsIntersection, bool CopyCenters, bool CopyRotates)
Duplicates object specified by localID at position raycasted against RayTargetObject using RayEnd and...
uint teleportFlags
How this agent got here
object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter)
This maintains the relationship between a UUID and a user name.
delegate void RequestObjectPropertiesFamily(IClientAPI remoteClient, UUID AgentID, uint RequestFlags, UUID TaskID)
virtual bool VerifyUserPresence(AgentCircuitData agent, out string reason)
Verifies that the user has a presence on the Grid
virtual void SubscribeToClientScriptEvents(IClientAPI client)
IAuthorizationService m_AuthorizationService
bool TryGetClient(UUID avatarID, out IClientAPI client)
override ISceneAgent AddNewAgent(IClientAPI client, PresenceType type)
Add a new agent with an attached client. All agents except initial login clients will starts off as a...
ScenePresence GetScenePresence(uint localID)
Request the scene presence by localID.
virtual void UnSubscribeToClientTeleportEvents(IClientAPI client)
bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup)
Add a newly created object to the scene. Updates are also sent to viewers.
virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
Teleport an avatar to their home region
IInventoryService m_InventoryService
IAssetService m_AssetService
ICapabilitiesModule m_capsModule
ScenePresenceState LifecycleState
The current state of this presence. Governs only the existence lifecycle. See ScenePresenceStateMachi...
void GetAvatarAppearance(IClientAPI client, out AvatarAppearance appearance)
Get the avatar appearance for the given client.
Scene(RegionInfo regInfo)
bool CloseAgent(UUID agentID, bool force, string auth_token)
Authenticated close (via network)
bool AddRestoredSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates)
Add an object into the scene that has come from storage
virtual void SubscribeToClientPrimRezEvents(IClientAPI client)
void UpdateCircuitData(AgentCircuitData data)
Update an AgentCircuitData object with new information
void ForEachClient(Action< IClientAPI > action)
Perform an action on all clients connected to the region (root and child)
This class used to be called InnerScene and may not yet truly be a SceneGraph. The non scene graph co...
Vector3 GetWorldPosition()
Method for a prim to get it's world position from the group.
void DeleteFromStorage(UUID uuid)
bool GroupContainsForeignPrims
Whether the group contains prims that came from a different group. This happens when linking or delin...
void DuplicateObject(uint originalPrim, Vector3 offset, uint flags, UUID AgentID, UUID GroupID)
Duplicates object specified by localID. This is the event handler for IClientAPI. ...
UpdatePrioritizationSchemes
long GetAndResetScriptExecutionTime()
Returns the total execution time of all the scripts in the region since the last call (in millisecond...
bool IsAttachment
Is this scene object acting as an attachment?
bool CheckNeighborRegion(RegionInfo region)
bool AddSceneObject(SceneObjectGroup sceneObject)
Adds a Scene Object group to the Scene. Verifies that the creator of the object is not banned from th...
delegate void GetScriptRunning(IClientAPI remoteClient, UUID objectID, UUID itemID)
void AddGroupTarget(SceneObjectGroup grp)
Scene(RegionInfo regInfo, AgentCircuitManager authen, ISimulationDataService simDataService, IEstateDataService estateDataService, IConfigSource config, string simulatorVersion)
virtual void SubscribeToClientInventoryEvents(IClientAPI client)
void SetModuleInterfaces()
Sets up references to modules required by the scene
virtual void UnSubscribeToClientNetworkEvents(IClientAPI client)
uint ParentID
If the avatar is sitting, the local ID of the prim that it's sitting on. If not sitting then zero...
UUID OwnerID
Owner Avatar or Group of the parcel. Naturally, all land masses must be owned by someone ...
void ForEachScenePresence(Action< ScenePresence > action)
Performs action on all scene presences (root and child)