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,6 +225,8 @@
219225 // o.bRep.support = null;
220226 // }
221227 o.selection = this.selection;
228
+ o.versionlist = this.versionlist;
229
+ o.versionindex = this.versionindex;
222230
223231 if (this.support != null)
224232 {
....@@ -239,6 +247,73 @@
239247 // this.bRep.support = null;
240248 // this.support = null;
241249 // 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;
242317 }
243318
244319 void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
....@@ -274,6 +349,9 @@
274349 }
275350
276351 this.selection = o.selection;
352
+
353
+ this.versionlist = o.versionlist;
354
+ this.versionindex = o.versionindex;
277355 // July 2019 if (this.bRep != null)
278356 // this.bRep.support = o.transientrep;
279357 // this.support = o.support;
....@@ -421,6 +499,7 @@
421499 }
422500
423501 boolean live = false;
502
+ transient boolean keepdontselect;
424503 boolean dontselect = false;
425504 boolean hide = false;
426505 boolean link2master = false; // performs reset support/master at each frame
....@@ -608,7 +687,7 @@
608687 {
609688 if (maxcount != 1)
610689 {
611
- new Exception().printStackTrace();
690
+ //new Exception().printStackTrace();
612691 }
613692
614693 toParentMarked = LA.newMatrix();
....@@ -1005,6 +1084,9 @@
10051084
10061085 if (material == null || material.multiply)
10071086 return true;
1087
+
1088
+ if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
1089
+ return false;
10081090
10091091 // Transparent objects are dynamic because we have to sort the triangles.
10101092 return material.opacity > 0.99;
....@@ -2287,11 +2369,6 @@
22872369
22882370 InitOthers();
22892371
2290
- if (this instanceof Camera)
2291
- {
2292
- material.shift = 90;
2293
- }
2294
-
22952372 material.multiply = multiply;
22962373
22972374 if (multiply)
....@@ -2432,6 +2509,11 @@
24322509 else
24332510 {
24342511 //((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");
24352517 }
24362518 }
24372519
....@@ -2561,7 +2643,8 @@
25612643 private static final int editSelf = 1;
25622644 private static final int editChild = 2;
25632645
2564
- void drawEditHandles(ClickInfo info, int level)
2646
+ void drawEditHandles(//ClickInfo info,
2647
+ int level)
25652648 {
25662649 if (level == 0)
25672650 {
....@@ -2569,7 +2652,8 @@
25692652 return;
25702653
25712654 Object3D selectee;
2572
- 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))
25732657 {
25742658 selectee = (Object3D) e.nextElement();
25752659 }
....@@ -2577,19 +2661,22 @@
25772661 } else
25782662 {
25792663 //super.
2580
- drawEditHandles0(info, level + 1);
2664
+ drawEditHandles0(//info,
2665
+ level + 1);
25812666 }
25822667 }
25832668
2584
- boolean doEditClick(ClickInfo info, int level)
2669
+ boolean doEditClick(//ClickInfo info,
2670
+ int level)
25852671 {
25862672 doSomething = 0;
25872673 if (level == 0)
25882674 {
2589
- return doParentClick(info);
2675
+ return doParentClick(); //info);
25902676 }
25912677 if (//super.
2592
- doEditClick0(info, level))
2678
+ doEditClick0(//info,
2679
+ level))
25932680 {
25942681 doSomething = 1;
25952682 return true;
....@@ -2599,7 +2686,7 @@
25992686 }
26002687 }
26012688
2602
- boolean doParentClick(ClickInfo info)
2689
+ boolean doParentClick() //ClickInfo info)
26032690 {
26042691 if (selection == null)
26052692 {
....@@ -2612,7 +2699,8 @@
26122699 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
26132700 {
26142701 Object3D selectee = (Object3D) e.nextElement();
2615
- if (selectee.doEditClick(info, 1))
2702
+ if (selectee.doEditClick(//info,
2703
+ 1))
26162704 {
26172705 childToDrag = selectee;
26182706 doSomething = 2;
....@@ -2624,13 +2712,15 @@
26242712 return retval;
26252713 }
26262714
2627
- void doEditDrag(ClickInfo info, boolean opposite)
2715
+ void doEditDrag(//ClickInfo clickInfo,
2716
+ boolean opposite)
26282717 {
26292718 switch (doSomething)
26302719 {
26312720 case 1: // '\001'
26322721 //super.
2633
- doEditDrag0(info, opposite);
2722
+ doEditDrag0(//clickInfo,
2723
+ opposite);
26342724 break;
26352725
26362726 case 2: // '\002'
....@@ -2643,11 +2733,13 @@
26432733 {
26442734 //sel.hitSomething = childToDrag.hitSomething;
26452735 //childToDrag.doEditDrag(info);
2646
- sel.doEditDrag(info, opposite);
2736
+ sel.doEditDrag(//clickInfo,
2737
+ opposite);
26472738 } else
26482739 {
26492740 //super.
2650
- doEditDrag0(info, opposite);
2741
+ doEditDrag0(//clickInfo,
2742
+ opposite);
26512743 }
26522744 }
26532745 break;
....@@ -2665,6 +2757,9 @@
26652757 {
26662758 deselectAll();
26672759 }
2760
+
2761
+ new Exception().printStackTrace();
2762
+
26682763 ClickInfo newInfo = new ClickInfo();
26692764 newInfo.flags = info.flags;
26702765 newInfo.bounds = info.bounds;
....@@ -3112,7 +3207,7 @@
31123207 {
31133208 if (bRep != null)
31143209 {
3115
- bRep.GenerateNormalsMINE();
3210
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
31163211 Touch();
31173212 }
31183213 }
....@@ -3522,15 +3617,47 @@
35223617
35233618 void ClearMaterials()
35243619 {
3620
+ if (blockloop)
3621
+ return;
3622
+
3623
+ blockloop = true;
3624
+
35253625 ClearMaterial();
3526
- for (int i = 0; i < size(); i++)
3626
+ for (int i = 0; i < Size(); i++)
35273627 {
3528
- Object3D child = (Object3D) reserve(i);
3628
+ Object3D child = (Object3D) get(i);
35293629 if (child == null)
35303630 continue;
35313631 child.ClearMaterials();
3532
- release(i);
35333632 }
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;
35343661 }
35353662
35363663 void FlipV(boolean flip)
....@@ -5415,6 +5542,51 @@
54155542 blockloop = false;
54165543 }
54175544
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
+
54185590 boolean IsSelected()
54195591 {
54205592 if (parent == null)
....@@ -5475,6 +5647,11 @@
54755647 if (fullname == null)
54765648 return "";
54775649
5650
+ if (fullname.pigment != null)
5651
+ {
5652
+ return fullname.pigment;
5653
+ }
5654
+
54785655 // System.out.println("Fullname = " + fullname);
54795656
54805657 // Does not work on Windows due to C:
....@@ -5487,7 +5664,7 @@
54875664
54885665 if (split.length == 0)
54895666 {
5490
- return "";
5667
+ return fullname.pigment = "";
54915668 }
54925669
54935670 if (split.length <= 2)
....@@ -5495,22 +5672,27 @@
54955672 if (fullname.name.endsWith(":"))
54965673 {
54975674 // Windows
5498
- return fullname.name.substring(0, fullname.name.length()-1);
5675
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
54995676 }
55005677
5501
- return split[0];
5678
+ return fullname.pigment = split[0];
55025679 }
55035680
55045681 // Windows
55055682 assert(split.length == 4);
55065683
5507
- return split[0] + ":" + split[1];
5684
+ return fullname.pigment = split[0] + ":" + split[1];
55085685 }
55095686
55105687 static String GetBump(cTexture fullname)
55115688 {
55125689 if (fullname == null)
55135690 return "";
5691
+
5692
+ if (fullname.bump != null)
5693
+ {
5694
+ return fullname.bump;
5695
+ }
55145696
55155697 // System.out.println("Fullname = " + fullname);
55165698 // Does not work on Windows due to C:
....@@ -5522,12 +5704,12 @@
55225704
55235705 if (split.length == 0)
55245706 {
5525
- return "";
5707
+ return fullname.bump = "";
55265708 }
55275709
55285710 if (split.length == 1)
55295711 {
5530
- return "";
5712
+ return fullname.bump = "";
55315713 }
55325714
55335715 if (split.length == 2)
....@@ -5535,16 +5717,16 @@
55355717 if (fullname.name.endsWith(":"))
55365718 {
55375719 // Windows
5538
- return "";
5720
+ return fullname.bump = "";
55395721 }
55405722
5541
- return split[1];
5723
+ return fullname.bump = split[1];
55425724 }
55435725
55445726 // Windows
55455727 assert(split.length == 4);
55465728
5547
- return split[2] + ":" + split[3];
5729
+ return fullname.bump = split[2] + ":" + split[3];
55485730 }
55495731
55505732 String GetPigmentTexture()
....@@ -5627,6 +5809,9 @@
56275809 texname = "";
56285810
56295811 GetTextures().name = texname + ":" + GetBump(GetTextures());
5812
+
5813
+ GetTextures().pigment = null;
5814
+
56305815 Touch();
56315816 }
56325817
....@@ -5700,6 +5885,8 @@
57005885
57015886 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
57025887
5888
+ GetTextures().bump = null;
5889
+
57035890 Touch();
57045891 }
57055892
....@@ -5720,6 +5907,38 @@
57205907
57215908 blockloop = true;
57225909 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);
57235942 blockloop = false;
57245943 }
57255944 }
....@@ -5810,8 +6029,10 @@
58106029 if (support != null)
58116030 support = support;
58126031
5813
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5814
- 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.
58156036
58166037 if (!usecalllists && bRep != null && bRep.displaylist > 0)
58176038 {
....@@ -5821,8 +6042,9 @@
58216042 // usecalllists &= !(parent instanceof RandomNode);
58226043 // usecalllists = false;
58236044
5824
- if (GetBRep() != null)
5825
- usecalllists = usecalllists;
6045
+ if (display.DrawMode() == display.SHADOW)
6046
+ //GetBRep() != null)
6047
+ usecalllists = !!usecalllists;
58266048 //System.out.println("draw " + this);
58276049 //new Exception().printStackTrace();
58286050
....@@ -5844,7 +6066,7 @@
58446066 if (!(this instanceof Composite))
58456067 touched = false;
58466068 //if (displaylist == -1 && usecalllists)
5847
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
6069
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
58486070 {
58496071 bRep.displaylist = display.GenList();
58506072 assert(bRep.displaylist != 0);
....@@ -5855,7 +6077,7 @@
58556077
58566078 //System.out.println("\tnew list " + list);
58576079 //gl.glDrawBuffer(gl.GL_NONE);
5858
- if (usecalllists)
6080
+ if (usecalllists && bRep.displaylist > 0)
58596081 {
58606082 // System.err.println("new list " + bRep.displaylist + " for " + this);
58616083 display.NewList(bRep.displaylist);
....@@ -5864,7 +6086,7 @@
58646086 CallList(display, root, selected, blocked);
58656087
58666088 // compiled = true;
5867
- if (usecalllists)
6089
+ if (usecalllists && bRep.displaylist > 0)
58686090 {
58696091 // System.err.println("end list " + bRep.displaylist + " for " + this);
58706092 display.EndList();
....@@ -7215,20 +7437,23 @@
72157437 }
72167438 }
72177439
7218
- 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)
72197444 {
7220
- int hc = info.bounds.x + info.bounds.width / 2;
7221
- int vc = info.bounds.y + info.bounds.height / 2;
7222
- 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;
72237448 if (toscreen == null)
72247449 {
7225
- toscreen = new Camera(info.camera.viewCode).toScreen;
7450
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
72267451 }
72277452 cVector vec = in;
72287453 LA.xformPos(in, toscreen, in);
72297454 //System.out.println("Distance = " + info.camera.Distance());
7230
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7231
- 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();
72327457 outPt.x = hc + (int) vec.x;
72337458 outPt.y = vc - (int) vec.y;
72347459 outRec.x = outPt.x - 3;
....@@ -7236,15 +7461,18 @@
72367461 outRec.width = outRec.height = 6;
72377462 }
72387463
7239
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7464
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7465
+ )
72407466 {
72417467 Point pt = new Point(0, 0);
72427468 Rectangle rec = new Rectangle();
7243
- calcHotSpot(in, info, pt, rec);
7469
+ calcHotSpot(in, //clickInfo,
7470
+ pt, rec);
72447471 return rec;
72457472 }
72467473
7247
- void drawEditHandles0(ClickInfo info, int level)
7474
+ void drawEditHandles0(//ClickInfo clickInfo,
7475
+ int level)
72487476 {
72497477 if (level == 0)
72507478 {
....@@ -7253,16 +7481,19 @@
72537481 {
72547482 cVector origin = new cVector();
72557483 //LA.xformPos(origin, toParent, origin);
7256
- Rectangle spot = calcHotSpot(origin, info);
7484
+ if (this.clickInfo == null)
7485
+ this.clickInfo = new ClickInfo();
7486
+
7487
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
72577488 Rectangle boundary = new Rectangle();
72587489 boundary.x = spot.x - 30;
72597490 boundary.y = spot.y - 30;
72607491 boundary.width = spot.width + 60;
72617492 boundary.height = spot.height + 60;
7262
- info.g.setColor(Color.red);
7493
+ clickInfo.g.setColor(Color.white);
72637494 int spotw = spot.x + spot.width;
72647495 int spoth = spot.y + spot.height;
7265
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7496
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72667497 // if (CameraPane.Xmin > spot.x)
72677498 // {
72687499 // CameraPane.Xmin = spot.x;
....@@ -7279,11 +7510,6 @@
72797510 // {
72807511 // CameraPane.Ymax = spoth;
72817512 // }
7282
- spot.translate(32, 32);
7283
- spotw = spot.x + spot.width;
7284
- spoth = spot.y + spot.height;
7285
- info.g.setColor(Color.cyan);
7286
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72877513 // if (CameraPane.Xmin > spot.x)
72887514 // {
72897515 // CameraPane.Xmin = spot.x;
....@@ -7302,10 +7528,15 @@
73027528 // }
73037529 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
73047530 //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7305
- spot.translate(0, -32);
7306
- info.g.setColor(Color.yellow);
7307
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7308
- 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);
73097540 // if (CameraPane.Xmin > spot.x)
73107541 // {
73117542 // CameraPane.Xmin = spot.x;
....@@ -7322,8 +7553,9 @@
73227553 // {
73237554 // CameraPane.Ymax = spoth;
73247555 // }
7325
- info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY,
7326
- (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);
73277559 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
73287560 // if (CameraPane.Xmin > boundary.x)
73297561 // {
....@@ -7345,7 +7577,8 @@
73457577 }
73467578 }
73477579
7348
- boolean doEditClick0(ClickInfo info, int level)
7580
+ boolean doEditClick0(//ClickInfo clickInfo,
7581
+ int level)
73497582 {
73507583 if (level == 0)
73517584 {
....@@ -7354,8 +7587,8 @@
73547587
73557588 boolean retval = false;
73567589
7357
- startX = info.x;
7358
- startY = info.y;
7590
+ startX = clickInfo.x;
7591
+ startY = clickInfo.y;
73597592
73607593 hitSomething = -1;
73617594 cVector origin = new cVector();
....@@ -7365,22 +7598,53 @@
73657598 {
73667599 centerPt = new Point(0, 0);
73677600 }
7368
- calcHotSpot(origin, info, centerPt, spot);
7369
- if (spot.contains(info.x, info.y))
7601
+ calcHotSpot(origin, //info,
7602
+ centerPt, spot);
7603
+ if (spot.contains(clickInfo.x, clickInfo.y))
73707604 {
73717605 hitSomething = hitCenter;
73727606 retval = true;
73737607 }
73747608 spot.translate(32, 0);
7375
- if (spot.contains(info.x, info.y))
7609
+ if (spot.contains(clickInfo.x, clickInfo.y))
73767610 {
73777611 hitSomething = hitRotate;
73787612 retval = true;
73797613 }
73807614 spot.translate(0, 32);
7381
- 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))
73827618 {
73837619 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
+
73847648 retval = true;
73857649 }
73867650
....@@ -7390,7 +7654,7 @@
73907654 }
73917655
73927656 //System.out.println("info.modifiers = " + info.modifiers);
7393
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7657
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
73947658 //System.out.println("modified = " + modified);
73957659 //new Exception().printStackTrace();
73967660 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7418,7 +7682,8 @@
74187682 return true;
74197683 }
74207684
7421
- void doEditDrag0(ClickInfo info, boolean opposite)
7685
+ void doEditDrag0(//ClickInfo info,
7686
+ boolean opposite)
74227687 {
74237688 if (hitSomething == 0)
74247689 {
....@@ -7432,7 +7697,7 @@
74327697
74337698 //System.out.println("hitSomething = " + hitSomething);
74347699
7435
- double scale = 0.005f * info.camera.Distance();
7700
+ double scale = 0.005f * clickInfo.camera.Distance();
74367701
74377702 cVector xlate = new cVector();
74387703 //cVector xlate2 = new cVector();
....@@ -7446,7 +7711,9 @@
74467711
74477712 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
74487713
7449
- if (modified || opposite)
7714
+ // Modified could snap
7715
+ if (//modified ||
7716
+ opposite)
74507717 {
74517718 //assert(false);
74527719 /*
....@@ -7466,8 +7733,8 @@
74667733 toParent[3][i] = xlate.get(i);
74677734 LA.matInvert(toParent, fromParent);
74687735 */
7469
- cVector delta = LA.newVector(0, 0, startY - info.y);
7470
- 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);
74717738
74727739 LA.matCopy(startMat, toParent);
74737740 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7476,7 +7743,7 @@
74767743 } else
74777744 {
74787745 //LA.xformDir(delta, info.camera.fromScreen, delta);
7479
- cVector up = new cVector(info.camera.up);
7746
+ cVector up = new cVector(clickInfo.camera.up);
74807747 cVector away = new cVector();
74817748 //cVector right2 = new cVector();
74827749 //LA.vecCross(up, cVector.Z, right);
....@@ -7493,19 +7760,19 @@
74937760 LA.xformDir(up, ClickInfo.matbuffer, up);
74947761 // if (!CameraPane.LOCALTRANSFORM)
74957762 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7496
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7763
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
74977764 // if (!CameraPane.LOCALTRANSFORM)
74987765 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
74997766 //LA.vecCross(up, cVector.Z, right2);
75007767
7501
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7768
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
75027769
75037770 //System.out.println("DELTA0 = " + delta);
75047771 //System.out.println("AWAY = " + info.camera.away);
75057772 //System.out.println("UP = " + info.camera.up);
75067773 if (away.z > 0)
75077774 {
7508
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7775
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
75097776 {
75107777 delta.x = -delta.x;
75117778 } else
....@@ -7520,7 +7787,7 @@
75207787 //System.out.println("DELTA1 = " + delta);
75217788 LA.xformDir(delta, ClickInfo.matbuffer, delta);
75227789 //System.out.println("DELTA2 = " + delta);
7523
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7790
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
75247791 LA.matCopy(startMat, toParent);
75257792 //System.out.println("DELTA3 = " + delta);
75267793 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7530,8 +7797,8 @@
75307797 break;
75317798
75327799 case hitRotate: // rotate
7533
- int dx = info.x - centerPt.x;
7534
- int dy = -(info.y - centerPt.y);
7800
+ int dx = clickInfo.x - centerPt.x;
7801
+ int dy = -(clickInfo.y - centerPt.y);
75357802 double angle = (double) Math.atan2(dx, dy);
75367803 angle = -(1.570796 - angle);
75377804
....@@ -7540,7 +7807,7 @@
75407807
75417808 if (modified)
75427809 {
7543
- // Rotate 90 degrees
7810
+ // Rotate 45 degrees
75447811 angle /= (Math.PI / 4);
75457812 angle = Math.floor(angle + 0.5);
75467813 angle *= (Math.PI / 4);
....@@ -7554,7 +7821,7 @@
75547821 }
75557822 /**/
75567823
7557
- switch (info.pane.RenderCamera().viewCode)
7824
+ switch (clickInfo.pane.RenderCamera().viewCode)
75587825 {
75597826 case 1: // '\001'
75607827 LA.matZRotate(toParent, angle);
....@@ -7581,7 +7848,7 @@
75817848 break;
75827849
75837850 case hitScale: // scale
7584
- double hScale = (double) (info.x - centerPt.x) / 32;
7851
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
75857852 double sign = 1;
75867853 if (hScale < 0)
75877854 {
....@@ -7593,7 +7860,7 @@
75937860 //hScale = 0.01;
75947861 }
75957862
7596
- double vScale = (double) (info.y - centerPt.y) / 32;
7863
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
75977864 sign = 1;
75987865 if (vScale < 0)
75997866 {
....@@ -7604,6 +7871,7 @@
76047871 {
76057872 //vScale = 0.01;
76067873 }
7874
+
76077875 LA.matCopy(startMat, toParent);
76087876 /**/
76097877 for (int i = 0; i < 3; i++)
....@@ -7613,33 +7881,39 @@
76137881 }
76147882 /**/
76157883
7616
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7884
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
76177885
76187886 if (totalScale < 0.01)
76197887 {
76207888 totalScale = 0.01;
76217889 }
76227890
7623
- switch (info.pane.RenderCamera().viewCode)
7891
+ switch (clickInfo.pane.RenderCamera().viewCode)
76247892 {
76257893 case 3: // '\001'
76267894 if (modified || opposite)
76277895 {
7896
+ if (modified) // && opposite)
7897
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
7898
+ else
76287899 //LA.matScale(toParent, 1, hScale, vScale);
7629
- LA.matScale(toParent, totalScale, 1, 1);
7900
+ LA.matScale(toParent, totalScale, 1, 1);
76307901 } // vScale, 1);
76317902 else
76327903 {
76337904 // EXCEPTION!
7634
- LA.matScale(toParent, totalScale, totalScale, totalScale);
7905
+ LA.matScale(toParent, 1, totalScale, totalScale);
76357906 } // vScale, 1);
76367907 break;
76377908
76387909 case 2: // '\002'
76397910 if (modified || opposite)
76407911 {
7641
- //LA.matScale(toParent, hScale, 1, vScale);
7642
- 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);
76437917 } else
76447918 {
76457919 LA.matScale(toParent, totalScale, 1, totalScale);
....@@ -7649,8 +7923,11 @@
76497923 case 1: // '\003'
76507924 if (modified || opposite)
76517925 {
7652
- //LA.matScale(toParent, hScale, vScale, 1);
7653
- 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);
76547931 } else
76557932 {
76567933 LA.matScale(toParent, totalScale, totalScale, 1);
....@@ -7687,7 +7964,7 @@
76877964 } // NEW ...
76887965
76897966
7690
- info.pane.repaint();
7967
+ clickInfo.pane.repaint();
76917968 }
76927969
76937970 boolean overflow = false;