Normand Briere
2019-10-06 9cf2c36d644d0aaa28797f57a3e71591d8e66973
Object3D.java
....@@ -41,6 +41,8 @@
4141
4242 java.util.Hashtable<java.util.UUID, Object3D> versiontable; // = new java.util.Hashtable<java.util.UUID, Object3D>();
4343
44
+ transient int tabIndex; // Tabs can change between sessions.
45
+
4446 ScriptNode scriptnode;
4547
4648 void deepCopyNode(Object3D other)
....@@ -100,7 +102,7 @@
100102 other.softtouched = softtouched;
101103
102104 other.random = random;
103
- other.link2master = link2master;
105
+ other.link2master = Link2Support();
104106 other.transformcount = transformcount;
105107 other.marked = marked;
106108 other.skip = skip;
....@@ -220,7 +222,7 @@
220222 return;
221223
222224 transientsupport = support;
223
- transientlink2master = link2master;
225
+ transientlink2master = Link2Support();
224226
225227 support = null;
226228 link2master = false;
....@@ -633,7 +635,10 @@
633635 transient boolean keepdontselect;
634636 boolean dontselect = false;
635637 boolean hide = false;
636
- boolean link2master = false; // performs reset support/master at each frame
638
+
639
+ boolean link2master = false; // performs reset support/master at each frame (cannot rename due to serialization)
640
+ boolean link2support = false; // (cannot rename due to serialization)
641
+
637642 boolean marked = false; // animation node
638643 boolean skip = false; // centroid issue
639644 boolean skipmocap = false; // mocap data
....@@ -1023,7 +1028,7 @@
10231028
10241029 void Step()
10251030 {
1026
- // marde pour serialization de Texture
1031
+ // patch pour serialization de Texture
10271032 resetmaxcount();
10281033 resettransformcount();
10291034 resetstep();
....@@ -1137,6 +1142,8 @@
11371142 (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
11381143 currentframe != Globals.framecount)
11391144 {
1145
+ Globals.lighttouched = true;
1146
+
11401147 currentframe = Globals.framecount;
11411148
11421149 // System.err.println("transformcount = " + transformcount);
....@@ -3414,7 +3421,7 @@
34143421 }
34153422 }
34163423
3417
- public void Scale(int scale)
3424
+ public void Scale(float scale)
34183425 {
34193426 Object3D obj = this;
34203427
....@@ -4101,11 +4108,6 @@
41014108 Step();
41024109 Touch();
41034110
4104
- StepRecur();
4105
- }
4106
-
4107
- void StepRecur()
4108
- {
41094111 for (int i = 0; i < size(); i++)
41104112 {
41114113 Object3D child = (Object3D) get(i); // reserve(i);
....@@ -6159,7 +6161,7 @@
61596161 boolean NeedSupport()
61606162 {
61616163 return
6162
- CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
6164
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && Link2Support() && /*live &&*/ support != null
61636165 // PROBLEM with CROWD!!
61646166 && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
61656167 }
....@@ -6182,6 +6184,15 @@
61826184 return live && bRep != null;
61836185 }
61846186
6187
+ boolean Link2Support()
6188
+ {
6189
+ return link2master || link2support;
6190
+ }
6191
+
6192
+ static cVector minima = new cVector();
6193
+ static cVector maxima = new cVector();
6194
+ static javax.vecmath.Point3d center = new javax.vecmath.Point3d();
6195
+
61856196 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
61866197 {
61876198 Invariants(); // june 2013
....@@ -6189,6 +6200,29 @@
61896200 if (support != null)
61906201 {
61916202 // System.err.println("Draw " + this + " Frame # " + ((Mocap)((Merge)support).object).frame);
6203
+ }
6204
+
6205
+ if (false) // live && Link2Support() && support == null && !this.marked) // project on ground
6206
+ {
6207
+ getBounds(minima, maxima, true);
6208
+ center.x = (minima.x + maxima.x) / 2;
6209
+ center.y = 10000; // (minima.y + maxima.y) / 2;
6210
+ center.z = (minima.z + maxima.z) / 2;
6211
+
6212
+ Ray ray = new Ray(center, new Vector3d(0,-1,0));
6213
+
6214
+ IntersectResult res = new IntersectResult();
6215
+ res.t = Double.POSITIVE_INFINITY;
6216
+
6217
+ if (Grafreed.grafreed.universe.intersect(ray, res))
6218
+ {
6219
+ double resx = ray.eyePoint.x + ray.viewDirection.x * res.t;
6220
+ double resy = ray.eyePoint.y + ray.viewDirection.y * res.t;
6221
+ double resz = ray.eyePoint.z + ray.viewDirection.z * res.t;
6222
+
6223
+ LA.matTranslate(toParent, 0, resy - minima.y, 0);
6224
+ LA.matInvert(toParent, fromParent);
6225
+ }
61926226 }
61936227
61946228 if (display.DrawMode() == iCameraPane.SELECTION &&
....@@ -6243,7 +6277,7 @@
62436277 support = support;
62446278
62456279 boolean usecalllists = !IsDynamic() &&
6246
- IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
6280
+ IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !Link2Support()); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
62476281 //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
62486282
62496283 //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass.
....@@ -6254,7 +6288,8 @@
62546288 bRep.displaylist = 0;
62556289 }
62566290 // usecalllists &= !(parent instanceof RandomNode);
6257
- // usecalllists = false;
6291
+ if (CameraPane.BOXMODE) // Too dynamic
6292
+ usecalllists = false;
62586293
62596294 if (display.DrawMode() == display.SHADOW)
62606295 //GetBRep() != null)
....@@ -6268,7 +6303,7 @@
62686303
62696304 if (!selectmode && //display.DrawMode() != display.SELECTION &&
62706305 //(touched || (bRep != null && bRep.displaylist <= 0)))
6271
- (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
6306
+ ((Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE) || touched)) // || (bRep != null && bRep.displaylist <= 0)))
62726307 {
62736308 Globals.lighttouched = true;
62746309 } // all panes...
....@@ -6350,7 +6385,7 @@
63506385 {
63516386 if (display.DrawMode() == iCameraPane.SHADOW)
63526387 {
6353
- if (!link2master // tricky to cull in shadow mode.
6388
+ if (!Link2Support() // tricky to cull in shadow mode.
63546389 && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
63556390 {
63566391 //System.out.print("CULLED");
....@@ -6823,7 +6858,8 @@
68236858
68246859 //javax.media.opengl.GL gl = display.GetGL();
68256860
6826
- if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
6861
+ if (CameraPane.BOXMODE && //!Link2Support()) //
6862
+ !selected) // || CameraPane.movingcamera)
68276863 {
68286864 int fc = bRep.FaceCount();
68296865 int vc = bRep.VertexCount();
....@@ -6985,7 +7021,7 @@
69857021 facescompare[k] = new FaceCompare(k);
69867022 }
69877023
6988
- center = new cVector();
7024
+ centertriangle = new cVector();
69897025 }
69907026 else
69917027 {
....@@ -7108,7 +7144,7 @@
71087144 */
71097145 }
71107146
7111
- transient cVector center;
7147
+ transient cVector centertriangle;
71127148
71137149 class FaceCompare implements Comparable
71147150 {
....@@ -7137,14 +7173,14 @@
71377173 Vertex q = bRep.GetVertex(face.q);
71387174 Vertex r = bRep.GetVertex(face.r);
71397175
7140
- center.set(p);
7141
- center.add(q);
7142
- center.add(r);
7143
- center.mul(1.0/3);
7176
+ centertriangle.set(p);
7177
+ centertriangle.add(q);
7178
+ centertriangle.add(r);
7179
+ centertriangle.mul(1.0/3);
71447180
7145
- center.sub(Globals.theRenderer.EyeCamera().location);
7181
+ centertriangle.sub(Globals.theRenderer.EyeCamera().location);
71467182
7147
- distance = center.dot(center);
7183
+ distance = centertriangle.dot(centertriangle);
71487184 }
71497185
71507186 return distance;
....@@ -8327,7 +8363,7 @@
83278363
83288364 public int hashCode()
83298365 {
8330
- // Fuck Vector...
8366
+ // Do not use Vector...
83318367 return System.identityHashCode(this);
83328368 }
83338369
....@@ -8869,7 +8905,7 @@
88698905 double diry = ray.viewDirection.y;
88708906 double dirz = ray.viewDirection.z;
88718907
8872
- if (this.fromParent != null)
8908
+ if (this.fromParent != null && !(this instanceof TextureNode))
88738909 {
88748910 eye.x = eyex;
88758911 eye.y = eyey;
....@@ -8894,7 +8930,7 @@
88948930
88958931 boolean touch = false;
88968932
8897
- if (bRep != null)
8933
+ if (bRep != null && Link2Support())
88988934 {
88998935 if (bbox == null)
89008936 {
....@@ -8903,7 +8939,7 @@
89038939 cVector min = new cVector();
89048940 cVector max = new cVector();
89058941
8906
- this.getBounds(min, max, false);
8942
+ this.getBounds(min, max, true);
89078943
89088944 bbox.min.x = min.x;
89098945 bbox.min.y = min.y;
....@@ -8914,7 +8950,7 @@
89148950 bbox.max.z = max.z;
89158951 }
89168952
8917
- if (bbox.intersect(ray, result))
8953
+ if (true) // NOT WORKING bbox.intersect(ray, result))
89188954 {
89198955 success |= intersectMesh(ray, result);
89208956 }
....@@ -8958,6 +8994,12 @@
89588994
89598995 private boolean intersectTriangle(Ray ray, IntersectResult result, Vertex v1, Vertex v2, Vertex v3)
89608996 {
8997
+ if (false)
8998
+ {
8999
+ result.t = 0;
9000
+ return true;
9001
+ }
9002
+
89619003 /*
89629004 Fast, Minimum Storage Ray/Triangle Intersection, Moller et al.
89639005