Normand Briere
2019-08-06 b3ae4e889872ca0b9ca76f1d17b2f0b961226729
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,10 @@
23862465 }
23872466 */
23882467 }
2468
+ else
2469
+ {
2470
+ //((ObjEditor)editWindow).SetupUI2(null);
2471
+ }
23892472 }
23902473
23912474 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2427,6 +2510,14 @@
24272510 {
24282511 editWindow.refreshContents();
24292512 }
2513
+ else
2514
+ {
2515
+ if (manipWindow != null)
2516
+ {
2517
+ manipWindow.refreshContents();
2518
+ }
2519
+ }
2520
+
24302521 //if (parent != null)
24312522 //parent.refreshEditWindow();
24322523 }
....@@ -2506,7 +2597,8 @@
25062597 private static final int editSelf = 1;
25072598 private static final int editChild = 2;
25082599
2509
- void drawEditHandles(ClickInfo info, int level)
2600
+ void drawEditHandles(//ClickInfo info,
2601
+ int level)
25102602 {
25112603 if (level == 0)
25122604 {
....@@ -2514,7 +2606,8 @@
25142606 return;
25152607
25162608 Object3D selectee;
2517
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2609
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2610
+ level + 1))
25182611 {
25192612 selectee = (Object3D) e.nextElement();
25202613 }
....@@ -2522,19 +2615,22 @@
25222615 } else
25232616 {
25242617 //super.
2525
- drawEditHandles0(info, level + 1);
2618
+ drawEditHandles0(//info,
2619
+ level + 1);
25262620 }
25272621 }
25282622
2529
- boolean doEditClick(ClickInfo info, int level)
2623
+ boolean doEditClick(//ClickInfo info,
2624
+ int level)
25302625 {
25312626 doSomething = 0;
25322627 if (level == 0)
25332628 {
2534
- return doParentClick(info);
2629
+ return doParentClick(); //info);
25352630 }
25362631 if (//super.
2537
- doEditClick0(info, level))
2632
+ doEditClick0(//info,
2633
+ level))
25382634 {
25392635 doSomething = 1;
25402636 return true;
....@@ -2544,7 +2640,7 @@
25442640 }
25452641 }
25462642
2547
- boolean doParentClick(ClickInfo info)
2643
+ boolean doParentClick() //ClickInfo info)
25482644 {
25492645 if (selection == null)
25502646 {
....@@ -2557,7 +2653,8 @@
25572653 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
25582654 {
25592655 Object3D selectee = (Object3D) e.nextElement();
2560
- if (selectee.doEditClick(info, 1))
2656
+ if (selectee.doEditClick(//info,
2657
+ 1))
25612658 {
25622659 childToDrag = selectee;
25632660 doSomething = 2;
....@@ -2569,13 +2666,15 @@
25692666 return retval;
25702667 }
25712668
2572
- void doEditDrag(ClickInfo info, boolean opposite)
2669
+ void doEditDrag(//ClickInfo clickInfo,
2670
+ boolean opposite)
25732671 {
25742672 switch (doSomething)
25752673 {
25762674 case 1: // '\001'
25772675 //super.
2578
- doEditDrag0(info, opposite);
2676
+ doEditDrag0(//clickInfo,
2677
+ opposite);
25792678 break;
25802679
25812680 case 2: // '\002'
....@@ -2588,11 +2687,13 @@
25882687 {
25892688 //sel.hitSomething = childToDrag.hitSomething;
25902689 //childToDrag.doEditDrag(info);
2591
- sel.doEditDrag(info, opposite);
2690
+ sel.doEditDrag(//clickInfo,
2691
+ opposite);
25922692 } else
25932693 {
25942694 //super.
2595
- doEditDrag0(info, opposite);
2695
+ doEditDrag0(//clickInfo,
2696
+ opposite);
25962697 }
25972698 }
25982699 break;
....@@ -2610,6 +2711,9 @@
26102711 {
26112712 deselectAll();
26122713 }
2714
+
2715
+ new Exception().printStackTrace();
2716
+
26132717 ClickInfo newInfo = new ClickInfo();
26142718 newInfo.flags = info.flags;
26152719 newInfo.bounds = info.bounds;
....@@ -3057,7 +3161,7 @@
30573161 {
30583162 if (bRep != null)
30593163 {
3060
- bRep.GenerateNormalsMINE();
3164
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
30613165 Touch();
30623166 }
30633167 }
....@@ -3503,7 +3607,8 @@
35033607 if (blockloop)
35043608 return;
35053609
3506
- if (marked || (bRep != null && material != null)) // borderline...
3610
+ if (//marked || // does not make sense
3611
+ (bRep != null || material != null)) // borderline...
35073612 live = h;
35083613
35093614 for (int i = 0; i < Size(); i++)
....@@ -3524,7 +3629,8 @@
35243629 return;
35253630
35263631 //if (bRep != null)
3527
- if (marked || (bRep != null && material != null)) // borderline...
3632
+ if (//marked || // does not make sense
3633
+ (bRep != null || material != null)) // borderline...
35283634 link2master = h;
35293635
35303636 for (int i = 0; i < Size(); i++)
....@@ -3544,7 +3650,8 @@
35443650 if (blockloop)
35453651 return;
35463652
3547
- if (marked || (bRep != null && material != null)) // borderline...
3653
+ if (//marked || // does not make sense
3654
+ (bRep != null || material != null)) // borderline...
35483655 hide = h;
35493656
35503657 for (int i = 0; i < Size(); i++)
....@@ -3564,7 +3671,7 @@
35643671 if (blockloop)
35653672 return;
35663673
3567
- if (bRep != null && material != null) // borderline...
3674
+ if (bRep != null || material != null) // borderline...
35683675 marked = h;
35693676
35703677 for (int i = 0; i < Size(); i++)
....@@ -3574,6 +3681,46 @@
35743681 continue;
35753682 blockloop = true;
35763683 child.MarkLeaves(h);
3684
+ blockloop = false;
3685
+ // release(i);
3686
+ }
3687
+ }
3688
+
3689
+ void RewindLeaves(boolean h)
3690
+ {
3691
+ if (blockloop)
3692
+ return;
3693
+
3694
+ if (bRep != null || material != null) // borderline...
3695
+ rewind = h;
3696
+
3697
+ for (int i = 0; i < Size(); i++)
3698
+ {
3699
+ Object3D child = (Object3D) get(i); // reserve(i);
3700
+ if (child == null)
3701
+ continue;
3702
+ blockloop = true;
3703
+ child.RewindLeaves(h);
3704
+ blockloop = false;
3705
+ // release(i);
3706
+ }
3707
+ }
3708
+
3709
+ void RandomLeaves(boolean h)
3710
+ {
3711
+ if (blockloop)
3712
+ return;
3713
+
3714
+ if (bRep != null || material != null) // borderline...
3715
+ random = h;
3716
+
3717
+ for (int i = 0; i < Size(); i++)
3718
+ {
3719
+ Object3D child = (Object3D) get(i); // reserve(i);
3720
+ if (child == null)
3721
+ continue;
3722
+ blockloop = true;
3723
+ child.RandomLeaves(h);
35773724 blockloop = false;
35783725 // release(i);
35793726 }
....@@ -4351,6 +4498,55 @@
43514498 }
43524499 }
43534500
4501
+ void RepairSOV()
4502
+ {
4503
+ if (blockloop)
4504
+ return;
4505
+
4506
+ String texname = this.GetPigmentTexture();
4507
+
4508
+ if (texname.startsWith("sov"))
4509
+ {
4510
+ String[] s = texname.split("/");
4511
+
4512
+ String[] sname = s[1].split("Color.pn");
4513
+
4514
+ texname = sname[0];
4515
+
4516
+ if (sname.length > 1)
4517
+ {
4518
+ texname += "Color.jpg";
4519
+ }
4520
+
4521
+ this.SetPigmentTexture("sov/" + texname);
4522
+ }
4523
+
4524
+ texname = this.GetBumpTexture();
4525
+
4526
+ if (texname.startsWith("sov"))
4527
+ {
4528
+ String[] s = texname.split("/");
4529
+
4530
+ String[] sname = s[1].split("Bump.pn");
4531
+
4532
+ texname = sname[0];
4533
+
4534
+ if (sname.length > 1)
4535
+ {
4536
+ texname += "Bump.jpg";
4537
+ }
4538
+
4539
+ this.SetBumpTexture("sov/" + texname);
4540
+ }
4541
+
4542
+ for (int i=0; i<Size(); i++)
4543
+ {
4544
+ blockloop = true;
4545
+ get(i).RepairSOV();
4546
+ blockloop = false;
4547
+ }
4548
+ }
4549
+
43544550 void RepairTexture()
43554551 {
43564552 if (this instanceof FileObject || blockloop)
....@@ -4865,6 +5061,14 @@
48655061 }
48665062 }
48675063
5064
+ ObjEditor GetWindow()
5065
+ {
5066
+ if (editWindow != null)
5067
+ return editWindow;
5068
+
5069
+ return manipWindow;
5070
+ }
5071
+
48685072 cTreePath Select(int indexcount, boolean deselect)
48695073 {
48705074 if (hide || dontselect)
....@@ -4901,10 +5105,11 @@
49015105 if (leaf != null)
49025106 {
49035107 cTreePath tp = new cTreePath(this, leaf);
4904
- if (editWindow != null)
5108
+ ObjEditor window = GetWindow();
5109
+ if (window != null)
49055110 {
49065111 //System.out.println("editWindow = " + editWindow + " vs " + this);
4907
- editWindow.Select(tp, deselect, true);
5112
+ window.Select(tp, deselect, true);
49085113 }
49095114
49105115 return tp;
....@@ -4921,6 +5126,7 @@
49215126
49225127 if (child == null)
49235128 continue;
5129
+
49245130 if (child.HasTransparency() && child.size() != 0)
49255131 {
49265132 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4930,9 +5136,10 @@
49305136 if (leaf != null)
49315137 {
49325138 cTreePath tp = new cTreePath(this, leaf);
4933
- if (editWindow != null)
5139
+ ObjEditor window = GetWindow();
5140
+ if (window != null)
49345141 {
4935
- editWindow.Select(tp, deselect, true);
5142
+ window.Select(tp, deselect, true);
49365143 }
49375144
49385145 return tp;
....@@ -5257,6 +5464,51 @@
52575464 blockloop = false;
52585465 }
52595466
5467
+ void ResetSelectable()
5468
+ {
5469
+ if (blockloop)
5470
+ return;
5471
+
5472
+ blockloop = true;
5473
+
5474
+ keepdontselect = dontselect;
5475
+ dontselect = true;
5476
+
5477
+ Object3D child;
5478
+ int nb = Size();
5479
+ for (int i = 0; i < nb; i++)
5480
+ {
5481
+ child = (Object3D) get(i);
5482
+ if (child == null)
5483
+ continue;
5484
+ child.ResetSelectable();
5485
+ }
5486
+
5487
+ blockloop = false;
5488
+ }
5489
+
5490
+ void RestoreSelectable()
5491
+ {
5492
+ if (blockloop)
5493
+ return;
5494
+
5495
+ blockloop = true;
5496
+
5497
+ dontselect = keepdontselect;
5498
+
5499
+ Object3D child;
5500
+ int nb = Size();
5501
+ for (int i = 0; i < nb; i++)
5502
+ {
5503
+ child = (Object3D) get(i);
5504
+ if (child == null)
5505
+ continue;
5506
+ child.RestoreSelectable();
5507
+ }
5508
+
5509
+ blockloop = false;
5510
+ }
5511
+
52605512 boolean IsSelected()
52615513 {
52625514 if (parent == null)
....@@ -5566,6 +5818,38 @@
55665818 }
55675819 }
55685820
5821
+ void EmbedTextures(boolean embed)
5822
+ {
5823
+ if (blockloop)
5824
+ return;
5825
+
5826
+ //if (GetTextures() != null)
5827
+ if (embed)
5828
+ CameraPane.EmbedTextures(GetTextures());
5829
+ else
5830
+ {
5831
+ GetTextures().pigmentdata = null;
5832
+ GetTextures().bumpdata = null;
5833
+ GetTextures().pw = 0;
5834
+ GetTextures().ph = 0;
5835
+ GetTextures().bw = 0;
5836
+ GetTextures().bh = 0;
5837
+ }
5838
+
5839
+ int nb = Size();
5840
+ for (int i = 0; i < nb; i++)
5841
+ {
5842
+ Object3D child = (Object3D) get(i);
5843
+
5844
+ if (child == null)
5845
+ continue;
5846
+
5847
+ blockloop = true;
5848
+ child.EmbedTextures(embed);
5849
+ blockloop = false;
5850
+ }
5851
+ }
5852
+
55695853 void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
55705854 {
55715855 Draw(display, root, selected, blocked);
....@@ -5652,8 +5936,10 @@
56525936 if (support != null)
56535937 support = support;
56545938
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);
5939
+ boolean usecalllists = !IsLive() && IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5940
+ //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5941
+
5942
+ //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass.
56575943
56585944 if (!usecalllists && bRep != null && bRep.displaylist > 0)
56595945 {
....@@ -5663,8 +5949,9 @@
56635949 // usecalllists &= !(parent instanceof RandomNode);
56645950 // usecalllists = false;
56655951
5666
- if (GetBRep() != null)
5667
- usecalllists = usecalllists;
5952
+ if (display.DrawMode() == display.SHADOW)
5953
+ //GetBRep() != null)
5954
+ usecalllists = !!usecalllists;
56685955 //System.out.println("draw " + this);
56695956 //new Exception().printStackTrace();
56705957
....@@ -5674,7 +5961,7 @@
56745961
56755962 if (!selectmode && //display.DrawMode() != display.SELECTION &&
56765963 //(touched || (bRep != null && bRep.displaylist <= 0)))
5677
- (Globals.isLIVE() || touched && (bRep != null && bRep.displaylist <= 0)))
5964
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
56785965 {
56795966 Globals.lighttouched = true;
56805967 } // all panes...
....@@ -5686,7 +5973,7 @@
56865973 if (!(this instanceof Composite))
56875974 touched = false;
56885975 //if (displaylist == -1 && usecalllists)
5689
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
5976
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
56905977 {
56915978 bRep.displaylist = display.GenList();
56925979 assert(bRep.displaylist != 0);
....@@ -5697,7 +5984,7 @@
56975984
56985985 //System.out.println("\tnew list " + list);
56995986 //gl.glDrawBuffer(gl.GL_NONE);
5700
- if (usecalllists)
5987
+ if (usecalllists && bRep.displaylist > 0)
57015988 {
57025989 // System.err.println("new list " + bRep.displaylist + " for " + this);
57035990 display.NewList(bRep.displaylist);
....@@ -5706,7 +5993,7 @@
57065993 CallList(display, root, selected, blocked);
57075994
57085995 // compiled = true;
5709
- if (usecalllists)
5996
+ if (usecalllists && bRep.displaylist > 0)
57105997 {
57115998 // System.err.println("end list " + bRep.displaylist + " for " + this);
57125999 display.EndList();
....@@ -5806,6 +6093,7 @@
58066093 if (GetBRep() != null)
58076094 {
58086095 display.NextIndex();
6096
+
58096097 // vertex color conflict : gl.glCallList(list);
58106098 DrawNode(display, root, selected);
58116099 if (this instanceof BezierPatch)
....@@ -5846,16 +6134,27 @@
58466134 tex = GetTextures();
58476135 }
58486136
5849
- boolean failed = false;
6137
+ boolean failedPigment = false;
6138
+ boolean failedBump = false;
58506139
58516140 try
58526141 {
5853
- display.BindTextures(tex, texres);
6142
+ display.BindPigmentTexture(tex, texres);
58546143 }
58556144 catch (Exception e)
58566145 {
58576146 System.err.println("FAILED: " + this);
5858
- failed = true;
6147
+ failedPigment = true;
6148
+ }
6149
+
6150
+ try
6151
+ {
6152
+ display.BindBumpTexture(tex, texres);
6153
+ }
6154
+ catch (Exception e)
6155
+ {
6156
+ //System.err.println("FAILED: " + this);
6157
+ failedBump = true;
58596158 }
58606159
58616160 if (!compiled)
....@@ -5878,8 +6177,11 @@
58786177 }
58796178 }
58806179
5881
- if (!failed)
5882
- display.ReleaseTextures(tex);
6180
+ if (!failedBump)
6181
+ display.ReleaseBumpTexture(tex);
6182
+
6183
+ if (!failedPigment)
6184
+ display.ReleasePigmentTexture(tex);
58836185
58846186 display.PopMaterial(this, selected);
58856187 }
....@@ -6252,6 +6554,11 @@
62526554 // dec 2012
62536555 new Exception().printStackTrace();
62546556 return;
6557
+ }
6558
+
6559
+ if (dontselect)
6560
+ {
6561
+ //bRep.GenerateNormalsMINE();
62556562 }
62566563
62576564 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -7037,20 +7344,23 @@
70377344 }
70387345 }
70397346
7040
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7347
+ static ClickInfo clickInfo = new ClickInfo();
7348
+
7349
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7350
+ Point outPt, Rectangle outRec)
70417351 {
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;
7352
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7353
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7354
+ double[][] toscreen = clickInfo.toScreen;
70457355 if (toscreen == null)
70467356 {
7047
- toscreen = new Camera(info.camera.viewCode).toScreen;
7357
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
70487358 }
70497359 cVector vec = in;
70507360 LA.xformPos(in, toscreen, in);
70517361 //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();
7362
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7363
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
70547364 outPt.x = hc + (int) vec.x;
70557365 outPt.y = vc - (int) vec.y;
70567366 outRec.x = outPt.x - 3;
....@@ -7058,15 +7368,18 @@
70587368 outRec.width = outRec.height = 6;
70597369 }
70607370
7061
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7371
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7372
+ )
70627373 {
70637374 Point pt = new Point(0, 0);
70647375 Rectangle rec = new Rectangle();
7065
- calcHotSpot(in, info, pt, rec);
7376
+ calcHotSpot(in, //clickInfo,
7377
+ pt, rec);
70667378 return rec;
70677379 }
70687380
7069
- void drawEditHandles0(ClickInfo info, int level)
7381
+ void drawEditHandles0(//ClickInfo clickInfo,
7382
+ int level)
70707383 {
70717384 if (level == 0)
70727385 {
....@@ -7075,16 +7388,19 @@
70757388 {
70767389 cVector origin = new cVector();
70777390 //LA.xformPos(origin, toParent, origin);
7078
- Rectangle spot = calcHotSpot(origin, info);
7391
+ if (this.clickInfo == null)
7392
+ this.clickInfo = new ClickInfo();
7393
+
7394
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
70797395 Rectangle boundary = new Rectangle();
70807396 boundary.x = spot.x - 30;
70817397 boundary.y = spot.y - 30;
70827398 boundary.width = spot.width + 60;
70837399 boundary.height = spot.height + 60;
7084
- info.g.setColor(Color.red);
7400
+ clickInfo.g.setColor(Color.red);
70857401 int spotw = spot.x + spot.width;
70867402 int spoth = spot.y + spot.height;
7087
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7403
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
70887404 // if (CameraPane.Xmin > spot.x)
70897405 // {
70907406 // CameraPane.Xmin = spot.x;
....@@ -7104,8 +7420,8 @@
71047420 spot.translate(32, 32);
71057421 spotw = spot.x + spot.width;
71067422 spoth = spot.y + spot.height;
7107
- info.g.setColor(Color.cyan);
7108
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7423
+ clickInfo.g.setColor(Color.cyan);
7424
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
71097425 // if (CameraPane.Xmin > spot.x)
71107426 // {
71117427 // CameraPane.Xmin = spot.x;
....@@ -7125,9 +7441,9 @@
71257441 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
71267442 //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
71277443 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);
7444
+ clickInfo.g.setColor(Color.yellow);
7445
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7446
+ clickInfo.g.setColor(Color.green);
71317447 // if (CameraPane.Xmin > spot.x)
71327448 // {
71337449 // CameraPane.Xmin = spot.x;
....@@ -7144,8 +7460,8 @@
71447460 // {
71457461 // CameraPane.Ymax = spoth;
71467462 // }
7147
- info.g.drawArc(boundary.x, boundary.y,
7148
- boundary.width, boundary.height, 0, 360);
7463
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7464
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
71497465 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
71507466 // if (CameraPane.Xmin > boundary.x)
71517467 // {
....@@ -7167,7 +7483,8 @@
71677483 }
71687484 }
71697485
7170
- boolean doEditClick0(ClickInfo info, int level)
7486
+ boolean doEditClick0(//ClickInfo clickInfo,
7487
+ int level)
71717488 {
71727489 if (level == 0)
71737490 {
....@@ -7176,8 +7493,8 @@
71767493
71777494 boolean retval = false;
71787495
7179
- startX = info.x;
7180
- startY = info.y;
7496
+ startX = clickInfo.x;
7497
+ startY = clickInfo.y;
71817498
71827499 hitSomething = -1;
71837500 cVector origin = new cVector();
....@@ -7187,22 +7504,51 @@
71877504 {
71887505 centerPt = new Point(0, 0);
71897506 }
7190
- calcHotSpot(origin, info, centerPt, spot);
7191
- if (spot.contains(info.x, info.y))
7507
+ calcHotSpot(origin, //info,
7508
+ centerPt, spot);
7509
+ if (spot.contains(clickInfo.x, clickInfo.y))
71927510 {
71937511 hitSomething = hitCenter;
71947512 retval = true;
71957513 }
71967514 spot.translate(32, 0);
7197
- if (spot.contains(info.x, info.y))
7515
+ if (spot.contains(clickInfo.x, clickInfo.y))
71987516 {
71997517 hitSomething = hitRotate;
72007518 retval = true;
72017519 }
72027520 spot.translate(0, 32);
7203
- if (spot.contains(info.x, info.y))
7521
+ if (spot.contains(clickInfo.x, clickInfo.y))
72047522 {
72057523 hitSomething = hitScale;
7524
+
7525
+ double scale = 0.005f * clickInfo.camera.Distance();
7526
+ double hScale = (double) (clickInfo.x - centerPt.x) / 32;
7527
+ double sign = 1;
7528
+ if (hScale < 0)
7529
+ {
7530
+ sign = -1;
7531
+ }
7532
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7533
+ if (hScale < 0.01)
7534
+ {
7535
+ //hScale = 0.01;
7536
+ }
7537
+
7538
+ double vScale = (double) (clickInfo.y - centerPt.y) / 32;
7539
+ sign = 1;
7540
+ if (vScale < 0)
7541
+ {
7542
+ sign = -1;
7543
+ }
7544
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7545
+ if (vScale < 0.01)
7546
+ {
7547
+ //vScale = 0.01;
7548
+ }
7549
+
7550
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7551
+
72067552 retval = true;
72077553 }
72087554
....@@ -7212,7 +7558,7 @@
72127558 }
72137559
72147560 //System.out.println("info.modifiers = " + info.modifiers);
7215
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7561
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
72167562 //System.out.println("modified = " + modified);
72177563 //new Exception().printStackTrace();
72187564 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7240,7 +7586,8 @@
72407586 return true;
72417587 }
72427588
7243
- void doEditDrag0(ClickInfo info, boolean opposite)
7589
+ void doEditDrag0(//ClickInfo info,
7590
+ boolean opposite)
72447591 {
72457592 if (hitSomething == 0)
72467593 {
....@@ -7254,7 +7601,7 @@
72547601
72557602 //System.out.println("hitSomething = " + hitSomething);
72567603
7257
- double scale = 0.005f * info.camera.Distance();
7604
+ double scale = 0.005f * clickInfo.camera.Distance();
72587605
72597606 cVector xlate = new cVector();
72607607 //cVector xlate2 = new cVector();
....@@ -7288,8 +7635,8 @@
72887635 toParent[3][i] = xlate.get(i);
72897636 LA.matInvert(toParent, fromParent);
72907637 */
7291
- cVector delta = LA.newVector(0, 0, startY - info.y);
7292
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7638
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7639
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
72937640
72947641 LA.matCopy(startMat, toParent);
72957642 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7298,7 +7645,7 @@
72987645 } else
72997646 {
73007647 //LA.xformDir(delta, info.camera.fromScreen, delta);
7301
- cVector up = new cVector(info.camera.up);
7648
+ cVector up = new cVector(clickInfo.camera.up);
73027649 cVector away = new cVector();
73037650 //cVector right2 = new cVector();
73047651 //LA.vecCross(up, cVector.Z, right);
....@@ -7315,19 +7662,19 @@
73157662 LA.xformDir(up, ClickInfo.matbuffer, up);
73167663 // if (!CameraPane.LOCALTRANSFORM)
73177664 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7318
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7665
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
73197666 // if (!CameraPane.LOCALTRANSFORM)
73207667 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
73217668 //LA.vecCross(up, cVector.Z, right2);
73227669
7323
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7670
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
73247671
73257672 //System.out.println("DELTA0 = " + delta);
73267673 //System.out.println("AWAY = " + info.camera.away);
73277674 //System.out.println("UP = " + info.camera.up);
73287675 if (away.z > 0)
73297676 {
7330
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7677
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
73317678 {
73327679 delta.x = -delta.x;
73337680 } else
....@@ -7342,7 +7689,7 @@
73427689 //System.out.println("DELTA1 = " + delta);
73437690 LA.xformDir(delta, ClickInfo.matbuffer, delta);
73447691 //System.out.println("DELTA2 = " + delta);
7345
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7692
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
73467693 LA.matCopy(startMat, toParent);
73477694 //System.out.println("DELTA3 = " + delta);
73487695 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7352,8 +7699,8 @@
73527699 break;
73537700
73547701 case hitRotate: // rotate
7355
- int dx = info.x - centerPt.x;
7356
- int dy = -(info.y - centerPt.y);
7702
+ int dx = clickInfo.x - centerPt.x;
7703
+ int dy = -(clickInfo.y - centerPt.y);
73577704 double angle = (double) Math.atan2(dx, dy);
73587705 angle = -(1.570796 - angle);
73597706
....@@ -7376,7 +7723,7 @@
73767723 }
73777724 /**/
73787725
7379
- switch (info.pane.RenderCamera().viewCode)
7726
+ switch (clickInfo.pane.RenderCamera().viewCode)
73807727 {
73817728 case 1: // '\001'
73827729 LA.matZRotate(toParent, angle);
....@@ -7403,7 +7750,7 @@
74037750 break;
74047751
74057752 case hitScale: // scale
7406
- double hScale = (double) (info.x - centerPt.x) / 32;
7753
+ double hScale = (double) (clickInfo.x - centerPt.x) / 32;
74077754 double sign = 1;
74087755 if (hScale < 0)
74097756 {
....@@ -7415,7 +7762,7 @@
74157762 //hScale = 0.01;
74167763 }
74177764
7418
- double vScale = (double) (info.y - centerPt.y) / 32;
7765
+ double vScale = (double) (clickInfo.y - centerPt.y) / 32;
74197766 sign = 1;
74207767 if (vScale < 0)
74217768 {
....@@ -7426,6 +7773,7 @@
74267773 {
74277774 //vScale = 0.01;
74287775 }
7776
+
74297777 LA.matCopy(startMat, toParent);
74307778 /**/
74317779 for (int i = 0; i < 3; i++)
....@@ -7435,14 +7783,14 @@
74357783 }
74367784 /**/
74377785
7438
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7786
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
74397787
74407788 if (totalScale < 0.01)
74417789 {
74427790 totalScale = 0.01;
74437791 }
74447792
7445
- switch (info.pane.RenderCamera().viewCode)
7793
+ switch (clickInfo.pane.RenderCamera().viewCode)
74467794 {
74477795 case 3: // '\001'
74487796 if (modified || opposite)
....@@ -7452,7 +7800,8 @@
74527800 } // vScale, 1);
74537801 else
74547802 {
7455
- LA.matScale(toParent, 1, totalScale, totalScale);
7803
+ // EXCEPTION!
7804
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
74567805 } // vScale, 1);
74577806 break;
74587807
....@@ -7508,7 +7857,7 @@
75087857 } // NEW ...
75097858
75107859
7511
- info.pane.repaint();
7860
+ clickInfo.pane.repaint();
75127861 }
75137862
75147863 boolean overflow = false;
....@@ -7688,6 +8037,10 @@
76888037 editWindow = null;
76898038 } // ?
76908039 }
8040
+ else
8041
+ {
8042
+ //editWindow.closeUI();
8043
+ }
76918044 }
76928045
76938046 boolean root; // patch for edit windows
....@@ -7845,6 +8198,10 @@
78458198 }
78468199
78478200 transient ObjEditor editWindow;
8201
+ transient ObjEditor manipWindow;
8202
+
8203
+ transient boolean pinned;
8204
+
78488205 transient ObjectUI objectUI;
78498206 public static int povDepth = 0;
78508207 private static cVector tbMin = new cVector();