Normand Briere
2019-07-19 e79247ef52a0bbb3864d46bb1e2c716005b3ecf3
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
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 }
....@@ -563,12 +608,14 @@
563608 toParent = LA.newMatrix();
564609 fromParent = LA.newMatrix();
565610 }
611
+
566612 if (toParentMarked == null)
567613 {
568614 if (maxcount != 1)
569615 {
570616 new Exception().printStackTrace();
571617 }
618
+
572619 toParentMarked = LA.newMatrix();
573620 fromParentMarked = LA.newMatrix();
574621 }
....@@ -879,7 +926,7 @@
879926
880927 if (marked && Globals.isLIVE() && live &&
881928 //TEMP21aug2018
882
- (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
929
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
883930 currentframe != Globals.framecount)
884931 {
885932 currentframe = Globals.framecount;
....@@ -891,7 +938,8 @@
891938
892939 boolean changedir = random && Math.random() < 0.01; // && !link2master;
893940
894
- if (transformcount*factor > maxcount || (step == 1 && changedir))
941
+ if (transformcount*factor >= maxcount && (rewind || random) ||
942
+ (step == 1 && changedir))
895943 {
896944 countdown = 1;
897945 delay = speedup?8:1;
....@@ -963,6 +1011,7 @@
9631011 if (material == null || material.multiply)
9641012 return true;
9651013
1014
+ // Transparent objects are dynamic because we have to sort the triangles.
9661015 return material.opacity > 0.99;
9671016 }
9681017
....@@ -1363,6 +1412,7 @@
13631412 toParent = LA.newMatrix();
13641413 fromParent = LA.newMatrix();
13651414 }
1415
+
13661416 LA.matCopy(other.toParent, toParent);
13671417 LA.matCopy(other.fromParent, fromParent);
13681418
....@@ -2384,6 +2434,10 @@
23842434 }
23852435 */
23862436 }
2437
+ else
2438
+ {
2439
+ //((ObjEditor)editWindow).SetupUI2(null);
2440
+ }
23872441 }
23882442
23892443 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2425,6 +2479,14 @@
24252479 {
24262480 editWindow.refreshContents();
24272481 }
2482
+ else
2483
+ {
2484
+ if (manipWindow != null)
2485
+ {
2486
+ manipWindow.refreshContents();
2487
+ }
2488
+ }
2489
+
24282490 //if (parent != null)
24292491 //parent.refreshEditWindow();
24302492 }
....@@ -3055,7 +3117,7 @@
30553117 {
30563118 if (bRep != null)
30573119 {
3058
- bRep.GenerateNormalsMINE();
3120
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
30593121 Touch();
30603122 }
30613123 }
....@@ -3501,7 +3563,8 @@
35013563 if (blockloop)
35023564 return;
35033565
3504
- if (marked || (bRep != null && material != null)) // borderline...
3566
+ if (//marked || // does not make sense
3567
+ (bRep != null || material != null)) // borderline...
35053568 live = h;
35063569
35073570 for (int i = 0; i < Size(); i++)
....@@ -3522,7 +3585,8 @@
35223585 return;
35233586
35243587 //if (bRep != null)
3525
- if (marked || (bRep != null && material != null)) // borderline...
3588
+ if (//marked || // does not make sense
3589
+ (bRep != null || material != null)) // borderline...
35263590 link2master = h;
35273591
35283592 for (int i = 0; i < Size(); i++)
....@@ -3542,7 +3606,8 @@
35423606 if (blockloop)
35433607 return;
35443608
3545
- if (marked || (bRep != null && material != null)) // borderline...
3609
+ if (//marked || // does not make sense
3610
+ (bRep != null || material != null)) // borderline...
35463611 hide = h;
35473612
35483613 for (int i = 0; i < Size(); i++)
....@@ -3562,7 +3627,7 @@
35623627 if (blockloop)
35633628 return;
35643629
3565
- if (bRep != null && material != null) // borderline...
3630
+ if (bRep != null || material != null) // borderline...
35663631 marked = h;
35673632
35683633 for (int i = 0; i < Size(); i++)
....@@ -3572,6 +3637,46 @@
35723637 continue;
35733638 blockloop = true;
35743639 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);
35753680 blockloop = false;
35763681 // release(i);
35773682 }
....@@ -4349,6 +4454,55 @@
43494454 }
43504455 }
43514456
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
+
43524506 void RepairTexture()
43534507 {
43544508 if (this instanceof FileObject || blockloop)
....@@ -4863,6 +5017,14 @@
48635017 }
48645018 }
48655019
5020
+ ObjEditor GetWindow()
5021
+ {
5022
+ if (editWindow != null)
5023
+ return editWindow;
5024
+
5025
+ return manipWindow;
5026
+ }
5027
+
48665028 cTreePath Select(int indexcount, boolean deselect)
48675029 {
48685030 if (hide || dontselect)
....@@ -4899,10 +5061,11 @@
48995061 if (leaf != null)
49005062 {
49015063 cTreePath tp = new cTreePath(this, leaf);
4902
- if (editWindow != null)
5064
+ ObjEditor window = GetWindow();
5065
+ if (window != null)
49035066 {
49045067 //System.out.println("editWindow = " + editWindow + " vs " + this);
4905
- editWindow.Select(tp, deselect, true);
5068
+ window.Select(tp, deselect, true);
49065069 }
49075070
49085071 return tp;
....@@ -4919,6 +5082,7 @@
49195082
49205083 if (child == null)
49215084 continue;
5085
+
49225086 if (child.HasTransparency() && child.size() != 0)
49235087 {
49245088 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4928,9 +5092,10 @@
49285092 if (leaf != null)
49295093 {
49305094 cTreePath tp = new cTreePath(this, leaf);
4931
- if (editWindow != null)
5095
+ ObjEditor window = GetWindow();
5096
+ if (window != null)
49325097 {
4933
- editWindow.Select(tp, deselect, true);
5098
+ window.Select(tp, deselect, true);
49345099 }
49355100
49365101 return tp;
....@@ -5572,12 +5737,23 @@
55725737 boolean NeedSupport()
55735738 {
55745739 return
5575
- CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null
5740
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
55765741 // PROBLEM with CROWD!!
55775742 && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
55785743 }
55795744
55805745 static boolean DEBUG_SELECTION = false;
5746
+
5747
+ boolean IsLive()
5748
+ {
5749
+ if (live)
5750
+ return true;
5751
+
5752
+ if (parent == null)
5753
+ return false;
5754
+
5755
+ return parent.IsLive();
5756
+ }
55815757
55825758 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
55835759 {
....@@ -5640,7 +5816,7 @@
56405816 support = support;
56415817
56425818 //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);
5819
+ boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
56445820
56455821 if (!usecalllists && bRep != null && bRep.displaylist > 0)
56465822 {
....@@ -5660,10 +5836,12 @@
56605836 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
56615837
56625838 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5663
- (touched || (bRep != null && bRep.displaylist <= 0)))
5839
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5840
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
56645841 {
56655842 Globals.lighttouched = true;
56665843 } // all panes...
5844
+
56675845 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
56685846 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
56695847 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5791,6 +5969,7 @@
57915969 if (GetBRep() != null)
57925970 {
57935971 display.NextIndex();
5972
+
57945973 // vertex color conflict : gl.glCallList(list);
57955974 DrawNode(display, root, selected);
57965975 if (this instanceof BezierPatch)
....@@ -5831,16 +6010,27 @@
58316010 tex = GetTextures();
58326011 }
58336012
5834
- boolean failed = false;
6013
+ boolean failedPigment = false;
6014
+ boolean failedBump = false;
58356015
58366016 try
58376017 {
5838
- display.BindTextures(tex, texres);
6018
+ display.BindPigmentTexture(tex, texres);
58396019 }
58406020 catch (Exception e)
58416021 {
58426022 System.err.println("FAILED: " + this);
5843
- 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;
58446034 }
58456035
58466036 if (!compiled)
....@@ -5863,8 +6053,11 @@
58636053 }
58646054 }
58656055
5866
- if (!failed)
5867
- display.ReleaseTextures(tex);
6056
+ if (!failedBump)
6057
+ display.ReleaseBumpTexture(tex);
6058
+
6059
+ if (!failedPigment)
6060
+ display.ReleasePigmentTexture(tex);
58686061
58696062 display.PopMaterial(this, selected);
58706063 }
....@@ -6237,6 +6430,11 @@
62376430 // dec 2012
62386431 new Exception().printStackTrace();
62396432 return;
6433
+ }
6434
+
6435
+ if (dontselect)
6436
+ {
6437
+ //bRep.GenerateNormalsMINE();
62406438 }
62416439
62426440 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -7089,7 +7287,7 @@
70897287 spot.translate(32, 32);
70907288 spotw = spot.x + spot.width;
70917289 spoth = spot.y + spot.height;
7092
- info.g.setColor(Color.blue);
7290
+ info.g.setColor(Color.cyan);
70937291 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
70947292 // if (CameraPane.Xmin > spot.x)
70957293 // {
....@@ -7107,11 +7305,12 @@
71077305 // {
71087306 // CameraPane.Ymax = spoth;
71097307 // }
7110
- // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7111
- //info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7308
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7309
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
71127310 spot.translate(0, -32);
7113
- info.g.setColor(Color.green);
7311
+ info.g.setColor(Color.yellow);
71147312 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7313
+ info.g.setColor(Color.green);
71157314 // if (CameraPane.Xmin > spot.x)
71167315 // {
71177316 // CameraPane.Xmin = spot.x;
....@@ -7128,8 +7327,8 @@
71287327 // {
71297328 // CameraPane.Ymax = spoth;
71307329 // }
7131
- info.g.drawArc(boundary.x, boundary.y,
7132
- 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);
71337332 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
71347333 // if (CameraPane.Xmin > boundary.x)
71357334 // {
....@@ -7429,19 +7628,20 @@
74297628 switch (info.pane.RenderCamera().viewCode)
74307629 {
74317630 case 3: // '\001'
7432
- if (modified)
7631
+ if (modified || opposite)
74337632 {
74347633 //LA.matScale(toParent, 1, hScale, vScale);
74357634 LA.matScale(toParent, totalScale, 1, 1);
74367635 } // vScale, 1);
74377636 else
74387637 {
7638
+ // EXCEPTION!
74397639 LA.matScale(toParent, totalScale, totalScale, totalScale);
74407640 } // vScale, 1);
74417641 break;
74427642
74437643 case 2: // '\002'
7444
- if (modified)
7644
+ if (modified || opposite)
74457645 {
74467646 //LA.matScale(toParent, hScale, 1, vScale);
74477647 LA.matScale(toParent, 1, totalScale, 1);
....@@ -7452,7 +7652,7 @@
74527652 break;
74537653
74547654 case 1: // '\003'
7455
- if (modified)
7655
+ if (modified || opposite)
74567656 {
74577657 //LA.matScale(toParent, hScale, vScale, 1);
74587658 LA.matScale(toParent, 1, 1, totalScale);
....@@ -7672,6 +7872,10 @@
76727872 editWindow = null;
76737873 } // ?
76747874 }
7875
+ else
7876
+ {
7877
+ //editWindow.closeUI();
7878
+ }
76757879 }
76767880
76777881 boolean root; // patch for edit windows
....@@ -7829,6 +8033,10 @@
78298033 }
78308034
78318035 transient ObjEditor editWindow;
8036
+ transient ObjEditor manipWindow;
8037
+
8038
+ transient boolean pinned;
8039
+
78328040 transient ObjectUI objectUI;
78338041 public static int povDepth = 0;
78348042 private static cVector tbMin = new cVector();