diff options
author | Justin Clark-Casey (justincc) | 2010-08-28 00:40:33 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2010-08-28 00:40:33 +0100 |
commit | 1c0b4457cdcd543f04bc818a987f6e3f2311098d (patch) | |
tree | 56b6a949423b5ca0f54b2c200e037052a9ac3ff0 /OpenSim/Region/CoreModules | |
parent | minor: reduce log chattiness of "load iar" for IARs with lots of folders (diff) | |
download | opensim-SC_OLD-1c0b4457cdcd543f04bc818a987f6e3f2311098d.zip opensim-SC_OLD-1c0b4457cdcd543f04bc818a987f6e3f2311098d.tar.gz opensim-SC_OLD-1c0b4457cdcd543f04bc818a987f6e3f2311098d.tar.bz2 opensim-SC_OLD-1c0b4457cdcd543f04bc818a987f6e3f2311098d.tar.xz |
Improve liveness by operating on list copies of SOG.Children where appropriate
Diffstat (limited to 'OpenSim/Region/CoreModules')
3 files changed, 288 insertions, 286 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index e8a26b5..b5f9a8e 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | |||
@@ -349,7 +349,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
349 | public void TestLoadIarPathStartsWithSlash() | 349 | public void TestLoadIarPathStartsWithSlash() |
350 | { | 350 | { |
351 | TestHelper.InMethod(); | 351 | TestHelper.InMethod(); |
352 | log4net.Config.XmlConfigurator.Configure(); | 352 | // log4net.Config.XmlConfigurator.Configure(); |
353 | 353 | ||
354 | SerialiserModule serialiserModule = new SerialiserModule(); | 354 | SerialiserModule serialiserModule = new SerialiserModule(); |
355 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); | 355 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index 1623e6e..1fba6c2 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs | |||
@@ -243,39 +243,40 @@ 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 | List<SceneObjectPart> partList = null; | ||
246 | lock (sceneObject.Children) | 247 | lock (sceneObject.Children) |
248 | partList = new List<SceneObjectPart>(sceneObject.Children.Values); | ||
249 | |||
250 | foreach (SceneObjectPart part in partList) | ||
247 | { | 251 | { |
248 | foreach (SceneObjectPart part in sceneObject.Children.Values) | 252 | if (!ResolveUserUuid(part.CreatorID)) |
253 | part.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner; | ||
254 | |||
255 | if (!ResolveUserUuid(part.OwnerID)) | ||
256 | part.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; | ||
257 | |||
258 | if (!ResolveUserUuid(part.LastOwnerID)) | ||
259 | part.LastOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; | ||
260 | |||
261 | // And zap any troublesome sit target information | ||
262 | part.SitTargetOrientation = new Quaternion(0, 0, 0, 1); | ||
263 | part.SitTargetPosition = new Vector3(0, 0, 0); | ||
264 | |||
265 | // Fix ownership/creator of inventory items | ||
266 | // Not doing so results in inventory items | ||
267 | // being no copy/no mod for everyone | ||
268 | lock (part.TaskInventory) | ||
249 | { | 269 | { |
250 | if (!ResolveUserUuid(part.CreatorID)) | 270 | TaskInventoryDictionary inv = part.TaskInventory; |
251 | part.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner; | 271 | foreach (KeyValuePair<UUID, TaskInventoryItem> kvp in inv) |
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) | ||
267 | { | 272 | { |
268 | TaskInventoryDictionary inv = part.TaskInventory; | 273 | if (!ResolveUserUuid(kvp.Value.OwnerID)) |
269 | foreach (KeyValuePair<UUID, TaskInventoryItem> kvp in inv) | 274 | { |
275 | kvp.Value.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; | ||
276 | } | ||
277 | if (!ResolveUserUuid(kvp.Value.CreatorID)) | ||
270 | { | 278 | { |
271 | if (!ResolveUserUuid(kvp.Value.OwnerID)) | 279 | kvp.Value.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner; |
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 | } | ||
279 | } | 280 | } |
280 | } | 281 | } |
281 | } | 282 | } |
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs index 2f70c0a..57eff8a 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs | |||
@@ -228,280 +228,281 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
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 | ||
231 | // Loop over prim in group | 231 | // Loop over prim in group |
232 | List<SceneObjectPart> partList = null; | ||
232 | lock (mapdot.Children) | 233 | lock (mapdot.Children) |
234 | partList = new List<SceneObjectPart>(mapdot.Children.Values); | ||
235 | |||
236 | foreach (SceneObjectPart part in partList) | ||
233 | { | 237 | { |
234 | foreach (SceneObjectPart part in mapdot.Children.Values) | 238 | if (part == null) |
239 | continue; | ||
240 | |||
241 | // Draw if the object is at least 1 meter wide in any direction | ||
242 | if (part.Scale.X > 1f || part.Scale.Y > 1f || part.Scale.Z > 1f) | ||
235 | { | 243 | { |
236 | if (part == null) | 244 | // Try to get the RGBA of the default texture entry.. |
237 | continue; | 245 | // |
238 | 246 | try | |
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) | ||
241 | { | 247 | { |
242 | // Try to get the RGBA of the default texture entry.. | 248 | // get the null checks out of the way |
243 | // | 249 | // skip the ones that break |
244 | try | 250 | if (part == null) |
251 | continue; | ||
252 | |||
253 | if (part.Shape == null) | ||
254 | continue; | ||
255 | |||
256 | if (part.Shape.PCode == (byte)PCode.Tree || part.Shape.PCode == (byte)PCode.NewTree || part.Shape.PCode == (byte)PCode.Grass) | ||
257 | continue; // eliminates trees from this since we don't really have a good tree representation | ||
258 | // if you want tree blocks on the map comment the above line and uncomment the below line | ||
259 | //mapdotspot = Color.PaleGreen; | ||
260 | |||
261 | Primitive.TextureEntry textureEntry = part.Shape.Textures; | ||
262 | |||
263 | if (textureEntry == null || textureEntry.DefaultTexture == null) | ||
264 | continue; | ||
265 | |||
266 | Color4 texcolor = textureEntry.DefaultTexture.RGBA; | ||
267 | |||
268 | // Not sure why some of these are null, oh well. | ||
269 | |||
270 | int colorr = 255 - (int)(texcolor.R * 255f); | ||
271 | int colorg = 255 - (int)(texcolor.G * 255f); | ||
272 | int colorb = 255 - (int)(texcolor.B * 255f); | ||
273 | |||
274 | if (!(colorr == 255 && colorg == 255 && colorb == 255)) | ||
245 | { | 275 | { |
246 | // get the null checks out of the way | 276 | //Try to set the map spot color |
247 | // skip the ones that break | 277 | try |
248 | if (part == null) | 278 | { |
249 | continue; | 279 | // If the color gets goofy somehow, skip it *shakes fist at Color4 |
250 | 280 | mapdotspot = Color.FromArgb(colorr, colorg, colorb); | |
251 | if (part.Shape == null) | 281 | } |
252 | continue; | 282 | catch (ArgumentException) |
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)) | ||
273 | { | 283 | { |
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 | } | ||
283 | } | 284 | } |
284 | } | 285 | } |
285 | catch (IndexOutOfRangeException) | 286 | } |
286 | { | 287 | catch (IndexOutOfRangeException) |
287 | // Windows Array | 288 | { |
288 | } | 289 | // Windows Array |
289 | catch (ArgumentOutOfRangeException) | 290 | } |
290 | { | 291 | catch (ArgumentOutOfRangeException) |
291 | // Mono Array | 292 | { |
292 | } | 293 | // Mono Array |
293 | 294 | } | |
294 | Vector3 pos = part.GetWorldPosition(); | 295 | |
295 | 296 | Vector3 pos = part.GetWorldPosition(); | |
296 | // skip prim outside of retion | 297 | |
297 | if (pos.X < 0f || pos.X > 256f || pos.Y < 0f || pos.Y > 256f) | 298 | // skip prim outside of retion |
298 | continue; | 299 | if (pos.X < 0f || pos.X > 256f || pos.Y < 0f || pos.Y > 256f) |
299 | 300 | continue; | |
300 | // skip prim in non-finite position | 301 | |
301 | if (Single.IsNaN(pos.X) || Single.IsNaN(pos.Y) || | 302 | // skip prim in non-finite position |
302 | Single.IsInfinity(pos.X) || Single.IsInfinity(pos.Y)) | 303 | if (Single.IsNaN(pos.X) || Single.IsNaN(pos.Y) || |
304 | Single.IsInfinity(pos.X) || Single.IsInfinity(pos.Y)) | ||
305 | continue; | ||
306 | |||
307 | // Figure out if object is under 256m above the height of the terrain | ||
308 | bool isBelow256AboveTerrain = false; | ||
309 | |||
310 | try | ||
311 | { | ||
312 | isBelow256AboveTerrain = (pos.Z < ((float)hm[(int)pos.X, (int)pos.Y] + 256f)); | ||
313 | } | ||
314 | catch (Exception) | ||
315 | { | ||
316 | } | ||
317 | |||
318 | if (isBelow256AboveTerrain) | ||
319 | { | ||
320 | // Translate scale by rotation so scale is represented properly when object is rotated | ||
321 | Vector3 lscale = new Vector3(part.Shape.Scale.X, part.Shape.Scale.Y, part.Shape.Scale.Z); | ||
322 | Vector3 scale = new Vector3(); | ||
323 | Vector3 tScale = new Vector3(); | ||
324 | Vector3 axPos = new Vector3(pos.X,pos.Y,pos.Z); | ||
325 | |||
326 | Quaternion llrot = part.GetWorldRotation(); | ||
327 | Quaternion rot = new Quaternion(llrot.W, llrot.X, llrot.Y, llrot.Z); | ||
328 | scale = lscale * rot; | ||
329 | |||
330 | // negative scales don't work in this situation | ||
331 | scale.X = Math.Abs(scale.X); | ||
332 | scale.Y = Math.Abs(scale.Y); | ||
333 | scale.Z = Math.Abs(scale.Z); | ||
334 | |||
335 | // This scaling isn't very accurate and doesn't take into account the face rotation :P | ||
336 | int mapdrawstartX = (int)(pos.X - scale.X); | ||
337 | int mapdrawstartY = (int)(pos.Y - scale.Y); | ||
338 | int mapdrawendX = (int)(pos.X + scale.X); | ||
339 | int mapdrawendY = (int)(pos.Y + scale.Y); | ||
340 | |||
341 | // If object is beyond the edge of the map, don't draw it to avoid errors | ||
342 | if (mapdrawstartX < 0 || mapdrawstartX > ((int)Constants.RegionSize - 1) || mapdrawendX < 0 || mapdrawendX > ((int)Constants.RegionSize - 1) | ||
343 | || mapdrawstartY < 0 || mapdrawstartY > ((int)Constants.RegionSize - 1) || mapdrawendY < 0 | ||
344 | || mapdrawendY > ((int)Constants.RegionSize - 1)) | ||
303 | continue; | 345 | continue; |
304 | 346 | ||
305 | // Figure out if object is under 256m above the height of the terrain | 347 | #region obb face reconstruction part duex |
306 | bool isBelow256AboveTerrain = false; | 348 | Vector3[] vertexes = new Vector3[8]; |
307 | 349 | ||
308 | try | 350 | // float[] distance = new float[6]; |
309 | { | 351 | Vector3[] FaceA = new Vector3[6]; // vertex A for Facei |
310 | isBelow256AboveTerrain = (pos.Z < ((float)hm[(int)pos.X, (int)pos.Y] + 256f)); | 352 | Vector3[] FaceB = new Vector3[6]; // vertex B for Facei |
311 | } | 353 | Vector3[] FaceC = new Vector3[6]; // vertex C for Facei |
312 | catch (Exception) | 354 | Vector3[] FaceD = new Vector3[6]; // vertex D for Facei |
355 | |||
356 | tScale = new Vector3(lscale.X, -lscale.Y, lscale.Z); | ||
357 | scale = ((tScale * rot)); | ||
358 | vertexes[0] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
359 | // vertexes[0].x = pos.X + vertexes[0].x; | ||
360 | //vertexes[0].y = pos.Y + vertexes[0].y; | ||
361 | //vertexes[0].z = pos.Z + vertexes[0].z; | ||
362 | |||
363 | FaceA[0] = vertexes[0]; | ||
364 | FaceB[3] = vertexes[0]; | ||
365 | FaceA[4] = vertexes[0]; | ||
366 | |||
367 | tScale = lscale; | ||
368 | scale = ((tScale * rot)); | ||
369 | vertexes[1] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
370 | |||
371 | // vertexes[1].x = pos.X + vertexes[1].x; | ||
372 | // vertexes[1].y = pos.Y + vertexes[1].y; | ||
373 | //vertexes[1].z = pos.Z + vertexes[1].z; | ||
374 | |||
375 | FaceB[0] = vertexes[1]; | ||
376 | FaceA[1] = vertexes[1]; | ||
377 | FaceC[4] = vertexes[1]; | ||
378 | |||
379 | tScale = new Vector3(lscale.X, -lscale.Y, -lscale.Z); | ||
380 | scale = ((tScale * rot)); | ||
381 | |||
382 | vertexes[2] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
383 | |||
384 | //vertexes[2].x = pos.X + vertexes[2].x; | ||
385 | //vertexes[2].y = pos.Y + vertexes[2].y; | ||
386 | //vertexes[2].z = pos.Z + vertexes[2].z; | ||
387 | |||
388 | FaceC[0] = vertexes[2]; | ||
389 | FaceD[3] = vertexes[2]; | ||
390 | FaceC[5] = vertexes[2]; | ||
391 | |||
392 | tScale = new Vector3(lscale.X, lscale.Y, -lscale.Z); | ||
393 | scale = ((tScale * rot)); | ||
394 | vertexes[3] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
395 | |||
396 | //vertexes[3].x = pos.X + vertexes[3].x; | ||
397 | // vertexes[3].y = pos.Y + vertexes[3].y; | ||
398 | // vertexes[3].z = pos.Z + vertexes[3].z; | ||
399 | |||
400 | FaceD[0] = vertexes[3]; | ||
401 | FaceC[1] = vertexes[3]; | ||
402 | FaceA[5] = vertexes[3]; | ||
403 | |||
404 | tScale = new Vector3(-lscale.X, lscale.Y, lscale.Z); | ||
405 | scale = ((tScale * rot)); | ||
406 | vertexes[4] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
407 | |||
408 | // vertexes[4].x = pos.X + vertexes[4].x; | ||
409 | // vertexes[4].y = pos.Y + vertexes[4].y; | ||
410 | // vertexes[4].z = pos.Z + vertexes[4].z; | ||
411 | |||
412 | FaceB[1] = vertexes[4]; | ||
413 | FaceA[2] = vertexes[4]; | ||
414 | FaceD[4] = vertexes[4]; | ||
415 | |||
416 | tScale = new Vector3(-lscale.X, lscale.Y, -lscale.Z); | ||
417 | scale = ((tScale * rot)); | ||
418 | vertexes[5] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
419 | |||
420 | // vertexes[5].x = pos.X + vertexes[5].x; | ||
421 | // vertexes[5].y = pos.Y + vertexes[5].y; | ||
422 | // vertexes[5].z = pos.Z + vertexes[5].z; | ||
423 | |||
424 | FaceD[1] = vertexes[5]; | ||
425 | FaceC[2] = vertexes[5]; | ||
426 | FaceB[5] = vertexes[5]; | ||
427 | |||
428 | tScale = new Vector3(-lscale.X, -lscale.Y, lscale.Z); | ||
429 | scale = ((tScale * rot)); | ||
430 | vertexes[6] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
431 | |||
432 | // vertexes[6].x = pos.X + vertexes[6].x; | ||
433 | // vertexes[6].y = pos.Y + vertexes[6].y; | ||
434 | // vertexes[6].z = pos.Z + vertexes[6].z; | ||
435 | |||
436 | FaceB[2] = vertexes[6]; | ||
437 | FaceA[3] = vertexes[6]; | ||
438 | FaceB[4] = vertexes[6]; | ||
439 | |||
440 | tScale = new Vector3(-lscale.X, -lscale.Y, -lscale.Z); | ||
441 | scale = ((tScale * rot)); | ||
442 | vertexes[7] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
443 | |||
444 | // vertexes[7].x = pos.X + vertexes[7].x; | ||
445 | // vertexes[7].y = pos.Y + vertexes[7].y; | ||
446 | // vertexes[7].z = pos.Z + vertexes[7].z; | ||
447 | |||
448 | FaceD[2] = vertexes[7]; | ||
449 | FaceC[3] = vertexes[7]; | ||
450 | FaceD[5] = vertexes[7]; | ||
451 | #endregion | ||
452 | |||
453 | //int wy = 0; | ||
454 | |||
455 | //bool breakYN = false; // If we run into an error drawing, break out of the | ||
456 | // loop so we don't lag to death on error handling | ||
457 | DrawStruct ds = new DrawStruct(); | ||
458 | ds.brush = new SolidBrush(mapdotspot); | ||
459 | //ds.rect = new Rectangle(mapdrawstartX, (255 - mapdrawstartY), mapdrawendX - mapdrawstartX, mapdrawendY - mapdrawstartY); | ||
460 | |||
461 | ds.trns = new face[FaceA.Length]; | ||
462 | |||
463 | for (int i = 0; i < FaceA.Length; i++) | ||
313 | { | 464 | { |
465 | Point[] working = new Point[5]; | ||
466 | working[0] = project(FaceA[i], axPos); | ||
467 | working[1] = project(FaceB[i], axPos); | ||
468 | working[2] = project(FaceD[i], axPos); | ||
469 | working[3] = project(FaceC[i], axPos); | ||
470 | working[4] = project(FaceA[i], axPos); | ||
471 | |||
472 | face workingface = new face(); | ||
473 | workingface.pts = working; | ||
474 | |||
475 | ds.trns[i] = workingface; | ||
314 | } | 476 | } |
315 | 477 | ||
316 | if (isBelow256AboveTerrain) | 478 | z_sort.Add(part.LocalId, ds); |
317 | { | 479 | z_localIDs.Add(part.LocalId); |
318 | // Translate scale by rotation so scale is represented properly when object is rotated | 480 | z_sortheights.Add(pos.Z); |
319 | Vector3 lscale = new Vector3(part.Shape.Scale.X, part.Shape.Scale.Y, part.Shape.Scale.Z); | 481 | |
320 | Vector3 scale = new Vector3(); | 482 | //for (int wx = mapdrawstartX; wx < mapdrawendX; wx++) |
321 | Vector3 tScale = new Vector3(); | 483 | //{ |
322 | Vector3 axPos = new Vector3(pos.X,pos.Y,pos.Z); | 484 | //for (wy = mapdrawstartY; wy < mapdrawendY; wy++) |
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++) | ||
481 | //{ | 485 | //{ |
482 | //for (wy = mapdrawstartY; wy < mapdrawendY; wy++) | 486 | //m_log.InfoFormat("[MAPDEBUG]: {0},{1}({2})", wx, (255 - wy),wy); |
487 | //try | ||
483 | //{ | 488 | //{ |
484 | //m_log.InfoFormat("[MAPDEBUG]: {0},{1}({2})", wx, (255 - wy),wy); | 489 | // Remember, flip the y! |
485 | //try | 490 | // mapbmp.SetPixel(wx, (255 - wy), mapdotspot); |
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; | ||
497 | //} | 491 | //} |
498 | 492 | //catch (ArgumentException) | |
493 | //{ | ||
494 | // breakYN = true; | ||
495 | //} | ||
496 | |||
499 | //if (breakYN) | 497 | //if (breakYN) |
500 | // break; | 498 | // break; |
501 | //} | 499 | //} |
502 | } // Object is within 256m Z of terrain | 500 | |
503 | } // object is at least a meter wide | 501 | //if (breakYN) |
504 | } // mapdot.Children lock | 502 | // break; |
503 | //} | ||
504 | } // Object is within 256m Z of terrain | ||
505 | } // object is at least a meter wide | ||
505 | } // loop over group children | 506 | } // loop over group children |
506 | } // entitybase is sceneobject group | 507 | } // entitybase is sceneobject group |
507 | } // foreach loop over entities | 508 | } // foreach loop over entities |