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.
....@@ -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
....@@ -3544,15 +3622,47 @@
35443622
35453623 void ClearMaterials()
35463624 {
3625
+ if (blockloop)
3626
+ return;
3627
+
3628
+ blockloop = true;
3629
+
35473630 ClearMaterial();
3548
- for (int i = 0; i < size(); i++)
3631
+ for (int i = 0; i < Size(); i++)
35493632 {
3550
- Object3D child = (Object3D) reserve(i);
3633
+ Object3D child = (Object3D) get(i);
35513634 if (child == null)
35523635 continue;
35533636 child.ClearMaterials();
3554
- release(i);
35553637 }
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;
35563666 }
35573667
35583668 void FlipV(boolean flip)
....@@ -5542,6 +5652,11 @@
55425652 if (fullname == null)
55435653 return "";
55445654
5655
+ if (fullname.pigment != null)
5656
+ {
5657
+ return fullname.pigment;
5658
+ }
5659
+
55455660 // System.out.println("Fullname = " + fullname);
55465661
55475662 // Does not work on Windows due to C:
....@@ -5554,7 +5669,7 @@
55545669
55555670 if (split.length == 0)
55565671 {
5557
- return "";
5672
+ return fullname.pigment = "";
55585673 }
55595674
55605675 if (split.length <= 2)
....@@ -5562,22 +5677,27 @@
55625677 if (fullname.name.endsWith(":"))
55635678 {
55645679 // Windows
5565
- return fullname.name.substring(0, fullname.name.length()-1);
5680
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
55665681 }
55675682
5568
- return split[0];
5683
+ return fullname.pigment = split[0];
55695684 }
55705685
55715686 // Windows
55725687 assert(split.length == 4);
55735688
5574
- return split[0] + ":" + split[1];
5689
+ return fullname.pigment = split[0] + ":" + split[1];
55755690 }
55765691
55775692 static String GetBump(cTexture fullname)
55785693 {
55795694 if (fullname == null)
55805695 return "";
5696
+
5697
+ if (fullname.bump != null)
5698
+ {
5699
+ return fullname.bump;
5700
+ }
55815701
55825702 // System.out.println("Fullname = " + fullname);
55835703 // Does not work on Windows due to C:
....@@ -5589,12 +5709,12 @@
55895709
55905710 if (split.length == 0)
55915711 {
5592
- return "";
5712
+ return fullname.bump = "";
55935713 }
55945714
55955715 if (split.length == 1)
55965716 {
5597
- return "";
5717
+ return fullname.bump = "";
55985718 }
55995719
56005720 if (split.length == 2)
....@@ -5602,16 +5722,16 @@
56025722 if (fullname.name.endsWith(":"))
56035723 {
56045724 // Windows
5605
- return "";
5725
+ return fullname.bump = "";
56065726 }
56075727
5608
- return split[1];
5728
+ return fullname.bump = split[1];
56095729 }
56105730
56115731 // Windows
56125732 assert(split.length == 4);
56135733
5614
- return split[2] + ":" + split[3];
5734
+ return fullname.bump = split[2] + ":" + split[3];
56155735 }
56165736
56175737 String GetPigmentTexture()
....@@ -5694,6 +5814,9 @@
56945814 texname = "";
56955815
56965816 GetTextures().name = texname + ":" + GetBump(GetTextures());
5817
+
5818
+ GetTextures().pigment = null;
5819
+
56975820 Touch();
56985821 }
56995822
....@@ -5766,6 +5889,8 @@
57665889 texname = "";
57675890
57685891 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
5892
+
5893
+ GetTextures().bump = null;
57695894
57705895 Touch();
57715896 }
....@@ -5909,8 +6034,10 @@
59096034 if (support != null)
59106035 support = support;
59116036
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);
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.
59146041
59156042 if (!usecalllists && bRep != null && bRep.displaylist > 0)
59166043 {
....@@ -5920,8 +6047,9 @@
59206047 // usecalllists &= !(parent instanceof RandomNode);
59216048 // usecalllists = false;
59226049
5923
- if (GetBRep() != null)
5924
- usecalllists = usecalllists;
6050
+ if (display.DrawMode() == display.SHADOW)
6051
+ //GetBRep() != null)
6052
+ usecalllists = !!usecalllists;
59256053 //System.out.println("draw " + this);
59266054 //new Exception().printStackTrace();
59276055
....@@ -5943,7 +6071,7 @@
59436071 if (!(this instanceof Composite))
59446072 touched = false;
59456073 //if (displaylist == -1 && usecalllists)
5946
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
6074
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
59476075 {
59486076 bRep.displaylist = display.GenList();
59496077 assert(bRep.displaylist != 0);
....@@ -5954,7 +6082,7 @@
59546082
59556083 //System.out.println("\tnew list " + list);
59566084 //gl.glDrawBuffer(gl.GL_NONE);
5957
- if (usecalllists)
6085
+ if (usecalllists && bRep.displaylist > 0)
59586086 {
59596087 // System.err.println("new list " + bRep.displaylist + " for " + this);
59606088 display.NewList(bRep.displaylist);
....@@ -5963,7 +6091,7 @@
59636091 CallList(display, root, selected, blocked);
59646092
59656093 // compiled = true;
5966
- if (usecalllists)
6094
+ if (usecalllists && bRep.displaylist > 0)
59676095 {
59686096 // System.err.println("end list " + bRep.displaylist + " for " + this);
59696097 display.EndList();
....@@ -7367,7 +7495,7 @@
73677495 boundary.y = spot.y - 30;
73687496 boundary.width = spot.width + 60;
73697497 boundary.height = spot.height + 60;
7370
- clickInfo.g.setColor(Color.red);
7498
+ clickInfo.g.setColor(Color.white);
73717499 int spotw = spot.x + spot.width;
73727500 int spoth = spot.y + spot.height;
73737501 clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
....@@ -7387,7 +7515,29 @@
73877515 // {
73887516 // CameraPane.Ymax = spoth;
73897517 // }
7390
- 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);
73917541 spotw = spot.x + spot.width;
73927542 spoth = spot.y + spot.height;
73937543 clickInfo.g.setColor(Color.cyan);
....@@ -7408,28 +7558,7 @@
74087558 // {
74097559 // CameraPane.Ymax = spoth;
74107560 // }
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);
74167561 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
-// }
74337562 clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
74347563 (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
74357564 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
....@@ -7488,12 +7617,14 @@
74887617 retval = true;
74897618 }
74907619 spot.translate(0, 32);
7620
+ spot.translate(32, 0);
7621
+ spot.translate(0, 32);
74917622 if (spot.contains(clickInfo.x, clickInfo.y))
74927623 {
74937624 hitSomething = hitScale;
74947625
74957626 double scale = 0.005f * clickInfo.camera.Distance();
7496
- double hScale = (double) (clickInfo.x - centerPt.x) / 32;
7627
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
74977628 double sign = 1;
74987629 if (hScale < 0)
74997630 {
....@@ -7505,7 +7636,7 @@
75057636 //hScale = 0.01;
75067637 }
75077638
7508
- double vScale = (double) (clickInfo.y - centerPt.y) / 32;
7639
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
75097640 sign = 1;
75107641 if (vScale < 0)
75117642 {
....@@ -7720,7 +7851,7 @@
77207851 break;
77217852
77227853 case hitScale: // scale
7723
- double hScale = (double) (clickInfo.x - centerPt.x) / 32;
7854
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
77247855 double sign = 1;
77257856 if (hScale < 0)
77267857 {
....@@ -7732,7 +7863,7 @@
77327863 //hScale = 0.01;
77337864 }
77347865
7735
- double vScale = (double) (clickInfo.y - centerPt.y) / 32;
7866
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
77367867 sign = 1;
77377868 if (vScale < 0)
77387869 {
....@@ -7765,21 +7896,27 @@
77657896 case 3: // '\001'
77667897 if (modified || opposite)
77677898 {
7899
+ if (modified && opposite)
7900
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7901
+ else
77687902 //LA.matScale(toParent, 1, hScale, vScale);
7769
- LA.matScale(toParent, totalScale, 1, 1);
7903
+ LA.matScale(toParent, totalScale, 1, 1);
77707904 } // vScale, 1);
77717905 else
77727906 {
77737907 // EXCEPTION!
7774
- LA.matScale(toParent, totalScale, totalScale, totalScale);
7908
+ LA.matScale(toParent, 1, totalScale, totalScale);
77757909 } // vScale, 1);
77767910 break;
77777911
77787912 case 2: // '\002'
77797913 if (modified || opposite)
77807914 {
7781
- //LA.matScale(toParent, hScale, 1, vScale);
7782
- 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);
77837920 } else
77847921 {
77857922 LA.matScale(toParent, totalScale, 1, totalScale);
....@@ -7789,8 +7926,11 @@
77897926 case 1: // '\003'
77907927 if (modified || opposite)
77917928 {
7792
- //LA.matScale(toParent, hScale, vScale, 1);
7793
- 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);
77947934 } else
77957935 {
77967936 LA.matScale(toParent, totalScale, totalScale, 1);