aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2010-08-26 00:08:53 +0100
committerJustin Clark-Casey (justincc)2010-08-26 00:08:53 +0100
commit8031f8ec09df4f654c86a9c7bc498664f7b9d9dc (patch)
treed6a6da4d448b9bc11ff8d1078b9be089b9872151 /OpenSim/Region/CoreModules
parentminor: remove mono compiler warning (diff)
downloadopensim-SC_OLD-8031f8ec09df4f654c86a9c7bc498664f7b9d9dc.zip
opensim-SC_OLD-8031f8ec09df4f654c86a9c7bc498664f7b9d9dc.tar.gz
opensim-SC_OLD-8031f8ec09df4f654c86a9c7bc498664f7b9d9dc.tar.bz2
opensim-SC_OLD-8031f8ec09df4f654c86a9c7bc498664f7b9d9dc.tar.xz
Improve consistency of locking for SOG.m_parts in order to avoid race conditions in linking and unlinking
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs6
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs55
-rw-r--r--OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs5
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs512
5 files changed, 296 insertions, 284 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 365cdbb..847a999 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -406,7 +406,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
406 if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) 406 if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence))
407 { 407 {
408 if (!m_scene.Permissions.CanRezObject( 408 if (!m_scene.Permissions.CanRezObject(
409 part.ParentGroup.Children.Count, remoteClient.AgentId, presence.AbsolutePosition)) 409 part.ParentGroup.PrimCount, remoteClient.AgentId, presence.AbsolutePosition))
410 return; 410 return;
411 411
412 presence.Appearance.DetachAttachment(itemID); 412 presence.Appearance.DetachAttachment(itemID);
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index eef0c73..6decf54 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -526,7 +526,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
526 group.RootPart.CreateSelected = true; 526 group.RootPart.CreateSelected = true;
527 527
528 if (!m_Scene.Permissions.CanRezObject( 528 if (!m_Scene.Permissions.CanRezObject(
529 group.Children.Count, remoteClient.AgentId, pos) 529 group.PrimCount, remoteClient.AgentId, pos)
530 && !attachment) 530 && !attachment)
531 { 531 {
532 // The client operates in no fail mode. It will 532 // The client operates in no fail mode. It will
@@ -594,7 +594,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
594 rootPart.Name = item.Name; 594 rootPart.Name = item.Name;
595 rootPart.Description = item.Description; 595 rootPart.Description = item.Description;
596 596
597 List<SceneObjectPart> partList = new List<SceneObjectPart>(group.Children.Values); 597 List<SceneObjectPart> partList = null;
598 lock (group.Children)
599 partList = new List<SceneObjectPart>(group.Children.Values);
598 600
599 group.SetGroup(remoteClient.ActiveGroupId, remoteClient); 601 group.SetGroup(remoteClient.ActiveGroupId, remoteClient);
600 if ((rootPart.OwnerID != item.Owner) || (item.CurrentPermissions & 16) != 0) 602 if ((rootPart.OwnerID != item.Owner) || (item.CurrentPermissions & 16) != 0)
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
index bc653ce..1623e6e 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
@@ -243,36 +243,39 @@ namespace OpenSim.Region.CoreModules.World.Archiver
243 // to the same scene (when this is possible). 243 // to the same scene (when this is possible).
244 sceneObject.ResetIDs(); 244 sceneObject.ResetIDs();
245 245
246 foreach (SceneObjectPart part in sceneObject.Children.Values) 246 lock (sceneObject.Children)
247 { 247 {
248 if (!ResolveUserUuid(part.CreatorID)) 248 foreach (SceneObjectPart part in sceneObject.Children.Values)
249 part.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner;
250
251 if (!ResolveUserUuid(part.OwnerID))
252 part.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
253
254 if (!ResolveUserUuid(part.LastOwnerID))
255 part.LastOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
256
257 // And zap any troublesome sit target information
258 part.SitTargetOrientation = new Quaternion(0, 0, 0, 1);
259 part.SitTargetPosition = new Vector3(0, 0, 0);
260
261 // Fix ownership/creator of inventory items
262 // Not doing so results in inventory items
263 // being no copy/no mod for everyone
264 lock (part.TaskInventory)
265 { 249 {
266 TaskInventoryDictionary inv = part.TaskInventory; 250 if (!ResolveUserUuid(part.CreatorID))
267 foreach (KeyValuePair<UUID, TaskInventoryItem> kvp in inv) 251 part.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner;
252
253 if (!ResolveUserUuid(part.OwnerID))
254 part.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
255
256 if (!ResolveUserUuid(part.LastOwnerID))
257 part.LastOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
258
259 // And zap any troublesome sit target information
260 part.SitTargetOrientation = new Quaternion(0, 0, 0, 1);
261 part.SitTargetPosition = new Vector3(0, 0, 0);
262
263 // Fix ownership/creator of inventory items
264 // Not doing so results in inventory items
265 // being no copy/no mod for everyone
266 lock (part.TaskInventory)
268 { 267 {
269 if (!ResolveUserUuid(kvp.Value.OwnerID)) 268 TaskInventoryDictionary inv = part.TaskInventory;
270 { 269 foreach (KeyValuePair<UUID, TaskInventoryItem> kvp in inv)
271 kvp.Value.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
272 }
273 if (!ResolveUserUuid(kvp.Value.CreatorID))
274 { 270 {
275 kvp.Value.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner; 271 if (!ResolveUserUuid(kvp.Value.OwnerID))
272 {
273 kvp.Value.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
274 }
275 if (!ResolveUserUuid(kvp.Value.CreatorID))
276 {
277 kvp.Value.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner;
278 }
276 } 279 }
277 } 280 }
278 } 281 }
diff --git a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
index 62abd4c..8ce6daf 100644
--- a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
+++ b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
@@ -128,7 +128,10 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
128 group.SetOwnerId(remoteClient.AgentId); 128 group.SetOwnerId(remoteClient.AgentId);
129 group.SetRootPartOwner(part, remoteClient.AgentId, remoteClient.ActiveGroupId); 129 group.SetRootPartOwner(part, remoteClient.AgentId, remoteClient.ActiveGroupId);
130 130
131 List<SceneObjectPart> partList = new List<SceneObjectPart>(group.Children.Values); 131 List<SceneObjectPart> partList = null;
132
133 lock (group.Children)
134 partList = new List<SceneObjectPart>(group.Children.Values);
132 135
133 if (m_scene.Permissions.PropagatePermissions()) 136 if (m_scene.Permissions.PropagatePermissions())
134 { 137 {
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs
index b96d95a..2f70c0a 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs
@@ -227,277 +227,281 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
227 { 227 {
228 SceneObjectGroup mapdot = (SceneObjectGroup)obj; 228 SceneObjectGroup mapdot = (SceneObjectGroup)obj;
229 Color mapdotspot = Color.Gray; // Default color when prim color is white 229 Color mapdotspot = Color.Gray; // Default color when prim color is white
230
230 // Loop over prim in group 231 // Loop over prim in group
231 foreach (SceneObjectPart part in mapdot.Children.Values) 232 lock (mapdot.Children)
232 { 233 {
233 if (part == null) 234 foreach (SceneObjectPart part in mapdot.Children.Values)
234 continue;
235
236 // Draw if the object is at least 1 meter wide in any direction
237 if (part.Scale.X > 1f || part.Scale.Y > 1f || part.Scale.Z > 1f)
238 { 235 {
239 // Try to get the RGBA of the default texture entry.. 236 if (part == null)
240 // 237 continue;
241 try 238
239 // Draw if the object is at least 1 meter wide in any direction
240 if (part.Scale.X > 1f || part.Scale.Y > 1f || part.Scale.Z > 1f)
242 { 241 {
243 // get the null checks out of the way 242 // Try to get the RGBA of the default texture entry..
244 // skip the ones that break 243 //
245 if (part == null) 244 try
246 continue;
247
248 if (part.Shape == null)
249 continue;
250
251 if (part.Shape.PCode == (byte)PCode.Tree || part.Shape.PCode == (byte)PCode.NewTree || part.Shape.PCode == (byte)PCode.Grass)
252 continue; // eliminates trees from this since we don't really have a good tree representation
253 // if you want tree blocks on the map comment the above line and uncomment the below line
254 //mapdotspot = Color.PaleGreen;
255
256 Primitive.TextureEntry textureEntry = part.Shape.Textures;
257
258 if (textureEntry == null || textureEntry.DefaultTexture == null)
259 continue;
260
261 Color4 texcolor = textureEntry.DefaultTexture.RGBA;
262
263 // Not sure why some of these are null, oh well.
264
265 int colorr = 255 - (int)(texcolor.R * 255f);
266 int colorg = 255 - (int)(texcolor.G * 255f);
267 int colorb = 255 - (int)(texcolor.B * 255f);
268
269 if (!(colorr == 255 && colorg == 255 && colorb == 255))
270 { 245 {
271 //Try to set the map spot color 246 // get the null checks out of the way
272 try 247 // skip the ones that break
273 { 248 if (part == null)
274 // If the color gets goofy somehow, skip it *shakes fist at Color4 249 continue;
275 mapdotspot = Color.FromArgb(colorr, colorg, colorb); 250
276 } 251 if (part.Shape == null)
277 catch (ArgumentException) 252 continue;
253
254 if (part.Shape.PCode == (byte)PCode.Tree || part.Shape.PCode == (byte)PCode.NewTree || part.Shape.PCode == (byte)PCode.Grass)
255 continue; // eliminates trees from this since we don't really have a good tree representation
256 // if you want tree blocks on the map comment the above line and uncomment the below line
257 //mapdotspot = Color.PaleGreen;
258
259 Primitive.TextureEntry textureEntry = part.Shape.Textures;
260
261 if (textureEntry == null || textureEntry.DefaultTexture == null)
262 continue;
263
264 Color4 texcolor = textureEntry.DefaultTexture.RGBA;
265
266 // Not sure why some of these are null, oh well.
267
268 int colorr = 255 - (int)(texcolor.R * 255f);
269 int colorg = 255 - (int)(texcolor.G * 255f);
270 int colorb = 255 - (int)(texcolor.B * 255f);
271
272 if (!(colorr == 255 && colorg == 255 && colorb == 255))
278 { 273 {
274 //Try to set the map spot color
275 try
276 {
277 // If the color gets goofy somehow, skip it *shakes fist at Color4
278 mapdotspot = Color.FromArgb(colorr, colorg, colorb);
279 }
280 catch (ArgumentException)
281 {
282 }
279 } 283 }
280 } 284 }
281 } 285 catch (IndexOutOfRangeException)
282 catch (IndexOutOfRangeException) 286 {
283 { 287 // Windows Array
284 // Windows Array 288 }
285 } 289 catch (ArgumentOutOfRangeException)
286 catch (ArgumentOutOfRangeException) 290 {
287 { 291 // Mono Array
288 // Mono Array 292 }
289 } 293
290 294 Vector3 pos = part.GetWorldPosition();
291 Vector3 pos = part.GetWorldPosition(); 295
292 296 // skip prim outside of retion
293 // skip prim outside of retion 297 if (pos.X < 0f || pos.X > 256f || pos.Y < 0f || pos.Y > 256f)
294 if (pos.X < 0f || pos.X > 256f || pos.Y < 0f || pos.Y > 256f)
295 continue;
296
297 // skip prim in non-finite position
298 if (Single.IsNaN(pos.X) || Single.IsNaN(pos.Y) ||
299 Single.IsInfinity(pos.X) || Single.IsInfinity(pos.Y))
300 continue;
301
302 // Figure out if object is under 256m above the height of the terrain
303 bool isBelow256AboveTerrain = false;
304
305 try
306 {
307 isBelow256AboveTerrain = (pos.Z < ((float)hm[(int)pos.X, (int)pos.Y] + 256f));
308 }
309 catch (Exception)
310 {
311 }
312
313 if (isBelow256AboveTerrain)
314 {
315 // Translate scale by rotation so scale is represented properly when object is rotated
316 Vector3 lscale = new Vector3(part.Shape.Scale.X, part.Shape.Scale.Y, part.Shape.Scale.Z);
317 Vector3 scale = new Vector3();
318 Vector3 tScale = new Vector3();
319 Vector3 axPos = new Vector3(pos.X,pos.Y,pos.Z);
320
321 Quaternion llrot = part.GetWorldRotation();
322 Quaternion rot = new Quaternion(llrot.W, llrot.X, llrot.Y, llrot.Z);
323 scale = lscale * rot;
324
325 // negative scales don't work in this situation
326 scale.X = Math.Abs(scale.X);
327 scale.Y = Math.Abs(scale.Y);
328 scale.Z = Math.Abs(scale.Z);
329
330 // This scaling isn't very accurate and doesn't take into account the face rotation :P
331 int mapdrawstartX = (int)(pos.X - scale.X);
332 int mapdrawstartY = (int)(pos.Y - scale.Y);
333 int mapdrawendX = (int)(pos.X + scale.X);
334 int mapdrawendY = (int)(pos.Y + scale.Y);
335
336 // If object is beyond the edge of the map, don't draw it to avoid errors
337 if (mapdrawstartX < 0 || mapdrawstartX > ((int)Constants.RegionSize - 1) || mapdrawendX < 0 || mapdrawendX > ((int)Constants.RegionSize - 1)
338 || mapdrawstartY < 0 || mapdrawstartY > ((int)Constants.RegionSize - 1) || mapdrawendY < 0
339 || mapdrawendY > ((int)Constants.RegionSize - 1))
340 continue; 298 continue;
341 299
342#region obb face reconstruction part duex 300 // skip prim in non-finite position
343 Vector3[] vertexes = new Vector3[8]; 301 if (Single.IsNaN(pos.X) || Single.IsNaN(pos.Y) ||
344 302 Single.IsInfinity(pos.X) || Single.IsInfinity(pos.Y))
345 // float[] distance = new float[6]; 303 continue;
346 Vector3[] FaceA = new Vector3[6]; // vertex A for Facei 304
347 Vector3[] FaceB = new Vector3[6]; // vertex B for Facei 305 // Figure out if object is under 256m above the height of the terrain
348 Vector3[] FaceC = new Vector3[6]; // vertex C for Facei 306 bool isBelow256AboveTerrain = false;
349 Vector3[] FaceD = new Vector3[6]; // vertex D for Facei 307
350 308 try
351 tScale = new Vector3(lscale.X, -lscale.Y, lscale.Z);
352 scale = ((tScale * rot));
353 vertexes[0] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
354 // vertexes[0].x = pos.X + vertexes[0].x;
355 //vertexes[0].y = pos.Y + vertexes[0].y;
356 //vertexes[0].z = pos.Z + vertexes[0].z;
357
358 FaceA[0] = vertexes[0];
359 FaceB[3] = vertexes[0];
360 FaceA[4] = vertexes[0];
361
362 tScale = lscale;
363 scale = ((tScale * rot));
364 vertexes[1] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
365
366 // vertexes[1].x = pos.X + vertexes[1].x;
367 // vertexes[1].y = pos.Y + vertexes[1].y;
368 //vertexes[1].z = pos.Z + vertexes[1].z;
369
370 FaceB[0] = vertexes[1];
371 FaceA[1] = vertexes[1];
372 FaceC[4] = vertexes[1];
373
374 tScale = new Vector3(lscale.X, -lscale.Y, -lscale.Z);
375 scale = ((tScale * rot));
376
377 vertexes[2] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
378
379 //vertexes[2].x = pos.X + vertexes[2].x;
380 //vertexes[2].y = pos.Y + vertexes[2].y;
381 //vertexes[2].z = pos.Z + vertexes[2].z;
382
383 FaceC[0] = vertexes[2];
384 FaceD[3] = vertexes[2];
385 FaceC[5] = vertexes[2];
386
387 tScale = new Vector3(lscale.X, lscale.Y, -lscale.Z);
388 scale = ((tScale * rot));
389 vertexes[3] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
390
391 //vertexes[3].x = pos.X + vertexes[3].x;
392 // vertexes[3].y = pos.Y + vertexes[3].y;
393 // vertexes[3].z = pos.Z + vertexes[3].z;
394
395 FaceD[0] = vertexes[3];
396 FaceC[1] = vertexes[3];
397 FaceA[5] = vertexes[3];
398
399 tScale = new Vector3(-lscale.X, lscale.Y, lscale.Z);
400 scale = ((tScale * rot));
401 vertexes[4] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
402
403 // vertexes[4].x = pos.X + vertexes[4].x;
404 // vertexes[4].y = pos.Y + vertexes[4].y;
405 // vertexes[4].z = pos.Z + vertexes[4].z;
406
407 FaceB[1] = vertexes[4];
408 FaceA[2] = vertexes[4];
409 FaceD[4] = vertexes[4];
410
411 tScale = new Vector3(-lscale.X, lscale.Y, -lscale.Z);
412 scale = ((tScale * rot));
413 vertexes[5] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
414
415 // vertexes[5].x = pos.X + vertexes[5].x;
416 // vertexes[5].y = pos.Y + vertexes[5].y;
417 // vertexes[5].z = pos.Z + vertexes[5].z;
418
419 FaceD[1] = vertexes[5];
420 FaceC[2] = vertexes[5];
421 FaceB[5] = vertexes[5];
422
423 tScale = new Vector3(-lscale.X, -lscale.Y, lscale.Z);
424 scale = ((tScale * rot));
425 vertexes[6] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
426
427 // vertexes[6].x = pos.X + vertexes[6].x;
428 // vertexes[6].y = pos.Y + vertexes[6].y;
429 // vertexes[6].z = pos.Z + vertexes[6].z;
430
431 FaceB[2] = vertexes[6];
432 FaceA[3] = vertexes[6];
433 FaceB[4] = vertexes[6];
434
435 tScale = new Vector3(-lscale.X, -lscale.Y, -lscale.Z);
436 scale = ((tScale * rot));
437 vertexes[7] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
438
439 // vertexes[7].x = pos.X + vertexes[7].x;
440 // vertexes[7].y = pos.Y + vertexes[7].y;
441 // vertexes[7].z = pos.Z + vertexes[7].z;
442
443 FaceD[2] = vertexes[7];
444 FaceC[3] = vertexes[7];
445 FaceD[5] = vertexes[7];
446#endregion
447
448 //int wy = 0;
449
450 //bool breakYN = false; // If we run into an error drawing, break out of the
451 // loop so we don't lag to death on error handling
452 DrawStruct ds = new DrawStruct();
453 ds.brush = new SolidBrush(mapdotspot);
454 //ds.rect = new Rectangle(mapdrawstartX, (255 - mapdrawstartY), mapdrawendX - mapdrawstartX, mapdrawendY - mapdrawstartY);
455
456 ds.trns = new face[FaceA.Length];
457
458 for (int i = 0; i < FaceA.Length; i++)
459 { 309 {
460 Point[] working = new Point[5]; 310 isBelow256AboveTerrain = (pos.Z < ((float)hm[(int)pos.X, (int)pos.Y] + 256f));
461 working[0] = project(FaceA[i], axPos);
462 working[1] = project(FaceB[i], axPos);
463 working[2] = project(FaceD[i], axPos);
464 working[3] = project(FaceC[i], axPos);
465 working[4] = project(FaceA[i], axPos);
466
467 face workingface = new face();
468 workingface.pts = working;
469
470 ds.trns[i] = workingface;
471 } 311 }
472 312 catch (Exception)
473 z_sort.Add(part.LocalId, ds); 313 {
474 z_localIDs.Add(part.LocalId); 314 }
475 z_sortheights.Add(pos.Z); 315
476 316 if (isBelow256AboveTerrain)
477 //for (int wx = mapdrawstartX; wx < mapdrawendX; wx++) 317 {
478 //{ 318 // Translate scale by rotation so scale is represented properly when object is rotated
479 //for (wy = mapdrawstartY; wy < mapdrawendY; wy++) 319 Vector3 lscale = new Vector3(part.Shape.Scale.X, part.Shape.Scale.Y, part.Shape.Scale.Z);
320 Vector3 scale = new Vector3();
321 Vector3 tScale = new Vector3();
322 Vector3 axPos = new Vector3(pos.X,pos.Y,pos.Z);
323
324 Quaternion llrot = part.GetWorldRotation();
325 Quaternion rot = new Quaternion(llrot.W, llrot.X, llrot.Y, llrot.Z);
326 scale = lscale * rot;
327
328 // negative scales don't work in this situation
329 scale.X = Math.Abs(scale.X);
330 scale.Y = Math.Abs(scale.Y);
331 scale.Z = Math.Abs(scale.Z);
332
333 // This scaling isn't very accurate and doesn't take into account the face rotation :P
334 int mapdrawstartX = (int)(pos.X - scale.X);
335 int mapdrawstartY = (int)(pos.Y - scale.Y);
336 int mapdrawendX = (int)(pos.X + scale.X);
337 int mapdrawendY = (int)(pos.Y + scale.Y);
338
339 // If object is beyond the edge of the map, don't draw it to avoid errors
340 if (mapdrawstartX < 0 || mapdrawstartX > ((int)Constants.RegionSize - 1) || mapdrawendX < 0 || mapdrawendX > ((int)Constants.RegionSize - 1)
341 || mapdrawstartY < 0 || mapdrawstartY > ((int)Constants.RegionSize - 1) || mapdrawendY < 0
342 || mapdrawendY > ((int)Constants.RegionSize - 1))
343 continue;
344
345 #region obb face reconstruction part duex
346 Vector3[] vertexes = new Vector3[8];
347
348 // float[] distance = new float[6];
349 Vector3[] FaceA = new Vector3[6]; // vertex A for Facei
350 Vector3[] FaceB = new Vector3[6]; // vertex B for Facei
351 Vector3[] FaceC = new Vector3[6]; // vertex C for Facei
352 Vector3[] FaceD = new Vector3[6]; // vertex D for Facei
353
354 tScale = new Vector3(lscale.X, -lscale.Y, lscale.Z);
355 scale = ((tScale * rot));
356 vertexes[0] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
357 // vertexes[0].x = pos.X + vertexes[0].x;
358 //vertexes[0].y = pos.Y + vertexes[0].y;
359 //vertexes[0].z = pos.Z + vertexes[0].z;
360
361 FaceA[0] = vertexes[0];
362 FaceB[3] = vertexes[0];
363 FaceA[4] = vertexes[0];
364
365 tScale = lscale;
366 scale = ((tScale * rot));
367 vertexes[1] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
368
369 // vertexes[1].x = pos.X + vertexes[1].x;
370 // vertexes[1].y = pos.Y + vertexes[1].y;
371 //vertexes[1].z = pos.Z + vertexes[1].z;
372
373 FaceB[0] = vertexes[1];
374 FaceA[1] = vertexes[1];
375 FaceC[4] = vertexes[1];
376
377 tScale = new Vector3(lscale.X, -lscale.Y, -lscale.Z);
378 scale = ((tScale * rot));
379
380 vertexes[2] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
381
382 //vertexes[2].x = pos.X + vertexes[2].x;
383 //vertexes[2].y = pos.Y + vertexes[2].y;
384 //vertexes[2].z = pos.Z + vertexes[2].z;
385
386 FaceC[0] = vertexes[2];
387 FaceD[3] = vertexes[2];
388 FaceC[5] = vertexes[2];
389
390 tScale = new Vector3(lscale.X, lscale.Y, -lscale.Z);
391 scale = ((tScale * rot));
392 vertexes[3] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
393
394 //vertexes[3].x = pos.X + vertexes[3].x;
395 // vertexes[3].y = pos.Y + vertexes[3].y;
396 // vertexes[3].z = pos.Z + vertexes[3].z;
397
398 FaceD[0] = vertexes[3];
399 FaceC[1] = vertexes[3];
400 FaceA[5] = vertexes[3];
401
402 tScale = new Vector3(-lscale.X, lscale.Y, lscale.Z);
403 scale = ((tScale * rot));
404 vertexes[4] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
405
406 // vertexes[4].x = pos.X + vertexes[4].x;
407 // vertexes[4].y = pos.Y + vertexes[4].y;
408 // vertexes[4].z = pos.Z + vertexes[4].z;
409
410 FaceB[1] = vertexes[4];
411 FaceA[2] = vertexes[4];
412 FaceD[4] = vertexes[4];
413
414 tScale = new Vector3(-lscale.X, lscale.Y, -lscale.Z);
415 scale = ((tScale * rot));
416 vertexes[5] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
417
418 // vertexes[5].x = pos.X + vertexes[5].x;
419 // vertexes[5].y = pos.Y + vertexes[5].y;
420 // vertexes[5].z = pos.Z + vertexes[5].z;
421
422 FaceD[1] = vertexes[5];
423 FaceC[2] = vertexes[5];
424 FaceB[5] = vertexes[5];
425
426 tScale = new Vector3(-lscale.X, -lscale.Y, lscale.Z);
427 scale = ((tScale * rot));
428 vertexes[6] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
429
430 // vertexes[6].x = pos.X + vertexes[6].x;
431 // vertexes[6].y = pos.Y + vertexes[6].y;
432 // vertexes[6].z = pos.Z + vertexes[6].z;
433
434 FaceB[2] = vertexes[6];
435 FaceA[3] = vertexes[6];
436 FaceB[4] = vertexes[6];
437
438 tScale = new Vector3(-lscale.X, -lscale.Y, -lscale.Z);
439 scale = ((tScale * rot));
440 vertexes[7] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
441
442 // vertexes[7].x = pos.X + vertexes[7].x;
443 // vertexes[7].y = pos.Y + vertexes[7].y;
444 // vertexes[7].z = pos.Z + vertexes[7].z;
445
446 FaceD[2] = vertexes[7];
447 FaceC[3] = vertexes[7];
448 FaceD[5] = vertexes[7];
449 #endregion
450
451 //int wy = 0;
452
453 //bool breakYN = false; // If we run into an error drawing, break out of the
454 // loop so we don't lag to death on error handling
455 DrawStruct ds = new DrawStruct();
456 ds.brush = new SolidBrush(mapdotspot);
457 //ds.rect = new Rectangle(mapdrawstartX, (255 - mapdrawstartY), mapdrawendX - mapdrawstartX, mapdrawendY - mapdrawstartY);
458
459 ds.trns = new face[FaceA.Length];
460
461 for (int i = 0; i < FaceA.Length; i++)
462 {
463 Point[] working = new Point[5];
464 working[0] = project(FaceA[i], axPos);
465 working[1] = project(FaceB[i], axPos);
466 working[2] = project(FaceD[i], axPos);
467 working[3] = project(FaceC[i], axPos);
468 working[4] = project(FaceA[i], axPos);
469
470 face workingface = new face();
471 workingface.pts = working;
472
473 ds.trns[i] = workingface;
474 }
475
476 z_sort.Add(part.LocalId, ds);
477 z_localIDs.Add(part.LocalId);
478 z_sortheights.Add(pos.Z);
479
480 //for (int wx = mapdrawstartX; wx < mapdrawendX; wx++)
480 //{ 481 //{
481 //m_log.InfoFormat("[MAPDEBUG]: {0},{1}({2})", wx, (255 - wy),wy); 482 //for (wy = mapdrawstartY; wy < mapdrawendY; wy++)
482 //try
483 //{ 483 //{
484 // Remember, flip the y! 484 //m_log.InfoFormat("[MAPDEBUG]: {0},{1}({2})", wx, (255 - wy),wy);
485 // mapbmp.SetPixel(wx, (255 - wy), mapdotspot); 485 //try
486 //{
487 // Remember, flip the y!
488 // mapbmp.SetPixel(wx, (255 - wy), mapdotspot);
489 //}
490 //catch (ArgumentException)
491 //{
492 // breakYN = true;
493 //}
494
495 //if (breakYN)
496 // break;
486 //} 497 //}
487 //catch (ArgumentException) 498
488 //{
489 // breakYN = true;
490 //}
491
492 //if (breakYN) 499 //if (breakYN)
493 // break; 500 // break;
494 //} 501 //}
495 502 } // Object is within 256m Z of terrain
496 //if (breakYN) 503 } // object is at least a meter wide
497 // break; 504 } // mapdot.Children lock
498 //}
499 } // Object is within 256m Z of terrain
500 } // object is at least a meter wide
501 } // loop over group children 505 } // loop over group children
502 } // entitybase is sceneobject group 506 } // entitybase is sceneobject group
503 } // foreach loop over entities 507 } // foreach loop over entities