aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes
diff options
context:
space:
mode:
authorUbitUmarov2014-08-12 18:42:18 +0100
committerUbitUmarov2014-08-12 18:42:18 +0100
commit4997a9e87a860e3c39c164bf8a4079ef4ff63089 (patch)
tree1a7140a0cab7f3deb3720440d82bd9dd478293d0 /OpenSim/Region/Framework/Scenes
parent change XMLIrpgGroups attach to events, using the more correct (diff)
downloadopensim-SC-4997a9e87a860e3c39c164bf8a4079ef4ff63089.zip
opensim-SC-4997a9e87a860e3c39c164bf8a4079ef4ff63089.tar.gz
opensim-SC-4997a9e87a860e3c39c164bf8a4079ef4ff63089.tar.bz2
opensim-SC-4997a9e87a860e3c39c164bf8a4079ef4ff63089.tar.xz
fix VS creative indentation
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs272
1 files changed, 136 insertions, 136 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 5387910..762dbd4 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -1113,9 +1113,9 @@ namespace OpenSim.Region.Framework.Scenes
1113 1113
1114 //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); 1114 //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count);
1115 1115
1116 // m_log.InfoFormat( 1116 // m_log.InfoFormat(
1117 // "[SCENE]: Upgrading child to root agent for {0} in {1}", 1117 // "[SCENE]: Upgrading child to root agent for {0} in {1}",
1118 // Name, m_scene.RegionInfo.RegionName); 1118 // Name, m_scene.RegionInfo.RegionName);
1119 1119
1120 if (ParentUUID != UUID.Zero) 1120 if (ParentUUID != UUID.Zero)
1121 { 1121 {
@@ -1148,17 +1148,17 @@ namespace OpenSim.Region.Framework.Scenes
1148 // Must reset this here so that a teleport to a region next to an existing region does not keep the flag 1148 // Must reset this here so that a teleport to a region next to an existing region does not keep the flag
1149 // set and prevent the close of the connection on a subsequent re-teleport. 1149 // set and prevent the close of the connection on a subsequent re-teleport.
1150 // Should not be needed if we are not trying to tell this region to close 1150 // Should not be needed if we are not trying to tell this region to close
1151// DoNotCloseAfterTeleport = false; 1151 // DoNotCloseAfterTeleport = false;
1152 1152
1153 IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); 1153 IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>();
1154 if (gm != null) 1154 if (gm != null)
1155 Grouptitle = gm.GetGroupTitle(m_uuid); 1155 Grouptitle = gm.GetGroupTitle(m_uuid);
1156 1156
1157 RegionHandle = m_scene.RegionInfo.RegionHandle; 1157 RegionHandle = m_scene.RegionInfo.RegionHandle;
1158 1158
1159 m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); 1159 m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene);
1160 1160
1161/* this is now done by groups module on TriggerOnMakeRootAgent(this) below 1161/* this should be done by groups module on TriggerOnMakeRootAgent(this) below
1162 at least XmlIRpcGroups 1162 at least XmlIRpcGroups
1163 UUID groupUUID = UUID.Zero; 1163 UUID groupUUID = UUID.Zero;
1164 string GroupName = string.Empty; 1164 string GroupName = string.Empty;
@@ -1191,149 +1191,149 @@ namespace OpenSim.Region.Framework.Scenes
1191 } 1191 }
1192 // ------------------------------------ 1192 // ------------------------------------
1193*/ 1193*/
1194 if (ParentID == 0) 1194 if (ParentID == 0)
1195 { 1195 {
1196 // Moved this from SendInitialData to ensure that Appearance is initialized 1196 // Moved this from SendInitialData to ensure that Appearance is initialized
1197 // before the inventory is processed in MakeRootAgent. This fixes a race condition 1197 // before the inventory is processed in MakeRootAgent. This fixes a race condition
1198 // related to the handling of attachments 1198 // related to the handling of attachments
1199 1199
1200 if (m_scene.TestBorderCross(pos, Cardinals.E)) 1200 if (m_scene.TestBorderCross(pos, Cardinals.E))
1201 { 1201 {
1202 Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); 1202 Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E);
1203 pos.X = crossedBorder.BorderLine.Z - 1; 1203 pos.X = crossedBorder.BorderLine.Z - 1;
1204 } 1204 }
1205 1205
1206 if (m_scene.TestBorderCross(pos, Cardinals.N)) 1206 if (m_scene.TestBorderCross(pos, Cardinals.N))
1207 { 1207 {
1208 Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); 1208 Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N);
1209 pos.Y = crossedBorder.BorderLine.Z - 1; 1209 pos.Y = crossedBorder.BorderLine.Z - 1;
1210 } 1210 }
1211 1211
1212 CheckAndAdjustLandingPoint(ref pos); 1212 CheckAndAdjustLandingPoint(ref pos);
1213 1213
1214 if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) 1214 if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f)
1215 { 1215 {
1216 m_log.WarnFormat( 1216 m_log.WarnFormat(
1217 "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", 1217 "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping",
1218 pos, Name, UUID); 1218 pos, Name, UUID);
1219 1219
1220 if (pos.X < 0f) pos.X = 0f; 1220 if (pos.X < 0f) pos.X = 0f;
1221 if (pos.Y < 0f) pos.Y = 0f; 1221 if (pos.Y < 0f) pos.Y = 0f;
1222 if (pos.Z < 0f) pos.Z = 0f; 1222 if (pos.Z < 0f) pos.Z = 0f;
1223 } 1223 }
1224 1224
1225 float localAVHeight = 1.56f; 1225 float localAVHeight = 1.56f;
1226 if (Appearance.AvatarHeight > 0) 1226 if (Appearance.AvatarHeight > 0)
1227 localAVHeight = Appearance.AvatarHeight; 1227 localAVHeight = Appearance.AvatarHeight;
1228 1228
1229 float posZLimit = 0; 1229 float posZLimit = 0;
1230 1230
1231 if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) 1231 if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize)
1232 posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; 1232 posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y];
1233
1234 float newPosZ = posZLimit + localAVHeight / 2;
1235 if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ)))
1236 {
1237 pos.Z = newPosZ;
1238 }
1239 AbsolutePosition = pos;
1240 1233
1241 if (m_teleportFlags == TeleportFlags.Default) 1234 float newPosZ = posZLimit + localAVHeight / 2;
1242 { 1235 if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ)))
1243 Vector3 vel = Velocity; 1236 {
1244 AddToPhysicalScene(isFlying); 1237 pos.Z = newPosZ;
1245 if (PhysicsActor != null) 1238 }
1246 PhysicsActor.SetMomentum(vel); 1239 AbsolutePosition = pos;
1247 }
1248 else
1249 AddToPhysicalScene(isFlying);
1250 1240
1251 // XXX: This is to trigger any secondary teleport needed for a megaregion when the user has teleported to a 1241 if (m_teleportFlags == TeleportFlags.Default)
1252 // location outside the 'root region' (the south-west 256x256 corner). This is the earlist we can do it 1242 {
1253 // since it requires a physics actor to be present. If it is left any later, then physics appears to reset 1243 Vector3 vel = Velocity;
1254 // the value to a negative position which does not trigger the border cross. 1244 AddToPhysicalScene(isFlying);
1255 // This may not be the best location for this. 1245 if (PhysicsActor != null)
1256 CheckForBorderCrossing(); 1246 PhysicsActor.SetMomentum(vel);
1247 }
1248 else
1249 AddToPhysicalScene(isFlying);
1257 1250
1258 if (ForceFly) 1251 // XXX: This is to trigger any secondary teleport needed for a megaregion when the user has teleported to a
1259 { 1252 // location outside the 'root region' (the south-west 256x256 corner). This is the earlist we can do it
1260 Flying = true; 1253 // since it requires a physics actor to be present. If it is left any later, then physics appears to reset
1261 } 1254 // the value to a negative position which does not trigger the border cross.
1262 else if (FlyDisabled) 1255 // This may not be the best location for this.
1263 { 1256 CheckForBorderCrossing();
1264 Flying = false;
1265 }
1266 }
1267 // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying
1268 // avatar to return to the standing position in mid-air. On login it looks like this is being sent
1269 // elsewhere anyway
1270 // Animator.SendAnimPack();
1271
1272 m_scene.SwapRootAgentCount(false);
1273
1274 // The initial login scene presence is already root when it gets here
1275 // and it has already rezzed the attachments and started their scripts.
1276 // We do the following only for non-login agents, because their scripts
1277 // haven't started yet.
1278 /* moved down
1279 if (PresenceType == PresenceType.Npc || (TeleportFlags & TeleportFlags.ViaLogin) != 0)
1280 {
1281 // Viewers which have a current outfit folder will actually rez their own attachments. However,
1282 // viewers without (e.g. v1 viewers) will not, so we still need to make this call.
1283 if (Scene.AttachmentsModule != null)
1284 Util.FireAndForget(
1285 o =>
1286 {
1287 // if (PresenceType != PresenceType.Npc && Util.FireAndForgetMethod != FireAndForgetMethod.None)
1288 // System.Threading.Thread.Sleep(7000);
1289
1290 Scene.AttachmentsModule.RezAttachments(this);
1291 });
1292 }
1293 else
1294 1257
1295 { 1258 if (ForceFly)
1296 // We need to restart scripts here so that they receive the correct changed events (CHANGED_TELEPORT 1259 {
1297 // and CHANGED_REGION) when the attachments have been rezzed in the new region. This cannot currently 1260 Flying = true;
1298 // be done in AttachmentsModule.CopyAttachments(AgentData ad, IScenePresence sp) itself since we are 1261 }
1299 // not transporting the required data. 1262 else if (FlyDisabled)
1300 // 1263 {
1301 // We need to restart scripts here so that they receive the correct changed events (CHANGED_TELEPORT 1264 Flying = false;
1302 // and CHANGED_REGION) when the attachments have been rezzed in the new region. This cannot currently 1265 }
1303 // be done in AttachmentsModule.CopyAttachments(AgentData ad, IScenePresence sp) itself since we are 1266 }
1304 // not transporting the required data. 1267 // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying
1305 // 1268 // avatar to return to the standing position in mid-air. On login it looks like this is being sent
1306 // We must take a copy of the attachments list here (rather than locking) to avoid a deadlock where a script in one of 1269 // elsewhere anyway
1307 // the attachments may start processing an event (which locks ScriptInstance.m_Script) that then calls a method here 1270 // Animator.SendAnimPack();
1308 // which needs to lock m_attachments. ResumeScripts() needs to take a ScriptInstance.m_Script lock to try to unset the Suspend status.
1309 //
1310 // FIXME: In theory, this deadlock should not arise since scripts should not be processing events until ResumeScripts().
1311 // But XEngine starts all scripts unsuspended. Starting them suspended will not currently work because script rezzing
1312 // is placed in an asynchronous queue in XEngine and so the ResumeScripts() call will almost certainly execute before the
1313 // script is rezzed. This means the ResumeScripts() does absolutely nothing when using XEngine.
1314 //
1315 // One cannot simply iterate over attachments in a fire and forget thread because this would no longer
1316 // be locked, allowing race conditions if other code changes the attachments list.
1317
1318 List<SceneObjectGroup> attachments = GetAttachments();
1319
1320 if (attachments.Count > 0)
1321 {
1322 m_log.DebugFormat(
1323 "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name);
1324 1271
1325 // Resume scripts this possible should also be moved down after sending the avatar to viewer ? 1272 m_scene.SwapRootAgentCount(false);
1326 foreach (SceneObjectGroup sog in attachments) 1273
1327 { 1274 // The initial login scene presence is already root when it gets here
1328 // sending attachments before the avatar ? 1275 // and it has already rezzed the attachments and started their scripts.
1329 // moved to completemovement where it already was 1276 // We do the following only for non-login agents, because their scripts
1330 // sog.ScheduleGroupForFullUpdate(); 1277 // haven't started yet.
1331 sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); 1278/* moved down
1332 sog.ResumeScripts(); 1279 if (PresenceType == PresenceType.Npc || (TeleportFlags & TeleportFlags.ViaLogin) != 0)
1333 } 1280 {
1334 } 1281 // Viewers which have a current outfit folder will actually rez their own attachments. However,
1335 } 1282 // viewers without (e.g. v1 viewers) will not, so we still need to make this call.
1336 */ 1283 if (Scene.AttachmentsModule != null)
1284 Util.FireAndForget(
1285 o =>
1286 {
1287// if (PresenceType != PresenceType.Npc && Util.FireAndForgetMethod != FireAndForgetMethod.None)
1288// System.Threading.Thread.Sleep(7000);
1289
1290 Scene.AttachmentsModule.RezAttachments(this);
1291 });
1292 }
1293 else
1294
1295 {
1296 // We need to restart scripts here so that they receive the correct changed events (CHANGED_TELEPORT
1297 // and CHANGED_REGION) when the attachments have been rezzed in the new region. This cannot currently
1298 // be done in AttachmentsModule.CopyAttachments(AgentData ad, IScenePresence sp) itself since we are
1299 // not transporting the required data.
1300 //
1301 // We need to restart scripts here so that they receive the correct changed events (CHANGED_TELEPORT
1302 // and CHANGED_REGION) when the attachments have been rezzed in the new region. This cannot currently
1303 // be done in AttachmentsModule.CopyAttachments(AgentData ad, IScenePresence sp) itself since we are
1304 // not transporting the required data.
1305 //
1306 // We must take a copy of the attachments list here (rather than locking) to avoid a deadlock where a script in one of
1307 // the attachments may start processing an event (which locks ScriptInstance.m_Script) that then calls a method here
1308 // which needs to lock m_attachments. ResumeScripts() needs to take a ScriptInstance.m_Script lock to try to unset the Suspend status.
1309 //
1310 // FIXME: In theory, this deadlock should not arise since scripts should not be processing events until ResumeScripts().
1311 // But XEngine starts all scripts unsuspended. Starting them suspended will not currently work because script rezzing
1312 // is placed in an asynchronous queue in XEngine and so the ResumeScripts() call will almost certainly execute before the
1313 // script is rezzed. This means the ResumeScripts() does absolutely nothing when using XEngine.
1314 //
1315 // One cannot simply iterate over attachments in a fire and forget thread because this would no longer
1316 // be locked, allowing race conditions if other code changes the attachments list.
1317
1318 List<SceneObjectGroup> attachments = GetAttachments();
1319
1320 if (attachments.Count > 0)
1321 {
1322 m_log.DebugFormat(
1323 "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name);
1324
1325 // Resume scripts this possible should also be moved down after sending the avatar to viewer ?
1326 foreach (SceneObjectGroup sog in attachments)
1327 {
1328// sending attachments before the avatar ?
1329// moved to completemovement where it already was
1330// sog.ScheduleGroupForFullUpdate();
1331 sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource());
1332 sog.ResumeScripts();
1333 }
1334 }
1335 }
1336*/
1337/* 1337/*
1338 SendAvatarDataToAllAgents(); 1338 SendAvatarDataToAllAgents();
1339 1339