Normand Briere
2019-08-08 8294241adc5fe698b70e13ebd6780af46ab83f7e
Object3D.java
....@@ -22,13 +22,20 @@
2222 //static final long serialVersionUID = -607422624994562685L;
2323 static final long serialVersionUID = 5022536242724664900L;
2424
25
+ // Use GetUUID for backward compatibility with null.
2526 private UUID uuid = UUID.randomUUID();
2627
27
- // TEMPORARY for mocap undo
28
- mocap.reader.BVHReader.BVHResult bvh;
29
- Object3D skeleton;
28
+ // TEMPORARY for mocap undo. No need to be transient.
29
+ mocap.reader.BVHReader.BVHResult savebvh;
30
+ Object3D saveskeleton;
3031 //
3132
33
+ String skyboxname;
34
+ String skyboxext;
35
+
36
+ Object3D versionlist[];
37
+ int versionindex = -1;
38
+
3239 ScriptNode scriptnode;
3340
3441 void InitOthers()
....@@ -170,24 +177,35 @@
170177
171178 void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
172179 {
180
+ Object3D o;
181
+
173182 if (hashtable.containsKey(GetUUID()))
174183 {
175
- Object3D o = hashtable.get(GetUUID());
184
+ o = hashtable.get(GetUUID());
176185
177186 Grafreed.Assert(this.bRep == o.bRep);
178
- if (this.bRep != null)
179
- assert(this.bRep.support == o.transientrep);
187
+ //if (this.bRep != null)
188
+ // assert(this.bRep.support == o.transientrep);
189
+ if (this.support != null)
190
+ assert(this.support.bRep == o.transientrep);
191
+ }
192
+ else
193
+ {
194
+ o = new Object3D("copy of " + this.name);
180195
181
- return;
196
+ hashtable.put(GetUUID(), o);
182197 }
183198
184
- Object3D o = new Object3D();
185
-
186
- hashtable.put(GetUUID(), o);
187
-
188
- for (int i=0; i<Size(); i++)
199
+ if (!blockloop)
189200 {
190
- get(i).ExtractBigData(hashtable);
201
+ blockloop = true;
202
+
203
+ for (int i=0; i<Size(); i++)
204
+ {
205
+ get(i).ExtractBigData(hashtable);
206
+ }
207
+
208
+ blockloop = false;
191209 }
192210
193211 ExtractBigData(o);
....@@ -195,11 +213,26 @@
195213
196214 void ExtractBigData(Object3D o)
197215 {
216
+ if (o.bRep != null)
217
+ Grafreed.Assert(o.bRep == this.bRep);
218
+
198219 o.bRep = this.bRep;
199
- if (this.bRep != null)
220
+// July 2019 if (this.bRep != null)
221
+// {
222
+// o.transientrep = this.bRep.support;
223
+// o.bRep.support = null;
224
+// }
225
+ o.selection = this.selection;
226
+ o.versionlist = this.versionlist;
227
+ o.versionindex = this.versionindex;
228
+
229
+ if (this.support != null)
200230 {
201
- o.transientrep = this.bRep.support;
202
- o.bRep.support = null;
231
+ if (o.transientrep != null)
232
+ Grafreed.Assert(o.transientrep == this.support.bRep);
233
+
234
+ o.transientrep = this.support.bRep;
235
+ this.support.bRep = null;
203236 }
204237
205238 // o.support = this.support;
....@@ -214,6 +247,29 @@
214247 // this.fileparent = null;
215248 }
216249
250
+// Object3D GetObject(java.util.UUID uuid)
251
+// {
252
+// if (this.uuid.equals(uuid))
253
+// return this;
254
+//
255
+// if (blockloop)
256
+// return null;
257
+//
258
+// blockloop = true;
259
+//
260
+// for (int i=0; i<Size(); i++)
261
+// {
262
+// Object3D o = get(i).GetObject(uuid);
263
+//
264
+// if (o != null)
265
+// return o;
266
+// }
267
+//
268
+// blockloop = false;
269
+//
270
+// return null;
271
+// }
272
+
217273 void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
218274 {
219275 if (!hashtable.containsKey(GetUUID()))
....@@ -223,19 +279,35 @@
223279
224280 RestoreBigData(o);
225281
226
- hashtable.remove(GetUUID());
282
+ if (blockloop)
283
+ return;
284
+
285
+ blockloop = true;
286
+
287
+ //hashtable.remove(GetUUID());
227288
228289 for (int i=0; i<Size(); i++)
229290 {
230291 get(i).RestoreBigData(hashtable);
231292 }
293
+
294
+ blockloop = false;
232295 }
233296
234297 void RestoreBigData(Object3D o)
235298 {
236299 this.bRep = o.bRep;
237
- if (this.bRep != null)
238
- this.bRep.support = o.transientrep;
300
+ if (this.support != null && o.transientrep != null)
301
+ {
302
+ this.support.bRep = o.transientrep;
303
+ }
304
+
305
+ this.selection = o.selection;
306
+
307
+ this.versionlist = o.versionlist;
308
+ this.versionindex = o.versionindex;
309
+// July 2019 if (this.bRep != null)
310
+// this.bRep.support = o.transientrep;
239311 // this.support = o.support;
240312 // this.fileparent = o.fileparent;
241313 }
....@@ -381,6 +453,7 @@
381453 }
382454
383455 boolean live = false;
456
+ transient boolean keepdontselect;
384457 boolean dontselect = false;
385458 boolean hide = false;
386459 boolean link2master = false; // performs reset support/master at each frame
....@@ -881,7 +954,7 @@
881954
882955 if (marked && Globals.isLIVE() && live &&
883956 //TEMP21aug2018
884
- (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
957
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
885958 currentframe != Globals.framecount)
886959 {
887960 currentframe = Globals.framecount;
....@@ -893,7 +966,8 @@
893966
894967 boolean changedir = random && Math.random() < 0.01; // && !link2master;
895968
896
- if (transformcount*factor > maxcount || (step == 1 && changedir))
969
+ if (transformcount*factor >= maxcount && (rewind || random) ||
970
+ (step == 1 && changedir))
897971 {
898972 countdown = 1;
899973 delay = speedup?8:1;
....@@ -965,6 +1039,10 @@
9651039 if (material == null || material.multiply)
9661040 return true;
9671041
1042
+ if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
1043
+ return false;
1044
+
1045
+ // Transparent objects are dynamic because we have to sort the triangles.
9681046 return material.opacity > 0.99;
9691047 }
9701048
....@@ -1365,6 +1443,7 @@
13651443 toParent = LA.newMatrix();
13661444 fromParent = LA.newMatrix();
13671445 }
1446
+
13681447 LA.matCopy(other.toParent, toParent);
13691448 LA.matCopy(other.fromParent, fromParent);
13701449
....@@ -2386,6 +2465,11 @@
23862465 }
23872466 */
23882467 }
2468
+ else
2469
+ {
2470
+ //((ObjEditor)editWindow).SetupUI2(null);
2471
+ ((ObjEditor)objectUI).pinButton.setSelected(pinned);
2472
+ }
23892473 }
23902474
23912475 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2427,6 +2511,14 @@
24272511 {
24282512 editWindow.refreshContents();
24292513 }
2514
+ else
2515
+ {
2516
+ if (manipWindow != null)
2517
+ {
2518
+ manipWindow.refreshContents();
2519
+ }
2520
+ }
2521
+
24302522 //if (parent != null)
24312523 //parent.refreshEditWindow();
24322524 }
....@@ -2506,7 +2598,8 @@
25062598 private static final int editSelf = 1;
25072599 private static final int editChild = 2;
25082600
2509
- void drawEditHandles(ClickInfo info, int level)
2601
+ void drawEditHandles(//ClickInfo info,
2602
+ int level)
25102603 {
25112604 if (level == 0)
25122605 {
....@@ -2514,7 +2607,8 @@
25142607 return;
25152608
25162609 Object3D selectee;
2517
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2610
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2611
+ level + 1))
25182612 {
25192613 selectee = (Object3D) e.nextElement();
25202614 }
....@@ -2522,19 +2616,22 @@
25222616 } else
25232617 {
25242618 //super.
2525
- drawEditHandles0(info, level + 1);
2619
+ drawEditHandles0(//info,
2620
+ level + 1);
25262621 }
25272622 }
25282623
2529
- boolean doEditClick(ClickInfo info, int level)
2624
+ boolean doEditClick(//ClickInfo info,
2625
+ int level)
25302626 {
25312627 doSomething = 0;
25322628 if (level == 0)
25332629 {
2534
- return doParentClick(info);
2630
+ return doParentClick(); //info);
25352631 }
25362632 if (//super.
2537
- doEditClick0(info, level))
2633
+ doEditClick0(//info,
2634
+ level))
25382635 {
25392636 doSomething = 1;
25402637 return true;
....@@ -2544,7 +2641,7 @@
25442641 }
25452642 }
25462643
2547
- boolean doParentClick(ClickInfo info)
2644
+ boolean doParentClick() //ClickInfo info)
25482645 {
25492646 if (selection == null)
25502647 {
....@@ -2557,7 +2654,8 @@
25572654 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
25582655 {
25592656 Object3D selectee = (Object3D) e.nextElement();
2560
- if (selectee.doEditClick(info, 1))
2657
+ if (selectee.doEditClick(//info,
2658
+ 1))
25612659 {
25622660 childToDrag = selectee;
25632661 doSomething = 2;
....@@ -2569,13 +2667,15 @@
25692667 return retval;
25702668 }
25712669
2572
- void doEditDrag(ClickInfo info, boolean opposite)
2670
+ void doEditDrag(//ClickInfo clickInfo,
2671
+ boolean opposite)
25732672 {
25742673 switch (doSomething)
25752674 {
25762675 case 1: // '\001'
25772676 //super.
2578
- doEditDrag0(info, opposite);
2677
+ doEditDrag0(//clickInfo,
2678
+ opposite);
25792679 break;
25802680
25812681 case 2: // '\002'
....@@ -2588,11 +2688,13 @@
25882688 {
25892689 //sel.hitSomething = childToDrag.hitSomething;
25902690 //childToDrag.doEditDrag(info);
2591
- sel.doEditDrag(info, opposite);
2691
+ sel.doEditDrag(//clickInfo,
2692
+ opposite);
25922693 } else
25932694 {
25942695 //super.
2595
- doEditDrag0(info, opposite);
2696
+ doEditDrag0(//clickInfo,
2697
+ opposite);
25962698 }
25972699 }
25982700 break;
....@@ -2610,6 +2712,9 @@
26102712 {
26112713 deselectAll();
26122714 }
2715
+
2716
+ new Exception().printStackTrace();
2717
+
26132718 ClickInfo newInfo = new ClickInfo();
26142719 newInfo.flags = info.flags;
26152720 newInfo.bounds = info.bounds;
....@@ -3057,7 +3162,7 @@
30573162 {
30583163 if (bRep != null)
30593164 {
3060
- bRep.GenerateNormalsMINE();
3165
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
30613166 Touch();
30623167 }
30633168 }
....@@ -3503,7 +3608,8 @@
35033608 if (blockloop)
35043609 return;
35053610
3506
- if (marked || (bRep != null && material != null)) // borderline...
3611
+ if (//marked || // does not make sense
3612
+ (bRep != null || material != null)) // borderline...
35073613 live = h;
35083614
35093615 for (int i = 0; i < Size(); i++)
....@@ -3524,7 +3630,8 @@
35243630 return;
35253631
35263632 //if (bRep != null)
3527
- if (marked || (bRep != null && material != null)) // borderline...
3633
+ if (//marked || // does not make sense
3634
+ (bRep != null || material != null)) // borderline...
35283635 link2master = h;
35293636
35303637 for (int i = 0; i < Size(); i++)
....@@ -3544,7 +3651,8 @@
35443651 if (blockloop)
35453652 return;
35463653
3547
- if (marked || (bRep != null && material != null)) // borderline...
3654
+ if (//marked || // does not make sense
3655
+ (bRep != null || material != null)) // borderline...
35483656 hide = h;
35493657
35503658 for (int i = 0; i < Size(); i++)
....@@ -3564,7 +3672,7 @@
35643672 if (blockloop)
35653673 return;
35663674
3567
- if (bRep != null && material != null) // borderline...
3675
+ if (bRep != null || material != null) // borderline...
35683676 marked = h;
35693677
35703678 for (int i = 0; i < Size(); i++)
....@@ -3574,6 +3682,46 @@
35743682 continue;
35753683 blockloop = true;
35763684 child.MarkLeaves(h);
3685
+ blockloop = false;
3686
+ // release(i);
3687
+ }
3688
+ }
3689
+
3690
+ void RewindLeaves(boolean h)
3691
+ {
3692
+ if (blockloop)
3693
+ return;
3694
+
3695
+ if (bRep != null || material != null) // borderline...
3696
+ rewind = h;
3697
+
3698
+ for (int i = 0; i < Size(); i++)
3699
+ {
3700
+ Object3D child = (Object3D) get(i); // reserve(i);
3701
+ if (child == null)
3702
+ continue;
3703
+ blockloop = true;
3704
+ child.RewindLeaves(h);
3705
+ blockloop = false;
3706
+ // release(i);
3707
+ }
3708
+ }
3709
+
3710
+ void RandomLeaves(boolean h)
3711
+ {
3712
+ if (blockloop)
3713
+ return;
3714
+
3715
+ if (bRep != null || material != null) // borderline...
3716
+ random = h;
3717
+
3718
+ for (int i = 0; i < Size(); i++)
3719
+ {
3720
+ Object3D child = (Object3D) get(i); // reserve(i);
3721
+ if (child == null)
3722
+ continue;
3723
+ blockloop = true;
3724
+ child.RandomLeaves(h);
35773725 blockloop = false;
35783726 // release(i);
35793727 }
....@@ -4351,6 +4499,55 @@
43514499 }
43524500 }
43534501
4502
+ void RepairSOV()
4503
+ {
4504
+ if (blockloop)
4505
+ return;
4506
+
4507
+ String texname = this.GetPigmentTexture();
4508
+
4509
+ if (texname.startsWith("sov"))
4510
+ {
4511
+ String[] s = texname.split("/");
4512
+
4513
+ String[] sname = s[1].split("Color.pn");
4514
+
4515
+ texname = sname[0];
4516
+
4517
+ if (sname.length > 1)
4518
+ {
4519
+ texname += "Color.jpg";
4520
+ }
4521
+
4522
+ this.SetPigmentTexture("sov/" + texname);
4523
+ }
4524
+
4525
+ texname = this.GetBumpTexture();
4526
+
4527
+ if (texname.startsWith("sov"))
4528
+ {
4529
+ String[] s = texname.split("/");
4530
+
4531
+ String[] sname = s[1].split("Bump.pn");
4532
+
4533
+ texname = sname[0];
4534
+
4535
+ if (sname.length > 1)
4536
+ {
4537
+ texname += "Bump.jpg";
4538
+ }
4539
+
4540
+ this.SetBumpTexture("sov/" + texname);
4541
+ }
4542
+
4543
+ for (int i=0; i<Size(); i++)
4544
+ {
4545
+ blockloop = true;
4546
+ get(i).RepairSOV();
4547
+ blockloop = false;
4548
+ }
4549
+ }
4550
+
43544551 void RepairTexture()
43554552 {
43564553 if (this instanceof FileObject || blockloop)
....@@ -4865,6 +5062,14 @@
48655062 }
48665063 }
48675064
5065
+ ObjEditor GetWindow()
5066
+ {
5067
+ if (editWindow != null)
5068
+ return editWindow;
5069
+
5070
+ return manipWindow;
5071
+ }
5072
+
48685073 cTreePath Select(int indexcount, boolean deselect)
48695074 {
48705075 if (hide || dontselect)
....@@ -4901,10 +5106,11 @@
49015106 if (leaf != null)
49025107 {
49035108 cTreePath tp = new cTreePath(this, leaf);
4904
- if (editWindow != null)
5109
+ ObjEditor window = GetWindow();
5110
+ if (window != null)
49055111 {
49065112 //System.out.println("editWindow = " + editWindow + " vs " + this);
4907
- editWindow.Select(tp, deselect, true);
5113
+ window.Select(tp, deselect, true);
49085114 }
49095115
49105116 return tp;
....@@ -4921,6 +5127,7 @@
49215127
49225128 if (child == null)
49235129 continue;
5130
+
49245131 if (child.HasTransparency() && child.size() != 0)
49255132 {
49265133 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4930,9 +5137,10 @@
49305137 if (leaf != null)
49315138 {
49325139 cTreePath tp = new cTreePath(this, leaf);
4933
- if (editWindow != null)
5140
+ ObjEditor window = GetWindow();
5141
+ if (window != null)
49345142 {
4935
- editWindow.Select(tp, deselect, true);
5143
+ window.Select(tp, deselect, true);
49365144 }
49375145
49385146 return tp;
....@@ -5257,6 +5465,51 @@
52575465 blockloop = false;
52585466 }
52595467
5468
+ void ResetSelectable()
5469
+ {
5470
+ if (blockloop)
5471
+ return;
5472
+
5473
+ blockloop = true;
5474
+
5475
+ keepdontselect = dontselect;
5476
+ dontselect = true;
5477
+
5478
+ Object3D child;
5479
+ int nb = Size();
5480
+ for (int i = 0; i < nb; i++)
5481
+ {
5482
+ child = (Object3D) get(i);
5483
+ if (child == null)
5484
+ continue;
5485
+ child.ResetSelectable();
5486
+ }
5487
+
5488
+ blockloop = false;
5489
+ }
5490
+
5491
+ void RestoreSelectable()
5492
+ {
5493
+ if (blockloop)
5494
+ return;
5495
+
5496
+ blockloop = true;
5497
+
5498
+ dontselect = keepdontselect;
5499
+
5500
+ Object3D child;
5501
+ int nb = Size();
5502
+ for (int i = 0; i < nb; i++)
5503
+ {
5504
+ child = (Object3D) get(i);
5505
+ if (child == null)
5506
+ continue;
5507
+ child.RestoreSelectable();
5508
+ }
5509
+
5510
+ blockloop = false;
5511
+ }
5512
+
52605513 boolean IsSelected()
52615514 {
52625515 if (parent == null)
....@@ -5566,6 +5819,38 @@
55665819 }
55675820 }
55685821
5822
+ void EmbedTextures(boolean embed)
5823
+ {
5824
+ if (blockloop)
5825
+ return;
5826
+
5827
+ //if (GetTextures() != null)
5828
+ if (embed)
5829
+ CameraPane.EmbedTextures(GetTextures());
5830
+ else
5831
+ {
5832
+ GetTextures().pigmentdata = null;
5833
+ GetTextures().bumpdata = null;
5834
+ GetTextures().pw = 0;
5835
+ GetTextures().ph = 0;
5836
+ GetTextures().bw = 0;
5837
+ GetTextures().bh = 0;
5838
+ }
5839
+
5840
+ int nb = Size();
5841
+ for (int i = 0; i < nb; i++)
5842
+ {
5843
+ Object3D child = (Object3D) get(i);
5844
+
5845
+ if (child == null)
5846
+ continue;
5847
+
5848
+ blockloop = true;
5849
+ child.EmbedTextures(embed);
5850
+ blockloop = false;
5851
+ }
5852
+ }
5853
+
55695854 void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
55705855 {
55715856 Draw(display, root, selected, blocked);
....@@ -5652,8 +5937,10 @@
56525937 if (support != null)
56535938 support = support;
56545939
5655
- //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);
5940
+ boolean usecalllists = !IsLive() && IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5941
+ //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5942
+
5943
+ //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass.
56575944
56585945 if (!usecalllists && bRep != null && bRep.displaylist > 0)
56595946 {
....@@ -5663,8 +5950,9 @@
56635950 // usecalllists &= !(parent instanceof RandomNode);
56645951 // usecalllists = false;
56655952
5666
- if (GetBRep() != null)
5667
- usecalllists = usecalllists;
5953
+ if (display.DrawMode() == display.SHADOW)
5954
+ //GetBRep() != null)
5955
+ usecalllists = !!usecalllists;
56685956 //System.out.println("draw " + this);
56695957 //new Exception().printStackTrace();
56705958
....@@ -5674,7 +5962,7 @@
56745962
56755963 if (!selectmode && //display.DrawMode() != display.SELECTION &&
56765964 //(touched || (bRep != null && bRep.displaylist <= 0)))
5677
- (Globals.isLIVE() || touched && (bRep != null && bRep.displaylist <= 0)))
5965
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
56785966 {
56795967 Globals.lighttouched = true;
56805968 } // all panes...
....@@ -5686,7 +5974,7 @@
56865974 if (!(this instanceof Composite))
56875975 touched = false;
56885976 //if (displaylist == -1 && usecalllists)
5689
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
5977
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
56905978 {
56915979 bRep.displaylist = display.GenList();
56925980 assert(bRep.displaylist != 0);
....@@ -5697,7 +5985,7 @@
56975985
56985986 //System.out.println("\tnew list " + list);
56995987 //gl.glDrawBuffer(gl.GL_NONE);
5700
- if (usecalllists)
5988
+ if (usecalllists && bRep.displaylist > 0)
57015989 {
57025990 // System.err.println("new list " + bRep.displaylist + " for " + this);
57035991 display.NewList(bRep.displaylist);
....@@ -5706,7 +5994,7 @@
57065994 CallList(display, root, selected, blocked);
57075995
57085996 // compiled = true;
5709
- if (usecalllists)
5997
+ if (usecalllists && bRep.displaylist > 0)
57105998 {
57115999 // System.err.println("end list " + bRep.displaylist + " for " + this);
57126000 display.EndList();
....@@ -5806,6 +6094,7 @@
58066094 if (GetBRep() != null)
58076095 {
58086096 display.NextIndex();
6097
+
58096098 // vertex color conflict : gl.glCallList(list);
58106099 DrawNode(display, root, selected);
58116100 if (this instanceof BezierPatch)
....@@ -5846,16 +6135,27 @@
58466135 tex = GetTextures();
58476136 }
58486137
5849
- boolean failed = false;
6138
+ boolean failedPigment = false;
6139
+ boolean failedBump = false;
58506140
58516141 try
58526142 {
5853
- display.BindTextures(tex, texres);
6143
+ display.BindPigmentTexture(tex, texres);
58546144 }
58556145 catch (Exception e)
58566146 {
58576147 System.err.println("FAILED: " + this);
5858
- failed = true;
6148
+ failedPigment = true;
6149
+ }
6150
+
6151
+ try
6152
+ {
6153
+ display.BindBumpTexture(tex, texres);
6154
+ }
6155
+ catch (Exception e)
6156
+ {
6157
+ //System.err.println("FAILED: " + this);
6158
+ failedBump = true;
58596159 }
58606160
58616161 if (!compiled)
....@@ -5878,8 +6178,11 @@
58786178 }
58796179 }
58806180
5881
- if (!failed)
5882
- display.ReleaseTextures(tex);
6181
+ if (!failedBump)
6182
+ display.ReleaseBumpTexture(tex);
6183
+
6184
+ if (!failedPigment)
6185
+ display.ReleasePigmentTexture(tex);
58836186
58846187 display.PopMaterial(this, selected);
58856188 }
....@@ -6252,6 +6555,11 @@
62526555 // dec 2012
62536556 new Exception().printStackTrace();
62546557 return;
6558
+ }
6559
+
6560
+ if (dontselect)
6561
+ {
6562
+ //bRep.GenerateNormalsMINE();
62556563 }
62566564
62576565 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -7037,20 +7345,23 @@
70377345 }
70387346 }
70397347
7040
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7348
+ static ClickInfo clickInfo = new ClickInfo();
7349
+
7350
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7351
+ Point outPt, Rectangle outRec)
70417352 {
7042
- int hc = info.bounds.x + info.bounds.width / 2;
7043
- int vc = info.bounds.y + info.bounds.height / 2;
7044
- double[][] toscreen = info.toScreen;
7353
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7354
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7355
+ double[][] toscreen = clickInfo.toScreen;
70457356 if (toscreen == null)
70467357 {
7047
- toscreen = new Camera(info.camera.viewCode).toScreen;
7358
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
70487359 }
70497360 cVector vec = in;
70507361 LA.xformPos(in, toscreen, in);
70517362 //System.out.println("Distance = " + info.camera.Distance());
7052
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7053
- vec.y *= 100 * info.camera.SCALE / info.camera.Distance();
7363
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7364
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
70547365 outPt.x = hc + (int) vec.x;
70557366 outPt.y = vc - (int) vec.y;
70567367 outRec.x = outPt.x - 3;
....@@ -7058,15 +7369,18 @@
70587369 outRec.width = outRec.height = 6;
70597370 }
70607371
7061
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7372
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7373
+ )
70627374 {
70637375 Point pt = new Point(0, 0);
70647376 Rectangle rec = new Rectangle();
7065
- calcHotSpot(in, info, pt, rec);
7377
+ calcHotSpot(in, //clickInfo,
7378
+ pt, rec);
70667379 return rec;
70677380 }
70687381
7069
- void drawEditHandles0(ClickInfo info, int level)
7382
+ void drawEditHandles0(//ClickInfo clickInfo,
7383
+ int level)
70707384 {
70717385 if (level == 0)
70727386 {
....@@ -7075,16 +7389,19 @@
70757389 {
70767390 cVector origin = new cVector();
70777391 //LA.xformPos(origin, toParent, origin);
7078
- Rectangle spot = calcHotSpot(origin, info);
7392
+ if (this.clickInfo == null)
7393
+ this.clickInfo = new ClickInfo();
7394
+
7395
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
70797396 Rectangle boundary = new Rectangle();
70807397 boundary.x = spot.x - 30;
70817398 boundary.y = spot.y - 30;
70827399 boundary.width = spot.width + 60;
70837400 boundary.height = spot.height + 60;
7084
- info.g.setColor(Color.red);
7401
+ clickInfo.g.setColor(Color.red);
70857402 int spotw = spot.x + spot.width;
70867403 int spoth = spot.y + spot.height;
7087
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7404
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
70887405 // if (CameraPane.Xmin > spot.x)
70897406 // {
70907407 // CameraPane.Xmin = spot.x;
....@@ -7104,8 +7421,8 @@
71047421 spot.translate(32, 32);
71057422 spotw = spot.x + spot.width;
71067423 spoth = spot.y + spot.height;
7107
- info.g.setColor(Color.cyan);
7108
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7424
+ clickInfo.g.setColor(Color.cyan);
7425
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
71097426 // if (CameraPane.Xmin > spot.x)
71107427 // {
71117428 // CameraPane.Xmin = spot.x;
....@@ -7125,9 +7442,9 @@
71257442 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
71267443 //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
71277444 spot.translate(0, -32);
7128
- info.g.setColor(Color.yellow);
7129
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7130
- info.g.setColor(Color.green);
7445
+ clickInfo.g.setColor(Color.yellow);
7446
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7447
+ clickInfo.g.setColor(Color.green);
71317448 // if (CameraPane.Xmin > spot.x)
71327449 // {
71337450 // CameraPane.Xmin = spot.x;
....@@ -7144,8 +7461,8 @@
71447461 // {
71457462 // CameraPane.Ymax = spoth;
71467463 // }
7147
- info.g.drawArc(boundary.x, boundary.y,
7148
- boundary.width, boundary.height, 0, 360);
7464
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7465
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
71497466 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
71507467 // if (CameraPane.Xmin > boundary.x)
71517468 // {
....@@ -7167,7 +7484,8 @@
71677484 }
71687485 }
71697486
7170
- boolean doEditClick0(ClickInfo info, int level)
7487
+ boolean doEditClick0(//ClickInfo clickInfo,
7488
+ int level)
71717489 {
71727490 if (level == 0)
71737491 {
....@@ -7176,8 +7494,8 @@
71767494
71777495 boolean retval = false;
71787496
7179
- startX = info.x;
7180
- startY = info.y;
7497
+ startX = clickInfo.x;
7498
+ startY = clickInfo.y;
71817499
71827500 hitSomething = -1;
71837501 cVector origin = new cVector();
....@@ -7187,22 +7505,51 @@
71877505 {
71887506 centerPt = new Point(0, 0);
71897507 }
7190
- calcHotSpot(origin, info, centerPt, spot);
7191
- if (spot.contains(info.x, info.y))
7508
+ calcHotSpot(origin, //info,
7509
+ centerPt, spot);
7510
+ if (spot.contains(clickInfo.x, clickInfo.y))
71927511 {
71937512 hitSomething = hitCenter;
71947513 retval = true;
71957514 }
71967515 spot.translate(32, 0);
7197
- if (spot.contains(info.x, info.y))
7516
+ if (spot.contains(clickInfo.x, clickInfo.y))
71987517 {
71997518 hitSomething = hitRotate;
72007519 retval = true;
72017520 }
72027521 spot.translate(0, 32);
7203
- if (spot.contains(info.x, info.y))
7522
+ if (spot.contains(clickInfo.x, clickInfo.y))
72047523 {
72057524 hitSomething = hitScale;
7525
+
7526
+ double scale = 0.005f * clickInfo.camera.Distance();
7527
+ double hScale = (double) (clickInfo.x - centerPt.x) / 32;
7528
+ double sign = 1;
7529
+ if (hScale < 0)
7530
+ {
7531
+ sign = -1;
7532
+ }
7533
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7534
+ if (hScale < 0.01)
7535
+ {
7536
+ //hScale = 0.01;
7537
+ }
7538
+
7539
+ double vScale = (double) (clickInfo.y - centerPt.y) / 32;
7540
+ sign = 1;
7541
+ if (vScale < 0)
7542
+ {
7543
+ sign = -1;
7544
+ }
7545
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7546
+ if (vScale < 0.01)
7547
+ {
7548
+ //vScale = 0.01;
7549
+ }
7550
+
7551
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7552
+
72067553 retval = true;
72077554 }
72087555
....@@ -7212,7 +7559,7 @@
72127559 }
72137560
72147561 //System.out.println("info.modifiers = " + info.modifiers);
7215
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7562
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
72167563 //System.out.println("modified = " + modified);
72177564 //new Exception().printStackTrace();
72187565 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7240,7 +7587,8 @@
72407587 return true;
72417588 }
72427589
7243
- void doEditDrag0(ClickInfo info, boolean opposite)
7590
+ void doEditDrag0(//ClickInfo info,
7591
+ boolean opposite)
72447592 {
72457593 if (hitSomething == 0)
72467594 {
....@@ -7254,7 +7602,7 @@
72547602
72557603 //System.out.println("hitSomething = " + hitSomething);
72567604
7257
- double scale = 0.005f * info.camera.Distance();
7605
+ double scale = 0.005f * clickInfo.camera.Distance();
72587606
72597607 cVector xlate = new cVector();
72607608 //cVector xlate2 = new cVector();
....@@ -7288,8 +7636,8 @@
72887636 toParent[3][i] = xlate.get(i);
72897637 LA.matInvert(toParent, fromParent);
72907638 */
7291
- cVector delta = LA.newVector(0, 0, startY - info.y);
7292
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7639
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7640
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
72937641
72947642 LA.matCopy(startMat, toParent);
72957643 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7298,7 +7646,7 @@
72987646 } else
72997647 {
73007648 //LA.xformDir(delta, info.camera.fromScreen, delta);
7301
- cVector up = new cVector(info.camera.up);
7649
+ cVector up = new cVector(clickInfo.camera.up);
73027650 cVector away = new cVector();
73037651 //cVector right2 = new cVector();
73047652 //LA.vecCross(up, cVector.Z, right);
....@@ -7315,19 +7663,19 @@
73157663 LA.xformDir(up, ClickInfo.matbuffer, up);
73167664 // if (!CameraPane.LOCALTRANSFORM)
73177665 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7318
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7666
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
73197667 // if (!CameraPane.LOCALTRANSFORM)
73207668 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
73217669 //LA.vecCross(up, cVector.Z, right2);
73227670
7323
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7671
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
73247672
73257673 //System.out.println("DELTA0 = " + delta);
73267674 //System.out.println("AWAY = " + info.camera.away);
73277675 //System.out.println("UP = " + info.camera.up);
73287676 if (away.z > 0)
73297677 {
7330
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7678
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
73317679 {
73327680 delta.x = -delta.x;
73337681 } else
....@@ -7342,7 +7690,7 @@
73427690 //System.out.println("DELTA1 = " + delta);
73437691 LA.xformDir(delta, ClickInfo.matbuffer, delta);
73447692 //System.out.println("DELTA2 = " + delta);
7345
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7693
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
73467694 LA.matCopy(startMat, toParent);
73477695 //System.out.println("DELTA3 = " + delta);
73487696 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7352,8 +7700,8 @@
73527700 break;
73537701
73547702 case hitRotate: // rotate
7355
- int dx = info.x - centerPt.x;
7356
- int dy = -(info.y - centerPt.y);
7703
+ int dx = clickInfo.x - centerPt.x;
7704
+ int dy = -(clickInfo.y - centerPt.y);
73577705 double angle = (double) Math.atan2(dx, dy);
73587706 angle = -(1.570796 - angle);
73597707
....@@ -7376,7 +7724,7 @@
73767724 }
73777725 /**/
73787726
7379
- switch (info.pane.RenderCamera().viewCode)
7727
+ switch (clickInfo.pane.RenderCamera().viewCode)
73807728 {
73817729 case 1: // '\001'
73827730 LA.matZRotate(toParent, angle);
....@@ -7403,7 +7751,7 @@
74037751 break;
74047752
74057753 case hitScale: // scale
7406
- double hScale = (double) (info.x - centerPt.x) / 32;
7754
+ double hScale = (double) (clickInfo.x - centerPt.x) / 32;
74077755 double sign = 1;
74087756 if (hScale < 0)
74097757 {
....@@ -7415,7 +7763,7 @@
74157763 //hScale = 0.01;
74167764 }
74177765
7418
- double vScale = (double) (info.y - centerPt.y) / 32;
7766
+ double vScale = (double) (clickInfo.y - centerPt.y) / 32;
74197767 sign = 1;
74207768 if (vScale < 0)
74217769 {
....@@ -7426,6 +7774,7 @@
74267774 {
74277775 //vScale = 0.01;
74287776 }
7777
+
74297778 LA.matCopy(startMat, toParent);
74307779 /**/
74317780 for (int i = 0; i < 3; i++)
....@@ -7435,14 +7784,14 @@
74357784 }
74367785 /**/
74377786
7438
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7787
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
74397788
74407789 if (totalScale < 0.01)
74417790 {
74427791 totalScale = 0.01;
74437792 }
74447793
7445
- switch (info.pane.RenderCamera().viewCode)
7794
+ switch (clickInfo.pane.RenderCamera().viewCode)
74467795 {
74477796 case 3: // '\001'
74487797 if (modified || opposite)
....@@ -7509,7 +7858,7 @@
75097858 } // NEW ...
75107859
75117860
7512
- info.pane.repaint();
7861
+ clickInfo.pane.repaint();
75137862 }
75147863
75157864 boolean overflow = false;
....@@ -7689,6 +8038,10 @@
76898038 editWindow = null;
76908039 } // ?
76918040 }
8041
+ else
8042
+ {
8043
+ //editWindow.closeUI();
8044
+ }
76928045 }
76938046
76948047 boolean root; // patch for edit windows
....@@ -7846,6 +8199,10 @@
78468199 }
78478200
78488201 transient ObjEditor editWindow;
8202
+ transient ObjEditor manipWindow;
8203
+
8204
+ transient boolean pinned;
8205
+
78498206 transient ObjectUI objectUI;
78508207 public static int povDepth = 0;
78518208 private static cVector tbMin = new cVector();