Normand Briere
2019-07-17 a5580a47d246c1272b10adba68070f6e13da5e41
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,24 @@
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
+
223
+ if (this.support != null)
200224 {
201
- o.transientrep = this.bRep.support;
202
- o.bRep.support = null;
225
+ if (o.transientrep != null)
226
+ Grafreed.Assert(o.transientrep == this.support.bRep);
227
+
228
+ o.transientrep = this.support.bRep;
229
+ this.support.bRep = null;
203230 }
204231
205232 // o.support = this.support;
....@@ -223,19 +250,32 @@
223250
224251 RestoreBigData(o);
225252
226
- hashtable.remove(GetUUID());
253
+ if (blockloop)
254
+ return;
255
+
256
+ blockloop = true;
257
+
258
+ //hashtable.remove(GetUUID());
227259
228260 for (int i=0; i<Size(); i++)
229261 {
230262 get(i).RestoreBigData(hashtable);
231263 }
264
+
265
+ blockloop = false;
232266 }
233267
234268 void RestoreBigData(Object3D o)
235269 {
236270 this.bRep = o.bRep;
237
- if (this.bRep != null)
238
- this.bRep.support = o.transientrep;
271
+ if (this.support != null && o.transientrep != null)
272
+ {
273
+ this.support.bRep = o.transientrep;
274
+ }
275
+
276
+ this.selection = o.selection;
277
+// July 2019 if (this.bRep != null)
278
+// this.bRep.support = o.transientrep;
239279 // this.support = o.support;
240280 // this.fileparent = o.fileparent;
241281 }
....@@ -881,7 +921,7 @@
881921
882922 if (marked && Globals.isLIVE() && live &&
883923 //TEMP21aug2018
884
- (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
924
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
885925 currentframe != Globals.framecount)
886926 {
887927 currentframe = Globals.framecount;
....@@ -893,7 +933,8 @@
893933
894934 boolean changedir = random && Math.random() < 0.01; // && !link2master;
895935
896
- if (transformcount*factor > maxcount || (step == 1 && changedir))
936
+ if (transformcount*factor >= maxcount && (rewind || random) ||
937
+ (step == 1 && changedir))
897938 {
898939 countdown = 1;
899940 delay = speedup?8:1;
....@@ -965,6 +1006,7 @@
9651006 if (material == null || material.multiply)
9661007 return true;
9671008
1009
+ // Transparent objects are dynamic because we have to sort the triangles.
9681010 return material.opacity > 0.99;
9691011 }
9701012
....@@ -1365,6 +1407,7 @@
13651407 toParent = LA.newMatrix();
13661408 fromParent = LA.newMatrix();
13671409 }
1410
+
13681411 LA.matCopy(other.toParent, toParent);
13691412 LA.matCopy(other.fromParent, fromParent);
13701413
....@@ -2386,6 +2429,10 @@
23862429 }
23872430 */
23882431 }
2432
+ else
2433
+ {
2434
+ //((ObjEditor)editWindow).SetupUI2(null);
2435
+ }
23892436 }
23902437
23912438 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2427,6 +2474,14 @@
24272474 {
24282475 editWindow.refreshContents();
24292476 }
2477
+ else
2478
+ {
2479
+ if (manipWindow != null)
2480
+ {
2481
+ manipWindow.refreshContents();
2482
+ }
2483
+ }
2484
+
24302485 //if (parent != null)
24312486 //parent.refreshEditWindow();
24322487 }
....@@ -3503,7 +3558,8 @@
35033558 if (blockloop)
35043559 return;
35053560
3506
- if (marked || (bRep != null && material != null)) // borderline...
3561
+ if (//marked || // does not make sense
3562
+ (bRep != null || material != null)) // borderline...
35073563 live = h;
35083564
35093565 for (int i = 0; i < Size(); i++)
....@@ -3524,7 +3580,8 @@
35243580 return;
35253581
35263582 //if (bRep != null)
3527
- if (marked || (bRep != null && material != null)) // borderline...
3583
+ if (//marked || // does not make sense
3584
+ (bRep != null || material != null)) // borderline...
35283585 link2master = h;
35293586
35303587 for (int i = 0; i < Size(); i++)
....@@ -3544,7 +3601,8 @@
35443601 if (blockloop)
35453602 return;
35463603
3547
- if (marked || (bRep != null && material != null)) // borderline...
3604
+ if (//marked || // does not make sense
3605
+ (bRep != null || material != null)) // borderline...
35483606 hide = h;
35493607
35503608 for (int i = 0; i < Size(); i++)
....@@ -3564,7 +3622,7 @@
35643622 if (blockloop)
35653623 return;
35663624
3567
- if (bRep != null && material != null) // borderline...
3625
+ if (bRep != null || material != null) // borderline...
35683626 marked = h;
35693627
35703628 for (int i = 0; i < Size(); i++)
....@@ -3574,6 +3632,46 @@
35743632 continue;
35753633 blockloop = true;
35763634 child.MarkLeaves(h);
3635
+ blockloop = false;
3636
+ // release(i);
3637
+ }
3638
+ }
3639
+
3640
+ void RewindLeaves(boolean h)
3641
+ {
3642
+ if (blockloop)
3643
+ return;
3644
+
3645
+ if (bRep != null || material != null) // borderline...
3646
+ rewind = h;
3647
+
3648
+ for (int i = 0; i < Size(); i++)
3649
+ {
3650
+ Object3D child = (Object3D) get(i); // reserve(i);
3651
+ if (child == null)
3652
+ continue;
3653
+ blockloop = true;
3654
+ child.RewindLeaves(h);
3655
+ blockloop = false;
3656
+ // release(i);
3657
+ }
3658
+ }
3659
+
3660
+ void RandomLeaves(boolean h)
3661
+ {
3662
+ if (blockloop)
3663
+ return;
3664
+
3665
+ if (bRep != null || material != null) // borderline...
3666
+ random = h;
3667
+
3668
+ for (int i = 0; i < Size(); i++)
3669
+ {
3670
+ Object3D child = (Object3D) get(i); // reserve(i);
3671
+ if (child == null)
3672
+ continue;
3673
+ blockloop = true;
3674
+ child.RandomLeaves(h);
35773675 blockloop = false;
35783676 // release(i);
35793677 }
....@@ -4351,6 +4449,55 @@
43514449 }
43524450 }
43534451
4452
+ void RepairSOV()
4453
+ {
4454
+ if (blockloop)
4455
+ return;
4456
+
4457
+ String texname = this.GetPigmentTexture();
4458
+
4459
+ if (texname.startsWith("sov"))
4460
+ {
4461
+ String[] s = texname.split("/");
4462
+
4463
+ String[] sname = s[1].split("Color.pn");
4464
+
4465
+ texname = sname[0];
4466
+
4467
+ if (sname.length > 1)
4468
+ {
4469
+ texname += "Color.jpg";
4470
+ }
4471
+
4472
+ this.SetPigmentTexture("sov/" + texname);
4473
+ }
4474
+
4475
+ texname = this.GetBumpTexture();
4476
+
4477
+ if (texname.startsWith("sov"))
4478
+ {
4479
+ String[] s = texname.split("/");
4480
+
4481
+ String[] sname = s[1].split("Bump.pn");
4482
+
4483
+ texname = sname[0];
4484
+
4485
+ if (sname.length > 1)
4486
+ {
4487
+ texname += "Bump.jpg";
4488
+ }
4489
+
4490
+ this.SetBumpTexture("sov/" + texname);
4491
+ }
4492
+
4493
+ for (int i=0; i<Size(); i++)
4494
+ {
4495
+ blockloop = true;
4496
+ get(i).RepairSOV();
4497
+ blockloop = false;
4498
+ }
4499
+ }
4500
+
43544501 void RepairTexture()
43554502 {
43564503 if (this instanceof FileObject || blockloop)
....@@ -4865,6 +5012,14 @@
48655012 }
48665013 }
48675014
5015
+ ObjEditor GetWindow()
5016
+ {
5017
+ if (editWindow != null)
5018
+ return editWindow;
5019
+
5020
+ return manipWindow;
5021
+ }
5022
+
48685023 cTreePath Select(int indexcount, boolean deselect)
48695024 {
48705025 if (hide || dontselect)
....@@ -4901,10 +5056,11 @@
49015056 if (leaf != null)
49025057 {
49035058 cTreePath tp = new cTreePath(this, leaf);
4904
- if (editWindow != null)
5059
+ ObjEditor window = GetWindow();
5060
+ if (window != null)
49055061 {
49065062 //System.out.println("editWindow = " + editWindow + " vs " + this);
4907
- editWindow.Select(tp, deselect, true);
5063
+ window.Select(tp, deselect, true);
49085064 }
49095065
49105066 return tp;
....@@ -4921,6 +5077,7 @@
49215077
49225078 if (child == null)
49235079 continue;
5080
+
49245081 if (child.HasTransparency() && child.size() != 0)
49255082 {
49265083 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4930,9 +5087,10 @@
49305087 if (leaf != null)
49315088 {
49325089 cTreePath tp = new cTreePath(this, leaf);
4933
- if (editWindow != null)
5090
+ ObjEditor window = GetWindow();
5091
+ if (window != null)
49345092 {
4935
- editWindow.Select(tp, deselect, true);
5093
+ window.Select(tp, deselect, true);
49365094 }
49375095
49385096 return tp;
....@@ -5653,7 +5811,7 @@
56535811 support = support;
56545812
56555813 //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);
5814
+ boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
56575815
56585816 if (!usecalllists && bRep != null && bRep.displaylist > 0)
56595817 {
....@@ -5674,7 +5832,7 @@
56745832
56755833 if (!selectmode && //display.DrawMode() != display.SELECTION &&
56765834 //(touched || (bRep != null && bRep.displaylist <= 0)))
5677
- (Globals.isLIVE() || touched && (bRep != null && bRep.displaylist <= 0)))
5835
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
56785836 {
56795837 Globals.lighttouched = true;
56805838 } // all panes...
....@@ -5806,6 +5964,7 @@
58065964 if (GetBRep() != null)
58075965 {
58085966 display.NextIndex();
5967
+
58095968 // vertex color conflict : gl.glCallList(list);
58105969 DrawNode(display, root, selected);
58115970 if (this instanceof BezierPatch)
....@@ -5846,16 +6005,27 @@
58466005 tex = GetTextures();
58476006 }
58486007
5849
- boolean failed = false;
6008
+ boolean failedPigment = false;
6009
+ boolean failedBump = false;
58506010
58516011 try
58526012 {
5853
- display.BindTextures(tex, texres);
6013
+ display.BindPigmentTexture(tex, texres);
58546014 }
58556015 catch (Exception e)
58566016 {
58576017 System.err.println("FAILED: " + this);
5858
- failed = true;
6018
+ failedPigment = true;
6019
+ }
6020
+
6021
+ try
6022
+ {
6023
+ display.BindBumpTexture(tex, texres);
6024
+ }
6025
+ catch (Exception e)
6026
+ {
6027
+ //System.err.println("FAILED: " + this);
6028
+ failedBump = true;
58596029 }
58606030
58616031 if (!compiled)
....@@ -5878,8 +6048,11 @@
58786048 }
58796049 }
58806050
5881
- if (!failed)
5882
- display.ReleaseTextures(tex);
6051
+ if (!failedBump)
6052
+ display.ReleaseBumpTexture(tex);
6053
+
6054
+ if (!failedPigment)
6055
+ display.ReleasePigmentTexture(tex);
58836056
58846057 display.PopMaterial(this, selected);
58856058 }
....@@ -6252,6 +6425,11 @@
62526425 // dec 2012
62536426 new Exception().printStackTrace();
62546427 return;
6428
+ }
6429
+
6430
+ if (dontselect)
6431
+ {
6432
+ //bRep.GenerateNormalsMINE();
62556433 }
62566434
62576435 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -7144,8 +7322,8 @@
71447322 // {
71457323 // CameraPane.Ymax = spoth;
71467324 // }
7147
- info.g.drawArc(boundary.x, boundary.y,
7148
- boundary.width, boundary.height, 0, 360);
7325
+ info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY,
7326
+ (int)(boundary.width * info.W), (int)(boundary.height * info.W), 0, 360);
71497327 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
71507328 // if (CameraPane.Xmin > boundary.x)
71517329 // {
....@@ -7689,6 +7867,10 @@
76897867 editWindow = null;
76907868 } // ?
76917869 }
7870
+ else
7871
+ {
7872
+ //editWindow.closeUI();
7873
+ }
76927874 }
76937875
76947876 boolean root; // patch for edit windows
....@@ -7846,6 +8028,10 @@
78468028 }
78478029
78488030 transient ObjEditor editWindow;
8031
+ transient ObjEditor manipWindow;
8032
+
8033
+ transient boolean pinned;
8034
+
78498035 transient ObjectUI objectUI;
78508036 public static int povDepth = 0;
78518037 private static cVector tbMin = new cVector();