Normand Briere
2019-08-22 0c7b833be7d86598a6813cd1c6db0ca9e1b17966
Object3D.java
....@@ -22,6 +22,7 @@
2222 //static final long serialVersionUID = -607422624994562685L;
2323 static final long serialVersionUID = 5022536242724664900L;
2424
25
+ // Use GetUUID for backward compatibility with null.
2526 private UUID uuid = UUID.randomUUID();
2627
2728 // TEMPORARY for mocap undo. No need to be transient.
....@@ -29,9 +30,14 @@
2930 Object3D saveskeleton;
3031 //
3132
32
- byte[] versions[];
33
+ String skyboxname;
34
+ String skyboxext;
35
+
36
+ Object3D versionlist[];
3337 int versionindex = -1;
3438
39
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable; // = new java.util.Hashtable<java.util.UUID, Object3D>();
40
+
3541 ScriptNode scriptnode;
3642
3743 void InitOthers()
....@@ -219,7 +225,7 @@
219225 // o.bRep.support = null;
220226 // }
221227 o.selection = this.selection;
222
- o.versions = this.versions;
228
+ o.versionlist = this.versionlist;
223229 o.versionindex = this.versionindex;
224230
225231 if (this.support != null)
....@@ -241,6 +247,73 @@
241247 // this.bRep.support = null;
242248 // this.support = null;
243249 // this.fileparent = null;
250
+ }
251
+
252
+// Object3D GetObject(java.util.UUID uuid)
253
+// {
254
+// if (this.uuid.equals(uuid))
255
+// return this;
256
+//
257
+// if (blockloop)
258
+// return null;
259
+//
260
+// blockloop = true;
261
+//
262
+// for (int i=0; i<Size(); i++)
263
+// {
264
+// Object3D o = get(i).GetObject(uuid);
265
+//
266
+// if (o != null)
267
+// return o;
268
+// }
269
+//
270
+// blockloop = false;
271
+//
272
+// return null;
273
+// }
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;
244317 }
245318
246319 void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
....@@ -277,7 +350,7 @@
277350
278351 this.selection = o.selection;
279352
280
- this.versions = o.versions;
353
+ this.versionlist = o.versionlist;
281354 this.versionindex = o.versionindex;
282355 // July 2019 if (this.bRep != null)
283356 // this.bRep.support = o.transientrep;
....@@ -1011,6 +1084,9 @@
10111084
10121085 if (material == null || material.multiply)
10131086 return true;
1087
+
1088
+ if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
1089
+ return false;
10141090
10151091 // Transparent objects are dynamic because we have to sort the triangles.
10161092 return material.opacity > 0.99;
....@@ -2438,6 +2514,11 @@
24382514 else
24392515 {
24402516 //((ObjEditor)editWindow).SetupUI2(null);
2517
+ if (objectUI != null)
2518
+ ((ObjEditor)objectUI).pinButton.setSelected(pinned);
2519
+ else
2520
+ //new Exception().printStackTrace();
2521
+ System.err.println("objectUI is null");
24412522 }
24422523 }
24432524
....@@ -3541,15 +3622,47 @@
35413622
35423623 void ClearMaterials()
35433624 {
3625
+ if (blockloop)
3626
+ return;
3627
+
3628
+ blockloop = true;
3629
+
35443630 ClearMaterial();
3545
- for (int i = 0; i < size(); i++)
3631
+ for (int i = 0; i < Size(); i++)
35463632 {
3547
- Object3D child = (Object3D) reserve(i);
3633
+ Object3D child = (Object3D) get(i);
35483634 if (child == null)
35493635 continue;
35503636 child.ClearMaterials();
3551
- release(i);
35523637 }
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;
35533666 }
35543667
35553668 void FlipV(boolean flip)
....@@ -5539,6 +5652,11 @@
55395652 if (fullname == null)
55405653 return "";
55415654
5655
+ if (fullname.pigment != null)
5656
+ {
5657
+ return fullname.pigment;
5658
+ }
5659
+
55425660 // System.out.println("Fullname = " + fullname);
55435661
55445662 // Does not work on Windows due to C:
....@@ -5551,7 +5669,7 @@
55515669
55525670 if (split.length == 0)
55535671 {
5554
- return "";
5672
+ return fullname.pigment = "";
55555673 }
55565674
55575675 if (split.length <= 2)
....@@ -5559,22 +5677,27 @@
55595677 if (fullname.name.endsWith(":"))
55605678 {
55615679 // Windows
5562
- return fullname.name.substring(0, fullname.name.length()-1);
5680
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
55635681 }
55645682
5565
- return split[0];
5683
+ return fullname.pigment = split[0];
55665684 }
55675685
55685686 // Windows
55695687 assert(split.length == 4);
55705688
5571
- return split[0] + ":" + split[1];
5689
+ return fullname.pigment = split[0] + ":" + split[1];
55725690 }
55735691
55745692 static String GetBump(cTexture fullname)
55755693 {
55765694 if (fullname == null)
55775695 return "";
5696
+
5697
+ if (fullname.bump != null)
5698
+ {
5699
+ return fullname.bump;
5700
+ }
55785701
55795702 // System.out.println("Fullname = " + fullname);
55805703 // Does not work on Windows due to C:
....@@ -5586,12 +5709,12 @@
55865709
55875710 if (split.length == 0)
55885711 {
5589
- return "";
5712
+ return fullname.bump = "";
55905713 }
55915714
55925715 if (split.length == 1)
55935716 {
5594
- return "";
5717
+ return fullname.bump = "";
55955718 }
55965719
55975720 if (split.length == 2)
....@@ -5599,16 +5722,16 @@
55995722 if (fullname.name.endsWith(":"))
56005723 {
56015724 // Windows
5602
- return "";
5725
+ return fullname.bump = "";
56035726 }
56045727
5605
- return split[1];
5728
+ return fullname.bump = split[1];
56065729 }
56075730
56085731 // Windows
56095732 assert(split.length == 4);
56105733
5611
- return split[2] + ":" + split[3];
5734
+ return fullname.bump = split[2] + ":" + split[3];
56125735 }
56135736
56145737 String GetPigmentTexture()
....@@ -5691,6 +5814,9 @@
56915814 texname = "";
56925815
56935816 GetTextures().name = texname + ":" + GetBump(GetTextures());
5817
+
5818
+ GetTextures().pigment = null;
5819
+
56945820 Touch();
56955821 }
56965822
....@@ -5763,6 +5889,8 @@
57635889 texname = "";
57645890
57655891 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
5892
+
5893
+ GetTextures().bump = null;
57665894
57675895 Touch();
57685896 }
....@@ -5906,8 +6034,10 @@
59066034 if (support != null)
59076035 support = support;
59086036
5909
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5910
- boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
6037
+ boolean usecalllists = !IsLive() && IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
6038
+ //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
6039
+
6040
+ //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass.
59116041
59126042 if (!usecalllists && bRep != null && bRep.displaylist > 0)
59136043 {
....@@ -5917,8 +6047,9 @@
59176047 // usecalllists &= !(parent instanceof RandomNode);
59186048 // usecalllists = false;
59196049
5920
- if (GetBRep() != null)
5921
- usecalllists = usecalllists;
6050
+ if (display.DrawMode() == display.SHADOW)
6051
+ //GetBRep() != null)
6052
+ usecalllists = !!usecalllists;
59226053 //System.out.println("draw " + this);
59236054 //new Exception().printStackTrace();
59246055
....@@ -5940,7 +6071,7 @@
59406071 if (!(this instanceof Composite))
59416072 touched = false;
59426073 //if (displaylist == -1 && usecalllists)
5943
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
6074
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
59446075 {
59456076 bRep.displaylist = display.GenList();
59466077 assert(bRep.displaylist != 0);
....@@ -5951,7 +6082,7 @@
59516082
59526083 //System.out.println("\tnew list " + list);
59536084 //gl.glDrawBuffer(gl.GL_NONE);
5954
- if (usecalllists)
6085
+ if (usecalllists && bRep.displaylist > 0)
59556086 {
59566087 // System.err.println("new list " + bRep.displaylist + " for " + this);
59576088 display.NewList(bRep.displaylist);
....@@ -5960,7 +6091,7 @@
59606091 CallList(display, root, selected, blocked);
59616092
59626093 // compiled = true;
5963
- if (usecalllists)
6094
+ if (usecalllists && bRep.displaylist > 0)
59646095 {
59656096 // System.err.println("end list " + bRep.displaylist + " for " + this);
59666097 display.EndList();
....@@ -7364,7 +7495,7 @@
73647495 boundary.y = spot.y - 30;
73657496 boundary.width = spot.width + 60;
73667497 boundary.height = spot.height + 60;
7367
- clickInfo.g.setColor(Color.red);
7498
+ clickInfo.g.setColor(Color.white);
73687499 int spotw = spot.x + spot.width;
73697500 int spoth = spot.y + spot.height;
73707501 clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
....@@ -7384,7 +7515,29 @@
73847515 // {
73857516 // CameraPane.Ymax = spoth;
73867517 // }
7387
- 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);
73887541 spotw = spot.x + spot.width;
73897542 spoth = spot.y + spot.height;
73907543 clickInfo.g.setColor(Color.cyan);
....@@ -7405,28 +7558,7 @@
74057558 // {
74067559 // CameraPane.Ymax = spoth;
74077560 // }
7408
- // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7409
- //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7410
- spot.translate(0, -32);
7411
- clickInfo.g.setColor(Color.yellow);
7412
- clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
74137561 clickInfo.g.setColor(Color.green);
7414
-// if (CameraPane.Xmin > spot.x)
7415
-// {
7416
-// CameraPane.Xmin = spot.x;
7417
-// }
7418
-// if (CameraPane.Xmax < spotw)
7419
-// {
7420
-// CameraPane.Xmax = spotw;
7421
-// }
7422
-// if (CameraPane.Ymin > spot.y)
7423
-// {
7424
-// CameraPane.Ymin = spot.y;
7425
-// }
7426
-// if (CameraPane.Ymax < spoth)
7427
-// {
7428
-// CameraPane.Ymax = spoth;
7429
-// }
74307562 clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
74317563 (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
74327564 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
....@@ -7485,12 +7617,14 @@
74857617 retval = true;
74867618 }
74877619 spot.translate(0, 32);
7620
+ spot.translate(32, 0);
7621
+ spot.translate(0, 32);
74887622 if (spot.contains(clickInfo.x, clickInfo.y))
74897623 {
74907624 hitSomething = hitScale;
74917625
74927626 double scale = 0.005f * clickInfo.camera.Distance();
7493
- double hScale = (double) (clickInfo.x /*- centerPt.x*/) / 32;
7627
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
74947628 double sign = 1;
74957629 if (hScale < 0)
74967630 {
....@@ -7502,7 +7636,7 @@
75027636 //hScale = 0.01;
75037637 }
75047638
7505
- double vScale = (double) (clickInfo.y /*- centerPt.y*/) / 32;
7639
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
75067640 sign = 1;
75077641 if (vScale < 0)
75087642 {
....@@ -7717,7 +7851,7 @@
77177851 break;
77187852
77197853 case hitScale: // scale
7720
- double hScale = (double) (clickInfo.x /*- centerPt.x*/) / 32;
7854
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
77217855 double sign = 1;
77227856 if (hScale < 0)
77237857 {
....@@ -7729,7 +7863,7 @@
77297863 //hScale = 0.01;
77307864 }
77317865
7732
- double vScale = (double) (clickInfo.y /*- centerPt.y*/) / 32;
7866
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
77337867 sign = 1;
77347868 if (vScale < 0)
77357869 {
....@@ -7762,21 +7896,27 @@
77627896 case 3: // '\001'
77637897 if (modified || opposite)
77647898 {
7899
+ if (modified && opposite)
7900
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7901
+ else
77657902 //LA.matScale(toParent, 1, hScale, vScale);
7766
- LA.matScale(toParent, totalScale, 1, 1);
7903
+ LA.matScale(toParent, totalScale, 1, 1);
77677904 } // vScale, 1);
77687905 else
77697906 {
77707907 // EXCEPTION!
7771
- LA.matScale(toParent, totalScale, totalScale, totalScale);
7908
+ LA.matScale(toParent, 1, totalScale, totalScale);
77727909 } // vScale, 1);
77737910 break;
77747911
77757912 case 2: // '\002'
77767913 if (modified || opposite)
77777914 {
7778
- //LA.matScale(toParent, hScale, 1, vScale);
7779
- 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);
77807920 } else
77817921 {
77827922 LA.matScale(toParent, totalScale, 1, totalScale);
....@@ -7786,8 +7926,11 @@
77867926 case 1: // '\003'
77877927 if (modified || opposite)
77887928 {
7789
- //LA.matScale(toParent, hScale, vScale, 1);
7790
- 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);
77917934 } else
77927935 {
77937936 LA.matScale(toParent, totalScale, totalScale, 1);