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.
....@@ -32,9 +33,11 @@
3233 String skyboxname;
3334 String skyboxext;
3435
35
- byte[] versions[];
36
+ Object3D versionlist[];
3637 int versionindex = -1;
3738
39
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable; // = new java.util.Hashtable<java.util.UUID, Object3D>();
40
+
3841 ScriptNode scriptnode;
3942
4043 void InitOthers()
....@@ -222,7 +225,7 @@
222225 // o.bRep.support = null;
223226 // }
224227 o.selection = this.selection;
225
- o.versions = this.versions;
228
+ o.versionlist = this.versionlist;
226229 o.versionindex = this.versionindex;
227230
228231 if (this.support != null)
....@@ -244,6 +247,73 @@
244247 // this.bRep.support = null;
245248 // this.support = null;
246249 // 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;
247317 }
248318
249319 void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
....@@ -280,7 +350,7 @@
280350
281351 this.selection = o.selection;
282352
283
- this.versions = o.versions;
353
+ this.versionlist = o.versionlist;
284354 this.versionindex = o.versionindex;
285355 // July 2019 if (this.bRep != null)
286356 // this.bRep.support = o.transientrep;
....@@ -1014,6 +1084,9 @@
10141084
10151085 if (material == null || material.multiply)
10161086 return true;
1087
+
1088
+ if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
1089
+ return false;
10171090
10181091 // Transparent objects are dynamic because we have to sort the triangles.
10191092 return material.opacity > 0.99;
....@@ -2441,6 +2514,11 @@
24412514 else
24422515 {
24432516 //((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");
24442522 }
24452523 }
24462524
....@@ -5542,6 +5620,11 @@
55425620 if (fullname == null)
55435621 return "";
55445622
5623
+ if (fullname.pigment != null)
5624
+ {
5625
+ return fullname.pigment;
5626
+ }
5627
+
55455628 // System.out.println("Fullname = " + fullname);
55465629
55475630 // Does not work on Windows due to C:
....@@ -5554,7 +5637,7 @@
55545637
55555638 if (split.length == 0)
55565639 {
5557
- return "";
5640
+ return fullname.pigment = "";
55585641 }
55595642
55605643 if (split.length <= 2)
....@@ -5562,22 +5645,27 @@
55625645 if (fullname.name.endsWith(":"))
55635646 {
55645647 // Windows
5565
- return fullname.name.substring(0, fullname.name.length()-1);
5648
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
55665649 }
55675650
5568
- return split[0];
5651
+ return fullname.pigment = split[0];
55695652 }
55705653
55715654 // Windows
55725655 assert(split.length == 4);
55735656
5574
- return split[0] + ":" + split[1];
5657
+ return fullname.pigment = split[0] + ":" + split[1];
55755658 }
55765659
55775660 static String GetBump(cTexture fullname)
55785661 {
55795662 if (fullname == null)
55805663 return "";
5664
+
5665
+ if (fullname.bump != null)
5666
+ {
5667
+ return fullname.bump;
5668
+ }
55815669
55825670 // System.out.println("Fullname = " + fullname);
55835671 // Does not work on Windows due to C:
....@@ -5589,12 +5677,12 @@
55895677
55905678 if (split.length == 0)
55915679 {
5592
- return "";
5680
+ return fullname.bump = "";
55935681 }
55945682
55955683 if (split.length == 1)
55965684 {
5597
- return "";
5685
+ return fullname.bump = "";
55985686 }
55995687
56005688 if (split.length == 2)
....@@ -5602,16 +5690,16 @@
56025690 if (fullname.name.endsWith(":"))
56035691 {
56045692 // Windows
5605
- return "";
5693
+ return fullname.bump = "";
56065694 }
56075695
5608
- return split[1];
5696
+ return fullname.bump = split[1];
56095697 }
56105698
56115699 // Windows
56125700 assert(split.length == 4);
56135701
5614
- return split[2] + ":" + split[3];
5702
+ return fullname.bump = split[2] + ":" + split[3];
56155703 }
56165704
56175705 String GetPigmentTexture()
....@@ -5694,6 +5782,9 @@
56945782 texname = "";
56955783
56965784 GetTextures().name = texname + ":" + GetBump(GetTextures());
5785
+
5786
+ GetTextures().pigment = null;
5787
+
56975788 Touch();
56985789 }
56995790
....@@ -5766,6 +5857,8 @@
57665857 texname = "";
57675858
57685859 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
5860
+
5861
+ GetTextures().bump = null;
57695862
57705863 Touch();
57715864 }
....@@ -5909,8 +6002,10 @@
59096002 if (support != null)
59106003 support = support;
59116004
5912
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5913
- 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.
59146009
59156010 if (!usecalllists && bRep != null && bRep.displaylist > 0)
59166011 {
....@@ -5920,8 +6015,9 @@
59206015 // usecalllists &= !(parent instanceof RandomNode);
59216016 // usecalllists = false;
59226017
5923
- if (GetBRep() != null)
5924
- usecalllists = usecalllists;
6018
+ if (display.DrawMode() == display.SHADOW)
6019
+ //GetBRep() != null)
6020
+ usecalllists = !!usecalllists;
59256021 //System.out.println("draw " + this);
59266022 //new Exception().printStackTrace();
59276023
....@@ -5943,7 +6039,7 @@
59436039 if (!(this instanceof Composite))
59446040 touched = false;
59456041 //if (displaylist == -1 && usecalllists)
5946
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
6042
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
59476043 {
59486044 bRep.displaylist = display.GenList();
59496045 assert(bRep.displaylist != 0);
....@@ -5954,7 +6050,7 @@
59546050
59556051 //System.out.println("\tnew list " + list);
59566052 //gl.glDrawBuffer(gl.GL_NONE);
5957
- if (usecalllists)
6053
+ if (usecalllists && bRep.displaylist > 0)
59586054 {
59596055 // System.err.println("new list " + bRep.displaylist + " for " + this);
59606056 display.NewList(bRep.displaylist);
....@@ -5963,7 +6059,7 @@
59636059 CallList(display, root, selected, blocked);
59646060
59656061 // compiled = true;
5966
- if (usecalllists)
6062
+ if (usecalllists && bRep.displaylist > 0)
59676063 {
59686064 // System.err.println("end list " + bRep.displaylist + " for " + this);
59696065 display.EndList();
....@@ -7367,7 +7463,7 @@
73677463 boundary.y = spot.y - 30;
73687464 boundary.width = spot.width + 60;
73697465 boundary.height = spot.height + 60;
7370
- clickInfo.g.setColor(Color.red);
7466
+ clickInfo.g.setColor(Color.white);
73717467 int spotw = spot.x + spot.width;
73727468 int spoth = spot.y + spot.height;
73737469 clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
....@@ -7387,7 +7483,29 @@
73877483 // {
73887484 // CameraPane.Ymax = spoth;
73897485 // }
7390
- 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);
73917509 spotw = spot.x + spot.width;
73927510 spoth = spot.y + spot.height;
73937511 clickInfo.g.setColor(Color.cyan);
....@@ -7408,28 +7526,7 @@
74087526 // {
74097527 // CameraPane.Ymax = spoth;
74107528 // }
7411
- // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7412
- //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7413
- spot.translate(0, -32);
7414
- clickInfo.g.setColor(Color.yellow);
7415
- clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
74167529 clickInfo.g.setColor(Color.green);
7417
-// if (CameraPane.Xmin > spot.x)
7418
-// {
7419
-// CameraPane.Xmin = spot.x;
7420
-// }
7421
-// if (CameraPane.Xmax < spotw)
7422
-// {
7423
-// CameraPane.Xmax = spotw;
7424
-// }
7425
-// if (CameraPane.Ymin > spot.y)
7426
-// {
7427
-// CameraPane.Ymin = spot.y;
7428
-// }
7429
-// if (CameraPane.Ymax < spoth)
7430
-// {
7431
-// CameraPane.Ymax = spoth;
7432
-// }
74337530 clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
74347531 (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
74357532 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
....@@ -7488,12 +7585,14 @@
74887585 retval = true;
74897586 }
74907587 spot.translate(0, 32);
7588
+ spot.translate(32, 0);
7589
+ spot.translate(0, 32);
74917590 if (spot.contains(clickInfo.x, clickInfo.y))
74927591 {
74937592 hitSomething = hitScale;
74947593
74957594 double scale = 0.005f * clickInfo.camera.Distance();
7496
- double hScale = (double) (clickInfo.x - centerPt.x) / 32;
7595
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
74977596 double sign = 1;
74987597 if (hScale < 0)
74997598 {
....@@ -7505,7 +7604,7 @@
75057604 //hScale = 0.01;
75067605 }
75077606
7508
- double vScale = (double) (clickInfo.y - centerPt.y) / 32;
7607
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
75097608 sign = 1;
75107609 if (vScale < 0)
75117610 {
....@@ -7720,7 +7819,7 @@
77207819 break;
77217820
77227821 case hitScale: // scale
7723
- double hScale = (double) (clickInfo.x - centerPt.x) / 32;
7822
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
77247823 double sign = 1;
77257824 if (hScale < 0)
77267825 {
....@@ -7732,7 +7831,7 @@
77327831 //hScale = 0.01;
77337832 }
77347833
7735
- double vScale = (double) (clickInfo.y - centerPt.y) / 32;
7834
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
77367835 sign = 1;
77377836 if (vScale < 0)
77387837 {
....@@ -7765,21 +7864,27 @@
77657864 case 3: // '\001'
77667865 if (modified || opposite)
77677866 {
7867
+ if (modified && opposite)
7868
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7869
+ else
77687870 //LA.matScale(toParent, 1, hScale, vScale);
7769
- LA.matScale(toParent, totalScale, 1, 1);
7871
+ LA.matScale(toParent, totalScale, 1, 1);
77707872 } // vScale, 1);
77717873 else
77727874 {
77737875 // EXCEPTION!
7774
- LA.matScale(toParent, totalScale, totalScale, totalScale);
7876
+ LA.matScale(toParent, 1, totalScale, totalScale);
77757877 } // vScale, 1);
77767878 break;
77777879
77787880 case 2: // '\002'
77797881 if (modified || opposite)
77807882 {
7781
- //LA.matScale(toParent, hScale, 1, vScale);
7782
- 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);
77837888 } else
77847889 {
77857890 LA.matScale(toParent, totalScale, 1, totalScale);
....@@ -7789,8 +7894,11 @@
77897894 case 1: // '\003'
77907895 if (modified || opposite)
77917896 {
7792
- //LA.matScale(toParent, hScale, vScale, 1);
7793
- 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);
77947902 } else
77957903 {
77967904 LA.matScale(toParent, totalScale, totalScale, 1);