Normand Briere
2019-08-22 6a823ffbfcda4c843f46e02e83c869d5bc323e25
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
....@@ -5539,6 +5620,11 @@
55395620 if (fullname == null)
55405621 return "";
55415622
5623
+ if (fullname.pigment != null)
5624
+ {
5625
+ return fullname.pigment;
5626
+ }
5627
+
55425628 // System.out.println("Fullname = " + fullname);
55435629
55445630 // Does not work on Windows due to C:
....@@ -5551,7 +5637,7 @@
55515637
55525638 if (split.length == 0)
55535639 {
5554
- return "";
5640
+ return fullname.pigment = "";
55555641 }
55565642
55575643 if (split.length <= 2)
....@@ -5559,22 +5645,27 @@
55595645 if (fullname.name.endsWith(":"))
55605646 {
55615647 // Windows
5562
- return fullname.name.substring(0, fullname.name.length()-1);
5648
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
55635649 }
55645650
5565
- return split[0];
5651
+ return fullname.pigment = split[0];
55665652 }
55675653
55685654 // Windows
55695655 assert(split.length == 4);
55705656
5571
- return split[0] + ":" + split[1];
5657
+ return fullname.pigment = split[0] + ":" + split[1];
55725658 }
55735659
55745660 static String GetBump(cTexture fullname)
55755661 {
55765662 if (fullname == null)
55775663 return "";
5664
+
5665
+ if (fullname.bump != null)
5666
+ {
5667
+ return fullname.bump;
5668
+ }
55785669
55795670 // System.out.println("Fullname = " + fullname);
55805671 // Does not work on Windows due to C:
....@@ -5586,12 +5677,12 @@
55865677
55875678 if (split.length == 0)
55885679 {
5589
- return "";
5680
+ return fullname.bump = "";
55905681 }
55915682
55925683 if (split.length == 1)
55935684 {
5594
- return "";
5685
+ return fullname.bump = "";
55955686 }
55965687
55975688 if (split.length == 2)
....@@ -5599,16 +5690,16 @@
55995690 if (fullname.name.endsWith(":"))
56005691 {
56015692 // Windows
5602
- return "";
5693
+ return fullname.bump = "";
56035694 }
56045695
5605
- return split[1];
5696
+ return fullname.bump = split[1];
56065697 }
56075698
56085699 // Windows
56095700 assert(split.length == 4);
56105701
5611
- return split[2] + ":" + split[3];
5702
+ return fullname.bump = split[2] + ":" + split[3];
56125703 }
56135704
56145705 String GetPigmentTexture()
....@@ -5691,6 +5782,9 @@
56915782 texname = "";
56925783
56935784 GetTextures().name = texname + ":" + GetBump(GetTextures());
5785
+
5786
+ GetTextures().pigment = null;
5787
+
56945788 Touch();
56955789 }
56965790
....@@ -5763,6 +5857,8 @@
57635857 texname = "";
57645858
57655859 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
5860
+
5861
+ GetTextures().bump = null;
57665862
57675863 Touch();
57685864 }
....@@ -5906,8 +6002,10 @@
59066002 if (support != null)
59076003 support = support;
59086004
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);
6005
+ boolean usecalllists = !IsLive() && IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
6006
+ //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
6007
+
6008
+ //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass.
59116009
59126010 if (!usecalllists && bRep != null && bRep.displaylist > 0)
59136011 {
....@@ -5917,8 +6015,9 @@
59176015 // usecalllists &= !(parent instanceof RandomNode);
59186016 // usecalllists = false;
59196017
5920
- if (GetBRep() != null)
5921
- usecalllists = usecalllists;
6018
+ if (display.DrawMode() == display.SHADOW)
6019
+ //GetBRep() != null)
6020
+ usecalllists = !!usecalllists;
59226021 //System.out.println("draw " + this);
59236022 //new Exception().printStackTrace();
59246023
....@@ -5940,7 +6039,7 @@
59406039 if (!(this instanceof Composite))
59416040 touched = false;
59426041 //if (displaylist == -1 && usecalllists)
5943
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
6042
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
59446043 {
59456044 bRep.displaylist = display.GenList();
59466045 assert(bRep.displaylist != 0);
....@@ -5951,7 +6050,7 @@
59516050
59526051 //System.out.println("\tnew list " + list);
59536052 //gl.glDrawBuffer(gl.GL_NONE);
5954
- if (usecalllists)
6053
+ if (usecalllists && bRep.displaylist > 0)
59556054 {
59566055 // System.err.println("new list " + bRep.displaylist + " for " + this);
59576056 display.NewList(bRep.displaylist);
....@@ -5960,7 +6059,7 @@
59606059 CallList(display, root, selected, blocked);
59616060
59626061 // compiled = true;
5963
- if (usecalllists)
6062
+ if (usecalllists && bRep.displaylist > 0)
59646063 {
59656064 // System.err.println("end list " + bRep.displaylist + " for " + this);
59666065 display.EndList();
....@@ -7364,7 +7463,7 @@
73647463 boundary.y = spot.y - 30;
73657464 boundary.width = spot.width + 60;
73667465 boundary.height = spot.height + 60;
7367
- clickInfo.g.setColor(Color.red);
7466
+ clickInfo.g.setColor(Color.white);
73687467 int spotw = spot.x + spot.width;
73697468 int spoth = spot.y + spot.height;
73707469 clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
....@@ -7384,7 +7483,29 @@
73847483 // {
73857484 // CameraPane.Ymax = spoth;
73867485 // }
7387
- spot.translate(32, 32);
7486
+// if (CameraPane.Xmin > spot.x)
7487
+// {
7488
+// CameraPane.Xmin = spot.x;
7489
+// }
7490
+// if (CameraPane.Xmax < spotw)
7491
+// {
7492
+// CameraPane.Xmax = spotw;
7493
+// }
7494
+// if (CameraPane.Ymin > spot.y)
7495
+// {
7496
+// CameraPane.Ymin = spot.y;
7497
+// }
7498
+// if (CameraPane.Ymax < spoth)
7499
+// {
7500
+// CameraPane.Ymax = spoth;
7501
+// }
7502
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7503
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7504
+ spot.translate(32, 0);
7505
+ clickInfo.g.setColor(Color.yellow);
7506
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7507
+
7508
+ spot.translate(32, 64);
73887509 spotw = spot.x + spot.width;
73897510 spoth = spot.y + spot.height;
73907511 clickInfo.g.setColor(Color.cyan);
....@@ -7405,28 +7526,7 @@
74057526 // {
74067527 // CameraPane.Ymax = spoth;
74077528 // }
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);
74137529 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
-// }
74307530 clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
74317531 (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
74327532 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
....@@ -7485,12 +7585,14 @@
74857585 retval = true;
74867586 }
74877587 spot.translate(0, 32);
7588
+ spot.translate(32, 0);
7589
+ spot.translate(0, 32);
74887590 if (spot.contains(clickInfo.x, clickInfo.y))
74897591 {
74907592 hitSomething = hitScale;
74917593
74927594 double scale = 0.005f * clickInfo.camera.Distance();
7493
- double hScale = (double) (clickInfo.x /*- centerPt.x*/) / 32;
7595
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
74947596 double sign = 1;
74957597 if (hScale < 0)
74967598 {
....@@ -7502,7 +7604,7 @@
75027604 //hScale = 0.01;
75037605 }
75047606
7505
- double vScale = (double) (clickInfo.y /*- centerPt.y*/) / 32;
7607
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
75067608 sign = 1;
75077609 if (vScale < 0)
75087610 {
....@@ -7717,7 +7819,7 @@
77177819 break;
77187820
77197821 case hitScale: // scale
7720
- double hScale = (double) (clickInfo.x /*- centerPt.x*/) / 32;
7822
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
77217823 double sign = 1;
77227824 if (hScale < 0)
77237825 {
....@@ -7729,7 +7831,7 @@
77297831 //hScale = 0.01;
77307832 }
77317833
7732
- double vScale = (double) (clickInfo.y /*- centerPt.y*/) / 32;
7834
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
77337835 sign = 1;
77347836 if (vScale < 0)
77357837 {
....@@ -7762,21 +7864,27 @@
77627864 case 3: // '\001'
77637865 if (modified || opposite)
77647866 {
7867
+ if (modified && opposite)
7868
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7869
+ else
77657870 //LA.matScale(toParent, 1, hScale, vScale);
7766
- LA.matScale(toParent, totalScale, 1, 1);
7871
+ LA.matScale(toParent, totalScale, 1, 1);
77677872 } // vScale, 1);
77687873 else
77697874 {
77707875 // EXCEPTION!
7771
- LA.matScale(toParent, totalScale, totalScale, totalScale);
7876
+ LA.matScale(toParent, 1, totalScale, totalScale);
77727877 } // vScale, 1);
77737878 break;
77747879
77757880 case 2: // '\002'
77767881 if (modified || opposite)
77777882 {
7778
- //LA.matScale(toParent, hScale, 1, vScale);
7779
- LA.matScale(toParent, 1, totalScale, 1);
7883
+ if (modified && opposite)
7884
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7885
+ else
7886
+ //LA.matScale(toParent, hScale, 1, vScale);
7887
+ LA.matScale(toParent, 1, totalScale, 1);
77807888 } else
77817889 {
77827890 LA.matScale(toParent, totalScale, 1, totalScale);
....@@ -7786,8 +7894,11 @@
77867894 case 1: // '\003'
77877895 if (modified || opposite)
77887896 {
7789
- //LA.matScale(toParent, hScale, vScale, 1);
7790
- LA.matScale(toParent, 1, 1, totalScale);
7897
+ if (modified && opposite)
7898
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7899
+ else
7900
+ //LA.matScale(toParent, hScale, vScale, 1);
7901
+ LA.matScale(toParent, 1, 1, totalScale);
77917902 } else
77927903 {
77937904 LA.matScale(toParent, totalScale, totalScale, 1);