Normand Briere
2015-04-12 89da025f40680d9cea46f2b0a7c8c6829a0d0451
BoundaryRep.java
....@@ -3531,7 +3531,7 @@
35313531 e.printStackTrace();
35323532 }
35333533
3534
- Trim(wastrim,true,crease,wasstrip,false);
3534
+ Trim(true/*wastrim*/,true,crease,wasstrip,false);
35353535 }
35363536
35373537 void GenNormalsJME()
....@@ -5038,6 +5038,59 @@
50385038 colors = null;
50395039 }
50405040
5041
+ void CreateMesh(iHeightField hf, int x, int y)
5042
+ {
5043
+ BoundaryRep tmp = new BoundaryRep();
5044
+
5045
+ int vc = 0;
5046
+
5047
+ Vertex v = new Vertex(true);
5048
+
5049
+ for (int i=0; i<x; i++)
5050
+ {
5051
+ for (int j=0; j<y; j++)
5052
+ {
5053
+// Vertex v = tmp.GetVertex(vc++);
5054
+
5055
+ v.s = v.x = i;
5056
+ v.t = v.z = j;
5057
+ v.s /= x; v.t /= y;
5058
+ v.y = hf.f(i,j);
5059
+
5060
+ int iu = tmp.AddTableVertex(v);
5061
+
5062
+ v.s = v.x = i+1;
5063
+ v.t = v.z = j;
5064
+ v.s /= x; v.t /= y;
5065
+ v.y = hf.f(i+1,j);
5066
+
5067
+ int iv = tmp.AddTableVertex(v);
5068
+
5069
+ v.s = v.x = i+1;
5070
+ v.t = v.z = j+1;
5071
+ v.s /= x; v.t /= y;
5072
+ v.y = hf.f(i+1,j+1);
5073
+
5074
+ int iw = tmp.AddTableVertex(v);
5075
+
5076
+ v.s = v.x = i;
5077
+ v.t = v.z = j+1;
5078
+ v.s /= x; v.t /= y;
5079
+ v.y = hf.f(i,j+1);
5080
+
5081
+ int ix = tmp.AddTableVertex(v);
5082
+
5083
+ tmp.AddFace(iu,iw,iv);
5084
+ tmp.AddFace(iu,ix,iw);
5085
+ }
5086
+ }
5087
+
5088
+ Set(tmp);
5089
+
5090
+ Trim(true,false,true);
5091
+ ClearColors();
5092
+ }
5093
+
50415094 void Stripify()
50425095 {
50435096 if (stripified)
....@@ -5297,18 +5350,10 @@
52975350 double minweight = 1E10;
52985351
52995352 nbbadfaces = 0;
5300
- for (int i=faces.size(); (i-=8)>=0;)
5353
+ for (int i=0; i<faces.size(); i+=8)
5354
+// for (int i=faces.size(); (i-=8)>=0;)
53015355 {
53025356 Face face = (Face) faces.get(i);
5303
-
5304
- //?? if (face.weight < 0)
5305
- // continue;
5306
-
5307
- double K = 1; // 0.01; // .25;
5308
-
5309
- double factor = (1-K)*face.nbiterations + K; //*face.weight;
5310
-
5311
- double weight = FaceWeight(face); // *Math.pow(PerimeterMax(face),0.25)*factor;
53125357
53135358 if (!Valid(face))
53145359 {
....@@ -5327,10 +5372,21 @@
53275372 !ValidValence(face.r))
53285373 continue;
53295374
5375
+ //?? if (face.weight < 0)
5376
+ // continue;
5377
+
5378
+ double K = 1; // 0.01; // .25;
5379
+
5380
+ double factor = (1-K)*face.nbiterations + K; //*face.weight;
5381
+
5382
+ double weight = FaceWeight(face); // *Math.pow(PerimeterMax(face),0.25)*factor;
5383
+
53305384 if (minweight > weight)
53315385 {
53325386 minweight = weight;
53335387 chosen = i;
5388
+ if (minweight == 0)
5389
+ break;
53345390 }
53355391 }
53365392
....@@ -7373,7 +7429,7 @@
73737429 if (max < maxz - minz)
73747430 max = maxz - minz;
73757431
7376
- tmp.THRESHOLD = max/25; // 50;
7432
+ tmp.THRESHOLD = 0.5; // max/25; // 50;
73777433
73787434 tmp.faces.clear();
73797435
....@@ -7932,6 +7988,8 @@
79327988
79337989 minface.q = minface.r = minface.p;
79347990
7991
+ int count = 0;
7992
+
79357993 for (int i=0; i<faces.size(); i++)
79367994 {
79377995 Face face = (Face) faces.get(i);
....@@ -7943,6 +8001,9 @@
79438001 TouchVertex(face.r, true); // , minface.weight);
79448002 // assert(!lock);
79458003 faces.remove(i--);
8004
+ count++;
8005
+ if (count == 4)
8006
+ break;
79468007 }
79478008 }
79488009