Normand Briere
2019-07-23 de4f66e0239a736bce24e09c9a0b49b5bb92d84b
Object3D.java
....@@ -24,11 +24,14 @@
2424
2525 private UUID uuid = UUID.randomUUID();
2626
27
- // TEMPORARY for mocap undo
28
- mocap.reader.BVHReader.BVHResult bvh;
29
- Object3D skeleton;
27
+ // TEMPORARY for mocap undo. No need to be transient.
28
+ mocap.reader.BVHReader.BVHResult savebvh;
29
+ Object3D saveskeleton;
3030 //
3131
32
+ byte[] versions[];
33
+ int versionindex = -1;
34
+
3235 ScriptNode scriptnode;
3336
3437 void InitOthers()
....@@ -170,24 +173,35 @@
170173
171174 void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
172175 {
176
+ Object3D o;
177
+
173178 if (hashtable.containsKey(GetUUID()))
174179 {
175
- Object3D o = hashtable.get(GetUUID());
180
+ o = hashtable.get(GetUUID());
176181
177182 Grafreed.Assert(this.bRep == o.bRep);
178
- if (this.bRep != null)
179
- assert(this.bRep.support == o.transientrep);
183
+ //if (this.bRep != null)
184
+ // assert(this.bRep.support == o.transientrep);
185
+ if (this.support != null)
186
+ assert(this.support.bRep == o.transientrep);
187
+ }
188
+ else
189
+ {
190
+ o = new Object3D("copy of " + this.name);
180191
181
- return;
192
+ hashtable.put(GetUUID(), o);
182193 }
183194
184
- Object3D o = new Object3D();
185
-
186
- hashtable.put(GetUUID(), o);
187
-
188
- for (int i=0; i<Size(); i++)
195
+ if (!blockloop)
189196 {
190
- get(i).ExtractBigData(hashtable);
197
+ blockloop = true;
198
+
199
+ for (int i=0; i<Size(); i++)
200
+ {
201
+ get(i).ExtractBigData(hashtable);
202
+ }
203
+
204
+ blockloop = false;
191205 }
192206
193207 ExtractBigData(o);
....@@ -195,11 +209,26 @@
195209
196210 void ExtractBigData(Object3D o)
197211 {
212
+ if (o.bRep != null)
213
+ Grafreed.Assert(o.bRep == this.bRep);
214
+
198215 o.bRep = this.bRep;
199
- if (this.bRep != null)
216
+// July 2019 if (this.bRep != null)
217
+// {
218
+// o.transientrep = this.bRep.support;
219
+// o.bRep.support = null;
220
+// }
221
+ o.selection = this.selection;
222
+ o.versions = this.versions;
223
+ o.versionindex = this.versionindex;
224
+
225
+ if (this.support != null)
200226 {
201
- o.transientrep = this.bRep.support;
202
- o.bRep.support = null;
227
+ if (o.transientrep != null)
228
+ Grafreed.Assert(o.transientrep == this.support.bRep);
229
+
230
+ o.transientrep = this.support.bRep;
231
+ this.support.bRep = null;
203232 }
204233
205234 // o.support = this.support;
....@@ -223,19 +252,35 @@
223252
224253 RestoreBigData(o);
225254
226
- hashtable.remove(GetUUID());
255
+ if (blockloop)
256
+ return;
257
+
258
+ blockloop = true;
259
+
260
+ //hashtable.remove(GetUUID());
227261
228262 for (int i=0; i<Size(); i++)
229263 {
230264 get(i).RestoreBigData(hashtable);
231265 }
266
+
267
+ blockloop = false;
232268 }
233269
234270 void RestoreBigData(Object3D o)
235271 {
236272 this.bRep = o.bRep;
237
- if (this.bRep != null)
238
- this.bRep.support = o.transientrep;
273
+ if (this.support != null && o.transientrep != null)
274
+ {
275
+ this.support.bRep = o.transientrep;
276
+ }
277
+
278
+ this.selection = o.selection;
279
+
280
+ this.versions = o.versions;
281
+ this.versionindex = o.versionindex;
282
+// July 2019 if (this.bRep != null)
283
+// this.bRep.support = o.transientrep;
239284 // this.support = o.support;
240285 // this.fileparent = o.fileparent;
241286 }
....@@ -381,6 +426,7 @@
381426 }
382427
383428 boolean live = false;
429
+ transient boolean keepdontselect;
384430 boolean dontselect = false;
385431 boolean hide = false;
386432 boolean link2master = false; // performs reset support/master at each frame
....@@ -881,7 +927,7 @@
881927
882928 if (marked && Globals.isLIVE() && live &&
883929 //TEMP21aug2018
884
- (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
930
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
885931 currentframe != Globals.framecount)
886932 {
887933 currentframe = Globals.framecount;
....@@ -966,6 +1012,7 @@
9661012 if (material == null || material.multiply)
9671013 return true;
9681014
1015
+ // Transparent objects are dynamic because we have to sort the triangles.
9691016 return material.opacity > 0.99;
9701017 }
9711018
....@@ -1366,6 +1413,7 @@
13661413 toParent = LA.newMatrix();
13671414 fromParent = LA.newMatrix();
13681415 }
1416
+
13691417 LA.matCopy(other.toParent, toParent);
13701418 LA.matCopy(other.fromParent, fromParent);
13711419
....@@ -2387,6 +2435,10 @@
23872435 }
23882436 */
23892437 }
2438
+ else
2439
+ {
2440
+ //((ObjEditor)editWindow).SetupUI2(null);
2441
+ }
23902442 }
23912443
23922444 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2428,6 +2480,14 @@
24282480 {
24292481 editWindow.refreshContents();
24302482 }
2483
+ else
2484
+ {
2485
+ if (manipWindow != null)
2486
+ {
2487
+ manipWindow.refreshContents();
2488
+ }
2489
+ }
2490
+
24312491 //if (parent != null)
24322492 //parent.refreshEditWindow();
24332493 }
....@@ -3058,7 +3118,7 @@
30583118 {
30593119 if (bRep != null)
30603120 {
3061
- bRep.GenerateNormalsMINE();
3121
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
30623122 Touch();
30633123 }
30643124 }
....@@ -4958,6 +5018,14 @@
49585018 }
49595019 }
49605020
5021
+ ObjEditor GetWindow()
5022
+ {
5023
+ if (editWindow != null)
5024
+ return editWindow;
5025
+
5026
+ return manipWindow;
5027
+ }
5028
+
49615029 cTreePath Select(int indexcount, boolean deselect)
49625030 {
49635031 if (hide || dontselect)
....@@ -4994,10 +5062,11 @@
49945062 if (leaf != null)
49955063 {
49965064 cTreePath tp = new cTreePath(this, leaf);
4997
- if (editWindow != null)
5065
+ ObjEditor window = GetWindow();
5066
+ if (window != null)
49985067 {
49995068 //System.out.println("editWindow = " + editWindow + " vs " + this);
5000
- editWindow.Select(tp, deselect, true);
5069
+ window.Select(tp, deselect, true);
50015070 }
50025071
50035072 return tp;
....@@ -5014,6 +5083,7 @@
50145083
50155084 if (child == null)
50165085 continue;
5086
+
50175087 if (child.HasTransparency() && child.size() != 0)
50185088 {
50195089 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -5023,9 +5093,10 @@
50235093 if (leaf != null)
50245094 {
50255095 cTreePath tp = new cTreePath(this, leaf);
5026
- if (editWindow != null)
5096
+ ObjEditor window = GetWindow();
5097
+ if (window != null)
50275098 {
5028
- editWindow.Select(tp, deselect, true);
5099
+ window.Select(tp, deselect, true);
50295100 }
50305101
50315102 return tp;
....@@ -5350,6 +5421,51 @@
53505421 blockloop = false;
53515422 }
53525423
5424
+ void ResetSelectable()
5425
+ {
5426
+ if (blockloop)
5427
+ return;
5428
+
5429
+ blockloop = true;
5430
+
5431
+ keepdontselect = dontselect;
5432
+ dontselect = true;
5433
+
5434
+ Object3D child;
5435
+ int nb = Size();
5436
+ for (int i = 0; i < nb; i++)
5437
+ {
5438
+ child = (Object3D) get(i);
5439
+ if (child == null)
5440
+ continue;
5441
+ child.ResetSelectable();
5442
+ }
5443
+
5444
+ blockloop = false;
5445
+ }
5446
+
5447
+ void RestoreSelectable()
5448
+ {
5449
+ if (blockloop)
5450
+ return;
5451
+
5452
+ blockloop = true;
5453
+
5454
+ dontselect = keepdontselect;
5455
+
5456
+ Object3D child;
5457
+ int nb = Size();
5458
+ for (int i = 0; i < nb; i++)
5459
+ {
5460
+ child = (Object3D) get(i);
5461
+ if (child == null)
5462
+ continue;
5463
+ child.RestoreSelectable();
5464
+ }
5465
+
5466
+ blockloop = false;
5467
+ }
5468
+
53535469 boolean IsSelected()
53545470 {
53555471 if (parent == null)
....@@ -5659,6 +5775,38 @@
56595775 }
56605776 }
56615777
5778
+ void EmbedTextures(boolean embed)
5779
+ {
5780
+ if (blockloop)
5781
+ return;
5782
+
5783
+ //if (GetTextures() != null)
5784
+ if (embed)
5785
+ CameraPane.EmbedTextures(GetTextures());
5786
+ else
5787
+ {
5788
+ GetTextures().pigmentdata = null;
5789
+ GetTextures().bumpdata = null;
5790
+ GetTextures().pw = 0;
5791
+ GetTextures().ph = 0;
5792
+ GetTextures().bw = 0;
5793
+ GetTextures().bh = 0;
5794
+ }
5795
+
5796
+ int nb = Size();
5797
+ for (int i = 0; i < nb; i++)
5798
+ {
5799
+ Object3D child = (Object3D) get(i);
5800
+
5801
+ if (child == null)
5802
+ continue;
5803
+
5804
+ blockloop = true;
5805
+ child.EmbedTextures(embed);
5806
+ blockloop = false;
5807
+ }
5808
+ }
5809
+
56625810 void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
56635811 {
56645812 Draw(display, root, selected, blocked);
....@@ -5746,7 +5894,7 @@
57465894 support = support;
57475895
57485896 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5749
- boolean usecalllists = IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5897
+ boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
57505898
57515899 if (!usecalllists && bRep != null && bRep.displaylist > 0)
57525900 {
....@@ -5767,7 +5915,7 @@
57675915
57685916 if (!selectmode && //display.DrawMode() != display.SELECTION &&
57695917 //(touched || (bRep != null && bRep.displaylist <= 0)))
5770
- (Globals.isLIVE() || touched && (bRep != null && bRep.displaylist <= 0)))
5918
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
57715919 {
57725920 Globals.lighttouched = true;
57735921 } // all panes...
....@@ -5899,6 +6047,7 @@
58996047 if (GetBRep() != null)
59006048 {
59016049 display.NextIndex();
6050
+
59026051 // vertex color conflict : gl.glCallList(list);
59036052 DrawNode(display, root, selected);
59046053 if (this instanceof BezierPatch)
....@@ -6359,6 +6508,11 @@
63596508 // dec 2012
63606509 new Exception().printStackTrace();
63616510 return;
6511
+ }
6512
+
6513
+ if (dontselect)
6514
+ {
6515
+ //bRep.GenerateNormalsMINE();
63626516 }
63636517
63646518 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -7251,8 +7405,8 @@
72517405 // {
72527406 // CameraPane.Ymax = spoth;
72537407 // }
7254
- info.g.drawArc(boundary.x, boundary.y,
7255
- boundary.width, boundary.height, 0, 360);
7408
+ info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY,
7409
+ (int)(boundary.width * info.W), (int)(boundary.height * info.W), 0, 360);
72567410 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
72577411 // if (CameraPane.Xmin > boundary.x)
72587412 // {
....@@ -7796,6 +7950,10 @@
77967950 editWindow = null;
77977951 } // ?
77987952 }
7953
+ else
7954
+ {
7955
+ //editWindow.closeUI();
7956
+ }
77997957 }
78007958
78017959 boolean root; // patch for edit windows
....@@ -7953,6 +8111,10 @@
79538111 }
79548112
79558113 transient ObjEditor editWindow;
8114
+ transient ObjEditor manipWindow;
8115
+
8116
+ transient boolean pinned;
8117
+
79568118 transient ObjectUI objectUI;
79578119 public static int povDepth = 0;
79588120 private static cVector tbMin = new cVector();