Normand Briere
2019-08-26 6266c8a4b2485b29a7d5bcb217460d7aad3e1c4a
Object3D.java
....@@ -36,8 +36,23 @@
3636 Object3D versionlist[];
3737 int versionindex = -1;
3838
39
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable; // = new java.util.Hashtable<java.util.UUID, Object3D>();
40
+
3941 ScriptNode scriptnode;
4042
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
+
4156 void InitOthers()
4257 {
4358 if (projectedVertices == null || projectedVertices.length <= 2)
....@@ -269,6 +284,50 @@
269284 //
270285 // return null;
271286 // }
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
+ }
272331
273332 void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
274333 {
....@@ -522,11 +581,11 @@
522581 }
523582 }
524583
525
- int memorysize;
584
+ transient int memorysize; // needs to be transient, dunno why
526585
527586 int MemorySize()
528587 {
529
- if (true) // memorysize == 0)
588
+ if (memorysize == 0)
530589 {
531590 try
532591 {
....@@ -641,7 +700,7 @@
641700 {
642701 if (maxcount != 1)
643702 {
644
- new Exception().printStackTrace();
703
+ //new Exception().printStackTrace();
645704 }
646705
647706 toParentMarked = LA.newMatrix();
....@@ -2323,11 +2382,6 @@
23232382
23242383 InitOthers();
23252384
2326
- if (this instanceof Camera)
2327
- {
2328
- material.shift = 90;
2329
- }
2330
-
23312385 material.multiply = multiply;
23322386
23332387 if (multiply)
....@@ -3223,6 +3277,93 @@
32233277 blockloop = false;
32243278 }
32253279
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
+
32263367 void TransformChildren()
32273368 {
32283369 if (toParent != null)
....@@ -3576,15 +3717,47 @@
35763717
35773718 void ClearMaterials()
35783719 {
3720
+ if (blockloop)
3721
+ return;
3722
+
3723
+ blockloop = true;
3724
+
35793725 ClearMaterial();
3580
- for (int i = 0; i < size(); i++)
3726
+ for (int i = 0; i < Size(); i++)
35813727 {
3582
- Object3D child = (Object3D) reserve(i);
3728
+ Object3D child = (Object3D) get(i);
35833729 if (child == null)
35843730 continue;
35853731 child.ClearMaterials();
3586
- release(i);
35873732 }
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;
35883761 }
35893762
35903763 void FlipV(boolean flip)
....@@ -5896,6 +6069,11 @@
58966069 return parent.IsLive();
58976070 }
58986071
6072
+ boolean IsDynamic()
6073
+ {
6074
+ return live && bRep != null;
6075
+ }
6076
+
58996077 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
59006078 {
59016079 Invariants(); // june 2013
....@@ -5956,7 +6134,8 @@
59566134 if (support != null)
59576135 support = support;
59586136
5959
- 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);
59606139 //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
59616140
59626141 //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass.
....@@ -7638,7 +7817,9 @@
76387817
76397818 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
76407819
7641
- if (modified || opposite)
7820
+ // Modified could snap
7821
+ if (//modified ||
7822
+ opposite)
76427823 {
76437824 //assert(false);
76447825 /*
....@@ -7732,7 +7913,7 @@
77327913
77337914 if (modified)
77347915 {
7735
- // Rotate 90 degrees
7916
+ // Rotate 45 degrees
77367917 angle /= (Math.PI / 4);
77377918 angle = Math.floor(angle + 0.5);
77387919 angle *= (Math.PI / 4);
....@@ -7818,7 +7999,7 @@
78187999 case 3: // '\001'
78198000 if (modified || opposite)
78208001 {
7821
- if (modified && opposite)
8002
+ if (modified) // && opposite)
78228003 LA.matScale(toParent, totalScale, totalScale, totalScale);
78238004 else
78248005 //LA.matScale(toParent, 1, hScale, vScale);
....@@ -7834,7 +8015,7 @@
78348015 case 2: // '\002'
78358016 if (modified || opposite)
78368017 {
7837
- if (modified && opposite)
8018
+ if (modified) // && opposite)
78388019 LA.matScale(toParent, totalScale, totalScale, totalScale);
78398020 else
78408021 //LA.matScale(toParent, hScale, 1, vScale);
....@@ -7848,7 +8029,7 @@
78488029 case 1: // '\003'
78498030 if (modified || opposite)
78508031 {
7851
- if (modified && opposite)
8032
+ if (modified) // && opposite)
78528033 LA.matScale(toParent, totalScale, totalScale, totalScale);
78538034 else
78548035 //LA.matScale(toParent, hScale, vScale, 1);
....@@ -8000,10 +8181,10 @@
80008181 } // + super.toString();
80018182 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
80028183
8003
- if (!Globals.ADVANCED)
8004
- return objname;
8184
+// if (!Globals.ADVANCED)
8185
+// return objname;
80058186
8006
- return objname + " " + System.identityHashCode(this);
8187
+ return objname + " " + System.identityHashCode(this); // + GetUUID()
80078188 }
80088189
80098190 public int hashCode()