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
2728 // TEMPORARY for mocap undo. No need to be transient.
2829 mocap.reader.BVHReader.BVHResult savebvh;
2930 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
....@@ -215,6 +224,9 @@
215224 // o.transientrep = this.bRep.support;
216225 // o.bRep.support = null;
217226 // }
227
+ o.selection = this.selection;
228
+ o.versionlist = this.versionlist;
229
+ o.versionindex = this.versionindex;
218230
219231 if (this.support != null)
220232 {
....@@ -235,6 +247,73 @@
235247 // this.bRep.support = null;
236248 // this.support = null;
237249 // 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;
238317 }
239318
240319 void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
....@@ -268,6 +347,11 @@
268347 {
269348 this.support.bRep = o.transientrep;
270349 }
350
+
351
+ this.selection = o.selection;
352
+
353
+ this.versionlist = o.versionlist;
354
+ this.versionindex = o.versionindex;
271355 // July 2019 if (this.bRep != null)
272356 // this.bRep.support = o.transientrep;
273357 // this.support = o.support;
....@@ -415,6 +499,7 @@
415499 }
416500
417501 boolean live = false;
502
+ transient boolean keepdontselect;
418503 boolean dontselect = false;
419504 boolean hide = false;
420505 boolean link2master = false; // performs reset support/master at each frame
....@@ -602,7 +687,7 @@
602687 {
603688 if (maxcount != 1)
604689 {
605
- new Exception().printStackTrace();
690
+ //new Exception().printStackTrace();
606691 }
607692
608693 toParentMarked = LA.newMatrix();
....@@ -999,6 +1084,9 @@
9991084
10001085 if (material == null || material.multiply)
10011086 return true;
1087
+
1088
+ if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
1089
+ return false;
10021090
10031091 // Transparent objects are dynamic because we have to sort the triangles.
10041092 return material.opacity > 0.99;
....@@ -2281,11 +2369,6 @@
22812369
22822370 InitOthers();
22832371
2284
- if (this instanceof Camera)
2285
- {
2286
- material.shift = 90;
2287
- }
2288
-
22892372 material.multiply = multiply;
22902373
22912374 if (multiply)
....@@ -2426,6 +2509,11 @@
24262509 else
24272510 {
24282511 //((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");
24292517 }
24302518 }
24312519
....@@ -2555,7 +2643,8 @@
25552643 private static final int editSelf = 1;
25562644 private static final int editChild = 2;
25572645
2558
- void drawEditHandles(ClickInfo info, int level)
2646
+ void drawEditHandles(//ClickInfo info,
2647
+ int level)
25592648 {
25602649 if (level == 0)
25612650 {
....@@ -2563,7 +2652,8 @@
25632652 return;
25642653
25652654 Object3D selectee;
2566
- 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))
25672657 {
25682658 selectee = (Object3D) e.nextElement();
25692659 }
....@@ -2571,19 +2661,22 @@
25712661 } else
25722662 {
25732663 //super.
2574
- drawEditHandles0(info, level + 1);
2664
+ drawEditHandles0(//info,
2665
+ level + 1);
25752666 }
25762667 }
25772668
2578
- boolean doEditClick(ClickInfo info, int level)
2669
+ boolean doEditClick(//ClickInfo info,
2670
+ int level)
25792671 {
25802672 doSomething = 0;
25812673 if (level == 0)
25822674 {
2583
- return doParentClick(info);
2675
+ return doParentClick(); //info);
25842676 }
25852677 if (//super.
2586
- doEditClick0(info, level))
2678
+ doEditClick0(//info,
2679
+ level))
25872680 {
25882681 doSomething = 1;
25892682 return true;
....@@ -2593,7 +2686,7 @@
25932686 }
25942687 }
25952688
2596
- boolean doParentClick(ClickInfo info)
2689
+ boolean doParentClick() //ClickInfo info)
25972690 {
25982691 if (selection == null)
25992692 {
....@@ -2606,7 +2699,8 @@
26062699 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
26072700 {
26082701 Object3D selectee = (Object3D) e.nextElement();
2609
- if (selectee.doEditClick(info, 1))
2702
+ if (selectee.doEditClick(//info,
2703
+ 1))
26102704 {
26112705 childToDrag = selectee;
26122706 doSomething = 2;
....@@ -2618,13 +2712,15 @@
26182712 return retval;
26192713 }
26202714
2621
- void doEditDrag(ClickInfo info, boolean opposite)
2715
+ void doEditDrag(//ClickInfo clickInfo,
2716
+ boolean opposite)
26222717 {
26232718 switch (doSomething)
26242719 {
26252720 case 1: // '\001'
26262721 //super.
2627
- doEditDrag0(info, opposite);
2722
+ doEditDrag0(//clickInfo,
2723
+ opposite);
26282724 break;
26292725
26302726 case 2: // '\002'
....@@ -2637,11 +2733,13 @@
26372733 {
26382734 //sel.hitSomething = childToDrag.hitSomething;
26392735 //childToDrag.doEditDrag(info);
2640
- sel.doEditDrag(info, opposite);
2736
+ sel.doEditDrag(//clickInfo,
2737
+ opposite);
26412738 } else
26422739 {
26432740 //super.
2644
- doEditDrag0(info, opposite);
2741
+ doEditDrag0(//clickInfo,
2742
+ opposite);
26452743 }
26462744 }
26472745 break;
....@@ -2659,6 +2757,9 @@
26592757 {
26602758 deselectAll();
26612759 }
2760
+
2761
+ new Exception().printStackTrace();
2762
+
26622763 ClickInfo newInfo = new ClickInfo();
26632764 newInfo.flags = info.flags;
26642765 newInfo.bounds = info.bounds;
....@@ -3106,7 +3207,7 @@
31063207 {
31073208 if (bRep != null)
31083209 {
3109
- bRep.GenerateNormalsMINE();
3210
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
31103211 Touch();
31113212 }
31123213 }
....@@ -3516,15 +3617,47 @@
35163617
35173618 void ClearMaterials()
35183619 {
3620
+ if (blockloop)
3621
+ return;
3622
+
3623
+ blockloop = true;
3624
+
35193625 ClearMaterial();
3520
- for (int i = 0; i < size(); i++)
3626
+ for (int i = 0; i < Size(); i++)
35213627 {
3522
- Object3D child = (Object3D) reserve(i);
3628
+ Object3D child = (Object3D) get(i);
35233629 if (child == null)
35243630 continue;
35253631 child.ClearMaterials();
3526
- release(i);
35273632 }
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;
35283661 }
35293662
35303663 void FlipV(boolean flip)
....@@ -5409,6 +5542,51 @@
54095542 blockloop = false;
54105543 }
54115544
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
+
54125590 boolean IsSelected()
54135591 {
54145592 if (parent == null)
....@@ -5469,6 +5647,11 @@
54695647 if (fullname == null)
54705648 return "";
54715649
5650
+ if (fullname.pigment != null)
5651
+ {
5652
+ return fullname.pigment;
5653
+ }
5654
+
54725655 // System.out.println("Fullname = " + fullname);
54735656
54745657 // Does not work on Windows due to C:
....@@ -5481,7 +5664,7 @@
54815664
54825665 if (split.length == 0)
54835666 {
5484
- return "";
5667
+ return fullname.pigment = "";
54855668 }
54865669
54875670 if (split.length <= 2)
....@@ -5489,22 +5672,27 @@
54895672 if (fullname.name.endsWith(":"))
54905673 {
54915674 // Windows
5492
- return fullname.name.substring(0, fullname.name.length()-1);
5675
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
54935676 }
54945677
5495
- return split[0];
5678
+ return fullname.pigment = split[0];
54965679 }
54975680
54985681 // Windows
54995682 assert(split.length == 4);
55005683
5501
- return split[0] + ":" + split[1];
5684
+ return fullname.pigment = split[0] + ":" + split[1];
55025685 }
55035686
55045687 static String GetBump(cTexture fullname)
55055688 {
55065689 if (fullname == null)
55075690 return "";
5691
+
5692
+ if (fullname.bump != null)
5693
+ {
5694
+ return fullname.bump;
5695
+ }
55085696
55095697 // System.out.println("Fullname = " + fullname);
55105698 // Does not work on Windows due to C:
....@@ -5516,12 +5704,12 @@
55165704
55175705 if (split.length == 0)
55185706 {
5519
- return "";
5707
+ return fullname.bump = "";
55205708 }
55215709
55225710 if (split.length == 1)
55235711 {
5524
- return "";
5712
+ return fullname.bump = "";
55255713 }
55265714
55275715 if (split.length == 2)
....@@ -5529,16 +5717,16 @@
55295717 if (fullname.name.endsWith(":"))
55305718 {
55315719 // Windows
5532
- return "";
5720
+ return fullname.bump = "";
55335721 }
55345722
5535
- return split[1];
5723
+ return fullname.bump = split[1];
55365724 }
55375725
55385726 // Windows
55395727 assert(split.length == 4);
55405728
5541
- return split[2] + ":" + split[3];
5729
+ return fullname.bump = split[2] + ":" + split[3];
55425730 }
55435731
55445732 String GetPigmentTexture()
....@@ -5621,6 +5809,9 @@
56215809 texname = "";
56225810
56235811 GetTextures().name = texname + ":" + GetBump(GetTextures());
5812
+
5813
+ GetTextures().pigment = null;
5814
+
56245815 Touch();
56255816 }
56265817
....@@ -5694,6 +5885,8 @@
56945885
56955886 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
56965887
5888
+ GetTextures().bump = null;
5889
+
56975890 Touch();
56985891 }
56995892
....@@ -5714,6 +5907,38 @@
57145907
57155908 blockloop = true;
57165909 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);
57175942 blockloop = false;
57185943 }
57195944 }
....@@ -5804,8 +6029,10 @@
58046029 if (support != null)
58056030 support = support;
58066031
5807
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5808
- 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.
58096036
58106037 if (!usecalllists && bRep != null && bRep.displaylist > 0)
58116038 {
....@@ -5815,8 +6042,9 @@
58156042 // usecalllists &= !(parent instanceof RandomNode);
58166043 // usecalllists = false;
58176044
5818
- if (GetBRep() != null)
5819
- usecalllists = usecalllists;
6045
+ if (display.DrawMode() == display.SHADOW)
6046
+ //GetBRep() != null)
6047
+ usecalllists = !!usecalllists;
58206048 //System.out.println("draw " + this);
58216049 //new Exception().printStackTrace();
58226050
....@@ -5838,7 +6066,7 @@
58386066 if (!(this instanceof Composite))
58396067 touched = false;
58406068 //if (displaylist == -1 && usecalllists)
5841
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
6069
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
58426070 {
58436071 bRep.displaylist = display.GenList();
58446072 assert(bRep.displaylist != 0);
....@@ -5849,7 +6077,7 @@
58496077
58506078 //System.out.println("\tnew list " + list);
58516079 //gl.glDrawBuffer(gl.GL_NONE);
5852
- if (usecalllists)
6080
+ if (usecalllists && bRep.displaylist > 0)
58536081 {
58546082 // System.err.println("new list " + bRep.displaylist + " for " + this);
58556083 display.NewList(bRep.displaylist);
....@@ -5858,7 +6086,7 @@
58586086 CallList(display, root, selected, blocked);
58596087
58606088 // compiled = true;
5861
- if (usecalllists)
6089
+ if (usecalllists && bRep.displaylist > 0)
58626090 {
58636091 // System.err.println("end list " + bRep.displaylist + " for " + this);
58646092 display.EndList();
....@@ -7209,20 +7437,23 @@
72097437 }
72107438 }
72117439
7212
- 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)
72137444 {
7214
- int hc = info.bounds.x + info.bounds.width / 2;
7215
- int vc = info.bounds.y + info.bounds.height / 2;
7216
- 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;
72177448 if (toscreen == null)
72187449 {
7219
- toscreen = new Camera(info.camera.viewCode).toScreen;
7450
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
72207451 }
72217452 cVector vec = in;
72227453 LA.xformPos(in, toscreen, in);
72237454 //System.out.println("Distance = " + info.camera.Distance());
7224
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7225
- 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();
72267457 outPt.x = hc + (int) vec.x;
72277458 outPt.y = vc - (int) vec.y;
72287459 outRec.x = outPt.x - 3;
....@@ -7230,15 +7461,18 @@
72307461 outRec.width = outRec.height = 6;
72317462 }
72327463
7233
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7464
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7465
+ )
72347466 {
72357467 Point pt = new Point(0, 0);
72367468 Rectangle rec = new Rectangle();
7237
- calcHotSpot(in, info, pt, rec);
7469
+ calcHotSpot(in, //clickInfo,
7470
+ pt, rec);
72387471 return rec;
72397472 }
72407473
7241
- void drawEditHandles0(ClickInfo info, int level)
7474
+ void drawEditHandles0(//ClickInfo clickInfo,
7475
+ int level)
72427476 {
72437477 if (level == 0)
72447478 {
....@@ -7247,16 +7481,19 @@
72477481 {
72487482 cVector origin = new cVector();
72497483 //LA.xformPos(origin, toParent, origin);
7250
- Rectangle spot = calcHotSpot(origin, info);
7484
+ if (this.clickInfo == null)
7485
+ this.clickInfo = new ClickInfo();
7486
+
7487
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
72517488 Rectangle boundary = new Rectangle();
72527489 boundary.x = spot.x - 30;
72537490 boundary.y = spot.y - 30;
72547491 boundary.width = spot.width + 60;
72557492 boundary.height = spot.height + 60;
7256
- info.g.setColor(Color.red);
7493
+ clickInfo.g.setColor(Color.white);
72577494 int spotw = spot.x + spot.width;
72587495 int spoth = spot.y + spot.height;
7259
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7496
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72607497 // if (CameraPane.Xmin > spot.x)
72617498 // {
72627499 // CameraPane.Xmin = spot.x;
....@@ -7273,11 +7510,6 @@
72737510 // {
72747511 // CameraPane.Ymax = spoth;
72757512 // }
7276
- spot.translate(32, 32);
7277
- spotw = spot.x + spot.width;
7278
- spoth = spot.y + spot.height;
7279
- info.g.setColor(Color.cyan);
7280
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72817513 // if (CameraPane.Xmin > spot.x)
72827514 // {
72837515 // CameraPane.Xmin = spot.x;
....@@ -7296,10 +7528,15 @@
72967528 // }
72977529 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
72987530 //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7299
- spot.translate(0, -32);
7300
- info.g.setColor(Color.yellow);
7301
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7302
- 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);
73037540 // if (CameraPane.Xmin > spot.x)
73047541 // {
73057542 // CameraPane.Xmin = spot.x;
....@@ -7316,8 +7553,9 @@
73167553 // {
73177554 // CameraPane.Ymax = spoth;
73187555 // }
7319
- info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY,
7320
- (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);
73217559 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
73227560 // if (CameraPane.Xmin > boundary.x)
73237561 // {
....@@ -7339,7 +7577,8 @@
73397577 }
73407578 }
73417579
7342
- boolean doEditClick0(ClickInfo info, int level)
7580
+ boolean doEditClick0(//ClickInfo clickInfo,
7581
+ int level)
73437582 {
73447583 if (level == 0)
73457584 {
....@@ -7348,8 +7587,8 @@
73487587
73497588 boolean retval = false;
73507589
7351
- startX = info.x;
7352
- startY = info.y;
7590
+ startX = clickInfo.x;
7591
+ startY = clickInfo.y;
73537592
73547593 hitSomething = -1;
73557594 cVector origin = new cVector();
....@@ -7359,22 +7598,53 @@
73597598 {
73607599 centerPt = new Point(0, 0);
73617600 }
7362
- calcHotSpot(origin, info, centerPt, spot);
7363
- if (spot.contains(info.x, info.y))
7601
+ calcHotSpot(origin, //info,
7602
+ centerPt, spot);
7603
+ if (spot.contains(clickInfo.x, clickInfo.y))
73647604 {
73657605 hitSomething = hitCenter;
73667606 retval = true;
73677607 }
73687608 spot.translate(32, 0);
7369
- if (spot.contains(info.x, info.y))
7609
+ if (spot.contains(clickInfo.x, clickInfo.y))
73707610 {
73717611 hitSomething = hitRotate;
73727612 retval = true;
73737613 }
73747614 spot.translate(0, 32);
7375
- 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))
73767618 {
73777619 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
+
73787648 retval = true;
73797649 }
73807650
....@@ -7384,7 +7654,7 @@
73847654 }
73857655
73867656 //System.out.println("info.modifiers = " + info.modifiers);
7387
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7657
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
73887658 //System.out.println("modified = " + modified);
73897659 //new Exception().printStackTrace();
73907660 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7412,7 +7682,8 @@
74127682 return true;
74137683 }
74147684
7415
- void doEditDrag0(ClickInfo info, boolean opposite)
7685
+ void doEditDrag0(//ClickInfo info,
7686
+ boolean opposite)
74167687 {
74177688 if (hitSomething == 0)
74187689 {
....@@ -7426,7 +7697,7 @@
74267697
74277698 //System.out.println("hitSomething = " + hitSomething);
74287699
7429
- double scale = 0.005f * info.camera.Distance();
7700
+ double scale = 0.005f * clickInfo.camera.Distance();
74307701
74317702 cVector xlate = new cVector();
74327703 //cVector xlate2 = new cVector();
....@@ -7440,7 +7711,9 @@
74407711
74417712 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
74427713
7443
- if (modified || opposite)
7714
+ // Modified could snap
7715
+ if (//modified ||
7716
+ opposite)
74447717 {
74457718 //assert(false);
74467719 /*
....@@ -7460,8 +7733,8 @@
74607733 toParent[3][i] = xlate.get(i);
74617734 LA.matInvert(toParent, fromParent);
74627735 */
7463
- cVector delta = LA.newVector(0, 0, startY - info.y);
7464
- 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);
74657738
74667739 LA.matCopy(startMat, toParent);
74677740 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7470,7 +7743,7 @@
74707743 } else
74717744 {
74727745 //LA.xformDir(delta, info.camera.fromScreen, delta);
7473
- cVector up = new cVector(info.camera.up);
7746
+ cVector up = new cVector(clickInfo.camera.up);
74747747 cVector away = new cVector();
74757748 //cVector right2 = new cVector();
74767749 //LA.vecCross(up, cVector.Z, right);
....@@ -7487,19 +7760,19 @@
74877760 LA.xformDir(up, ClickInfo.matbuffer, up);
74887761 // if (!CameraPane.LOCALTRANSFORM)
74897762 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7490
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7763
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
74917764 // if (!CameraPane.LOCALTRANSFORM)
74927765 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
74937766 //LA.vecCross(up, cVector.Z, right2);
74947767
7495
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7768
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
74967769
74977770 //System.out.println("DELTA0 = " + delta);
74987771 //System.out.println("AWAY = " + info.camera.away);
74997772 //System.out.println("UP = " + info.camera.up);
75007773 if (away.z > 0)
75017774 {
7502
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7775
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
75037776 {
75047777 delta.x = -delta.x;
75057778 } else
....@@ -7514,7 +7787,7 @@
75147787 //System.out.println("DELTA1 = " + delta);
75157788 LA.xformDir(delta, ClickInfo.matbuffer, delta);
75167789 //System.out.println("DELTA2 = " + delta);
7517
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7790
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
75187791 LA.matCopy(startMat, toParent);
75197792 //System.out.println("DELTA3 = " + delta);
75207793 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7524,8 +7797,8 @@
75247797 break;
75257798
75267799 case hitRotate: // rotate
7527
- int dx = info.x - centerPt.x;
7528
- int dy = -(info.y - centerPt.y);
7800
+ int dx = clickInfo.x - centerPt.x;
7801
+ int dy = -(clickInfo.y - centerPt.y);
75297802 double angle = (double) Math.atan2(dx, dy);
75307803 angle = -(1.570796 - angle);
75317804
....@@ -7534,7 +7807,7 @@
75347807
75357808 if (modified)
75367809 {
7537
- // Rotate 90 degrees
7810
+ // Rotate 45 degrees
75387811 angle /= (Math.PI / 4);
75397812 angle = Math.floor(angle + 0.5);
75407813 angle *= (Math.PI / 4);
....@@ -7548,7 +7821,7 @@
75487821 }
75497822 /**/
75507823
7551
- switch (info.pane.RenderCamera().viewCode)
7824
+ switch (clickInfo.pane.RenderCamera().viewCode)
75527825 {
75537826 case 1: // '\001'
75547827 LA.matZRotate(toParent, angle);
....@@ -7575,7 +7848,7 @@
75757848 break;
75767849
75777850 case hitScale: // scale
7578
- double hScale = (double) (info.x - centerPt.x) / 32;
7851
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
75797852 double sign = 1;
75807853 if (hScale < 0)
75817854 {
....@@ -7587,7 +7860,7 @@
75877860 //hScale = 0.01;
75887861 }
75897862
7590
- double vScale = (double) (info.y - centerPt.y) / 32;
7863
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
75917864 sign = 1;
75927865 if (vScale < 0)
75937866 {
....@@ -7598,6 +7871,7 @@
75987871 {
75997872 //vScale = 0.01;
76007873 }
7874
+
76017875 LA.matCopy(startMat, toParent);
76027876 /**/
76037877 for (int i = 0; i < 3; i++)
....@@ -7607,33 +7881,39 @@
76077881 }
76087882 /**/
76097883
7610
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7884
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
76117885
76127886 if (totalScale < 0.01)
76137887 {
76147888 totalScale = 0.01;
76157889 }
76167890
7617
- switch (info.pane.RenderCamera().viewCode)
7891
+ switch (clickInfo.pane.RenderCamera().viewCode)
76187892 {
76197893 case 3: // '\001'
76207894 if (modified || opposite)
76217895 {
7896
+ if (modified) // && opposite)
7897
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7898
+ else
76227899 //LA.matScale(toParent, 1, hScale, vScale);
7623
- LA.matScale(toParent, totalScale, 1, 1);
7900
+ LA.matScale(toParent, totalScale, 1, 1);
76247901 } // vScale, 1);
76257902 else
76267903 {
76277904 // EXCEPTION!
7628
- LA.matScale(toParent, totalScale, totalScale, totalScale);
7905
+ LA.matScale(toParent, 1, totalScale, totalScale);
76297906 } // vScale, 1);
76307907 break;
76317908
76327909 case 2: // '\002'
76337910 if (modified || opposite)
76347911 {
7635
- //LA.matScale(toParent, hScale, 1, vScale);
7636
- 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);
76377917 } else
76387918 {
76397919 LA.matScale(toParent, totalScale, 1, totalScale);
....@@ -7643,8 +7923,11 @@
76437923 case 1: // '\003'
76447924 if (modified || opposite)
76457925 {
7646
- //LA.matScale(toParent, hScale, vScale, 1);
7647
- 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);
76487931 } else
76497932 {
76507933 LA.matScale(toParent, totalScale, totalScale, 1);
....@@ -7681,7 +7964,7 @@
76817964 } // NEW ...
76827965
76837966
7684
- info.pane.repaint();
7967
+ clickInfo.pane.repaint();
76857968 }
76867969
76877970 boolean overflow = false;