Normand Briere
2019-06-11 d0dc7ff35d71919d503ae35592478b173cf3cfd3
BoundaryRep.java
....@@ -15,7 +15,7 @@
1515 {
1616 this(0, 0);
1717 }
18
-
18
+
1919 void SaveSupports()
2020 {
2121 transientsupport = support;
....@@ -161,6 +161,7 @@
161161 || FaceCount() != other.FaceCount()
162162 || !(indices == null ^ other.indices != null)) // july 2014
163163 {
164
+ // The meshes have different structures.
164165 //new Exception().printStackTrace();
165166 trimmed = other.trimmed;
166167 stripified = other.stripified;
....@@ -172,16 +173,16 @@
172173 bufV = other.bufV;
173174 bufF = other.bufF;
174175
175
- positions = (float[]) GrafreeD.clone(other.positions);
176
- normals = (float[]) GrafreeD.clone(other.normals);
177
- colors = (float[]) GrafreeD.clone(other.colors);
178
- uvmap = (float[]) GrafreeD.clone(other.uvmap);
179
- triangles = (int[]) GrafreeD.clone(other.triangles);
176
+ positions = (float[]) Grafreed.clone(other.positions);
177
+ normals = (float[]) Grafreed.clone(other.normals);
178
+ colors = (float[]) Grafreed.clone(other.colors);
179
+ uvmap = (float[]) Grafreed.clone(other.uvmap);
180
+ triangles = (int[]) Grafreed.clone(other.triangles);
180181
181
- indices = (int[]) GrafreeD.clone(other.indices);
182
+ indices = (int[]) Grafreed.clone(other.indices);
182183
183
- vertices = (Vector<Vertex>) GrafreeD.clone(other.vertices);
184
- faces = (Vector<Face>) GrafreeD.clone(other.faces);
184
+ vertices = (Vector<Vertex>) Grafreed.clone(other.vertices);
185
+ faces = (Vector<Face>) Grafreed.clone(other.faces);
185186 }
186187 else
187188 {
....@@ -239,9 +240,16 @@
239240 }
240241 }
241242
242
- Support[] InitConnections(BoundaryRep other)
243
+ transient Support[] cachesupports = null;
244
+
245
+ Support[] InitConnections()
243246 {
244
- int n = other.startvertices.length-1;
247
+ if (cachesupports != null)
248
+ {
249
+ return cachesupports;
250
+ }
251
+
252
+ int n = this.startvertices.length-1;
245253
246254 Support[] supports = new Support[n];
247255
....@@ -253,38 +261,60 @@
253261
254262 for (int object=1; object<=n; object++)
255263 {
256
- int start = other.startvertices[object-1];
257
- int end = other.startvertices[object];
264
+ int start = this.startvertices[object-1];
265
+ int end = this.startvertices[object];
258266
259267 if (start == end)
260268 continue; // ??
261269
270
+ /**
271
+ Vertex v2 = vertextemp;
272
+ v2.x = averagepoints[object*3];
273
+ v2.y = averagepoints[object*3+1];
274
+ v2.z = averagepoints[object*3+2];
275
+
276
+ //v2.set(GetVertex(this.startvertices[subsupport]));
277
+
278
+ // projected point
279
+ Vertex v3 = vertextemp2;
280
+ //GetVertex(this.startvertices[subsupport]);
281
+ v3.x = extremepoints[object*3];
282
+ v3.y = extremepoints[object*3+1];
283
+ v3.z = extremepoints[object*3+2];
284
+
285
+ vect3.set(v3); // "X" axis apex
286
+ vect3.sub(v2); // origin (center)
287
+ vect3.normalize();
288
+ /**/
289
+
262290 int linkcount = 0;
263291
264292 int objectinlist = -1;
293
+
294
+ Support subsupport = supports[object-1];
265295
266296 for (int object2=1; object2<=n; object2++)
267297 {
268298 for (int i = start; i < end; i++)
269299 {
270
- Vertex v = other.GetVertex(i);
300
+ Vertex v = this.GetVertex(i);
271301
272
- //
273
- if (other.Contains(v, object2))
302
+ // Check if v is close enough from any vertex of the given subobject.
303
+ if (this.Contains(v, object2))
274304 {
275
- if (linkcount == supports[object-1].links.length)
305
+ if (linkcount == subsupport.links.length)
276306 break;
277307
278308 if (object2 == object)
279309 objectinlist = linkcount;
280310
281
- supports[object-1].links[linkcount++] = object2;
311
+ subsupport.links[linkcount++] = object2;
282312 break;
283313 }
284314 }
285315 }
286316
287
- supports[object-1].links[linkcount] = -1;
317
+ subsupport.links[linkcount] = -1;
288318
289319 if (objectinlist == -1)
290320 assert(objectinlist != -1);
....@@ -293,9 +323,9 @@
293323 // assert(linkcount > 1);
294324
295325 // show main support as blue
296
- int first = supports[object-1].links[0];
297
- supports[object-1].links[0] = supports[object-1].links[objectinlist];
298
- supports[object-1].links[objectinlist] = first;
326
+ int first = subsupport.links[0];
327
+ subsupport.links[0] = subsupport.links[objectinlist];
328
+ subsupport.links[objectinlist] = first;
299329 }
300330
301331 for (int loop = 0; --loop>=0;)
....@@ -353,7 +383,7 @@
353383 supports = supports2;
354384 }
355385
356
- return supports;
386
+ return cachesupports = supports;
357387 }
358388
359389 double Distance2(Vertex v, Vertex v2, double dist2beat, double[][] toRoot, int k)
....@@ -497,10 +527,10 @@
497527 return dist2;
498528 }
499529
500
- static Vertex vertextemp = new Vertex();
501
- static Vertex vertextemp2 = new Vertex();
530
+ static Vertex vertextemp = new Vertex(true);
531
+ static Vertex vertextemp2 = new Vertex(true);
502532
503
- static double SEUIL = 0.1; // 0.1 for rag doll; 0.07;
533
+ static double SEUIL = 0.05f; // 0.1 for rag doll; 0.07;
504534
505535 // Compute weight of point w/r to this
506536 float ComputeWeight(Vertex v, double[][] toRoot, int k)
....@@ -570,8 +600,10 @@
570600
571601 if (dot > distmax)
572602 dot = distmax;
603
+ //return 0; // patch for strange behavior
573604 if (dot < -distmax)
574605 dot = -distmax;
606
+ //return 0; // patch for strange behavior
575607
576608 // v3 = GetVertex(this.startvertices[subsupport] + 16);
577609 //
....@@ -596,7 +628,7 @@
596628 // ;
597629 //
598630
599
- supportsize = supportsizes[subsupport];
631
+ supportsize = supportminsize[subsupport];
600632
601633 double K = supportsize / distmax;
602634
....@@ -609,10 +641,12 @@
609641
610642 float dist2 = (float)Distance2(v, v2, 1E10, toRoot, k);
611643
612
- if (dist2 >= 2 * SEUIL*SEUIL) // && !CameraPane.CROWD) // weightmode
644
+ double seuil = SEUIL * 2;
645
+
646
+ if (dist2 >= 2 * seuil*seuil) // && !CameraPane.CROWD) // weightmode
613647 return 0;
614648
615
- dist2 /= 2 * SEUIL*SEUIL; // multiplied by two because center of support
649
+ dist2 /= 2 * seuil*seuil; // multiplied by two because center of support
616650 // could be far from closest point
617651
618652 // dist2 = Math.pow(dist2, 2);
....@@ -646,7 +680,8 @@
646680 // if (supportsize * fadefactor > 1)
647681 // return 1;
648682
649
- return supportsize * fadefactor;
683
+ return //supportsize *
684
+ supportsize * fadefactor;
650685 }
651686
652687 void RecomputeBasis(BoundaryRep other, double[][] toRoot, Vertex v)
....@@ -786,7 +821,7 @@
786821 v.weights[k] = other.ComputeWeight(v, toRoot, k); // (float)(supportsize * normalweight * nz / Math.pow(tx*tx+ty*ty+tz*tz, 1));
787822 v.totalweight += v.weights[k];
788823
789
- if (CameraPane.CROWD)
824
+ if (Globals.CROWD)
790825 {
791826 // System.out.print("weight = " + v.weights[k]);
792827 // System.out.println("; totalweight = " + v.totalweight);
....@@ -946,9 +981,9 @@
946981
947982 int nbsupports;
948983
949
- SEUIL = 0.1; // aout 2013
984
+ // sept 2017 SEUIL = 0.1; // aout 2013
950985
951
- supports = InitConnections(other);
986
+ supports = other.InitConnections();
952987
953988 other.supports = supports; // should be the other way around...
954989
....@@ -982,7 +1017,7 @@
9821017
9831018 int subsupports = 0;
9841019
985
- SEUIL = 0.1; // aout 2013
1020
+ // sept 2017 SEUIL = 0.1; // aout 2013
9861021
9871022 while (subsupports == 0)
9881023 {
....@@ -1006,6 +1041,26 @@
10061041
10071042 vect.set(v);
10081043 vect.sub(vect2);
1044
+
1045
+// vertextemp.x = other.averagepoints[c*3];
1046
+// vertextemp.y = other.averagepoints[c*3+1];
1047
+// vertextemp.z = other.averagepoints[c*3+2];
1048
+//
1049
+// Vertex v3 = vertextemp2;
1050
+// v3.x = other.extremepoints[c*3];
1051
+// v3.y = other.extremepoints[c*3+1];
1052
+// v3.z = other.extremepoints[c*3+2];
1053
+//
1054
+// vect3.set(v3); // "X" axis apex
1055
+// vect3.sub(vertextemp); // origin (center)
1056
+//
1057
+// double distmax = vect3.length();
1058
+//
1059
+// vect3.set(v2); // "X" axis apex
1060
+// vect3.sub(vertextemp); // origin (center)
1061
+//
1062
+// if (vect3.length() >= distmax)
1063
+// continue;
10091064
10101065 if (mindistance > vect.dot(vect))
10111066 {
....@@ -1017,7 +1072,9 @@
10171072
10181073 subsupports = v.closestsupport==-1 ? 0 : supports[v.closestsupport].Length();
10191074
1020
- SEUIL *= 2;
1075
+ // previously for "contains", now for weights.
1076
+ assert(subsupports > 0);
1077
+ //SEUIL *= 2;
10211078 }
10221079
10231080 assert(subsupports > 0);
....@@ -1492,7 +1549,7 @@
14921549 InitFaceIndices();
14931550 }
14941551
1495
- BoundaryRep rep = (BoundaryRep) GrafreeD.clone(this);
1552
+ BoundaryRep rep = (BoundaryRep) Grafreed.clone(this);
14961553 //float[] v = new float[100];
14971554
14981555 for (int loops=1; --loops>=0;)
....@@ -1522,7 +1579,7 @@
15221579 InitFaceIndices();
15231580 }
15241581
1525
- BoundaryRep rep = (BoundaryRep) GrafreeD.clone(this);
1582
+ BoundaryRep rep = (BoundaryRep) Grafreed.clone(this);
15261583 //float[] v = new float[100];
15271584
15281585 for (int loops=10; --loops>=0;)
....@@ -1869,7 +1926,7 @@
18691926 return;
18701927 }
18711928
1872
- // System.exit(0);
1929
+ // System.exit(0);
18731930
18741931 cVector vect = new cVector();
18751932 cVector normal = new cVector();
....@@ -1940,7 +1997,7 @@
19401997 if (v.vertexlinks == null)
19411998 continue;
19421999
1943
- if (v.weights != null && v.weights[j] == 0) // < 0.01 * v.totalweight) // == 0)
2000
+ if (v.weights != null && v.weights[j] < 0.001 * v.totalweight) // == 0)
19442001 {
19452002 //testweight += v.weights[j-1];
19462003 continue;
....@@ -2163,7 +2220,7 @@
21632220 // if (slow)
21642221 // aout 2013
21652222 // sept 2013 merde...
2166
- W = 13;
2223
+ W = 3; // 13;
21672224
21682225 // POSERATE
21692226 if (CameraPane.tickcount > 0 || CameraPane.SLOWPOSE)
....@@ -2221,6 +2278,8 @@
22212278
22222279 transient int lastsoundtime;
22232280
2281
+ transient boolean once = false;
2282
+
22242283 void setMasterThis0(BoundaryRep other, double[][] toRoot, boolean smooth, boolean marked)
22252284 {
22262285 if (LA.isIdentity(toRoot))
....@@ -2276,7 +2335,11 @@
22762335
22772336 if (v.totalweight == 0)
22782337 {
2279
- System.err.println("v.totalweight == 0! --> " + this + " : " + other);
2338
+ if (!once)
2339
+ {
2340
+ System.err.println("v.totalweight == 0! --> " + this + " : " + other);
2341
+ once = true;
2342
+ }
22802343 continue;
22812344 }
22822345
....@@ -2635,18 +2698,18 @@
26352698 if (false) // slow && stepout && onein)
26362699 {
26372700 // sound
2638
- cVector eye = CameraPane.theRenderer.eyeCamera.location;
2701
+ cVector eye = Globals.theRenderer.EyeCamera().location;
26392702
26402703 Vertex v = GetVertex(0);
26412704
26422705 tmp.set(v);
26432706 tmp.sub(eye);
26442707
2645
- if (CameraPane.framecount - lastsoundtime > 30) // 0.25 secs
2708
+ if (Globals.framecount - lastsoundtime > 30) // 0.25 secs
26462709 {
2647
- GrafreeD.wav.play((Math.random()+0.5)/Math.max(tmp.length2(),0.2)); //, 1);
2710
+ Grafreed.wav.play((Math.random()+0.5)/Math.max(tmp.length2(),0.2)); //, 1);
26482711
2649
- lastsoundtime = CameraPane.framecount;
2712
+ lastsoundtime = Globals.framecount;
26502713 }
26512714
26522715 stepout = false;
....@@ -3072,6 +3135,7 @@
30723135 //
30733136 // transient VertexCompare[] vertexcompare = null;
30743137
3138
+ // Check if v0 is close enough from any vertex of the given subobject of this.
30753139 boolean Contains(Vertex v0, int object)
30763140 {
30773141 int start = startvertices[object-1];
....@@ -3129,7 +3193,27 @@
31293193 */
31303194 }
31313195
3132
- void GenUV()
3196
+ void UnfoldUV()
3197
+ {
3198
+ for (int i = 0; i < VertexCount(); i++)
3199
+ {
3200
+ Vertex v = GetVertex(i);
3201
+
3202
+ v.x = v.s;
3203
+ v.y = v.t;
3204
+ v.z = 0;
3205
+
3206
+ v.norm.x = 0;
3207
+ v.norm.y = 0;
3208
+ v.norm.z = 1;
3209
+
3210
+ SetVertex(v, i);
3211
+ }
3212
+ }
3213
+
3214
+ float power = 2;
3215
+
3216
+ void GenUV() // float power)
31333217 {
31343218 Trim();
31353219
....@@ -3193,6 +3277,125 @@
31933277 y -= 0.5;
31943278 z -= 0.5;
31953279
3280
+ double ax = Math.abs(x);
3281
+ double ay = Math.abs(y);
3282
+ double max = ax;
3283
+ if (max < ay)
3284
+ {
3285
+ max = ay;
3286
+ }
3287
+
3288
+ if (max == 0)
3289
+ {
3290
+ uvmap[i2] = 0.5f;
3291
+ uvmap[i2+1] = 0.5f;
3292
+ continue;
3293
+ }
3294
+
3295
+ x /= max;
3296
+ y /= max;
3297
+
3298
+ double angle = Math.acos(Math.abs(z*2));
3299
+
3300
+ double k = angle / Math.PI * 2;
3301
+
3302
+ assert(k >= 0);
3303
+
3304
+ // k == 0 => uv = 0 (center)
3305
+ // k == 1 => uv = -1,1 (border)
3306
+
3307
+ if (i == 0)
3308
+ System.out.println("power = " + power);
3309
+
3310
+ double length1 = (ax+ay)/max;
3311
+ double length2 = Math.sqrt(ax*ax + ay*ay) / max;
3312
+
3313
+ double t = k;
3314
+
3315
+ t = Math.pow(t, 3);
3316
+
3317
+ // Interpolate between k/length2 (center) and k (border)
3318
+ if (length2 > 0)
3319
+ k *= (1 - t) / length2 + t;
3320
+
3321
+ double u = k*x;
3322
+ double v = k*y;
3323
+
3324
+ u /= 2;
3325
+ v /= 2;
3326
+ u += 0.5;
3327
+ v += 0.5;
3328
+
3329
+ uvmap[i2] = (float) u;
3330
+ uvmap[i2+1] = (float) v;
3331
+ }
3332
+ }
3333
+
3334
+ void GenUVold(float power)
3335
+ {
3336
+ Trim();
3337
+
3338
+ cVector boxcenter = null;
3339
+ cVector minima, maxima;
3340
+ minima = new cVector();
3341
+ maxima = new cVector();
3342
+ minima.x = minima.y = minima.z = Double.MAX_VALUE;
3343
+ maxima.x = maxima.y = maxima.z = -Double.MAX_VALUE;
3344
+ for (int i = 0; i < VertexCount(); i++)
3345
+ {
3346
+ Vertex v = GetVertex(i);
3347
+
3348
+ if (minima.x > v.x)
3349
+ {
3350
+ minima.x = v.x;
3351
+ }
3352
+ if (minima.y > v.y)
3353
+ {
3354
+ minima.y = v.y;
3355
+ }
3356
+ if (minima.z > v.z)
3357
+ {
3358
+ minima.z = v.z;
3359
+ }
3360
+
3361
+ if (maxima.x < v.x)
3362
+ {
3363
+ maxima.x = v.x;
3364
+ }
3365
+ if (maxima.y < v.y)
3366
+ {
3367
+ maxima.y = v.y;
3368
+ }
3369
+ if (maxima.z < v.z)
3370
+ {
3371
+ maxima.z = v.z;
3372
+ }
3373
+ }
3374
+
3375
+ boxcenter = new cVector((maxima.x + minima.x) / 2, (maxima.y + minima.y) / 2, (maxima.z + minima.z) / 2);
3376
+ int i2 = 0, i3 = 0;
3377
+ for (int i = 0; i < positions.length/3; i++, i3 += 3, i2 += 2)
3378
+ {
3379
+// //uvmap[i2] = (float) normals[i3]*0.5f + 0.5f; // v.x;
3380
+// //uvmap[i2 + 1] = (float) normals[i3+1]*0.5f + 0.5f; //z;
3381
+// uvmap[i2] = (float) (positions[i3] - boxcenter.x);
3382
+// uvmap[i2 + 1] = (float) (positions[i3+2] - boxcenter.z);
3383
+// uvmap[i2] = (float) Math.atan2(positions[i3+1] - boxcenter.y, positions[i3] - boxcenter.x);
3384
+// uvmap[i2 + 1] = (float)(positions[i3+2] - boxcenter.z);
3385
+ // box UV
3386
+ double x = positions[i3] - minima.x; // - Math.floor(positions[i3]);
3387
+ double y = positions[i3+1] - minima.y; // - Math.floor(positions[i3+1]);
3388
+ double z = positions[i3+2] - minima.z; // - Math.floor(positions[i3+2]);
3389
+
3390
+ // [-1/2, 1/2]
3391
+ x /= maxima.x - minima.x;
3392
+ y /= maxima.y - minima.y;
3393
+ z /= maxima.z - minima.z;
3394
+
3395
+ x -= 0.5;
3396
+ y -= 0.5;
3397
+ z -= 0.5;
3398
+
31963399 // x *= 2;
31973400 // y *= 2;
31983401 // z *= 2;
....@@ -3219,6 +3422,15 @@
32193422
32203423 z = Math.cos(angle/2);
32213424
3425
+ assert(z >= 0);
3426
+ assert(z <= 1);
3427
+
3428
+ /**/
3429
+ //z = Math.pow(z, power); //1.08f);
3430
+
3431
+ if (i == 0)
3432
+ System.out.println("power = " + power);
3433
+
32223434 // sqrt(k2*x2 + k2*z2 + y2) = length
32233435 // k2*x2 + k2*z2 = length2 - y2
32243436 // k2 = (length2 - y2) / (x2 + z2)
....@@ -3229,7 +3441,7 @@
32293441 k /= x*x + y*y;
32303442 }
32313443 else
3232
- GrafreeD.Assert(z == 1);
3444
+ Grafreed.Assert(z == 1);
32333445
32343446 if (k < 0)
32353447 k = 0;
....@@ -3238,6 +3450,7 @@
32383450
32393451 x *= k;
32403452 y *= k;
3453
+ /**/
32413454
32423455 double max = Math.abs(x);
32433456 if (max < Math.abs(y))
....@@ -3250,10 +3463,15 @@
32503463 }
32513464
32523465 // max = Math.sqrt(max*2)/2;
3466
+// double x2 = Math.pow(Math.abs(x), 1/power);
3467
+// double y2 = Math.pow(Math.abs(y), 1/power);
3468
+// double z2 = Math.pow(Math.abs(z), 1/power);
3469
+// max = Math.pow(x2 + y2 + z2, power);
32533470
32543471 // if (!(max > 0))
3255
- assert(max > 0);
3256
-
3472
+ //assert(max > 0);
3473
+ assert(max >= 0);
3474
+
32573475 x /= max;
32583476 y /= max;
32593477 z /= max;
....@@ -3516,6 +3734,111 @@
35163734 */
35173735 }
35183736
3737
+ void GenerateNormals2(boolean crease)
3738
+ {
3739
+ cVector tempVector = new cVector();
3740
+
3741
+// java.util.HashMap<cVector, cVector> tableBase = new java.util.HashMap<cVector, cVector>();
3742
+//
3743
+//
3744
+// for (int i=0; i<this.VertexCount(); i++)
3745
+// {
3746
+// Vertex v = this.GetVertex(i);
3747
+//
3748
+// tempVector.set(v);
3749
+//
3750
+// cVector n = tableBase.get(tempVector.ToFloat());
3751
+//
3752
+// if (n != null)
3753
+// {
3754
+// continue;
3755
+// }
3756
+//
3757
+// tableBase.put(new cVector(tempVector), new cVector(v.norm));
3758
+// }
3759
+
3760
+ BoundaryRep tempSupport = this.support;
3761
+
3762
+ this.support = null;
3763
+
3764
+ BoundaryRep tempRep = (BoundaryRep)Grafreed.clone(this);
3765
+
3766
+ this.support = tempSupport;
3767
+
3768
+ //tempRep.Unstripify();
3769
+
3770
+ tempRep.GenerateNormals2(crease);
3771
+
3772
+ boolean keepnormal = Vertex.normalmode;
3773
+ boolean epsequal = Grafreed.epsequal;
3774
+
3775
+ Vertex.normalmode = false;
3776
+ Grafreed.epsequal = false; // A bit strange
3777
+
3778
+ // No need to have a match for vertex counts.
3779
+
3780
+ java.util.HashMap<cVector, cVector> table = new java.util.HashMap<cVector, cVector>();
3781
+
3782
+ for (int i=0; i<tempRep.VertexCount(); i++)
3783
+ {
3784
+ Vertex v = tempRep.GetVertex(i);
3785
+
3786
+ cVector n = table.get(tempVector.ToFloat());
3787
+
3788
+ if (v.norm.x == 1 && v.norm.y == 0 && v.norm.z == 0)
3789
+ {
3790
+ //continue;
3791
+ }
3792
+
3793
+ tempVector.set(v);
3794
+
3795
+ //cVector nBase = tableBase.get(tempVector);
3796
+
3797
+ //if (v.norm.dot(nBase) < 0.9)
3798
+ //{
3799
+ // continue;
3800
+ //}
3801
+
3802
+ if (n != null && n.x == 1 && n.y == 0 && n.z == 0)
3803
+ {
3804
+ //continue;
3805
+ }
3806
+
3807
+ if (n != null)
3808
+ {
3809
+// if (n.dot(v.norm) < 0)
3810
+// n.sub(v.norm);
3811
+// else
3812
+// n.add(v.norm);
3813
+//
3814
+// n.normalize();
3815
+ continue;
3816
+ }
3817
+
3818
+ table.put(new cVector(tempVector), new cVector(v.norm));
3819
+ }
3820
+
3821
+ for (int i=0; i<this.VertexCount(); i++)
3822
+ {
3823
+ Vertex v = this.GetVertex(i);
3824
+
3825
+ tempVector.set(v);
3826
+
3827
+ cVector n = table.get(tempVector.ToFloat());
3828
+
3829
+ //if (n.dot(v.norm) < 0)
3830
+ if (n == null)
3831
+ continue;
3832
+
3833
+ LA.vecCopy(n, v.norm);
3834
+
3835
+ this.SetVertex(v, i);
3836
+ }
3837
+
3838
+ Grafreed.epsequal = epsequal;
3839
+ Vertex.normalmode = keepnormal;
3840
+ }
3841
+
35193842 void GenerateNormals(boolean crease)
35203843 {
35213844 boolean wastrim = trimmed;
....@@ -3689,6 +4012,9 @@
36894012 {
36904013 triangles[i] = i;
36914014 }
4015
+
4016
+ Untrim();
4017
+ MergeNormals();
36924018 }
36934019 }
36944020
....@@ -3722,6 +4048,11 @@
37224048 tsa.getNormals(0, normals);
37234049 tsa.getTextureCoordinates(0, 0, uvmap);
37244050 // tsa.getColors(0, colors);
4051
+
4052
+ for (int i=colors.length; --i>=0;)
4053
+ {
4054
+ colors[i] = 1;
4055
+ }
37254056
37264057 int stripcount = tsa.getNumStrips();
37274058 triangles = new int[stripcount];
....@@ -3744,6 +4075,9 @@
37444075 triangles = new int[1];
37454076 triangles[0] = 3;
37464077 }
4078
+
4079
+ Untrim();
4080
+ MergeNormals();
37474081 }
37484082
37494083 /*
....@@ -3776,21 +4110,64 @@
37764110 for (int i = 0; i < VertexCount(); i++)
37774111 {
37784112 Vertex v = GetVertex(i);
4113
+
4114
+ vertextemp.set(v);
4115
+
37794116 //if (v.norm.x == 0 && v.norm.y == 0 && v.norm.z == 0)
37804117 {
3781
- GenerateNormal(i, v);
3782
- SetVertex(v, i);
4118
+ if (!GenerateNormal(i, vertextemp))
4119
+ continue;
4120
+
4121
+ if (v.norm.dot(vertextemp.norm) < 0)
4122
+ vertextemp.norm.mul(-1);
4123
+
4124
+ if (v.norm.dot(vertextemp.norm) < 0.9)
4125
+ SetVertex(vertextemp, i);
37834126 }
37844127 }
37854128
37864129 Vertex.normalmode = false;
37874130 }
37884131
4132
+ void MergeNormals()
4133
+ {
4134
+ boolean smooth = Grafreed.smoothmode;
4135
+ boolean link = Grafreed.linkUV;
4136
+ Grafreed.smoothmode = true;
4137
+ Grafreed.linkUV = true;
4138
+
4139
+ System.out.println("#Vertex = " + VertexCount());
4140
+ System.out.println("#Face = " + FaceCount());
4141
+
4142
+ java.util.HashSet<Vertex> table = new java.util.HashSet<Vertex>();
4143
+
4144
+ for (int i = 0; i < VertexCount(); i++)
4145
+ {
4146
+ Vertex v = GetVertex(i);
4147
+
4148
+ if (!table.contains(v))
4149
+ {
4150
+ table.add(v);
4151
+ }
4152
+ }
4153
+
4154
+ Grafreed.smoothmode = smooth;
4155
+ Grafreed.linkUV = link;
4156
+
4157
+// for (int i = 0; i < VertexCount(); i++)
4158
+// {
4159
+// Vertex v = GetVertex(i);
4160
+//
4161
+// table.add(v);
4162
+// }
4163
+
4164
+ }
4165
+
37894166 static cVector temp1 = new cVector();
37904167 static cVector temp2 = new cVector();
37914168 static cVector temp3 = new cVector();
37924169
3793
- void GenerateNormal(int index, Vertex v)
4170
+ boolean GenerateNormal(int index, Vertex v)
37944171 {
37954172 //System.out.println("Old normal = " + v.norm);
37964173 LA.setVector(v.norm, 0, 0, 0);
....@@ -3819,6 +4196,10 @@
38194196 LA.vecSub(p/*.pos*/, v/*.pos*/, temp1);
38204197 LA.vecSub(q/*.pos*/, v/*.pos*/, temp2);
38214198 }
4199
+ else
4200
+ {
4201
+ continue;
4202
+ }
38224203
38234204 //LA.vecNormalize(temp1);
38244205 //LA.vecNormalize(temp2);
....@@ -3829,17 +4210,25 @@
38294210 double s = temp3.length();
38304211 //double c = temp2.dot(temp1);
38314212
4213
+ if (s == 0)
4214
+ return false;
4215
+
38324216 float angle = 1; // (float) Math.atan2(s, c);
38334217 //if(angle < 0) angle = -angle;
38344218
38354219 //LA.vecNormalize(temp3);
38364220 LA.vecScale(temp3, angle / s);
38374221
4222
+// if (temp3.dot(v.norm) < 0)
4223
+// assert(temp3.dot(v.norm) >= 0);
4224
+
38384225 LA.vecAdd(temp3, v.norm, v.norm);
38394226 }
38404227
38414228 LA.vecNormalize(v.norm);
38424229 //System.out.println("New normal = " + v.norm);
4230
+
4231
+ return true;
38434232 }
38444233
38454234 double Arccos(double x)
....@@ -4233,7 +4622,7 @@
42334622 int count = VertexCount();
42344623
42354624 // mars 2014
4236
- while (step >= count)
4625
+ while (step > count)
42374626 step /= 10;
42384627
42394628 for (int i = 0; i < count; i+=step)
....@@ -4381,7 +4770,7 @@
43814770 }
43824771 }
43834772
4384
- void CullVertex(javax.media.opengl.GL gl, boolean shadow)
4773
+ void CullVertex(javax.media.opengl.GL glNOTUSED, boolean shadowNOTUSED)
43854774 {
43864775 CameraPane.glu.gluProject(vect5.x,vect5.y,vect5.z,
43874776 CameraPane.tempmat,0, CameraPane.tempmat2,0,
....@@ -4413,14 +4802,14 @@
44134802 // june 2014
44144803 // Camera parentcam = cam;
44154804 //
4416
-// if (cam == CameraPane.theRenderer.cameras[0])
4805
+// if (cam == Globals.theRenderer.cameras[0])
44174806 // {
4418
-// parentcam = CameraPane.theRenderer.cameras[1];
4807
+// parentcam = Globals.theRenderer.cameras[1];
44194808 // }
44204809 //
4421
-// if (cam == CameraPane.theRenderer.cameras[1])
4810
+// if (cam == Globals.theRenderer.cameras[1])
44224811 // {
4423
-// parentcam = CameraPane.theRenderer.cameras[0];
4812
+// parentcam = Globals.theRenderer.cameras[0];
44244813 // }
44254814
44264815 gl.glGetDoublev(gl.GL_MODELVIEW_MATRIX, CameraPane.tempmat, 0);
....@@ -4546,7 +4935,7 @@
45464935 {
45474936 i3 = positions.length-3;
45484937 i2 = uvmap.length - 2;
4549
- new Exception().printStackTrace();
4938
+ //new Exception().printStackTrace();
45504939 }
45514940
45524941 v./*pos.*/x = positions[i3];
....@@ -4846,7 +5235,7 @@
48465235 return verticesCopy;
48475236 }
48485237
4849
- void PreprocessOcclusion(CameraPane cp, double[][] transform)
5238
+ void PreprocessOcclusion(iCameraPane cp, double[][] transform)
48505239 {
48515240 if (//!trimmed ||
48525241 AOdone)
....@@ -4855,80 +5244,7 @@
48555244 return;
48565245 }
48575246
4858
- Camera keep = cp.renderCamera;
4859
- cp.renderCamera = localcamera;
4860
-
4861
- if (trimmed)
4862
- {
4863
- float[] colors = new float[positions.length / 3];
4864
-
4865
- int i3 = 0;
4866
- for (int i = 0; i < positions.length / 3; i++, i3 += 3)
4867
- {
4868
- if (normals[i3] == 0 && normals[i3+1] == 0 && normals[i3+2] == 0)
4869
- continue;
4870
-
4871
- from.set(positions[i3], positions[i3 + 1], positions[i3 + 2]);
4872
- to.set(positions[i3] + normals[i3],
4873
- positions[i3 + 1] + normals[i3 + 1],
4874
- positions[i3 + 2] + normals[i3 + 2]);
4875
- LA.xformPos(from, transform, from);
4876
- LA.xformPos(to, transform, to); // RIGID ONLY
4877
- localcamera.setAim(from, to);
4878
-
4879
- CameraPane.occlusionbuffer.display();
4880
-
4881
- if (CameraPane.DEBUG_OCCLUSION)
4882
- cp.display(); // debug
4883
-
4884
- colors[i] = cp.vertexOcclusion.r;
4885
- //colors[i3 + 1] = cp.vertexOcclusion.g;
4886
- //colors[i3 + 2] = cp.vertexOcclusion.b;
4887
-
4888
- if ((i % 1000) == 0 && i != 0)
4889
- {
4890
- CameraPane.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
4891
- //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done");
4892
- System.out.println((int) (100.0 * i / (positions.length / 3)) + "% (" + i + " of " + (positions.length / 3) + ")");
4893
- }
4894
- }
4895
-
4896
- this.colors = colors;
4897
- }
4898
- else
4899
- {
4900
- for (int i = 0; i < VertexCount(); i++)
4901
- {
4902
- Vertex v = GetVertex(i);
4903
-
4904
- if (v.norm.x == 0 && v.norm.y == 0 && v.norm.z == 0)
4905
- continue;
4906
-
4907
- from.set(v.x, v.y, v.z);
4908
- to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z);
4909
- LA.xformPos(from, transform, from);
4910
- LA.xformPos(to, transform, to); // RIGID ONLY
4911
- localcamera.setAim(from, to);
4912
-
4913
- CameraPane.occlusionbuffer.display();
4914
-
4915
- if (CameraPane.DEBUG_OCCLUSION)
4916
- cp.display(); // debug
4917
-
4918
- v.AO = cp.vertexOcclusion.r;
4919
-
4920
- if ((i % 1000) == 0 && i != 0)
4921
- {
4922
- CameraPane.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
4923
- //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done");
4924
- System.out.println((int) (100.0 * i / VertexCount()) + "% (" + i + " of " + VertexCount() + ")");
4925
- }
4926
- }
4927
- }
4928
-
4929
- System.out.println("done.");
4930
-
4931
- cp.renderCamera = keep;
5247
+ cp.PrepOcclusion(this, transform);
49325248
49335249 AOdone = true;
49345250 }
....@@ -5343,17 +5659,27 @@
53435659
53445660 transient int nbbadfaces; // ?? = 1000000;
53455661
5346
- int ChooseTriangle()
5662
+ /*
5663
+ */
5664
+ int ChooseTriangle(boolean firstEquilateral)
53475665 {
53485666 int chosen = -1;
53495667
53505668 double minweight = 1E10;
53515669
5670
+ int step = 8; // ?
5671
+
5672
+ if (firstEquilateral)
5673
+ step = 1;
5674
+
53525675 nbbadfaces = 0;
5353
- for (int i=0; i<faces.size(); i+=8)
5676
+ for (int i=0; i<faces.size(); i+=step)
53545677 // for (int i=faces.size(); (i-=8)>=0;)
53555678 {
53565679 Face face = (Face) faces.get(i);
5680
+
5681
+ if (face.used)
5682
+ continue;
53575683
53585684 if (!Valid(face))
53595685 {
....@@ -5363,6 +5689,15 @@
53635689
53645690 if (Boundary(face))
53655691 continue;
5692
+
5693
+// if (Boundary(face.p))
5694
+// continue;
5695
+//
5696
+// if (Boundary(face.q))
5697
+// continue;
5698
+//
5699
+// if (Boundary(face.r))
5700
+// continue;
53665701
53675702 if (!ValidValence(face))
53685703 continue;
....@@ -5375,22 +5710,55 @@
53755710 //?? if (face.weight < 0)
53765711 // continue;
53775712
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
-
5384
- if (minweight > weight)
5713
+ if (firstEquilateral)
53855714 {
5386
- minweight = weight;
5715
+ if (OneFaceUsed(links.get(face.p)))
5716
+ continue;
5717
+
5718
+ if (OneFaceUsed(links.get(face.q)))
5719
+ continue;
5720
+
5721
+ if (OneFaceUsed(links.get(face.r)))
5722
+ continue;
5723
+
53875724 chosen = i;
5388
- if (minweight == 0)
5389
- break;
5725
+ break;
5726
+ }
5727
+ else
5728
+ {
5729
+ double K = 1; // 0.01; // .25;
5730
+
5731
+ double factor = (1-K)*face.nbiterations + K; //*face.weight;
5732
+
5733
+ double weight = FaceWeight(face); // *Math.pow(PerimeterMax(face),0.25)*factor;
5734
+
5735
+ if (minweight > weight)
5736
+ {
5737
+ minweight = weight;
5738
+ chosen = i;
5739
+ if (minweight == 0)
5740
+ break;
5741
+ }
53905742 }
53915743 }
53925744
53935745 return chosen;
5746
+ }
5747
+
5748
+ private boolean OneFaceUsed(Vector<Face> faces)
5749
+ {
5750
+ if (faces.size() != 6)
5751
+ return true;
5752
+
5753
+ for (int i=0; i<6; i+=1)
5754
+ {
5755
+ if (faces.get(i).used)
5756
+ {
5757
+ return true;
5758
+ }
5759
+ }
5760
+
5761
+ return false;
53945762 }
53955763
53965764 static boolean remove3valence = true;
....@@ -5426,7 +5794,7 @@
54265794 }
54275795 else
54285796 {
5429
- assert(links.size() == vertices.size());
5797
+ // TODO Grafreed.Assert(links.size() == vertices.size());
54305798
54315799 links.setSize(vertices.size());
54325800 for (int i=vertices.size(); --i>=0;)
....@@ -5434,6 +5802,7 @@
54345802 // linkstouched[i] = false;
54355803 if (links.get(i) == null) // ??
54365804 {
5805
+ new Exception().printStackTrace();
54375806 links.set(i, new Vector(8));
54385807 // linkstouched[i] = true;
54395808 }
....@@ -5444,6 +5813,8 @@
54445813 }
54455814 }
54465815
5816
+ boolean once = false;
5817
+
54475818 for (int i=faces.size(); --i>=0;)
54485819 {
54495820 Face face = (Face) faces.get(i);
....@@ -5455,6 +5826,9 @@
54555826 //if (linkstouched[face.r])
54565827 links.get(face.r).add(face);
54575828
5829
+ if (face.used)
5830
+ once = true;
5831
+
54585832 face.good = 1;
54595833 face.boundary = -1;
54605834 }
....@@ -6226,6 +6600,7 @@
62266600
62276601 void InitWeights()
62286602 {
6603
+ new Exception().printStackTrace();
62296604 System.exit(0);
62306605 int n = 0;
62316606 int b = 0;
....@@ -6819,6 +7194,10 @@
68197194 return (face.boundary = 1) == 1;
68207195 }
68217196
7197
+ // June 2019
7198
+ if (true)
7199
+ return (face.boundary = 0) == 1;
7200
+
68227201 // reverse triangle test
68237202 q1.set(p);
68247203 q2.set(q);
....@@ -7075,6 +7454,7 @@
70757454 assert(f2.contains(i));
70767455 assert(f3.contains(i));
70777456
7457
+ // when r is the "center", p is along the boundary
70787458 while (f0.r != i)
70797459 {
70807460 int t = f0.p;
....@@ -7131,59 +7511,90 @@
71317511 f0 = f3;
71327512 f3 = t;
71337513 }
7134
- atleastone = true;
71357514
7515
+ int va = f0.q;
7516
+ int vb = f0.r;
7517
+ int vc = -1;
7518
+
7519
+ Face toremove1 = null;
7520
+ Face toremove2 = null;
7521
+
7522
+ // f0 is the buffer for the first new triangle,
7523
+ // and otherf is the other upper one.
71367524 Face otherf = null;
71377525
71387526 if (f1.contains(f0.p))
71397527 {
71407528 if (f1.p == f0.p)
71417529 {
7530
+ assert(false);
71427531 f0.r = f1.q;
71437532 }
71447533 else
71457534 {
71467535 assert(f1.q == f0.p);
7147
- f0.r = f1.p;
7536
+ vc = f1.p;
71487537 }
71497538
71507539 otherf = f2;
7151
- faces.remove(f1);
7152
- faces.remove(f3);
7540
+ toremove1 = f1;
7541
+ toremove2 = f3;
71537542 }
71547543 else
71557544 if (f2.contains(f0.p))
71567545 {
71577546 if (f2.p == f0.p)
71587547 {
7548
+ assert(false);
71597549 f0.r = f2.q;
71607550 }
71617551 else
71627552 {
71637553 assert(f2.q == f0.p);
7164
- f0.r = f2.p;
7554
+ vc = f2.p;
71657555 }
71667556
71677557 otherf = f3;
7168
- faces.remove(f1);
7169
- faces.remove(f2);
7558
+ toremove1 = f1;
7559
+ toremove2 = f2;
71707560 }
71717561 if (f3.contains(f0.p))
71727562 {
71737563 if (f3.p == f0.p)
71747564 {
7565
+// assert(false);
7566
+ new Exception().printStackTrace();
71757567 f0.r = f3.q;
71767568 }
71777569 else
71787570 {
71797571 assert(f3.q == f0.p);
7180
- f0.r = f3.p;
7572
+ vc = f3.p;
71817573 }
71827574
71837575 otherf = f1;
7184
- faces.remove(f2);
7185
- faces.remove(f3);
7576
+ toremove1 = f2;
7577
+ toremove2 = f3;
71867578 }
7579
+
7580
+ vertextemp.set(vertices.get(va));
7581
+ vertextemp.sub(vertices.get(vb));
7582
+ vertextemp.normalize();
7583
+ vertextemp2.set(vertices.get(vc));
7584
+ vertextemp2.sub(vertices.get(vb));
7585
+ vertextemp2.normalize();
7586
+
7587
+ if (vertextemp.dot(vertextemp2) > -0.95)
7588
+ {
7589
+ continue;
7590
+ }
7591
+
7592
+ atleastone = true;
7593
+
7594
+ f0.r = vc;
7595
+
7596
+ faces.remove(toremove1);
7597
+ faces.remove(toremove2);
71877598
71887599 if (!f0.contains(otherf.p))
71897600 {
....@@ -7236,7 +7647,7 @@
72367647 //InitWeights();
72377648 }
72387649
7239
- int chosen = ChooseTriangle(); // Best is slow and not really better
7650
+ int chosen = ChooseTriangle(true); // Best is slow and not really better
72407651
72417652 if (chosen == -1)
72427653 {
....@@ -7250,7 +7661,7 @@
72507661 //remove3valence = false;
72517662 // InitWeights();
72527663
7253
- chosen = ChooseTriangle();
7664
+ chosen = ChooseTriangle(true);
72547665 }
72557666 }
72567667
....@@ -7526,7 +7937,7 @@
75267937
75277938 // boolean lock;
75287939
7529
- void SplitInTwo(boolean reduction34, boolean onlyone)
7940
+ boolean SplitInTwo(boolean reduction34, boolean onlyone)
75307941 {
75317942 if (stripified)
75327943 {
....@@ -7554,7 +7965,7 @@
75547965 s3 = new cVector();
75557966 }
75567967
7557
- CameraPane.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
7968
+ Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
75587969
75597970 try
75607971 {
....@@ -7563,12 +7974,12 @@
75637974 {
75647975 System.err.println("EXCEPTION CAUGHT");
75657976 e.printStackTrace();
7566
- return;
7977
+ return false;
75677978 } catch (Error e)
75687979 {
75697980 System.err.println("ERROR CAUGHT");
75707981 e.printStackTrace();
7571
- return;
7982
+ return false;
75727983 }
75737984
75747985 System.out.println("# faces = " + faces.size());
....@@ -7578,6 +7989,7 @@
75787989 {
75797990 Face face = (Face) faces.get(i);
75807991
7992
+ face.used = false;
75817993 face.nbiterations = 1;
75827994 face.weight = -1;
75837995 face.boundary = -1;
....@@ -7629,6 +8041,11 @@
76298041 nbbadfaces = faces.size();
76308042 //remove3valence = true;
76318043
8044
+ int count = 2;
8045
+
8046
+ if (onlyone)
8047
+ count = 1;
8048
+
76328049 firstpass = true;
76338050
76348051 int n = faces.size();
....@@ -7644,12 +8061,13 @@
76448061 System.out.print('.');
76458062 }
76468063 System.out.println();
8064
+ boolean atleastone = false;
76478065 int i = 0;
7648
- while (reduction34 || faces.size() > n/2)
8066
+ while (true) // reduction34 || faces.size() > n/2)
76498067 {
76508068 if (i++%100 == 0)
76518069 {
7652
- CameraPane.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
8070
+ Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
76538071 System.out.println("#faces = " + faces.size());
76548072 // if (i != 1)
76558073 // break;
....@@ -7667,6 +8085,8 @@
76678085 {
76688086 if (!RemoveOneTriangle())
76698087 break;
8088
+
8089
+ atleastone = true;
76708090 }
76718091 // if (iterationcount == 0)
76728092 // break;
....@@ -7677,8 +8097,8 @@
76778097 break;
76788098 }
76798099 firstpass = false;
7680
- if (onlyone)
7681
- break; // one triangle only
8100
+// if (--count<0 && !reduction34)
8101
+// break; // one triangle only
76828102 }
76838103
76848104 InitLinks(false); // for further display
....@@ -7693,7 +8113,9 @@
76938113 //Trim(true,cJME.gennormals,true,false); // doesn't work
76948114 Trim(true,false,false,false,false);
76958115
7696
- CameraPane.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR));
8116
+ Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR));
8117
+
8118
+ return atleastone;
76978119 }
76988120
76998121 void UpdateIndices(Face face, Face minface)
....@@ -7706,18 +8128,21 @@
77068128 face.p = minface.p;
77078129 //if (leafweights)
77088130 face.good = 0; // false;
8131
+ face.used = true;
77098132 }
77108133 if (face.q == minface.p || face.q == minface.q || face.q == minface.r)
77118134 {
77128135 face.q = minface.p;
77138136 //if (leafweights)
77148137 face.good = 0; // false;
8138
+ face.used = true;
77158139 }
77168140 if (face.r == minface.p || face.r == minface.q || face.r == minface.r)
77178141 {
77188142 face.r = minface.p;
77198143 //if (leafweights)
77208144 face.good = 0; // false;
8145
+ face.used = true;
77218146 }
77228147
77238148 if (face.p >/*=*/ minface.q && face.p < minface.r)
....@@ -7777,50 +8202,50 @@
77778202 if (v == 2)
77788203 vert = minface.r;
77798204 // Face face = (Face) faces.get(i);
7780
- Vector<Face> vertfaces = links.get(vert);
7781
- for (int i=vertfaces.size(); --i>=0;)
7782
- {
7783
- Face face = (Face) vertfaces.get(i);
7784
-
7785
- // if (face.weight == 10000)
7786
- // continue;
7787
-
7788
- if (face.p == minface.p || face.q == minface.p || face.r == minface.p ||
7789
- face.p == minface.q || face.q == minface.q || face.r == minface.q ||
7790
- face.p == minface.r || face.q == minface.r || face.r == minface.r)
8205
+ Vector<Face> vertfaces = links.get(vert);
8206
+ for (int i=vertfaces.size(); --i>=0;)
77918207 {
7792
- if (!leafweights)
8208
+ Face face = (Face) vertfaces.get(i);
8209
+
8210
+ // if (face.weight == 10000)
8211
+ // continue;
8212
+
8213
+ if (face.p == minface.p || face.q == minface.p || face.r == minface.p ||
8214
+ face.p == minface.q || face.q == minface.q || face.r == minface.q ||
8215
+ face.p == minface.r || face.q == minface.r || face.r == minface.r)
77938216 {
7794
-// if(minfaceweight <= 0)
7795
-// assert(minfaceweight > 0);
7796
-//
7797
-// //FaceWeight(face);
7798
-// if(face.weight < 0)
7799
-// assert(face.weight >= 0);
7800
-
7801
- face.weight += minfaceweight;
7802
-
7803
-// if (face.weight >= 10000)
7804
-// assert(face.weight < 10000);
8217
+ if (!leafweights)
8218
+ {
8219
+ // if(minfaceweight <= 0)
8220
+ // assert(minfaceweight > 0);
8221
+ //
8222
+ // //FaceWeight(face);
8223
+ // if(face.weight < 0)
8224
+ // assert(face.weight >= 0);
8225
+
8226
+ face.weight += minfaceweight;
8227
+
8228
+ // if (face.weight >= 10000)
8229
+ // assert(face.weight < 10000);
8230
+ }
8231
+ else
8232
+ face.weight = -1;
8233
+
8234
+ face.nbiterations += 1;
8235
+ face.boundary = -1;
8236
+
8237
+ Vertex p = (Vertex)vertices.get(face.p);
8238
+ Vertex q = (Vertex)vertices.get(face.q);
8239
+ Vertex r = (Vertex)vertices.get(face.r);
8240
+
8241
+ p.boundary = -1;
8242
+ q.boundary = -1;
8243
+ r.boundary = -1;
78058244 }
78068245 else
7807
- face.weight = -1;
7808
-
7809
- face.nbiterations += 1;
7810
- face.boundary = -1;
7811
-
7812
- Vertex p = (Vertex)vertices.get(face.p);
7813
- Vertex q = (Vertex)vertices.get(face.q);
7814
- Vertex r = (Vertex)vertices.get(face.r);
7815
-
7816
- p.boundary = -1;
7817
- q.boundary = -1;
7818
- r.boundary = -1;
8246
+ assert(false);
78198247 }
7820
- else
7821
- assert(false);
78228248 }
7823
- }
78248249
78258250 // TouchVertex(minface.p);
78268251 // TouchVertex(minface.q);
....@@ -8021,6 +8446,7 @@
80218446 for (int i=vertfaces.size(); --i>=0;)
80228447 {
80238448 Face face = (Face) vertfaces.get(i);
8449
+ face.used = true;
80248450 face.good = 0; // false;
80258451 if (leafweights)
80268452 face.weight = -1;
....@@ -8067,7 +8493,7 @@
80678493 if (!trimmed)
80688494 return;
80698495
8070
- GrafreeD.linkUV = false;
8496
+ Grafreed.linkUV = false;
80718497
80728498 try
80738499 {
....@@ -8275,9 +8701,6 @@
82758701 return "trim = " + trimmed + "; stripped = " + stripified + "; colors = " + colors + "; faces = " + (faces!=null?faces.size():null) + "; triangles = " + (triangles!=null?triangles.length:null) + "; indices = " + indices;
82768702 }
82778703
8278
- static Camera localcamera = new Camera();
8279
- static cVector from = new cVector();
8280
- static cVector to = new cVector();
82818704 boolean trimmed = false;
82828705 boolean stripified = false;
82838706 transient boolean AOdone = false;
....@@ -8285,8 +8708,10 @@
82858708 /*transient*/ int maxIndexV = 0;
82868709 /*transient*/ int bufV, bufF;
82878710 // Raw version
8288
- private float[] positions;
8289
- private float[] normals;
8711
+ //private
8712
+ float[] positions;
8713
+ //private
8714
+ float[] normals;
82908715 float[] colors;
82918716 private float[] uvmap;
82928717 private int[] triangles;
....@@ -8300,7 +8725,8 @@
83008725 int[] startvertices;
83018726 float[] averagepoints;
83028727 float[] extremepoints;
8303
- float[] supportsizes; // distance of closest point
8728
+ float[] supportminsize; // distance of closest point
8729
+ float[] supportmaxsize; // distance of fartest point
83048730
83058731 transient Hashtable vertextable;
83068732 /*transient*/ private Vertex[] verticesCopy;