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();
....@@ -965,6 +1084,9 @@
9651084
9661085 if (material == null || material.multiply)
9671086 return true;
1087
+
1088
+ if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
1089
+ return false;
9681090
9691091 // Transparent objects are dynamic because we have to sort the triangles.
9701092 return material.opacity > 0.99;
....@@ -1367,6 +1489,7 @@
13671489 toParent = LA.newMatrix();
13681490 fromParent = LA.newMatrix();
13691491 }
1492
+
13701493 LA.matCopy(other.toParent, toParent);
13711494 LA.matCopy(other.fromParent, fromParent);
13721495
....@@ -2246,11 +2369,6 @@
22462369
22472370 InitOthers();
22482371
2249
- if (this instanceof Camera)
2250
- {
2251
- material.shift = 90;
2252
- }
2253
-
22542372 material.multiply = multiply;
22552373
22562374 if (multiply)
....@@ -2391,6 +2509,11 @@
23912509 else
23922510 {
23932511 //((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");
23942517 }
23952518 }
23962519
....@@ -2433,6 +2556,14 @@
24332556 {
24342557 editWindow.refreshContents();
24352558 }
2559
+ else
2560
+ {
2561
+ if (manipWindow != null)
2562
+ {
2563
+ manipWindow.refreshContents();
2564
+ }
2565
+ }
2566
+
24362567 //if (parent != null)
24372568 //parent.refreshEditWindow();
24382569 }
....@@ -2512,7 +2643,8 @@
25122643 private static final int editSelf = 1;
25132644 private static final int editChild = 2;
25142645
2515
- void drawEditHandles(ClickInfo info, int level)
2646
+ void drawEditHandles(//ClickInfo info,
2647
+ int level)
25162648 {
25172649 if (level == 0)
25182650 {
....@@ -2520,7 +2652,8 @@
25202652 return;
25212653
25222654 Object3D selectee;
2523
- 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))
25242657 {
25252658 selectee = (Object3D) e.nextElement();
25262659 }
....@@ -2528,19 +2661,22 @@
25282661 } else
25292662 {
25302663 //super.
2531
- drawEditHandles0(info, level + 1);
2664
+ drawEditHandles0(//info,
2665
+ level + 1);
25322666 }
25332667 }
25342668
2535
- boolean doEditClick(ClickInfo info, int level)
2669
+ boolean doEditClick(//ClickInfo info,
2670
+ int level)
25362671 {
25372672 doSomething = 0;
25382673 if (level == 0)
25392674 {
2540
- return doParentClick(info);
2675
+ return doParentClick(); //info);
25412676 }
25422677 if (//super.
2543
- doEditClick0(info, level))
2678
+ doEditClick0(//info,
2679
+ level))
25442680 {
25452681 doSomething = 1;
25462682 return true;
....@@ -2550,7 +2686,7 @@
25502686 }
25512687 }
25522688
2553
- boolean doParentClick(ClickInfo info)
2689
+ boolean doParentClick() //ClickInfo info)
25542690 {
25552691 if (selection == null)
25562692 {
....@@ -2563,7 +2699,8 @@
25632699 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
25642700 {
25652701 Object3D selectee = (Object3D) e.nextElement();
2566
- if (selectee.doEditClick(info, 1))
2702
+ if (selectee.doEditClick(//info,
2703
+ 1))
25672704 {
25682705 childToDrag = selectee;
25692706 doSomething = 2;
....@@ -2575,13 +2712,15 @@
25752712 return retval;
25762713 }
25772714
2578
- void doEditDrag(ClickInfo info, boolean opposite)
2715
+ void doEditDrag(//ClickInfo clickInfo,
2716
+ boolean opposite)
25792717 {
25802718 switch (doSomething)
25812719 {
25822720 case 1: // '\001'
25832721 //super.
2584
- doEditDrag0(info, opposite);
2722
+ doEditDrag0(//clickInfo,
2723
+ opposite);
25852724 break;
25862725
25872726 case 2: // '\002'
....@@ -2594,11 +2733,13 @@
25942733 {
25952734 //sel.hitSomething = childToDrag.hitSomething;
25962735 //childToDrag.doEditDrag(info);
2597
- sel.doEditDrag(info, opposite);
2736
+ sel.doEditDrag(//clickInfo,
2737
+ opposite);
25982738 } else
25992739 {
26002740 //super.
2601
- doEditDrag0(info, opposite);
2741
+ doEditDrag0(//clickInfo,
2742
+ opposite);
26022743 }
26032744 }
26042745 break;
....@@ -2616,6 +2757,9 @@
26162757 {
26172758 deselectAll();
26182759 }
2760
+
2761
+ new Exception().printStackTrace();
2762
+
26192763 ClickInfo newInfo = new ClickInfo();
26202764 newInfo.flags = info.flags;
26212765 newInfo.bounds = info.bounds;
....@@ -3063,7 +3207,7 @@
30633207 {
30643208 if (bRep != null)
30653209 {
3066
- bRep.GenerateNormalsMINE();
3210
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
30673211 Touch();
30683212 }
30693213 }
....@@ -3473,15 +3617,47 @@
34733617
34743618 void ClearMaterials()
34753619 {
3620
+ if (blockloop)
3621
+ return;
3622
+
3623
+ blockloop = true;
3624
+
34763625 ClearMaterial();
3477
- for (int i = 0; i < size(); i++)
3626
+ for (int i = 0; i < Size(); i++)
34783627 {
3479
- Object3D child = (Object3D) reserve(i);
3628
+ Object3D child = (Object3D) get(i);
34803629 if (child == null)
34813630 continue;
34823631 child.ClearMaterials();
3483
- release(i);
34843632 }
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;
34853661 }
34863662
34873663 void FlipV(boolean flip)
....@@ -4963,6 +5139,14 @@
49635139 }
49645140 }
49655141
5142
+ ObjEditor GetWindow()
5143
+ {
5144
+ if (editWindow != null)
5145
+ return editWindow;
5146
+
5147
+ return manipWindow;
5148
+ }
5149
+
49665150 cTreePath Select(int indexcount, boolean deselect)
49675151 {
49685152 if (hide || dontselect)
....@@ -4999,10 +5183,11 @@
49995183 if (leaf != null)
50005184 {
50015185 cTreePath tp = new cTreePath(this, leaf);
5002
- if (editWindow != null)
5186
+ ObjEditor window = GetWindow();
5187
+ if (window != null)
50035188 {
50045189 //System.out.println("editWindow = " + editWindow + " vs " + this);
5005
- editWindow.Select(tp, deselect, true);
5190
+ window.Select(tp, deselect, true);
50065191 }
50075192
50085193 return tp;
....@@ -5019,6 +5204,7 @@
50195204
50205205 if (child == null)
50215206 continue;
5207
+
50225208 if (child.HasTransparency() && child.size() != 0)
50235209 {
50245210 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -5028,9 +5214,10 @@
50285214 if (leaf != null)
50295215 {
50305216 cTreePath tp = new cTreePath(this, leaf);
5031
- if (editWindow != null)
5217
+ ObjEditor window = GetWindow();
5218
+ if (window != null)
50325219 {
5033
- editWindow.Select(tp, deselect, true);
5220
+ window.Select(tp, deselect, true);
50345221 }
50355222
50365223 return tp;
....@@ -5355,6 +5542,51 @@
53555542 blockloop = false;
53565543 }
53575544
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
+
53585590 boolean IsSelected()
53595591 {
53605592 if (parent == null)
....@@ -5415,6 +5647,11 @@
54155647 if (fullname == null)
54165648 return "";
54175649
5650
+ if (fullname.pigment != null)
5651
+ {
5652
+ return fullname.pigment;
5653
+ }
5654
+
54185655 // System.out.println("Fullname = " + fullname);
54195656
54205657 // Does not work on Windows due to C:
....@@ -5427,7 +5664,7 @@
54275664
54285665 if (split.length == 0)
54295666 {
5430
- return "";
5667
+ return fullname.pigment = "";
54315668 }
54325669
54335670 if (split.length <= 2)
....@@ -5435,22 +5672,27 @@
54355672 if (fullname.name.endsWith(":"))
54365673 {
54375674 // Windows
5438
- return fullname.name.substring(0, fullname.name.length()-1);
5675
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
54395676 }
54405677
5441
- return split[0];
5678
+ return fullname.pigment = split[0];
54425679 }
54435680
54445681 // Windows
54455682 assert(split.length == 4);
54465683
5447
- return split[0] + ":" + split[1];
5684
+ return fullname.pigment = split[0] + ":" + split[1];
54485685 }
54495686
54505687 static String GetBump(cTexture fullname)
54515688 {
54525689 if (fullname == null)
54535690 return "";
5691
+
5692
+ if (fullname.bump != null)
5693
+ {
5694
+ return fullname.bump;
5695
+ }
54545696
54555697 // System.out.println("Fullname = " + fullname);
54565698 // Does not work on Windows due to C:
....@@ -5462,12 +5704,12 @@
54625704
54635705 if (split.length == 0)
54645706 {
5465
- return "";
5707
+ return fullname.bump = "";
54665708 }
54675709
54685710 if (split.length == 1)
54695711 {
5470
- return "";
5712
+ return fullname.bump = "";
54715713 }
54725714
54735715 if (split.length == 2)
....@@ -5475,16 +5717,16 @@
54755717 if (fullname.name.endsWith(":"))
54765718 {
54775719 // Windows
5478
- return "";
5720
+ return fullname.bump = "";
54795721 }
54805722
5481
- return split[1];
5723
+ return fullname.bump = split[1];
54825724 }
54835725
54845726 // Windows
54855727 assert(split.length == 4);
54865728
5487
- return split[2] + ":" + split[3];
5729
+ return fullname.bump = split[2] + ":" + split[3];
54885730 }
54895731
54905732 String GetPigmentTexture()
....@@ -5567,6 +5809,9 @@
55675809 texname = "";
55685810
55695811 GetTextures().name = texname + ":" + GetBump(GetTextures());
5812
+
5813
+ GetTextures().pigment = null;
5814
+
55705815 Touch();
55715816 }
55725817
....@@ -5640,6 +5885,8 @@
56405885
56415886 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
56425887
5888
+ GetTextures().bump = null;
5889
+
56435890 Touch();
56445891 }
56455892
....@@ -5660,6 +5907,38 @@
56605907
56615908 blockloop = true;
56625909 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);
56635942 blockloop = false;
56645943 }
56655944 }
....@@ -5750,8 +6029,10 @@
57506029 if (support != null)
57516030 support = support;
57526031
5753
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5754
- 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.
57556036
57566037 if (!usecalllists && bRep != null && bRep.displaylist > 0)
57576038 {
....@@ -5761,8 +6042,9 @@
57616042 // usecalllists &= !(parent instanceof RandomNode);
57626043 // usecalllists = false;
57636044
5764
- if (GetBRep() != null)
5765
- usecalllists = usecalllists;
6045
+ if (display.DrawMode() == display.SHADOW)
6046
+ //GetBRep() != null)
6047
+ usecalllists = !!usecalllists;
57666048 //System.out.println("draw " + this);
57676049 //new Exception().printStackTrace();
57686050
....@@ -5772,7 +6054,7 @@
57726054
57736055 if (!selectmode && //display.DrawMode() != display.SELECTION &&
57746056 //(touched || (bRep != null && bRep.displaylist <= 0)))
5775
- (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && (bRep != null && bRep.displaylist <= 0)))
6057
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
57766058 {
57776059 Globals.lighttouched = true;
57786060 } // all panes...
....@@ -5784,7 +6066,7 @@
57846066 if (!(this instanceof Composite))
57856067 touched = false;
57866068 //if (displaylist == -1 && usecalllists)
5787
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
6069
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
57886070 {
57896071 bRep.displaylist = display.GenList();
57906072 assert(bRep.displaylist != 0);
....@@ -5795,7 +6077,7 @@
57956077
57966078 //System.out.println("\tnew list " + list);
57976079 //gl.glDrawBuffer(gl.GL_NONE);
5798
- if (usecalllists)
6080
+ if (usecalllists && bRep.displaylist > 0)
57996081 {
58006082 // System.err.println("new list " + bRep.displaylist + " for " + this);
58016083 display.NewList(bRep.displaylist);
....@@ -5804,7 +6086,7 @@
58046086 CallList(display, root, selected, blocked);
58056087
58066088 // compiled = true;
5807
- if (usecalllists)
6089
+ if (usecalllists && bRep.displaylist > 0)
58086090 {
58096091 // System.err.println("end list " + bRep.displaylist + " for " + this);
58106092 display.EndList();
....@@ -5904,6 +6186,7 @@
59046186 if (GetBRep() != null)
59056187 {
59066188 display.NextIndex();
6189
+
59076190 // vertex color conflict : gl.glCallList(list);
59086191 DrawNode(display, root, selected);
59096192 if (this instanceof BezierPatch)
....@@ -7154,20 +7437,23 @@
71547437 }
71557438 }
71567439
7157
- 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)
71587444 {
7159
- int hc = info.bounds.x + info.bounds.width / 2;
7160
- int vc = info.bounds.y + info.bounds.height / 2;
7161
- 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;
71627448 if (toscreen == null)
71637449 {
7164
- toscreen = new Camera(info.camera.viewCode).toScreen;
7450
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
71657451 }
71667452 cVector vec = in;
71677453 LA.xformPos(in, toscreen, in);
71687454 //System.out.println("Distance = " + info.camera.Distance());
7169
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7170
- 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();
71717457 outPt.x = hc + (int) vec.x;
71727458 outPt.y = vc - (int) vec.y;
71737459 outRec.x = outPt.x - 3;
....@@ -7175,15 +7461,18 @@
71757461 outRec.width = outRec.height = 6;
71767462 }
71777463
7178
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7464
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7465
+ )
71797466 {
71807467 Point pt = new Point(0, 0);
71817468 Rectangle rec = new Rectangle();
7182
- calcHotSpot(in, info, pt, rec);
7469
+ calcHotSpot(in, //clickInfo,
7470
+ pt, rec);
71837471 return rec;
71847472 }
71857473
7186
- void drawEditHandles0(ClickInfo info, int level)
7474
+ void drawEditHandles0(//ClickInfo clickInfo,
7475
+ int level)
71877476 {
71887477 if (level == 0)
71897478 {
....@@ -7192,16 +7481,19 @@
71927481 {
71937482 cVector origin = new cVector();
71947483 //LA.xformPos(origin, toParent, origin);
7195
- Rectangle spot = calcHotSpot(origin, info);
7484
+ if (this.clickInfo == null)
7485
+ this.clickInfo = new ClickInfo();
7486
+
7487
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
71967488 Rectangle boundary = new Rectangle();
71977489 boundary.x = spot.x - 30;
71987490 boundary.y = spot.y - 30;
71997491 boundary.width = spot.width + 60;
72007492 boundary.height = spot.height + 60;
7201
- info.g.setColor(Color.red);
7493
+ clickInfo.g.setColor(Color.white);
72027494 int spotw = spot.x + spot.width;
72037495 int spoth = spot.y + spot.height;
7204
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7496
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72057497 // if (CameraPane.Xmin > spot.x)
72067498 // {
72077499 // CameraPane.Xmin = spot.x;
....@@ -7218,11 +7510,6 @@
72187510 // {
72197511 // CameraPane.Ymax = spoth;
72207512 // }
7221
- spot.translate(32, 32);
7222
- spotw = spot.x + spot.width;
7223
- spoth = spot.y + spot.height;
7224
- info.g.setColor(Color.cyan);
7225
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72267513 // if (CameraPane.Xmin > spot.x)
72277514 // {
72287515 // CameraPane.Xmin = spot.x;
....@@ -7241,10 +7528,15 @@
72417528 // }
72427529 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
72437530 //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7244
- spot.translate(0, -32);
7245
- info.g.setColor(Color.yellow);
7246
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7247
- 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);
72487540 // if (CameraPane.Xmin > spot.x)
72497541 // {
72507542 // CameraPane.Xmin = spot.x;
....@@ -7261,8 +7553,9 @@
72617553 // {
72627554 // CameraPane.Ymax = spoth;
72637555 // }
7264
- info.g.drawArc(boundary.x, boundary.y,
7265
- 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);
72667559 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
72677560 // if (CameraPane.Xmin > boundary.x)
72687561 // {
....@@ -7284,7 +7577,8 @@
72847577 }
72857578 }
72867579
7287
- boolean doEditClick0(ClickInfo info, int level)
7580
+ boolean doEditClick0(//ClickInfo clickInfo,
7581
+ int level)
72887582 {
72897583 if (level == 0)
72907584 {
....@@ -7293,8 +7587,8 @@
72937587
72947588 boolean retval = false;
72957589
7296
- startX = info.x;
7297
- startY = info.y;
7590
+ startX = clickInfo.x;
7591
+ startY = clickInfo.y;
72987592
72997593 hitSomething = -1;
73007594 cVector origin = new cVector();
....@@ -7304,22 +7598,53 @@
73047598 {
73057599 centerPt = new Point(0, 0);
73067600 }
7307
- calcHotSpot(origin, info, centerPt, spot);
7308
- if (spot.contains(info.x, info.y))
7601
+ calcHotSpot(origin, //info,
7602
+ centerPt, spot);
7603
+ if (spot.contains(clickInfo.x, clickInfo.y))
73097604 {
73107605 hitSomething = hitCenter;
73117606 retval = true;
73127607 }
73137608 spot.translate(32, 0);
7314
- if (spot.contains(info.x, info.y))
7609
+ if (spot.contains(clickInfo.x, clickInfo.y))
73157610 {
73167611 hitSomething = hitRotate;
73177612 retval = true;
73187613 }
73197614 spot.translate(0, 32);
7320
- 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))
73217618 {
73227619 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
+
73237648 retval = true;
73247649 }
73257650
....@@ -7329,7 +7654,7 @@
73297654 }
73307655
73317656 //System.out.println("info.modifiers = " + info.modifiers);
7332
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7657
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
73337658 //System.out.println("modified = " + modified);
73347659 //new Exception().printStackTrace();
73357660 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7357,7 +7682,8 @@
73577682 return true;
73587683 }
73597684
7360
- void doEditDrag0(ClickInfo info, boolean opposite)
7685
+ void doEditDrag0(//ClickInfo info,
7686
+ boolean opposite)
73617687 {
73627688 if (hitSomething == 0)
73637689 {
....@@ -7371,7 +7697,7 @@
73717697
73727698 //System.out.println("hitSomething = " + hitSomething);
73737699
7374
- double scale = 0.005f * info.camera.Distance();
7700
+ double scale = 0.005f * clickInfo.camera.Distance();
73757701
73767702 cVector xlate = new cVector();
73777703 //cVector xlate2 = new cVector();
....@@ -7385,7 +7711,9 @@
73857711
73867712 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
73877713
7388
- if (modified || opposite)
7714
+ // Modified could snap
7715
+ if (//modified ||
7716
+ opposite)
73897717 {
73907718 //assert(false);
73917719 /*
....@@ -7405,8 +7733,8 @@
74057733 toParent[3][i] = xlate.get(i);
74067734 LA.matInvert(toParent, fromParent);
74077735 */
7408
- cVector delta = LA.newVector(0, 0, startY - info.y);
7409
- 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);
74107738
74117739 LA.matCopy(startMat, toParent);
74127740 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7415,7 +7743,7 @@
74157743 } else
74167744 {
74177745 //LA.xformDir(delta, info.camera.fromScreen, delta);
7418
- cVector up = new cVector(info.camera.up);
7746
+ cVector up = new cVector(clickInfo.camera.up);
74197747 cVector away = new cVector();
74207748 //cVector right2 = new cVector();
74217749 //LA.vecCross(up, cVector.Z, right);
....@@ -7432,19 +7760,19 @@
74327760 LA.xformDir(up, ClickInfo.matbuffer, up);
74337761 // if (!CameraPane.LOCALTRANSFORM)
74347762 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7435
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7763
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
74367764 // if (!CameraPane.LOCALTRANSFORM)
74377765 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
74387766 //LA.vecCross(up, cVector.Z, right2);
74397767
7440
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7768
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
74417769
74427770 //System.out.println("DELTA0 = " + delta);
74437771 //System.out.println("AWAY = " + info.camera.away);
74447772 //System.out.println("UP = " + info.camera.up);
74457773 if (away.z > 0)
74467774 {
7447
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7775
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
74487776 {
74497777 delta.x = -delta.x;
74507778 } else
....@@ -7459,7 +7787,7 @@
74597787 //System.out.println("DELTA1 = " + delta);
74607788 LA.xformDir(delta, ClickInfo.matbuffer, delta);
74617789 //System.out.println("DELTA2 = " + delta);
7462
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7790
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
74637791 LA.matCopy(startMat, toParent);
74647792 //System.out.println("DELTA3 = " + delta);
74657793 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7469,8 +7797,8 @@
74697797 break;
74707798
74717799 case hitRotate: // rotate
7472
- int dx = info.x - centerPt.x;
7473
- int dy = -(info.y - centerPt.y);
7800
+ int dx = clickInfo.x - centerPt.x;
7801
+ int dy = -(clickInfo.y - centerPt.y);
74747802 double angle = (double) Math.atan2(dx, dy);
74757803 angle = -(1.570796 - angle);
74767804
....@@ -7479,7 +7807,7 @@
74797807
74807808 if (modified)
74817809 {
7482
- // Rotate 90 degrees
7810
+ // Rotate 45 degrees
74837811 angle /= (Math.PI / 4);
74847812 angle = Math.floor(angle + 0.5);
74857813 angle *= (Math.PI / 4);
....@@ -7493,7 +7821,7 @@
74937821 }
74947822 /**/
74957823
7496
- switch (info.pane.RenderCamera().viewCode)
7824
+ switch (clickInfo.pane.RenderCamera().viewCode)
74977825 {
74987826 case 1: // '\001'
74997827 LA.matZRotate(toParent, angle);
....@@ -7520,7 +7848,7 @@
75207848 break;
75217849
75227850 case hitScale: // scale
7523
- double hScale = (double) (info.x - centerPt.x) / 32;
7851
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
75247852 double sign = 1;
75257853 if (hScale < 0)
75267854 {
....@@ -7532,7 +7860,7 @@
75327860 //hScale = 0.01;
75337861 }
75347862
7535
- double vScale = (double) (info.y - centerPt.y) / 32;
7863
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
75367864 sign = 1;
75377865 if (vScale < 0)
75387866 {
....@@ -7543,6 +7871,7 @@
75437871 {
75447872 //vScale = 0.01;
75457873 }
7874
+
75467875 LA.matCopy(startMat, toParent);
75477876 /**/
75487877 for (int i = 0; i < 3; i++)
....@@ -7552,33 +7881,39 @@
75527881 }
75537882 /**/
75547883
7555
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7884
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
75567885
75577886 if (totalScale < 0.01)
75587887 {
75597888 totalScale = 0.01;
75607889 }
75617890
7562
- switch (info.pane.RenderCamera().viewCode)
7891
+ switch (clickInfo.pane.RenderCamera().viewCode)
75637892 {
75647893 case 3: // '\001'
75657894 if (modified || opposite)
75667895 {
7896
+ if (modified) // && opposite)
7897
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7898
+ else
75677899 //LA.matScale(toParent, 1, hScale, vScale);
7568
- LA.matScale(toParent, totalScale, 1, 1);
7900
+ LA.matScale(toParent, totalScale, 1, 1);
75697901 } // vScale, 1);
75707902 else
75717903 {
75727904 // EXCEPTION!
7573
- LA.matScale(toParent, totalScale, totalScale, totalScale);
7905
+ LA.matScale(toParent, 1, totalScale, totalScale);
75747906 } // vScale, 1);
75757907 break;
75767908
75777909 case 2: // '\002'
75787910 if (modified || opposite)
75797911 {
7580
- //LA.matScale(toParent, hScale, 1, vScale);
7581
- 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);
75827917 } else
75837918 {
75847919 LA.matScale(toParent, totalScale, 1, totalScale);
....@@ -7588,8 +7923,11 @@
75887923 case 1: // '\003'
75897924 if (modified || opposite)
75907925 {
7591
- //LA.matScale(toParent, hScale, vScale, 1);
7592
- 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);
75937931 } else
75947932 {
75957933 LA.matScale(toParent, totalScale, totalScale, 1);
....@@ -7626,7 +7964,7 @@
76267964 } // NEW ...
76277965
76287966
7629
- info.pane.repaint();
7967
+ clickInfo.pane.repaint();
76307968 }
76317969
76327970 boolean overflow = false;
....@@ -7967,6 +8305,10 @@
79678305 }
79688306
79698307 transient ObjEditor editWindow;
8308
+ transient ObjEditor manipWindow;
8309
+
8310
+ transient boolean pinned;
8311
+
79708312 transient ObjectUI objectUI;
79718313 public static int povDepth = 0;
79728314 private static cVector tbMin = new cVector();