Normand Briere
2019-08-22 0c7b833be7d86598a6813cd1c6db0ca9e1b17966
Object3D.java
....@@ -36,6 +36,8 @@
3636 Object3D versionlist[];
3737 int versionindex = -1;
3838
39
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable; // = new java.util.Hashtable<java.util.UUID, Object3D>();
40
+
3941 ScriptNode scriptnode;
4042
4143 void InitOthers()
....@@ -269,6 +271,50 @@
269271 //
270272 // return null;
271273 // }
274
+
275
+ transient boolean tag;
276
+
277
+ void TagObjects(Object3D o, boolean tag)
278
+ {
279
+ if (blockloop)
280
+ return;
281
+
282
+ o.tag = tag;
283
+
284
+ if (o == this)
285
+ return;
286
+
287
+ blockloop = true;
288
+
289
+ for (int i=0; i<Size(); i++)
290
+ {
291
+ get(i).TagObjects(o, tag);
292
+ }
293
+
294
+ blockloop = false;
295
+ }
296
+
297
+ boolean HasTags()
298
+ {
299
+ if (blockloop)
300
+ return false;
301
+
302
+ blockloop = true;
303
+
304
+ boolean hasTags = false;
305
+
306
+ for (int i=0; i<Size(); i++)
307
+ {
308
+ hasTags |= get(i).tag || get(i).HasTags();
309
+
310
+ if (hasTags)
311
+ break;
312
+ }
313
+
314
+ blockloop = false;
315
+
316
+ return hasTags;
317
+ }
272318
273319 void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
274320 {
....@@ -2468,7 +2514,11 @@
24682514 else
24692515 {
24702516 //((ObjEditor)editWindow).SetupUI2(null);
2471
- ((ObjEditor)objectUI).pinButton.setSelected(pinned);
2517
+ if (objectUI != null)
2518
+ ((ObjEditor)objectUI).pinButton.setSelected(pinned);
2519
+ else
2520
+ //new Exception().printStackTrace();
2521
+ System.err.println("objectUI is null");
24722522 }
24732523 }
24742524
....@@ -3572,15 +3622,47 @@
35723622
35733623 void ClearMaterials()
35743624 {
3625
+ if (blockloop)
3626
+ return;
3627
+
3628
+ blockloop = true;
3629
+
35753630 ClearMaterial();
3576
- for (int i = 0; i < size(); i++)
3631
+ for (int i = 0; i < Size(); i++)
35773632 {
3578
- Object3D child = (Object3D) reserve(i);
3633
+ Object3D child = (Object3D) get(i);
35793634 if (child == null)
35803635 continue;
35813636 child.ClearMaterials();
3582
- release(i);
35833637 }
3638
+
3639
+ blockloop = false;
3640
+ }
3641
+
3642
+ void ClearVersionList()
3643
+ {
3644
+ this.versionlist = null;
3645
+ this.versionindex = -1;
3646
+ this.versiontable = null;
3647
+ }
3648
+
3649
+ void ClearVersions()
3650
+ {
3651
+ if (blockloop)
3652
+ return;
3653
+
3654
+ blockloop = true;
3655
+
3656
+ ClearVersionList();
3657
+ for (int i = 0; i < Size(); i++)
3658
+ {
3659
+ Object3D child = (Object3D) get(i);
3660
+ if (child == null)
3661
+ continue;
3662
+ child.ClearVersions();
3663
+ }
3664
+
3665
+ blockloop = false;
35843666 }
35853667
35863668 void FlipV(boolean flip)
....@@ -5570,6 +5652,11 @@
55705652 if (fullname == null)
55715653 return "";
55725654
5655
+ if (fullname.pigment != null)
5656
+ {
5657
+ return fullname.pigment;
5658
+ }
5659
+
55735660 // System.out.println("Fullname = " + fullname);
55745661
55755662 // Does not work on Windows due to C:
....@@ -5582,7 +5669,7 @@
55825669
55835670 if (split.length == 0)
55845671 {
5585
- return "";
5672
+ return fullname.pigment = "";
55865673 }
55875674
55885675 if (split.length <= 2)
....@@ -5590,22 +5677,27 @@
55905677 if (fullname.name.endsWith(":"))
55915678 {
55925679 // Windows
5593
- return fullname.name.substring(0, fullname.name.length()-1);
5680
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
55945681 }
55955682
5596
- return split[0];
5683
+ return fullname.pigment = split[0];
55975684 }
55985685
55995686 // Windows
56005687 assert(split.length == 4);
56015688
5602
- return split[0] + ":" + split[1];
5689
+ return fullname.pigment = split[0] + ":" + split[1];
56035690 }
56045691
56055692 static String GetBump(cTexture fullname)
56065693 {
56075694 if (fullname == null)
56085695 return "";
5696
+
5697
+ if (fullname.bump != null)
5698
+ {
5699
+ return fullname.bump;
5700
+ }
56095701
56105702 // System.out.println("Fullname = " + fullname);
56115703 // Does not work on Windows due to C:
....@@ -5617,12 +5709,12 @@
56175709
56185710 if (split.length == 0)
56195711 {
5620
- return "";
5712
+ return fullname.bump = "";
56215713 }
56225714
56235715 if (split.length == 1)
56245716 {
5625
- return "";
5717
+ return fullname.bump = "";
56265718 }
56275719
56285720 if (split.length == 2)
....@@ -5630,16 +5722,16 @@
56305722 if (fullname.name.endsWith(":"))
56315723 {
56325724 // Windows
5633
- return "";
5725
+ return fullname.bump = "";
56345726 }
56355727
5636
- return split[1];
5728
+ return fullname.bump = split[1];
56375729 }
56385730
56395731 // Windows
56405732 assert(split.length == 4);
56415733
5642
- return split[2] + ":" + split[3];
5734
+ return fullname.bump = split[2] + ":" + split[3];
56435735 }
56445736
56455737 String GetPigmentTexture()
....@@ -5722,6 +5814,9 @@
57225814 texname = "";
57235815
57245816 GetTextures().name = texname + ":" + GetBump(GetTextures());
5817
+
5818
+ GetTextures().pigment = null;
5819
+
57255820 Touch();
57265821 }
57275822
....@@ -5794,6 +5889,8 @@
57945889 texname = "";
57955890
57965891 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
5892
+
5893
+ GetTextures().bump = null;
57975894
57985895 Touch();
57995896 }
....@@ -7398,7 +7495,7 @@
73987495 boundary.y = spot.y - 30;
73997496 boundary.width = spot.width + 60;
74007497 boundary.height = spot.height + 60;
7401
- clickInfo.g.setColor(Color.red);
7498
+ clickInfo.g.setColor(Color.white);
74027499 int spotw = spot.x + spot.width;
74037500 int spoth = spot.y + spot.height;
74047501 clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
....@@ -7418,7 +7515,29 @@
74187515 // {
74197516 // CameraPane.Ymax = spoth;
74207517 // }
7421
- spot.translate(32, 32);
7518
+// if (CameraPane.Xmin > spot.x)
7519
+// {
7520
+// CameraPane.Xmin = spot.x;
7521
+// }
7522
+// if (CameraPane.Xmax < spotw)
7523
+// {
7524
+// CameraPane.Xmax = spotw;
7525
+// }
7526
+// if (CameraPane.Ymin > spot.y)
7527
+// {
7528
+// CameraPane.Ymin = spot.y;
7529
+// }
7530
+// if (CameraPane.Ymax < spoth)
7531
+// {
7532
+// CameraPane.Ymax = spoth;
7533
+// }
7534
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7535
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7536
+ spot.translate(32, 0);
7537
+ clickInfo.g.setColor(Color.yellow);
7538
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7539
+
7540
+ spot.translate(32, 64);
74227541 spotw = spot.x + spot.width;
74237542 spoth = spot.y + spot.height;
74247543 clickInfo.g.setColor(Color.cyan);
....@@ -7439,28 +7558,7 @@
74397558 // {
74407559 // CameraPane.Ymax = spoth;
74417560 // }
7442
- // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7443
- //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7444
- spot.translate(0, -32);
7445
- clickInfo.g.setColor(Color.yellow);
7446
- clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
74477561 clickInfo.g.setColor(Color.green);
7448
-// if (CameraPane.Xmin > spot.x)
7449
-// {
7450
-// CameraPane.Xmin = spot.x;
7451
-// }
7452
-// if (CameraPane.Xmax < spotw)
7453
-// {
7454
-// CameraPane.Xmax = spotw;
7455
-// }
7456
-// if (CameraPane.Ymin > spot.y)
7457
-// {
7458
-// CameraPane.Ymin = spot.y;
7459
-// }
7460
-// if (CameraPane.Ymax < spoth)
7461
-// {
7462
-// CameraPane.Ymax = spoth;
7463
-// }
74647562 clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
74657563 (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
74667564 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
....@@ -7519,12 +7617,14 @@
75197617 retval = true;
75207618 }
75217619 spot.translate(0, 32);
7620
+ spot.translate(32, 0);
7621
+ spot.translate(0, 32);
75227622 if (spot.contains(clickInfo.x, clickInfo.y))
75237623 {
75247624 hitSomething = hitScale;
75257625
75267626 double scale = 0.005f * clickInfo.camera.Distance();
7527
- double hScale = (double) (clickInfo.x - centerPt.x) / 32;
7627
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
75287628 double sign = 1;
75297629 if (hScale < 0)
75307630 {
....@@ -7536,7 +7636,7 @@
75367636 //hScale = 0.01;
75377637 }
75387638
7539
- double vScale = (double) (clickInfo.y - centerPt.y) / 32;
7639
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
75407640 sign = 1;
75417641 if (vScale < 0)
75427642 {
....@@ -7751,7 +7851,7 @@
77517851 break;
77527852
77537853 case hitScale: // scale
7754
- double hScale = (double) (clickInfo.x - centerPt.x) / 32;
7854
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
77557855 double sign = 1;
77567856 if (hScale < 0)
77577857 {
....@@ -7763,7 +7863,7 @@
77637863 //hScale = 0.01;
77647864 }
77657865
7766
- double vScale = (double) (clickInfo.y - centerPt.y) / 32;
7866
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
77677867 sign = 1;
77687868 if (vScale < 0)
77697869 {
....@@ -7796,21 +7896,27 @@
77967896 case 3: // '\001'
77977897 if (modified || opposite)
77987898 {
7899
+ if (modified && opposite)
7900
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7901
+ else
77997902 //LA.matScale(toParent, 1, hScale, vScale);
7800
- LA.matScale(toParent, totalScale, 1, 1);
7903
+ LA.matScale(toParent, totalScale, 1, 1);
78017904 } // vScale, 1);
78027905 else
78037906 {
78047907 // EXCEPTION!
7805
- LA.matScale(toParent, totalScale, totalScale, totalScale);
7908
+ LA.matScale(toParent, 1, totalScale, totalScale);
78067909 } // vScale, 1);
78077910 break;
78087911
78097912 case 2: // '\002'
78107913 if (modified || opposite)
78117914 {
7812
- //LA.matScale(toParent, hScale, 1, vScale);
7813
- LA.matScale(toParent, 1, totalScale, 1);
7915
+ if (modified && opposite)
7916
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7917
+ else
7918
+ //LA.matScale(toParent, hScale, 1, vScale);
7919
+ LA.matScale(toParent, 1, totalScale, 1);
78147920 } else
78157921 {
78167922 LA.matScale(toParent, totalScale, 1, totalScale);
....@@ -7820,8 +7926,11 @@
78207926 case 1: // '\003'
78217927 if (modified || opposite)
78227928 {
7823
- //LA.matScale(toParent, hScale, vScale, 1);
7824
- LA.matScale(toParent, 1, 1, totalScale);
7929
+ if (modified && opposite)
7930
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7931
+ else
7932
+ //LA.matScale(toParent, hScale, vScale, 1);
7933
+ LA.matScale(toParent, 1, 1, totalScale);
78257934 } else
78267935 {
78277936 LA.matScale(toParent, totalScale, totalScale, 1);