Normand Briere
2019-07-21 40f408aaee14abd85d391008b4d22977dc586b50
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
177182 Grafreed.Assert(this.bRep == o.bRep);
178
- if (this.bRep != null)
179
- assert(this.bRep.support == o.transientrep);
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
....@@ -881,7 +927,7 @@
881927
882928 if (marked && Globals.isLIVE() && live &&
883929 //TEMP21aug2018
884
- (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
930
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
885931 currentframe != Globals.framecount)
886932 {
887933 currentframe = Globals.framecount;
....@@ -893,7 +939,8 @@
893939
894940 boolean changedir = random && Math.random() < 0.01; // && !link2master;
895941
896
- if (transformcount*factor > maxcount || (step == 1 && changedir))
942
+ if (transformcount*factor >= maxcount && (rewind || random) ||
943
+ (step == 1 && changedir))
897944 {
898945 countdown = 1;
899946 delay = speedup?8:1;
....@@ -965,6 +1012,7 @@
9651012 if (material == null || material.multiply)
9661013 return true;
9671014
1015
+ // Transparent objects are dynamic because we have to sort the triangles.
9681016 return material.opacity > 0.99;
9691017 }
9701018
....@@ -1365,6 +1413,7 @@
13651413 toParent = LA.newMatrix();
13661414 fromParent = LA.newMatrix();
13671415 }
1416
+
13681417 LA.matCopy(other.toParent, toParent);
13691418 LA.matCopy(other.fromParent, fromParent);
13701419
....@@ -2386,6 +2435,10 @@
23862435 }
23872436 */
23882437 }
2438
+ else
2439
+ {
2440
+ //((ObjEditor)editWindow).SetupUI2(null);
2441
+ }
23892442 }
23902443
23912444 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2427,6 +2480,14 @@
24272480 {
24282481 editWindow.refreshContents();
24292482 }
2483
+ else
2484
+ {
2485
+ if (manipWindow != null)
2486
+ {
2487
+ manipWindow.refreshContents();
2488
+ }
2489
+ }
2490
+
24302491 //if (parent != null)
24312492 //parent.refreshEditWindow();
24322493 }
....@@ -3057,7 +3118,7 @@
30573118 {
30583119 if (bRep != null)
30593120 {
3060
- bRep.GenerateNormalsMINE();
3121
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
30613122 Touch();
30623123 }
30633124 }
....@@ -3503,7 +3564,8 @@
35033564 if (blockloop)
35043565 return;
35053566
3506
- if (marked || (bRep != null && material != null)) // borderline...
3567
+ if (//marked || // does not make sense
3568
+ (bRep != null || material != null)) // borderline...
35073569 live = h;
35083570
35093571 for (int i = 0; i < Size(); i++)
....@@ -3524,7 +3586,8 @@
35243586 return;
35253587
35263588 //if (bRep != null)
3527
- if (marked || (bRep != null && material != null)) // borderline...
3589
+ if (//marked || // does not make sense
3590
+ (bRep != null || material != null)) // borderline...
35283591 link2master = h;
35293592
35303593 for (int i = 0; i < Size(); i++)
....@@ -3544,7 +3607,8 @@
35443607 if (blockloop)
35453608 return;
35463609
3547
- if (marked || (bRep != null && material != null)) // borderline...
3610
+ if (//marked || // does not make sense
3611
+ (bRep != null || material != null)) // borderline...
35483612 hide = h;
35493613
35503614 for (int i = 0; i < Size(); i++)
....@@ -3564,7 +3628,7 @@
35643628 if (blockloop)
35653629 return;
35663630
3567
- if (bRep != null && material != null) // borderline...
3631
+ if (bRep != null || material != null) // borderline...
35683632 marked = h;
35693633
35703634 for (int i = 0; i < Size(); i++)
....@@ -3574,6 +3638,46 @@
35743638 continue;
35753639 blockloop = true;
35763640 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);
35773681 blockloop = false;
35783682 // release(i);
35793683 }
....@@ -4351,6 +4455,55 @@
43514455 }
43524456 }
43534457
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
+
43544507 void RepairTexture()
43554508 {
43564509 if (this instanceof FileObject || blockloop)
....@@ -4865,6 +5018,14 @@
48655018 }
48665019 }
48675020
5021
+ ObjEditor GetWindow()
5022
+ {
5023
+ if (editWindow != null)
5024
+ return editWindow;
5025
+
5026
+ return manipWindow;
5027
+ }
5028
+
48685029 cTreePath Select(int indexcount, boolean deselect)
48695030 {
48705031 if (hide || dontselect)
....@@ -4901,10 +5062,11 @@
49015062 if (leaf != null)
49025063 {
49035064 cTreePath tp = new cTreePath(this, leaf);
4904
- if (editWindow != null)
5065
+ ObjEditor window = GetWindow();
5066
+ if (window != null)
49055067 {
49065068 //System.out.println("editWindow = " + editWindow + " vs " + this);
4907
- editWindow.Select(tp, deselect, true);
5069
+ window.Select(tp, deselect, true);
49085070 }
49095071
49105072 return tp;
....@@ -4921,6 +5083,7 @@
49215083
49225084 if (child == null)
49235085 continue;
5086
+
49245087 if (child.HasTransparency() && child.size() != 0)
49255088 {
49265089 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4930,9 +5093,10 @@
49305093 if (leaf != null)
49315094 {
49325095 cTreePath tp = new cTreePath(this, leaf);
4933
- if (editWindow != null)
5096
+ ObjEditor window = GetWindow();
5097
+ if (window != null)
49345098 {
4935
- editWindow.Select(tp, deselect, true);
5099
+ window.Select(tp, deselect, true);
49365100 }
49375101
49385102 return tp;
....@@ -5252,6 +5416,51 @@
52525416 continue;
52535417 child.ResetDisplayList();
52545418 // release(i);
5419
+ }
5420
+
5421
+ blockloop = false;
5422
+ }
5423
+
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();
52555464 }
52565465
52575466 blockloop = false;
....@@ -5653,7 +5862,7 @@
56535862 support = support;
56545863
56555864 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5656
- boolean usecalllists = IsLive(); // 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);
56575866
56585867 if (!usecalllists && bRep != null && bRep.displaylist > 0)
56595868 {
....@@ -5674,7 +5883,7 @@
56745883
56755884 if (!selectmode && //display.DrawMode() != display.SELECTION &&
56765885 //(touched || (bRep != null && bRep.displaylist <= 0)))
5677
- (Globals.isLIVE() || touched && (bRep != null && bRep.displaylist <= 0)))
5886
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
56785887 {
56795888 Globals.lighttouched = true;
56805889 } // all panes...
....@@ -5806,6 +6015,7 @@
58066015 if (GetBRep() != null)
58076016 {
58086017 display.NextIndex();
6018
+
58096019 // vertex color conflict : gl.glCallList(list);
58106020 DrawNode(display, root, selected);
58116021 if (this instanceof BezierPatch)
....@@ -5846,16 +6056,27 @@
58466056 tex = GetTextures();
58476057 }
58486058
5849
- boolean failed = false;
6059
+ boolean failedPigment = false;
6060
+ boolean failedBump = false;
58506061
58516062 try
58526063 {
5853
- display.BindTextures(tex, texres);
6064
+ display.BindPigmentTexture(tex, texres);
58546065 }
58556066 catch (Exception e)
58566067 {
58576068 System.err.println("FAILED: " + this);
5858
- 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;
58596080 }
58606081
58616082 if (!compiled)
....@@ -5878,8 +6099,11 @@
58786099 }
58796100 }
58806101
5881
- if (!failed)
5882
- display.ReleaseTextures(tex);
6102
+ if (!failedBump)
6103
+ display.ReleaseBumpTexture(tex);
6104
+
6105
+ if (!failedPigment)
6106
+ display.ReleasePigmentTexture(tex);
58836107
58846108 display.PopMaterial(this, selected);
58856109 }
....@@ -6252,6 +6476,11 @@
62526476 // dec 2012
62536477 new Exception().printStackTrace();
62546478 return;
6479
+ }
6480
+
6481
+ if (dontselect)
6482
+ {
6483
+ //bRep.GenerateNormalsMINE();
62556484 }
62566485
62576486 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -7144,8 +7373,8 @@
71447373 // {
71457374 // CameraPane.Ymax = spoth;
71467375 // }
7147
- info.g.drawArc(boundary.x, boundary.y,
7148
- 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);
71497378 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
71507379 // if (CameraPane.Xmin > boundary.x)
71517380 // {
....@@ -7689,6 +7918,10 @@
76897918 editWindow = null;
76907919 } // ?
76917920 }
7921
+ else
7922
+ {
7923
+ //editWindow.closeUI();
7924
+ }
76927925 }
76937926
76947927 boolean root; // patch for edit windows
....@@ -7846,6 +8079,10 @@
78468079 }
78478080
78488081 transient ObjEditor editWindow;
8082
+ transient ObjEditor manipWindow;
8083
+
8084
+ transient boolean pinned;
8085
+
78498086 transient ObjectUI objectUI;
78508087 public static int povDepth = 0;
78518088 private static cVector tbMin = new cVector();