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
177179 Grafreed.Assert(this.bRep == o.bRep);
178
- if (this.bRep != null)
179
- assert(this.bRep.support == o.transientrep);
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 }
....@@ -881,7 +915,7 @@
881915
882916 if (marked && Globals.isLIVE() && live &&
883917 //TEMP21aug2018
884
- (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
918
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
885919 currentframe != Globals.framecount)
886920 {
887921 currentframe = Globals.framecount;
....@@ -893,7 +927,8 @@
893927
894928 boolean changedir = random && Math.random() < 0.01; // && !link2master;
895929
896
- if (transformcount*factor > maxcount || (step == 1 && changedir))
930
+ if (transformcount*factor >= maxcount && (rewind || random) ||
931
+ (step == 1 && changedir))
897932 {
898933 countdown = 1;
899934 delay = speedup?8:1;
....@@ -965,6 +1000,7 @@
9651000 if (material == null || material.multiply)
9661001 return true;
9671002
1003
+ // Transparent objects are dynamic because we have to sort the triangles.
9681004 return material.opacity > 0.99;
9691005 }
9701006
....@@ -1365,6 +1401,7 @@
13651401 toParent = LA.newMatrix();
13661402 fromParent = LA.newMatrix();
13671403 }
1404
+
13681405 LA.matCopy(other.toParent, toParent);
13691406 LA.matCopy(other.fromParent, fromParent);
13701407
....@@ -2386,6 +2423,10 @@
23862423 }
23872424 */
23882425 }
2426
+ else
2427
+ {
2428
+ //((ObjEditor)editWindow).SetupUI2(null);
2429
+ }
23892430 }
23902431
23912432 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2427,6 +2468,14 @@
24272468 {
24282469 editWindow.refreshContents();
24292470 }
2471
+ else
2472
+ {
2473
+ if (manipWindow != null)
2474
+ {
2475
+ manipWindow.refreshContents();
2476
+ }
2477
+ }
2478
+
24302479 //if (parent != null)
24312480 //parent.refreshEditWindow();
24322481 }
....@@ -3503,7 +3552,8 @@
35033552 if (blockloop)
35043553 return;
35053554
3506
- if (marked || (bRep != null && material != null)) // borderline...
3555
+ if (//marked || // does not make sense
3556
+ (bRep != null || material != null)) // borderline...
35073557 live = h;
35083558
35093559 for (int i = 0; i < Size(); i++)
....@@ -3524,7 +3574,8 @@
35243574 return;
35253575
35263576 //if (bRep != null)
3527
- if (marked || (bRep != null && material != null)) // borderline...
3577
+ if (//marked || // does not make sense
3578
+ (bRep != null || material != null)) // borderline...
35283579 link2master = h;
35293580
35303581 for (int i = 0; i < Size(); i++)
....@@ -3544,7 +3595,8 @@
35443595 if (blockloop)
35453596 return;
35463597
3547
- if (marked || (bRep != null && material != null)) // borderline...
3598
+ if (//marked || // does not make sense
3599
+ (bRep != null || material != null)) // borderline...
35483600 hide = h;
35493601
35503602 for (int i = 0; i < Size(); i++)
....@@ -3564,7 +3616,7 @@
35643616 if (blockloop)
35653617 return;
35663618
3567
- if (bRep != null && material != null) // borderline...
3619
+ if (bRep != null || material != null) // borderline...
35683620 marked = h;
35693621
35703622 for (int i = 0; i < Size(); i++)
....@@ -3574,6 +3626,46 @@
35743626 continue;
35753627 blockloop = true;
35763628 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);
35773669 blockloop = false;
35783670 // release(i);
35793671 }
....@@ -4351,6 +4443,55 @@
43514443 }
43524444 }
43534445
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
+
43544495 void RepairTexture()
43554496 {
43564497 if (this instanceof FileObject || blockloop)
....@@ -4865,6 +5006,14 @@
48655006 }
48665007 }
48675008
5009
+ ObjEditor GetWindow()
5010
+ {
5011
+ if (editWindow != null)
5012
+ return editWindow;
5013
+
5014
+ return manipWindow;
5015
+ }
5016
+
48685017 cTreePath Select(int indexcount, boolean deselect)
48695018 {
48705019 if (hide || dontselect)
....@@ -4901,10 +5050,11 @@
49015050 if (leaf != null)
49025051 {
49035052 cTreePath tp = new cTreePath(this, leaf);
4904
- if (editWindow != null)
5053
+ ObjEditor window = GetWindow();
5054
+ if (window != null)
49055055 {
49065056 //System.out.println("editWindow = " + editWindow + " vs " + this);
4907
- editWindow.Select(tp, deselect, true);
5057
+ window.Select(tp, deselect, true);
49085058 }
49095059
49105060 return tp;
....@@ -4921,6 +5071,7 @@
49215071
49225072 if (child == null)
49235073 continue;
5074
+
49245075 if (child.HasTransparency() && child.size() != 0)
49255076 {
49265077 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4930,9 +5081,10 @@
49305081 if (leaf != null)
49315082 {
49325083 cTreePath tp = new cTreePath(this, leaf);
4933
- if (editWindow != null)
5084
+ ObjEditor window = GetWindow();
5085
+ if (window != null)
49345086 {
4935
- editWindow.Select(tp, deselect, true);
5087
+ window.Select(tp, deselect, true);
49365088 }
49375089
49385090 return tp;
....@@ -5653,7 +5805,7 @@
56535805 support = support;
56545806
56555807 //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);
5808
+ boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
56575809
56585810 if (!usecalllists && bRep != null && bRep.displaylist > 0)
56595811 {
....@@ -5673,10 +5825,12 @@
56735825 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
56745826
56755827 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5676
- (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)))
56775830 {
56785831 Globals.lighttouched = true;
56795832 } // all panes...
5833
+
56805834 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
56815835 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
56825836 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5804,6 +5958,7 @@
58045958 if (GetBRep() != null)
58055959 {
58065960 display.NextIndex();
5961
+
58075962 // vertex color conflict : gl.glCallList(list);
58085963 DrawNode(display, root, selected);
58095964 if (this instanceof BezierPatch)
....@@ -5844,16 +5999,27 @@
58445999 tex = GetTextures();
58456000 }
58466001
5847
- boolean failed = false;
6002
+ boolean failedPigment = false;
6003
+ boolean failedBump = false;
58486004
58496005 try
58506006 {
5851
- display.BindTextures(tex, texres);
6007
+ display.BindPigmentTexture(tex, texres);
58526008 }
58536009 catch (Exception e)
58546010 {
58556011 System.err.println("FAILED: " + this);
5856
- 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;
58576023 }
58586024
58596025 if (!compiled)
....@@ -5876,8 +6042,11 @@
58766042 }
58776043 }
58786044
5879
- if (!failed)
5880
- display.ReleaseTextures(tex);
6045
+ if (!failedBump)
6046
+ display.ReleaseBumpTexture(tex);
6047
+
6048
+ if (!failedPigment)
6049
+ display.ReleasePigmentTexture(tex);
58816050
58826051 display.PopMaterial(this, selected);
58836052 }
....@@ -6250,6 +6419,11 @@
62506419 // dec 2012
62516420 new Exception().printStackTrace();
62526421 return;
6422
+ }
6423
+
6424
+ if (dontselect)
6425
+ {
6426
+ //bRep.GenerateNormalsMINE();
62536427 }
62546428
62556429 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -7142,8 +7316,8 @@
71427316 // {
71437317 // CameraPane.Ymax = spoth;
71447318 // }
7145
- info.g.drawArc(boundary.x, boundary.y,
7146
- 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);
71477321 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
71487322 // if (CameraPane.Xmin > boundary.x)
71497323 // {
....@@ -7450,7 +7624,8 @@
74507624 } // vScale, 1);
74517625 else
74527626 {
7453
- LA.matScale(toParent, 1, totalScale, totalScale);
7627
+ // EXCEPTION!
7628
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
74547629 } // vScale, 1);
74557630 break;
74567631
....@@ -7686,6 +7861,10 @@
76867861 editWindow = null;
76877862 } // ?
76887863 }
7864
+ else
7865
+ {
7866
+ //editWindow.closeUI();
7867
+ }
76897868 }
76907869
76917870 boolean root; // patch for edit windows
....@@ -7843,6 +8022,10 @@
78438022 }
78448023
78458024 transient ObjEditor editWindow;
8025
+ transient ObjEditor manipWindow;
8026
+
8027
+ transient boolean pinned;
8028
+
78468029 transient ObjectUI objectUI;
78478030 public static int povDepth = 0;
78488031 private static cVector tbMin = new cVector();