Normand Briere
2019-07-14 bc829f47837b5a001f911542140b0b8e63c2bb0c
Object3D.java
....@@ -24,9 +24,9 @@
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
3232 ScriptNode scriptnode;
....@@ -170,24 +170,35 @@
170170
171171 void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
172172 {
173
+ Object3D o;
174
+
173175 if (hashtable.containsKey(GetUUID()))
174176 {
175
- Object3D o = hashtable.get(GetUUID());
177
+ o = hashtable.get(GetUUID());
176178
177
- assert(this.bRep == o.bRep);
178
- if (this.bRep != null)
179
- assert(this.bRep.support == o.transientrep);
179
+ Grafreed.Assert(this.bRep == o.bRep);
180
+ //if (this.bRep != null)
181
+ // assert(this.bRep.support == o.transientrep);
182
+ if (this.support != null)
183
+ assert(this.support.bRep == o.transientrep);
184
+ }
185
+ else
186
+ {
187
+ o = new Object3D("copy of " + this.name);
180188
181
- return;
189
+ hashtable.put(GetUUID(), o);
182190 }
183191
184
- Object3D o = new Object3D();
185
-
186
- hashtable.put(GetUUID(), o);
187
-
188
- for (int i=0; i<Size(); i++)
192
+ if (!blockloop)
189193 {
190
- get(i).ExtractBigData(hashtable);
194
+ blockloop = true;
195
+
196
+ for (int i=0; i<Size(); i++)
197
+ {
198
+ get(i).ExtractBigData(hashtable);
199
+ }
200
+
201
+ blockloop = false;
191202 }
192203
193204 ExtractBigData(o);
....@@ -195,11 +206,23 @@
195206
196207 void ExtractBigData(Object3D o)
197208 {
209
+ if (o.bRep != null)
210
+ Grafreed.Assert(o.bRep == this.bRep);
211
+
198212 o.bRep = this.bRep;
199
- if (this.bRep != null)
213
+// July 2019 if (this.bRep != null)
214
+// {
215
+// o.transientrep = this.bRep.support;
216
+// o.bRep.support = null;
217
+// }
218
+
219
+ if (this.support != null)
200220 {
201
- o.transientrep = this.bRep.support;
202
- o.bRep.support = null;
221
+ if (o.transientrep != null)
222
+ Grafreed.Assert(o.transientrep == this.support.bRep);
223
+
224
+ o.transientrep = this.support.bRep;
225
+ this.support.bRep = null;
203226 }
204227
205228 // o.support = this.support;
....@@ -223,19 +246,30 @@
223246
224247 RestoreBigData(o);
225248
226
- hashtable.remove(GetUUID());
249
+ if (blockloop)
250
+ return;
251
+
252
+ blockloop = true;
253
+
254
+ //hashtable.remove(GetUUID());
227255
228256 for (int i=0; i<Size(); i++)
229257 {
230258 get(i).RestoreBigData(hashtable);
231259 }
260
+
261
+ blockloop = false;
232262 }
233263
234264 void RestoreBigData(Object3D o)
235265 {
236266 this.bRep = o.bRep;
237
- if (this.bRep != null)
238
- this.bRep.support = o.transientrep;
267
+ if (this.support != null && o.transientrep != null)
268
+ {
269
+ this.support.bRep = o.transientrep;
270
+ }
271
+// July 2019 if (this.bRep != null)
272
+// this.bRep.support = o.transientrep;
239273 // this.support = o.support;
240274 // this.fileparent = o.fileparent;
241275 }
....@@ -563,12 +597,14 @@
563597 toParent = LA.newMatrix();
564598 fromParent = LA.newMatrix();
565599 }
600
+
566601 if (toParentMarked == null)
567602 {
568603 if (maxcount != 1)
569604 {
570605 new Exception().printStackTrace();
571606 }
607
+
572608 toParentMarked = LA.newMatrix();
573609 fromParentMarked = LA.newMatrix();
574610 }
....@@ -879,7 +915,7 @@
879915
880916 if (marked && Globals.isLIVE() && live &&
881917 //TEMP21aug2018
882
- (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
918
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
883919 currentframe != Globals.framecount)
884920 {
885921 currentframe = Globals.framecount;
....@@ -891,7 +927,8 @@
891927
892928 boolean changedir = random && Math.random() < 0.01; // && !link2master;
893929
894
- if (transformcount*factor > maxcount || (step == 1 && changedir))
930
+ if (transformcount*factor >= maxcount && (rewind || random) ||
931
+ (step == 1 && changedir))
895932 {
896933 countdown = 1;
897934 delay = speedup?8:1;
....@@ -963,6 +1000,7 @@
9631000 if (material == null || material.multiply)
9641001 return true;
9651002
1003
+ // Transparent objects are dynamic because we have to sort the triangles.
9661004 return material.opacity > 0.99;
9671005 }
9681006
....@@ -1363,6 +1401,7 @@
13631401 toParent = LA.newMatrix();
13641402 fromParent = LA.newMatrix();
13651403 }
1404
+
13661405 LA.matCopy(other.toParent, toParent);
13671406 LA.matCopy(other.fromParent, fromParent);
13681407
....@@ -2384,6 +2423,10 @@
23842423 }
23852424 */
23862425 }
2426
+ else
2427
+ {
2428
+ //((ObjEditor)editWindow).SetupUI2(null);
2429
+ }
23872430 }
23882431
23892432 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2425,6 +2468,14 @@
24252468 {
24262469 editWindow.refreshContents();
24272470 }
2471
+ else
2472
+ {
2473
+ if (manipWindow != null)
2474
+ {
2475
+ manipWindow.refreshContents();
2476
+ }
2477
+ }
2478
+
24282479 //if (parent != null)
24292480 //parent.refreshEditWindow();
24302481 }
....@@ -3501,7 +3552,8 @@
35013552 if (blockloop)
35023553 return;
35033554
3504
- if (marked || (bRep != null && material != null)) // borderline...
3555
+ if (//marked || // does not make sense
3556
+ (bRep != null || material != null)) // borderline...
35053557 live = h;
35063558
35073559 for (int i = 0; i < Size(); i++)
....@@ -3522,7 +3574,8 @@
35223574 return;
35233575
35243576 //if (bRep != null)
3525
- if (marked || (bRep != null && material != null)) // borderline...
3577
+ if (//marked || // does not make sense
3578
+ (bRep != null || material != null)) // borderline...
35263579 link2master = h;
35273580
35283581 for (int i = 0; i < Size(); i++)
....@@ -3542,7 +3595,8 @@
35423595 if (blockloop)
35433596 return;
35443597
3545
- if (marked || (bRep != null && material != null)) // borderline...
3598
+ if (//marked || // does not make sense
3599
+ (bRep != null || material != null)) // borderline...
35463600 hide = h;
35473601
35483602 for (int i = 0; i < Size(); i++)
....@@ -3562,7 +3616,7 @@
35623616 if (blockloop)
35633617 return;
35643618
3565
- if (bRep != null && material != null) // borderline...
3619
+ if (bRep != null || material != null) // borderline...
35663620 marked = h;
35673621
35683622 for (int i = 0; i < Size(); i++)
....@@ -3572,6 +3626,46 @@
35723626 continue;
35733627 blockloop = true;
35743628 child.MarkLeaves(h);
3629
+ blockloop = false;
3630
+ // release(i);
3631
+ }
3632
+ }
3633
+
3634
+ void RewindLeaves(boolean h)
3635
+ {
3636
+ if (blockloop)
3637
+ return;
3638
+
3639
+ if (bRep != null || material != null) // borderline...
3640
+ rewind = h;
3641
+
3642
+ for (int i = 0; i < Size(); i++)
3643
+ {
3644
+ Object3D child = (Object3D) get(i); // reserve(i);
3645
+ if (child == null)
3646
+ continue;
3647
+ blockloop = true;
3648
+ child.RewindLeaves(h);
3649
+ blockloop = false;
3650
+ // release(i);
3651
+ }
3652
+ }
3653
+
3654
+ void RandomLeaves(boolean h)
3655
+ {
3656
+ if (blockloop)
3657
+ return;
3658
+
3659
+ if (bRep != null || material != null) // borderline...
3660
+ random = h;
3661
+
3662
+ for (int i = 0; i < Size(); i++)
3663
+ {
3664
+ Object3D child = (Object3D) get(i); // reserve(i);
3665
+ if (child == null)
3666
+ continue;
3667
+ blockloop = true;
3668
+ child.RandomLeaves(h);
35753669 blockloop = false;
35763670 // release(i);
35773671 }
....@@ -4349,6 +4443,55 @@
43494443 }
43504444 }
43514445
4446
+ void RepairSOV()
4447
+ {
4448
+ if (blockloop)
4449
+ return;
4450
+
4451
+ String texname = this.GetPigmentTexture();
4452
+
4453
+ if (texname.startsWith("sov"))
4454
+ {
4455
+ String[] s = texname.split("/");
4456
+
4457
+ String[] sname = s[1].split("Color.pn");
4458
+
4459
+ texname = sname[0];
4460
+
4461
+ if (sname.length > 1)
4462
+ {
4463
+ texname += "Color.jpg";
4464
+ }
4465
+
4466
+ this.SetPigmentTexture("sov/" + texname);
4467
+ }
4468
+
4469
+ texname = this.GetBumpTexture();
4470
+
4471
+ if (texname.startsWith("sov"))
4472
+ {
4473
+ String[] s = texname.split("/");
4474
+
4475
+ String[] sname = s[1].split("Bump.pn");
4476
+
4477
+ texname = sname[0];
4478
+
4479
+ if (sname.length > 1)
4480
+ {
4481
+ texname += "Bump.jpg";
4482
+ }
4483
+
4484
+ this.SetBumpTexture("sov/" + texname);
4485
+ }
4486
+
4487
+ for (int i=0; i<Size(); i++)
4488
+ {
4489
+ blockloop = true;
4490
+ get(i).RepairSOV();
4491
+ blockloop = false;
4492
+ }
4493
+ }
4494
+
43524495 void RepairTexture()
43534496 {
43544497 if (this instanceof FileObject || blockloop)
....@@ -4863,6 +5006,14 @@
48635006 }
48645007 }
48655008
5009
+ ObjEditor GetWindow()
5010
+ {
5011
+ if (editWindow != null)
5012
+ return editWindow;
5013
+
5014
+ return manipWindow;
5015
+ }
5016
+
48665017 cTreePath Select(int indexcount, boolean deselect)
48675018 {
48685019 if (hide || dontselect)
....@@ -4899,10 +5050,11 @@
48995050 if (leaf != null)
49005051 {
49015052 cTreePath tp = new cTreePath(this, leaf);
4902
- if (editWindow != null)
5053
+ ObjEditor window = GetWindow();
5054
+ if (window != null)
49035055 {
49045056 //System.out.println("editWindow = " + editWindow + " vs " + this);
4905
- editWindow.Select(tp, deselect, true);
5057
+ window.Select(tp, deselect, true);
49065058 }
49075059
49085060 return tp;
....@@ -4919,6 +5071,7 @@
49195071
49205072 if (child == null)
49215073 continue;
5074
+
49225075 if (child.HasTransparency() && child.size() != 0)
49235076 {
49245077 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4928,9 +5081,10 @@
49285081 if (leaf != null)
49295082 {
49305083 cTreePath tp = new cTreePath(this, leaf);
4931
- if (editWindow != null)
5084
+ ObjEditor window = GetWindow();
5085
+ if (window != null)
49325086 {
4933
- editWindow.Select(tp, deselect, true);
5087
+ window.Select(tp, deselect, true);
49345088 }
49355089
49365090 return tp;
....@@ -5572,12 +5726,23 @@
55725726 boolean NeedSupport()
55735727 {
55745728 return
5575
- CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null
5729
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
55765730 // PROBLEM with CROWD!!
55775731 && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
55785732 }
55795733
55805734 static boolean DEBUG_SELECTION = false;
5735
+
5736
+ boolean IsLive()
5737
+ {
5738
+ if (live)
5739
+ return true;
5740
+
5741
+ if (parent == null)
5742
+ return false;
5743
+
5744
+ return parent.IsLive();
5745
+ }
55815746
55825747 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
55835748 {
....@@ -5640,7 +5805,7 @@
56405805 support = support;
56415806
56425807 //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);
5808
+ boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
56445809
56455810 if (!usecalllists && bRep != null && bRep.displaylist > 0)
56465811 {
....@@ -5660,10 +5825,12 @@
56605825 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
56615826
56625827 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5663
- (touched || (bRep != null && bRep.displaylist <= 0)))
5828
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5829
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
56645830 {
56655831 Globals.lighttouched = true;
56665832 } // all panes...
5833
+
56675834 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
56685835 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
56695836 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5791,6 +5958,7 @@
57915958 if (GetBRep() != null)
57925959 {
57935960 display.NextIndex();
5961
+
57945962 // vertex color conflict : gl.glCallList(list);
57955963 DrawNode(display, root, selected);
57965964 if (this instanceof BezierPatch)
....@@ -5831,16 +5999,27 @@
58315999 tex = GetTextures();
58326000 }
58336001
5834
- boolean failed = false;
6002
+ boolean failedPigment = false;
6003
+ boolean failedBump = false;
58356004
58366005 try
58376006 {
5838
- display.BindTextures(tex, texres);
6007
+ display.BindPigmentTexture(tex, texres);
58396008 }
58406009 catch (Exception e)
58416010 {
58426011 System.err.println("FAILED: " + this);
5843
- failed = true;
6012
+ failedPigment = true;
6013
+ }
6014
+
6015
+ try
6016
+ {
6017
+ display.BindBumpTexture(tex, texres);
6018
+ }
6019
+ catch (Exception e)
6020
+ {
6021
+ //System.err.println("FAILED: " + this);
6022
+ failedBump = true;
58446023 }
58456024
58466025 if (!compiled)
....@@ -5863,8 +6042,11 @@
58636042 }
58646043 }
58656044
5866
- if (!failed)
5867
- display.ReleaseTextures(tex);
6045
+ if (!failedBump)
6046
+ display.ReleaseBumpTexture(tex);
6047
+
6048
+ if (!failedPigment)
6049
+ display.ReleasePigmentTexture(tex);
58686050
58696051 display.PopMaterial(this, selected);
58706052 }
....@@ -6237,6 +6419,11 @@
62376419 // dec 2012
62386420 new Exception().printStackTrace();
62396421 return;
6422
+ }
6423
+
6424
+ if (dontselect)
6425
+ {
6426
+ //bRep.GenerateNormalsMINE();
62406427 }
62416428
62426429 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -7089,7 +7276,7 @@
70897276 spot.translate(32, 32);
70907277 spotw = spot.x + spot.width;
70917278 spoth = spot.y + spot.height;
7092
- info.g.setColor(Color.blue);
7279
+ info.g.setColor(Color.cyan);
70937280 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
70947281 // if (CameraPane.Xmin > spot.x)
70957282 // {
....@@ -7107,11 +7294,12 @@
71077294 // {
71087295 // CameraPane.Ymax = spoth;
71097296 // }
7110
- // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7111
- //info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7297
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7298
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
71127299 spot.translate(0, -32);
7113
- info.g.setColor(Color.green);
7300
+ info.g.setColor(Color.yellow);
71147301 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7302
+ info.g.setColor(Color.green);
71157303 // if (CameraPane.Xmin > spot.x)
71167304 // {
71177305 // CameraPane.Xmin = spot.x;
....@@ -7128,8 +7316,8 @@
71287316 // {
71297317 // CameraPane.Ymax = spoth;
71307318 // }
7131
- info.g.drawArc(boundary.x, boundary.y,
7132
- boundary.width, boundary.height, 0, 360);
7319
+ info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY,
7320
+ (int)(boundary.width * info.W), (int)(boundary.height * info.W), 0, 360);
71337321 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
71347322 // if (CameraPane.Xmin > boundary.x)
71357323 // {
....@@ -7429,19 +7617,20 @@
74297617 switch (info.pane.RenderCamera().viewCode)
74307618 {
74317619 case 3: // '\001'
7432
- if (modified)
7620
+ if (modified || opposite)
74337621 {
74347622 //LA.matScale(toParent, 1, hScale, vScale);
74357623 LA.matScale(toParent, totalScale, 1, 1);
74367624 } // vScale, 1);
74377625 else
74387626 {
7627
+ // EXCEPTION!
74397628 LA.matScale(toParent, totalScale, totalScale, totalScale);
74407629 } // vScale, 1);
74417630 break;
74427631
74437632 case 2: // '\002'
7444
- if (modified)
7633
+ if (modified || opposite)
74457634 {
74467635 //LA.matScale(toParent, hScale, 1, vScale);
74477636 LA.matScale(toParent, 1, totalScale, 1);
....@@ -7452,7 +7641,7 @@
74527641 break;
74537642
74547643 case 1: // '\003'
7455
- if (modified)
7644
+ if (modified || opposite)
74567645 {
74577646 //LA.matScale(toParent, hScale, vScale, 1);
74587647 LA.matScale(toParent, 1, 1, totalScale);
....@@ -7672,6 +7861,10 @@
76727861 editWindow = null;
76737862 } // ?
76747863 }
7864
+ else
7865
+ {
7866
+ //editWindow.closeUI();
7867
+ }
76757868 }
76767869
76777870 boolean root; // patch for edit windows
....@@ -7829,6 +8022,10 @@
78298022 }
78308023
78318024 transient ObjEditor editWindow;
8025
+ transient ObjEditor manipWindow;
8026
+
8027
+ transient boolean pinned;
8028
+
78328029 transient ObjectUI objectUI;
78338030 public static int povDepth = 0;
78348031 private static cVector tbMin = new cVector();