Normand Briere
2019-06-23 8088590686a45e71278f9a52bb9cc37943dc0c37
Object3D.java
....@@ -24,6 +24,11 @@
2424
2525 private UUID uuid = UUID.randomUUID();
2626
27
+ // TEMPORARY for mocap undo
28
+ mocap.reader.BVHReader.BVHResult bvh;
29
+ Object3D skeleton;
30
+ //
31
+
2732 ScriptNode scriptnode;
2833
2934 void InitOthers()
....@@ -104,125 +109,136 @@
104109
105110 // transient boolean reduced; // for morph reduction
106111
107
-transient com.bulletphysics.linearmath.Transform cache; // for fast merge
108
-transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
112
+ transient com.bulletphysics.linearmath.Transform cache; // for fast merge
113
+ transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
109114
110
-transient Object3D transientsupport; // for cloning
111
-transient boolean transientlink2master;
115
+ transient Object3D transientsupport; // for cloning
116
+ transient boolean transientlink2master;
112117
113
-void SaveSupports()
114
-{
115
- if (blockloop)
116
- return;
117
-
118
- transientsupport = support;
119
- transientlink2master = link2master;
120
-
121
- support = null;
122
- link2master = false;
123
-
124
- if (bRep != null)
118
+ void SaveSupports()
125119 {
126
- bRep.SaveSupports();
120
+ if (blockloop)
121
+ return;
122
+
123
+ transientsupport = support;
124
+ transientlink2master = link2master;
125
+
126
+ support = null;
127
+ link2master = false;
128
+
129
+ if (bRep != null)
130
+ {
131
+ bRep.SaveSupports();
132
+ }
133
+
134
+ for (int i = 0; i < Size(); i++)
135
+ {
136
+ Object3D child = (Object3D) get(i);
137
+ if (child == null)
138
+ continue;
139
+ blockloop = true;
140
+ child.SaveSupports();
141
+ blockloop = false;
142
+ }
127143 }
128
-
129
- for (int i = 0; i < Size(); i++)
130
- {
131
- Object3D child = (Object3D) get(i);
132
- if (child == null)
133
- continue;
134
- blockloop = true;
135
- child.SaveSupports();
136
- blockloop = false;
137
- }
138
-}
139144
140
-void RestoreSupports()
141
-{
142
- if (blockloop)
143
- return;
145
+ void RestoreSupports()
146
+ {
147
+ if (blockloop)
148
+ return;
144149
145
- support = transientsupport;
146
- link2master = transientlink2master;
147
- transientsupport = null;
148
- transientlink2master = false;
149
-
150
- if (bRep != null)
151
- {
152
- bRep.RestoreSupports();
153
- }
154
-
155
- for (int i = 0; i < Size(); i++)
156
- {
157
- Object3D child = (Object3D) get(i);
158
- if (child == null)
159
- continue;
160
- blockloop = true;
161
- child.RestoreSupports();
162
- blockloop = false;
163
- }
164
-}
150
+ support = transientsupport;
151
+ link2master = transientlink2master;
152
+ transientsupport = null;
153
+ transientlink2master = false;
165154
166
-void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
167
-{
168
- if (hashtable.containsKey(GetUUID()))
155
+ if (bRep != null)
156
+ {
157
+ bRep.RestoreSupports();
158
+ }
159
+
160
+ for (int i = 0; i < Size(); i++)
161
+ {
162
+ Object3D child = (Object3D) get(i);
163
+ if (child == null)
164
+ continue;
165
+ blockloop = true;
166
+ child.RestoreSupports();
167
+ blockloop = false;
168
+ }
169
+ }
170
+
171
+ void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
169172 {
173
+ if (hashtable.containsKey(GetUUID()))
174
+ {
175
+ Object3D o = hashtable.get(GetUUID());
176
+
177
+ Grafreed.Assert(this.bRep == o.bRep);
178
+ if (this.bRep != null)
179
+ assert(this.bRep.support == o.transientrep);
180
+
181
+ return;
182
+ }
183
+
184
+ Object3D o = new Object3D();
185
+
186
+ hashtable.put(GetUUID(), o);
187
+
188
+ for (int i=0; i<Size(); i++)
189
+ {
190
+ get(i).ExtractBigData(hashtable);
191
+ }
192
+
193
+ ExtractBigData(o);
194
+ }
195
+
196
+ void ExtractBigData(Object3D o)
197
+ {
198
+ o.bRep = this.bRep;
199
+ if (this.bRep != null)
200
+ {
201
+ o.transientrep = this.bRep.support;
202
+ o.bRep.support = null;
203
+ }
204
+
205
+ // o.support = this.support;
206
+ // o.fileparent = this.fileparent;
207
+ // if (this.bRep != null)
208
+ // o.bRep = this.bRep.support;
209
+
210
+ this.bRep = null;
211
+ // if (this.bRep != null)
212
+ // this.bRep.support = null;
213
+ // this.support = null;
214
+ // this.fileparent = null;
215
+ }
216
+
217
+ void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
218
+ {
219
+ if (!hashtable.containsKey(GetUUID()))
220
+ return;
221
+
170222 Object3D o = hashtable.get(GetUUID());
171223
172
- assert(this.bRep == o.bRep);
173
- if (this.bRep != null)
174
- assert(this.bRep.support == o.transientrep);
175
-
176
- return;
177
- }
178
-
179
- Object3D o = new Object3D();
180
- o.bRep = this.bRep;
181
- if (this.bRep != null)
182
- {
183
- o.transientrep = this.bRep.support;
184
- o.bRep.support = null;
185
- }
186
-
187
-// o.support = this.support;
188
-// o.fileparent = this.fileparent;
189
-// if (this.bRep != null)
190
-// o.bRep = this.bRep.support;
191
-
192
- hashtable.put(GetUUID(), o);
193
-
194
- this.bRep = null;
195
-// if (this.bRep != null)
196
-// this.bRep.support = null;
197
-// this.support = null;
198
-// this.fileparent = null;
199
-
200
- for (int i=0; i<Size(); i++)
201
- {
202
- get(i).ExtractBigData(hashtable);
203
- }
204
-}
224
+ RestoreBigData(o);
205225
206
-void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
207
-{
208
- if (!hashtable.containsKey(GetUUID()))
209
- return;
210
-
211
- Object3D o = hashtable.get(GetUUID());
212
-
213
- this.bRep = o.bRep;
214
- if (this.bRep != null)
215
- this.bRep.support = o.transientrep;
216
-// this.support = o.support;
217
-// this.fileparent = o.fileparent;
218
-
219
- hashtable.remove(GetUUID());
220
-
221
- for (int i=0; i<Size(); i++)
222
- {
223
- get(i).RestoreBigData(hashtable);
226
+ hashtable.remove(GetUUID());
227
+
228
+ for (int i=0; i<Size(); i++)
229
+ {
230
+ get(i).RestoreBigData(hashtable);
231
+ }
224232 }
225
-}
233
+
234
+ void RestoreBigData(Object3D o)
235
+ {
236
+ this.bRep = o.bRep;
237
+ if (this.bRep != null)
238
+ this.bRep.support = o.transientrep;
239
+ // this.support = o.support;
240
+ // this.fileparent = o.fileparent;
241
+ }
226242
227243 // MOCAP SUPPORT
228244 double tx,ty,tz,rx,ry,rz;
....@@ -547,12 +563,14 @@
547563 toParent = LA.newMatrix();
548564 fromParent = LA.newMatrix();
549565 }
566
+
550567 if (toParentMarked == null)
551568 {
552569 if (maxcount != 1)
553570 {
554571 new Exception().printStackTrace();
555572 }
573
+
556574 toParentMarked = LA.newMatrix();
557575 fromParentMarked = LA.newMatrix();
558576 }
....@@ -875,7 +893,8 @@
875893
876894 boolean changedir = random && Math.random() < 0.01; // && !link2master;
877895
878
- if (transformcount*factor > maxcount || (step == 1 && changedir))
896
+ if (transformcount*factor >= maxcount && (rewind || random) ||
897
+ (step == 1 && changedir))
879898 {
880899 countdown = 1;
881900 delay = speedup?8:1;
....@@ -2368,6 +2387,10 @@
23682387 }
23692388 */
23702389 }
2390
+ else
2391
+ {
2392
+ //((ObjEditor)editWindow).SetupUI2(null);
2393
+ }
23712394 }
23722395
23732396 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2693,6 +2716,18 @@
26932716 //Touch();
26942717 }
26952718
2719
+ void GenNormalsMeshS()
2720
+ {
2721
+ selection.GenNormalsMesh();
2722
+// for (int i=0; i<selection.size(); i++)
2723
+// {
2724
+// Object3D selectee = (Object3D) selection.elementAt(i);
2725
+// selectee.GenNormals(crease);
2726
+// }
2727
+
2728
+ //Touch();
2729
+ }
2730
+
26962731 void ClearColorsS()
26972732 {
26982733 selection.ClearColors();
....@@ -2824,6 +2859,24 @@
28242859 if (child == null)
28252860 continue;
28262861 child.GenNormals(crease);
2862
+// Children().release(i);
2863
+ }
2864
+ blockloop = false;
2865
+ }
2866
+
2867
+ void GenNormalsMesh()
2868
+ {
2869
+ if (blockloop)
2870
+ return;
2871
+
2872
+ blockloop = true;
2873
+ GenNormalsMesh0();
2874
+ for (int i = 0; i < Children().Size(); i++)
2875
+ {
2876
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2877
+ if (child == null)
2878
+ continue;
2879
+ child.GenNormalsMesh();
28272880 // Children().release(i);
28282881 }
28292882 blockloop = false;
....@@ -2992,6 +3045,15 @@
29923045 if (bRep != null)
29933046 {
29943047 bRep.GenerateNormals(crease);
3048
+ Touch();
3049
+ }
3050
+ }
3051
+
3052
+ void GenNormalsMesh0()
3053
+ {
3054
+ if (bRep != null)
3055
+ {
3056
+ bRep.GenerateNormalsMesh();
29953057 Touch();
29963058 }
29973059 }
....@@ -3446,7 +3508,8 @@
34463508 if (blockloop)
34473509 return;
34483510
3449
- if (marked || (bRep != null && material != null)) // borderline...
3511
+ if (//marked || // does not make sense
3512
+ (bRep != null || material != null)) // borderline...
34503513 live = h;
34513514
34523515 for (int i = 0; i < Size(); i++)
....@@ -3467,7 +3530,8 @@
34673530 return;
34683531
34693532 //if (bRep != null)
3470
- if (marked || (bRep != null && material != null)) // borderline...
3533
+ if (//marked || // does not make sense
3534
+ (bRep != null || material != null)) // borderline...
34713535 link2master = h;
34723536
34733537 for (int i = 0; i < Size(); i++)
....@@ -3487,7 +3551,8 @@
34873551 if (blockloop)
34883552 return;
34893553
3490
- if (marked || (bRep != null && material != null)) // borderline...
3554
+ if (//marked || // does not make sense
3555
+ (bRep != null || material != null)) // borderline...
34913556 hide = h;
34923557
34933558 for (int i = 0; i < Size(); i++)
....@@ -3507,7 +3572,7 @@
35073572 if (blockloop)
35083573 return;
35093574
3510
- if (bRep != null && material != null) // borderline...
3575
+ if (bRep != null || material != null) // borderline...
35113576 marked = h;
35123577
35133578 for (int i = 0; i < Size(); i++)
....@@ -3517,6 +3582,46 @@
35173582 continue;
35183583 blockloop = true;
35193584 child.MarkLeaves(h);
3585
+ blockloop = false;
3586
+ // release(i);
3587
+ }
3588
+ }
3589
+
3590
+ void RewindLeaves(boolean h)
3591
+ {
3592
+ if (blockloop)
3593
+ return;
3594
+
3595
+ if (bRep != null || material != null) // borderline...
3596
+ rewind = h;
3597
+
3598
+ for (int i = 0; i < Size(); i++)
3599
+ {
3600
+ Object3D child = (Object3D) get(i); // reserve(i);
3601
+ if (child == null)
3602
+ continue;
3603
+ blockloop = true;
3604
+ child.RewindLeaves(h);
3605
+ blockloop = false;
3606
+ // release(i);
3607
+ }
3608
+ }
3609
+
3610
+ void RandomLeaves(boolean h)
3611
+ {
3612
+ if (blockloop)
3613
+ return;
3614
+
3615
+ if (bRep != null || material != null) // borderline...
3616
+ random = h;
3617
+
3618
+ for (int i = 0; i < Size(); i++)
3619
+ {
3620
+ Object3D child = (Object3D) get(i); // reserve(i);
3621
+ if (child == null)
3622
+ continue;
3623
+ blockloop = true;
3624
+ child.RandomLeaves(h);
35203625 blockloop = false;
35213626 // release(i);
35223627 }
....@@ -4290,6 +4395,55 @@
42904395 {
42914396 blockloop = true;
42924397 get(i).RepairShadow();
4398
+ blockloop = false;
4399
+ }
4400
+ }
4401
+
4402
+ void RepairSOV()
4403
+ {
4404
+ if (blockloop)
4405
+ return;
4406
+
4407
+ String texname = this.GetPigmentTexture();
4408
+
4409
+ if (texname.startsWith("sov"))
4410
+ {
4411
+ String[] s = texname.split("/");
4412
+
4413
+ String[] sname = s[1].split("Color.pn");
4414
+
4415
+ texname = sname[0];
4416
+
4417
+ if (sname.length > 1)
4418
+ {
4419
+ texname += "Color.jpg";
4420
+ }
4421
+
4422
+ this.SetPigmentTexture("sov/" + texname);
4423
+ }
4424
+
4425
+ texname = this.GetBumpTexture();
4426
+
4427
+ if (texname.startsWith("sov"))
4428
+ {
4429
+ String[] s = texname.split("/");
4430
+
4431
+ String[] sname = s[1].split("Bump.pn");
4432
+
4433
+ texname = sname[0];
4434
+
4435
+ if (sname.length > 1)
4436
+ {
4437
+ texname += "Bump.jpg";
4438
+ }
4439
+
4440
+ this.SetBumpTexture("sov/" + texname);
4441
+ }
4442
+
4443
+ for (int i=0; i<Size(); i++)
4444
+ {
4445
+ blockloop = true;
4446
+ get(i).RepairSOV();
42934447 blockloop = false;
42944448 }
42954449 }
....@@ -5517,12 +5671,23 @@
55175671 boolean NeedSupport()
55185672 {
55195673 return
5520
- CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null
5674
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
55215675 // PROBLEM with CROWD!!
55225676 && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
55235677 }
55245678
55255679 static boolean DEBUG_SELECTION = false;
5680
+
5681
+ boolean IsLive()
5682
+ {
5683
+ if (live)
5684
+ return true;
5685
+
5686
+ if (parent == null)
5687
+ return false;
5688
+
5689
+ return parent.IsLive();
5690
+ }
55265691
55275692 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
55285693 {
....@@ -5585,7 +5750,7 @@
55855750 support = support;
55865751
55875752 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5588
- boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5753
+ boolean usecalllists = IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
55895754
55905755 if (!usecalllists && bRep != null && bRep.displaylist > 0)
55915756 {
....@@ -5605,10 +5770,12 @@
56055770 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
56065771
56075772 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5608
- (touched || (bRep != null && bRep.displaylist <= 0)))
5773
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5774
+ (Globals.isLIVE() || touched && (bRep != null && bRep.displaylist <= 0)))
56095775 {
56105776 Globals.lighttouched = true;
56115777 } // all panes...
5778
+
56125779 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
56135780 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
56145781 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5776,16 +5943,27 @@
57765943 tex = GetTextures();
57775944 }
57785945
5779
- boolean failed = false;
5946
+ boolean failedPigment = false;
5947
+ boolean failedBump = false;
57805948
57815949 try
57825950 {
5783
- display.BindTextures(tex, texres);
5951
+ display.BindPigmentTexture(tex, texres);
57845952 }
57855953 catch (Exception e)
57865954 {
57875955 System.err.println("FAILED: " + this);
5788
- failed = true;
5956
+ failedPigment = true;
5957
+ }
5958
+
5959
+ try
5960
+ {
5961
+ display.BindBumpTexture(tex, texres);
5962
+ }
5963
+ catch (Exception e)
5964
+ {
5965
+ //System.err.println("FAILED: " + this);
5966
+ failedBump = true;
57895967 }
57905968
57915969 if (!compiled)
....@@ -5808,8 +5986,11 @@
58085986 }
58095987 }
58105988
5811
- if (!failed)
5812
- display.ReleaseTextures(tex);
5989
+ if (!failedBump)
5990
+ display.ReleaseBumpTexture(tex);
5991
+
5992
+ if (!failedPigment)
5993
+ display.ReleasePigmentTexture(tex);
58135994
58145995 display.PopMaterial(this, selected);
58155996 }
....@@ -6182,6 +6363,11 @@
61826363 // dec 2012
61836364 new Exception().printStackTrace();
61846365 return;
6366
+ }
6367
+
6368
+ if (dontselect)
6369
+ {
6370
+ //bRep.GenerateNormalsMINE();
61856371 }
61866372
61876373 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -7034,7 +7220,7 @@
70347220 spot.translate(32, 32);
70357221 spotw = spot.x + spot.width;
70367222 spoth = spot.y + spot.height;
7037
- info.g.setColor(Color.blue);
7223
+ info.g.setColor(Color.cyan);
70387224 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
70397225 // if (CameraPane.Xmin > spot.x)
70407226 // {
....@@ -7052,11 +7238,12 @@
70527238 // {
70537239 // CameraPane.Ymax = spoth;
70547240 // }
7055
- // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7056
- //info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7241
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7242
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
70577243 spot.translate(0, -32);
7058
- info.g.setColor(Color.green);
7244
+ info.g.setColor(Color.yellow);
70597245 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7246
+ info.g.setColor(Color.green);
70607247 // if (CameraPane.Xmin > spot.x)
70617248 // {
70627249 // CameraPane.Xmin = spot.x;
....@@ -7374,19 +7561,20 @@
73747561 switch (info.pane.RenderCamera().viewCode)
73757562 {
73767563 case 3: // '\001'
7377
- if (modified)
7564
+ if (modified || opposite)
73787565 {
73797566 //LA.matScale(toParent, 1, hScale, vScale);
73807567 LA.matScale(toParent, totalScale, 1, 1);
73817568 } // vScale, 1);
73827569 else
73837570 {
7571
+ // EXCEPTION!
73847572 LA.matScale(toParent, totalScale, totalScale, totalScale);
73857573 } // vScale, 1);
73867574 break;
73877575
73887576 case 2: // '\002'
7389
- if (modified)
7577
+ if (modified || opposite)
73907578 {
73917579 //LA.matScale(toParent, hScale, 1, vScale);
73927580 LA.matScale(toParent, 1, totalScale, 1);
....@@ -7397,7 +7585,7 @@
73977585 break;
73987586
73997587 case 1: // '\003'
7400
- if (modified)
7588
+ if (modified || opposite)
74017589 {
74027590 //LA.matScale(toParent, hScale, vScale, 1);
74037591 LA.matScale(toParent, 1, 1, totalScale);
....@@ -7617,6 +7805,10 @@
76177805 editWindow = null;
76187806 } // ?
76197807 }
7808
+ else
7809
+ {
7810
+ //editWindow.closeUI();
7811
+ }
76207812 }
76217813
76227814 boolean root; // patch for edit windows