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[] = new byte[100][];
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;
....@@ -426,6 +499,7 @@
426499 }
427500
428501 boolean live = false;
502
+ transient boolean keepdontselect;
429503 boolean dontselect = false;
430504 boolean hide = false;
431505 boolean link2master = false; // performs reset support/master at each frame
....@@ -613,7 +687,7 @@
613687 {
614688 if (maxcount != 1)
615689 {
616
- new Exception().printStackTrace();
690
+ //new Exception().printStackTrace();
617691 }
618692
619693 toParentMarked = LA.newMatrix();
....@@ -1010,6 +1084,9 @@
10101084
10111085 if (material == null || material.multiply)
10121086 return true;
1087
+
1088
+ if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
1089
+ return false;
10131090
10141091 // Transparent objects are dynamic because we have to sort the triangles.
10151092 return material.opacity > 0.99;
....@@ -2292,11 +2369,6 @@
22922369
22932370 InitOthers();
22942371
2295
- if (this instanceof Camera)
2296
- {
2297
- material.shift = 90;
2298
- }
2299
-
23002372 material.multiply = multiply;
23012373
23022374 if (multiply)
....@@ -2437,6 +2509,11 @@
24372509 else
24382510 {
24392511 //((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");
24402517 }
24412518 }
24422519
....@@ -2566,7 +2643,8 @@
25662643 private static final int editSelf = 1;
25672644 private static final int editChild = 2;
25682645
2569
- void drawEditHandles(ClickInfo info, int level)
2646
+ void drawEditHandles(//ClickInfo info,
2647
+ int level)
25702648 {
25712649 if (level == 0)
25722650 {
....@@ -2574,7 +2652,8 @@
25742652 return;
25752653
25762654 Object3D selectee;
2577
- 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))
25782657 {
25792658 selectee = (Object3D) e.nextElement();
25802659 }
....@@ -2582,19 +2661,22 @@
25822661 } else
25832662 {
25842663 //super.
2585
- drawEditHandles0(info, level + 1);
2664
+ drawEditHandles0(//info,
2665
+ level + 1);
25862666 }
25872667 }
25882668
2589
- boolean doEditClick(ClickInfo info, int level)
2669
+ boolean doEditClick(//ClickInfo info,
2670
+ int level)
25902671 {
25912672 doSomething = 0;
25922673 if (level == 0)
25932674 {
2594
- return doParentClick(info);
2675
+ return doParentClick(); //info);
25952676 }
25962677 if (//super.
2597
- doEditClick0(info, level))
2678
+ doEditClick0(//info,
2679
+ level))
25982680 {
25992681 doSomething = 1;
26002682 return true;
....@@ -2604,7 +2686,7 @@
26042686 }
26052687 }
26062688
2607
- boolean doParentClick(ClickInfo info)
2689
+ boolean doParentClick() //ClickInfo info)
26082690 {
26092691 if (selection == null)
26102692 {
....@@ -2617,7 +2699,8 @@
26172699 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
26182700 {
26192701 Object3D selectee = (Object3D) e.nextElement();
2620
- if (selectee.doEditClick(info, 1))
2702
+ if (selectee.doEditClick(//info,
2703
+ 1))
26212704 {
26222705 childToDrag = selectee;
26232706 doSomething = 2;
....@@ -2629,13 +2712,15 @@
26292712 return retval;
26302713 }
26312714
2632
- void doEditDrag(ClickInfo info, boolean opposite)
2715
+ void doEditDrag(//ClickInfo clickInfo,
2716
+ boolean opposite)
26332717 {
26342718 switch (doSomething)
26352719 {
26362720 case 1: // '\001'
26372721 //super.
2638
- doEditDrag0(info, opposite);
2722
+ doEditDrag0(//clickInfo,
2723
+ opposite);
26392724 break;
26402725
26412726 case 2: // '\002'
....@@ -2648,11 +2733,13 @@
26482733 {
26492734 //sel.hitSomething = childToDrag.hitSomething;
26502735 //childToDrag.doEditDrag(info);
2651
- sel.doEditDrag(info, opposite);
2736
+ sel.doEditDrag(//clickInfo,
2737
+ opposite);
26522738 } else
26532739 {
26542740 //super.
2655
- doEditDrag0(info, opposite);
2741
+ doEditDrag0(//clickInfo,
2742
+ opposite);
26562743 }
26572744 }
26582745 break;
....@@ -2670,6 +2757,9 @@
26702757 {
26712758 deselectAll();
26722759 }
2760
+
2761
+ new Exception().printStackTrace();
2762
+
26732763 ClickInfo newInfo = new ClickInfo();
26742764 newInfo.flags = info.flags;
26752765 newInfo.bounds = info.bounds;
....@@ -3527,15 +3617,47 @@
35273617
35283618 void ClearMaterials()
35293619 {
3620
+ if (blockloop)
3621
+ return;
3622
+
3623
+ blockloop = true;
3624
+
35303625 ClearMaterial();
3531
- for (int i = 0; i < size(); i++)
3626
+ for (int i = 0; i < Size(); i++)
35323627 {
3533
- Object3D child = (Object3D) reserve(i);
3628
+ Object3D child = (Object3D) get(i);
35343629 if (child == null)
35353630 continue;
35363631 child.ClearMaterials();
3537
- release(i);
35383632 }
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;
35393661 }
35403662
35413663 void FlipV(boolean flip)
....@@ -5420,6 +5542,51 @@
54205542 blockloop = false;
54215543 }
54225544
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
+
54235590 boolean IsSelected()
54245591 {
54255592 if (parent == null)
....@@ -5480,6 +5647,11 @@
54805647 if (fullname == null)
54815648 return "";
54825649
5650
+ if (fullname.pigment != null)
5651
+ {
5652
+ return fullname.pigment;
5653
+ }
5654
+
54835655 // System.out.println("Fullname = " + fullname);
54845656
54855657 // Does not work on Windows due to C:
....@@ -5492,7 +5664,7 @@
54925664
54935665 if (split.length == 0)
54945666 {
5495
- return "";
5667
+ return fullname.pigment = "";
54965668 }
54975669
54985670 if (split.length <= 2)
....@@ -5500,22 +5672,27 @@
55005672 if (fullname.name.endsWith(":"))
55015673 {
55025674 // Windows
5503
- return fullname.name.substring(0, fullname.name.length()-1);
5675
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
55045676 }
55055677
5506
- return split[0];
5678
+ return fullname.pigment = split[0];
55075679 }
55085680
55095681 // Windows
55105682 assert(split.length == 4);
55115683
5512
- return split[0] + ":" + split[1];
5684
+ return fullname.pigment = split[0] + ":" + split[1];
55135685 }
55145686
55155687 static String GetBump(cTexture fullname)
55165688 {
55175689 if (fullname == null)
55185690 return "";
5691
+
5692
+ if (fullname.bump != null)
5693
+ {
5694
+ return fullname.bump;
5695
+ }
55195696
55205697 // System.out.println("Fullname = " + fullname);
55215698 // Does not work on Windows due to C:
....@@ -5527,12 +5704,12 @@
55275704
55285705 if (split.length == 0)
55295706 {
5530
- return "";
5707
+ return fullname.bump = "";
55315708 }
55325709
55335710 if (split.length == 1)
55345711 {
5535
- return "";
5712
+ return fullname.bump = "";
55365713 }
55375714
55385715 if (split.length == 2)
....@@ -5540,16 +5717,16 @@
55405717 if (fullname.name.endsWith(":"))
55415718 {
55425719 // Windows
5543
- return "";
5720
+ return fullname.bump = "";
55445721 }
55455722
5546
- return split[1];
5723
+ return fullname.bump = split[1];
55475724 }
55485725
55495726 // Windows
55505727 assert(split.length == 4);
55515728
5552
- return split[2] + ":" + split[3];
5729
+ return fullname.bump = split[2] + ":" + split[3];
55535730 }
55545731
55555732 String GetPigmentTexture()
....@@ -5632,6 +5809,9 @@
56325809 texname = "";
56335810
56345811 GetTextures().name = texname + ":" + GetBump(GetTextures());
5812
+
5813
+ GetTextures().pigment = null;
5814
+
56355815 Touch();
56365816 }
56375817
....@@ -5705,6 +5885,8 @@
57055885
57065886 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
57075887
5888
+ GetTextures().bump = null;
5889
+
57085890 Touch();
57095891 }
57105892
....@@ -5725,6 +5907,38 @@
57255907
57265908 blockloop = true;
57275909 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);
57285942 blockloop = false;
57295943 }
57305944 }
....@@ -5815,8 +6029,10 @@
58156029 if (support != null)
58166030 support = support;
58176031
5818
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5819
- 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.
58206036
58216037 if (!usecalllists && bRep != null && bRep.displaylist > 0)
58226038 {
....@@ -5826,8 +6042,9 @@
58266042 // usecalllists &= !(parent instanceof RandomNode);
58276043 // usecalllists = false;
58286044
5829
- if (GetBRep() != null)
5830
- usecalllists = usecalllists;
6045
+ if (display.DrawMode() == display.SHADOW)
6046
+ //GetBRep() != null)
6047
+ usecalllists = !!usecalllists;
58316048 //System.out.println("draw " + this);
58326049 //new Exception().printStackTrace();
58336050
....@@ -5849,7 +6066,7 @@
58496066 if (!(this instanceof Composite))
58506067 touched = false;
58516068 //if (displaylist == -1 && usecalllists)
5852
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
6069
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
58536070 {
58546071 bRep.displaylist = display.GenList();
58556072 assert(bRep.displaylist != 0);
....@@ -5860,7 +6077,7 @@
58606077
58616078 //System.out.println("\tnew list " + list);
58626079 //gl.glDrawBuffer(gl.GL_NONE);
5863
- if (usecalllists)
6080
+ if (usecalllists && bRep.displaylist > 0)
58646081 {
58656082 // System.err.println("new list " + bRep.displaylist + " for " + this);
58666083 display.NewList(bRep.displaylist);
....@@ -5869,7 +6086,7 @@
58696086 CallList(display, root, selected, blocked);
58706087
58716088 // compiled = true;
5872
- if (usecalllists)
6089
+ if (usecalllists && bRep.displaylist > 0)
58736090 {
58746091 // System.err.println("end list " + bRep.displaylist + " for " + this);
58756092 display.EndList();
....@@ -7220,20 +7437,23 @@
72207437 }
72217438 }
72227439
7223
- 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)
72247444 {
7225
- int hc = info.bounds.x + info.bounds.width / 2;
7226
- int vc = info.bounds.y + info.bounds.height / 2;
7227
- 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;
72287448 if (toscreen == null)
72297449 {
7230
- toscreen = new Camera(info.camera.viewCode).toScreen;
7450
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
72317451 }
72327452 cVector vec = in;
72337453 LA.xformPos(in, toscreen, in);
72347454 //System.out.println("Distance = " + info.camera.Distance());
7235
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7236
- 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();
72377457 outPt.x = hc + (int) vec.x;
72387458 outPt.y = vc - (int) vec.y;
72397459 outRec.x = outPt.x - 3;
....@@ -7241,15 +7461,18 @@
72417461 outRec.width = outRec.height = 6;
72427462 }
72437463
7244
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7464
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7465
+ )
72457466 {
72467467 Point pt = new Point(0, 0);
72477468 Rectangle rec = new Rectangle();
7248
- calcHotSpot(in, info, pt, rec);
7469
+ calcHotSpot(in, //clickInfo,
7470
+ pt, rec);
72497471 return rec;
72507472 }
72517473
7252
- void drawEditHandles0(ClickInfo info, int level)
7474
+ void drawEditHandles0(//ClickInfo clickInfo,
7475
+ int level)
72537476 {
72547477 if (level == 0)
72557478 {
....@@ -7258,16 +7481,19 @@
72587481 {
72597482 cVector origin = new cVector();
72607483 //LA.xformPos(origin, toParent, origin);
7261
- Rectangle spot = calcHotSpot(origin, info);
7484
+ if (this.clickInfo == null)
7485
+ this.clickInfo = new ClickInfo();
7486
+
7487
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
72627488 Rectangle boundary = new Rectangle();
72637489 boundary.x = spot.x - 30;
72647490 boundary.y = spot.y - 30;
72657491 boundary.width = spot.width + 60;
72667492 boundary.height = spot.height + 60;
7267
- info.g.setColor(Color.red);
7493
+ clickInfo.g.setColor(Color.white);
72687494 int spotw = spot.x + spot.width;
72697495 int spoth = spot.y + spot.height;
7270
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7496
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72717497 // if (CameraPane.Xmin > spot.x)
72727498 // {
72737499 // CameraPane.Xmin = spot.x;
....@@ -7284,11 +7510,6 @@
72847510 // {
72857511 // CameraPane.Ymax = spoth;
72867512 // }
7287
- spot.translate(32, 32);
7288
- spotw = spot.x + spot.width;
7289
- spoth = spot.y + spot.height;
7290
- info.g.setColor(Color.cyan);
7291
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72927513 // if (CameraPane.Xmin > spot.x)
72937514 // {
72947515 // CameraPane.Xmin = spot.x;
....@@ -7307,10 +7528,15 @@
73077528 // }
73087529 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
73097530 //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7310
- spot.translate(0, -32);
7311
- info.g.setColor(Color.yellow);
7312
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7313
- 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);
73147540 // if (CameraPane.Xmin > spot.x)
73157541 // {
73167542 // CameraPane.Xmin = spot.x;
....@@ -7327,8 +7553,9 @@
73277553 // {
73287554 // CameraPane.Ymax = spoth;
73297555 // }
7330
- info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY,
7331
- (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);
73327559 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
73337560 // if (CameraPane.Xmin > boundary.x)
73347561 // {
....@@ -7350,7 +7577,8 @@
73507577 }
73517578 }
73527579
7353
- boolean doEditClick0(ClickInfo info, int level)
7580
+ boolean doEditClick0(//ClickInfo clickInfo,
7581
+ int level)
73547582 {
73557583 if (level == 0)
73567584 {
....@@ -7359,8 +7587,8 @@
73597587
73607588 boolean retval = false;
73617589
7362
- startX = info.x;
7363
- startY = info.y;
7590
+ startX = clickInfo.x;
7591
+ startY = clickInfo.y;
73647592
73657593 hitSomething = -1;
73667594 cVector origin = new cVector();
....@@ -7370,22 +7598,53 @@
73707598 {
73717599 centerPt = new Point(0, 0);
73727600 }
7373
- calcHotSpot(origin, info, centerPt, spot);
7374
- if (spot.contains(info.x, info.y))
7601
+ calcHotSpot(origin, //info,
7602
+ centerPt, spot);
7603
+ if (spot.contains(clickInfo.x, clickInfo.y))
73757604 {
73767605 hitSomething = hitCenter;
73777606 retval = true;
73787607 }
73797608 spot.translate(32, 0);
7380
- if (spot.contains(info.x, info.y))
7609
+ if (spot.contains(clickInfo.x, clickInfo.y))
73817610 {
73827611 hitSomething = hitRotate;
73837612 retval = true;
73847613 }
73857614 spot.translate(0, 32);
7386
- 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))
73877618 {
73887619 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
+
73897648 retval = true;
73907649 }
73917650
....@@ -7395,7 +7654,7 @@
73957654 }
73967655
73977656 //System.out.println("info.modifiers = " + info.modifiers);
7398
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7657
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
73997658 //System.out.println("modified = " + modified);
74007659 //new Exception().printStackTrace();
74017660 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7423,7 +7682,8 @@
74237682 return true;
74247683 }
74257684
7426
- void doEditDrag0(ClickInfo info, boolean opposite)
7685
+ void doEditDrag0(//ClickInfo info,
7686
+ boolean opposite)
74277687 {
74287688 if (hitSomething == 0)
74297689 {
....@@ -7437,7 +7697,7 @@
74377697
74387698 //System.out.println("hitSomething = " + hitSomething);
74397699
7440
- double scale = 0.005f * info.camera.Distance();
7700
+ double scale = 0.005f * clickInfo.camera.Distance();
74417701
74427702 cVector xlate = new cVector();
74437703 //cVector xlate2 = new cVector();
....@@ -7451,7 +7711,9 @@
74517711
74527712 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
74537713
7454
- if (modified || opposite)
7714
+ // Modified could snap
7715
+ if (//modified ||
7716
+ opposite)
74557717 {
74567718 //assert(false);
74577719 /*
....@@ -7471,8 +7733,8 @@
74717733 toParent[3][i] = xlate.get(i);
74727734 LA.matInvert(toParent, fromParent);
74737735 */
7474
- cVector delta = LA.newVector(0, 0, startY - info.y);
7475
- 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);
74767738
74777739 LA.matCopy(startMat, toParent);
74787740 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7481,7 +7743,7 @@
74817743 } else
74827744 {
74837745 //LA.xformDir(delta, info.camera.fromScreen, delta);
7484
- cVector up = new cVector(info.camera.up);
7746
+ cVector up = new cVector(clickInfo.camera.up);
74857747 cVector away = new cVector();
74867748 //cVector right2 = new cVector();
74877749 //LA.vecCross(up, cVector.Z, right);
....@@ -7498,19 +7760,19 @@
74987760 LA.xformDir(up, ClickInfo.matbuffer, up);
74997761 // if (!CameraPane.LOCALTRANSFORM)
75007762 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7501
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7763
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
75027764 // if (!CameraPane.LOCALTRANSFORM)
75037765 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
75047766 //LA.vecCross(up, cVector.Z, right2);
75057767
7506
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7768
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
75077769
75087770 //System.out.println("DELTA0 = " + delta);
75097771 //System.out.println("AWAY = " + info.camera.away);
75107772 //System.out.println("UP = " + info.camera.up);
75117773 if (away.z > 0)
75127774 {
7513
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7775
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
75147776 {
75157777 delta.x = -delta.x;
75167778 } else
....@@ -7525,7 +7787,7 @@
75257787 //System.out.println("DELTA1 = " + delta);
75267788 LA.xformDir(delta, ClickInfo.matbuffer, delta);
75277789 //System.out.println("DELTA2 = " + delta);
7528
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7790
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
75297791 LA.matCopy(startMat, toParent);
75307792 //System.out.println("DELTA3 = " + delta);
75317793 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7535,8 +7797,8 @@
75357797 break;
75367798
75377799 case hitRotate: // rotate
7538
- int dx = info.x - centerPt.x;
7539
- int dy = -(info.y - centerPt.y);
7800
+ int dx = clickInfo.x - centerPt.x;
7801
+ int dy = -(clickInfo.y - centerPt.y);
75407802 double angle = (double) Math.atan2(dx, dy);
75417803 angle = -(1.570796 - angle);
75427804
....@@ -7545,7 +7807,7 @@
75457807
75467808 if (modified)
75477809 {
7548
- // Rotate 90 degrees
7810
+ // Rotate 45 degrees
75497811 angle /= (Math.PI / 4);
75507812 angle = Math.floor(angle + 0.5);
75517813 angle *= (Math.PI / 4);
....@@ -7559,7 +7821,7 @@
75597821 }
75607822 /**/
75617823
7562
- switch (info.pane.RenderCamera().viewCode)
7824
+ switch (clickInfo.pane.RenderCamera().viewCode)
75637825 {
75647826 case 1: // '\001'
75657827 LA.matZRotate(toParent, angle);
....@@ -7586,7 +7848,7 @@
75867848 break;
75877849
75887850 case hitScale: // scale
7589
- double hScale = (double) (info.x - centerPt.x) / 32;
7851
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
75907852 double sign = 1;
75917853 if (hScale < 0)
75927854 {
....@@ -7598,7 +7860,7 @@
75987860 //hScale = 0.01;
75997861 }
76007862
7601
- double vScale = (double) (info.y - centerPt.y) / 32;
7863
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
76027864 sign = 1;
76037865 if (vScale < 0)
76047866 {
....@@ -7609,6 +7871,7 @@
76097871 {
76107872 //vScale = 0.01;
76117873 }
7874
+
76127875 LA.matCopy(startMat, toParent);
76137876 /**/
76147877 for (int i = 0; i < 3; i++)
....@@ -7618,33 +7881,39 @@
76187881 }
76197882 /**/
76207883
7621
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7884
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
76227885
76237886 if (totalScale < 0.01)
76247887 {
76257888 totalScale = 0.01;
76267889 }
76277890
7628
- switch (info.pane.RenderCamera().viewCode)
7891
+ switch (clickInfo.pane.RenderCamera().viewCode)
76297892 {
76307893 case 3: // '\001'
76317894 if (modified || opposite)
76327895 {
7896
+ if (modified) // && opposite)
7897
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7898
+ else
76337899 //LA.matScale(toParent, 1, hScale, vScale);
7634
- LA.matScale(toParent, totalScale, 1, 1);
7900
+ LA.matScale(toParent, totalScale, 1, 1);
76357901 } // vScale, 1);
76367902 else
76377903 {
76387904 // EXCEPTION!
7639
- LA.matScale(toParent, totalScale, totalScale, totalScale);
7905
+ LA.matScale(toParent, 1, totalScale, totalScale);
76407906 } // vScale, 1);
76417907 break;
76427908
76437909 case 2: // '\002'
76447910 if (modified || opposite)
76457911 {
7646
- //LA.matScale(toParent, hScale, 1, vScale);
7647
- 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);
76487917 } else
76497918 {
76507919 LA.matScale(toParent, totalScale, 1, totalScale);
....@@ -7654,8 +7923,11 @@
76547923 case 1: // '\003'
76557924 if (modified || opposite)
76567925 {
7657
- //LA.matScale(toParent, hScale, vScale, 1);
7658
- 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);
76597931 } else
76607932 {
76617933 LA.matScale(toParent, totalScale, totalScale, 1);
....@@ -7692,7 +7964,7 @@
76927964 } // NEW ...
76937965
76947966
7695
- info.pane.repaint();
7967
+ clickInfo.pane.repaint();
76967968 }
76977969
76987970 boolean overflow = false;