Normand Briere
2019-08-23 60cec91731a350fe67e9b5ffe7a00d70e9026314
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;
....@@ -617,7 +687,7 @@
617687 {
618688 if (maxcount != 1)
619689 {
620
- new Exception().printStackTrace();
690
+ //new Exception().printStackTrace();
621691 }
622692
623693 toParentMarked = LA.newMatrix();
....@@ -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;
....@@ -2296,11 +2369,6 @@
22962369
22972370 InitOthers();
22982371
2299
- if (this instanceof Camera)
2300
- {
2301
- material.shift = 90;
2302
- }
2303
-
23042372 material.multiply = multiply;
23052373
23062374 if (multiply)
....@@ -2441,6 +2509,11 @@
24412509 else
24422510 {
24432511 //((ObjEditor)editWindow).SetupUI2(null);
2512
+ if (objectUI != null)
2513
+ ((ObjEditor)objectUI).pinButton.setSelected(pinned);
2514
+ else
2515
+ //new Exception().printStackTrace();
2516
+ System.err.println("objectUI is null");
24442517 }
24452518 }
24462519
....@@ -3544,15 +3617,47 @@
35443617
35453618 void ClearMaterials()
35463619 {
3620
+ if (blockloop)
3621
+ return;
3622
+
3623
+ blockloop = true;
3624
+
35473625 ClearMaterial();
3548
- for (int i = 0; i < size(); i++)
3626
+ for (int i = 0; i < Size(); i++)
35493627 {
3550
- Object3D child = (Object3D) reserve(i);
3628
+ Object3D child = (Object3D) get(i);
35513629 if (child == null)
35523630 continue;
35533631 child.ClearMaterials();
3554
- release(i);
35553632 }
3633
+
3634
+ blockloop = false;
3635
+ }
3636
+
3637
+ void ClearVersionList()
3638
+ {
3639
+ this.versionlist = null;
3640
+ this.versionindex = -1;
3641
+ this.versiontable = null;
3642
+ }
3643
+
3644
+ void ClearVersions()
3645
+ {
3646
+ if (blockloop)
3647
+ return;
3648
+
3649
+ blockloop = true;
3650
+
3651
+ ClearVersionList();
3652
+ for (int i = 0; i < Size(); i++)
3653
+ {
3654
+ Object3D child = (Object3D) get(i);
3655
+ if (child == null)
3656
+ continue;
3657
+ child.ClearVersions();
3658
+ }
3659
+
3660
+ blockloop = false;
35563661 }
35573662
35583663 void FlipV(boolean flip)
....@@ -5542,6 +5647,11 @@
55425647 if (fullname == null)
55435648 return "";
55445649
5650
+ if (fullname.pigment != null)
5651
+ {
5652
+ return fullname.pigment;
5653
+ }
5654
+
55455655 // System.out.println("Fullname = " + fullname);
55465656
55475657 // Does not work on Windows due to C:
....@@ -5554,7 +5664,7 @@
55545664
55555665 if (split.length == 0)
55565666 {
5557
- return "";
5667
+ return fullname.pigment = "";
55585668 }
55595669
55605670 if (split.length <= 2)
....@@ -5562,22 +5672,27 @@
55625672 if (fullname.name.endsWith(":"))
55635673 {
55645674 // Windows
5565
- return fullname.name.substring(0, fullname.name.length()-1);
5675
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
55665676 }
55675677
5568
- return split[0];
5678
+ return fullname.pigment = split[0];
55695679 }
55705680
55715681 // Windows
55725682 assert(split.length == 4);
55735683
5574
- return split[0] + ":" + split[1];
5684
+ return fullname.pigment = split[0] + ":" + split[1];
55755685 }
55765686
55775687 static String GetBump(cTexture fullname)
55785688 {
55795689 if (fullname == null)
55805690 return "";
5691
+
5692
+ if (fullname.bump != null)
5693
+ {
5694
+ return fullname.bump;
5695
+ }
55815696
55825697 // System.out.println("Fullname = " + fullname);
55835698 // Does not work on Windows due to C:
....@@ -5589,12 +5704,12 @@
55895704
55905705 if (split.length == 0)
55915706 {
5592
- return "";
5707
+ return fullname.bump = "";
55935708 }
55945709
55955710 if (split.length == 1)
55965711 {
5597
- return "";
5712
+ return fullname.bump = "";
55985713 }
55995714
56005715 if (split.length == 2)
....@@ -5602,16 +5717,16 @@
56025717 if (fullname.name.endsWith(":"))
56035718 {
56045719 // Windows
5605
- return "";
5720
+ return fullname.bump = "";
56065721 }
56075722
5608
- return split[1];
5723
+ return fullname.bump = split[1];
56095724 }
56105725
56115726 // Windows
56125727 assert(split.length == 4);
56135728
5614
- return split[2] + ":" + split[3];
5729
+ return fullname.bump = split[2] + ":" + split[3];
56155730 }
56165731
56175732 String GetPigmentTexture()
....@@ -5694,6 +5809,9 @@
56945809 texname = "";
56955810
56965811 GetTextures().name = texname + ":" + GetBump(GetTextures());
5812
+
5813
+ GetTextures().pigment = null;
5814
+
56975815 Touch();
56985816 }
56995817
....@@ -5766,6 +5884,8 @@
57665884 texname = "";
57675885
57685886 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
5887
+
5888
+ GetTextures().bump = null;
57695889
57705890 Touch();
57715891 }
....@@ -5909,8 +6029,10 @@
59096029 if (support != null)
59106030 support = support;
59116031
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);
6032
+ boolean usecalllists = !IsLive() && IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
6033
+ //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
6034
+
6035
+ //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass.
59146036
59156037 if (!usecalllists && bRep != null && bRep.displaylist > 0)
59166038 {
....@@ -5920,8 +6042,9 @@
59206042 // usecalllists &= !(parent instanceof RandomNode);
59216043 // usecalllists = false;
59226044
5923
- if (GetBRep() != null)
5924
- usecalllists = usecalllists;
6045
+ if (display.DrawMode() == display.SHADOW)
6046
+ //GetBRep() != null)
6047
+ usecalllists = !!usecalllists;
59256048 //System.out.println("draw " + this);
59266049 //new Exception().printStackTrace();
59276050
....@@ -5943,7 +6066,7 @@
59436066 if (!(this instanceof Composite))
59446067 touched = false;
59456068 //if (displaylist == -1 && usecalllists)
5946
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
6069
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
59476070 {
59486071 bRep.displaylist = display.GenList();
59496072 assert(bRep.displaylist != 0);
....@@ -5954,7 +6077,7 @@
59546077
59556078 //System.out.println("\tnew list " + list);
59566079 //gl.glDrawBuffer(gl.GL_NONE);
5957
- if (usecalllists)
6080
+ if (usecalllists && bRep.displaylist > 0)
59586081 {
59596082 // System.err.println("new list " + bRep.displaylist + " for " + this);
59606083 display.NewList(bRep.displaylist);
....@@ -5963,7 +6086,7 @@
59636086 CallList(display, root, selected, blocked);
59646087
59656088 // compiled = true;
5966
- if (usecalllists)
6089
+ if (usecalllists && bRep.displaylist > 0)
59676090 {
59686091 // System.err.println("end list " + bRep.displaylist + " for " + this);
59696092 display.EndList();
....@@ -7367,7 +7490,7 @@
73677490 boundary.y = spot.y - 30;
73687491 boundary.width = spot.width + 60;
73697492 boundary.height = spot.height + 60;
7370
- clickInfo.g.setColor(Color.red);
7493
+ clickInfo.g.setColor(Color.white);
73717494 int spotw = spot.x + spot.width;
73727495 int spoth = spot.y + spot.height;
73737496 clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
....@@ -7387,7 +7510,29 @@
73877510 // {
73887511 // CameraPane.Ymax = spoth;
73897512 // }
7390
- spot.translate(32, 32);
7513
+// if (CameraPane.Xmin > spot.x)
7514
+// {
7515
+// CameraPane.Xmin = spot.x;
7516
+// }
7517
+// if (CameraPane.Xmax < spotw)
7518
+// {
7519
+// CameraPane.Xmax = spotw;
7520
+// }
7521
+// if (CameraPane.Ymin > spot.y)
7522
+// {
7523
+// CameraPane.Ymin = spot.y;
7524
+// }
7525
+// if (CameraPane.Ymax < spoth)
7526
+// {
7527
+// CameraPane.Ymax = spoth;
7528
+// }
7529
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7530
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7531
+ spot.translate(32, 0);
7532
+ clickInfo.g.setColor(Color.yellow);
7533
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7534
+
7535
+ spot.translate(32, 64);
73917536 spotw = spot.x + spot.width;
73927537 spoth = spot.y + spot.height;
73937538 clickInfo.g.setColor(Color.cyan);
....@@ -7408,28 +7553,7 @@
74087553 // {
74097554 // CameraPane.Ymax = spoth;
74107555 // }
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);
74167556 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
-// }
74337557 clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
74347558 (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
74357559 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
....@@ -7488,12 +7612,14 @@
74887612 retval = true;
74897613 }
74907614 spot.translate(0, 32);
7615
+ spot.translate(32, 0);
7616
+ spot.translate(0, 32);
74917617 if (spot.contains(clickInfo.x, clickInfo.y))
74927618 {
74937619 hitSomething = hitScale;
74947620
74957621 double scale = 0.005f * clickInfo.camera.Distance();
7496
- double hScale = (double) (clickInfo.x - centerPt.x) / 32;
7622
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
74977623 double sign = 1;
74987624 if (hScale < 0)
74997625 {
....@@ -7505,7 +7631,7 @@
75057631 //hScale = 0.01;
75067632 }
75077633
7508
- double vScale = (double) (clickInfo.y - centerPt.y) / 32;
7634
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
75097635 sign = 1;
75107636 if (vScale < 0)
75117637 {
....@@ -7585,7 +7711,9 @@
75857711
75867712 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
75877713
7588
- if (modified || opposite)
7714
+ // Modified could snap
7715
+ if (//modified ||
7716
+ opposite)
75897717 {
75907718 //assert(false);
75917719 /*
....@@ -7679,7 +7807,7 @@
76797807
76807808 if (modified)
76817809 {
7682
- // Rotate 90 degrees
7810
+ // Rotate 45 degrees
76837811 angle /= (Math.PI / 4);
76847812 angle = Math.floor(angle + 0.5);
76857813 angle *= (Math.PI / 4);
....@@ -7720,7 +7848,7 @@
77207848 break;
77217849
77227850 case hitScale: // scale
7723
- double hScale = (double) (clickInfo.x - centerPt.x) / 32;
7851
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
77247852 double sign = 1;
77257853 if (hScale < 0)
77267854 {
....@@ -7732,7 +7860,7 @@
77327860 //hScale = 0.01;
77337861 }
77347862
7735
- double vScale = (double) (clickInfo.y - centerPt.y) / 32;
7863
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
77367864 sign = 1;
77377865 if (vScale < 0)
77387866 {
....@@ -7765,21 +7893,27 @@
77657893 case 3: // '\001'
77667894 if (modified || opposite)
77677895 {
7896
+ if (modified) // && opposite)
7897
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7898
+ else
77687899 //LA.matScale(toParent, 1, hScale, vScale);
7769
- LA.matScale(toParent, totalScale, 1, 1);
7900
+ LA.matScale(toParent, totalScale, 1, 1);
77707901 } // vScale, 1);
77717902 else
77727903 {
77737904 // EXCEPTION!
7774
- LA.matScale(toParent, totalScale, totalScale, totalScale);
7905
+ LA.matScale(toParent, 1, totalScale, totalScale);
77757906 } // vScale, 1);
77767907 break;
77777908
77787909 case 2: // '\002'
77797910 if (modified || opposite)
77807911 {
7781
- //LA.matScale(toParent, hScale, 1, vScale);
7782
- LA.matScale(toParent, 1, totalScale, 1);
7912
+ if (modified) // && opposite)
7913
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7914
+ else
7915
+ //LA.matScale(toParent, hScale, 1, vScale);
7916
+ LA.matScale(toParent, 1, totalScale, 1);
77837917 } else
77847918 {
77857919 LA.matScale(toParent, totalScale, 1, totalScale);
....@@ -7789,8 +7923,11 @@
77897923 case 1: // '\003'
77907924 if (modified || opposite)
77917925 {
7792
- //LA.matScale(toParent, hScale, vScale, 1);
7793
- LA.matScale(toParent, 1, 1, totalScale);
7926
+ if (modified) // && opposite)
7927
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7928
+ else
7929
+ //LA.matScale(toParent, hScale, vScale, 1);
7930
+ LA.matScale(toParent, 1, 1, totalScale);
77947931 } else
77957932 {
77967933 LA.matScale(toParent, totalScale, totalScale, 1);