Normand Briere
2019-07-25 7058eef32e524cae08a7373d8bc1061e373b223c
Object3D.java
....@@ -29,7 +29,7 @@
2929 Object3D saveskeleton;
3030 //
3131
32
- byte[] versions[] = new byte[100][];
32
+ byte[] versions[];
3333 int versionindex = -1;
3434
3535 ScriptNode scriptnode;
....@@ -219,6 +219,8 @@
219219 // o.bRep.support = null;
220220 // }
221221 o.selection = this.selection;
222
+ o.versions = this.versions;
223
+ o.versionindex = this.versionindex;
222224
223225 if (this.support != null)
224226 {
....@@ -274,6 +276,9 @@
274276 }
275277
276278 this.selection = o.selection;
279
+
280
+ this.versions = o.versions;
281
+ this.versionindex = o.versionindex;
277282 // July 2019 if (this.bRep != null)
278283 // this.bRep.support = o.transientrep;
279284 // this.support = o.support;
....@@ -421,6 +426,7 @@
421426 }
422427
423428 boolean live = false;
429
+ transient boolean keepdontselect;
424430 boolean dontselect = false;
425431 boolean hide = false;
426432 boolean link2master = false; // performs reset support/master at each frame
....@@ -2561,7 +2567,8 @@
25612567 private static final int editSelf = 1;
25622568 private static final int editChild = 2;
25632569
2564
- void drawEditHandles(ClickInfo info, int level)
2570
+ void drawEditHandles(//ClickInfo info,
2571
+ int level)
25652572 {
25662573 if (level == 0)
25672574 {
....@@ -2569,7 +2576,8 @@
25692576 return;
25702577
25712578 Object3D selectee;
2572
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2579
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2580
+ level + 1))
25732581 {
25742582 selectee = (Object3D) e.nextElement();
25752583 }
....@@ -2577,19 +2585,22 @@
25772585 } else
25782586 {
25792587 //super.
2580
- drawEditHandles0(info, level + 1);
2588
+ drawEditHandles0(//info,
2589
+ level + 1);
25812590 }
25822591 }
25832592
2584
- boolean doEditClick(ClickInfo info, int level)
2593
+ boolean doEditClick(//ClickInfo info,
2594
+ int level)
25852595 {
25862596 doSomething = 0;
25872597 if (level == 0)
25882598 {
2589
- return doParentClick(info);
2599
+ return doParentClick(); //info);
25902600 }
25912601 if (//super.
2592
- doEditClick0(info, level))
2602
+ doEditClick0(//info,
2603
+ level))
25932604 {
25942605 doSomething = 1;
25952606 return true;
....@@ -2599,7 +2610,7 @@
25992610 }
26002611 }
26012612
2602
- boolean doParentClick(ClickInfo info)
2613
+ boolean doParentClick() //ClickInfo info)
26032614 {
26042615 if (selection == null)
26052616 {
....@@ -2612,7 +2623,8 @@
26122623 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
26132624 {
26142625 Object3D selectee = (Object3D) e.nextElement();
2615
- if (selectee.doEditClick(info, 1))
2626
+ if (selectee.doEditClick(//info,
2627
+ 1))
26162628 {
26172629 childToDrag = selectee;
26182630 doSomething = 2;
....@@ -2624,13 +2636,15 @@
26242636 return retval;
26252637 }
26262638
2627
- void doEditDrag(ClickInfo info, boolean opposite)
2639
+ void doEditDrag(//ClickInfo clickInfo,
2640
+ boolean opposite)
26282641 {
26292642 switch (doSomething)
26302643 {
26312644 case 1: // '\001'
26322645 //super.
2633
- doEditDrag0(info, opposite);
2646
+ doEditDrag0(//clickInfo,
2647
+ opposite);
26342648 break;
26352649
26362650 case 2: // '\002'
....@@ -2643,11 +2657,13 @@
26432657 {
26442658 //sel.hitSomething = childToDrag.hitSomething;
26452659 //childToDrag.doEditDrag(info);
2646
- sel.doEditDrag(info, opposite);
2660
+ sel.doEditDrag(//clickInfo,
2661
+ opposite);
26472662 } else
26482663 {
26492664 //super.
2650
- doEditDrag0(info, opposite);
2665
+ doEditDrag0(//clickInfo,
2666
+ opposite);
26512667 }
26522668 }
26532669 break;
....@@ -2665,6 +2681,9 @@
26652681 {
26662682 deselectAll();
26672683 }
2684
+
2685
+ new Exception().printStackTrace();
2686
+
26682687 ClickInfo newInfo = new ClickInfo();
26692688 newInfo.flags = info.flags;
26702689 newInfo.bounds = info.bounds;
....@@ -3112,7 +3131,7 @@
31123131 {
31133132 if (bRep != null)
31143133 {
3115
- bRep.GenerateNormalsMINE();
3134
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
31163135 Touch();
31173136 }
31183137 }
....@@ -5415,6 +5434,51 @@
54155434 blockloop = false;
54165435 }
54175436
5437
+ void ResetSelectable()
5438
+ {
5439
+ if (blockloop)
5440
+ return;
5441
+
5442
+ blockloop = true;
5443
+
5444
+ keepdontselect = dontselect;
5445
+ dontselect = true;
5446
+
5447
+ Object3D child;
5448
+ int nb = Size();
5449
+ for (int i = 0; i < nb; i++)
5450
+ {
5451
+ child = (Object3D) get(i);
5452
+ if (child == null)
5453
+ continue;
5454
+ child.ResetSelectable();
5455
+ }
5456
+
5457
+ blockloop = false;
5458
+ }
5459
+
5460
+ void RestoreSelectable()
5461
+ {
5462
+ if (blockloop)
5463
+ return;
5464
+
5465
+ blockloop = true;
5466
+
5467
+ dontselect = keepdontselect;
5468
+
5469
+ Object3D child;
5470
+ int nb = Size();
5471
+ for (int i = 0; i < nb; i++)
5472
+ {
5473
+ child = (Object3D) get(i);
5474
+ if (child == null)
5475
+ continue;
5476
+ child.RestoreSelectable();
5477
+ }
5478
+
5479
+ blockloop = false;
5480
+ }
5481
+
54185482 boolean IsSelected()
54195483 {
54205484 if (parent == null)
....@@ -5724,6 +5788,38 @@
57245788 }
57255789 }
57265790
5791
+ void EmbedTextures(boolean embed)
5792
+ {
5793
+ if (blockloop)
5794
+ return;
5795
+
5796
+ //if (GetTextures() != null)
5797
+ if (embed)
5798
+ CameraPane.EmbedTextures(GetTextures());
5799
+ else
5800
+ {
5801
+ GetTextures().pigmentdata = null;
5802
+ GetTextures().bumpdata = null;
5803
+ GetTextures().pw = 0;
5804
+ GetTextures().ph = 0;
5805
+ GetTextures().bw = 0;
5806
+ GetTextures().bh = 0;
5807
+ }
5808
+
5809
+ int nb = Size();
5810
+ for (int i = 0; i < nb; i++)
5811
+ {
5812
+ Object3D child = (Object3D) get(i);
5813
+
5814
+ if (child == null)
5815
+ continue;
5816
+
5817
+ blockloop = true;
5818
+ child.EmbedTextures(embed);
5819
+ blockloop = false;
5820
+ }
5821
+ }
5822
+
57275823 void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57285824 {
57295825 Draw(display, root, selected, blocked);
....@@ -5811,7 +5907,7 @@
58115907 support = support;
58125908
58135909 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5814
- boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5910
+ boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
58155911
58165912 if (!usecalllists && bRep != null && bRep.displaylist > 0)
58175913 {
....@@ -7215,20 +7311,23 @@
72157311 }
72167312 }
72177313
7218
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7314
+ static ClickInfo clickInfo = new ClickInfo();
7315
+
7316
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7317
+ Point outPt, Rectangle outRec)
72197318 {
7220
- int hc = info.bounds.x + info.bounds.width / 2;
7221
- int vc = info.bounds.y + info.bounds.height / 2;
7222
- double[][] toscreen = info.toScreen;
7319
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7320
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7321
+ double[][] toscreen = clickInfo.toScreen;
72237322 if (toscreen == null)
72247323 {
7225
- toscreen = new Camera(info.camera.viewCode).toScreen;
7324
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
72267325 }
72277326 cVector vec = in;
72287327 LA.xformPos(in, toscreen, in);
72297328 //System.out.println("Distance = " + info.camera.Distance());
7230
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7231
- vec.y *= 100 * info.camera.SCALE / info.camera.Distance();
7329
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7330
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
72327331 outPt.x = hc + (int) vec.x;
72337332 outPt.y = vc - (int) vec.y;
72347333 outRec.x = outPt.x - 3;
....@@ -7236,15 +7335,18 @@
72367335 outRec.width = outRec.height = 6;
72377336 }
72387337
7239
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7338
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7339
+ )
72407340 {
72417341 Point pt = new Point(0, 0);
72427342 Rectangle rec = new Rectangle();
7243
- calcHotSpot(in, info, pt, rec);
7343
+ calcHotSpot(in, //clickInfo,
7344
+ pt, rec);
72447345 return rec;
72457346 }
72467347
7247
- void drawEditHandles0(ClickInfo info, int level)
7348
+ void drawEditHandles0(//ClickInfo clickInfo,
7349
+ int level)
72487350 {
72497351 if (level == 0)
72507352 {
....@@ -7253,16 +7355,19 @@
72537355 {
72547356 cVector origin = new cVector();
72557357 //LA.xformPos(origin, toParent, origin);
7256
- Rectangle spot = calcHotSpot(origin, info);
7358
+ if (this.clickInfo == null)
7359
+ this.clickInfo = new ClickInfo();
7360
+
7361
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
72577362 Rectangle boundary = new Rectangle();
72587363 boundary.x = spot.x - 30;
72597364 boundary.y = spot.y - 30;
72607365 boundary.width = spot.width + 60;
72617366 boundary.height = spot.height + 60;
7262
- info.g.setColor(Color.red);
7367
+ clickInfo.g.setColor(Color.red);
72637368 int spotw = spot.x + spot.width;
72647369 int spoth = spot.y + spot.height;
7265
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7370
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72667371 // if (CameraPane.Xmin > spot.x)
72677372 // {
72687373 // CameraPane.Xmin = spot.x;
....@@ -7282,8 +7387,8 @@
72827387 spot.translate(32, 32);
72837388 spotw = spot.x + spot.width;
72847389 spoth = spot.y + spot.height;
7285
- info.g.setColor(Color.cyan);
7286
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7390
+ clickInfo.g.setColor(Color.cyan);
7391
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72877392 // if (CameraPane.Xmin > spot.x)
72887393 // {
72897394 // CameraPane.Xmin = spot.x;
....@@ -7303,9 +7408,9 @@
73037408 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
73047409 //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
73057410 spot.translate(0, -32);
7306
- info.g.setColor(Color.yellow);
7307
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7308
- info.g.setColor(Color.green);
7411
+ clickInfo.g.setColor(Color.yellow);
7412
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7413
+ clickInfo.g.setColor(Color.green);
73097414 // if (CameraPane.Xmin > spot.x)
73107415 // {
73117416 // CameraPane.Xmin = spot.x;
....@@ -7322,8 +7427,8 @@
73227427 // {
73237428 // CameraPane.Ymax = spoth;
73247429 // }
7325
- info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY,
7326
- (int)(boundary.width * info.W), (int)(boundary.height * info.W), 0, 360);
7430
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7431
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
73277432 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
73287433 // if (CameraPane.Xmin > boundary.x)
73297434 // {
....@@ -7345,7 +7450,8 @@
73457450 }
73467451 }
73477452
7348
- boolean doEditClick0(ClickInfo info, int level)
7453
+ boolean doEditClick0(//ClickInfo clickInfo,
7454
+ int level)
73497455 {
73507456 if (level == 0)
73517457 {
....@@ -7354,8 +7460,8 @@
73547460
73557461 boolean retval = false;
73567462
7357
- startX = info.x;
7358
- startY = info.y;
7463
+ startX = clickInfo.x;
7464
+ startY = clickInfo.y;
73597465
73607466 hitSomething = -1;
73617467 cVector origin = new cVector();
....@@ -7365,22 +7471,51 @@
73657471 {
73667472 centerPt = new Point(0, 0);
73677473 }
7368
- calcHotSpot(origin, info, centerPt, spot);
7369
- if (spot.contains(info.x, info.y))
7474
+ calcHotSpot(origin, //info,
7475
+ centerPt, spot);
7476
+ if (spot.contains(clickInfo.x, clickInfo.y))
73707477 {
73717478 hitSomething = hitCenter;
73727479 retval = true;
73737480 }
73747481 spot.translate(32, 0);
7375
- if (spot.contains(info.x, info.y))
7482
+ if (spot.contains(clickInfo.x, clickInfo.y))
73767483 {
73777484 hitSomething = hitRotate;
73787485 retval = true;
73797486 }
73807487 spot.translate(0, 32);
7381
- if (spot.contains(info.x, info.y))
7488
+ if (spot.contains(clickInfo.x, clickInfo.y))
73827489 {
73837490 hitSomething = hitScale;
7491
+
7492
+ double scale = 0.005f * clickInfo.camera.Distance();
7493
+ double hScale = (double) (clickInfo.x /*- centerPt.x*/) / 32;
7494
+ double sign = 1;
7495
+ if (hScale < 0)
7496
+ {
7497
+ sign = -1;
7498
+ }
7499
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7500
+ if (hScale < 0.01)
7501
+ {
7502
+ //hScale = 0.01;
7503
+ }
7504
+
7505
+ double vScale = (double) (clickInfo.y /*- centerPt.y*/) / 32;
7506
+ sign = 1;
7507
+ if (vScale < 0)
7508
+ {
7509
+ sign = -1;
7510
+ }
7511
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7512
+ if (vScale < 0.01)
7513
+ {
7514
+ //vScale = 0.01;
7515
+ }
7516
+
7517
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7518
+
73847519 retval = true;
73857520 }
73867521
....@@ -7390,7 +7525,7 @@
73907525 }
73917526
73927527 //System.out.println("info.modifiers = " + info.modifiers);
7393
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7528
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
73947529 //System.out.println("modified = " + modified);
73957530 //new Exception().printStackTrace();
73967531 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7418,7 +7553,8 @@
74187553 return true;
74197554 }
74207555
7421
- void doEditDrag0(ClickInfo info, boolean opposite)
7556
+ void doEditDrag0(//ClickInfo info,
7557
+ boolean opposite)
74227558 {
74237559 if (hitSomething == 0)
74247560 {
....@@ -7432,7 +7568,7 @@
74327568
74337569 //System.out.println("hitSomething = " + hitSomething);
74347570
7435
- double scale = 0.005f * info.camera.Distance();
7571
+ double scale = 0.005f * clickInfo.camera.Distance();
74367572
74377573 cVector xlate = new cVector();
74387574 //cVector xlate2 = new cVector();
....@@ -7466,8 +7602,8 @@
74667602 toParent[3][i] = xlate.get(i);
74677603 LA.matInvert(toParent, fromParent);
74687604 */
7469
- cVector delta = LA.newVector(0, 0, startY - info.y);
7470
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7605
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7606
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
74717607
74727608 LA.matCopy(startMat, toParent);
74737609 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7476,7 +7612,7 @@
74767612 } else
74777613 {
74787614 //LA.xformDir(delta, info.camera.fromScreen, delta);
7479
- cVector up = new cVector(info.camera.up);
7615
+ cVector up = new cVector(clickInfo.camera.up);
74807616 cVector away = new cVector();
74817617 //cVector right2 = new cVector();
74827618 //LA.vecCross(up, cVector.Z, right);
....@@ -7493,19 +7629,19 @@
74937629 LA.xformDir(up, ClickInfo.matbuffer, up);
74947630 // if (!CameraPane.LOCALTRANSFORM)
74957631 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7496
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7632
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
74977633 // if (!CameraPane.LOCALTRANSFORM)
74987634 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
74997635 //LA.vecCross(up, cVector.Z, right2);
75007636
7501
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7637
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
75027638
75037639 //System.out.println("DELTA0 = " + delta);
75047640 //System.out.println("AWAY = " + info.camera.away);
75057641 //System.out.println("UP = " + info.camera.up);
75067642 if (away.z > 0)
75077643 {
7508
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7644
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
75097645 {
75107646 delta.x = -delta.x;
75117647 } else
....@@ -7520,7 +7656,7 @@
75207656 //System.out.println("DELTA1 = " + delta);
75217657 LA.xformDir(delta, ClickInfo.matbuffer, delta);
75227658 //System.out.println("DELTA2 = " + delta);
7523
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7659
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
75247660 LA.matCopy(startMat, toParent);
75257661 //System.out.println("DELTA3 = " + delta);
75267662 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7530,8 +7666,8 @@
75307666 break;
75317667
75327668 case hitRotate: // rotate
7533
- int dx = info.x - centerPt.x;
7534
- int dy = -(info.y - centerPt.y);
7669
+ int dx = clickInfo.x - centerPt.x;
7670
+ int dy = -(clickInfo.y - centerPt.y);
75357671 double angle = (double) Math.atan2(dx, dy);
75367672 angle = -(1.570796 - angle);
75377673
....@@ -7554,7 +7690,7 @@
75547690 }
75557691 /**/
75567692
7557
- switch (info.pane.RenderCamera().viewCode)
7693
+ switch (clickInfo.pane.RenderCamera().viewCode)
75587694 {
75597695 case 1: // '\001'
75607696 LA.matZRotate(toParent, angle);
....@@ -7581,7 +7717,7 @@
75817717 break;
75827718
75837719 case hitScale: // scale
7584
- double hScale = (double) (info.x - centerPt.x) / 32;
7720
+ double hScale = (double) (clickInfo.x /*- centerPt.x*/) / 32;
75857721 double sign = 1;
75867722 if (hScale < 0)
75877723 {
....@@ -7593,7 +7729,7 @@
75937729 //hScale = 0.01;
75947730 }
75957731
7596
- double vScale = (double) (info.y - centerPt.y) / 32;
7732
+ double vScale = (double) (clickInfo.y /*- centerPt.y*/) / 32;
75977733 sign = 1;
75987734 if (vScale < 0)
75997735 {
....@@ -7604,6 +7740,7 @@
76047740 {
76057741 //vScale = 0.01;
76067742 }
7743
+
76077744 LA.matCopy(startMat, toParent);
76087745 /**/
76097746 for (int i = 0; i < 3; i++)
....@@ -7613,14 +7750,14 @@
76137750 }
76147751 /**/
76157752
7616
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7753
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
76177754
76187755 if (totalScale < 0.01)
76197756 {
76207757 totalScale = 0.01;
76217758 }
76227759
7623
- switch (info.pane.RenderCamera().viewCode)
7760
+ switch (clickInfo.pane.RenderCamera().viewCode)
76247761 {
76257762 case 3: // '\001'
76267763 if (modified || opposite)
....@@ -7687,7 +7824,7 @@
76877824 } // NEW ...
76887825
76897826
7690
- info.pane.repaint();
7827
+ clickInfo.pane.repaint();
76917828 }
76927829
76937830 boolean overflow = false;