Normand Briere
2019-07-18 d7a17c35c443e2cb6c09eaa3cfeaf590a571faa1
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[] = new byte[100][];
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 }
....@@ -881,7 +926,7 @@
881926
882927 if (marked && Globals.isLIVE() && live &&
883928 //TEMP21aug2018
884
- (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
929
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
885930 currentframe != Globals.framecount)
886931 {
887932 currentframe = Globals.framecount;
....@@ -893,7 +938,8 @@
893938
894939 boolean changedir = random && Math.random() < 0.01; // && !link2master;
895940
896
- if (transformcount*factor > maxcount || (step == 1 && changedir))
941
+ if (transformcount*factor >= maxcount && (rewind || random) ||
942
+ (step == 1 && changedir))
897943 {
898944 countdown = 1;
899945 delay = speedup?8:1;
....@@ -965,6 +1011,7 @@
9651011 if (material == null || material.multiply)
9661012 return true;
9671013
1014
+ // Transparent objects are dynamic because we have to sort the triangles.
9681015 return material.opacity > 0.99;
9691016 }
9701017
....@@ -1365,6 +1412,7 @@
13651412 toParent = LA.newMatrix();
13661413 fromParent = LA.newMatrix();
13671414 }
1415
+
13681416 LA.matCopy(other.toParent, toParent);
13691417 LA.matCopy(other.fromParent, fromParent);
13701418
....@@ -2386,6 +2434,10 @@
23862434 }
23872435 */
23882436 }
2437
+ else
2438
+ {
2439
+ //((ObjEditor)editWindow).SetupUI2(null);
2440
+ }
23892441 }
23902442
23912443 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2427,6 +2479,14 @@
24272479 {
24282480 editWindow.refreshContents();
24292481 }
2482
+ else
2483
+ {
2484
+ if (manipWindow != null)
2485
+ {
2486
+ manipWindow.refreshContents();
2487
+ }
2488
+ }
2489
+
24302490 //if (parent != null)
24312491 //parent.refreshEditWindow();
24322492 }
....@@ -3503,7 +3563,8 @@
35033563 if (blockloop)
35043564 return;
35053565
3506
- if (marked || (bRep != null && material != null)) // borderline...
3566
+ if (//marked || // does not make sense
3567
+ (bRep != null || material != null)) // borderline...
35073568 live = h;
35083569
35093570 for (int i = 0; i < Size(); i++)
....@@ -3524,7 +3585,8 @@
35243585 return;
35253586
35263587 //if (bRep != null)
3527
- if (marked || (bRep != null && material != null)) // borderline...
3588
+ if (//marked || // does not make sense
3589
+ (bRep != null || material != null)) // borderline...
35283590 link2master = h;
35293591
35303592 for (int i = 0; i < Size(); i++)
....@@ -3544,7 +3606,8 @@
35443606 if (blockloop)
35453607 return;
35463608
3547
- if (marked || (bRep != null && material != null)) // borderline...
3609
+ if (//marked || // does not make sense
3610
+ (bRep != null || material != null)) // borderline...
35483611 hide = h;
35493612
35503613 for (int i = 0; i < Size(); i++)
....@@ -3564,7 +3627,7 @@
35643627 if (blockloop)
35653628 return;
35663629
3567
- if (bRep != null && material != null) // borderline...
3630
+ if (bRep != null || material != null) // borderline...
35683631 marked = h;
35693632
35703633 for (int i = 0; i < Size(); i++)
....@@ -3574,6 +3637,46 @@
35743637 continue;
35753638 blockloop = true;
35763639 child.MarkLeaves(h);
3640
+ blockloop = false;
3641
+ // release(i);
3642
+ }
3643
+ }
3644
+
3645
+ void RewindLeaves(boolean h)
3646
+ {
3647
+ if (blockloop)
3648
+ return;
3649
+
3650
+ if (bRep != null || material != null) // borderline...
3651
+ rewind = h;
3652
+
3653
+ for (int i = 0; i < Size(); i++)
3654
+ {
3655
+ Object3D child = (Object3D) get(i); // reserve(i);
3656
+ if (child == null)
3657
+ continue;
3658
+ blockloop = true;
3659
+ child.RewindLeaves(h);
3660
+ blockloop = false;
3661
+ // release(i);
3662
+ }
3663
+ }
3664
+
3665
+ void RandomLeaves(boolean h)
3666
+ {
3667
+ if (blockloop)
3668
+ return;
3669
+
3670
+ if (bRep != null || material != null) // borderline...
3671
+ random = h;
3672
+
3673
+ for (int i = 0; i < Size(); i++)
3674
+ {
3675
+ Object3D child = (Object3D) get(i); // reserve(i);
3676
+ if (child == null)
3677
+ continue;
3678
+ blockloop = true;
3679
+ child.RandomLeaves(h);
35773680 blockloop = false;
35783681 // release(i);
35793682 }
....@@ -4351,6 +4454,55 @@
43514454 }
43524455 }
43534456
4457
+ void RepairSOV()
4458
+ {
4459
+ if (blockloop)
4460
+ return;
4461
+
4462
+ String texname = this.GetPigmentTexture();
4463
+
4464
+ if (texname.startsWith("sov"))
4465
+ {
4466
+ String[] s = texname.split("/");
4467
+
4468
+ String[] sname = s[1].split("Color.pn");
4469
+
4470
+ texname = sname[0];
4471
+
4472
+ if (sname.length > 1)
4473
+ {
4474
+ texname += "Color.jpg";
4475
+ }
4476
+
4477
+ this.SetPigmentTexture("sov/" + texname);
4478
+ }
4479
+
4480
+ texname = this.GetBumpTexture();
4481
+
4482
+ if (texname.startsWith("sov"))
4483
+ {
4484
+ String[] s = texname.split("/");
4485
+
4486
+ String[] sname = s[1].split("Bump.pn");
4487
+
4488
+ texname = sname[0];
4489
+
4490
+ if (sname.length > 1)
4491
+ {
4492
+ texname += "Bump.jpg";
4493
+ }
4494
+
4495
+ this.SetBumpTexture("sov/" + texname);
4496
+ }
4497
+
4498
+ for (int i=0; i<Size(); i++)
4499
+ {
4500
+ blockloop = true;
4501
+ get(i).RepairSOV();
4502
+ blockloop = false;
4503
+ }
4504
+ }
4505
+
43544506 void RepairTexture()
43554507 {
43564508 if (this instanceof FileObject || blockloop)
....@@ -4865,6 +5017,14 @@
48655017 }
48665018 }
48675019
5020
+ ObjEditor GetWindow()
5021
+ {
5022
+ if (editWindow != null)
5023
+ return editWindow;
5024
+
5025
+ return manipWindow;
5026
+ }
5027
+
48685028 cTreePath Select(int indexcount, boolean deselect)
48695029 {
48705030 if (hide || dontselect)
....@@ -4901,10 +5061,11 @@
49015061 if (leaf != null)
49025062 {
49035063 cTreePath tp = new cTreePath(this, leaf);
4904
- if (editWindow != null)
5064
+ ObjEditor window = GetWindow();
5065
+ if (window != null)
49055066 {
49065067 //System.out.println("editWindow = " + editWindow + " vs " + this);
4907
- editWindow.Select(tp, deselect, true);
5068
+ window.Select(tp, deselect, true);
49085069 }
49095070
49105071 return tp;
....@@ -4921,6 +5082,7 @@
49215082
49225083 if (child == null)
49235084 continue;
5085
+
49245086 if (child.HasTransparency() && child.size() != 0)
49255087 {
49265088 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4930,9 +5092,10 @@
49305092 if (leaf != null)
49315093 {
49325094 cTreePath tp = new cTreePath(this, leaf);
4933
- if (editWindow != null)
5095
+ ObjEditor window = GetWindow();
5096
+ if (window != null)
49345097 {
4935
- editWindow.Select(tp, deselect, true);
5098
+ window.Select(tp, deselect, true);
49365099 }
49375100
49385101 return tp;
....@@ -5653,7 +5816,7 @@
56535816 support = support;
56545817
56555818 //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);
5819
+ boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
56575820
56585821 if (!usecalllists && bRep != null && bRep.displaylist > 0)
56595822 {
....@@ -5674,7 +5837,7 @@
56745837
56755838 if (!selectmode && //display.DrawMode() != display.SELECTION &&
56765839 //(touched || (bRep != null && bRep.displaylist <= 0)))
5677
- (Globals.isLIVE() || touched && (bRep != null && bRep.displaylist <= 0)))
5840
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
56785841 {
56795842 Globals.lighttouched = true;
56805843 } // all panes...
....@@ -5806,6 +5969,7 @@
58065969 if (GetBRep() != null)
58075970 {
58085971 display.NextIndex();
5972
+
58095973 // vertex color conflict : gl.glCallList(list);
58105974 DrawNode(display, root, selected);
58115975 if (this instanceof BezierPatch)
....@@ -5846,16 +6010,27 @@
58466010 tex = GetTextures();
58476011 }
58486012
5849
- boolean failed = false;
6013
+ boolean failedPigment = false;
6014
+ boolean failedBump = false;
58506015
58516016 try
58526017 {
5853
- display.BindTextures(tex, texres);
6018
+ display.BindPigmentTexture(tex, texres);
58546019 }
58556020 catch (Exception e)
58566021 {
58576022 System.err.println("FAILED: " + this);
5858
- failed = true;
6023
+ failedPigment = true;
6024
+ }
6025
+
6026
+ try
6027
+ {
6028
+ display.BindBumpTexture(tex, texres);
6029
+ }
6030
+ catch (Exception e)
6031
+ {
6032
+ //System.err.println("FAILED: " + this);
6033
+ failedBump = true;
58596034 }
58606035
58616036 if (!compiled)
....@@ -5878,8 +6053,11 @@
58786053 }
58796054 }
58806055
5881
- if (!failed)
5882
- display.ReleaseTextures(tex);
6056
+ if (!failedBump)
6057
+ display.ReleaseBumpTexture(tex);
6058
+
6059
+ if (!failedPigment)
6060
+ display.ReleasePigmentTexture(tex);
58836061
58846062 display.PopMaterial(this, selected);
58856063 }
....@@ -6252,6 +6430,11 @@
62526430 // dec 2012
62536431 new Exception().printStackTrace();
62546432 return;
6433
+ }
6434
+
6435
+ if (dontselect)
6436
+ {
6437
+ //bRep.GenerateNormalsMINE();
62556438 }
62566439
62576440 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -7144,8 +7327,8 @@
71447327 // {
71457328 // CameraPane.Ymax = spoth;
71467329 // }
7147
- info.g.drawArc(boundary.x, boundary.y,
7148
- boundary.width, boundary.height, 0, 360);
7330
+ info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY,
7331
+ (int)(boundary.width * info.W), (int)(boundary.height * info.W), 0, 360);
71497332 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
71507333 // if (CameraPane.Xmin > boundary.x)
71517334 // {
....@@ -7452,7 +7635,8 @@
74527635 } // vScale, 1);
74537636 else
74547637 {
7455
- LA.matScale(toParent, 1, totalScale, totalScale);
7638
+ // EXCEPTION!
7639
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
74567640 } // vScale, 1);
74577641 break;
74587642
....@@ -7688,6 +7872,10 @@
76887872 editWindow = null;
76897873 } // ?
76907874 }
7875
+ else
7876
+ {
7877
+ //editWindow.closeUI();
7878
+ }
76917879 }
76927880
76937881 boolean root; // patch for edit windows
....@@ -7845,6 +8033,10 @@
78458033 }
78468034
78478035 transient ObjEditor editWindow;
8036
+ transient ObjEditor manipWindow;
8037
+
8038
+ transient boolean pinned;
8039
+
78488040 transient ObjectUI objectUI;
78498041 public static int povDepth = 0;
78508042 private static cVector tbMin = new cVector();