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("copy of " + this.name);
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,19 +249,86 @@
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()))
220322 return;
221323
324
+ Object3D o = hashtable.get(GetUUID());
325
+
326
+ RestoreBigData(o);
327
+
222328 if (blockloop)
223329 return;
224330
225331 blockloop = true;
226
-
227
- Object3D o = hashtable.get(GetUUID());
228
-
229
- RestoreBigData(o);
230332
231333 //hashtable.remove(GetUUID());
232334
....@@ -241,8 +343,17 @@
241343 void RestoreBigData(Object3D o)
242344 {
243345 this.bRep = o.bRep;
244
- if (this.bRep != null)
245
- 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;
246357 // this.support = o.support;
247358 // this.fileparent = o.fileparent;
248359 }
....@@ -388,6 +499,7 @@
388499 }
389500
390501 boolean live = false;
502
+ transient boolean keepdontselect;
391503 boolean dontselect = false;
392504 boolean hide = false;
393505 boolean link2master = false; // performs reset support/master at each frame
....@@ -575,7 +687,7 @@
575687 {
576688 if (maxcount != 1)
577689 {
578
- new Exception().printStackTrace();
690
+ //new Exception().printStackTrace();
579691 }
580692
581693 toParentMarked = LA.newMatrix();
....@@ -972,6 +1084,9 @@
9721084
9731085 if (material == null || material.multiply)
9741086 return true;
1087
+
1088
+ if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
1089
+ return false;
9751090
9761091 // Transparent objects are dynamic because we have to sort the triangles.
9771092 return material.opacity > 0.99;
....@@ -1374,6 +1489,7 @@
13741489 toParent = LA.newMatrix();
13751490 fromParent = LA.newMatrix();
13761491 }
1492
+
13771493 LA.matCopy(other.toParent, toParent);
13781494 LA.matCopy(other.fromParent, fromParent);
13791495
....@@ -2253,11 +2369,6 @@
22532369
22542370 InitOthers();
22552371
2256
- if (this instanceof Camera)
2257
- {
2258
- material.shift = 90;
2259
- }
2260
-
22612372 material.multiply = multiply;
22622373
22632374 if (multiply)
....@@ -2398,6 +2509,11 @@
23982509 else
23992510 {
24002511 //((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");
24012517 }
24022518 }
24032519
....@@ -2527,7 +2643,8 @@
25272643 private static final int editSelf = 1;
25282644 private static final int editChild = 2;
25292645
2530
- void drawEditHandles(ClickInfo info, int level)
2646
+ void drawEditHandles(//ClickInfo info,
2647
+ int level)
25312648 {
25322649 if (level == 0)
25332650 {
....@@ -2535,7 +2652,8 @@
25352652 return;
25362653
25372654 Object3D selectee;
2538
- 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))
25392657 {
25402658 selectee = (Object3D) e.nextElement();
25412659 }
....@@ -2543,19 +2661,22 @@
25432661 } else
25442662 {
25452663 //super.
2546
- drawEditHandles0(info, level + 1);
2664
+ drawEditHandles0(//info,
2665
+ level + 1);
25472666 }
25482667 }
25492668
2550
- boolean doEditClick(ClickInfo info, int level)
2669
+ boolean doEditClick(//ClickInfo info,
2670
+ int level)
25512671 {
25522672 doSomething = 0;
25532673 if (level == 0)
25542674 {
2555
- return doParentClick(info);
2675
+ return doParentClick(); //info);
25562676 }
25572677 if (//super.
2558
- doEditClick0(info, level))
2678
+ doEditClick0(//info,
2679
+ level))
25592680 {
25602681 doSomething = 1;
25612682 return true;
....@@ -2565,7 +2686,7 @@
25652686 }
25662687 }
25672688
2568
- boolean doParentClick(ClickInfo info)
2689
+ boolean doParentClick() //ClickInfo info)
25692690 {
25702691 if (selection == null)
25712692 {
....@@ -2578,7 +2699,8 @@
25782699 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
25792700 {
25802701 Object3D selectee = (Object3D) e.nextElement();
2581
- if (selectee.doEditClick(info, 1))
2702
+ if (selectee.doEditClick(//info,
2703
+ 1))
25822704 {
25832705 childToDrag = selectee;
25842706 doSomething = 2;
....@@ -2590,13 +2712,15 @@
25902712 return retval;
25912713 }
25922714
2593
- void doEditDrag(ClickInfo info, boolean opposite)
2715
+ void doEditDrag(//ClickInfo clickInfo,
2716
+ boolean opposite)
25942717 {
25952718 switch (doSomething)
25962719 {
25972720 case 1: // '\001'
25982721 //super.
2599
- doEditDrag0(info, opposite);
2722
+ doEditDrag0(//clickInfo,
2723
+ opposite);
26002724 break;
26012725
26022726 case 2: // '\002'
....@@ -2609,11 +2733,13 @@
26092733 {
26102734 //sel.hitSomething = childToDrag.hitSomething;
26112735 //childToDrag.doEditDrag(info);
2612
- sel.doEditDrag(info, opposite);
2736
+ sel.doEditDrag(//clickInfo,
2737
+ opposite);
26132738 } else
26142739 {
26152740 //super.
2616
- doEditDrag0(info, opposite);
2741
+ doEditDrag0(//clickInfo,
2742
+ opposite);
26172743 }
26182744 }
26192745 break;
....@@ -2631,6 +2757,9 @@
26312757 {
26322758 deselectAll();
26332759 }
2760
+
2761
+ new Exception().printStackTrace();
2762
+
26342763 ClickInfo newInfo = new ClickInfo();
26352764 newInfo.flags = info.flags;
26362765 newInfo.bounds = info.bounds;
....@@ -3078,7 +3207,7 @@
30783207 {
30793208 if (bRep != null)
30803209 {
3081
- bRep.GenerateNormalsMINE();
3210
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
30823211 Touch();
30833212 }
30843213 }
....@@ -3488,15 +3617,47 @@
34883617
34893618 void ClearMaterials()
34903619 {
3620
+ if (blockloop)
3621
+ return;
3622
+
3623
+ blockloop = true;
3624
+
34913625 ClearMaterial();
3492
- for (int i = 0; i < size(); i++)
3626
+ for (int i = 0; i < Size(); i++)
34933627 {
3494
- Object3D child = (Object3D) reserve(i);
3628
+ Object3D child = (Object3D) get(i);
34953629 if (child == null)
34963630 continue;
34973631 child.ClearMaterials();
3498
- release(i);
34993632 }
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;
35003661 }
35013662
35023663 void FlipV(boolean flip)
....@@ -5043,6 +5204,7 @@
50435204
50445205 if (child == null)
50455206 continue;
5207
+
50465208 if (child.HasTransparency() && child.size() != 0)
50475209 {
50485210 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -5380,6 +5542,51 @@
53805542 blockloop = false;
53815543 }
53825544
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
+
53835590 boolean IsSelected()
53845591 {
53855592 if (parent == null)
....@@ -5440,6 +5647,11 @@
54405647 if (fullname == null)
54415648 return "";
54425649
5650
+ if (fullname.pigment != null)
5651
+ {
5652
+ return fullname.pigment;
5653
+ }
5654
+
54435655 // System.out.println("Fullname = " + fullname);
54445656
54455657 // Does not work on Windows due to C:
....@@ -5452,7 +5664,7 @@
54525664
54535665 if (split.length == 0)
54545666 {
5455
- return "";
5667
+ return fullname.pigment = "";
54565668 }
54575669
54585670 if (split.length <= 2)
....@@ -5460,22 +5672,27 @@
54605672 if (fullname.name.endsWith(":"))
54615673 {
54625674 // Windows
5463
- return fullname.name.substring(0, fullname.name.length()-1);
5675
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
54645676 }
54655677
5466
- return split[0];
5678
+ return fullname.pigment = split[0];
54675679 }
54685680
54695681 // Windows
54705682 assert(split.length == 4);
54715683
5472
- return split[0] + ":" + split[1];
5684
+ return fullname.pigment = split[0] + ":" + split[1];
54735685 }
54745686
54755687 static String GetBump(cTexture fullname)
54765688 {
54775689 if (fullname == null)
54785690 return "";
5691
+
5692
+ if (fullname.bump != null)
5693
+ {
5694
+ return fullname.bump;
5695
+ }
54795696
54805697 // System.out.println("Fullname = " + fullname);
54815698 // Does not work on Windows due to C:
....@@ -5487,12 +5704,12 @@
54875704
54885705 if (split.length == 0)
54895706 {
5490
- return "";
5707
+ return fullname.bump = "";
54915708 }
54925709
54935710 if (split.length == 1)
54945711 {
5495
- return "";
5712
+ return fullname.bump = "";
54965713 }
54975714
54985715 if (split.length == 2)
....@@ -5500,16 +5717,16 @@
55005717 if (fullname.name.endsWith(":"))
55015718 {
55025719 // Windows
5503
- return "";
5720
+ return fullname.bump = "";
55045721 }
55055722
5506
- return split[1];
5723
+ return fullname.bump = split[1];
55075724 }
55085725
55095726 // Windows
55105727 assert(split.length == 4);
55115728
5512
- return split[2] + ":" + split[3];
5729
+ return fullname.bump = split[2] + ":" + split[3];
55135730 }
55145731
55155732 String GetPigmentTexture()
....@@ -5592,6 +5809,9 @@
55925809 texname = "";
55935810
55945811 GetTextures().name = texname + ":" + GetBump(GetTextures());
5812
+
5813
+ GetTextures().pigment = null;
5814
+
55955815 Touch();
55965816 }
55975817
....@@ -5665,6 +5885,8 @@
56655885
56665886 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
56675887
5888
+ GetTextures().bump = null;
5889
+
56685890 Touch();
56695891 }
56705892
....@@ -5685,6 +5907,38 @@
56855907
56865908 blockloop = true;
56875909 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);
56885942 blockloop = false;
56895943 }
56905944 }
....@@ -5775,8 +6029,10 @@
57756029 if (support != null)
57766030 support = support;
57776031
5778
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5779
- 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.
57806036
57816037 if (!usecalllists && bRep != null && bRep.displaylist > 0)
57826038 {
....@@ -5786,8 +6042,9 @@
57866042 // usecalllists &= !(parent instanceof RandomNode);
57876043 // usecalllists = false;
57886044
5789
- if (GetBRep() != null)
5790
- usecalllists = usecalllists;
6045
+ if (display.DrawMode() == display.SHADOW)
6046
+ //GetBRep() != null)
6047
+ usecalllists = !!usecalllists;
57916048 //System.out.println("draw " + this);
57926049 //new Exception().printStackTrace();
57936050
....@@ -5797,7 +6054,7 @@
57976054
57986055 if (!selectmode && //display.DrawMode() != display.SELECTION &&
57996056 //(touched || (bRep != null && bRep.displaylist <= 0)))
5800
- (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched || (bRep != null && bRep.displaylist <= 0)))
6057
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
58016058 {
58026059 Globals.lighttouched = true;
58036060 } // all panes...
....@@ -5809,7 +6066,7 @@
58096066 if (!(this instanceof Composite))
58106067 touched = false;
58116068 //if (displaylist == -1 && usecalllists)
5812
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
6069
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
58136070 {
58146071 bRep.displaylist = display.GenList();
58156072 assert(bRep.displaylist != 0);
....@@ -5820,7 +6077,7 @@
58206077
58216078 //System.out.println("\tnew list " + list);
58226079 //gl.glDrawBuffer(gl.GL_NONE);
5823
- if (usecalllists)
6080
+ if (usecalllists && bRep.displaylist > 0)
58246081 {
58256082 // System.err.println("new list " + bRep.displaylist + " for " + this);
58266083 display.NewList(bRep.displaylist);
....@@ -5829,7 +6086,7 @@
58296086 CallList(display, root, selected, blocked);
58306087
58316088 // compiled = true;
5832
- if (usecalllists)
6089
+ if (usecalllists && bRep.displaylist > 0)
58336090 {
58346091 // System.err.println("end list " + bRep.displaylist + " for " + this);
58356092 display.EndList();
....@@ -5929,6 +6186,7 @@
59296186 if (GetBRep() != null)
59306187 {
59316188 display.NextIndex();
6189
+
59326190 // vertex color conflict : gl.glCallList(list);
59336191 DrawNode(display, root, selected);
59346192 if (this instanceof BezierPatch)
....@@ -7179,20 +7437,23 @@
71797437 }
71807438 }
71817439
7182
- 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)
71837444 {
7184
- int hc = info.bounds.x + info.bounds.width / 2;
7185
- int vc = info.bounds.y + info.bounds.height / 2;
7186
- 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;
71877448 if (toscreen == null)
71887449 {
7189
- toscreen = new Camera(info.camera.viewCode).toScreen;
7450
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
71907451 }
71917452 cVector vec = in;
71927453 LA.xformPos(in, toscreen, in);
71937454 //System.out.println("Distance = " + info.camera.Distance());
7194
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7195
- 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();
71967457 outPt.x = hc + (int) vec.x;
71977458 outPt.y = vc - (int) vec.y;
71987459 outRec.x = outPt.x - 3;
....@@ -7200,15 +7461,18 @@
72007461 outRec.width = outRec.height = 6;
72017462 }
72027463
7203
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7464
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7465
+ )
72047466 {
72057467 Point pt = new Point(0, 0);
72067468 Rectangle rec = new Rectangle();
7207
- calcHotSpot(in, info, pt, rec);
7469
+ calcHotSpot(in, //clickInfo,
7470
+ pt, rec);
72087471 return rec;
72097472 }
72107473
7211
- void drawEditHandles0(ClickInfo info, int level)
7474
+ void drawEditHandles0(//ClickInfo clickInfo,
7475
+ int level)
72127476 {
72137477 if (level == 0)
72147478 {
....@@ -7217,16 +7481,19 @@
72177481 {
72187482 cVector origin = new cVector();
72197483 //LA.xformPos(origin, toParent, origin);
7220
- Rectangle spot = calcHotSpot(origin, info);
7484
+ if (this.clickInfo == null)
7485
+ this.clickInfo = new ClickInfo();
7486
+
7487
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
72217488 Rectangle boundary = new Rectangle();
72227489 boundary.x = spot.x - 30;
72237490 boundary.y = spot.y - 30;
72247491 boundary.width = spot.width + 60;
72257492 boundary.height = spot.height + 60;
7226
- info.g.setColor(Color.red);
7493
+ clickInfo.g.setColor(Color.white);
72277494 int spotw = spot.x + spot.width;
72287495 int spoth = spot.y + spot.height;
7229
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7496
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72307497 // if (CameraPane.Xmin > spot.x)
72317498 // {
72327499 // CameraPane.Xmin = spot.x;
....@@ -7243,11 +7510,6 @@
72437510 // {
72447511 // CameraPane.Ymax = spoth;
72457512 // }
7246
- spot.translate(32, 32);
7247
- spotw = spot.x + spot.width;
7248
- spoth = spot.y + spot.height;
7249
- info.g.setColor(Color.cyan);
7250
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72517513 // if (CameraPane.Xmin > spot.x)
72527514 // {
72537515 // CameraPane.Xmin = spot.x;
....@@ -7266,10 +7528,15 @@
72667528 // }
72677529 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
72687530 //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7269
- spot.translate(0, -32);
7270
- info.g.setColor(Color.yellow);
7271
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7272
- 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);
72737540 // if (CameraPane.Xmin > spot.x)
72747541 // {
72757542 // CameraPane.Xmin = spot.x;
....@@ -7286,8 +7553,9 @@
72867553 // {
72877554 // CameraPane.Ymax = spoth;
72887555 // }
7289
- info.g.drawArc(boundary.x, boundary.y,
7290
- 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);
72917559 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
72927560 // if (CameraPane.Xmin > boundary.x)
72937561 // {
....@@ -7309,7 +7577,8 @@
73097577 }
73107578 }
73117579
7312
- boolean doEditClick0(ClickInfo info, int level)
7580
+ boolean doEditClick0(//ClickInfo clickInfo,
7581
+ int level)
73137582 {
73147583 if (level == 0)
73157584 {
....@@ -7318,8 +7587,8 @@
73187587
73197588 boolean retval = false;
73207589
7321
- startX = info.x;
7322
- startY = info.y;
7590
+ startX = clickInfo.x;
7591
+ startY = clickInfo.y;
73237592
73247593 hitSomething = -1;
73257594 cVector origin = new cVector();
....@@ -7329,22 +7598,53 @@
73297598 {
73307599 centerPt = new Point(0, 0);
73317600 }
7332
- calcHotSpot(origin, info, centerPt, spot);
7333
- if (spot.contains(info.x, info.y))
7601
+ calcHotSpot(origin, //info,
7602
+ centerPt, spot);
7603
+ if (spot.contains(clickInfo.x, clickInfo.y))
73347604 {
73357605 hitSomething = hitCenter;
73367606 retval = true;
73377607 }
73387608 spot.translate(32, 0);
7339
- if (spot.contains(info.x, info.y))
7609
+ if (spot.contains(clickInfo.x, clickInfo.y))
73407610 {
73417611 hitSomething = hitRotate;
73427612 retval = true;
73437613 }
73447614 spot.translate(0, 32);
7345
- 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))
73467618 {
73477619 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
+
73487648 retval = true;
73497649 }
73507650
....@@ -7354,7 +7654,7 @@
73547654 }
73557655
73567656 //System.out.println("info.modifiers = " + info.modifiers);
7357
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7657
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
73587658 //System.out.println("modified = " + modified);
73597659 //new Exception().printStackTrace();
73607660 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7382,7 +7682,8 @@
73827682 return true;
73837683 }
73847684
7385
- void doEditDrag0(ClickInfo info, boolean opposite)
7685
+ void doEditDrag0(//ClickInfo info,
7686
+ boolean opposite)
73867687 {
73877688 if (hitSomething == 0)
73887689 {
....@@ -7396,7 +7697,7 @@
73967697
73977698 //System.out.println("hitSomething = " + hitSomething);
73987699
7399
- double scale = 0.005f * info.camera.Distance();
7700
+ double scale = 0.005f * clickInfo.camera.Distance();
74007701
74017702 cVector xlate = new cVector();
74027703 //cVector xlate2 = new cVector();
....@@ -7410,7 +7711,9 @@
74107711
74117712 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
74127713
7413
- if (modified || opposite)
7714
+ // Modified could snap
7715
+ if (//modified ||
7716
+ opposite)
74147717 {
74157718 //assert(false);
74167719 /*
....@@ -7430,8 +7733,8 @@
74307733 toParent[3][i] = xlate.get(i);
74317734 LA.matInvert(toParent, fromParent);
74327735 */
7433
- cVector delta = LA.newVector(0, 0, startY - info.y);
7434
- 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);
74357738
74367739 LA.matCopy(startMat, toParent);
74377740 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7440,7 +7743,7 @@
74407743 } else
74417744 {
74427745 //LA.xformDir(delta, info.camera.fromScreen, delta);
7443
- cVector up = new cVector(info.camera.up);
7746
+ cVector up = new cVector(clickInfo.camera.up);
74447747 cVector away = new cVector();
74457748 //cVector right2 = new cVector();
74467749 //LA.vecCross(up, cVector.Z, right);
....@@ -7457,19 +7760,19 @@
74577760 LA.xformDir(up, ClickInfo.matbuffer, up);
74587761 // if (!CameraPane.LOCALTRANSFORM)
74597762 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7460
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7763
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
74617764 // if (!CameraPane.LOCALTRANSFORM)
74627765 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
74637766 //LA.vecCross(up, cVector.Z, right2);
74647767
7465
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7768
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
74667769
74677770 //System.out.println("DELTA0 = " + delta);
74687771 //System.out.println("AWAY = " + info.camera.away);
74697772 //System.out.println("UP = " + info.camera.up);
74707773 if (away.z > 0)
74717774 {
7472
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7775
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
74737776 {
74747777 delta.x = -delta.x;
74757778 } else
....@@ -7484,7 +7787,7 @@
74847787 //System.out.println("DELTA1 = " + delta);
74857788 LA.xformDir(delta, ClickInfo.matbuffer, delta);
74867789 //System.out.println("DELTA2 = " + delta);
7487
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7790
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
74887791 LA.matCopy(startMat, toParent);
74897792 //System.out.println("DELTA3 = " + delta);
74907793 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7494,8 +7797,8 @@
74947797 break;
74957798
74967799 case hitRotate: // rotate
7497
- int dx = info.x - centerPt.x;
7498
- int dy = -(info.y - centerPt.y);
7800
+ int dx = clickInfo.x - centerPt.x;
7801
+ int dy = -(clickInfo.y - centerPt.y);
74997802 double angle = (double) Math.atan2(dx, dy);
75007803 angle = -(1.570796 - angle);
75017804
....@@ -7504,7 +7807,7 @@
75047807
75057808 if (modified)
75067809 {
7507
- // Rotate 90 degrees
7810
+ // Rotate 45 degrees
75087811 angle /= (Math.PI / 4);
75097812 angle = Math.floor(angle + 0.5);
75107813 angle *= (Math.PI / 4);
....@@ -7518,7 +7821,7 @@
75187821 }
75197822 /**/
75207823
7521
- switch (info.pane.RenderCamera().viewCode)
7824
+ switch (clickInfo.pane.RenderCamera().viewCode)
75227825 {
75237826 case 1: // '\001'
75247827 LA.matZRotate(toParent, angle);
....@@ -7545,7 +7848,7 @@
75457848 break;
75467849
75477850 case hitScale: // scale
7548
- double hScale = (double) (info.x - centerPt.x) / 32;
7851
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
75497852 double sign = 1;
75507853 if (hScale < 0)
75517854 {
....@@ -7557,7 +7860,7 @@
75577860 //hScale = 0.01;
75587861 }
75597862
7560
- double vScale = (double) (info.y - centerPt.y) / 32;
7863
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
75617864 sign = 1;
75627865 if (vScale < 0)
75637866 {
....@@ -7568,6 +7871,7 @@
75687871 {
75697872 //vScale = 0.01;
75707873 }
7874
+
75717875 LA.matCopy(startMat, toParent);
75727876 /**/
75737877 for (int i = 0; i < 3; i++)
....@@ -7577,33 +7881,39 @@
75777881 }
75787882 /**/
75797883
7580
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7884
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
75817885
75827886 if (totalScale < 0.01)
75837887 {
75847888 totalScale = 0.01;
75857889 }
75867890
7587
- switch (info.pane.RenderCamera().viewCode)
7891
+ switch (clickInfo.pane.RenderCamera().viewCode)
75887892 {
75897893 case 3: // '\001'
75907894 if (modified || opposite)
75917895 {
7896
+ if (modified) // && opposite)
7897
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7898
+ else
75927899 //LA.matScale(toParent, 1, hScale, vScale);
7593
- LA.matScale(toParent, totalScale, 1, 1);
7900
+ LA.matScale(toParent, totalScale, 1, 1);
75947901 } // vScale, 1);
75957902 else
75967903 {
75977904 // EXCEPTION!
7598
- LA.matScale(toParent, totalScale, totalScale, totalScale);
7905
+ LA.matScale(toParent, 1, totalScale, totalScale);
75997906 } // vScale, 1);
76007907 break;
76017908
76027909 case 2: // '\002'
76037910 if (modified || opposite)
76047911 {
7605
- //LA.matScale(toParent, hScale, 1, vScale);
7606
- 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);
76077917 } else
76087918 {
76097919 LA.matScale(toParent, totalScale, 1, totalScale);
....@@ -7613,8 +7923,11 @@
76137923 case 1: // '\003'
76147924 if (modified || opposite)
76157925 {
7616
- //LA.matScale(toParent, hScale, vScale, 1);
7617
- 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);
76187931 } else
76197932 {
76207933 LA.matScale(toParent, totalScale, totalScale, 1);
....@@ -7651,7 +7964,7 @@
76517964 } // NEW ...
76527965
76537966
7654
- info.pane.repaint();
7967
+ clickInfo.pane.repaint();
76557968 }
76567969
76577970 boolean overflow = false;