Normand Briere
2019-06-23 f1382bc839a74ef1d1534c61ea94e53cf54716df
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,64 +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();
127
- }
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
-}
120
+ if (blockloop)
121
+ return;
139122
140
-void RestoreSupports()
141
-{
142
- if (blockloop)
143
- return;
123
+ transientsupport = support;
124
+ transientlink2master = link2master;
144125
145
- support = transientsupport;
146
- link2master = transientlink2master;
147
- transientsupport = null;
148
- transientlink2master = false;
149
-
150
- if (bRep != null)
151
- {
152
- bRep.RestoreSupports();
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
+ }
153143 }
154
-
155
- for (int i = 0; i < Size(); i++)
144
+
145
+ void RestoreSupports()
156146 {
157
- Object3D child = (Object3D) get(i);
158
- if (child == null)
159
- continue;
160
- blockloop = true;
161
- child.RestoreSupports();
162
- blockloop = false;
147
+ if (blockloop)
148
+ return;
149
+
150
+ support = transientsupport;
151
+ link2master = transientlink2master;
152
+ transientsupport = null;
153
+ transientlink2master = false;
154
+
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
+ }
163169 }
164
-}
170
+
171
+ void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
172
+ {
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
+
222
+ Object3D o = hashtable.get(GetUUID());
223
+
224
+ RestoreBigData(o);
225
+
226
+ hashtable.remove(GetUUID());
227
+
228
+ for (int i=0; i<Size(); i++)
229
+ {
230
+ get(i).RestoreBigData(hashtable);
231
+ }
232
+ }
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
+ }
165242
166243 // MOCAP SUPPORT
167244 double tx,ty,tz,rx,ry,rz;
....@@ -486,12 +563,14 @@
486563 toParent = LA.newMatrix();
487564 fromParent = LA.newMatrix();
488565 }
566
+
489567 if (toParentMarked == null)
490568 {
491569 if (maxcount != 1)
492570 {
493571 new Exception().printStackTrace();
494572 }
573
+
495574 toParentMarked = LA.newMatrix();
496575 fromParentMarked = LA.newMatrix();
497576 }
....@@ -814,7 +893,8 @@
814893
815894 boolean changedir = random && Math.random() < 0.01; // && !link2master;
816895
817
- if (transformcount*factor > maxcount || (step == 1 && changedir))
896
+ if (transformcount*factor >= maxcount && (rewind || random) ||
897
+ (step == 1 && changedir))
818898 {
819899 countdown = 1;
820900 delay = speedup?8:1;
....@@ -2307,6 +2387,10 @@
23072387 }
23082388 */
23092389 }
2390
+ else
2391
+ {
2392
+ //((ObjEditor)editWindow).SetupUI2(null);
2393
+ }
23102394 }
23112395
23122396 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2632,6 +2716,18 @@
26322716 //Touch();
26332717 }
26342718
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
+
26352731 void ClearColorsS()
26362732 {
26372733 selection.ClearColors();
....@@ -2763,6 +2859,24 @@
27632859 if (child == null)
27642860 continue;
27652861 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();
27662880 // Children().release(i);
27672881 }
27682882 blockloop = false;
....@@ -2931,6 +3045,15 @@
29313045 if (bRep != null)
29323046 {
29333047 bRep.GenerateNormals(crease);
3048
+ Touch();
3049
+ }
3050
+ }
3051
+
3052
+ void GenNormalsMesh0()
3053
+ {
3054
+ if (bRep != null)
3055
+ {
3056
+ bRep.GenerateNormalsMesh();
29343057 Touch();
29353058 }
29363059 }
....@@ -3385,7 +3508,8 @@
33853508 if (blockloop)
33863509 return;
33873510
3388
- if (marked || (bRep != null && material != null)) // borderline...
3511
+ if (//marked || // does not make sense
3512
+ (bRep != null || material != null)) // borderline...
33893513 live = h;
33903514
33913515 for (int i = 0; i < Size(); i++)
....@@ -3406,7 +3530,8 @@
34063530 return;
34073531
34083532 //if (bRep != null)
3409
- if (marked || (bRep != null && material != null)) // borderline...
3533
+ if (//marked || // does not make sense
3534
+ (bRep != null || material != null)) // borderline...
34103535 link2master = h;
34113536
34123537 for (int i = 0; i < Size(); i++)
....@@ -3426,7 +3551,8 @@
34263551 if (blockloop)
34273552 return;
34283553
3429
- if (marked || (bRep != null && material != null)) // borderline...
3554
+ if (//marked || // does not make sense
3555
+ (bRep != null || material != null)) // borderline...
34303556 hide = h;
34313557
34323558 for (int i = 0; i < Size(); i++)
....@@ -3446,7 +3572,7 @@
34463572 if (blockloop)
34473573 return;
34483574
3449
- if (bRep != null && material != null) // borderline...
3575
+ if (bRep != null || material != null) // borderline...
34503576 marked = h;
34513577
34523578 for (int i = 0; i < Size(); i++)
....@@ -3456,6 +3582,46 @@
34563582 continue;
34573583 blockloop = true;
34583584 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);
34593625 blockloop = false;
34603626 // release(i);
34613627 }
....@@ -4229,6 +4395,55 @@
42294395 {
42304396 blockloop = true;
42314397 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();
42324447 blockloop = false;
42334448 }
42344449 }
....@@ -5456,12 +5671,23 @@
54565671 boolean NeedSupport()
54575672 {
54585673 return
5459
- CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null
5674
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
54605675 // PROBLEM with CROWD!!
54615676 && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
54625677 }
54635678
54645679 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
+ }
54655691
54665692 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
54675693 {
....@@ -5524,7 +5750,7 @@
55245750 support = support;
55255751
55265752 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5527
- 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);
55285754
55295755 if (!usecalllists && bRep != null && bRep.displaylist > 0)
55305756 {
....@@ -5544,10 +5770,12 @@
55445770 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
55455771
55465772 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5547
- (touched || (bRep != null && bRep.displaylist <= 0)))
5773
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5774
+ (Globals.isLIVE() || touched && (bRep != null && bRep.displaylist <= 0)))
55485775 {
55495776 Globals.lighttouched = true;
55505777 } // all panes...
5778
+
55515779 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
55525780 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
55535781 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5715,16 +5943,27 @@
57155943 tex = GetTextures();
57165944 }
57175945
5718
- boolean failed = false;
5946
+ boolean failedPigment = false;
5947
+ boolean failedBump = false;
57195948
57205949 try
57215950 {
5722
- display.BindTextures(tex, texres);
5951
+ display.BindPigmentTexture(tex, texres);
57235952 }
57245953 catch (Exception e)
57255954 {
57265955 System.err.println("FAILED: " + this);
5727
- 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;
57285967 }
57295968
57305969 if (!compiled)
....@@ -5747,8 +5986,11 @@
57475986 }
57485987 }
57495988
5750
- if (!failed)
5751
- display.ReleaseTextures(tex);
5989
+ if (!failedBump)
5990
+ display.ReleaseBumpTexture(tex);
5991
+
5992
+ if (!failedPigment)
5993
+ display.ReleasePigmentTexture(tex);
57525994
57535995 display.PopMaterial(this, selected);
57545996 }
....@@ -6121,6 +6363,11 @@
61216363 // dec 2012
61226364 new Exception().printStackTrace();
61236365 return;
6366
+ }
6367
+
6368
+ if (dontselect)
6369
+ {
6370
+ //bRep.GenerateNormalsMINE();
61246371 }
61256372
61266373 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -6973,7 +7220,7 @@
69737220 spot.translate(32, 32);
69747221 spotw = spot.x + spot.width;
69757222 spoth = spot.y + spot.height;
6976
- info.g.setColor(Color.blue);
7223
+ info.g.setColor(Color.cyan);
69777224 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
69787225 // if (CameraPane.Xmin > spot.x)
69797226 // {
....@@ -6991,11 +7238,12 @@
69917238 // {
69927239 // CameraPane.Ymax = spoth;
69937240 // }
6994
- // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15);
6995
- //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
69967243 spot.translate(0, -32);
6997
- info.g.setColor(Color.green);
7244
+ info.g.setColor(Color.yellow);
69987245 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7246
+ info.g.setColor(Color.green);
69997247 // if (CameraPane.Xmin > spot.x)
70007248 // {
70017249 // CameraPane.Xmin = spot.x;
....@@ -7313,19 +7561,20 @@
73137561 switch (info.pane.RenderCamera().viewCode)
73147562 {
73157563 case 3: // '\001'
7316
- if (modified)
7564
+ if (modified || opposite)
73177565 {
73187566 //LA.matScale(toParent, 1, hScale, vScale);
73197567 LA.matScale(toParent, totalScale, 1, 1);
73207568 } // vScale, 1);
73217569 else
73227570 {
7571
+ // EXCEPTION!
73237572 LA.matScale(toParent, totalScale, totalScale, totalScale);
73247573 } // vScale, 1);
73257574 break;
73267575
73277576 case 2: // '\002'
7328
- if (modified)
7577
+ if (modified || opposite)
73297578 {
73307579 //LA.matScale(toParent, hScale, 1, vScale);
73317580 LA.matScale(toParent, 1, totalScale, 1);
....@@ -7336,7 +7585,7 @@
73367585 break;
73377586
73387587 case 1: // '\003'
7339
- if (modified)
7588
+ if (modified || opposite)
73407589 {
73417590 //LA.matScale(toParent, hScale, vScale, 1);
73427591 LA.matScale(toParent, 1, 1, totalScale);
....@@ -7556,6 +7805,10 @@
75567805 editWindow = null;
75577806 } // ?
75587807 }
7808
+ else
7809
+ {
7810
+ //editWindow.closeUI();
7811
+ }
75597812 }
75607813
75617814 boolean root; // patch for edit windows
....@@ -7567,7 +7820,7 @@
75677820 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
75687821
75697822 Object3D /*Composite*/ parent;
7570
- Object3D /*Composite*/ fileparent;
7823
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
75717824
75727825 double[][] toParent; // dynamic matrix
75737826 double[][] fromParent;