Normand Briere
2019-08-26 6266c8a4b2485b29a7d5bcb217460d7aad3e1c4a
Object3D.java
....@@ -22,15 +22,37 @@
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 //
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
43
+ int VersionCount()
44
+ {
45
+ int count = 0;
46
+
47
+ for (int i = versionlist.length; --i >= 0;)
48
+ {
49
+ if (versionlist[i] != null)
50
+ count++;
51
+ }
52
+
53
+ return count;
54
+ }
55
+
3456 void InitOthers()
3557 {
3658 if (projectedVertices == null || projectedVertices.length <= 2)
....@@ -170,24 +192,35 @@
170192
171193 void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
172194 {
195
+ Object3D o;
196
+
173197 if (hashtable.containsKey(GetUUID()))
174198 {
175
- Object3D o = hashtable.get(GetUUID());
199
+ o = hashtable.get(GetUUID());
176200
177201 Grafreed.Assert(this.bRep == o.bRep);
178
- if (this.bRep != null)
179
- assert(this.bRep.support == o.transientrep);
202
+ //if (this.bRep != null)
203
+ // assert(this.bRep.support == o.transientrep);
204
+ if (this.support != null)
205
+ assert(this.support.bRep == o.transientrep);
206
+ }
207
+ else
208
+ {
209
+ o = new Object3D("copy of " + this.name);
180210
181
- return;
211
+ hashtable.put(GetUUID(), o);
182212 }
183213
184
- Object3D o = new Object3D("copy of " + this.name);
185
-
186
- hashtable.put(GetUUID(), o);
187
-
188
- for (int i=0; i<Size(); i++)
214
+ if (!blockloop)
189215 {
190
- get(i).ExtractBigData(hashtable);
216
+ blockloop = true;
217
+
218
+ for (int i=0; i<Size(); i++)
219
+ {
220
+ get(i).ExtractBigData(hashtable);
221
+ }
222
+
223
+ blockloop = false;
191224 }
192225
193226 ExtractBigData(o);
....@@ -195,11 +228,26 @@
195228
196229 void ExtractBigData(Object3D o)
197230 {
231
+ if (o.bRep != null)
232
+ Grafreed.Assert(o.bRep == this.bRep);
233
+
198234 o.bRep = this.bRep;
199
- if (this.bRep != null)
235
+// July 2019 if (this.bRep != null)
236
+// {
237
+// o.transientrep = this.bRep.support;
238
+// o.bRep.support = null;
239
+// }
240
+ o.selection = this.selection;
241
+ o.versionlist = this.versionlist;
242
+ o.versionindex = this.versionindex;
243
+
244
+ if (this.support != null)
200245 {
201
- o.transientrep = this.bRep.support;
202
- o.bRep.support = null;
246
+ if (o.transientrep != null)
247
+ Grafreed.Assert(o.transientrep == this.support.bRep);
248
+
249
+ o.transientrep = this.support.bRep;
250
+ this.support.bRep = null;
203251 }
204252
205253 // o.support = this.support;
....@@ -214,19 +262,86 @@
214262 // this.fileparent = null;
215263 }
216264
265
+// Object3D GetObject(java.util.UUID uuid)
266
+// {
267
+// if (this.uuid.equals(uuid))
268
+// return this;
269
+//
270
+// if (blockloop)
271
+// return null;
272
+//
273
+// blockloop = true;
274
+//
275
+// for (int i=0; i<Size(); i++)
276
+// {
277
+// Object3D o = get(i).GetObject(uuid);
278
+//
279
+// if (o != null)
280
+// return o;
281
+// }
282
+//
283
+// blockloop = false;
284
+//
285
+// return null;
286
+// }
287
+
288
+ transient boolean tag;
289
+
290
+ void TagObjects(Object3D o, boolean tag)
291
+ {
292
+ if (blockloop)
293
+ return;
294
+
295
+ o.tag = tag;
296
+
297
+ if (o == this)
298
+ return;
299
+
300
+ blockloop = true;
301
+
302
+ for (int i=0; i<Size(); i++)
303
+ {
304
+ get(i).TagObjects(o, tag);
305
+ }
306
+
307
+ blockloop = false;
308
+ }
309
+
310
+ boolean HasTags()
311
+ {
312
+ if (blockloop)
313
+ return false;
314
+
315
+ blockloop = true;
316
+
317
+ boolean hasTags = false;
318
+
319
+ for (int i=0; i<Size(); i++)
320
+ {
321
+ hasTags |= get(i).tag || get(i).HasTags();
322
+
323
+ if (hasTags)
324
+ break;
325
+ }
326
+
327
+ blockloop = false;
328
+
329
+ return hasTags;
330
+ }
331
+
217332 void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
218333 {
219334 if (!hashtable.containsKey(GetUUID()))
220335 return;
221336
337
+ Object3D o = hashtable.get(GetUUID());
338
+
339
+ RestoreBigData(o);
340
+
222341 if (blockloop)
223342 return;
224343
225344 blockloop = true;
226
-
227
- Object3D o = hashtable.get(GetUUID());
228
-
229
- RestoreBigData(o);
230345
231346 //hashtable.remove(GetUUID());
232347
....@@ -241,8 +356,17 @@
241356 void RestoreBigData(Object3D o)
242357 {
243358 this.bRep = o.bRep;
244
- if (this.bRep != null)
245
- this.bRep.support = o.transientrep;
359
+ if (this.support != null && o.transientrep != null)
360
+ {
361
+ this.support.bRep = o.transientrep;
362
+ }
363
+
364
+ this.selection = o.selection;
365
+
366
+ this.versionlist = o.versionlist;
367
+ this.versionindex = o.versionindex;
368
+// July 2019 if (this.bRep != null)
369
+// this.bRep.support = o.transientrep;
246370 // this.support = o.support;
247371 // this.fileparent = o.fileparent;
248372 }
....@@ -388,6 +512,7 @@
388512 }
389513
390514 boolean live = false;
515
+ transient boolean keepdontselect;
391516 boolean dontselect = false;
392517 boolean hide = false;
393518 boolean link2master = false; // performs reset support/master at each frame
....@@ -456,11 +581,11 @@
456581 }
457582 }
458583
459
- int memorysize;
584
+ transient int memorysize; // needs to be transient, dunno why
460585
461586 int MemorySize()
462587 {
463
- if (true) // memorysize == 0)
588
+ if (memorysize == 0)
464589 {
465590 try
466591 {
....@@ -575,7 +700,7 @@
575700 {
576701 if (maxcount != 1)
577702 {
578
- new Exception().printStackTrace();
703
+ //new Exception().printStackTrace();
579704 }
580705
581706 toParentMarked = LA.newMatrix();
....@@ -972,6 +1097,9 @@
9721097
9731098 if (material == null || material.multiply)
9741099 return true;
1100
+
1101
+ if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
1102
+ return false;
9751103
9761104 // Transparent objects are dynamic because we have to sort the triangles.
9771105 return material.opacity > 0.99;
....@@ -1374,6 +1502,7 @@
13741502 toParent = LA.newMatrix();
13751503 fromParent = LA.newMatrix();
13761504 }
1505
+
13771506 LA.matCopy(other.toParent, toParent);
13781507 LA.matCopy(other.fromParent, fromParent);
13791508
....@@ -2253,11 +2382,6 @@
22532382
22542383 InitOthers();
22552384
2256
- if (this instanceof Camera)
2257
- {
2258
- material.shift = 90;
2259
- }
2260
-
22612385 material.multiply = multiply;
22622386
22632387 if (multiply)
....@@ -2398,6 +2522,11 @@
23982522 else
23992523 {
24002524 //((ObjEditor)editWindow).SetupUI2(null);
2525
+ if (objectUI != null)
2526
+ ((ObjEditor)objectUI).pinButton.setSelected(pinned);
2527
+ else
2528
+ //new Exception().printStackTrace();
2529
+ System.err.println("objectUI is null");
24012530 }
24022531 }
24032532
....@@ -2527,7 +2656,8 @@
25272656 private static final int editSelf = 1;
25282657 private static final int editChild = 2;
25292658
2530
- void drawEditHandles(ClickInfo info, int level)
2659
+ void drawEditHandles(//ClickInfo info,
2660
+ int level)
25312661 {
25322662 if (level == 0)
25332663 {
....@@ -2535,7 +2665,8 @@
25352665 return;
25362666
25372667 Object3D selectee;
2538
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2668
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2669
+ level + 1))
25392670 {
25402671 selectee = (Object3D) e.nextElement();
25412672 }
....@@ -2543,19 +2674,22 @@
25432674 } else
25442675 {
25452676 //super.
2546
- drawEditHandles0(info, level + 1);
2677
+ drawEditHandles0(//info,
2678
+ level + 1);
25472679 }
25482680 }
25492681
2550
- boolean doEditClick(ClickInfo info, int level)
2682
+ boolean doEditClick(//ClickInfo info,
2683
+ int level)
25512684 {
25522685 doSomething = 0;
25532686 if (level == 0)
25542687 {
2555
- return doParentClick(info);
2688
+ return doParentClick(); //info);
25562689 }
25572690 if (//super.
2558
- doEditClick0(info, level))
2691
+ doEditClick0(//info,
2692
+ level))
25592693 {
25602694 doSomething = 1;
25612695 return true;
....@@ -2565,7 +2699,7 @@
25652699 }
25662700 }
25672701
2568
- boolean doParentClick(ClickInfo info)
2702
+ boolean doParentClick() //ClickInfo info)
25692703 {
25702704 if (selection == null)
25712705 {
....@@ -2578,7 +2712,8 @@
25782712 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
25792713 {
25802714 Object3D selectee = (Object3D) e.nextElement();
2581
- if (selectee.doEditClick(info, 1))
2715
+ if (selectee.doEditClick(//info,
2716
+ 1))
25822717 {
25832718 childToDrag = selectee;
25842719 doSomething = 2;
....@@ -2590,13 +2725,15 @@
25902725 return retval;
25912726 }
25922727
2593
- void doEditDrag(ClickInfo info, boolean opposite)
2728
+ void doEditDrag(//ClickInfo clickInfo,
2729
+ boolean opposite)
25942730 {
25952731 switch (doSomething)
25962732 {
25972733 case 1: // '\001'
25982734 //super.
2599
- doEditDrag0(info, opposite);
2735
+ doEditDrag0(//clickInfo,
2736
+ opposite);
26002737 break;
26012738
26022739 case 2: // '\002'
....@@ -2609,11 +2746,13 @@
26092746 {
26102747 //sel.hitSomething = childToDrag.hitSomething;
26112748 //childToDrag.doEditDrag(info);
2612
- sel.doEditDrag(info, opposite);
2749
+ sel.doEditDrag(//clickInfo,
2750
+ opposite);
26132751 } else
26142752 {
26152753 //super.
2616
- doEditDrag0(info, opposite);
2754
+ doEditDrag0(//clickInfo,
2755
+ opposite);
26172756 }
26182757 }
26192758 break;
....@@ -2631,6 +2770,9 @@
26312770 {
26322771 deselectAll();
26332772 }
2773
+
2774
+ new Exception().printStackTrace();
2775
+
26342776 ClickInfo newInfo = new ClickInfo();
26352777 newInfo.flags = info.flags;
26362778 newInfo.bounds = info.bounds;
....@@ -3078,7 +3220,7 @@
30783220 {
30793221 if (bRep != null)
30803222 {
3081
- bRep.GenerateNormalsMINE();
3223
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
30823224 Touch();
30833225 }
30843226 }
....@@ -3135,6 +3277,93 @@
31353277 blockloop = false;
31363278 }
31373279
3280
+ public void ResetTransform(int mask)
3281
+ {
3282
+ Object3D obj = this;
3283
+
3284
+ if (mask == -1)
3285
+ {
3286
+ if (obj instanceof Camera) // jan 2014
3287
+ {
3288
+ LA.matIdentity(obj.toParent);
3289
+ LA.matIdentity(obj.fromParent);
3290
+ }
3291
+ else
3292
+ {
3293
+ obj.toParent = null; // jan 2014 LA.matIdentity(obj.toParent);
3294
+ obj.fromParent = null; // LA.matIdentity(obj.fromParent);
3295
+ }
3296
+ return;
3297
+ }
3298
+
3299
+ if ((mask&2) != 0) // Scale/rotation
3300
+ {
3301
+ obj.toParent[0][0] = obj.toParent[1][1] = obj.toParent[2][2] = 1;
3302
+ obj.toParent[0][1] = obj.toParent[1][0] = obj.toParent[2][0] = 0;
3303
+ obj.toParent[0][2] = obj.toParent[1][2] = obj.toParent[2][1] = 0;
3304
+ obj.fromParent[0][0] = obj.fromParent[1][1] = obj.fromParent[2][2] = 1;
3305
+ obj.fromParent[0][1] = obj.fromParent[1][0] = obj.fromParent[2][0] = 0;
3306
+ obj.fromParent[0][2] = obj.fromParent[1][2] = obj.fromParent[2][1] = 0;
3307
+ }
3308
+ if ((mask&1) != 0) // Translation
3309
+ {
3310
+ if (obj.toParent != null)
3311
+ {
3312
+ obj.toParent[3][0] = obj.toParent[3][1] = obj.toParent[3][2] = 0;
3313
+ obj.fromParent[3][0] = obj.fromParent[3][1] = obj.fromParent[3][2] = 0;
3314
+ }
3315
+ }
3316
+ }
3317
+
3318
+ public void TextureRatioTransform(int axis)
3319
+ {
3320
+ cTexture tex = GetTextures();
3321
+
3322
+ com.sun.opengl.util.texture.TextureData texturedata = null;
3323
+
3324
+ try
3325
+ {
3326
+ texturedata = Globals.theRenderer.GetTextureData(tex, false, texres);
3327
+ }
3328
+ catch (Exception e)
3329
+ {
3330
+ System.err.println("FAIL TextureRatio: " + this);
3331
+ }
3332
+
3333
+ LA.matIdentity(Object3D.mat);
3334
+ Object3D.mat[axis][axis] = (double)texturedata.getWidth() / texturedata.getHeight();
3335
+
3336
+ if (toParent == null)
3337
+ {
3338
+ toParent = LA.newMatrix();
3339
+ fromParent = LA.newMatrix();
3340
+ }
3341
+
3342
+ ResetTransform(2);
3343
+
3344
+ LA.matConcat(Object3D.mat, fromParent, fromParent);
3345
+ LA.matInvert(fromParent, toParent);
3346
+ }
3347
+
3348
+ void TextureRatio(int axis)
3349
+ {
3350
+ if (blockloop)
3351
+ return;
3352
+
3353
+ blockloop = true;
3354
+
3355
+ TextureRatioTransform(axis);
3356
+
3357
+ for (int i=Size(); --i>=0;)
3358
+ {
3359
+ Object3D v = get(i);
3360
+
3361
+ v.TextureRatio(axis);
3362
+ }
3363
+
3364
+ blockloop = false;
3365
+ }
3366
+
31383367 void TransformChildren()
31393368 {
31403369 if (toParent != null)
....@@ -3488,15 +3717,47 @@
34883717
34893718 void ClearMaterials()
34903719 {
3720
+ if (blockloop)
3721
+ return;
3722
+
3723
+ blockloop = true;
3724
+
34913725 ClearMaterial();
3492
- for (int i = 0; i < size(); i++)
3726
+ for (int i = 0; i < Size(); i++)
34933727 {
3494
- Object3D child = (Object3D) reserve(i);
3728
+ Object3D child = (Object3D) get(i);
34953729 if (child == null)
34963730 continue;
34973731 child.ClearMaterials();
3498
- release(i);
34993732 }
3733
+
3734
+ blockloop = false;
3735
+ }
3736
+
3737
+ void ClearVersionList()
3738
+ {
3739
+ this.versionlist = null;
3740
+ this.versionindex = -1;
3741
+ this.versiontable = null;
3742
+ }
3743
+
3744
+ void ClearVersions()
3745
+ {
3746
+ if (blockloop)
3747
+ return;
3748
+
3749
+ blockloop = true;
3750
+
3751
+ ClearVersionList();
3752
+ for (int i = 0; i < Size(); i++)
3753
+ {
3754
+ Object3D child = (Object3D) get(i);
3755
+ if (child == null)
3756
+ continue;
3757
+ child.ClearVersions();
3758
+ }
3759
+
3760
+ blockloop = false;
35003761 }
35013762
35023763 void FlipV(boolean flip)
....@@ -5043,6 +5304,7 @@
50435304
50445305 if (child == null)
50455306 continue;
5307
+
50465308 if (child.HasTransparency() && child.size() != 0)
50475309 {
50485310 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -5380,6 +5642,51 @@
53805642 blockloop = false;
53815643 }
53825644
5645
+ void ResetSelectable()
5646
+ {
5647
+ if (blockloop)
5648
+ return;
5649
+
5650
+ blockloop = true;
5651
+
5652
+ keepdontselect = dontselect;
5653
+ dontselect = true;
5654
+
5655
+ Object3D child;
5656
+ int nb = Size();
5657
+ for (int i = 0; i < nb; i++)
5658
+ {
5659
+ child = (Object3D) get(i);
5660
+ if (child == null)
5661
+ continue;
5662
+ child.ResetSelectable();
5663
+ }
5664
+
5665
+ blockloop = false;
5666
+ }
5667
+
5668
+ void RestoreSelectable()
5669
+ {
5670
+ if (blockloop)
5671
+ return;
5672
+
5673
+ blockloop = true;
5674
+
5675
+ dontselect = keepdontselect;
5676
+
5677
+ Object3D child;
5678
+ int nb = Size();
5679
+ for (int i = 0; i < nb; i++)
5680
+ {
5681
+ child = (Object3D) get(i);
5682
+ if (child == null)
5683
+ continue;
5684
+ child.RestoreSelectable();
5685
+ }
5686
+
5687
+ blockloop = false;
5688
+ }
5689
+
53835690 boolean IsSelected()
53845691 {
53855692 if (parent == null)
....@@ -5440,6 +5747,11 @@
54405747 if (fullname == null)
54415748 return "";
54425749
5750
+ if (fullname.pigment != null)
5751
+ {
5752
+ return fullname.pigment;
5753
+ }
5754
+
54435755 // System.out.println("Fullname = " + fullname);
54445756
54455757 // Does not work on Windows due to C:
....@@ -5452,7 +5764,7 @@
54525764
54535765 if (split.length == 0)
54545766 {
5455
- return "";
5767
+ return fullname.pigment = "";
54565768 }
54575769
54585770 if (split.length <= 2)
....@@ -5460,22 +5772,27 @@
54605772 if (fullname.name.endsWith(":"))
54615773 {
54625774 // Windows
5463
- return fullname.name.substring(0, fullname.name.length()-1);
5775
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
54645776 }
54655777
5466
- return split[0];
5778
+ return fullname.pigment = split[0];
54675779 }
54685780
54695781 // Windows
54705782 assert(split.length == 4);
54715783
5472
- return split[0] + ":" + split[1];
5784
+ return fullname.pigment = split[0] + ":" + split[1];
54735785 }
54745786
54755787 static String GetBump(cTexture fullname)
54765788 {
54775789 if (fullname == null)
54785790 return "";
5791
+
5792
+ if (fullname.bump != null)
5793
+ {
5794
+ return fullname.bump;
5795
+ }
54795796
54805797 // System.out.println("Fullname = " + fullname);
54815798 // Does not work on Windows due to C:
....@@ -5487,12 +5804,12 @@
54875804
54885805 if (split.length == 0)
54895806 {
5490
- return "";
5807
+ return fullname.bump = "";
54915808 }
54925809
54935810 if (split.length == 1)
54945811 {
5495
- return "";
5812
+ return fullname.bump = "";
54965813 }
54975814
54985815 if (split.length == 2)
....@@ -5500,16 +5817,16 @@
55005817 if (fullname.name.endsWith(":"))
55015818 {
55025819 // Windows
5503
- return "";
5820
+ return fullname.bump = "";
55045821 }
55055822
5506
- return split[1];
5823
+ return fullname.bump = split[1];
55075824 }
55085825
55095826 // Windows
55105827 assert(split.length == 4);
55115828
5512
- return split[2] + ":" + split[3];
5829
+ return fullname.bump = split[2] + ":" + split[3];
55135830 }
55145831
55155832 String GetPigmentTexture()
....@@ -5592,6 +5909,9 @@
55925909 texname = "";
55935910
55945911 GetTextures().name = texname + ":" + GetBump(GetTextures());
5912
+
5913
+ GetTextures().pigment = null;
5914
+
55955915 Touch();
55965916 }
55975917
....@@ -5665,6 +5985,8 @@
56655985
56665986 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
56675987
5988
+ GetTextures().bump = null;
5989
+
56685990 Touch();
56695991 }
56705992
....@@ -5685,6 +6007,38 @@
56856007
56866008 blockloop = true;
56876009 child.ResetBumpTexture();
6010
+ blockloop = false;
6011
+ }
6012
+ }
6013
+
6014
+ void EmbedTextures(boolean embed)
6015
+ {
6016
+ if (blockloop)
6017
+ return;
6018
+
6019
+ //if (GetTextures() != null)
6020
+ if (embed)
6021
+ CameraPane.EmbedTextures(GetTextures());
6022
+ else
6023
+ {
6024
+ GetTextures().pigmentdata = null;
6025
+ GetTextures().bumpdata = null;
6026
+ GetTextures().pw = 0;
6027
+ GetTextures().ph = 0;
6028
+ GetTextures().bw = 0;
6029
+ GetTextures().bh = 0;
6030
+ }
6031
+
6032
+ int nb = Size();
6033
+ for (int i = 0; i < nb; i++)
6034
+ {
6035
+ Object3D child = (Object3D) get(i);
6036
+
6037
+ if (child == null)
6038
+ continue;
6039
+
6040
+ blockloop = true;
6041
+ child.EmbedTextures(embed);
56886042 blockloop = false;
56896043 }
56906044 }
....@@ -5713,6 +6067,11 @@
57136067 return false;
57146068
57156069 return parent.IsLive();
6070
+ }
6071
+
6072
+ boolean IsDynamic()
6073
+ {
6074
+ return live && bRep != null;
57166075 }
57176076
57186077 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
....@@ -5775,8 +6134,11 @@
57756134 if (support != null)
57766135 support = support;
57776136
5778
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5779
- boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
6137
+ boolean usecalllists = !IsDynamic() &&
6138
+ IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
6139
+ //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
6140
+
6141
+ //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass.
57806142
57816143 if (!usecalllists && bRep != null && bRep.displaylist > 0)
57826144 {
....@@ -5786,8 +6148,9 @@
57866148 // usecalllists &= !(parent instanceof RandomNode);
57876149 // usecalllists = false;
57886150
5789
- if (GetBRep() != null)
5790
- usecalllists = usecalllists;
6151
+ if (display.DrawMode() == display.SHADOW)
6152
+ //GetBRep() != null)
6153
+ usecalllists = !!usecalllists;
57916154 //System.out.println("draw " + this);
57926155 //new Exception().printStackTrace();
57936156
....@@ -5797,7 +6160,7 @@
57976160
57986161 if (!selectmode && //display.DrawMode() != display.SELECTION &&
57996162 //(touched || (bRep != null && bRep.displaylist <= 0)))
5800
- (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched || (bRep != null && bRep.displaylist <= 0)))
6163
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
58016164 {
58026165 Globals.lighttouched = true;
58036166 } // all panes...
....@@ -5809,7 +6172,7 @@
58096172 if (!(this instanceof Composite))
58106173 touched = false;
58116174 //if (displaylist == -1 && usecalllists)
5812
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
6175
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
58136176 {
58146177 bRep.displaylist = display.GenList();
58156178 assert(bRep.displaylist != 0);
....@@ -5820,7 +6183,7 @@
58206183
58216184 //System.out.println("\tnew list " + list);
58226185 //gl.glDrawBuffer(gl.GL_NONE);
5823
- if (usecalllists)
6186
+ if (usecalllists && bRep.displaylist > 0)
58246187 {
58256188 // System.err.println("new list " + bRep.displaylist + " for " + this);
58266189 display.NewList(bRep.displaylist);
....@@ -5829,7 +6192,7 @@
58296192 CallList(display, root, selected, blocked);
58306193
58316194 // compiled = true;
5832
- if (usecalllists)
6195
+ if (usecalllists && bRep.displaylist > 0)
58336196 {
58346197 // System.err.println("end list " + bRep.displaylist + " for " + this);
58356198 display.EndList();
....@@ -5929,6 +6292,7 @@
59296292 if (GetBRep() != null)
59306293 {
59316294 display.NextIndex();
6295
+
59326296 // vertex color conflict : gl.glCallList(list);
59336297 DrawNode(display, root, selected);
59346298 if (this instanceof BezierPatch)
....@@ -7179,20 +7543,23 @@
71797543 }
71807544 }
71817545
7182
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7546
+ static ClickInfo clickInfo = new ClickInfo();
7547
+
7548
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7549
+ Point outPt, Rectangle outRec)
71837550 {
7184
- int hc = info.bounds.x + info.bounds.width / 2;
7185
- int vc = info.bounds.y + info.bounds.height / 2;
7186
- double[][] toscreen = info.toScreen;
7551
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7552
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7553
+ double[][] toscreen = clickInfo.toScreen;
71877554 if (toscreen == null)
71887555 {
7189
- toscreen = new Camera(info.camera.viewCode).toScreen;
7556
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
71907557 }
71917558 cVector vec = in;
71927559 LA.xformPos(in, toscreen, in);
71937560 //System.out.println("Distance = " + info.camera.Distance());
7194
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7195
- vec.y *= 100 * info.camera.SCALE / info.camera.Distance();
7561
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7562
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
71967563 outPt.x = hc + (int) vec.x;
71977564 outPt.y = vc - (int) vec.y;
71987565 outRec.x = outPt.x - 3;
....@@ -7200,15 +7567,18 @@
72007567 outRec.width = outRec.height = 6;
72017568 }
72027569
7203
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7570
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7571
+ )
72047572 {
72057573 Point pt = new Point(0, 0);
72067574 Rectangle rec = new Rectangle();
7207
- calcHotSpot(in, info, pt, rec);
7575
+ calcHotSpot(in, //clickInfo,
7576
+ pt, rec);
72087577 return rec;
72097578 }
72107579
7211
- void drawEditHandles0(ClickInfo info, int level)
7580
+ void drawEditHandles0(//ClickInfo clickInfo,
7581
+ int level)
72127582 {
72137583 if (level == 0)
72147584 {
....@@ -7217,16 +7587,19 @@
72177587 {
72187588 cVector origin = new cVector();
72197589 //LA.xformPos(origin, toParent, origin);
7220
- Rectangle spot = calcHotSpot(origin, info);
7590
+ if (this.clickInfo == null)
7591
+ this.clickInfo = new ClickInfo();
7592
+
7593
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
72217594 Rectangle boundary = new Rectangle();
72227595 boundary.x = spot.x - 30;
72237596 boundary.y = spot.y - 30;
72247597 boundary.width = spot.width + 60;
72257598 boundary.height = spot.height + 60;
7226
- info.g.setColor(Color.red);
7599
+ clickInfo.g.setColor(Color.white);
72277600 int spotw = spot.x + spot.width;
72287601 int spoth = spot.y + spot.height;
7229
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7602
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72307603 // if (CameraPane.Xmin > spot.x)
72317604 // {
72327605 // CameraPane.Xmin = spot.x;
....@@ -7243,11 +7616,6 @@
72437616 // {
72447617 // CameraPane.Ymax = spoth;
72457618 // }
7246
- spot.translate(32, 32);
7247
- spotw = spot.x + spot.width;
7248
- spoth = spot.y + spot.height;
7249
- info.g.setColor(Color.cyan);
7250
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72517619 // if (CameraPane.Xmin > spot.x)
72527620 // {
72537621 // CameraPane.Xmin = spot.x;
....@@ -7266,10 +7634,15 @@
72667634 // }
72677635 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
72687636 //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7269
- spot.translate(0, -32);
7270
- info.g.setColor(Color.yellow);
7271
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7272
- info.g.setColor(Color.green);
7637
+ spot.translate(32, 0);
7638
+ clickInfo.g.setColor(Color.yellow);
7639
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7640
+
7641
+ spot.translate(32, 64);
7642
+ spotw = spot.x + spot.width;
7643
+ spoth = spot.y + spot.height;
7644
+ clickInfo.g.setColor(Color.cyan);
7645
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72737646 // if (CameraPane.Xmin > spot.x)
72747647 // {
72757648 // CameraPane.Xmin = spot.x;
....@@ -7286,8 +7659,9 @@
72867659 // {
72877660 // CameraPane.Ymax = spoth;
72887661 // }
7289
- info.g.drawArc(boundary.x, boundary.y,
7290
- boundary.width, boundary.height, 0, 360);
7662
+ clickInfo.g.setColor(Color.green);
7663
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7664
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
72917665 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
72927666 // if (CameraPane.Xmin > boundary.x)
72937667 // {
....@@ -7309,7 +7683,8 @@
73097683 }
73107684 }
73117685
7312
- boolean doEditClick0(ClickInfo info, int level)
7686
+ boolean doEditClick0(//ClickInfo clickInfo,
7687
+ int level)
73137688 {
73147689 if (level == 0)
73157690 {
....@@ -7318,8 +7693,8 @@
73187693
73197694 boolean retval = false;
73207695
7321
- startX = info.x;
7322
- startY = info.y;
7696
+ startX = clickInfo.x;
7697
+ startY = clickInfo.y;
73237698
73247699 hitSomething = -1;
73257700 cVector origin = new cVector();
....@@ -7329,22 +7704,53 @@
73297704 {
73307705 centerPt = new Point(0, 0);
73317706 }
7332
- calcHotSpot(origin, info, centerPt, spot);
7333
- if (spot.contains(info.x, info.y))
7707
+ calcHotSpot(origin, //info,
7708
+ centerPt, spot);
7709
+ if (spot.contains(clickInfo.x, clickInfo.y))
73347710 {
73357711 hitSomething = hitCenter;
73367712 retval = true;
73377713 }
73387714 spot.translate(32, 0);
7339
- if (spot.contains(info.x, info.y))
7715
+ if (spot.contains(clickInfo.x, clickInfo.y))
73407716 {
73417717 hitSomething = hitRotate;
73427718 retval = true;
73437719 }
73447720 spot.translate(0, 32);
7345
- if (spot.contains(info.x, info.y))
7721
+ spot.translate(32, 0);
7722
+ spot.translate(0, 32);
7723
+ if (spot.contains(clickInfo.x, clickInfo.y))
73467724 {
73477725 hitSomething = hitScale;
7726
+
7727
+ double scale = 0.005f * clickInfo.camera.Distance();
7728
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
7729
+ double sign = 1;
7730
+ if (hScale < 0)
7731
+ {
7732
+ sign = -1;
7733
+ }
7734
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7735
+ if (hScale < 0.01)
7736
+ {
7737
+ //hScale = 0.01;
7738
+ }
7739
+
7740
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
7741
+ sign = 1;
7742
+ if (vScale < 0)
7743
+ {
7744
+ sign = -1;
7745
+ }
7746
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7747
+ if (vScale < 0.01)
7748
+ {
7749
+ //vScale = 0.01;
7750
+ }
7751
+
7752
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7753
+
73487754 retval = true;
73497755 }
73507756
....@@ -7354,7 +7760,7 @@
73547760 }
73557761
73567762 //System.out.println("info.modifiers = " + info.modifiers);
7357
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7763
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
73587764 //System.out.println("modified = " + modified);
73597765 //new Exception().printStackTrace();
73607766 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7382,7 +7788,8 @@
73827788 return true;
73837789 }
73847790
7385
- void doEditDrag0(ClickInfo info, boolean opposite)
7791
+ void doEditDrag0(//ClickInfo info,
7792
+ boolean opposite)
73867793 {
73877794 if (hitSomething == 0)
73887795 {
....@@ -7396,7 +7803,7 @@
73967803
73977804 //System.out.println("hitSomething = " + hitSomething);
73987805
7399
- double scale = 0.005f * info.camera.Distance();
7806
+ double scale = 0.005f * clickInfo.camera.Distance();
74007807
74017808 cVector xlate = new cVector();
74027809 //cVector xlate2 = new cVector();
....@@ -7410,7 +7817,9 @@
74107817
74117818 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
74127819
7413
- if (modified || opposite)
7820
+ // Modified could snap
7821
+ if (//modified ||
7822
+ opposite)
74147823 {
74157824 //assert(false);
74167825 /*
....@@ -7430,8 +7839,8 @@
74307839 toParent[3][i] = xlate.get(i);
74317840 LA.matInvert(toParent, fromParent);
74327841 */
7433
- cVector delta = LA.newVector(0, 0, startY - info.y);
7434
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7842
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7843
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
74357844
74367845 LA.matCopy(startMat, toParent);
74377846 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7440,7 +7849,7 @@
74407849 } else
74417850 {
74427851 //LA.xformDir(delta, info.camera.fromScreen, delta);
7443
- cVector up = new cVector(info.camera.up);
7852
+ cVector up = new cVector(clickInfo.camera.up);
74447853 cVector away = new cVector();
74457854 //cVector right2 = new cVector();
74467855 //LA.vecCross(up, cVector.Z, right);
....@@ -7457,19 +7866,19 @@
74577866 LA.xformDir(up, ClickInfo.matbuffer, up);
74587867 // if (!CameraPane.LOCALTRANSFORM)
74597868 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7460
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7869
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
74617870 // if (!CameraPane.LOCALTRANSFORM)
74627871 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
74637872 //LA.vecCross(up, cVector.Z, right2);
74647873
7465
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7874
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
74667875
74677876 //System.out.println("DELTA0 = " + delta);
74687877 //System.out.println("AWAY = " + info.camera.away);
74697878 //System.out.println("UP = " + info.camera.up);
74707879 if (away.z > 0)
74717880 {
7472
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7881
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
74737882 {
74747883 delta.x = -delta.x;
74757884 } else
....@@ -7484,7 +7893,7 @@
74847893 //System.out.println("DELTA1 = " + delta);
74857894 LA.xformDir(delta, ClickInfo.matbuffer, delta);
74867895 //System.out.println("DELTA2 = " + delta);
7487
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7896
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
74887897 LA.matCopy(startMat, toParent);
74897898 //System.out.println("DELTA3 = " + delta);
74907899 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7494,8 +7903,8 @@
74947903 break;
74957904
74967905 case hitRotate: // rotate
7497
- int dx = info.x - centerPt.x;
7498
- int dy = -(info.y - centerPt.y);
7906
+ int dx = clickInfo.x - centerPt.x;
7907
+ int dy = -(clickInfo.y - centerPt.y);
74997908 double angle = (double) Math.atan2(dx, dy);
75007909 angle = -(1.570796 - angle);
75017910
....@@ -7504,7 +7913,7 @@
75047913
75057914 if (modified)
75067915 {
7507
- // Rotate 90 degrees
7916
+ // Rotate 45 degrees
75087917 angle /= (Math.PI / 4);
75097918 angle = Math.floor(angle + 0.5);
75107919 angle *= (Math.PI / 4);
....@@ -7518,7 +7927,7 @@
75187927 }
75197928 /**/
75207929
7521
- switch (info.pane.RenderCamera().viewCode)
7930
+ switch (clickInfo.pane.RenderCamera().viewCode)
75227931 {
75237932 case 1: // '\001'
75247933 LA.matZRotate(toParent, angle);
....@@ -7545,7 +7954,7 @@
75457954 break;
75467955
75477956 case hitScale: // scale
7548
- double hScale = (double) (info.x - centerPt.x) / 32;
7957
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
75497958 double sign = 1;
75507959 if (hScale < 0)
75517960 {
....@@ -7557,7 +7966,7 @@
75577966 //hScale = 0.01;
75587967 }
75597968
7560
- double vScale = (double) (info.y - centerPt.y) / 32;
7969
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
75617970 sign = 1;
75627971 if (vScale < 0)
75637972 {
....@@ -7568,6 +7977,7 @@
75687977 {
75697978 //vScale = 0.01;
75707979 }
7980
+
75717981 LA.matCopy(startMat, toParent);
75727982 /**/
75737983 for (int i = 0; i < 3; i++)
....@@ -7577,33 +7987,39 @@
75777987 }
75787988 /**/
75797989
7580
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7990
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
75817991
75827992 if (totalScale < 0.01)
75837993 {
75847994 totalScale = 0.01;
75857995 }
75867996
7587
- switch (info.pane.RenderCamera().viewCode)
7997
+ switch (clickInfo.pane.RenderCamera().viewCode)
75887998 {
75897999 case 3: // '\001'
75908000 if (modified || opposite)
75918001 {
8002
+ if (modified) // && opposite)
8003
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
8004
+ else
75928005 //LA.matScale(toParent, 1, hScale, vScale);
7593
- LA.matScale(toParent, totalScale, 1, 1);
8006
+ LA.matScale(toParent, totalScale, 1, 1);
75948007 } // vScale, 1);
75958008 else
75968009 {
75978010 // EXCEPTION!
7598
- LA.matScale(toParent, totalScale, totalScale, totalScale);
8011
+ LA.matScale(toParent, 1, totalScale, totalScale);
75998012 } // vScale, 1);
76008013 break;
76018014
76028015 case 2: // '\002'
76038016 if (modified || opposite)
76048017 {
7605
- //LA.matScale(toParent, hScale, 1, vScale);
7606
- LA.matScale(toParent, 1, totalScale, 1);
8018
+ if (modified) // && opposite)
8019
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
8020
+ else
8021
+ //LA.matScale(toParent, hScale, 1, vScale);
8022
+ LA.matScale(toParent, 1, totalScale, 1);
76078023 } else
76088024 {
76098025 LA.matScale(toParent, totalScale, 1, totalScale);
....@@ -7613,8 +8029,11 @@
76138029 case 1: // '\003'
76148030 if (modified || opposite)
76158031 {
7616
- //LA.matScale(toParent, hScale, vScale, 1);
7617
- LA.matScale(toParent, 1, 1, totalScale);
8032
+ if (modified) // && opposite)
8033
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
8034
+ else
8035
+ //LA.matScale(toParent, hScale, vScale, 1);
8036
+ LA.matScale(toParent, 1, 1, totalScale);
76188037 } else
76198038 {
76208039 LA.matScale(toParent, totalScale, totalScale, 1);
....@@ -7651,7 +8070,7 @@
76518070 } // NEW ...
76528071
76538072
7654
- info.pane.repaint();
8073
+ clickInfo.pane.repaint();
76558074 }
76568075
76578076 boolean overflow = false;
....@@ -7762,10 +8181,10 @@
77628181 } // + super.toString();
77638182 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
77648183
7765
- if (!Globals.ADVANCED)
7766
- return objname;
8184
+// if (!Globals.ADVANCED)
8185
+// return objname;
77678186
7768
- return objname + " " + System.identityHashCode(this);
8187
+ return objname + " " + System.identityHashCode(this); // + GetUUID()
77698188 }
77708189
77718190 public int hashCode()