Normand Briere
2019-08-23 60cec91731a350fe67e9b5ffe7a00d70e9026314
Object3D.java
....@@ -22,6 +22,7 @@
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
2728 // TEMPORARY for mocap undo. No need to be transient.
....@@ -29,9 +30,14 @@
2930 Object3D saveskeleton;
3031 //
3132
32
- byte[] versions[];
33
+ String skyboxname;
34
+ String skyboxext;
35
+
36
+ Object3D versionlist[];
3337 int versionindex = -1;
3438
39
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable; // = new java.util.Hashtable<java.util.UUID, Object3D>();
40
+
3541 ScriptNode scriptnode;
3642
3743 void InitOthers()
....@@ -219,7 +225,7 @@
219225 // o.bRep.support = null;
220226 // }
221227 o.selection = this.selection;
222
- o.versions = this.versions;
228
+ o.versionlist = this.versionlist;
223229 o.versionindex = this.versionindex;
224230
225231 if (this.support != null)
....@@ -241,6 +247,73 @@
241247 // this.bRep.support = null;
242248 // this.support = null;
243249 // this.fileparent = null;
250
+ }
251
+
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;
244317 }
245318
246319 void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
....@@ -277,7 +350,7 @@
277350
278351 this.selection = o.selection;
279352
280
- this.versions = o.versions;
353
+ this.versionlist = o.versionlist;
281354 this.versionindex = o.versionindex;
282355 // July 2019 if (this.bRep != null)
283356 // this.bRep.support = o.transientrep;
....@@ -614,7 +687,7 @@
614687 {
615688 if (maxcount != 1)
616689 {
617
- new Exception().printStackTrace();
690
+ //new Exception().printStackTrace();
618691 }
619692
620693 toParentMarked = LA.newMatrix();
....@@ -1011,6 +1084,9 @@
10111084
10121085 if (material == null || material.multiply)
10131086 return true;
1087
+
1088
+ if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
1089
+ return false;
10141090
10151091 // Transparent objects are dynamic because we have to sort the triangles.
10161092 return material.opacity > 0.99;
....@@ -2293,11 +2369,6 @@
22932369
22942370 InitOthers();
22952371
2296
- if (this instanceof Camera)
2297
- {
2298
- material.shift = 90;
2299
- }
2300
-
23012372 material.multiply = multiply;
23022373
23032374 if (multiply)
....@@ -2438,6 +2509,11 @@
24382509 else
24392510 {
24402511 //((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");
24412517 }
24422518 }
24432519
....@@ -2567,7 +2643,8 @@
25672643 private static final int editSelf = 1;
25682644 private static final int editChild = 2;
25692645
2570
- void drawEditHandles(ClickInfo info, int level)
2646
+ void drawEditHandles(//ClickInfo info,
2647
+ int level)
25712648 {
25722649 if (level == 0)
25732650 {
....@@ -2575,7 +2652,8 @@
25752652 return;
25762653
25772654 Object3D selectee;
2578
- 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))
25792657 {
25802658 selectee = (Object3D) e.nextElement();
25812659 }
....@@ -2583,19 +2661,22 @@
25832661 } else
25842662 {
25852663 //super.
2586
- drawEditHandles0(info, level + 1);
2664
+ drawEditHandles0(//info,
2665
+ level + 1);
25872666 }
25882667 }
25892668
2590
- boolean doEditClick(ClickInfo info, int level)
2669
+ boolean doEditClick(//ClickInfo info,
2670
+ int level)
25912671 {
25922672 doSomething = 0;
25932673 if (level == 0)
25942674 {
2595
- return doParentClick(info);
2675
+ return doParentClick(); //info);
25962676 }
25972677 if (//super.
2598
- doEditClick0(info, level))
2678
+ doEditClick0(//info,
2679
+ level))
25992680 {
26002681 doSomething = 1;
26012682 return true;
....@@ -2605,7 +2686,7 @@
26052686 }
26062687 }
26072688
2608
- boolean doParentClick(ClickInfo info)
2689
+ boolean doParentClick() //ClickInfo info)
26092690 {
26102691 if (selection == null)
26112692 {
....@@ -2618,7 +2699,8 @@
26182699 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
26192700 {
26202701 Object3D selectee = (Object3D) e.nextElement();
2621
- if (selectee.doEditClick(info, 1))
2702
+ if (selectee.doEditClick(//info,
2703
+ 1))
26222704 {
26232705 childToDrag = selectee;
26242706 doSomething = 2;
....@@ -2630,13 +2712,15 @@
26302712 return retval;
26312713 }
26322714
2633
- void doEditDrag(ClickInfo info, boolean opposite)
2715
+ void doEditDrag(//ClickInfo clickInfo,
2716
+ boolean opposite)
26342717 {
26352718 switch (doSomething)
26362719 {
26372720 case 1: // '\001'
26382721 //super.
2639
- doEditDrag0(info, opposite);
2722
+ doEditDrag0(//clickInfo,
2723
+ opposite);
26402724 break;
26412725
26422726 case 2: // '\002'
....@@ -2649,11 +2733,13 @@
26492733 {
26502734 //sel.hitSomething = childToDrag.hitSomething;
26512735 //childToDrag.doEditDrag(info);
2652
- sel.doEditDrag(info, opposite);
2736
+ sel.doEditDrag(//clickInfo,
2737
+ opposite);
26532738 } else
26542739 {
26552740 //super.
2656
- doEditDrag0(info, opposite);
2741
+ doEditDrag0(//clickInfo,
2742
+ opposite);
26572743 }
26582744 }
26592745 break;
....@@ -2671,6 +2757,9 @@
26712757 {
26722758 deselectAll();
26732759 }
2760
+
2761
+ new Exception().printStackTrace();
2762
+
26742763 ClickInfo newInfo = new ClickInfo();
26752764 newInfo.flags = info.flags;
26762765 newInfo.bounds = info.bounds;
....@@ -3528,15 +3617,47 @@
35283617
35293618 void ClearMaterials()
35303619 {
3620
+ if (blockloop)
3621
+ return;
3622
+
3623
+ blockloop = true;
3624
+
35313625 ClearMaterial();
3532
- for (int i = 0; i < size(); i++)
3626
+ for (int i = 0; i < Size(); i++)
35333627 {
3534
- Object3D child = (Object3D) reserve(i);
3628
+ Object3D child = (Object3D) get(i);
35353629 if (child == null)
35363630 continue;
35373631 child.ClearMaterials();
3538
- release(i);
35393632 }
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;
35403661 }
35413662
35423663 void FlipV(boolean flip)
....@@ -5526,6 +5647,11 @@
55265647 if (fullname == null)
55275648 return "";
55285649
5650
+ if (fullname.pigment != null)
5651
+ {
5652
+ return fullname.pigment;
5653
+ }
5654
+
55295655 // System.out.println("Fullname = " + fullname);
55305656
55315657 // Does not work on Windows due to C:
....@@ -5538,7 +5664,7 @@
55385664
55395665 if (split.length == 0)
55405666 {
5541
- return "";
5667
+ return fullname.pigment = "";
55425668 }
55435669
55445670 if (split.length <= 2)
....@@ -5546,22 +5672,27 @@
55465672 if (fullname.name.endsWith(":"))
55475673 {
55485674 // Windows
5549
- return fullname.name.substring(0, fullname.name.length()-1);
5675
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
55505676 }
55515677
5552
- return split[0];
5678
+ return fullname.pigment = split[0];
55535679 }
55545680
55555681 // Windows
55565682 assert(split.length == 4);
55575683
5558
- return split[0] + ":" + split[1];
5684
+ return fullname.pigment = split[0] + ":" + split[1];
55595685 }
55605686
55615687 static String GetBump(cTexture fullname)
55625688 {
55635689 if (fullname == null)
55645690 return "";
5691
+
5692
+ if (fullname.bump != null)
5693
+ {
5694
+ return fullname.bump;
5695
+ }
55655696
55665697 // System.out.println("Fullname = " + fullname);
55675698 // Does not work on Windows due to C:
....@@ -5573,12 +5704,12 @@
55735704
55745705 if (split.length == 0)
55755706 {
5576
- return "";
5707
+ return fullname.bump = "";
55775708 }
55785709
55795710 if (split.length == 1)
55805711 {
5581
- return "";
5712
+ return fullname.bump = "";
55825713 }
55835714
55845715 if (split.length == 2)
....@@ -5586,16 +5717,16 @@
55865717 if (fullname.name.endsWith(":"))
55875718 {
55885719 // Windows
5589
- return "";
5720
+ return fullname.bump = "";
55905721 }
55915722
5592
- return split[1];
5723
+ return fullname.bump = split[1];
55935724 }
55945725
55955726 // Windows
55965727 assert(split.length == 4);
55975728
5598
- return split[2] + ":" + split[3];
5729
+ return fullname.bump = split[2] + ":" + split[3];
55995730 }
56005731
56015732 String GetPigmentTexture()
....@@ -5678,6 +5809,9 @@
56785809 texname = "";
56795810
56805811 GetTextures().name = texname + ":" + GetBump(GetTextures());
5812
+
5813
+ GetTextures().pigment = null;
5814
+
56815815 Touch();
56825816 }
56835817
....@@ -5751,6 +5885,8 @@
57515885
57525886 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
57535887
5888
+ GetTextures().bump = null;
5889
+
57545890 Touch();
57555891 }
57565892
....@@ -5775,12 +5911,23 @@
57755911 }
57765912 }
57775913
5778
- void EmbedTextures()
5914
+ void EmbedTextures(boolean embed)
57795915 {
57805916 if (blockloop)
57815917 return;
57825918
5783
- CameraPane.EmbedTextures(texture);
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
+ }
57845931
57855932 int nb = Size();
57865933 for (int i = 0; i < nb; i++)
....@@ -5791,7 +5938,7 @@
57915938 continue;
57925939
57935940 blockloop = true;
5794
- child.EmbedTextures();
5941
+ child.EmbedTextures(embed);
57955942 blockloop = false;
57965943 }
57975944 }
....@@ -5882,8 +6029,10 @@
58826029 if (support != null)
58836030 support = support;
58846031
5885
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5886
- 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.
58876036
58886037 if (!usecalllists && bRep != null && bRep.displaylist > 0)
58896038 {
....@@ -5893,8 +6042,9 @@
58936042 // usecalllists &= !(parent instanceof RandomNode);
58946043 // usecalllists = false;
58956044
5896
- if (GetBRep() != null)
5897
- usecalllists = usecalllists;
6045
+ if (display.DrawMode() == display.SHADOW)
6046
+ //GetBRep() != null)
6047
+ usecalllists = !!usecalllists;
58986048 //System.out.println("draw " + this);
58996049 //new Exception().printStackTrace();
59006050
....@@ -5916,7 +6066,7 @@
59166066 if (!(this instanceof Composite))
59176067 touched = false;
59186068 //if (displaylist == -1 && usecalllists)
5919
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
6069
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
59206070 {
59216071 bRep.displaylist = display.GenList();
59226072 assert(bRep.displaylist != 0);
....@@ -5927,7 +6077,7 @@
59276077
59286078 //System.out.println("\tnew list " + list);
59296079 //gl.glDrawBuffer(gl.GL_NONE);
5930
- if (usecalllists)
6080
+ if (usecalllists && bRep.displaylist > 0)
59316081 {
59326082 // System.err.println("new list " + bRep.displaylist + " for " + this);
59336083 display.NewList(bRep.displaylist);
....@@ -5936,7 +6086,7 @@
59366086 CallList(display, root, selected, blocked);
59376087
59386088 // compiled = true;
5939
- if (usecalllists)
6089
+ if (usecalllists && bRep.displaylist > 0)
59406090 {
59416091 // System.err.println("end list " + bRep.displaylist + " for " + this);
59426092 display.EndList();
....@@ -7287,20 +7437,23 @@
72877437 }
72887438 }
72897439
7290
- 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)
72917444 {
7292
- int hc = info.bounds.x + info.bounds.width / 2;
7293
- int vc = info.bounds.y + info.bounds.height / 2;
7294
- 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;
72957448 if (toscreen == null)
72967449 {
7297
- toscreen = new Camera(info.camera.viewCode).toScreen;
7450
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
72987451 }
72997452 cVector vec = in;
73007453 LA.xformPos(in, toscreen, in);
73017454 //System.out.println("Distance = " + info.camera.Distance());
7302
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7303
- 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();
73047457 outPt.x = hc + (int) vec.x;
73057458 outPt.y = vc - (int) vec.y;
73067459 outRec.x = outPt.x - 3;
....@@ -7308,15 +7461,18 @@
73087461 outRec.width = outRec.height = 6;
73097462 }
73107463
7311
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7464
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7465
+ )
73127466 {
73137467 Point pt = new Point(0, 0);
73147468 Rectangle rec = new Rectangle();
7315
- calcHotSpot(in, info, pt, rec);
7469
+ calcHotSpot(in, //clickInfo,
7470
+ pt, rec);
73167471 return rec;
73177472 }
73187473
7319
- void drawEditHandles0(ClickInfo info, int level)
7474
+ void drawEditHandles0(//ClickInfo clickInfo,
7475
+ int level)
73207476 {
73217477 if (level == 0)
73227478 {
....@@ -7325,16 +7481,19 @@
73257481 {
73267482 cVector origin = new cVector();
73277483 //LA.xformPos(origin, toParent, origin);
7328
- Rectangle spot = calcHotSpot(origin, info);
7484
+ if (this.clickInfo == null)
7485
+ this.clickInfo = new ClickInfo();
7486
+
7487
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
73297488 Rectangle boundary = new Rectangle();
73307489 boundary.x = spot.x - 30;
73317490 boundary.y = spot.y - 30;
73327491 boundary.width = spot.width + 60;
73337492 boundary.height = spot.height + 60;
7334
- info.g.setColor(Color.red);
7493
+ clickInfo.g.setColor(Color.white);
73357494 int spotw = spot.x + spot.width;
73367495 int spoth = spot.y + spot.height;
7337
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7496
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
73387497 // if (CameraPane.Xmin > spot.x)
73397498 // {
73407499 // CameraPane.Xmin = spot.x;
....@@ -7351,11 +7510,6 @@
73517510 // {
73527511 // CameraPane.Ymax = spoth;
73537512 // }
7354
- spot.translate(32, 32);
7355
- spotw = spot.x + spot.width;
7356
- spoth = spot.y + spot.height;
7357
- info.g.setColor(Color.cyan);
7358
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
73597513 // if (CameraPane.Xmin > spot.x)
73607514 // {
73617515 // CameraPane.Xmin = spot.x;
....@@ -7374,10 +7528,15 @@
73747528 // }
73757529 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
73767530 //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7377
- spot.translate(0, -32);
7378
- info.g.setColor(Color.yellow);
7379
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7380
- 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);
73817540 // if (CameraPane.Xmin > spot.x)
73827541 // {
73837542 // CameraPane.Xmin = spot.x;
....@@ -7394,8 +7553,9 @@
73947553 // {
73957554 // CameraPane.Ymax = spoth;
73967555 // }
7397
- info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY,
7398
- (int)(boundary.width * info.W), (int)(boundary.height * info.W), 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);
73997559 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
74007560 // if (CameraPane.Xmin > boundary.x)
74017561 // {
....@@ -7417,7 +7577,8 @@
74177577 }
74187578 }
74197579
7420
- boolean doEditClick0(ClickInfo info, int level)
7580
+ boolean doEditClick0(//ClickInfo clickInfo,
7581
+ int level)
74217582 {
74227583 if (level == 0)
74237584 {
....@@ -7426,8 +7587,8 @@
74267587
74277588 boolean retval = false;
74287589
7429
- startX = info.x;
7430
- startY = info.y;
7590
+ startX = clickInfo.x;
7591
+ startY = clickInfo.y;
74317592
74327593 hitSomething = -1;
74337594 cVector origin = new cVector();
....@@ -7437,22 +7598,53 @@
74377598 {
74387599 centerPt = new Point(0, 0);
74397600 }
7440
- calcHotSpot(origin, info, centerPt, spot);
7441
- if (spot.contains(info.x, info.y))
7601
+ calcHotSpot(origin, //info,
7602
+ centerPt, spot);
7603
+ if (spot.contains(clickInfo.x, clickInfo.y))
74427604 {
74437605 hitSomething = hitCenter;
74447606 retval = true;
74457607 }
74467608 spot.translate(32, 0);
7447
- if (spot.contains(info.x, info.y))
7609
+ if (spot.contains(clickInfo.x, clickInfo.y))
74487610 {
74497611 hitSomething = hitRotate;
74507612 retval = true;
74517613 }
74527614 spot.translate(0, 32);
7453
- 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))
74547618 {
74557619 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
+
74567648 retval = true;
74577649 }
74587650
....@@ -7462,7 +7654,7 @@
74627654 }
74637655
74647656 //System.out.println("info.modifiers = " + info.modifiers);
7465
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7657
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
74667658 //System.out.println("modified = " + modified);
74677659 //new Exception().printStackTrace();
74687660 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7490,7 +7682,8 @@
74907682 return true;
74917683 }
74927684
7493
- void doEditDrag0(ClickInfo info, boolean opposite)
7685
+ void doEditDrag0(//ClickInfo info,
7686
+ boolean opposite)
74947687 {
74957688 if (hitSomething == 0)
74967689 {
....@@ -7504,7 +7697,7 @@
75047697
75057698 //System.out.println("hitSomething = " + hitSomething);
75067699
7507
- double scale = 0.005f * info.camera.Distance();
7700
+ double scale = 0.005f * clickInfo.camera.Distance();
75087701
75097702 cVector xlate = new cVector();
75107703 //cVector xlate2 = new cVector();
....@@ -7518,7 +7711,9 @@
75187711
75197712 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
75207713
7521
- if (modified || opposite)
7714
+ // Modified could snap
7715
+ if (//modified ||
7716
+ opposite)
75227717 {
75237718 //assert(false);
75247719 /*
....@@ -7538,8 +7733,8 @@
75387733 toParent[3][i] = xlate.get(i);
75397734 LA.matInvert(toParent, fromParent);
75407735 */
7541
- cVector delta = LA.newVector(0, 0, startY - info.y);
7542
- 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);
75437738
75447739 LA.matCopy(startMat, toParent);
75457740 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7548,7 +7743,7 @@
75487743 } else
75497744 {
75507745 //LA.xformDir(delta, info.camera.fromScreen, delta);
7551
- cVector up = new cVector(info.camera.up);
7746
+ cVector up = new cVector(clickInfo.camera.up);
75527747 cVector away = new cVector();
75537748 //cVector right2 = new cVector();
75547749 //LA.vecCross(up, cVector.Z, right);
....@@ -7565,19 +7760,19 @@
75657760 LA.xformDir(up, ClickInfo.matbuffer, up);
75667761 // if (!CameraPane.LOCALTRANSFORM)
75677762 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7568
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7763
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
75697764 // if (!CameraPane.LOCALTRANSFORM)
75707765 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
75717766 //LA.vecCross(up, cVector.Z, right2);
75727767
7573
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7768
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
75747769
75757770 //System.out.println("DELTA0 = " + delta);
75767771 //System.out.println("AWAY = " + info.camera.away);
75777772 //System.out.println("UP = " + info.camera.up);
75787773 if (away.z > 0)
75797774 {
7580
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7775
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
75817776 {
75827777 delta.x = -delta.x;
75837778 } else
....@@ -7592,7 +7787,7 @@
75927787 //System.out.println("DELTA1 = " + delta);
75937788 LA.xformDir(delta, ClickInfo.matbuffer, delta);
75947789 //System.out.println("DELTA2 = " + delta);
7595
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7790
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
75967791 LA.matCopy(startMat, toParent);
75977792 //System.out.println("DELTA3 = " + delta);
75987793 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7602,8 +7797,8 @@
76027797 break;
76037798
76047799 case hitRotate: // rotate
7605
- int dx = info.x - centerPt.x;
7606
- int dy = -(info.y - centerPt.y);
7800
+ int dx = clickInfo.x - centerPt.x;
7801
+ int dy = -(clickInfo.y - centerPt.y);
76077802 double angle = (double) Math.atan2(dx, dy);
76087803 angle = -(1.570796 - angle);
76097804
....@@ -7612,7 +7807,7 @@
76127807
76137808 if (modified)
76147809 {
7615
- // Rotate 90 degrees
7810
+ // Rotate 45 degrees
76167811 angle /= (Math.PI / 4);
76177812 angle = Math.floor(angle + 0.5);
76187813 angle *= (Math.PI / 4);
....@@ -7626,7 +7821,7 @@
76267821 }
76277822 /**/
76287823
7629
- switch (info.pane.RenderCamera().viewCode)
7824
+ switch (clickInfo.pane.RenderCamera().viewCode)
76307825 {
76317826 case 1: // '\001'
76327827 LA.matZRotate(toParent, angle);
....@@ -7653,7 +7848,7 @@
76537848 break;
76547849
76557850 case hitScale: // scale
7656
- double hScale = (double) (info.x - centerPt.x) / 32;
7851
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
76577852 double sign = 1;
76587853 if (hScale < 0)
76597854 {
....@@ -7665,7 +7860,7 @@
76657860 //hScale = 0.01;
76667861 }
76677862
7668
- double vScale = (double) (info.y - centerPt.y) / 32;
7863
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
76697864 sign = 1;
76707865 if (vScale < 0)
76717866 {
....@@ -7676,6 +7871,7 @@
76767871 {
76777872 //vScale = 0.01;
76787873 }
7874
+
76797875 LA.matCopy(startMat, toParent);
76807876 /**/
76817877 for (int i = 0; i < 3; i++)
....@@ -7685,33 +7881,39 @@
76857881 }
76867882 /**/
76877883
7688
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7884
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
76897885
76907886 if (totalScale < 0.01)
76917887 {
76927888 totalScale = 0.01;
76937889 }
76947890
7695
- switch (info.pane.RenderCamera().viewCode)
7891
+ switch (clickInfo.pane.RenderCamera().viewCode)
76967892 {
76977893 case 3: // '\001'
76987894 if (modified || opposite)
76997895 {
7896
+ if (modified) // && opposite)
7897
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7898
+ else
77007899 //LA.matScale(toParent, 1, hScale, vScale);
7701
- LA.matScale(toParent, totalScale, 1, 1);
7900
+ LA.matScale(toParent, totalScale, 1, 1);
77027901 } // vScale, 1);
77037902 else
77047903 {
77057904 // EXCEPTION!
7706
- LA.matScale(toParent, totalScale, totalScale, totalScale);
7905
+ LA.matScale(toParent, 1, totalScale, totalScale);
77077906 } // vScale, 1);
77087907 break;
77097908
77107909 case 2: // '\002'
77117910 if (modified || opposite)
77127911 {
7713
- //LA.matScale(toParent, hScale, 1, vScale);
7714
- 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);
77157917 } else
77167918 {
77177919 LA.matScale(toParent, totalScale, 1, totalScale);
....@@ -7721,8 +7923,11 @@
77217923 case 1: // '\003'
77227924 if (modified || opposite)
77237925 {
7724
- //LA.matScale(toParent, hScale, vScale, 1);
7725
- 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);
77267931 } else
77277932 {
77287933 LA.matScale(toParent, totalScale, totalScale, 1);
....@@ -7759,7 +7964,7 @@
77597964 } // NEW ...
77607965
77617966
7762
- info.pane.repaint();
7967
+ clickInfo.pane.repaint();
77637968 }
77647969
77657970 boolean overflow = false;