Normand Briere
2019-08-13 0cdf3fb57ddea3226f094ba45c836c7e9b123e3a
Object3D.java
....@@ -22,13 +22,20 @@
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
27
- // TEMPORARY for mocap undo
28
- mocap.reader.BVHReader.BVHResult bvh;
29
- Object3D skeleton;
28
+ // TEMPORARY for mocap undo. No need to be transient.
29
+ mocap.reader.BVHReader.BVHResult savebvh;
30
+ Object3D saveskeleton;
3031 //
3132
33
+ String skyboxname;
34
+ String skyboxext;
35
+
36
+ Object3D versionlist[];
37
+ int versionindex = -1;
38
+
3239 ScriptNode scriptnode;
3340
3441 void InitOthers()
....@@ -170,24 +177,35 @@
170177
171178 void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
172179 {
180
+ Object3D o;
181
+
173182 if (hashtable.containsKey(GetUUID()))
174183 {
175
- Object3D o = hashtable.get(GetUUID());
184
+ o = hashtable.get(GetUUID());
176185
177186 Grafreed.Assert(this.bRep == o.bRep);
178
- if (this.bRep != null)
179
- assert(this.bRep.support == o.transientrep);
187
+ //if (this.bRep != null)
188
+ // assert(this.bRep.support == o.transientrep);
189
+ if (this.support != null)
190
+ assert(this.support.bRep == o.transientrep);
191
+ }
192
+ else
193
+ {
194
+ o = new Object3D("copy of " + this.name);
180195
181
- return;
196
+ hashtable.put(GetUUID(), o);
182197 }
183198
184
- Object3D o = new Object3D();
185
-
186
- hashtable.put(GetUUID(), o);
187
-
188
- for (int i=0; i<Size(); i++)
199
+ if (!blockloop)
189200 {
190
- get(i).ExtractBigData(hashtable);
201
+ blockloop = true;
202
+
203
+ for (int i=0; i<Size(); i++)
204
+ {
205
+ get(i).ExtractBigData(hashtable);
206
+ }
207
+
208
+ blockloop = false;
191209 }
192210
193211 ExtractBigData(o);
....@@ -195,11 +213,26 @@
195213
196214 void ExtractBigData(Object3D o)
197215 {
216
+ if (o.bRep != null)
217
+ Grafreed.Assert(o.bRep == this.bRep);
218
+
198219 o.bRep = this.bRep;
199
- if (this.bRep != null)
220
+// July 2019 if (this.bRep != null)
221
+// {
222
+// o.transientrep = this.bRep.support;
223
+// o.bRep.support = null;
224
+// }
225
+ o.selection = this.selection;
226
+ o.versionlist = this.versionlist;
227
+ o.versionindex = this.versionindex;
228
+
229
+ if (this.support != null)
200230 {
201
- o.transientrep = this.bRep.support;
202
- o.bRep.support = null;
231
+ if (o.transientrep != null)
232
+ Grafreed.Assert(o.transientrep == this.support.bRep);
233
+
234
+ o.transientrep = this.support.bRep;
235
+ this.support.bRep = null;
203236 }
204237
205238 // o.support = this.support;
....@@ -214,6 +247,29 @@
214247 // this.fileparent = null;
215248 }
216249
250
+// Object3D GetObject(java.util.UUID uuid)
251
+// {
252
+// if (this.uuid.equals(uuid))
253
+// return this;
254
+//
255
+// if (blockloop)
256
+// return null;
257
+//
258
+// blockloop = true;
259
+//
260
+// for (int i=0; i<Size(); i++)
261
+// {
262
+// Object3D o = get(i).GetObject(uuid);
263
+//
264
+// if (o != null)
265
+// return o;
266
+// }
267
+//
268
+// blockloop = false;
269
+//
270
+// return null;
271
+// }
272
+
217273 void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
218274 {
219275 if (!hashtable.containsKey(GetUUID()))
....@@ -223,19 +279,35 @@
223279
224280 RestoreBigData(o);
225281
226
- hashtable.remove(GetUUID());
282
+ if (blockloop)
283
+ return;
284
+
285
+ blockloop = true;
286
+
287
+ //hashtable.remove(GetUUID());
227288
228289 for (int i=0; i<Size(); i++)
229290 {
230291 get(i).RestoreBigData(hashtable);
231292 }
293
+
294
+ blockloop = false;
232295 }
233296
234297 void RestoreBigData(Object3D o)
235298 {
236299 this.bRep = o.bRep;
237
- if (this.bRep != null)
238
- this.bRep.support = o.transientrep;
300
+ if (this.support != null && o.transientrep != null)
301
+ {
302
+ this.support.bRep = o.transientrep;
303
+ }
304
+
305
+ this.selection = o.selection;
306
+
307
+ this.versionlist = o.versionlist;
308
+ this.versionindex = o.versionindex;
309
+// July 2019 if (this.bRep != null)
310
+// this.bRep.support = o.transientrep;
239311 // this.support = o.support;
240312 // this.fileparent = o.fileparent;
241313 }
....@@ -381,6 +453,7 @@
381453 }
382454
383455 boolean live = false;
456
+ transient boolean keepdontselect;
384457 boolean dontselect = false;
385458 boolean hide = false;
386459 boolean link2master = false; // performs reset support/master at each frame
....@@ -881,7 +954,7 @@
881954
882955 if (marked && Globals.isLIVE() && live &&
883956 //TEMP21aug2018
884
- (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
957
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
885958 currentframe != Globals.framecount)
886959 {
887960 currentframe = Globals.framecount;
....@@ -893,7 +966,8 @@
893966
894967 boolean changedir = random && Math.random() < 0.01; // && !link2master;
895968
896
- if (transformcount*factor > maxcount || (step == 1 && changedir))
969
+ if (transformcount*factor >= maxcount && (rewind || random) ||
970
+ (step == 1 && changedir))
897971 {
898972 countdown = 1;
899973 delay = speedup?8:1;
....@@ -965,6 +1039,10 @@
9651039 if (material == null || material.multiply)
9661040 return true;
9671041
1042
+ if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
1043
+ return false;
1044
+
1045
+ // Transparent objects are dynamic because we have to sort the triangles.
9681046 return material.opacity > 0.99;
9691047 }
9701048
....@@ -1365,6 +1443,7 @@
13651443 toParent = LA.newMatrix();
13661444 fromParent = LA.newMatrix();
13671445 }
1446
+
13681447 LA.matCopy(other.toParent, toParent);
13691448 LA.matCopy(other.fromParent, fromParent);
13701449
....@@ -2386,6 +2465,15 @@
23862465 }
23872466 */
23882467 }
2468
+ else
2469
+ {
2470
+ //((ObjEditor)editWindow).SetupUI2(null);
2471
+ if (objectUI != null)
2472
+ ((ObjEditor)objectUI).pinButton.setSelected(pinned);
2473
+ else
2474
+ //new Exception().printStackTrace();
2475
+ System.err.println("objectUI is null");
2476
+ }
23892477 }
23902478
23912479 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2427,6 +2515,14 @@
24272515 {
24282516 editWindow.refreshContents();
24292517 }
2518
+ else
2519
+ {
2520
+ if (manipWindow != null)
2521
+ {
2522
+ manipWindow.refreshContents();
2523
+ }
2524
+ }
2525
+
24302526 //if (parent != null)
24312527 //parent.refreshEditWindow();
24322528 }
....@@ -2506,7 +2602,8 @@
25062602 private static final int editSelf = 1;
25072603 private static final int editChild = 2;
25082604
2509
- void drawEditHandles(ClickInfo info, int level)
2605
+ void drawEditHandles(//ClickInfo info,
2606
+ int level)
25102607 {
25112608 if (level == 0)
25122609 {
....@@ -2514,7 +2611,8 @@
25142611 return;
25152612
25162613 Object3D selectee;
2517
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2614
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2615
+ level + 1))
25182616 {
25192617 selectee = (Object3D) e.nextElement();
25202618 }
....@@ -2522,19 +2620,22 @@
25222620 } else
25232621 {
25242622 //super.
2525
- drawEditHandles0(info, level + 1);
2623
+ drawEditHandles0(//info,
2624
+ level + 1);
25262625 }
25272626 }
25282627
2529
- boolean doEditClick(ClickInfo info, int level)
2628
+ boolean doEditClick(//ClickInfo info,
2629
+ int level)
25302630 {
25312631 doSomething = 0;
25322632 if (level == 0)
25332633 {
2534
- return doParentClick(info);
2634
+ return doParentClick(); //info);
25352635 }
25362636 if (//super.
2537
- doEditClick0(info, level))
2637
+ doEditClick0(//info,
2638
+ level))
25382639 {
25392640 doSomething = 1;
25402641 return true;
....@@ -2544,7 +2645,7 @@
25442645 }
25452646 }
25462647
2547
- boolean doParentClick(ClickInfo info)
2648
+ boolean doParentClick() //ClickInfo info)
25482649 {
25492650 if (selection == null)
25502651 {
....@@ -2557,7 +2658,8 @@
25572658 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
25582659 {
25592660 Object3D selectee = (Object3D) e.nextElement();
2560
- if (selectee.doEditClick(info, 1))
2661
+ if (selectee.doEditClick(//info,
2662
+ 1))
25612663 {
25622664 childToDrag = selectee;
25632665 doSomething = 2;
....@@ -2569,13 +2671,15 @@
25692671 return retval;
25702672 }
25712673
2572
- void doEditDrag(ClickInfo info, boolean opposite)
2674
+ void doEditDrag(//ClickInfo clickInfo,
2675
+ boolean opposite)
25732676 {
25742677 switch (doSomething)
25752678 {
25762679 case 1: // '\001'
25772680 //super.
2578
- doEditDrag0(info, opposite);
2681
+ doEditDrag0(//clickInfo,
2682
+ opposite);
25792683 break;
25802684
25812685 case 2: // '\002'
....@@ -2588,11 +2692,13 @@
25882692 {
25892693 //sel.hitSomething = childToDrag.hitSomething;
25902694 //childToDrag.doEditDrag(info);
2591
- sel.doEditDrag(info, opposite);
2695
+ sel.doEditDrag(//clickInfo,
2696
+ opposite);
25922697 } else
25932698 {
25942699 //super.
2595
- doEditDrag0(info, opposite);
2700
+ doEditDrag0(//clickInfo,
2701
+ opposite);
25962702 }
25972703 }
25982704 break;
....@@ -2610,6 +2716,9 @@
26102716 {
26112717 deselectAll();
26122718 }
2719
+
2720
+ new Exception().printStackTrace();
2721
+
26132722 ClickInfo newInfo = new ClickInfo();
26142723 newInfo.flags = info.flags;
26152724 newInfo.bounds = info.bounds;
....@@ -3057,7 +3166,7 @@
30573166 {
30583167 if (bRep != null)
30593168 {
3060
- bRep.GenerateNormalsMINE();
3169
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
30613170 Touch();
30623171 }
30633172 }
....@@ -3503,7 +3612,8 @@
35033612 if (blockloop)
35043613 return;
35053614
3506
- if (marked || (bRep != null && material != null)) // borderline...
3615
+ if (//marked || // does not make sense
3616
+ (bRep != null || material != null)) // borderline...
35073617 live = h;
35083618
35093619 for (int i = 0; i < Size(); i++)
....@@ -3524,7 +3634,8 @@
35243634 return;
35253635
35263636 //if (bRep != null)
3527
- if (marked || (bRep != null && material != null)) // borderline...
3637
+ if (//marked || // does not make sense
3638
+ (bRep != null || material != null)) // borderline...
35283639 link2master = h;
35293640
35303641 for (int i = 0; i < Size(); i++)
....@@ -3544,7 +3655,8 @@
35443655 if (blockloop)
35453656 return;
35463657
3547
- if (marked || (bRep != null && material != null)) // borderline...
3658
+ if (//marked || // does not make sense
3659
+ (bRep != null || material != null)) // borderline...
35483660 hide = h;
35493661
35503662 for (int i = 0; i < Size(); i++)
....@@ -3564,7 +3676,7 @@
35643676 if (blockloop)
35653677 return;
35663678
3567
- if (bRep != null && material != null) // borderline...
3679
+ if (bRep != null || material != null) // borderline...
35683680 marked = h;
35693681
35703682 for (int i = 0; i < Size(); i++)
....@@ -3574,6 +3686,46 @@
35743686 continue;
35753687 blockloop = true;
35763688 child.MarkLeaves(h);
3689
+ blockloop = false;
3690
+ // release(i);
3691
+ }
3692
+ }
3693
+
3694
+ void RewindLeaves(boolean h)
3695
+ {
3696
+ if (blockloop)
3697
+ return;
3698
+
3699
+ if (bRep != null || material != null) // borderline...
3700
+ rewind = h;
3701
+
3702
+ for (int i = 0; i < Size(); i++)
3703
+ {
3704
+ Object3D child = (Object3D) get(i); // reserve(i);
3705
+ if (child == null)
3706
+ continue;
3707
+ blockloop = true;
3708
+ child.RewindLeaves(h);
3709
+ blockloop = false;
3710
+ // release(i);
3711
+ }
3712
+ }
3713
+
3714
+ void RandomLeaves(boolean h)
3715
+ {
3716
+ if (blockloop)
3717
+ return;
3718
+
3719
+ if (bRep != null || material != null) // borderline...
3720
+ random = h;
3721
+
3722
+ for (int i = 0; i < Size(); i++)
3723
+ {
3724
+ Object3D child = (Object3D) get(i); // reserve(i);
3725
+ if (child == null)
3726
+ continue;
3727
+ blockloop = true;
3728
+ child.RandomLeaves(h);
35773729 blockloop = false;
35783730 // release(i);
35793731 }
....@@ -4914,6 +5066,14 @@
49145066 }
49155067 }
49165068
5069
+ ObjEditor GetWindow()
5070
+ {
5071
+ if (editWindow != null)
5072
+ return editWindow;
5073
+
5074
+ return manipWindow;
5075
+ }
5076
+
49175077 cTreePath Select(int indexcount, boolean deselect)
49185078 {
49195079 if (hide || dontselect)
....@@ -4950,10 +5110,11 @@
49505110 if (leaf != null)
49515111 {
49525112 cTreePath tp = new cTreePath(this, leaf);
4953
- if (editWindow != null)
5113
+ ObjEditor window = GetWindow();
5114
+ if (window != null)
49545115 {
49555116 //System.out.println("editWindow = " + editWindow + " vs " + this);
4956
- editWindow.Select(tp, deselect, true);
5117
+ window.Select(tp, deselect, true);
49575118 }
49585119
49595120 return tp;
....@@ -4970,6 +5131,7 @@
49705131
49715132 if (child == null)
49725133 continue;
5134
+
49735135 if (child.HasTransparency() && child.size() != 0)
49745136 {
49755137 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4979,9 +5141,10 @@
49795141 if (leaf != null)
49805142 {
49815143 cTreePath tp = new cTreePath(this, leaf);
4982
- if (editWindow != null)
5144
+ ObjEditor window = GetWindow();
5145
+ if (window != null)
49835146 {
4984
- editWindow.Select(tp, deselect, true);
5147
+ window.Select(tp, deselect, true);
49855148 }
49865149
49875150 return tp;
....@@ -5306,6 +5469,51 @@
53065469 blockloop = false;
53075470 }
53085471
5472
+ void ResetSelectable()
5473
+ {
5474
+ if (blockloop)
5475
+ return;
5476
+
5477
+ blockloop = true;
5478
+
5479
+ keepdontselect = dontselect;
5480
+ dontselect = true;
5481
+
5482
+ Object3D child;
5483
+ int nb = Size();
5484
+ for (int i = 0; i < nb; i++)
5485
+ {
5486
+ child = (Object3D) get(i);
5487
+ if (child == null)
5488
+ continue;
5489
+ child.ResetSelectable();
5490
+ }
5491
+
5492
+ blockloop = false;
5493
+ }
5494
+
5495
+ void RestoreSelectable()
5496
+ {
5497
+ if (blockloop)
5498
+ return;
5499
+
5500
+ blockloop = true;
5501
+
5502
+ dontselect = keepdontselect;
5503
+
5504
+ Object3D child;
5505
+ int nb = Size();
5506
+ for (int i = 0; i < nb; i++)
5507
+ {
5508
+ child = (Object3D) get(i);
5509
+ if (child == null)
5510
+ continue;
5511
+ child.RestoreSelectable();
5512
+ }
5513
+
5514
+ blockloop = false;
5515
+ }
5516
+
53095517 boolean IsSelected()
53105518 {
53115519 if (parent == null)
....@@ -5615,6 +5823,38 @@
56155823 }
56165824 }
56175825
5826
+ void EmbedTextures(boolean embed)
5827
+ {
5828
+ if (blockloop)
5829
+ return;
5830
+
5831
+ //if (GetTextures() != null)
5832
+ if (embed)
5833
+ CameraPane.EmbedTextures(GetTextures());
5834
+ else
5835
+ {
5836
+ GetTextures().pigmentdata = null;
5837
+ GetTextures().bumpdata = null;
5838
+ GetTextures().pw = 0;
5839
+ GetTextures().ph = 0;
5840
+ GetTextures().bw = 0;
5841
+ GetTextures().bh = 0;
5842
+ }
5843
+
5844
+ int nb = Size();
5845
+ for (int i = 0; i < nb; i++)
5846
+ {
5847
+ Object3D child = (Object3D) get(i);
5848
+
5849
+ if (child == null)
5850
+ continue;
5851
+
5852
+ blockloop = true;
5853
+ child.EmbedTextures(embed);
5854
+ blockloop = false;
5855
+ }
5856
+ }
5857
+
56185858 void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
56195859 {
56205860 Draw(display, root, selected, blocked);
....@@ -5701,8 +5941,10 @@
57015941 if (support != null)
57025942 support = support;
57035943
5704
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5705
- boolean usecalllists = IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5944
+ boolean usecalllists = !IsLive() && IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5945
+ //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5946
+
5947
+ //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass.
57065948
57075949 if (!usecalllists && bRep != null && bRep.displaylist > 0)
57085950 {
....@@ -5712,8 +5954,9 @@
57125954 // usecalllists &= !(parent instanceof RandomNode);
57135955 // usecalllists = false;
57145956
5715
- if (GetBRep() != null)
5716
- usecalllists = usecalllists;
5957
+ if (display.DrawMode() == display.SHADOW)
5958
+ //GetBRep() != null)
5959
+ usecalllists = !!usecalllists;
57175960 //System.out.println("draw " + this);
57185961 //new Exception().printStackTrace();
57195962
....@@ -5723,7 +5966,7 @@
57235966
57245967 if (!selectmode && //display.DrawMode() != display.SELECTION &&
57255968 //(touched || (bRep != null && bRep.displaylist <= 0)))
5726
- (Globals.isLIVE() || touched && (bRep != null && bRep.displaylist <= 0)))
5969
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
57275970 {
57285971 Globals.lighttouched = true;
57295972 } // all panes...
....@@ -5735,7 +5978,7 @@
57355978 if (!(this instanceof Composite))
57365979 touched = false;
57375980 //if (displaylist == -1 && usecalllists)
5738
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
5981
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
57395982 {
57405983 bRep.displaylist = display.GenList();
57415984 assert(bRep.displaylist != 0);
....@@ -5746,7 +5989,7 @@
57465989
57475990 //System.out.println("\tnew list " + list);
57485991 //gl.glDrawBuffer(gl.GL_NONE);
5749
- if (usecalllists)
5992
+ if (usecalllists && bRep.displaylist > 0)
57505993 {
57515994 // System.err.println("new list " + bRep.displaylist + " for " + this);
57525995 display.NewList(bRep.displaylist);
....@@ -5755,7 +5998,7 @@
57555998 CallList(display, root, selected, blocked);
57565999
57576000 // compiled = true;
5758
- if (usecalllists)
6001
+ if (usecalllists && bRep.displaylist > 0)
57596002 {
57606003 // System.err.println("end list " + bRep.displaylist + " for " + this);
57616004 display.EndList();
....@@ -5855,6 +6098,7 @@
58556098 if (GetBRep() != null)
58566099 {
58576100 display.NextIndex();
6101
+
58586102 // vertex color conflict : gl.glCallList(list);
58596103 DrawNode(display, root, selected);
58606104 if (this instanceof BezierPatch)
....@@ -6315,6 +6559,11 @@
63156559 // dec 2012
63166560 new Exception().printStackTrace();
63176561 return;
6562
+ }
6563
+
6564
+ if (dontselect)
6565
+ {
6566
+ //bRep.GenerateNormalsMINE();
63186567 }
63196568
63206569 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -7100,20 +7349,23 @@
71007349 }
71017350 }
71027351
7103
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7352
+ static ClickInfo clickInfo = new ClickInfo();
7353
+
7354
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7355
+ Point outPt, Rectangle outRec)
71047356 {
7105
- int hc = info.bounds.x + info.bounds.width / 2;
7106
- int vc = info.bounds.y + info.bounds.height / 2;
7107
- double[][] toscreen = info.toScreen;
7357
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7358
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7359
+ double[][] toscreen = clickInfo.toScreen;
71087360 if (toscreen == null)
71097361 {
7110
- toscreen = new Camera(info.camera.viewCode).toScreen;
7362
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
71117363 }
71127364 cVector vec = in;
71137365 LA.xformPos(in, toscreen, in);
71147366 //System.out.println("Distance = " + info.camera.Distance());
7115
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7116
- vec.y *= 100 * info.camera.SCALE / info.camera.Distance();
7367
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7368
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
71177369 outPt.x = hc + (int) vec.x;
71187370 outPt.y = vc - (int) vec.y;
71197371 outRec.x = outPt.x - 3;
....@@ -7121,15 +7373,18 @@
71217373 outRec.width = outRec.height = 6;
71227374 }
71237375
7124
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7376
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7377
+ )
71257378 {
71267379 Point pt = new Point(0, 0);
71277380 Rectangle rec = new Rectangle();
7128
- calcHotSpot(in, info, pt, rec);
7381
+ calcHotSpot(in, //clickInfo,
7382
+ pt, rec);
71297383 return rec;
71307384 }
71317385
7132
- void drawEditHandles0(ClickInfo info, int level)
7386
+ void drawEditHandles0(//ClickInfo clickInfo,
7387
+ int level)
71337388 {
71347389 if (level == 0)
71357390 {
....@@ -7138,16 +7393,19 @@
71387393 {
71397394 cVector origin = new cVector();
71407395 //LA.xformPos(origin, toParent, origin);
7141
- Rectangle spot = calcHotSpot(origin, info);
7396
+ if (this.clickInfo == null)
7397
+ this.clickInfo = new ClickInfo();
7398
+
7399
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
71427400 Rectangle boundary = new Rectangle();
71437401 boundary.x = spot.x - 30;
71447402 boundary.y = spot.y - 30;
71457403 boundary.width = spot.width + 60;
71467404 boundary.height = spot.height + 60;
7147
- info.g.setColor(Color.red);
7405
+ clickInfo.g.setColor(Color.red);
71487406 int spotw = spot.x + spot.width;
71497407 int spoth = spot.y + spot.height;
7150
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7408
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
71517409 // if (CameraPane.Xmin > spot.x)
71527410 // {
71537411 // CameraPane.Xmin = spot.x;
....@@ -7167,8 +7425,8 @@
71677425 spot.translate(32, 32);
71687426 spotw = spot.x + spot.width;
71697427 spoth = spot.y + spot.height;
7170
- info.g.setColor(Color.cyan);
7171
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7428
+ clickInfo.g.setColor(Color.cyan);
7429
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
71727430 // if (CameraPane.Xmin > spot.x)
71737431 // {
71747432 // CameraPane.Xmin = spot.x;
....@@ -7188,9 +7446,9 @@
71887446 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
71897447 //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
71907448 spot.translate(0, -32);
7191
- info.g.setColor(Color.yellow);
7192
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7193
- info.g.setColor(Color.green);
7449
+ clickInfo.g.setColor(Color.yellow);
7450
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7451
+ clickInfo.g.setColor(Color.green);
71947452 // if (CameraPane.Xmin > spot.x)
71957453 // {
71967454 // CameraPane.Xmin = spot.x;
....@@ -7207,8 +7465,8 @@
72077465 // {
72087466 // CameraPane.Ymax = spoth;
72097467 // }
7210
- info.g.drawArc(boundary.x, boundary.y,
7211
- boundary.width, boundary.height, 0, 360);
7468
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7469
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
72127470 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
72137471 // if (CameraPane.Xmin > boundary.x)
72147472 // {
....@@ -7230,7 +7488,8 @@
72307488 }
72317489 }
72327490
7233
- boolean doEditClick0(ClickInfo info, int level)
7491
+ boolean doEditClick0(//ClickInfo clickInfo,
7492
+ int level)
72347493 {
72357494 if (level == 0)
72367495 {
....@@ -7239,8 +7498,8 @@
72397498
72407499 boolean retval = false;
72417500
7242
- startX = info.x;
7243
- startY = info.y;
7501
+ startX = clickInfo.x;
7502
+ startY = clickInfo.y;
72447503
72457504 hitSomething = -1;
72467505 cVector origin = new cVector();
....@@ -7250,22 +7509,51 @@
72507509 {
72517510 centerPt = new Point(0, 0);
72527511 }
7253
- calcHotSpot(origin, info, centerPt, spot);
7254
- if (spot.contains(info.x, info.y))
7512
+ calcHotSpot(origin, //info,
7513
+ centerPt, spot);
7514
+ if (spot.contains(clickInfo.x, clickInfo.y))
72557515 {
72567516 hitSomething = hitCenter;
72577517 retval = true;
72587518 }
72597519 spot.translate(32, 0);
7260
- if (spot.contains(info.x, info.y))
7520
+ if (spot.contains(clickInfo.x, clickInfo.y))
72617521 {
72627522 hitSomething = hitRotate;
72637523 retval = true;
72647524 }
72657525 spot.translate(0, 32);
7266
- if (spot.contains(info.x, info.y))
7526
+ if (spot.contains(clickInfo.x, clickInfo.y))
72677527 {
72687528 hitSomething = hitScale;
7529
+
7530
+ double scale = 0.005f * clickInfo.camera.Distance();
7531
+ double hScale = (double) (clickInfo.x - centerPt.x) / 32;
7532
+ double sign = 1;
7533
+ if (hScale < 0)
7534
+ {
7535
+ sign = -1;
7536
+ }
7537
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7538
+ if (hScale < 0.01)
7539
+ {
7540
+ //hScale = 0.01;
7541
+ }
7542
+
7543
+ double vScale = (double) (clickInfo.y - centerPt.y) / 32;
7544
+ sign = 1;
7545
+ if (vScale < 0)
7546
+ {
7547
+ sign = -1;
7548
+ }
7549
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7550
+ if (vScale < 0.01)
7551
+ {
7552
+ //vScale = 0.01;
7553
+ }
7554
+
7555
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7556
+
72697557 retval = true;
72707558 }
72717559
....@@ -7275,7 +7563,7 @@
72757563 }
72767564
72777565 //System.out.println("info.modifiers = " + info.modifiers);
7278
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7566
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
72797567 //System.out.println("modified = " + modified);
72807568 //new Exception().printStackTrace();
72817569 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7303,7 +7591,8 @@
73037591 return true;
73047592 }
73057593
7306
- void doEditDrag0(ClickInfo info, boolean opposite)
7594
+ void doEditDrag0(//ClickInfo info,
7595
+ boolean opposite)
73077596 {
73087597 if (hitSomething == 0)
73097598 {
....@@ -7317,7 +7606,7 @@
73177606
73187607 //System.out.println("hitSomething = " + hitSomething);
73197608
7320
- double scale = 0.005f * info.camera.Distance();
7609
+ double scale = 0.005f * clickInfo.camera.Distance();
73217610
73227611 cVector xlate = new cVector();
73237612 //cVector xlate2 = new cVector();
....@@ -7351,8 +7640,8 @@
73517640 toParent[3][i] = xlate.get(i);
73527641 LA.matInvert(toParent, fromParent);
73537642 */
7354
- cVector delta = LA.newVector(0, 0, startY - info.y);
7355
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7643
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7644
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
73567645
73577646 LA.matCopy(startMat, toParent);
73587647 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7361,7 +7650,7 @@
73617650 } else
73627651 {
73637652 //LA.xformDir(delta, info.camera.fromScreen, delta);
7364
- cVector up = new cVector(info.camera.up);
7653
+ cVector up = new cVector(clickInfo.camera.up);
73657654 cVector away = new cVector();
73667655 //cVector right2 = new cVector();
73677656 //LA.vecCross(up, cVector.Z, right);
....@@ -7378,19 +7667,19 @@
73787667 LA.xformDir(up, ClickInfo.matbuffer, up);
73797668 // if (!CameraPane.LOCALTRANSFORM)
73807669 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7381
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7670
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
73827671 // if (!CameraPane.LOCALTRANSFORM)
73837672 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
73847673 //LA.vecCross(up, cVector.Z, right2);
73857674
7386
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7675
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
73877676
73887677 //System.out.println("DELTA0 = " + delta);
73897678 //System.out.println("AWAY = " + info.camera.away);
73907679 //System.out.println("UP = " + info.camera.up);
73917680 if (away.z > 0)
73927681 {
7393
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7682
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
73947683 {
73957684 delta.x = -delta.x;
73967685 } else
....@@ -7405,7 +7694,7 @@
74057694 //System.out.println("DELTA1 = " + delta);
74067695 LA.xformDir(delta, ClickInfo.matbuffer, delta);
74077696 //System.out.println("DELTA2 = " + delta);
7408
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7697
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
74097698 LA.matCopy(startMat, toParent);
74107699 //System.out.println("DELTA3 = " + delta);
74117700 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7415,8 +7704,8 @@
74157704 break;
74167705
74177706 case hitRotate: // rotate
7418
- int dx = info.x - centerPt.x;
7419
- int dy = -(info.y - centerPt.y);
7707
+ int dx = clickInfo.x - centerPt.x;
7708
+ int dy = -(clickInfo.y - centerPt.y);
74207709 double angle = (double) Math.atan2(dx, dy);
74217710 angle = -(1.570796 - angle);
74227711
....@@ -7439,7 +7728,7 @@
74397728 }
74407729 /**/
74417730
7442
- switch (info.pane.RenderCamera().viewCode)
7731
+ switch (clickInfo.pane.RenderCamera().viewCode)
74437732 {
74447733 case 1: // '\001'
74457734 LA.matZRotate(toParent, angle);
....@@ -7466,7 +7755,7 @@
74667755 break;
74677756
74687757 case hitScale: // scale
7469
- double hScale = (double) (info.x - centerPt.x) / 32;
7758
+ double hScale = (double) (clickInfo.x - centerPt.x) / 32;
74707759 double sign = 1;
74717760 if (hScale < 0)
74727761 {
....@@ -7478,7 +7767,7 @@
74787767 //hScale = 0.01;
74797768 }
74807769
7481
- double vScale = (double) (info.y - centerPt.y) / 32;
7770
+ double vScale = (double) (clickInfo.y - centerPt.y) / 32;
74827771 sign = 1;
74837772 if (vScale < 0)
74847773 {
....@@ -7489,6 +7778,7 @@
74897778 {
74907779 //vScale = 0.01;
74917780 }
7781
+
74927782 LA.matCopy(startMat, toParent);
74937783 /**/
74947784 for (int i = 0; i < 3; i++)
....@@ -7498,14 +7788,14 @@
74987788 }
74997789 /**/
75007790
7501
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7791
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
75027792
75037793 if (totalScale < 0.01)
75047794 {
75057795 totalScale = 0.01;
75067796 }
75077797
7508
- switch (info.pane.RenderCamera().viewCode)
7798
+ switch (clickInfo.pane.RenderCamera().viewCode)
75097799 {
75107800 case 3: // '\001'
75117801 if (modified || opposite)
....@@ -7572,7 +7862,7 @@
75727862 } // NEW ...
75737863
75747864
7575
- info.pane.repaint();
7865
+ clickInfo.pane.repaint();
75767866 }
75777867
75787868 boolean overflow = false;
....@@ -7752,6 +8042,10 @@
77528042 editWindow = null;
77538043 } // ?
77548044 }
8045
+ else
8046
+ {
8047
+ //editWindow.closeUI();
8048
+ }
77558049 }
77568050
77578051 boolean root; // patch for edit windows
....@@ -7909,6 +8203,10 @@
79098203 }
79108204
79118205 transient ObjEditor editWindow;
8206
+ transient ObjEditor manipWindow;
8207
+
8208
+ transient boolean pinned;
8209
+
79128210 transient ObjectUI objectUI;
79138211 public static int povDepth = 0;
79148212 private static cVector tbMin = new cVector();