Normand Briere
2019-08-23 60cec91731a350fe67e9b5ffe7a00d70e9026314
Object3D.java
....@@ -22,12 +22,21 @@
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 //
32
+
33
+ String skyboxname;
34
+ String skyboxext;
35
+
36
+ Object3D versionlist[];
37
+ int versionindex = -1;
38
+
39
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable; // = new java.util.Hashtable<java.util.UUID, Object3D>();
3140
3241 ScriptNode scriptnode;
3342
....@@ -170,24 +179,35 @@
170179
171180 void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
172181 {
182
+ Object3D o;
183
+
173184 if (hashtable.containsKey(GetUUID()))
174185 {
175
- Object3D o = hashtable.get(GetUUID());
186
+ o = hashtable.get(GetUUID());
176187
177188 Grafreed.Assert(this.bRep == o.bRep);
178
- if (this.bRep != null)
179
- assert(this.bRep.support == o.transientrep);
189
+ //if (this.bRep != null)
190
+ // assert(this.bRep.support == o.transientrep);
191
+ if (this.support != null)
192
+ assert(this.support.bRep == o.transientrep);
193
+ }
194
+ else
195
+ {
196
+ o = new Object3D("copy of " + this.name);
180197
181
- return;
198
+ hashtable.put(GetUUID(), o);
182199 }
183200
184
- Object3D o = new Object3D();
185
-
186
- hashtable.put(GetUUID(), o);
187
-
188
- for (int i=0; i<Size(); i++)
201
+ if (!blockloop)
189202 {
190
- get(i).ExtractBigData(hashtable);
203
+ blockloop = true;
204
+
205
+ for (int i=0; i<Size(); i++)
206
+ {
207
+ get(i).ExtractBigData(hashtable);
208
+ }
209
+
210
+ blockloop = false;
191211 }
192212
193213 ExtractBigData(o);
....@@ -195,11 +215,26 @@
195215
196216 void ExtractBigData(Object3D o)
197217 {
218
+ if (o.bRep != null)
219
+ Grafreed.Assert(o.bRep == this.bRep);
220
+
198221 o.bRep = this.bRep;
199
- if (this.bRep != null)
222
+// July 2019 if (this.bRep != null)
223
+// {
224
+// o.transientrep = this.bRep.support;
225
+// o.bRep.support = null;
226
+// }
227
+ o.selection = this.selection;
228
+ o.versionlist = this.versionlist;
229
+ o.versionindex = this.versionindex;
230
+
231
+ if (this.support != null)
200232 {
201
- o.transientrep = this.bRep.support;
202
- o.bRep.support = null;
233
+ if (o.transientrep != null)
234
+ Grafreed.Assert(o.transientrep == this.support.bRep);
235
+
236
+ o.transientrep = this.support.bRep;
237
+ this.support.bRep = null;
203238 }
204239
205240 // o.support = this.support;
....@@ -214,6 +249,73 @@
214249 // this.fileparent = null;
215250 }
216251
252
+// Object3D GetObject(java.util.UUID uuid)
253
+// {
254
+// if (this.uuid.equals(uuid))
255
+// return this;
256
+//
257
+// if (blockloop)
258
+// return null;
259
+//
260
+// blockloop = true;
261
+//
262
+// for (int i=0; i<Size(); i++)
263
+// {
264
+// Object3D o = get(i).GetObject(uuid);
265
+//
266
+// if (o != null)
267
+// return o;
268
+// }
269
+//
270
+// blockloop = false;
271
+//
272
+// return null;
273
+// }
274
+
275
+ transient boolean tag;
276
+
277
+ void TagObjects(Object3D o, boolean tag)
278
+ {
279
+ if (blockloop)
280
+ return;
281
+
282
+ o.tag = tag;
283
+
284
+ if (o == this)
285
+ return;
286
+
287
+ blockloop = true;
288
+
289
+ for (int i=0; i<Size(); i++)
290
+ {
291
+ get(i).TagObjects(o, tag);
292
+ }
293
+
294
+ blockloop = false;
295
+ }
296
+
297
+ boolean HasTags()
298
+ {
299
+ if (blockloop)
300
+ return false;
301
+
302
+ blockloop = true;
303
+
304
+ boolean hasTags = false;
305
+
306
+ for (int i=0; i<Size(); i++)
307
+ {
308
+ hasTags |= get(i).tag || get(i).HasTags();
309
+
310
+ if (hasTags)
311
+ break;
312
+ }
313
+
314
+ blockloop = false;
315
+
316
+ return hasTags;
317
+ }
318
+
217319 void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
218320 {
219321 if (!hashtable.containsKey(GetUUID()))
....@@ -223,19 +325,35 @@
223325
224326 RestoreBigData(o);
225327
226
- hashtable.remove(GetUUID());
328
+ if (blockloop)
329
+ return;
330
+
331
+ blockloop = true;
332
+
333
+ //hashtable.remove(GetUUID());
227334
228335 for (int i=0; i<Size(); i++)
229336 {
230337 get(i).RestoreBigData(hashtable);
231338 }
339
+
340
+ blockloop = false;
232341 }
233342
234343 void RestoreBigData(Object3D o)
235344 {
236345 this.bRep = o.bRep;
237
- if (this.bRep != null)
238
- this.bRep.support = o.transientrep;
346
+ if (this.support != null && o.transientrep != null)
347
+ {
348
+ this.support.bRep = o.transientrep;
349
+ }
350
+
351
+ this.selection = o.selection;
352
+
353
+ this.versionlist = o.versionlist;
354
+ this.versionindex = o.versionindex;
355
+// July 2019 if (this.bRep != null)
356
+// this.bRep.support = o.transientrep;
239357 // this.support = o.support;
240358 // this.fileparent = o.fileparent;
241359 }
....@@ -381,6 +499,7 @@
381499 }
382500
383501 boolean live = false;
502
+ transient boolean keepdontselect;
384503 boolean dontselect = false;
385504 boolean hide = false;
386505 boolean link2master = false; // performs reset support/master at each frame
....@@ -568,7 +687,7 @@
568687 {
569688 if (maxcount != 1)
570689 {
571
- new Exception().printStackTrace();
690
+ //new Exception().printStackTrace();
572691 }
573692
574693 toParentMarked = LA.newMatrix();
....@@ -881,7 +1000,7 @@
8811000
8821001 if (marked && Globals.isLIVE() && live &&
8831002 //TEMP21aug2018
884
- (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
1003
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
8851004 currentframe != Globals.framecount)
8861005 {
8871006 currentframe = Globals.framecount;
....@@ -966,6 +1085,10 @@
9661085 if (material == null || material.multiply)
9671086 return true;
9681087
1088
+ if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
1089
+ return false;
1090
+
1091
+ // Transparent objects are dynamic because we have to sort the triangles.
9691092 return material.opacity > 0.99;
9701093 }
9711094
....@@ -1366,6 +1489,7 @@
13661489 toParent = LA.newMatrix();
13671490 fromParent = LA.newMatrix();
13681491 }
1492
+
13691493 LA.matCopy(other.toParent, toParent);
13701494 LA.matCopy(other.fromParent, fromParent);
13711495
....@@ -2245,11 +2369,6 @@
22452369
22462370 InitOthers();
22472371
2248
- if (this instanceof Camera)
2249
- {
2250
- material.shift = 90;
2251
- }
2252
-
22532372 material.multiply = multiply;
22542373
22552374 if (multiply)
....@@ -2390,6 +2509,11 @@
23902509 else
23912510 {
23922511 //((ObjEditor)editWindow).SetupUI2(null);
2512
+ if (objectUI != null)
2513
+ ((ObjEditor)objectUI).pinButton.setSelected(pinned);
2514
+ else
2515
+ //new Exception().printStackTrace();
2516
+ System.err.println("objectUI is null");
23932517 }
23942518 }
23952519
....@@ -2432,6 +2556,14 @@
24322556 {
24332557 editWindow.refreshContents();
24342558 }
2559
+ else
2560
+ {
2561
+ if (manipWindow != null)
2562
+ {
2563
+ manipWindow.refreshContents();
2564
+ }
2565
+ }
2566
+
24352567 //if (parent != null)
24362568 //parent.refreshEditWindow();
24372569 }
....@@ -2511,7 +2643,8 @@
25112643 private static final int editSelf = 1;
25122644 private static final int editChild = 2;
25132645
2514
- void drawEditHandles(ClickInfo info, int level)
2646
+ void drawEditHandles(//ClickInfo info,
2647
+ int level)
25152648 {
25162649 if (level == 0)
25172650 {
....@@ -2519,7 +2652,8 @@
25192652 return;
25202653
25212654 Object3D selectee;
2522
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2655
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2656
+ level + 1))
25232657 {
25242658 selectee = (Object3D) e.nextElement();
25252659 }
....@@ -2527,19 +2661,22 @@
25272661 } else
25282662 {
25292663 //super.
2530
- drawEditHandles0(info, level + 1);
2664
+ drawEditHandles0(//info,
2665
+ level + 1);
25312666 }
25322667 }
25332668
2534
- boolean doEditClick(ClickInfo info, int level)
2669
+ boolean doEditClick(//ClickInfo info,
2670
+ int level)
25352671 {
25362672 doSomething = 0;
25372673 if (level == 0)
25382674 {
2539
- return doParentClick(info);
2675
+ return doParentClick(); //info);
25402676 }
25412677 if (//super.
2542
- doEditClick0(info, level))
2678
+ doEditClick0(//info,
2679
+ level))
25432680 {
25442681 doSomething = 1;
25452682 return true;
....@@ -2549,7 +2686,7 @@
25492686 }
25502687 }
25512688
2552
- boolean doParentClick(ClickInfo info)
2689
+ boolean doParentClick() //ClickInfo info)
25532690 {
25542691 if (selection == null)
25552692 {
....@@ -2562,7 +2699,8 @@
25622699 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
25632700 {
25642701 Object3D selectee = (Object3D) e.nextElement();
2565
- if (selectee.doEditClick(info, 1))
2702
+ if (selectee.doEditClick(//info,
2703
+ 1))
25662704 {
25672705 childToDrag = selectee;
25682706 doSomething = 2;
....@@ -2574,13 +2712,15 @@
25742712 return retval;
25752713 }
25762714
2577
- void doEditDrag(ClickInfo info, boolean opposite)
2715
+ void doEditDrag(//ClickInfo clickInfo,
2716
+ boolean opposite)
25782717 {
25792718 switch (doSomething)
25802719 {
25812720 case 1: // '\001'
25822721 //super.
2583
- doEditDrag0(info, opposite);
2722
+ doEditDrag0(//clickInfo,
2723
+ opposite);
25842724 break;
25852725
25862726 case 2: // '\002'
....@@ -2593,11 +2733,13 @@
25932733 {
25942734 //sel.hitSomething = childToDrag.hitSomething;
25952735 //childToDrag.doEditDrag(info);
2596
- sel.doEditDrag(info, opposite);
2736
+ sel.doEditDrag(//clickInfo,
2737
+ opposite);
25972738 } else
25982739 {
25992740 //super.
2600
- doEditDrag0(info, opposite);
2741
+ doEditDrag0(//clickInfo,
2742
+ opposite);
26012743 }
26022744 }
26032745 break;
....@@ -2615,6 +2757,9 @@
26152757 {
26162758 deselectAll();
26172759 }
2760
+
2761
+ new Exception().printStackTrace();
2762
+
26182763 ClickInfo newInfo = new ClickInfo();
26192764 newInfo.flags = info.flags;
26202765 newInfo.bounds = info.bounds;
....@@ -3062,7 +3207,7 @@
30623207 {
30633208 if (bRep != null)
30643209 {
3065
- bRep.GenerateNormalsMINE();
3210
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
30663211 Touch();
30673212 }
30683213 }
....@@ -3472,15 +3617,47 @@
34723617
34733618 void ClearMaterials()
34743619 {
3620
+ if (blockloop)
3621
+ return;
3622
+
3623
+ blockloop = true;
3624
+
34753625 ClearMaterial();
3476
- for (int i = 0; i < size(); i++)
3626
+ for (int i = 0; i < Size(); i++)
34773627 {
3478
- Object3D child = (Object3D) reserve(i);
3628
+ Object3D child = (Object3D) get(i);
34793629 if (child == null)
34803630 continue;
34813631 child.ClearMaterials();
3482
- release(i);
34833632 }
3633
+
3634
+ blockloop = false;
3635
+ }
3636
+
3637
+ void ClearVersionList()
3638
+ {
3639
+ this.versionlist = null;
3640
+ this.versionindex = -1;
3641
+ this.versiontable = null;
3642
+ }
3643
+
3644
+ void ClearVersions()
3645
+ {
3646
+ if (blockloop)
3647
+ return;
3648
+
3649
+ blockloop = true;
3650
+
3651
+ ClearVersionList();
3652
+ for (int i = 0; i < Size(); i++)
3653
+ {
3654
+ Object3D child = (Object3D) get(i);
3655
+ if (child == null)
3656
+ continue;
3657
+ child.ClearVersions();
3658
+ }
3659
+
3660
+ blockloop = false;
34843661 }
34853662
34863663 void FlipV(boolean flip)
....@@ -4962,6 +5139,14 @@
49625139 }
49635140 }
49645141
5142
+ ObjEditor GetWindow()
5143
+ {
5144
+ if (editWindow != null)
5145
+ return editWindow;
5146
+
5147
+ return manipWindow;
5148
+ }
5149
+
49655150 cTreePath Select(int indexcount, boolean deselect)
49665151 {
49675152 if (hide || dontselect)
....@@ -4998,10 +5183,11 @@
49985183 if (leaf != null)
49995184 {
50005185 cTreePath tp = new cTreePath(this, leaf);
5001
- if (editWindow != null)
5186
+ ObjEditor window = GetWindow();
5187
+ if (window != null)
50025188 {
50035189 //System.out.println("editWindow = " + editWindow + " vs " + this);
5004
- editWindow.Select(tp, deselect, true);
5190
+ window.Select(tp, deselect, true);
50055191 }
50065192
50075193 return tp;
....@@ -5018,6 +5204,7 @@
50185204
50195205 if (child == null)
50205206 continue;
5207
+
50215208 if (child.HasTransparency() && child.size() != 0)
50225209 {
50235210 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -5027,9 +5214,10 @@
50275214 if (leaf != null)
50285215 {
50295216 cTreePath tp = new cTreePath(this, leaf);
5030
- if (editWindow != null)
5217
+ ObjEditor window = GetWindow();
5218
+ if (window != null)
50315219 {
5032
- editWindow.Select(tp, deselect, true);
5220
+ window.Select(tp, deselect, true);
50335221 }
50345222
50355223 return tp;
....@@ -5354,6 +5542,51 @@
53545542 blockloop = false;
53555543 }
53565544
5545
+ void ResetSelectable()
5546
+ {
5547
+ if (blockloop)
5548
+ return;
5549
+
5550
+ blockloop = true;
5551
+
5552
+ keepdontselect = dontselect;
5553
+ dontselect = true;
5554
+
5555
+ Object3D child;
5556
+ int nb = Size();
5557
+ for (int i = 0; i < nb; i++)
5558
+ {
5559
+ child = (Object3D) get(i);
5560
+ if (child == null)
5561
+ continue;
5562
+ child.ResetSelectable();
5563
+ }
5564
+
5565
+ blockloop = false;
5566
+ }
5567
+
5568
+ void RestoreSelectable()
5569
+ {
5570
+ if (blockloop)
5571
+ return;
5572
+
5573
+ blockloop = true;
5574
+
5575
+ dontselect = keepdontselect;
5576
+
5577
+ Object3D child;
5578
+ int nb = Size();
5579
+ for (int i = 0; i < nb; i++)
5580
+ {
5581
+ child = (Object3D) get(i);
5582
+ if (child == null)
5583
+ continue;
5584
+ child.RestoreSelectable();
5585
+ }
5586
+
5587
+ blockloop = false;
5588
+ }
5589
+
53575590 boolean IsSelected()
53585591 {
53595592 if (parent == null)
....@@ -5414,6 +5647,11 @@
54145647 if (fullname == null)
54155648 return "";
54165649
5650
+ if (fullname.pigment != null)
5651
+ {
5652
+ return fullname.pigment;
5653
+ }
5654
+
54175655 // System.out.println("Fullname = " + fullname);
54185656
54195657 // Does not work on Windows due to C:
....@@ -5426,7 +5664,7 @@
54265664
54275665 if (split.length == 0)
54285666 {
5429
- return "";
5667
+ return fullname.pigment = "";
54305668 }
54315669
54325670 if (split.length <= 2)
....@@ -5434,22 +5672,27 @@
54345672 if (fullname.name.endsWith(":"))
54355673 {
54365674 // Windows
5437
- return fullname.name.substring(0, fullname.name.length()-1);
5675
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
54385676 }
54395677
5440
- return split[0];
5678
+ return fullname.pigment = split[0];
54415679 }
54425680
54435681 // Windows
54445682 assert(split.length == 4);
54455683
5446
- return split[0] + ":" + split[1];
5684
+ return fullname.pigment = split[0] + ":" + split[1];
54475685 }
54485686
54495687 static String GetBump(cTexture fullname)
54505688 {
54515689 if (fullname == null)
54525690 return "";
5691
+
5692
+ if (fullname.bump != null)
5693
+ {
5694
+ return fullname.bump;
5695
+ }
54535696
54545697 // System.out.println("Fullname = " + fullname);
54555698 // Does not work on Windows due to C:
....@@ -5461,12 +5704,12 @@
54615704
54625705 if (split.length == 0)
54635706 {
5464
- return "";
5707
+ return fullname.bump = "";
54655708 }
54665709
54675710 if (split.length == 1)
54685711 {
5469
- return "";
5712
+ return fullname.bump = "";
54705713 }
54715714
54725715 if (split.length == 2)
....@@ -5474,16 +5717,16 @@
54745717 if (fullname.name.endsWith(":"))
54755718 {
54765719 // Windows
5477
- return "";
5720
+ return fullname.bump = "";
54785721 }
54795722
5480
- return split[1];
5723
+ return fullname.bump = split[1];
54815724 }
54825725
54835726 // Windows
54845727 assert(split.length == 4);
54855728
5486
- return split[2] + ":" + split[3];
5729
+ return fullname.bump = split[2] + ":" + split[3];
54875730 }
54885731
54895732 String GetPigmentTexture()
....@@ -5566,6 +5809,9 @@
55665809 texname = "";
55675810
55685811 GetTextures().name = texname + ":" + GetBump(GetTextures());
5812
+
5813
+ GetTextures().pigment = null;
5814
+
55695815 Touch();
55705816 }
55715817
....@@ -5639,6 +5885,8 @@
56395885
56405886 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
56415887
5888
+ GetTextures().bump = null;
5889
+
56425890 Touch();
56435891 }
56445892
....@@ -5659,6 +5907,38 @@
56595907
56605908 blockloop = true;
56615909 child.ResetBumpTexture();
5910
+ blockloop = false;
5911
+ }
5912
+ }
5913
+
5914
+ void EmbedTextures(boolean embed)
5915
+ {
5916
+ if (blockloop)
5917
+ return;
5918
+
5919
+ //if (GetTextures() != null)
5920
+ if (embed)
5921
+ CameraPane.EmbedTextures(GetTextures());
5922
+ else
5923
+ {
5924
+ GetTextures().pigmentdata = null;
5925
+ GetTextures().bumpdata = null;
5926
+ GetTextures().pw = 0;
5927
+ GetTextures().ph = 0;
5928
+ GetTextures().bw = 0;
5929
+ GetTextures().bh = 0;
5930
+ }
5931
+
5932
+ int nb = Size();
5933
+ for (int i = 0; i < nb; i++)
5934
+ {
5935
+ Object3D child = (Object3D) get(i);
5936
+
5937
+ if (child == null)
5938
+ continue;
5939
+
5940
+ blockloop = true;
5941
+ child.EmbedTextures(embed);
56625942 blockloop = false;
56635943 }
56645944 }
....@@ -5749,8 +6029,10 @@
57496029 if (support != null)
57506030 support = support;
57516031
5752
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5753
- boolean usecalllists = IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
6032
+ boolean usecalllists = !IsLive() && IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
6033
+ //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
6034
+
6035
+ //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass.
57546036
57556037 if (!usecalllists && bRep != null && bRep.displaylist > 0)
57566038 {
....@@ -5760,8 +6042,9 @@
57606042 // usecalllists &= !(parent instanceof RandomNode);
57616043 // usecalllists = false;
57626044
5763
- if (GetBRep() != null)
5764
- usecalllists = usecalllists;
6045
+ if (display.DrawMode() == display.SHADOW)
6046
+ //GetBRep() != null)
6047
+ usecalllists = !!usecalllists;
57656048 //System.out.println("draw " + this);
57666049 //new Exception().printStackTrace();
57676050
....@@ -5771,7 +6054,7 @@
57716054
57726055 if (!selectmode && //display.DrawMode() != display.SELECTION &&
57736056 //(touched || (bRep != null && bRep.displaylist <= 0)))
5774
- (Globals.isLIVE() || touched && (bRep != null && bRep.displaylist <= 0)))
6057
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
57756058 {
57766059 Globals.lighttouched = true;
57776060 } // all panes...
....@@ -5783,7 +6066,7 @@
57836066 if (!(this instanceof Composite))
57846067 touched = false;
57856068 //if (displaylist == -1 && usecalllists)
5786
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
6069
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
57876070 {
57886071 bRep.displaylist = display.GenList();
57896072 assert(bRep.displaylist != 0);
....@@ -5794,7 +6077,7 @@
57946077
57956078 //System.out.println("\tnew list " + list);
57966079 //gl.glDrawBuffer(gl.GL_NONE);
5797
- if (usecalllists)
6080
+ if (usecalllists && bRep.displaylist > 0)
57986081 {
57996082 // System.err.println("new list " + bRep.displaylist + " for " + this);
58006083 display.NewList(bRep.displaylist);
....@@ -5803,7 +6086,7 @@
58036086 CallList(display, root, selected, blocked);
58046087
58056088 // compiled = true;
5806
- if (usecalllists)
6089
+ if (usecalllists && bRep.displaylist > 0)
58076090 {
58086091 // System.err.println("end list " + bRep.displaylist + " for " + this);
58096092 display.EndList();
....@@ -5903,6 +6186,7 @@
59036186 if (GetBRep() != null)
59046187 {
59056188 display.NextIndex();
6189
+
59066190 // vertex color conflict : gl.glCallList(list);
59076191 DrawNode(display, root, selected);
59086192 if (this instanceof BezierPatch)
....@@ -7153,20 +7437,23 @@
71537437 }
71547438 }
71557439
7156
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7440
+ static ClickInfo clickInfo = new ClickInfo();
7441
+
7442
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7443
+ Point outPt, Rectangle outRec)
71577444 {
7158
- int hc = info.bounds.x + info.bounds.width / 2;
7159
- int vc = info.bounds.y + info.bounds.height / 2;
7160
- double[][] toscreen = info.toScreen;
7445
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7446
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7447
+ double[][] toscreen = clickInfo.toScreen;
71617448 if (toscreen == null)
71627449 {
7163
- toscreen = new Camera(info.camera.viewCode).toScreen;
7450
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
71647451 }
71657452 cVector vec = in;
71667453 LA.xformPos(in, toscreen, in);
71677454 //System.out.println("Distance = " + info.camera.Distance());
7168
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7169
- vec.y *= 100 * info.camera.SCALE / info.camera.Distance();
7455
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7456
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
71707457 outPt.x = hc + (int) vec.x;
71717458 outPt.y = vc - (int) vec.y;
71727459 outRec.x = outPt.x - 3;
....@@ -7174,15 +7461,18 @@
71747461 outRec.width = outRec.height = 6;
71757462 }
71767463
7177
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7464
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7465
+ )
71787466 {
71797467 Point pt = new Point(0, 0);
71807468 Rectangle rec = new Rectangle();
7181
- calcHotSpot(in, info, pt, rec);
7469
+ calcHotSpot(in, //clickInfo,
7470
+ pt, rec);
71827471 return rec;
71837472 }
71847473
7185
- void drawEditHandles0(ClickInfo info, int level)
7474
+ void drawEditHandles0(//ClickInfo clickInfo,
7475
+ int level)
71867476 {
71877477 if (level == 0)
71887478 {
....@@ -7191,16 +7481,19 @@
71917481 {
71927482 cVector origin = new cVector();
71937483 //LA.xformPos(origin, toParent, origin);
7194
- Rectangle spot = calcHotSpot(origin, info);
7484
+ if (this.clickInfo == null)
7485
+ this.clickInfo = new ClickInfo();
7486
+
7487
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
71957488 Rectangle boundary = new Rectangle();
71967489 boundary.x = spot.x - 30;
71977490 boundary.y = spot.y - 30;
71987491 boundary.width = spot.width + 60;
71997492 boundary.height = spot.height + 60;
7200
- info.g.setColor(Color.red);
7493
+ clickInfo.g.setColor(Color.white);
72017494 int spotw = spot.x + spot.width;
72027495 int spoth = spot.y + spot.height;
7203
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7496
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72047497 // if (CameraPane.Xmin > spot.x)
72057498 // {
72067499 // CameraPane.Xmin = spot.x;
....@@ -7217,11 +7510,6 @@
72177510 // {
72187511 // CameraPane.Ymax = spoth;
72197512 // }
7220
- spot.translate(32, 32);
7221
- spotw = spot.x + spot.width;
7222
- spoth = spot.y + spot.height;
7223
- info.g.setColor(Color.cyan);
7224
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72257513 // if (CameraPane.Xmin > spot.x)
72267514 // {
72277515 // CameraPane.Xmin = spot.x;
....@@ -7240,10 +7528,15 @@
72407528 // }
72417529 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
72427530 //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7243
- spot.translate(0, -32);
7244
- info.g.setColor(Color.yellow);
7245
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7246
- info.g.setColor(Color.green);
7531
+ spot.translate(32, 0);
7532
+ clickInfo.g.setColor(Color.yellow);
7533
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7534
+
7535
+ spot.translate(32, 64);
7536
+ spotw = spot.x + spot.width;
7537
+ spoth = spot.y + spot.height;
7538
+ clickInfo.g.setColor(Color.cyan);
7539
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72477540 // if (CameraPane.Xmin > spot.x)
72487541 // {
72497542 // CameraPane.Xmin = spot.x;
....@@ -7260,8 +7553,9 @@
72607553 // {
72617554 // CameraPane.Ymax = spoth;
72627555 // }
7263
- info.g.drawArc(boundary.x, boundary.y,
7264
- boundary.width, boundary.height, 0, 360);
7556
+ clickInfo.g.setColor(Color.green);
7557
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7558
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
72657559 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
72667560 // if (CameraPane.Xmin > boundary.x)
72677561 // {
....@@ -7283,7 +7577,8 @@
72837577 }
72847578 }
72857579
7286
- boolean doEditClick0(ClickInfo info, int level)
7580
+ boolean doEditClick0(//ClickInfo clickInfo,
7581
+ int level)
72877582 {
72887583 if (level == 0)
72897584 {
....@@ -7292,8 +7587,8 @@
72927587
72937588 boolean retval = false;
72947589
7295
- startX = info.x;
7296
- startY = info.y;
7590
+ startX = clickInfo.x;
7591
+ startY = clickInfo.y;
72977592
72987593 hitSomething = -1;
72997594 cVector origin = new cVector();
....@@ -7303,22 +7598,53 @@
73037598 {
73047599 centerPt = new Point(0, 0);
73057600 }
7306
- calcHotSpot(origin, info, centerPt, spot);
7307
- if (spot.contains(info.x, info.y))
7601
+ calcHotSpot(origin, //info,
7602
+ centerPt, spot);
7603
+ if (spot.contains(clickInfo.x, clickInfo.y))
73087604 {
73097605 hitSomething = hitCenter;
73107606 retval = true;
73117607 }
73127608 spot.translate(32, 0);
7313
- if (spot.contains(info.x, info.y))
7609
+ if (spot.contains(clickInfo.x, clickInfo.y))
73147610 {
73157611 hitSomething = hitRotate;
73167612 retval = true;
73177613 }
73187614 spot.translate(0, 32);
7319
- if (spot.contains(info.x, info.y))
7615
+ spot.translate(32, 0);
7616
+ spot.translate(0, 32);
7617
+ if (spot.contains(clickInfo.x, clickInfo.y))
73207618 {
73217619 hitSomething = hitScale;
7620
+
7621
+ double scale = 0.005f * clickInfo.camera.Distance();
7622
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
7623
+ double sign = 1;
7624
+ if (hScale < 0)
7625
+ {
7626
+ sign = -1;
7627
+ }
7628
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7629
+ if (hScale < 0.01)
7630
+ {
7631
+ //hScale = 0.01;
7632
+ }
7633
+
7634
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
7635
+ sign = 1;
7636
+ if (vScale < 0)
7637
+ {
7638
+ sign = -1;
7639
+ }
7640
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7641
+ if (vScale < 0.01)
7642
+ {
7643
+ //vScale = 0.01;
7644
+ }
7645
+
7646
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7647
+
73227648 retval = true;
73237649 }
73247650
....@@ -7328,7 +7654,7 @@
73287654 }
73297655
73307656 //System.out.println("info.modifiers = " + info.modifiers);
7331
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7657
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
73327658 //System.out.println("modified = " + modified);
73337659 //new Exception().printStackTrace();
73347660 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7356,7 +7682,8 @@
73567682 return true;
73577683 }
73587684
7359
- void doEditDrag0(ClickInfo info, boolean opposite)
7685
+ void doEditDrag0(//ClickInfo info,
7686
+ boolean opposite)
73607687 {
73617688 if (hitSomething == 0)
73627689 {
....@@ -7370,7 +7697,7 @@
73707697
73717698 //System.out.println("hitSomething = " + hitSomething);
73727699
7373
- double scale = 0.005f * info.camera.Distance();
7700
+ double scale = 0.005f * clickInfo.camera.Distance();
73747701
73757702 cVector xlate = new cVector();
73767703 //cVector xlate2 = new cVector();
....@@ -7384,7 +7711,9 @@
73847711
73857712 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
73867713
7387
- if (modified || opposite)
7714
+ // Modified could snap
7715
+ if (//modified ||
7716
+ opposite)
73887717 {
73897718 //assert(false);
73907719 /*
....@@ -7404,8 +7733,8 @@
74047733 toParent[3][i] = xlate.get(i);
74057734 LA.matInvert(toParent, fromParent);
74067735 */
7407
- cVector delta = LA.newVector(0, 0, startY - info.y);
7408
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7736
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7737
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
74097738
74107739 LA.matCopy(startMat, toParent);
74117740 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7414,7 +7743,7 @@
74147743 } else
74157744 {
74167745 //LA.xformDir(delta, info.camera.fromScreen, delta);
7417
- cVector up = new cVector(info.camera.up);
7746
+ cVector up = new cVector(clickInfo.camera.up);
74187747 cVector away = new cVector();
74197748 //cVector right2 = new cVector();
74207749 //LA.vecCross(up, cVector.Z, right);
....@@ -7431,19 +7760,19 @@
74317760 LA.xformDir(up, ClickInfo.matbuffer, up);
74327761 // if (!CameraPane.LOCALTRANSFORM)
74337762 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7434
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7763
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
74357764 // if (!CameraPane.LOCALTRANSFORM)
74367765 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
74377766 //LA.vecCross(up, cVector.Z, right2);
74387767
7439
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7768
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
74407769
74417770 //System.out.println("DELTA0 = " + delta);
74427771 //System.out.println("AWAY = " + info.camera.away);
74437772 //System.out.println("UP = " + info.camera.up);
74447773 if (away.z > 0)
74457774 {
7446
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7775
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
74477776 {
74487777 delta.x = -delta.x;
74497778 } else
....@@ -7458,7 +7787,7 @@
74587787 //System.out.println("DELTA1 = " + delta);
74597788 LA.xformDir(delta, ClickInfo.matbuffer, delta);
74607789 //System.out.println("DELTA2 = " + delta);
7461
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7790
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
74627791 LA.matCopy(startMat, toParent);
74637792 //System.out.println("DELTA3 = " + delta);
74647793 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7468,8 +7797,8 @@
74687797 break;
74697798
74707799 case hitRotate: // rotate
7471
- int dx = info.x - centerPt.x;
7472
- int dy = -(info.y - centerPt.y);
7800
+ int dx = clickInfo.x - centerPt.x;
7801
+ int dy = -(clickInfo.y - centerPt.y);
74737802 double angle = (double) Math.atan2(dx, dy);
74747803 angle = -(1.570796 - angle);
74757804
....@@ -7478,7 +7807,7 @@
74787807
74797808 if (modified)
74807809 {
7481
- // Rotate 90 degrees
7810
+ // Rotate 45 degrees
74827811 angle /= (Math.PI / 4);
74837812 angle = Math.floor(angle + 0.5);
74847813 angle *= (Math.PI / 4);
....@@ -7492,7 +7821,7 @@
74927821 }
74937822 /**/
74947823
7495
- switch (info.pane.RenderCamera().viewCode)
7824
+ switch (clickInfo.pane.RenderCamera().viewCode)
74967825 {
74977826 case 1: // '\001'
74987827 LA.matZRotate(toParent, angle);
....@@ -7519,7 +7848,7 @@
75197848 break;
75207849
75217850 case hitScale: // scale
7522
- double hScale = (double) (info.x - centerPt.x) / 32;
7851
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
75237852 double sign = 1;
75247853 if (hScale < 0)
75257854 {
....@@ -7531,7 +7860,7 @@
75317860 //hScale = 0.01;
75327861 }
75337862
7534
- double vScale = (double) (info.y - centerPt.y) / 32;
7863
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
75357864 sign = 1;
75367865 if (vScale < 0)
75377866 {
....@@ -7542,6 +7871,7 @@
75427871 {
75437872 //vScale = 0.01;
75447873 }
7874
+
75457875 LA.matCopy(startMat, toParent);
75467876 /**/
75477877 for (int i = 0; i < 3; i++)
....@@ -7551,33 +7881,39 @@
75517881 }
75527882 /**/
75537883
7554
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7884
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
75557885
75567886 if (totalScale < 0.01)
75577887 {
75587888 totalScale = 0.01;
75597889 }
75607890
7561
- switch (info.pane.RenderCamera().viewCode)
7891
+ switch (clickInfo.pane.RenderCamera().viewCode)
75627892 {
75637893 case 3: // '\001'
75647894 if (modified || opposite)
75657895 {
7896
+ if (modified) // && opposite)
7897
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7898
+ else
75667899 //LA.matScale(toParent, 1, hScale, vScale);
7567
- LA.matScale(toParent, totalScale, 1, 1);
7900
+ LA.matScale(toParent, totalScale, 1, 1);
75687901 } // vScale, 1);
75697902 else
75707903 {
75717904 // EXCEPTION!
7572
- LA.matScale(toParent, totalScale, totalScale, totalScale);
7905
+ LA.matScale(toParent, 1, totalScale, totalScale);
75737906 } // vScale, 1);
75747907 break;
75757908
75767909 case 2: // '\002'
75777910 if (modified || opposite)
75787911 {
7579
- //LA.matScale(toParent, hScale, 1, vScale);
7580
- LA.matScale(toParent, 1, totalScale, 1);
7912
+ if (modified) // && opposite)
7913
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7914
+ else
7915
+ //LA.matScale(toParent, hScale, 1, vScale);
7916
+ LA.matScale(toParent, 1, totalScale, 1);
75817917 } else
75827918 {
75837919 LA.matScale(toParent, totalScale, 1, totalScale);
....@@ -7587,8 +7923,11 @@
75877923 case 1: // '\003'
75887924 if (modified || opposite)
75897925 {
7590
- //LA.matScale(toParent, hScale, vScale, 1);
7591
- LA.matScale(toParent, 1, 1, totalScale);
7926
+ if (modified) // && opposite)
7927
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7928
+ else
7929
+ //LA.matScale(toParent, hScale, vScale, 1);
7930
+ LA.matScale(toParent, 1, 1, totalScale);
75927931 } else
75937932 {
75947933 LA.matScale(toParent, totalScale, totalScale, 1);
....@@ -7625,7 +7964,7 @@
76257964 } // NEW ...
76267965
76277966
7628
- info.pane.repaint();
7967
+ clickInfo.pane.repaint();
76297968 }
76307969
76317970 boolean overflow = false;
....@@ -7966,6 +8305,10 @@
79668305 }
79678306
79688307 transient ObjEditor editWindow;
8308
+ transient ObjEditor manipWindow;
8309
+
8310
+ transient boolean pinned;
8311
+
79698312 transient ObjectUI objectUI;
79708313 public static int povDepth = 0;
79718314 private static cVector tbMin = new cVector();