Normand Briere
2019-09-04 c8bb659043bfa0ccf9436d7cbbc49255b4c82402
Object3D.java
....@@ -33,12 +33,84 @@
3333 String skyboxname;
3434 String skyboxext;
3535
36
- Object3D versionlist[];
36
+ Object3D[] versionlist;
3737 int versionindex = -1;
3838
3939 java.util.Hashtable<java.util.UUID, Object3D> versiontable; // = new java.util.Hashtable<java.util.UUID, Object3D>();
4040
4141 ScriptNode scriptnode;
42
+
43
+ void deepCopyNode(Object3D other)
44
+ {
45
+ other.skyboxname = skyboxname;
46
+ other.skyboxext = skyboxext;
47
+
48
+ if (toParent != null)
49
+ {
50
+ other.toParent = LA.newMatrix();
51
+ other.fromParent = LA.newMatrix();
52
+ LA.matCopy(toParent, other.toParent);
53
+ LA.matCopy(fromParent, other.fromParent);
54
+ if (toParentMarked != null)
55
+ {
56
+ other.toParentMarked = LA.newMatrix();
57
+ other.fromParentMarked = LA.newMatrix();
58
+ LA.matCopy(toParentMarked, other.toParentMarked);
59
+ LA.matCopy(fromParentMarked, other.fromParentMarked);
60
+ }
61
+ }
62
+ else
63
+ {
64
+ if (other.toParent == null)
65
+// assert(other.toParent == null);
66
+// new Exception().printStackTrace();
67
+ System.err.println("null parent: " + other);
68
+ }
69
+
70
+ /*
71
+ double ident[][] = LA.newMatrix();
72
+ if (bRep == null)
73
+ other.bRep = null;
74
+ else
75
+ other.bRep = new BoundaryRep(bRep, ident);
76
+ */
77
+ // Really new...
78
+ //other.editWindow = null;
79
+ if (name == null)
80
+ other.name = null;
81
+ else
82
+ other.name = new String(name);
83
+
84
+ if (material != null)
85
+ {
86
+ other.material = new cMaterial(material);
87
+ } else
88
+ {
89
+ other.material = null;
90
+ }
91
+
92
+ other.GetTextures().name = GetTextures().name;
93
+
94
+ CopyExtraMaterial(other);
95
+
96
+ other.touched = touched;
97
+ other.softtouched = softtouched;
98
+
99
+ other.random = random;
100
+ other.link2master = link2master;
101
+ other.transformcount = transformcount;
102
+ other.marked = marked;
103
+ other.skip = skip;
104
+ other.count = count;
105
+ other.flipV = flipV;
106
+ other.live = live;
107
+ other.rewind = rewind;
108
+ other.hide = hide;
109
+ other.texres = texres;
110
+ other.speedup = speedup;
111
+ other.height = height;
112
+ other.depth = depth;
113
+ }
42114
43115 int VersionCount()
44116 {
....@@ -190,8 +262,39 @@
190262 }
191263 }
192264
265
+ boolean HasBigData()
266
+ {
267
+ if (blockloop)
268
+ return false;
269
+
270
+ if (bRep != null)
271
+ {
272
+ return true;
273
+ }
274
+
275
+ blockloop = true;
276
+
277
+ for (int i = 0; i < Size(); i++)
278
+ {
279
+ Object3D child = (Object3D) get(i);
280
+ if (child == null)
281
+ continue;
282
+ if (child.HasBigData())
283
+ {
284
+ blockloop = false;
285
+ return true;
286
+ }
287
+ }
288
+
289
+ blockloop = false;
290
+ return false;
291
+ }
292
+
193293 void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
194294 {
295
+ if (blockloop)
296
+ return;
297
+
195298 Object3D o;
196299
197300 boolean isnew = false;
....@@ -215,7 +318,7 @@
215318 hashtable.put(GetUUID(), o);
216319 }
217320
218
- if (!blockloop)
321
+ //if (!blockloop)
219322 {
220323 blockloop = true;
221324
....@@ -227,7 +330,7 @@
227330 blockloop = false;
228331 }
229332
230
- if (isnew)
333
+ //if (isnew)
231334 ExtractBigData(o);
232335 }
233336
....@@ -338,15 +441,15 @@
338441
339442 void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
340443 {
444
+ if (blockloop)
445
+ return;
446
+
341447 if (!hashtable.containsKey(GetUUID()))
342448 return;
343449
344450 Object3D o = hashtable.get(GetUUID());
345451
346452 RestoreBigData(o);
347
-
348
- if (blockloop)
349
- return;
350453
351454 blockloop = true;
352455
....@@ -363,6 +466,7 @@
363466 void RestoreBigData(Object3D o)
364467 {
365468 //System.err.println("RestoreBigData : " + this + " <-- " + o);
469
+ Grafreed.Assert(this.bRep == null);
366470
367471 this.bRep = o.bRep;
368472 if (this.support != null && o.transientrep != null)
....@@ -1199,8 +1303,10 @@
11991303
12001304 // will share the geometry
12011305 assert (!(this instanceof Composite));
1202
- return deepCopy(); // Never called for Composite
1203
-
1306
+
1307
+ Object3D obj = deepCopy(); // Never called for Composite
1308
+ obj.count = 2;
1309
+ return obj;
12041310 }
12051311
12061312 boolean HasLoops()
....@@ -1278,78 +1384,16 @@
12781384 return;
12791385
12801386 blockloop = true;
1387
+
1388
+ other.parent = parent;
1389
+
12811390 //System.out.println("COPY " + this + " to " + other);
12821391 //new Exception().printStackTrace();
1392
+ deepCopyNode(other);
12831393
1284
- other.parent = parent;
1285
- if (toParent != null)
1286
- {
1287
- other.toParent = LA.newMatrix();
1288
- other.fromParent = LA.newMatrix();
1289
- LA.matCopy(toParent, other.toParent);
1290
- LA.matCopy(fromParent, other.fromParent);
1291
- if (toParentMarked != null)
1292
- {
1293
- other.toParentMarked = LA.newMatrix();
1294
- other.fromParentMarked = LA.newMatrix();
1295
- LA.matCopy(toParentMarked, other.toParentMarked);
1296
- LA.matCopy(fromParentMarked, other.fromParentMarked);
1297
- }
1298
- }
1299
- else
1300
- {
1301
- if (other.toParent == null)
1302
-// assert(other.toParent == null);
1303
-// new Exception().printStackTrace();
1304
- System.err.println("null parent: " + other);
1305
- }
1306
- /*
1307
- double ident[][] = LA.newMatrix();
1308
- if (bRep == null)
1309
- other.bRep = null;
1310
- else
1311
- other.bRep = new BoundaryRep(bRep, ident);
1312
- */
1313
- // Really new...
13141394 other.bRep = bRep; // Share the geometry
13151395
13161396 other.support = support; // Share the support
1317
-
1318
- //other.editWindow = null;
1319
- if (name == null)
1320
- other.name = null;
1321
- else
1322
- other.name = new String(name);
1323
-
1324
- if (material != null)
1325
- {
1326
- other.material = new cMaterial(material);
1327
- } else
1328
- {
1329
- other.material = null;
1330
- }
1331
-
1332
- other.GetTextures().name = GetTextures().name;
1333
-
1334
- CopyExtraMaterial(other);
1335
-
1336
- other.touched = touched;
1337
- other.softtouched = softtouched;
1338
-
1339
- other.random = random;
1340
- other.link2master = link2master;
1341
- other.transformcount = transformcount;
1342
- other.marked = marked;
1343
- other.skip = skip;
1344
- other.count = count;
1345
- other.flipV = flipV;
1346
- other.live = live;
1347
- other.rewind = rewind;
1348
- other.hide = hide;
1349
- other.texres = texres;
1350
- other.speedup = speedup;
1351
- other.height = height;
1352
- other.depth = depth;
13531397
13541398 // aout 2013 if (/*displaylist != -1 &&*/other.displaylist != displaylist)
13551399 // {
....@@ -1405,17 +1449,24 @@
14051449 if ((mask & GEOMETRY) != 0)
14061450 {
14071451 if (bRep != null)
1408
- bRep.overwriteThis(other.bRep==null?other.transientrep:other.bRep);
1409
- else
1410
- assert(other.bRep == null);
1411
-
1412
- if (bRep != null)
14131452 {
1453
+ bRep.overwriteThis(other.bRep==null?other.transientrep:other.bRep);
14141454 CameraPane.RemoveList(bRep.displaylist);
14151455 bRep.displaylist = 0; // june 2013 -1;
14161456 }
14171457 else
1418
- bRep = bRep;
1458
+ {
1459
+ //assert(other.bRep == null);
1460
+ bRep = other.bRep;
1461
+ }
1462
+
1463
+// if (bRep != null)
1464
+// {
1465
+// CameraPane.RemoveList(bRep.displaylist);
1466
+// bRep.displaylist = 0; // june 2013 -1;
1467
+// }
1468
+// else
1469
+// bRep = bRep;
14191470 }
14201471
14211472 /* Use a MASK = GEO/MAT
....@@ -3324,6 +3375,18 @@
33243375 }
33253376 }
33263377
3378
+ public void Scale(int scale)
3379
+ {
3380
+ Object3D obj = this;
3381
+
3382
+ obj.toParent[0][0] = obj.toParent[1][1] = obj.toParent[2][2] = scale;
3383
+ obj.toParent[0][1] = obj.toParent[1][0] = obj.toParent[2][0] = 0;
3384
+ obj.toParent[0][2] = obj.toParent[1][2] = obj.toParent[2][1] = 0;
3385
+ obj.fromParent[0][0] = obj.fromParent[1][1] = obj.fromParent[2][2] = 1/scale;
3386
+ obj.fromParent[0][1] = obj.fromParent[1][0] = obj.fromParent[2][0] = 0;
3387
+ obj.fromParent[0][2] = obj.fromParent[1][2] = obj.fromParent[2][1] = 0;
3388
+ }
3389
+
33273390 public void TextureRatioTransform(int axis)
33283391 {
33293392 cTexture tex = GetTextures();
....@@ -4216,9 +4279,9 @@
42164279 max = new cVector();
42174280 }
42184281
4219
- for (int i = 0; i<size(); i++)
4282
+ for (int i = 0; i<Size(); i++)
42204283 {
4221
- Object3D child = (Object3D) reserve(i);
4284
+ Object3D child = (Object3D) get(i); //reserve(i);
42224285 if (child == null)
42234286 continue;
42244287
....@@ -4237,14 +4300,14 @@
42374300 if (child.hide && !(child instanceof Merge) || child.skip)
42384301 //if (child.hide)
42394302 {
4240
- release(i);
4303
+ //release(i);
42414304 continue;
42424305 }
42434306
42444307 blockloop = true;
42454308 child.getBounds(min, max, true); // xform);
42464309 blockloop = false;
4247
- release(i);
4310
+ //release(i);
42484311
42494312 MinMax(minima, maxima);
42504313 }
....@@ -6313,6 +6376,20 @@
63136376 {
63146377 drawSelf(display, root, selected, blocked);
63156378 }
6379
+
6380
+// if (!(this instanceof Composite))
6381
+// {
6382
+// for (int i = 0; i < size(); i++)
6383
+// {
6384
+// Object3D child = (Object3D) reserve(i);
6385
+// if (child == null)
6386
+// continue;
6387
+//
6388
+// child.draw(display, root, selected, blocked);
6389
+//
6390
+// release(i);
6391
+// }
6392
+// }
63166393 } else
63176394 {
63186395 /*
....@@ -6351,7 +6428,7 @@
63516428 }
63526429 catch (Exception e)
63536430 {
6354
- System.err.println("FAILED: " + this);
6431
+ // System.err.println("FAILED: " + this);
63556432 failedPigment = true;
63566433 }
63576434
....@@ -6381,6 +6458,20 @@
63816458 assert(bRep.displaylist != 0);
63826459 display.CallList(bRep.displaylist);
63836460 // june 2013 drawSelf(display, root, selected);
6461
+ }
6462
+ }
6463
+
6464
+ assert (!(this instanceof Composite));
6465
+ {
6466
+ for (int i = 0; i < size(); i++)
6467
+ {
6468
+ Object3D child = (Object3D) reserve(i);
6469
+ if (child == null)
6470
+ continue;
6471
+
6472
+ child.draw(display, root, selected, blocked);
6473
+
6474
+ release(i);
63846475 }
63856476 }
63866477 }
....@@ -6435,16 +6526,17 @@
64356526
64366527 void CallList(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
64376528 {
6438
- if (GetBRep() == null)
6439
- {
6440
- drawSelf(display, root, selected, blocked);
6441
- } else
6529
+ if (GetBRep() != null)
64426530 {
64436531 DrawNode(display, root, selected);
64446532 if (this instanceof BezierPatch)
64456533 {
64466534 //drawSelf(display, root, selected);
64476535 }
6536
+ }
6537
+ else
6538
+ {
6539
+ drawSelf(display, root, selected, blocked);
64486540 }
64496541 }
64506542
....@@ -8193,7 +8285,7 @@
81938285 // if (!Globals.ADVANCED)
81948286 // return objname;
81958287
8196
- return objname + " " + System.identityHashCode(this); // + GetUUID()
8288
+ return objname; // + " " + System.identityHashCode(this); // + GetUUID()
81978289 }
81988290
81998291 public int hashCode()