aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/PhysicsModules/ubOdeMeshing
diff options
context:
space:
mode:
authorUbitUmarov2016-09-17 12:44:52 +0100
committerUbitUmarov2016-09-17 12:44:52 +0100
commite5383604cb68710b1f9960d6a0aeb0812d2db3ea (patch)
tree844cb56f494c58c123cd167280673dae58f89f16 /OpenSim/Region/PhysicsModules/ubOdeMeshing
parent forgot the dll (diff)
parentchange spinobject math, and a few minor things (diff)
downloadopensim-SC-e5383604cb68710b1f9960d6a0aeb0812d2db3ea.zip
opensim-SC-e5383604cb68710b1f9960d6a0aeb0812d2db3ea.tar.gz
opensim-SC-e5383604cb68710b1f9960d6a0aeb0812d2db3ea.tar.bz2
opensim-SC-e5383604cb68710b1f9960d6a0aeb0812d2db3ea.tar.xz
Merge branch 'master' into httptests
Diffstat (limited to 'OpenSim/Region/PhysicsModules/ubOdeMeshing')
-rw-r--r--OpenSim/Region/PhysicsModules/ubOdeMeshing/Mesh.cs47
-rw-r--r--OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs49
2 files changed, 50 insertions, 46 deletions
diff --git a/OpenSim/Region/PhysicsModules/ubOdeMeshing/Mesh.cs b/OpenSim/Region/PhysicsModules/ubOdeMeshing/Mesh.cs
index 5b1510f..d9ea4a4 100644
--- a/OpenSim/Region/PhysicsModules/ubOdeMeshing/Mesh.cs
+++ b/OpenSim/Region/PhysicsModules/ubOdeMeshing/Mesh.cs
@@ -588,38 +588,37 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
588 Mesh mesh = new Mesh(); 588 Mesh mesh = new Mesh();
589 mesh.releaseBuildingMeshData(); 589 mesh.releaseBuildingMeshData();
590 590
591 BinaryReader br = new BinaryReader(st);
592
593 bool ok = true; 591 bool ok = true;
594 try 592 using(BinaryReader br = new BinaryReader(st))
595 { 593 {
596 mesh.m_vertexCount = br.ReadInt32(); 594 try
597 mesh.m_indexCount = br.ReadInt32(); 595 {
596 mesh.m_vertexCount = br.ReadInt32();
597 mesh.m_indexCount = br.ReadInt32();
598 598
599 int n = 3 * mesh.m_vertexCount; 599 int n = 3 * mesh.m_vertexCount;
600 mesh.vertices = new float[n]; 600 mesh.vertices = new float[n];
601 for (int i = 0; i < n; i++) 601 for (int i = 0; i < n; i++)
602 mesh.vertices[i] = br.ReadSingle(); 602 mesh.vertices[i] = br.ReadSingle();
603 603
604 mesh.indexes = new int[mesh.m_indexCount]; 604 mesh.indexes = new int[mesh.m_indexCount];
605 for (int i = 0; i < mesh.m_indexCount; i++) 605 for (int i = 0; i < mesh.m_indexCount; i++)
606 mesh.indexes[i] = br.ReadInt32(); 606 mesh.indexes[i] = br.ReadInt32();
607 607
608 mesh.m_obb.X = br.ReadSingle(); 608 mesh.m_obb.X = br.ReadSingle();
609 mesh.m_obb.Y = br.ReadSingle(); 609 mesh.m_obb.Y = br.ReadSingle();
610 mesh.m_obb.Z = br.ReadSingle(); 610 mesh.m_obb.Z = br.ReadSingle();
611 611
612 mesh.m_obboffset.X = br.ReadSingle(); 612 mesh.m_obboffset.X = br.ReadSingle();
613 mesh.m_obboffset.Y = br.ReadSingle(); 613 mesh.m_obboffset.Y = br.ReadSingle();
614 mesh.m_obboffset.Z = br.ReadSingle(); 614 mesh.m_obboffset.Z = br.ReadSingle();
615 } 615 }
616 catch 616 catch
617 { 617 {
618 ok = false; 618 ok = false;
619 }
619 } 620 }
620 621
621 br.Close();
622
623 if (ok) 622 if (ok)
624 { 623 {
625 mesh.pinMemory(); 624 mesh.pinMemory();
diff --git a/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs b/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs
index d9544db..ff10e7f 100644
--- a/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs
+++ b/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs
@@ -60,7 +60,7 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
60 60
61 private bool m_Enabled = false; 61 private bool m_Enabled = false;
62 62
63 public object diskLock = new object(); 63 public static object diskLock = new object();
64 64
65 public bool doMeshFileCache = true; 65 public bool doMeshFileCache = true;
66 66
@@ -1426,13 +1426,13 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
1426 { 1426 {
1427 if (File.Exists(filename)) 1427 if (File.Exists(filename))
1428 { 1428 {
1429 FileStream stream = null;
1430 try 1429 try
1431 { 1430 {
1432 stream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read); 1431 using(FileStream stream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read))
1433 BinaryFormatter bformatter = new BinaryFormatter(); 1432 {
1434 1433// BinaryFormatter bformatter = new BinaryFormatter();
1435 mesh = Mesh.FromStream(stream, key); 1434 mesh = Mesh.FromStream(stream,key);
1435 }
1436 1436
1437 } 1437 }
1438 catch (Exception e) 1438 catch (Exception e)
@@ -1443,13 +1443,17 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
1443 filename, e.Message, e.StackTrace); 1443 filename, e.Message, e.StackTrace);
1444 } 1444 }
1445 1445
1446 if (stream != null) 1446 try
1447 stream.Close(); 1447 {
1448 if (mesh == null || !ok)
1449 File.Delete(filename);
1450 else
1451 File.SetLastAccessTimeUtc(filename, DateTime.UtcNow);
1452 }
1453 catch
1454 {
1455 }
1448 1456
1449 if (mesh == null || !ok)
1450 File.Delete(filename);
1451 else
1452 File.SetLastAccessTimeUtc(filename, DateTime.UtcNow);
1453 } 1457 }
1454 } 1458 }
1455 1459
@@ -1458,7 +1462,6 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
1458 1462
1459 private void StoreToFileCache(AMeshKey key, Mesh mesh) 1463 private void StoreToFileCache(AMeshKey key, Mesh mesh)
1460 { 1464 {
1461 Stream stream = null;
1462 bool ok = false; 1465 bool ok = false;
1463 1466
1464 // Make sure the target cache directory exists 1467 // Make sure the target cache directory exists
@@ -1476,8 +1479,8 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
1476 Directory.CreateDirectory(dir); 1479 Directory.CreateDirectory(dir);
1477 } 1480 }
1478 1481
1479 stream = File.Open(filename, FileMode.Create); 1482 using(Stream stream = File.Open(filename, FileMode.Create))
1480 ok = mesh.ToStream(stream); 1483 ok = mesh.ToStream(stream);
1481 } 1484 }
1482 catch (IOException e) 1485 catch (IOException e)
1483 { 1486 {
@@ -1487,15 +1490,17 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
1487 ok = false; 1490 ok = false;
1488 } 1491 }
1489 1492
1490 if (stream != null) 1493 if (!ok && File.Exists(filename))
1491 stream.Close();
1492
1493 if (File.Exists(filename))
1494 { 1494 {
1495 if (ok) 1495 try
1496 File.SetLastAccessTimeUtc(filename, DateTime.UtcNow); 1496 {
1497 else
1498 File.Delete(filename); 1497 File.Delete(filename);
1498 }
1499 catch (IOException e)
1500 {
1501 m_log.ErrorFormat(
1502 "[MESH CACHE]: Failed to delete file {0}",filename);
1503 }
1499 } 1504 }
1500 } 1505 }
1501 } 1506 }