Normand Briere
2019-07-22 c570e1e38f2ff8622a71f81436654bad01cfdd5b
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)
....@@ -5564,6 +5775,38 @@
55645775 }
55655776 }
55665777
5778
+ void EmbedTextures(boolean embed)
5779
+ {
5780
+ if (blockloop)
5781
+ return;
5782
+
5783
+ //if (GetTextures() != null)
5784
+ if (embed)
5785
+ CameraPane.EmbedTextures(GetTextures());
5786
+ else
5787
+ {
5788
+ GetTextures().pigmentdata = null;
5789
+ GetTextures().bumpdata = null;
5790
+ GetTextures().pw = 0;
5791
+ GetTextures().ph = 0;
5792
+ GetTextures().bw = 0;
5793
+ GetTextures().bh = 0;
5794
+ }
5795
+
5796
+ int nb = Size();
5797
+ for (int i = 0; i < nb; i++)
5798
+ {
5799
+ Object3D child = (Object3D) get(i);
5800
+
5801
+ if (child == null)
5802
+ continue;
5803
+
5804
+ blockloop = true;
5805
+ child.EmbedTextures(embed);
5806
+ blockloop = false;
5807
+ }
5808
+ }
5809
+
55675810 void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
55685811 {
55695812 Draw(display, root, selected, blocked);
....@@ -5572,12 +5815,23 @@
55725815 boolean NeedSupport()
55735816 {
55745817 return
5575
- CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null
5818
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
55765819 // PROBLEM with CROWD!!
55775820 && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
55785821 }
55795822
55805823 static boolean DEBUG_SELECTION = false;
5824
+
5825
+ boolean IsLive()
5826
+ {
5827
+ if (live)
5828
+ return true;
5829
+
5830
+ if (parent == null)
5831
+ return false;
5832
+
5833
+ return parent.IsLive();
5834
+ }
55815835
55825836 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
55835837 {
....@@ -5640,7 +5894,7 @@
56405894 support = support;
56415895
56425896 //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);
5897
+ boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
56445898
56455899 if (!usecalllists && bRep != null && bRep.displaylist > 0)
56465900 {
....@@ -5660,10 +5914,12 @@
56605914 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
56615915
56625916 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5663
- (touched || (bRep != null && bRep.displaylist <= 0)))
5917
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5918
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
56645919 {
56655920 Globals.lighttouched = true;
56665921 } // all panes...
5922
+
56675923 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
56685924 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
56695925 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5791,6 +6047,7 @@
57916047 if (GetBRep() != null)
57926048 {
57936049 display.NextIndex();
6050
+
57946051 // vertex color conflict : gl.glCallList(list);
57956052 DrawNode(display, root, selected);
57966053 if (this instanceof BezierPatch)
....@@ -5831,16 +6088,27 @@
58316088 tex = GetTextures();
58326089 }
58336090
5834
- boolean failed = false;
6091
+ boolean failedPigment = false;
6092
+ boolean failedBump = false;
58356093
58366094 try
58376095 {
5838
- display.BindTextures(tex, texres);
6096
+ display.BindPigmentTexture(tex, texres);
58396097 }
58406098 catch (Exception e)
58416099 {
58426100 System.err.println("FAILED: " + this);
5843
- failed = true;
6101
+ failedPigment = true;
6102
+ }
6103
+
6104
+ try
6105
+ {
6106
+ display.BindBumpTexture(tex, texres);
6107
+ }
6108
+ catch (Exception e)
6109
+ {
6110
+ //System.err.println("FAILED: " + this);
6111
+ failedBump = true;
58446112 }
58456113
58466114 if (!compiled)
....@@ -5863,8 +6131,11 @@
58636131 }
58646132 }
58656133
5866
- if (!failed)
5867
- display.ReleaseTextures(tex);
6134
+ if (!failedBump)
6135
+ display.ReleaseBumpTexture(tex);
6136
+
6137
+ if (!failedPigment)
6138
+ display.ReleasePigmentTexture(tex);
58686139
58696140 display.PopMaterial(this, selected);
58706141 }
....@@ -6237,6 +6508,11 @@
62376508 // dec 2012
62386509 new Exception().printStackTrace();
62396510 return;
6511
+ }
6512
+
6513
+ if (dontselect)
6514
+ {
6515
+ //bRep.GenerateNormalsMINE();
62406516 }
62416517
62426518 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -7089,7 +7365,7 @@
70897365 spot.translate(32, 32);
70907366 spotw = spot.x + spot.width;
70917367 spoth = spot.y + spot.height;
7092
- info.g.setColor(Color.blue);
7368
+ info.g.setColor(Color.cyan);
70937369 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
70947370 // if (CameraPane.Xmin > spot.x)
70957371 // {
....@@ -7107,11 +7383,12 @@
71077383 // {
71087384 // CameraPane.Ymax = spoth;
71097385 // }
7110
- // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7111
- //info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7386
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7387
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
71127388 spot.translate(0, -32);
7113
- info.g.setColor(Color.green);
7389
+ info.g.setColor(Color.yellow);
71147390 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7391
+ info.g.setColor(Color.green);
71157392 // if (CameraPane.Xmin > spot.x)
71167393 // {
71177394 // CameraPane.Xmin = spot.x;
....@@ -7128,8 +7405,8 @@
71287405 // {
71297406 // CameraPane.Ymax = spoth;
71307407 // }
7131
- info.g.drawArc(boundary.x, boundary.y,
7132
- boundary.width, boundary.height, 0, 360);
7408
+ info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY,
7409
+ (int)(boundary.width * info.W), (int)(boundary.height * info.W), 0, 360);
71337410 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
71347411 // if (CameraPane.Xmin > boundary.x)
71357412 // {
....@@ -7429,19 +7706,20 @@
74297706 switch (info.pane.RenderCamera().viewCode)
74307707 {
74317708 case 3: // '\001'
7432
- if (modified)
7709
+ if (modified || opposite)
74337710 {
74347711 //LA.matScale(toParent, 1, hScale, vScale);
74357712 LA.matScale(toParent, totalScale, 1, 1);
74367713 } // vScale, 1);
74377714 else
74387715 {
7716
+ // EXCEPTION!
74397717 LA.matScale(toParent, totalScale, totalScale, totalScale);
74407718 } // vScale, 1);
74417719 break;
74427720
74437721 case 2: // '\002'
7444
- if (modified)
7722
+ if (modified || opposite)
74457723 {
74467724 //LA.matScale(toParent, hScale, 1, vScale);
74477725 LA.matScale(toParent, 1, totalScale, 1);
....@@ -7452,7 +7730,7 @@
74527730 break;
74537731
74547732 case 1: // '\003'
7455
- if (modified)
7733
+ if (modified || opposite)
74567734 {
74577735 //LA.matScale(toParent, hScale, vScale, 1);
74587736 LA.matScale(toParent, 1, 1, totalScale);
....@@ -7672,6 +7950,10 @@
76727950 editWindow = null;
76737951 } // ?
76747952 }
7953
+ else
7954
+ {
7955
+ //editWindow.closeUI();
7956
+ }
76757957 }
76767958
76777959 boolean root; // patch for edit windows
....@@ -7829,6 +8111,10 @@
78298111 }
78308112
78318113 transient ObjEditor editWindow;
8114
+ transient ObjEditor manipWindow;
8115
+
8116
+ transient boolean pinned;
8117
+
78328118 transient ObjectUI objectUI;
78338119 public static int povDepth = 0;
78348120 private static cVector tbMin = new cVector();