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)
....@@ -2387,6 +2506,15 @@
23872506 }
23882507 */
23892508 }
2509
+ else
2510
+ {
2511
+ //((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");
2517
+ }
23902518 }
23912519
23922520 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2428,6 +2556,14 @@
24282556 {
24292557 editWindow.refreshContents();
24302558 }
2559
+ else
2560
+ {
2561
+ if (manipWindow != null)
2562
+ {
2563
+ manipWindow.refreshContents();
2564
+ }
2565
+ }
2566
+
24312567 //if (parent != null)
24322568 //parent.refreshEditWindow();
24332569 }
....@@ -2507,7 +2643,8 @@
25072643 private static final int editSelf = 1;
25082644 private static final int editChild = 2;
25092645
2510
- void drawEditHandles(ClickInfo info, int level)
2646
+ void drawEditHandles(//ClickInfo info,
2647
+ int level)
25112648 {
25122649 if (level == 0)
25132650 {
....@@ -2515,7 +2652,8 @@
25152652 return;
25162653
25172654 Object3D selectee;
2518
- 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))
25192657 {
25202658 selectee = (Object3D) e.nextElement();
25212659 }
....@@ -2523,19 +2661,22 @@
25232661 } else
25242662 {
25252663 //super.
2526
- drawEditHandles0(info, level + 1);
2664
+ drawEditHandles0(//info,
2665
+ level + 1);
25272666 }
25282667 }
25292668
2530
- boolean doEditClick(ClickInfo info, int level)
2669
+ boolean doEditClick(//ClickInfo info,
2670
+ int level)
25312671 {
25322672 doSomething = 0;
25332673 if (level == 0)
25342674 {
2535
- return doParentClick(info);
2675
+ return doParentClick(); //info);
25362676 }
25372677 if (//super.
2538
- doEditClick0(info, level))
2678
+ doEditClick0(//info,
2679
+ level))
25392680 {
25402681 doSomething = 1;
25412682 return true;
....@@ -2545,7 +2686,7 @@
25452686 }
25462687 }
25472688
2548
- boolean doParentClick(ClickInfo info)
2689
+ boolean doParentClick() //ClickInfo info)
25492690 {
25502691 if (selection == null)
25512692 {
....@@ -2558,7 +2699,8 @@
25582699 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
25592700 {
25602701 Object3D selectee = (Object3D) e.nextElement();
2561
- if (selectee.doEditClick(info, 1))
2702
+ if (selectee.doEditClick(//info,
2703
+ 1))
25622704 {
25632705 childToDrag = selectee;
25642706 doSomething = 2;
....@@ -2570,13 +2712,15 @@
25702712 return retval;
25712713 }
25722714
2573
- void doEditDrag(ClickInfo info, boolean opposite)
2715
+ void doEditDrag(//ClickInfo clickInfo,
2716
+ boolean opposite)
25742717 {
25752718 switch (doSomething)
25762719 {
25772720 case 1: // '\001'
25782721 //super.
2579
- doEditDrag0(info, opposite);
2722
+ doEditDrag0(//clickInfo,
2723
+ opposite);
25802724 break;
25812725
25822726 case 2: // '\002'
....@@ -2589,11 +2733,13 @@
25892733 {
25902734 //sel.hitSomething = childToDrag.hitSomething;
25912735 //childToDrag.doEditDrag(info);
2592
- sel.doEditDrag(info, opposite);
2736
+ sel.doEditDrag(//clickInfo,
2737
+ opposite);
25932738 } else
25942739 {
25952740 //super.
2596
- doEditDrag0(info, opposite);
2741
+ doEditDrag0(//clickInfo,
2742
+ opposite);
25972743 }
25982744 }
25992745 break;
....@@ -2611,6 +2757,9 @@
26112757 {
26122758 deselectAll();
26132759 }
2760
+
2761
+ new Exception().printStackTrace();
2762
+
26142763 ClickInfo newInfo = new ClickInfo();
26152764 newInfo.flags = info.flags;
26162765 newInfo.bounds = info.bounds;
....@@ -3058,7 +3207,7 @@
30583207 {
30593208 if (bRep != null)
30603209 {
3061
- bRep.GenerateNormalsMINE();
3210
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
30623211 Touch();
30633212 }
30643213 }
....@@ -3468,15 +3617,47 @@
34683617
34693618 void ClearMaterials()
34703619 {
3620
+ if (blockloop)
3621
+ return;
3622
+
3623
+ blockloop = true;
3624
+
34713625 ClearMaterial();
3472
- for (int i = 0; i < size(); i++)
3626
+ for (int i = 0; i < Size(); i++)
34733627 {
3474
- Object3D child = (Object3D) reserve(i);
3628
+ Object3D child = (Object3D) get(i);
34753629 if (child == null)
34763630 continue;
34773631 child.ClearMaterials();
3478
- release(i);
34793632 }
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;
34803661 }
34813662
34823663 void FlipV(boolean flip)
....@@ -4958,6 +5139,14 @@
49585139 }
49595140 }
49605141
5142
+ ObjEditor GetWindow()
5143
+ {
5144
+ if (editWindow != null)
5145
+ return editWindow;
5146
+
5147
+ return manipWindow;
5148
+ }
5149
+
49615150 cTreePath Select(int indexcount, boolean deselect)
49625151 {
49635152 if (hide || dontselect)
....@@ -4994,10 +5183,11 @@
49945183 if (leaf != null)
49955184 {
49965185 cTreePath tp = new cTreePath(this, leaf);
4997
- if (editWindow != null)
5186
+ ObjEditor window = GetWindow();
5187
+ if (window != null)
49985188 {
49995189 //System.out.println("editWindow = " + editWindow + " vs " + this);
5000
- editWindow.Select(tp, deselect, true);
5190
+ window.Select(tp, deselect, true);
50015191 }
50025192
50035193 return tp;
....@@ -5014,6 +5204,7 @@
50145204
50155205 if (child == null)
50165206 continue;
5207
+
50175208 if (child.HasTransparency() && child.size() != 0)
50185209 {
50195210 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -5023,9 +5214,10 @@
50235214 if (leaf != null)
50245215 {
50255216 cTreePath tp = new cTreePath(this, leaf);
5026
- if (editWindow != null)
5217
+ ObjEditor window = GetWindow();
5218
+ if (window != null)
50275219 {
5028
- editWindow.Select(tp, deselect, true);
5220
+ window.Select(tp, deselect, true);
50295221 }
50305222
50315223 return tp;
....@@ -5350,6 +5542,51 @@
53505542 blockloop = false;
53515543 }
53525544
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
+
53535590 boolean IsSelected()
53545591 {
53555592 if (parent == null)
....@@ -5410,6 +5647,11 @@
54105647 if (fullname == null)
54115648 return "";
54125649
5650
+ if (fullname.pigment != null)
5651
+ {
5652
+ return fullname.pigment;
5653
+ }
5654
+
54135655 // System.out.println("Fullname = " + fullname);
54145656
54155657 // Does not work on Windows due to C:
....@@ -5422,7 +5664,7 @@
54225664
54235665 if (split.length == 0)
54245666 {
5425
- return "";
5667
+ return fullname.pigment = "";
54265668 }
54275669
54285670 if (split.length <= 2)
....@@ -5430,22 +5672,27 @@
54305672 if (fullname.name.endsWith(":"))
54315673 {
54325674 // Windows
5433
- return fullname.name.substring(0, fullname.name.length()-1);
5675
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
54345676 }
54355677
5436
- return split[0];
5678
+ return fullname.pigment = split[0];
54375679 }
54385680
54395681 // Windows
54405682 assert(split.length == 4);
54415683
5442
- return split[0] + ":" + split[1];
5684
+ return fullname.pigment = split[0] + ":" + split[1];
54435685 }
54445686
54455687 static String GetBump(cTexture fullname)
54465688 {
54475689 if (fullname == null)
54485690 return "";
5691
+
5692
+ if (fullname.bump != null)
5693
+ {
5694
+ return fullname.bump;
5695
+ }
54495696
54505697 // System.out.println("Fullname = " + fullname);
54515698 // Does not work on Windows due to C:
....@@ -5457,12 +5704,12 @@
54575704
54585705 if (split.length == 0)
54595706 {
5460
- return "";
5707
+ return fullname.bump = "";
54615708 }
54625709
54635710 if (split.length == 1)
54645711 {
5465
- return "";
5712
+ return fullname.bump = "";
54665713 }
54675714
54685715 if (split.length == 2)
....@@ -5470,16 +5717,16 @@
54705717 if (fullname.name.endsWith(":"))
54715718 {
54725719 // Windows
5473
- return "";
5720
+ return fullname.bump = "";
54745721 }
54755722
5476
- return split[1];
5723
+ return fullname.bump = split[1];
54775724 }
54785725
54795726 // Windows
54805727 assert(split.length == 4);
54815728
5482
- return split[2] + ":" + split[3];
5729
+ return fullname.bump = split[2] + ":" + split[3];
54835730 }
54845731
54855732 String GetPigmentTexture()
....@@ -5562,6 +5809,9 @@
55625809 texname = "";
55635810
55645811 GetTextures().name = texname + ":" + GetBump(GetTextures());
5812
+
5813
+ GetTextures().pigment = null;
5814
+
55655815 Touch();
55665816 }
55675817
....@@ -5635,6 +5885,8 @@
56355885
56365886 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
56375887
5888
+ GetTextures().bump = null;
5889
+
56385890 Touch();
56395891 }
56405892
....@@ -5655,6 +5907,38 @@
56555907
56565908 blockloop = true;
56575909 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);
56585942 blockloop = false;
56595943 }
56605944 }
....@@ -5745,8 +6029,10 @@
57456029 if (support != null)
57466030 support = support;
57476031
5748
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5749
- 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.
57506036
57516037 if (!usecalllists && bRep != null && bRep.displaylist > 0)
57526038 {
....@@ -5756,8 +6042,9 @@
57566042 // usecalllists &= !(parent instanceof RandomNode);
57576043 // usecalllists = false;
57586044
5759
- if (GetBRep() != null)
5760
- usecalllists = usecalllists;
6045
+ if (display.DrawMode() == display.SHADOW)
6046
+ //GetBRep() != null)
6047
+ usecalllists = !!usecalllists;
57616048 //System.out.println("draw " + this);
57626049 //new Exception().printStackTrace();
57636050
....@@ -5767,7 +6054,7 @@
57676054
57686055 if (!selectmode && //display.DrawMode() != display.SELECTION &&
57696056 //(touched || (bRep != null && bRep.displaylist <= 0)))
5770
- (Globals.isLIVE() || touched && (bRep != null && bRep.displaylist <= 0)))
6057
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
57716058 {
57726059 Globals.lighttouched = true;
57736060 } // all panes...
....@@ -5779,7 +6066,7 @@
57796066 if (!(this instanceof Composite))
57806067 touched = false;
57816068 //if (displaylist == -1 && usecalllists)
5782
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
6069
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
57836070 {
57846071 bRep.displaylist = display.GenList();
57856072 assert(bRep.displaylist != 0);
....@@ -5790,7 +6077,7 @@
57906077
57916078 //System.out.println("\tnew list " + list);
57926079 //gl.glDrawBuffer(gl.GL_NONE);
5793
- if (usecalllists)
6080
+ if (usecalllists && bRep.displaylist > 0)
57946081 {
57956082 // System.err.println("new list " + bRep.displaylist + " for " + this);
57966083 display.NewList(bRep.displaylist);
....@@ -5799,7 +6086,7 @@
57996086 CallList(display, root, selected, blocked);
58006087
58016088 // compiled = true;
5802
- if (usecalllists)
6089
+ if (usecalllists && bRep.displaylist > 0)
58036090 {
58046091 // System.err.println("end list " + bRep.displaylist + " for " + this);
58056092 display.EndList();
....@@ -5899,6 +6186,7 @@
58996186 if (GetBRep() != null)
59006187 {
59016188 display.NextIndex();
6189
+
59026190 // vertex color conflict : gl.glCallList(list);
59036191 DrawNode(display, root, selected);
59046192 if (this instanceof BezierPatch)
....@@ -6359,6 +6647,11 @@
63596647 // dec 2012
63606648 new Exception().printStackTrace();
63616649 return;
6650
+ }
6651
+
6652
+ if (dontselect)
6653
+ {
6654
+ //bRep.GenerateNormalsMINE();
63626655 }
63636656
63646657 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -7144,20 +7437,23 @@
71447437 }
71457438 }
71467439
7147
- 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)
71487444 {
7149
- int hc = info.bounds.x + info.bounds.width / 2;
7150
- int vc = info.bounds.y + info.bounds.height / 2;
7151
- 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;
71527448 if (toscreen == null)
71537449 {
7154
- toscreen = new Camera(info.camera.viewCode).toScreen;
7450
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
71557451 }
71567452 cVector vec = in;
71577453 LA.xformPos(in, toscreen, in);
71587454 //System.out.println("Distance = " + info.camera.Distance());
7159
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7160
- 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();
71617457 outPt.x = hc + (int) vec.x;
71627458 outPt.y = vc - (int) vec.y;
71637459 outRec.x = outPt.x - 3;
....@@ -7165,15 +7461,18 @@
71657461 outRec.width = outRec.height = 6;
71667462 }
71677463
7168
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7464
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7465
+ )
71697466 {
71707467 Point pt = new Point(0, 0);
71717468 Rectangle rec = new Rectangle();
7172
- calcHotSpot(in, info, pt, rec);
7469
+ calcHotSpot(in, //clickInfo,
7470
+ pt, rec);
71737471 return rec;
71747472 }
71757473
7176
- void drawEditHandles0(ClickInfo info, int level)
7474
+ void drawEditHandles0(//ClickInfo clickInfo,
7475
+ int level)
71777476 {
71787477 if (level == 0)
71797478 {
....@@ -7182,16 +7481,19 @@
71827481 {
71837482 cVector origin = new cVector();
71847483 //LA.xformPos(origin, toParent, origin);
7185
- Rectangle spot = calcHotSpot(origin, info);
7484
+ if (this.clickInfo == null)
7485
+ this.clickInfo = new ClickInfo();
7486
+
7487
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
71867488 Rectangle boundary = new Rectangle();
71877489 boundary.x = spot.x - 30;
71887490 boundary.y = spot.y - 30;
71897491 boundary.width = spot.width + 60;
71907492 boundary.height = spot.height + 60;
7191
- info.g.setColor(Color.red);
7493
+ clickInfo.g.setColor(Color.white);
71927494 int spotw = spot.x + spot.width;
71937495 int spoth = spot.y + spot.height;
7194
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7496
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
71957497 // if (CameraPane.Xmin > spot.x)
71967498 // {
71977499 // CameraPane.Xmin = spot.x;
....@@ -7208,11 +7510,6 @@
72087510 // {
72097511 // CameraPane.Ymax = spoth;
72107512 // }
7211
- spot.translate(32, 32);
7212
- spotw = spot.x + spot.width;
7213
- spoth = spot.y + spot.height;
7214
- info.g.setColor(Color.cyan);
7215
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72167513 // if (CameraPane.Xmin > spot.x)
72177514 // {
72187515 // CameraPane.Xmin = spot.x;
....@@ -7231,10 +7528,15 @@
72317528 // }
72327529 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
72337530 //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7234
- spot.translate(0, -32);
7235
- info.g.setColor(Color.yellow);
7236
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7237
- 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);
72387540 // if (CameraPane.Xmin > spot.x)
72397541 // {
72407542 // CameraPane.Xmin = spot.x;
....@@ -7251,8 +7553,9 @@
72517553 // {
72527554 // CameraPane.Ymax = spoth;
72537555 // }
7254
- info.g.drawArc(boundary.x, boundary.y,
7255
- 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);
72567559 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
72577560 // if (CameraPane.Xmin > boundary.x)
72587561 // {
....@@ -7274,7 +7577,8 @@
72747577 }
72757578 }
72767579
7277
- boolean doEditClick0(ClickInfo info, int level)
7580
+ boolean doEditClick0(//ClickInfo clickInfo,
7581
+ int level)
72787582 {
72797583 if (level == 0)
72807584 {
....@@ -7283,8 +7587,8 @@
72837587
72847588 boolean retval = false;
72857589
7286
- startX = info.x;
7287
- startY = info.y;
7590
+ startX = clickInfo.x;
7591
+ startY = clickInfo.y;
72887592
72897593 hitSomething = -1;
72907594 cVector origin = new cVector();
....@@ -7294,22 +7598,53 @@
72947598 {
72957599 centerPt = new Point(0, 0);
72967600 }
7297
- calcHotSpot(origin, info, centerPt, spot);
7298
- if (spot.contains(info.x, info.y))
7601
+ calcHotSpot(origin, //info,
7602
+ centerPt, spot);
7603
+ if (spot.contains(clickInfo.x, clickInfo.y))
72997604 {
73007605 hitSomething = hitCenter;
73017606 retval = true;
73027607 }
73037608 spot.translate(32, 0);
7304
- if (spot.contains(info.x, info.y))
7609
+ if (spot.contains(clickInfo.x, clickInfo.y))
73057610 {
73067611 hitSomething = hitRotate;
73077612 retval = true;
73087613 }
73097614 spot.translate(0, 32);
7310
- 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))
73117618 {
73127619 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
+
73137648 retval = true;
73147649 }
73157650
....@@ -7319,7 +7654,7 @@
73197654 }
73207655
73217656 //System.out.println("info.modifiers = " + info.modifiers);
7322
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7657
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
73237658 //System.out.println("modified = " + modified);
73247659 //new Exception().printStackTrace();
73257660 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7347,7 +7682,8 @@
73477682 return true;
73487683 }
73497684
7350
- void doEditDrag0(ClickInfo info, boolean opposite)
7685
+ void doEditDrag0(//ClickInfo info,
7686
+ boolean opposite)
73517687 {
73527688 if (hitSomething == 0)
73537689 {
....@@ -7361,7 +7697,7 @@
73617697
73627698 //System.out.println("hitSomething = " + hitSomething);
73637699
7364
- double scale = 0.005f * info.camera.Distance();
7700
+ double scale = 0.005f * clickInfo.camera.Distance();
73657701
73667702 cVector xlate = new cVector();
73677703 //cVector xlate2 = new cVector();
....@@ -7375,7 +7711,9 @@
73757711
73767712 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
73777713
7378
- if (modified || opposite)
7714
+ // Modified could snap
7715
+ if (//modified ||
7716
+ opposite)
73797717 {
73807718 //assert(false);
73817719 /*
....@@ -7395,8 +7733,8 @@
73957733 toParent[3][i] = xlate.get(i);
73967734 LA.matInvert(toParent, fromParent);
73977735 */
7398
- cVector delta = LA.newVector(0, 0, startY - info.y);
7399
- 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);
74007738
74017739 LA.matCopy(startMat, toParent);
74027740 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7405,7 +7743,7 @@
74057743 } else
74067744 {
74077745 //LA.xformDir(delta, info.camera.fromScreen, delta);
7408
- cVector up = new cVector(info.camera.up);
7746
+ cVector up = new cVector(clickInfo.camera.up);
74097747 cVector away = new cVector();
74107748 //cVector right2 = new cVector();
74117749 //LA.vecCross(up, cVector.Z, right);
....@@ -7422,19 +7760,19 @@
74227760 LA.xformDir(up, ClickInfo.matbuffer, up);
74237761 // if (!CameraPane.LOCALTRANSFORM)
74247762 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7425
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7763
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
74267764 // if (!CameraPane.LOCALTRANSFORM)
74277765 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
74287766 //LA.vecCross(up, cVector.Z, right2);
74297767
7430
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7768
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
74317769
74327770 //System.out.println("DELTA0 = " + delta);
74337771 //System.out.println("AWAY = " + info.camera.away);
74347772 //System.out.println("UP = " + info.camera.up);
74357773 if (away.z > 0)
74367774 {
7437
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7775
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
74387776 {
74397777 delta.x = -delta.x;
74407778 } else
....@@ -7449,7 +7787,7 @@
74497787 //System.out.println("DELTA1 = " + delta);
74507788 LA.xformDir(delta, ClickInfo.matbuffer, delta);
74517789 //System.out.println("DELTA2 = " + delta);
7452
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7790
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
74537791 LA.matCopy(startMat, toParent);
74547792 //System.out.println("DELTA3 = " + delta);
74557793 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7459,8 +7797,8 @@
74597797 break;
74607798
74617799 case hitRotate: // rotate
7462
- int dx = info.x - centerPt.x;
7463
- int dy = -(info.y - centerPt.y);
7800
+ int dx = clickInfo.x - centerPt.x;
7801
+ int dy = -(clickInfo.y - centerPt.y);
74647802 double angle = (double) Math.atan2(dx, dy);
74657803 angle = -(1.570796 - angle);
74667804
....@@ -7469,7 +7807,7 @@
74697807
74707808 if (modified)
74717809 {
7472
- // Rotate 90 degrees
7810
+ // Rotate 45 degrees
74737811 angle /= (Math.PI / 4);
74747812 angle = Math.floor(angle + 0.5);
74757813 angle *= (Math.PI / 4);
....@@ -7483,7 +7821,7 @@
74837821 }
74847822 /**/
74857823
7486
- switch (info.pane.RenderCamera().viewCode)
7824
+ switch (clickInfo.pane.RenderCamera().viewCode)
74877825 {
74887826 case 1: // '\001'
74897827 LA.matZRotate(toParent, angle);
....@@ -7510,7 +7848,7 @@
75107848 break;
75117849
75127850 case hitScale: // scale
7513
- double hScale = (double) (info.x - centerPt.x) / 32;
7851
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
75147852 double sign = 1;
75157853 if (hScale < 0)
75167854 {
....@@ -7522,7 +7860,7 @@
75227860 //hScale = 0.01;
75237861 }
75247862
7525
- double vScale = (double) (info.y - centerPt.y) / 32;
7863
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
75267864 sign = 1;
75277865 if (vScale < 0)
75287866 {
....@@ -7533,6 +7871,7 @@
75337871 {
75347872 //vScale = 0.01;
75357873 }
7874
+
75367875 LA.matCopy(startMat, toParent);
75377876 /**/
75387877 for (int i = 0; i < 3; i++)
....@@ -7542,33 +7881,39 @@
75427881 }
75437882 /**/
75447883
7545
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7884
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
75467885
75477886 if (totalScale < 0.01)
75487887 {
75497888 totalScale = 0.01;
75507889 }
75517890
7552
- switch (info.pane.RenderCamera().viewCode)
7891
+ switch (clickInfo.pane.RenderCamera().viewCode)
75537892 {
75547893 case 3: // '\001'
75557894 if (modified || opposite)
75567895 {
7896
+ if (modified) // && opposite)
7897
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7898
+ else
75577899 //LA.matScale(toParent, 1, hScale, vScale);
7558
- LA.matScale(toParent, totalScale, 1, 1);
7900
+ LA.matScale(toParent, totalScale, 1, 1);
75597901 } // vScale, 1);
75607902 else
75617903 {
75627904 // EXCEPTION!
7563
- LA.matScale(toParent, totalScale, totalScale, totalScale);
7905
+ LA.matScale(toParent, 1, totalScale, totalScale);
75647906 } // vScale, 1);
75657907 break;
75667908
75677909 case 2: // '\002'
75687910 if (modified || opposite)
75697911 {
7570
- //LA.matScale(toParent, hScale, 1, vScale);
7571
- 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);
75727917 } else
75737918 {
75747919 LA.matScale(toParent, totalScale, 1, totalScale);
....@@ -7578,8 +7923,11 @@
75787923 case 1: // '\003'
75797924 if (modified || opposite)
75807925 {
7581
- //LA.matScale(toParent, hScale, vScale, 1);
7582
- 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);
75837931 } else
75847932 {
75857933 LA.matScale(toParent, totalScale, totalScale, 1);
....@@ -7616,7 +7964,7 @@
76167964 } // NEW ...
76177965
76187966
7619
- info.pane.repaint();
7967
+ clickInfo.pane.repaint();
76207968 }
76217969
76227970 boolean overflow = false;
....@@ -7796,6 +8144,10 @@
77968144 editWindow = null;
77978145 } // ?
77988146 }
8147
+ else
8148
+ {
8149
+ //editWindow.closeUI();
8150
+ }
77998151 }
78008152
78018153 boolean root; // patch for edit windows
....@@ -7953,6 +8305,10 @@
79538305 }
79548306
79558307 transient ObjEditor editWindow;
8308
+ transient ObjEditor manipWindow;
8309
+
8310
+ transient boolean pinned;
8311
+
79568312 transient ObjectUI objectUI;
79578313 public static int povDepth = 0;
79588314 private static cVector tbMin = new cVector();