Normand Briere
2019-06-25 829f93f305ce15893aada126a98d9068b1cdefed
Object3D.java
....@@ -174,14 +174,14 @@
174174 {
175175 Object3D o = hashtable.get(GetUUID());
176176
177
- assert(this.bRep == o.bRep);
177
+ Grafreed.Assert(this.bRep == o.bRep);
178178 if (this.bRep != null)
179179 assert(this.bRep.support == o.transientrep);
180180
181181 return;
182182 }
183183
184
- Object3D o = new Object3D();
184
+ Object3D o = new Object3D("copy of " + this.name);
185185
186186 hashtable.put(GetUUID(), o);
187187
....@@ -219,16 +219,23 @@
219219 if (!hashtable.containsKey(GetUUID()))
220220 return;
221221
222
+ if (blockloop)
223
+ return;
224
+
225
+ blockloop = true;
226
+
222227 Object3D o = hashtable.get(GetUUID());
223228
224229 RestoreBigData(o);
225230
226
- hashtable.remove(GetUUID());
231
+ //hashtable.remove(GetUUID());
227232
228233 for (int i=0; i<Size(); i++)
229234 {
230235 get(i).RestoreBigData(hashtable);
231236 }
237
+
238
+ blockloop = false;
232239 }
233240
234241 void RestoreBigData(Object3D o)
....@@ -563,12 +570,14 @@
563570 toParent = LA.newMatrix();
564571 fromParent = LA.newMatrix();
565572 }
573
+
566574 if (toParentMarked == null)
567575 {
568576 if (maxcount != 1)
569577 {
570578 new Exception().printStackTrace();
571579 }
580
+
572581 toParentMarked = LA.newMatrix();
573582 fromParentMarked = LA.newMatrix();
574583 }
....@@ -879,7 +888,7 @@
879888
880889 if (marked && Globals.isLIVE() && live &&
881890 //TEMP21aug2018
882
- (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
891
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
883892 currentframe != Globals.framecount)
884893 {
885894 currentframe = Globals.framecount;
....@@ -891,7 +900,8 @@
891900
892901 boolean changedir = random && Math.random() < 0.01; // && !link2master;
893902
894
- if (transformcount*factor > maxcount || (step == 1 && changedir))
903
+ if (transformcount*factor >= maxcount && (rewind || random) ||
904
+ (step == 1 && changedir))
895905 {
896906 countdown = 1;
897907 delay = speedup?8:1;
....@@ -963,6 +973,7 @@
963973 if (material == null || material.multiply)
964974 return true;
965975
976
+ // Transparent objects are dynamic because we have to sort the triangles.
966977 return material.opacity > 0.99;
967978 }
968979
....@@ -2384,6 +2395,10 @@
23842395 }
23852396 */
23862397 }
2398
+ else
2399
+ {
2400
+ //((ObjEditor)editWindow).SetupUI2(null);
2401
+ }
23872402 }
23882403
23892404 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2425,6 +2440,14 @@
24252440 {
24262441 editWindow.refreshContents();
24272442 }
2443
+ else
2444
+ {
2445
+ if (manipWindow != null)
2446
+ {
2447
+ manipWindow.refreshContents();
2448
+ }
2449
+ }
2450
+
24282451 //if (parent != null)
24292452 //parent.refreshEditWindow();
24302453 }
....@@ -3501,7 +3524,8 @@
35013524 if (blockloop)
35023525 return;
35033526
3504
- if (marked || (bRep != null && material != null)) // borderline...
3527
+ if (//marked || // does not make sense
3528
+ (bRep != null || material != null)) // borderline...
35053529 live = h;
35063530
35073531 for (int i = 0; i < Size(); i++)
....@@ -3522,7 +3546,8 @@
35223546 return;
35233547
35243548 //if (bRep != null)
3525
- if (marked || (bRep != null && material != null)) // borderline...
3549
+ if (//marked || // does not make sense
3550
+ (bRep != null || material != null)) // borderline...
35263551 link2master = h;
35273552
35283553 for (int i = 0; i < Size(); i++)
....@@ -3542,7 +3567,8 @@
35423567 if (blockloop)
35433568 return;
35443569
3545
- if (marked || (bRep != null && material != null)) // borderline...
3570
+ if (//marked || // does not make sense
3571
+ (bRep != null || material != null)) // borderline...
35463572 hide = h;
35473573
35483574 for (int i = 0; i < Size(); i++)
....@@ -3562,7 +3588,7 @@
35623588 if (blockloop)
35633589 return;
35643590
3565
- if (bRep != null && material != null) // borderline...
3591
+ if (bRep != null || material != null) // borderline...
35663592 marked = h;
35673593
35683594 for (int i = 0; i < Size(); i++)
....@@ -3572,6 +3598,46 @@
35723598 continue;
35733599 blockloop = true;
35743600 child.MarkLeaves(h);
3601
+ blockloop = false;
3602
+ // release(i);
3603
+ }
3604
+ }
3605
+
3606
+ void RewindLeaves(boolean h)
3607
+ {
3608
+ if (blockloop)
3609
+ return;
3610
+
3611
+ if (bRep != null || material != null) // borderline...
3612
+ rewind = h;
3613
+
3614
+ for (int i = 0; i < Size(); i++)
3615
+ {
3616
+ Object3D child = (Object3D) get(i); // reserve(i);
3617
+ if (child == null)
3618
+ continue;
3619
+ blockloop = true;
3620
+ child.RewindLeaves(h);
3621
+ blockloop = false;
3622
+ // release(i);
3623
+ }
3624
+ }
3625
+
3626
+ void RandomLeaves(boolean h)
3627
+ {
3628
+ if (blockloop)
3629
+ return;
3630
+
3631
+ if (bRep != null || material != null) // borderline...
3632
+ random = h;
3633
+
3634
+ for (int i = 0; i < Size(); i++)
3635
+ {
3636
+ Object3D child = (Object3D) get(i); // reserve(i);
3637
+ if (child == null)
3638
+ continue;
3639
+ blockloop = true;
3640
+ child.RandomLeaves(h);
35753641 blockloop = false;
35763642 // release(i);
35773643 }
....@@ -4349,6 +4415,55 @@
43494415 }
43504416 }
43514417
4418
+ void RepairSOV()
4419
+ {
4420
+ if (blockloop)
4421
+ return;
4422
+
4423
+ String texname = this.GetPigmentTexture();
4424
+
4425
+ if (texname.startsWith("sov"))
4426
+ {
4427
+ String[] s = texname.split("/");
4428
+
4429
+ String[] sname = s[1].split("Color.pn");
4430
+
4431
+ texname = sname[0];
4432
+
4433
+ if (sname.length > 1)
4434
+ {
4435
+ texname += "Color.jpg";
4436
+ }
4437
+
4438
+ this.SetPigmentTexture("sov/" + texname);
4439
+ }
4440
+
4441
+ texname = this.GetBumpTexture();
4442
+
4443
+ if (texname.startsWith("sov"))
4444
+ {
4445
+ String[] s = texname.split("/");
4446
+
4447
+ String[] sname = s[1].split("Bump.pn");
4448
+
4449
+ texname = sname[0];
4450
+
4451
+ if (sname.length > 1)
4452
+ {
4453
+ texname += "Bump.jpg";
4454
+ }
4455
+
4456
+ this.SetBumpTexture("sov/" + texname);
4457
+ }
4458
+
4459
+ for (int i=0; i<Size(); i++)
4460
+ {
4461
+ blockloop = true;
4462
+ get(i).RepairSOV();
4463
+ blockloop = false;
4464
+ }
4465
+ }
4466
+
43524467 void RepairTexture()
43534468 {
43544469 if (this instanceof FileObject || blockloop)
....@@ -4863,6 +4978,14 @@
48634978 }
48644979 }
48654980
4981
+ ObjEditor GetWindow()
4982
+ {
4983
+ if (editWindow != null)
4984
+ return editWindow;
4985
+
4986
+ return manipWindow;
4987
+ }
4988
+
48664989 cTreePath Select(int indexcount, boolean deselect)
48674990 {
48684991 if (hide || dontselect)
....@@ -4899,10 +5022,11 @@
48995022 if (leaf != null)
49005023 {
49015024 cTreePath tp = new cTreePath(this, leaf);
4902
- if (editWindow != null)
5025
+ ObjEditor window = GetWindow();
5026
+ if (window != null)
49035027 {
49045028 //System.out.println("editWindow = " + editWindow + " vs " + this);
4905
- editWindow.Select(tp, deselect, true);
5029
+ window.Select(tp, deselect, true);
49065030 }
49075031
49085032 return tp;
....@@ -4928,9 +5052,10 @@
49285052 if (leaf != null)
49295053 {
49305054 cTreePath tp = new cTreePath(this, leaf);
4931
- if (editWindow != null)
5055
+ ObjEditor window = GetWindow();
5056
+ if (window != null)
49325057 {
4933
- editWindow.Select(tp, deselect, true);
5058
+ window.Select(tp, deselect, true);
49345059 }
49355060
49365061 return tp;
....@@ -5572,12 +5697,23 @@
55725697 boolean NeedSupport()
55735698 {
55745699 return
5575
- CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null
5700
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
55765701 // PROBLEM with CROWD!!
55775702 && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
55785703 }
55795704
55805705 static boolean DEBUG_SELECTION = false;
5706
+
5707
+ boolean IsLive()
5708
+ {
5709
+ if (live)
5710
+ return true;
5711
+
5712
+ if (parent == null)
5713
+ return false;
5714
+
5715
+ return parent.IsLive();
5716
+ }
55815717
55825718 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
55835719 {
....@@ -5640,7 +5776,7 @@
56405776 support = support;
56415777
56425778 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5643
- boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5779
+ boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
56445780
56455781 if (!usecalllists && bRep != null && bRep.displaylist > 0)
56465782 {
....@@ -5660,10 +5796,12 @@
56605796 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
56615797
56625798 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5663
- (touched || (bRep != null && bRep.displaylist <= 0)))
5799
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5800
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && (bRep != null && bRep.displaylist <= 0)))
56645801 {
56655802 Globals.lighttouched = true;
56665803 } // all panes...
5804
+
56675805 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
56685806 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
56695807 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5831,16 +5969,27 @@
58315969 tex = GetTextures();
58325970 }
58335971
5834
- boolean failed = false;
5972
+ boolean failedPigment = false;
5973
+ boolean failedBump = false;
58355974
58365975 try
58375976 {
5838
- display.BindTextures(tex, texres);
5977
+ display.BindPigmentTexture(tex, texres);
58395978 }
58405979 catch (Exception e)
58415980 {
58425981 System.err.println("FAILED: " + this);
5843
- failed = true;
5982
+ failedPigment = true;
5983
+ }
5984
+
5985
+ try
5986
+ {
5987
+ display.BindBumpTexture(tex, texres);
5988
+ }
5989
+ catch (Exception e)
5990
+ {
5991
+ //System.err.println("FAILED: " + this);
5992
+ failedBump = true;
58445993 }
58455994
58465995 if (!compiled)
....@@ -5863,8 +6012,11 @@
58636012 }
58646013 }
58656014
5866
- if (!failed)
5867
- display.ReleaseTextures(tex);
6015
+ if (!failedBump)
6016
+ display.ReleaseBumpTexture(tex);
6017
+
6018
+ if (!failedPigment)
6019
+ display.ReleasePigmentTexture(tex);
58686020
58696021 display.PopMaterial(this, selected);
58706022 }
....@@ -6237,6 +6389,11 @@
62376389 // dec 2012
62386390 new Exception().printStackTrace();
62396391 return;
6392
+ }
6393
+
6394
+ if (dontselect)
6395
+ {
6396
+ //bRep.GenerateNormalsMINE();
62406397 }
62416398
62426399 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -7089,7 +7246,7 @@
70897246 spot.translate(32, 32);
70907247 spotw = spot.x + spot.width;
70917248 spoth = spot.y + spot.height;
7092
- info.g.setColor(Color.blue);
7249
+ info.g.setColor(Color.cyan);
70937250 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
70947251 // if (CameraPane.Xmin > spot.x)
70957252 // {
....@@ -7107,11 +7264,12 @@
71077264 // {
71087265 // CameraPane.Ymax = spoth;
71097266 // }
7110
- // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7111
- //info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7267
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7268
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
71127269 spot.translate(0, -32);
7113
- info.g.setColor(Color.green);
7270
+ info.g.setColor(Color.yellow);
71147271 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7272
+ info.g.setColor(Color.green);
71157273 // if (CameraPane.Xmin > spot.x)
71167274 // {
71177275 // CameraPane.Xmin = spot.x;
....@@ -7429,19 +7587,20 @@
74297587 switch (info.pane.RenderCamera().viewCode)
74307588 {
74317589 case 3: // '\001'
7432
- if (modified)
7590
+ if (modified || opposite)
74337591 {
74347592 //LA.matScale(toParent, 1, hScale, vScale);
74357593 LA.matScale(toParent, totalScale, 1, 1);
74367594 } // vScale, 1);
74377595 else
74387596 {
7597
+ // EXCEPTION!
74397598 LA.matScale(toParent, totalScale, totalScale, totalScale);
74407599 } // vScale, 1);
74417600 break;
74427601
74437602 case 2: // '\002'
7444
- if (modified)
7603
+ if (modified || opposite)
74457604 {
74467605 //LA.matScale(toParent, hScale, 1, vScale);
74477606 LA.matScale(toParent, 1, totalScale, 1);
....@@ -7452,7 +7611,7 @@
74527611 break;
74537612
74547613 case 1: // '\003'
7455
- if (modified)
7614
+ if (modified || opposite)
74567615 {
74577616 //LA.matScale(toParent, hScale, vScale, 1);
74587617 LA.matScale(toParent, 1, 1, totalScale);
....@@ -7672,6 +7831,10 @@
76727831 editWindow = null;
76737832 } // ?
76747833 }
7834
+ else
7835
+ {
7836
+ //editWindow.closeUI();
7837
+ }
76757838 }
76767839
76777840 boolean root; // patch for edit windows
....@@ -7829,6 +7992,8 @@
78297992 }
78307993
78317994 transient ObjEditor editWindow;
7995
+ transient ObjEditor manipWindow;
7996
+
78327997 transient ObjectUI objectUI;
78337998 public static int povDepth = 0;
78347999 private static cVector tbMin = new cVector();