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
....@@ -5750,6 +5884,8 @@
57505884 texname = "";
57515885
57525886 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
5887
+
5888
+ GetTextures().bump = null;
57535889
57545890 Touch();
57555891 }
....@@ -5893,8 +6029,10 @@
58936029 if (support != null)
58946030 support = support;
58956031
5896
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5897
- 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.
58986036
58996037 if (!usecalllists && bRep != null && bRep.displaylist > 0)
59006038 {
....@@ -5904,8 +6042,9 @@
59046042 // usecalllists &= !(parent instanceof RandomNode);
59056043 // usecalllists = false;
59066044
5907
- if (GetBRep() != null)
5908
- usecalllists = usecalllists;
6045
+ if (display.DrawMode() == display.SHADOW)
6046
+ //GetBRep() != null)
6047
+ usecalllists = !!usecalllists;
59096048 //System.out.println("draw " + this);
59106049 //new Exception().printStackTrace();
59116050
....@@ -5927,7 +6066,7 @@
59276066 if (!(this instanceof Composite))
59286067 touched = false;
59296068 //if (displaylist == -1 && usecalllists)
5930
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
6069
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
59316070 {
59326071 bRep.displaylist = display.GenList();
59336072 assert(bRep.displaylist != 0);
....@@ -5938,7 +6077,7 @@
59386077
59396078 //System.out.println("\tnew list " + list);
59406079 //gl.glDrawBuffer(gl.GL_NONE);
5941
- if (usecalllists)
6080
+ if (usecalllists && bRep.displaylist > 0)
59426081 {
59436082 // System.err.println("new list " + bRep.displaylist + " for " + this);
59446083 display.NewList(bRep.displaylist);
....@@ -5947,7 +6086,7 @@
59476086 CallList(display, root, selected, blocked);
59486087
59496088 // compiled = true;
5950
- if (usecalllists)
6089
+ if (usecalllists && bRep.displaylist > 0)
59516090 {
59526091 // System.err.println("end list " + bRep.displaylist + " for " + this);
59536092 display.EndList();
....@@ -7298,20 +7437,23 @@
72987437 }
72997438 }
73007439
7301
- 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)
73027444 {
7303
- int hc = info.bounds.x + info.bounds.width / 2;
7304
- int vc = info.bounds.y + info.bounds.height / 2;
7305
- 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;
73067448 if (toscreen == null)
73077449 {
7308
- toscreen = new Camera(info.camera.viewCode).toScreen;
7450
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
73097451 }
73107452 cVector vec = in;
73117453 LA.xformPos(in, toscreen, in);
73127454 //System.out.println("Distance = " + info.camera.Distance());
7313
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7314
- 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();
73157457 outPt.x = hc + (int) vec.x;
73167458 outPt.y = vc - (int) vec.y;
73177459 outRec.x = outPt.x - 3;
....@@ -7319,15 +7461,18 @@
73197461 outRec.width = outRec.height = 6;
73207462 }
73217463
7322
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7464
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7465
+ )
73237466 {
73247467 Point pt = new Point(0, 0);
73257468 Rectangle rec = new Rectangle();
7326
- calcHotSpot(in, info, pt, rec);
7469
+ calcHotSpot(in, //clickInfo,
7470
+ pt, rec);
73277471 return rec;
73287472 }
73297473
7330
- void drawEditHandles0(ClickInfo info, int level)
7474
+ void drawEditHandles0(//ClickInfo clickInfo,
7475
+ int level)
73317476 {
73327477 if (level == 0)
73337478 {
....@@ -7336,16 +7481,19 @@
73367481 {
73377482 cVector origin = new cVector();
73387483 //LA.xformPos(origin, toParent, origin);
7339
- Rectangle spot = calcHotSpot(origin, info);
7484
+ if (this.clickInfo == null)
7485
+ this.clickInfo = new ClickInfo();
7486
+
7487
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
73407488 Rectangle boundary = new Rectangle();
73417489 boundary.x = spot.x - 30;
73427490 boundary.y = spot.y - 30;
73437491 boundary.width = spot.width + 60;
73447492 boundary.height = spot.height + 60;
7345
- info.g.setColor(Color.red);
7493
+ clickInfo.g.setColor(Color.white);
73467494 int spotw = spot.x + spot.width;
73477495 int spoth = spot.y + spot.height;
7348
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7496
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
73497497 // if (CameraPane.Xmin > spot.x)
73507498 // {
73517499 // CameraPane.Xmin = spot.x;
....@@ -7362,11 +7510,6 @@
73627510 // {
73637511 // CameraPane.Ymax = spoth;
73647512 // }
7365
- spot.translate(32, 32);
7366
- spotw = spot.x + spot.width;
7367
- spoth = spot.y + spot.height;
7368
- info.g.setColor(Color.cyan);
7369
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
73707513 // if (CameraPane.Xmin > spot.x)
73717514 // {
73727515 // CameraPane.Xmin = spot.x;
....@@ -7385,10 +7528,15 @@
73857528 // }
73867529 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
73877530 //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7388
- spot.translate(0, -32);
7389
- info.g.setColor(Color.yellow);
7390
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7391
- 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);
73927540 // if (CameraPane.Xmin > spot.x)
73937541 // {
73947542 // CameraPane.Xmin = spot.x;
....@@ -7405,8 +7553,9 @@
74057553 // {
74067554 // CameraPane.Ymax = spoth;
74077555 // }
7408
- info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY,
7409
- (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);
74107559 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
74117560 // if (CameraPane.Xmin > boundary.x)
74127561 // {
....@@ -7428,7 +7577,8 @@
74287577 }
74297578 }
74307579
7431
- boolean doEditClick0(ClickInfo info, int level)
7580
+ boolean doEditClick0(//ClickInfo clickInfo,
7581
+ int level)
74327582 {
74337583 if (level == 0)
74347584 {
....@@ -7437,8 +7587,8 @@
74377587
74387588 boolean retval = false;
74397589
7440
- startX = info.x;
7441
- startY = info.y;
7590
+ startX = clickInfo.x;
7591
+ startY = clickInfo.y;
74427592
74437593 hitSomething = -1;
74447594 cVector origin = new cVector();
....@@ -7448,22 +7598,53 @@
74487598 {
74497599 centerPt = new Point(0, 0);
74507600 }
7451
- calcHotSpot(origin, info, centerPt, spot);
7452
- if (spot.contains(info.x, info.y))
7601
+ calcHotSpot(origin, //info,
7602
+ centerPt, spot);
7603
+ if (spot.contains(clickInfo.x, clickInfo.y))
74537604 {
74547605 hitSomething = hitCenter;
74557606 retval = true;
74567607 }
74577608 spot.translate(32, 0);
7458
- if (spot.contains(info.x, info.y))
7609
+ if (spot.contains(clickInfo.x, clickInfo.y))
74597610 {
74607611 hitSomething = hitRotate;
74617612 retval = true;
74627613 }
74637614 spot.translate(0, 32);
7464
- 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))
74657618 {
74667619 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
+
74677648 retval = true;
74687649 }
74697650
....@@ -7473,7 +7654,7 @@
74737654 }
74747655
74757656 //System.out.println("info.modifiers = " + info.modifiers);
7476
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7657
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
74777658 //System.out.println("modified = " + modified);
74787659 //new Exception().printStackTrace();
74797660 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7501,7 +7682,8 @@
75017682 return true;
75027683 }
75037684
7504
- void doEditDrag0(ClickInfo info, boolean opposite)
7685
+ void doEditDrag0(//ClickInfo info,
7686
+ boolean opposite)
75057687 {
75067688 if (hitSomething == 0)
75077689 {
....@@ -7515,7 +7697,7 @@
75157697
75167698 //System.out.println("hitSomething = " + hitSomething);
75177699
7518
- double scale = 0.005f * info.camera.Distance();
7700
+ double scale = 0.005f * clickInfo.camera.Distance();
75197701
75207702 cVector xlate = new cVector();
75217703 //cVector xlate2 = new cVector();
....@@ -7529,7 +7711,9 @@
75297711
75307712 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
75317713
7532
- if (modified || opposite)
7714
+ // Modified could snap
7715
+ if (//modified ||
7716
+ opposite)
75337717 {
75347718 //assert(false);
75357719 /*
....@@ -7549,8 +7733,8 @@
75497733 toParent[3][i] = xlate.get(i);
75507734 LA.matInvert(toParent, fromParent);
75517735 */
7552
- cVector delta = LA.newVector(0, 0, startY - info.y);
7553
- 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);
75547738
75557739 LA.matCopy(startMat, toParent);
75567740 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7559,7 +7743,7 @@
75597743 } else
75607744 {
75617745 //LA.xformDir(delta, info.camera.fromScreen, delta);
7562
- cVector up = new cVector(info.camera.up);
7746
+ cVector up = new cVector(clickInfo.camera.up);
75637747 cVector away = new cVector();
75647748 //cVector right2 = new cVector();
75657749 //LA.vecCross(up, cVector.Z, right);
....@@ -7576,19 +7760,19 @@
75767760 LA.xformDir(up, ClickInfo.matbuffer, up);
75777761 // if (!CameraPane.LOCALTRANSFORM)
75787762 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7579
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7763
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
75807764 // if (!CameraPane.LOCALTRANSFORM)
75817765 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
75827766 //LA.vecCross(up, cVector.Z, right2);
75837767
7584
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7768
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
75857769
75867770 //System.out.println("DELTA0 = " + delta);
75877771 //System.out.println("AWAY = " + info.camera.away);
75887772 //System.out.println("UP = " + info.camera.up);
75897773 if (away.z > 0)
75907774 {
7591
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7775
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
75927776 {
75937777 delta.x = -delta.x;
75947778 } else
....@@ -7603,7 +7787,7 @@
76037787 //System.out.println("DELTA1 = " + delta);
76047788 LA.xformDir(delta, ClickInfo.matbuffer, delta);
76057789 //System.out.println("DELTA2 = " + delta);
7606
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7790
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
76077791 LA.matCopy(startMat, toParent);
76087792 //System.out.println("DELTA3 = " + delta);
76097793 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7613,8 +7797,8 @@
76137797 break;
76147798
76157799 case hitRotate: // rotate
7616
- int dx = info.x - centerPt.x;
7617
- int dy = -(info.y - centerPt.y);
7800
+ int dx = clickInfo.x - centerPt.x;
7801
+ int dy = -(clickInfo.y - centerPt.y);
76187802 double angle = (double) Math.atan2(dx, dy);
76197803 angle = -(1.570796 - angle);
76207804
....@@ -7623,7 +7807,7 @@
76237807
76247808 if (modified)
76257809 {
7626
- // Rotate 90 degrees
7810
+ // Rotate 45 degrees
76277811 angle /= (Math.PI / 4);
76287812 angle = Math.floor(angle + 0.5);
76297813 angle *= (Math.PI / 4);
....@@ -7637,7 +7821,7 @@
76377821 }
76387822 /**/
76397823
7640
- switch (info.pane.RenderCamera().viewCode)
7824
+ switch (clickInfo.pane.RenderCamera().viewCode)
76417825 {
76427826 case 1: // '\001'
76437827 LA.matZRotate(toParent, angle);
....@@ -7664,7 +7848,7 @@
76647848 break;
76657849
76667850 case hitScale: // scale
7667
- double hScale = (double) (info.x - centerPt.x) / 32;
7851
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
76687852 double sign = 1;
76697853 if (hScale < 0)
76707854 {
....@@ -7676,7 +7860,7 @@
76767860 //hScale = 0.01;
76777861 }
76787862
7679
- double vScale = (double) (info.y - centerPt.y) / 32;
7863
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
76807864 sign = 1;
76817865 if (vScale < 0)
76827866 {
....@@ -7687,6 +7871,7 @@
76877871 {
76887872 //vScale = 0.01;
76897873 }
7874
+
76907875 LA.matCopy(startMat, toParent);
76917876 /**/
76927877 for (int i = 0; i < 3; i++)
....@@ -7696,33 +7881,39 @@
76967881 }
76977882 /**/
76987883
7699
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7884
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
77007885
77017886 if (totalScale < 0.01)
77027887 {
77037888 totalScale = 0.01;
77047889 }
77057890
7706
- switch (info.pane.RenderCamera().viewCode)
7891
+ switch (clickInfo.pane.RenderCamera().viewCode)
77077892 {
77087893 case 3: // '\001'
77097894 if (modified || opposite)
77107895 {
7896
+ if (modified) // && opposite)
7897
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7898
+ else
77117899 //LA.matScale(toParent, 1, hScale, vScale);
7712
- LA.matScale(toParent, totalScale, 1, 1);
7900
+ LA.matScale(toParent, totalScale, 1, 1);
77137901 } // vScale, 1);
77147902 else
77157903 {
77167904 // EXCEPTION!
7717
- LA.matScale(toParent, totalScale, totalScale, totalScale);
7905
+ LA.matScale(toParent, 1, totalScale, totalScale);
77187906 } // vScale, 1);
77197907 break;
77207908
77217909 case 2: // '\002'
77227910 if (modified || opposite)
77237911 {
7724
- //LA.matScale(toParent, hScale, 1, vScale);
7725
- 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);
77267917 } else
77277918 {
77287919 LA.matScale(toParent, totalScale, 1, totalScale);
....@@ -7732,8 +7923,11 @@
77327923 case 1: // '\003'
77337924 if (modified || opposite)
77347925 {
7735
- //LA.matScale(toParent, hScale, vScale, 1);
7736
- 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);
77377931 } else
77387932 {
77397933 LA.matScale(toParent, totalScale, totalScale, 1);
....@@ -7770,7 +7964,7 @@
77707964 } // NEW ...
77717965
77727966
7773
- info.pane.repaint();
7967
+ clickInfo.pane.repaint();
77747968 }
77757969
77767970 boolean overflow = false;