Normand Briere
2019-07-21 5a546232b84ce65d8779d29e9171e7e2df013614
Object3D.java
....@@ -24,11 +24,14 @@
2424
2525 private UUID uuid = UUID.randomUUID();
2626
27
- // TEMPORARY for mocap undo
28
- mocap.reader.BVHReader.BVHResult bvh;
29
- Object3D skeleton;
27
+ // TEMPORARY for mocap undo. No need to be transient.
28
+ mocap.reader.BVHReader.BVHResult savebvh;
29
+ Object3D saveskeleton;
3030 //
3131
32
+ byte[] versions[];
33
+ int versionindex = -1;
34
+
3235 ScriptNode scriptnode;
3336
3437 void InitOthers()
....@@ -170,24 +173,35 @@
170173
171174 void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
172175 {
176
+ Object3D o;
177
+
173178 if (hashtable.containsKey(GetUUID()))
174179 {
175
- Object3D o = hashtable.get(GetUUID());
180
+ o = hashtable.get(GetUUID());
176181
177
- assert(this.bRep == o.bRep);
178
- if (this.bRep != null)
179
- assert(this.bRep.support == o.transientrep);
182
+ Grafreed.Assert(this.bRep == o.bRep);
183
+ //if (this.bRep != null)
184
+ // assert(this.bRep.support == o.transientrep);
185
+ if (this.support != null)
186
+ assert(this.support.bRep == o.transientrep);
187
+ }
188
+ else
189
+ {
190
+ o = new Object3D("copy of " + this.name);
180191
181
- return;
192
+ hashtable.put(GetUUID(), o);
182193 }
183194
184
- Object3D o = new Object3D();
185
-
186
- hashtable.put(GetUUID(), o);
187
-
188
- for (int i=0; i<Size(); i++)
195
+ if (!blockloop)
189196 {
190
- get(i).ExtractBigData(hashtable);
197
+ blockloop = true;
198
+
199
+ for (int i=0; i<Size(); i++)
200
+ {
201
+ get(i).ExtractBigData(hashtable);
202
+ }
203
+
204
+ blockloop = false;
191205 }
192206
193207 ExtractBigData(o);
....@@ -195,11 +209,26 @@
195209
196210 void ExtractBigData(Object3D o)
197211 {
212
+ if (o.bRep != null)
213
+ Grafreed.Assert(o.bRep == this.bRep);
214
+
198215 o.bRep = this.bRep;
199
- if (this.bRep != null)
216
+// July 2019 if (this.bRep != null)
217
+// {
218
+// o.transientrep = this.bRep.support;
219
+// o.bRep.support = null;
220
+// }
221
+ o.selection = this.selection;
222
+ o.versions = this.versions;
223
+ o.versionindex = this.versionindex;
224
+
225
+ if (this.support != null)
200226 {
201
- o.transientrep = this.bRep.support;
202
- o.bRep.support = null;
227
+ if (o.transientrep != null)
228
+ Grafreed.Assert(o.transientrep == this.support.bRep);
229
+
230
+ o.transientrep = this.support.bRep;
231
+ this.support.bRep = null;
203232 }
204233
205234 // o.support = this.support;
....@@ -223,19 +252,35 @@
223252
224253 RestoreBigData(o);
225254
226
- hashtable.remove(GetUUID());
255
+ if (blockloop)
256
+ return;
257
+
258
+ blockloop = true;
259
+
260
+ //hashtable.remove(GetUUID());
227261
228262 for (int i=0; i<Size(); i++)
229263 {
230264 get(i).RestoreBigData(hashtable);
231265 }
266
+
267
+ blockloop = false;
232268 }
233269
234270 void RestoreBigData(Object3D o)
235271 {
236272 this.bRep = o.bRep;
237
- if (this.bRep != null)
238
- this.bRep.support = o.transientrep;
273
+ if (this.support != null && o.transientrep != null)
274
+ {
275
+ this.support.bRep = o.transientrep;
276
+ }
277
+
278
+ this.selection = o.selection;
279
+
280
+ this.versions = o.versions;
281
+ this.versionindex = o.versionindex;
282
+// July 2019 if (this.bRep != null)
283
+// this.bRep.support = o.transientrep;
239284 // this.support = o.support;
240285 // this.fileparent = o.fileparent;
241286 }
....@@ -381,6 +426,7 @@
381426 }
382427
383428 boolean live = false;
429
+ transient boolean keepdontselect;
384430 boolean dontselect = false;
385431 boolean hide = false;
386432 boolean link2master = false; // performs reset support/master at each frame
....@@ -563,12 +609,14 @@
563609 toParent = LA.newMatrix();
564610 fromParent = LA.newMatrix();
565611 }
612
+
566613 if (toParentMarked == null)
567614 {
568615 if (maxcount != 1)
569616 {
570617 new Exception().printStackTrace();
571618 }
619
+
572620 toParentMarked = LA.newMatrix();
573621 fromParentMarked = LA.newMatrix();
574622 }
....@@ -879,7 +927,7 @@
879927
880928 if (marked && Globals.isLIVE() && live &&
881929 //TEMP21aug2018
882
- (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
930
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
883931 currentframe != Globals.framecount)
884932 {
885933 currentframe = Globals.framecount;
....@@ -891,7 +939,8 @@
891939
892940 boolean changedir = random && Math.random() < 0.01; // && !link2master;
893941
894
- if (transformcount*factor > maxcount || (step == 1 && changedir))
942
+ if (transformcount*factor >= maxcount && (rewind || random) ||
943
+ (step == 1 && changedir))
895944 {
896945 countdown = 1;
897946 delay = speedup?8:1;
....@@ -963,6 +1012,7 @@
9631012 if (material == null || material.multiply)
9641013 return true;
9651014
1015
+ // Transparent objects are dynamic because we have to sort the triangles.
9661016 return material.opacity > 0.99;
9671017 }
9681018
....@@ -1363,6 +1413,7 @@
13631413 toParent = LA.newMatrix();
13641414 fromParent = LA.newMatrix();
13651415 }
1416
+
13661417 LA.matCopy(other.toParent, toParent);
13671418 LA.matCopy(other.fromParent, fromParent);
13681419
....@@ -2384,6 +2435,10 @@
23842435 }
23852436 */
23862437 }
2438
+ else
2439
+ {
2440
+ //((ObjEditor)editWindow).SetupUI2(null);
2441
+ }
23872442 }
23882443
23892444 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2425,6 +2480,14 @@
24252480 {
24262481 editWindow.refreshContents();
24272482 }
2483
+ else
2484
+ {
2485
+ if (manipWindow != null)
2486
+ {
2487
+ manipWindow.refreshContents();
2488
+ }
2489
+ }
2490
+
24282491 //if (parent != null)
24292492 //parent.refreshEditWindow();
24302493 }
....@@ -3055,7 +3118,7 @@
30553118 {
30563119 if (bRep != null)
30573120 {
3058
- bRep.GenerateNormalsMINE();
3121
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
30593122 Touch();
30603123 }
30613124 }
....@@ -3501,7 +3564,8 @@
35013564 if (blockloop)
35023565 return;
35033566
3504
- if (marked || (bRep != null && material != null)) // borderline...
3567
+ if (//marked || // does not make sense
3568
+ (bRep != null || material != null)) // borderline...
35053569 live = h;
35063570
35073571 for (int i = 0; i < Size(); i++)
....@@ -3522,7 +3586,8 @@
35223586 return;
35233587
35243588 //if (bRep != null)
3525
- if (marked || (bRep != null && material != null)) // borderline...
3589
+ if (//marked || // does not make sense
3590
+ (bRep != null || material != null)) // borderline...
35263591 link2master = h;
35273592
35283593 for (int i = 0; i < Size(); i++)
....@@ -3542,7 +3607,8 @@
35423607 if (blockloop)
35433608 return;
35443609
3545
- if (marked || (bRep != null && material != null)) // borderline...
3610
+ if (//marked || // does not make sense
3611
+ (bRep != null || material != null)) // borderline...
35463612 hide = h;
35473613
35483614 for (int i = 0; i < Size(); i++)
....@@ -3562,7 +3628,7 @@
35623628 if (blockloop)
35633629 return;
35643630
3565
- if (bRep != null && material != null) // borderline...
3631
+ if (bRep != null || material != null) // borderline...
35663632 marked = h;
35673633
35683634 for (int i = 0; i < Size(); i++)
....@@ -3572,6 +3638,46 @@
35723638 continue;
35733639 blockloop = true;
35743640 child.MarkLeaves(h);
3641
+ blockloop = false;
3642
+ // release(i);
3643
+ }
3644
+ }
3645
+
3646
+ void RewindLeaves(boolean h)
3647
+ {
3648
+ if (blockloop)
3649
+ return;
3650
+
3651
+ if (bRep != null || material != null) // borderline...
3652
+ rewind = h;
3653
+
3654
+ for (int i = 0; i < Size(); i++)
3655
+ {
3656
+ Object3D child = (Object3D) get(i); // reserve(i);
3657
+ if (child == null)
3658
+ continue;
3659
+ blockloop = true;
3660
+ child.RewindLeaves(h);
3661
+ blockloop = false;
3662
+ // release(i);
3663
+ }
3664
+ }
3665
+
3666
+ void RandomLeaves(boolean h)
3667
+ {
3668
+ if (blockloop)
3669
+ return;
3670
+
3671
+ if (bRep != null || material != null) // borderline...
3672
+ random = h;
3673
+
3674
+ for (int i = 0; i < Size(); i++)
3675
+ {
3676
+ Object3D child = (Object3D) get(i); // reserve(i);
3677
+ if (child == null)
3678
+ continue;
3679
+ blockloop = true;
3680
+ child.RandomLeaves(h);
35753681 blockloop = false;
35763682 // release(i);
35773683 }
....@@ -4349,6 +4455,55 @@
43494455 }
43504456 }
43514457
4458
+ void RepairSOV()
4459
+ {
4460
+ if (blockloop)
4461
+ return;
4462
+
4463
+ String texname = this.GetPigmentTexture();
4464
+
4465
+ if (texname.startsWith("sov"))
4466
+ {
4467
+ String[] s = texname.split("/");
4468
+
4469
+ String[] sname = s[1].split("Color.pn");
4470
+
4471
+ texname = sname[0];
4472
+
4473
+ if (sname.length > 1)
4474
+ {
4475
+ texname += "Color.jpg";
4476
+ }
4477
+
4478
+ this.SetPigmentTexture("sov/" + texname);
4479
+ }
4480
+
4481
+ texname = this.GetBumpTexture();
4482
+
4483
+ if (texname.startsWith("sov"))
4484
+ {
4485
+ String[] s = texname.split("/");
4486
+
4487
+ String[] sname = s[1].split("Bump.pn");
4488
+
4489
+ texname = sname[0];
4490
+
4491
+ if (sname.length > 1)
4492
+ {
4493
+ texname += "Bump.jpg";
4494
+ }
4495
+
4496
+ this.SetBumpTexture("sov/" + texname);
4497
+ }
4498
+
4499
+ for (int i=0; i<Size(); i++)
4500
+ {
4501
+ blockloop = true;
4502
+ get(i).RepairSOV();
4503
+ blockloop = false;
4504
+ }
4505
+ }
4506
+
43524507 void RepairTexture()
43534508 {
43544509 if (this instanceof FileObject || blockloop)
....@@ -4863,6 +5018,14 @@
48635018 }
48645019 }
48655020
5021
+ ObjEditor GetWindow()
5022
+ {
5023
+ if (editWindow != null)
5024
+ return editWindow;
5025
+
5026
+ return manipWindow;
5027
+ }
5028
+
48665029 cTreePath Select(int indexcount, boolean deselect)
48675030 {
48685031 if (hide || dontselect)
....@@ -4899,10 +5062,11 @@
48995062 if (leaf != null)
49005063 {
49015064 cTreePath tp = new cTreePath(this, leaf);
4902
- if (editWindow != null)
5065
+ ObjEditor window = GetWindow();
5066
+ if (window != null)
49035067 {
49045068 //System.out.println("editWindow = " + editWindow + " vs " + this);
4905
- editWindow.Select(tp, deselect, true);
5069
+ window.Select(tp, deselect, true);
49065070 }
49075071
49085072 return tp;
....@@ -4919,6 +5083,7 @@
49195083
49205084 if (child == null)
49215085 continue;
5086
+
49225087 if (child.HasTransparency() && child.size() != 0)
49235088 {
49245089 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4928,9 +5093,10 @@
49285093 if (leaf != null)
49295094 {
49305095 cTreePath tp = new cTreePath(this, leaf);
4931
- if (editWindow != null)
5096
+ ObjEditor window = GetWindow();
5097
+ if (window != null)
49325098 {
4933
- editWindow.Select(tp, deselect, true);
5099
+ window.Select(tp, deselect, true);
49345100 }
49355101
49365102 return tp;
....@@ -5255,6 +5421,51 @@
52555421 blockloop = false;
52565422 }
52575423
5424
+ void ResetSelectable()
5425
+ {
5426
+ if (blockloop)
5427
+ return;
5428
+
5429
+ blockloop = true;
5430
+
5431
+ keepdontselect = dontselect;
5432
+ dontselect = true;
5433
+
5434
+ Object3D child;
5435
+ int nb = Size();
5436
+ for (int i = 0; i < nb; i++)
5437
+ {
5438
+ child = (Object3D) get(i);
5439
+ if (child == null)
5440
+ continue;
5441
+ child.ResetSelectable();
5442
+ }
5443
+
5444
+ blockloop = false;
5445
+ }
5446
+
5447
+ void RestoreSelectable()
5448
+ {
5449
+ if (blockloop)
5450
+ return;
5451
+
5452
+ blockloop = true;
5453
+
5454
+ dontselect = keepdontselect;
5455
+
5456
+ Object3D child;
5457
+ int nb = Size();
5458
+ for (int i = 0; i < nb; i++)
5459
+ {
5460
+ child = (Object3D) get(i);
5461
+ if (child == null)
5462
+ continue;
5463
+ child.RestoreSelectable();
5464
+ }
5465
+
5466
+ blockloop = false;
5467
+ }
5468
+
52585469 boolean IsSelected()
52595470 {
52605471 if (parent == null)
....@@ -5572,12 +5783,23 @@
55725783 boolean NeedSupport()
55735784 {
55745785 return
5575
- CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null
5786
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
55765787 // PROBLEM with CROWD!!
55775788 && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
55785789 }
55795790
55805791 static boolean DEBUG_SELECTION = false;
5792
+
5793
+ boolean IsLive()
5794
+ {
5795
+ if (live)
5796
+ return true;
5797
+
5798
+ if (parent == null)
5799
+ return false;
5800
+
5801
+ return parent.IsLive();
5802
+ }
55815803
55825804 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
55835805 {
....@@ -5640,7 +5862,7 @@
56405862 support = support;
56415863
56425864 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5643
- boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5865
+ boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
56445866
56455867 if (!usecalllists && bRep != null && bRep.displaylist > 0)
56465868 {
....@@ -5660,10 +5882,12 @@
56605882 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
56615883
56625884 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5663
- (touched || (bRep != null && bRep.displaylist <= 0)))
5885
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5886
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
56645887 {
56655888 Globals.lighttouched = true;
56665889 } // all panes...
5890
+
56675891 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
56685892 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
56695893 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5791,6 +6015,7 @@
57916015 if (GetBRep() != null)
57926016 {
57936017 display.NextIndex();
6018
+
57946019 // vertex color conflict : gl.glCallList(list);
57956020 DrawNode(display, root, selected);
57966021 if (this instanceof BezierPatch)
....@@ -5831,16 +6056,27 @@
58316056 tex = GetTextures();
58326057 }
58336058
5834
- boolean failed = false;
6059
+ boolean failedPigment = false;
6060
+ boolean failedBump = false;
58356061
58366062 try
58376063 {
5838
- display.BindTextures(tex, texres);
6064
+ display.BindPigmentTexture(tex, texres);
58396065 }
58406066 catch (Exception e)
58416067 {
58426068 System.err.println("FAILED: " + this);
5843
- failed = true;
6069
+ failedPigment = true;
6070
+ }
6071
+
6072
+ try
6073
+ {
6074
+ display.BindBumpTexture(tex, texres);
6075
+ }
6076
+ catch (Exception e)
6077
+ {
6078
+ //System.err.println("FAILED: " + this);
6079
+ failedBump = true;
58446080 }
58456081
58466082 if (!compiled)
....@@ -5863,8 +6099,11 @@
58636099 }
58646100 }
58656101
5866
- if (!failed)
5867
- display.ReleaseTextures(tex);
6102
+ if (!failedBump)
6103
+ display.ReleaseBumpTexture(tex);
6104
+
6105
+ if (!failedPigment)
6106
+ display.ReleasePigmentTexture(tex);
58686107
58696108 display.PopMaterial(this, selected);
58706109 }
....@@ -6237,6 +6476,11 @@
62376476 // dec 2012
62386477 new Exception().printStackTrace();
62396478 return;
6479
+ }
6480
+
6481
+ if (dontselect)
6482
+ {
6483
+ //bRep.GenerateNormalsMINE();
62406484 }
62416485
62426486 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -7089,7 +7333,7 @@
70897333 spot.translate(32, 32);
70907334 spotw = spot.x + spot.width;
70917335 spoth = spot.y + spot.height;
7092
- info.g.setColor(Color.blue);
7336
+ info.g.setColor(Color.cyan);
70937337 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
70947338 // if (CameraPane.Xmin > spot.x)
70957339 // {
....@@ -7107,11 +7351,12 @@
71077351 // {
71087352 // CameraPane.Ymax = spoth;
71097353 // }
7110
- // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7111
- //info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7354
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7355
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
71127356 spot.translate(0, -32);
7113
- info.g.setColor(Color.green);
7357
+ info.g.setColor(Color.yellow);
71147358 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7359
+ info.g.setColor(Color.green);
71157360 // if (CameraPane.Xmin > spot.x)
71167361 // {
71177362 // CameraPane.Xmin = spot.x;
....@@ -7128,8 +7373,8 @@
71287373 // {
71297374 // CameraPane.Ymax = spoth;
71307375 // }
7131
- info.g.drawArc(boundary.x, boundary.y,
7132
- boundary.width, boundary.height, 0, 360);
7376
+ info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY,
7377
+ (int)(boundary.width * info.W), (int)(boundary.height * info.W), 0, 360);
71337378 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
71347379 // if (CameraPane.Xmin > boundary.x)
71357380 // {
....@@ -7429,19 +7674,20 @@
74297674 switch (info.pane.RenderCamera().viewCode)
74307675 {
74317676 case 3: // '\001'
7432
- if (modified)
7677
+ if (modified || opposite)
74337678 {
74347679 //LA.matScale(toParent, 1, hScale, vScale);
74357680 LA.matScale(toParent, totalScale, 1, 1);
74367681 } // vScale, 1);
74377682 else
74387683 {
7684
+ // EXCEPTION!
74397685 LA.matScale(toParent, totalScale, totalScale, totalScale);
74407686 } // vScale, 1);
74417687 break;
74427688
74437689 case 2: // '\002'
7444
- if (modified)
7690
+ if (modified || opposite)
74457691 {
74467692 //LA.matScale(toParent, hScale, 1, vScale);
74477693 LA.matScale(toParent, 1, totalScale, 1);
....@@ -7452,7 +7698,7 @@
74527698 break;
74537699
74547700 case 1: // '\003'
7455
- if (modified)
7701
+ if (modified || opposite)
74567702 {
74577703 //LA.matScale(toParent, hScale, vScale, 1);
74587704 LA.matScale(toParent, 1, 1, totalScale);
....@@ -7672,6 +7918,10 @@
76727918 editWindow = null;
76737919 } // ?
76747920 }
7921
+ else
7922
+ {
7923
+ //editWindow.closeUI();
7924
+ }
76757925 }
76767926
76777927 boolean root; // patch for edit windows
....@@ -7829,6 +8079,10 @@
78298079 }
78308080
78318081 transient ObjEditor editWindow;
8082
+ transient ObjEditor manipWindow;
8083
+
8084
+ transient boolean pinned;
8085
+
78328086 transient ObjectUI objectUI;
78338087 public static int povDepth = 0;
78348088 private static cVector tbMin = new cVector();