aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/PhysicsModules
diff options
context:
space:
mode:
authorUbitUmarov2017-07-23 14:23:44 +0100
committerUbitUmarov2017-07-23 14:23:44 +0100
commit8b2e95d1c1e1beb83c03bae435ae34ac479de292 (patch)
treece0cba3125e69cf88fe2df83541fd4999fba104a /OpenSim/Region/PhysicsModules
parentmantis 8212 do use defined sqlite connection (diff)
downloadopensim-SC_OLD-8b2e95d1c1e1beb83c03bae435ae34ac479de292.zip
opensim-SC_OLD-8b2e95d1c1e1beb83c03bae435ae34ac479de292.tar.gz
opensim-SC_OLD-8b2e95d1c1e1beb83c03bae435ae34ac479de292.tar.bz2
opensim-SC_OLD-8b2e95d1c1e1beb83c03bae435ae34ac479de292.tar.xz
add a rudimentary version control to ubOde meshs cache
Diffstat (limited to 'OpenSim/Region/PhysicsModules')
-rw-r--r--OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs180
1 files changed, 90 insertions, 90 deletions
diff --git a/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs b/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs
index 010262f..1233d48 100644
--- a/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs
+++ b/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs
@@ -36,7 +36,7 @@ using OpenSim.Region.PhysicsModules.ConvexDecompositionDotNet;
36using OpenMetaverse; 36using OpenMetaverse;
37using OpenMetaverse.StructuredData; 37using OpenMetaverse.StructuredData;
38using System.Drawing; 38using System.Drawing;
39using System.Drawing.Imaging; 39using System.Threading;
40using System.IO.Compression; 40using System.IO.Compression;
41using PrimMesher; 41using PrimMesher;
42using log4net; 42using log4net;
@@ -56,15 +56,15 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
56 // Setting baseDir to a path will enable the dumping of raw files 56 // Setting baseDir to a path will enable the dumping of raw files
57 // raw files can be imported by blender so a visual inspection of the results can be done 57 // raw files can be imported by blender so a visual inspection of the results can be done
58 58
59 private static string cacheControlFilename = "cntr";
59 private bool m_Enabled = false; 60 private bool m_Enabled = false;
60 61
61 public static object diskLock = new object(); 62 public static object diskLock = new object();
62 63
63 public bool doMeshFileCache = true; 64 public bool doMeshFileCache = true;
64 65 public bool doCacheExpire = true;
65 public string cachePath = "MeshCache"; 66 public string cachePath = "MeshCache";
66 public TimeSpan CacheExpire; 67 public TimeSpan CacheExpire;
67 public bool doCacheExpire = true;
68 68
69// const string baseDir = "rawFiles"; 69// const string baseDir = "rawFiles";
70 private const string baseDir = null; //"rawFiles"; 70 private const string baseDir = null; //"rawFiles";
@@ -101,10 +101,8 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
101 if (mesh_config != null) 101 if (mesh_config != null)
102 { 102 {
103 useMeshiesPhysicsMesh = mesh_config.GetBoolean("UseMeshiesPhysicsMesh", useMeshiesPhysicsMesh); 103 useMeshiesPhysicsMesh = mesh_config.GetBoolean("UseMeshiesPhysicsMesh", useMeshiesPhysicsMesh);
104
105 doConvexPrims = mesh_config.GetBoolean("ConvexPrims",doConvexPrims); 104 doConvexPrims = mesh_config.GetBoolean("ConvexPrims",doConvexPrims);
106 doConvexSculpts = mesh_config.GetBoolean("ConvexSculpts",doConvexPrims); 105 doConvexSculpts = mesh_config.GetBoolean("ConvexSculpts",doConvexPrims);
107
108 doMeshFileCache = mesh_config.GetBoolean("MeshFileCache", doMeshFileCache); 106 doMeshFileCache = mesh_config.GetBoolean("MeshFileCache", doMeshFileCache);
109 cachePath = mesh_config.GetString("MeshFileCachePath", cachePath); 107 cachePath = mesh_config.GetString("MeshFileCachePath", cachePath);
110 fcache = mesh_config.GetFloat("MeshFileCacheExpireHours", fcache); 108 fcache = mesh_config.GetFloat("MeshFileCacheExpireHours", fcache);
@@ -115,22 +113,19 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
115 113
116 CacheExpire = TimeSpan.FromHours(fcache); 114 CacheExpire = TimeSpan.FromHours(fcache);
117 115
118 lock (diskLock) 116 if(String.IsNullOrEmpty(cachePath))
117 doMeshFileCache = false;
118
119 if(doMeshFileCache)
119 { 120 {
120 if(doMeshFileCache && cachePath != "") 121 if(!checkCache())
121 { 122 {
122 try 123 doMeshFileCache = false;
123 { 124 doCacheExpire = false;
124 if (!Directory.Exists(cachePath))
125 Directory.CreateDirectory(cachePath);
126 }
127 catch
128 {
129 doMeshFileCache = false;
130 doCacheExpire = false;
131 }
132 } 125 }
133 } 126 }
127 else
128 doCacheExpire = false;
134 } 129 }
135 } 130 }
136 131
@@ -283,7 +278,7 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
283 { 278 {
284 List<Coord> convexcoords; 279 List<Coord> convexcoords;
285 List<Face> convexfaces; 280 List<Face> convexfaces;
286 if(CreateHull(coords, out convexcoords, out convexfaces) && convexcoords != null && convexfaces != null) 281 if(CreateBoundingHull(coords, out convexcoords, out convexfaces) && convexcoords != null && convexfaces != null)
287 { 282 {
288 coords.Clear(); 283 coords.Clear();
289 coords = convexcoords; 284 coords = convexcoords;
@@ -565,45 +560,7 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
565 vs.Clear(); 560 vs.Clear();
566 continue; 561 continue;
567 } 562 }
568 /*
569 if (!HullUtils.ComputeHull(vs, ref hullr, 0, 0.0f))
570 {
571 vs.Clear();
572 continue;
573 }
574
575 nverts = hullr.Vertices.Count;
576 nindexs = hullr.Indices.Count;
577
578 if (nindexs % 3 != 0)
579 {
580 vs.Clear();
581 continue;
582 }
583 563
584 for (i = 0; i < nverts; i++)
585 {
586 c.X = hullr.Vertices[i].x;
587 c.Y = hullr.Vertices[i].y;
588 c.Z = hullr.Vertices[i].z;
589 coords.Add(c);
590 }
591
592 for (i = 0; i < nindexs; i += 3)
593 {
594 t1 = hullr.Indices[i];
595 if (t1 > nverts)
596 break;
597 t2 = hullr.Indices[i + 1];
598 if (t2 > nverts)
599 break;
600 t3 = hullr.Indices[i + 2];
601 if (t3 > nverts)
602 break;
603 f = new Face(vertsoffset + t1, vertsoffset + t2, vertsoffset + t3);
604 faces.Add(f);
605 }
606 */
607 List<int> indices; 564 List<int> indices;
608 if (!HullUtils.ComputeHull(vs, out indices)) 565 if (!HullUtils.ComputeHull(vs, out indices))
609 { 566 {
@@ -709,38 +666,7 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
709 vs.Clear(); 666 vs.Clear();
710 return true; 667 return true;
711 } 668 }
712/*
713 if (!HullUtils.ComputeHull(vs, ref hullr, 0, 0.0f))
714 return false;
715
716 nverts = hullr.Vertices.Count;
717 nindexs = hullr.Indices.Count;
718 669
719 if (nindexs % 3 != 0)
720 return false;
721
722 for (i = 0; i < nverts; i++)
723 {
724 c.X = hullr.Vertices[i].x;
725 c.Y = hullr.Vertices[i].y;
726 c.Z = hullr.Vertices[i].z;
727 coords.Add(c);
728 }
729 for (i = 0; i < nindexs; i += 3)
730 {
731 t1 = hullr.Indices[i];
732 if (t1 > nverts)
733 break;
734 t2 = hullr.Indices[i + 1];
735 if (t2 > nverts)
736 break;
737 t3 = hullr.Indices[i + 2];
738 if (t3 > nverts)
739 break;
740 f = new Face(t1, t2, t3);
741 faces.Add(f);
742 }
743*/
744 List<int> indices; 670 List<int> indices;
745 if (!HullUtils.ComputeHull(vs, out indices)) 671 if (!HullUtils.ComputeHull(vs, out indices))
746 return false; 672 return false;
@@ -1353,7 +1279,7 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
1353 } 1279 }
1354 } 1280 }
1355 1281
1356 public void FileNames(AMeshKey key, out string dir,out string fullFileName) 1282 public void FileNames(AMeshKey key, out string dir, out string fullFileName)
1357 { 1283 {
1358 string id = key.ToString(); 1284 string id = key.ToString();
1359 string init = id.Substring(0, 1); 1285 string init = id.Substring(0, 1);
@@ -1470,7 +1396,7 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
1470 if (!doCacheExpire) 1396 if (!doCacheExpire)
1471 return; 1397 return;
1472 1398
1473 string controlfile = System.IO.Path.Combine(cachePath, "cntr"); 1399 string controlfile = System.IO.Path.Combine(cachePath, cacheControlFilename);
1474 1400
1475 lock (diskLock) 1401 lock (diskLock)
1476 { 1402 {
@@ -1524,7 +1450,81 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
1524 } 1450 }
1525 } 1451 }
1526 1452
1527 public bool CreateHull(List<Coord> inputVertices, out List<Coord> convexcoords, out List<Face> newfaces) 1453 public bool checkCache()
1454 {
1455 string controlfile = System.IO.Path.Combine(cachePath, cacheControlFilename);
1456 lock (diskLock)
1457 {
1458 try
1459 {
1460 if (!Directory.Exists(cachePath))
1461 {
1462 Directory.CreateDirectory(cachePath);
1463 Thread.Sleep(100);
1464 FileStream fs = File.Create(controlfile, 4096, FileOptions.WriteThrough);
1465 fs.Close();
1466 return true;
1467 }
1468 }
1469 catch
1470 {
1471 doMeshFileCache = false;
1472 doCacheExpire = false;
1473 return false;
1474 }
1475 finally {}
1476
1477 if (File.Exists(controlfile))
1478 return true;
1479
1480 try
1481 {
1482 Directory.Delete(cachePath, true);
1483 while(Directory.Exists(cachePath))
1484 Thread.Sleep(100);
1485 }
1486 catch(Exception e)
1487 {
1488 m_log.Error("[MESH CACHE]: failed to delete old version of the cache: " + e.Message);
1489 doMeshFileCache = false;
1490 doCacheExpire = false;
1491 return false;
1492 }
1493 finally {}
1494 try
1495 {
1496 Directory.CreateDirectory(cachePath);
1497 while(!Directory.Exists(cachePath))
1498 Thread.Sleep(100);
1499 }
1500 catch(Exception e)
1501 {
1502 m_log.Error("[MESH CACHE]: failed to create new cache folder: " + e.Message);
1503 doMeshFileCache = false;
1504 doCacheExpire = false;
1505 return false;
1506 }
1507 finally {}
1508
1509 try
1510 {
1511 FileStream fs = File.Create(controlfile, 4096, FileOptions.WriteThrough);
1512 fs.Close();
1513 }
1514 catch(Exception e)
1515 {
1516 m_log.Error("[MESH CACHE]: failed to create new control file: " + e.Message);
1517 doMeshFileCache = false;
1518 doCacheExpire = false;
1519 return false;
1520 }
1521 finally {}
1522
1523 return true;
1524 }
1525 }
1526
1527 public bool CreateBoundingHull(List<Coord> inputVertices, out List<Coord> convexcoords, out List<Face> newfaces)
1528 { 1528 {
1529 convexcoords = null; 1529 convexcoords = null;
1530 newfaces = null; 1530 newfaces = null;