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.
....@@ -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;
....@@ -614,7 +687,7 @@
614687 {
615688 if (maxcount != 1)
616689 {
617
- new Exception().printStackTrace();
690
+ //new Exception().printStackTrace();
618691 }
619692
620693 toParentMarked = LA.newMatrix();
....@@ -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;
....@@ -2293,11 +2369,6 @@
22932369
22942370 InitOthers();
22952371
2296
- if (this instanceof Camera)
2297
- {
2298
- material.shift = 90;
2299
- }
2300
-
23012372 material.multiply = multiply;
23022373
23032374 if (multiply)
....@@ -2438,6 +2509,11 @@
24382509 else
24392510 {
24402511 //((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");
24412517 }
24422518 }
24432519
....@@ -3541,15 +3617,47 @@
35413617
35423618 void ClearMaterials()
35433619 {
3620
+ if (blockloop)
3621
+ return;
3622
+
3623
+ blockloop = true;
3624
+
35443625 ClearMaterial();
3545
- for (int i = 0; i < size(); i++)
3626
+ for (int i = 0; i < Size(); i++)
35463627 {
3547
- Object3D child = (Object3D) reserve(i);
3628
+ Object3D child = (Object3D) get(i);
35483629 if (child == null)
35493630 continue;
35503631 child.ClearMaterials();
3551
- release(i);
35523632 }
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;
35533661 }
35543662
35553663 void FlipV(boolean flip)
....@@ -5539,6 +5647,11 @@
55395647 if (fullname == null)
55405648 return "";
55415649
5650
+ if (fullname.pigment != null)
5651
+ {
5652
+ return fullname.pigment;
5653
+ }
5654
+
55425655 // System.out.println("Fullname = " + fullname);
55435656
55445657 // Does not work on Windows due to C:
....@@ -5551,7 +5664,7 @@
55515664
55525665 if (split.length == 0)
55535666 {
5554
- return "";
5667
+ return fullname.pigment = "";
55555668 }
55565669
55575670 if (split.length <= 2)
....@@ -5559,22 +5672,27 @@
55595672 if (fullname.name.endsWith(":"))
55605673 {
55615674 // Windows
5562
- return fullname.name.substring(0, fullname.name.length()-1);
5675
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
55635676 }
55645677
5565
- return split[0];
5678
+ return fullname.pigment = split[0];
55665679 }
55675680
55685681 // Windows
55695682 assert(split.length == 4);
55705683
5571
- return split[0] + ":" + split[1];
5684
+ return fullname.pigment = split[0] + ":" + split[1];
55725685 }
55735686
55745687 static String GetBump(cTexture fullname)
55755688 {
55765689 if (fullname == null)
55775690 return "";
5691
+
5692
+ if (fullname.bump != null)
5693
+ {
5694
+ return fullname.bump;
5695
+ }
55785696
55795697 // System.out.println("Fullname = " + fullname);
55805698 // Does not work on Windows due to C:
....@@ -5586,12 +5704,12 @@
55865704
55875705 if (split.length == 0)
55885706 {
5589
- return "";
5707
+ return fullname.bump = "";
55905708 }
55915709
55925710 if (split.length == 1)
55935711 {
5594
- return "";
5712
+ return fullname.bump = "";
55955713 }
55965714
55975715 if (split.length == 2)
....@@ -5599,16 +5717,16 @@
55995717 if (fullname.name.endsWith(":"))
56005718 {
56015719 // Windows
5602
- return "";
5720
+ return fullname.bump = "";
56035721 }
56045722
5605
- return split[1];
5723
+ return fullname.bump = split[1];
56065724 }
56075725
56085726 // Windows
56095727 assert(split.length == 4);
56105728
5611
- return split[2] + ":" + split[3];
5729
+ return fullname.bump = split[2] + ":" + split[3];
56125730 }
56135731
56145732 String GetPigmentTexture()
....@@ -5691,6 +5809,9 @@
56915809 texname = "";
56925810
56935811 GetTextures().name = texname + ":" + GetBump(GetTextures());
5812
+
5813
+ GetTextures().pigment = null;
5814
+
56945815 Touch();
56955816 }
56965817
....@@ -5763,6 +5884,8 @@
57635884 texname = "";
57645885
57655886 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
5887
+
5888
+ GetTextures().bump = null;
57665889
57675890 Touch();
57685891 }
....@@ -5906,8 +6029,10 @@
59066029 if (support != null)
59076030 support = support;
59086031
5909
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5910
- boolean usecalllists = !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.
59116036
59126037 if (!usecalllists && bRep != null && bRep.displaylist > 0)
59136038 {
....@@ -5917,8 +6042,9 @@
59176042 // usecalllists &= !(parent instanceof RandomNode);
59186043 // usecalllists = false;
59196044
5920
- if (GetBRep() != null)
5921
- usecalllists = usecalllists;
6045
+ if (display.DrawMode() == display.SHADOW)
6046
+ //GetBRep() != null)
6047
+ usecalllists = !!usecalllists;
59226048 //System.out.println("draw " + this);
59236049 //new Exception().printStackTrace();
59246050
....@@ -5940,7 +6066,7 @@
59406066 if (!(this instanceof Composite))
59416067 touched = false;
59426068 //if (displaylist == -1 && usecalllists)
5943
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
6069
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
59446070 {
59456071 bRep.displaylist = display.GenList();
59466072 assert(bRep.displaylist != 0);
....@@ -5951,7 +6077,7 @@
59516077
59526078 //System.out.println("\tnew list " + list);
59536079 //gl.glDrawBuffer(gl.GL_NONE);
5954
- if (usecalllists)
6080
+ if (usecalllists && bRep.displaylist > 0)
59556081 {
59566082 // System.err.println("new list " + bRep.displaylist + " for " + this);
59576083 display.NewList(bRep.displaylist);
....@@ -5960,7 +6086,7 @@
59606086 CallList(display, root, selected, blocked);
59616087
59626088 // compiled = true;
5963
- if (usecalllists)
6089
+ if (usecalllists && bRep.displaylist > 0)
59646090 {
59656091 // System.err.println("end list " + bRep.displaylist + " for " + this);
59666092 display.EndList();
....@@ -7364,7 +7490,7 @@
73647490 boundary.y = spot.y - 30;
73657491 boundary.width = spot.width + 60;
73667492 boundary.height = spot.height + 60;
7367
- clickInfo.g.setColor(Color.red);
7493
+ clickInfo.g.setColor(Color.white);
73687494 int spotw = spot.x + spot.width;
73697495 int spoth = spot.y + spot.height;
73707496 clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
....@@ -7384,7 +7510,29 @@
73847510 // {
73857511 // CameraPane.Ymax = spoth;
73867512 // }
7387
- 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);
73887536 spotw = spot.x + spot.width;
73897537 spoth = spot.y + spot.height;
73907538 clickInfo.g.setColor(Color.cyan);
....@@ -7405,28 +7553,7 @@
74057553 // {
74067554 // CameraPane.Ymax = spoth;
74077555 // }
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);
74137556 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
-// }
74307557 clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
74317558 (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
74327559 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
....@@ -7485,12 +7612,14 @@
74857612 retval = true;
74867613 }
74877614 spot.translate(0, 32);
7615
+ spot.translate(32, 0);
7616
+ spot.translate(0, 32);
74887617 if (spot.contains(clickInfo.x, clickInfo.y))
74897618 {
74907619 hitSomething = hitScale;
74917620
74927621 double scale = 0.005f * clickInfo.camera.Distance();
7493
- double hScale = (double) (clickInfo.x /*- centerPt.x*/) / 32;
7622
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
74947623 double sign = 1;
74957624 if (hScale < 0)
74967625 {
....@@ -7502,7 +7631,7 @@
75027631 //hScale = 0.01;
75037632 }
75047633
7505
- double vScale = (double) (clickInfo.y /*- centerPt.y*/) / 32;
7634
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
75067635 sign = 1;
75077636 if (vScale < 0)
75087637 {
....@@ -7582,7 +7711,9 @@
75827711
75837712 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
75847713
7585
- if (modified || opposite)
7714
+ // Modified could snap
7715
+ if (//modified ||
7716
+ opposite)
75867717 {
75877718 //assert(false);
75887719 /*
....@@ -7676,7 +7807,7 @@
76767807
76777808 if (modified)
76787809 {
7679
- // Rotate 90 degrees
7810
+ // Rotate 45 degrees
76807811 angle /= (Math.PI / 4);
76817812 angle = Math.floor(angle + 0.5);
76827813 angle *= (Math.PI / 4);
....@@ -7717,7 +7848,7 @@
77177848 break;
77187849
77197850 case hitScale: // scale
7720
- double hScale = (double) (clickInfo.x /*- centerPt.x*/) / 32;
7851
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
77217852 double sign = 1;
77227853 if (hScale < 0)
77237854 {
....@@ -7729,7 +7860,7 @@
77297860 //hScale = 0.01;
77307861 }
77317862
7732
- double vScale = (double) (clickInfo.y /*- centerPt.y*/) / 32;
7863
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
77337864 sign = 1;
77347865 if (vScale < 0)
77357866 {
....@@ -7762,21 +7893,27 @@
77627893 case 3: // '\001'
77637894 if (modified || opposite)
77647895 {
7896
+ if (modified) // && opposite)
7897
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7898
+ else
77657899 //LA.matScale(toParent, 1, hScale, vScale);
7766
- LA.matScale(toParent, totalScale, 1, 1);
7900
+ LA.matScale(toParent, totalScale, 1, 1);
77677901 } // vScale, 1);
77687902 else
77697903 {
77707904 // EXCEPTION!
7771
- LA.matScale(toParent, totalScale, totalScale, totalScale);
7905
+ LA.matScale(toParent, 1, totalScale, totalScale);
77727906 } // vScale, 1);
77737907 break;
77747908
77757909 case 2: // '\002'
77767910 if (modified || opposite)
77777911 {
7778
- //LA.matScale(toParent, hScale, 1, vScale);
7779
- 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);
77807917 } else
77817918 {
77827919 LA.matScale(toParent, totalScale, 1, totalScale);
....@@ -7786,8 +7923,11 @@
77867923 case 1: // '\003'
77877924 if (modified || opposite)
77887925 {
7789
- //LA.matScale(toParent, hScale, vScale, 1);
7790
- 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);
77917931 } else
77927932 {
77937933 LA.matScale(toParent, totalScale, totalScale, 1);