Normand Briere
2019-07-27 1af7d3700724834e40ad8636bc9a56cdc3b19b15
Object3D.java
....@@ -29,6 +29,9 @@
2929 Object3D saveskeleton;
3030 //
3131
32
+ byte[] versions[];
33
+ int versionindex = -1;
34
+
3235 ScriptNode scriptnode;
3336
3437 void InitOthers()
....@@ -215,6 +218,9 @@
215218 // o.transientrep = this.bRep.support;
216219 // o.bRep.support = null;
217220 // }
221
+ o.selection = this.selection;
222
+ o.versions = this.versions;
223
+ o.versionindex = this.versionindex;
218224
219225 if (this.support != null)
220226 {
....@@ -268,6 +274,11 @@
268274 {
269275 this.support.bRep = o.transientrep;
270276 }
277
+
278
+ this.selection = o.selection;
279
+
280
+ this.versions = o.versions;
281
+ this.versionindex = o.versionindex;
271282 // July 2019 if (this.bRep != null)
272283 // this.bRep.support = o.transientrep;
273284 // this.support = o.support;
....@@ -415,6 +426,7 @@
415426 }
416427
417428 boolean live = false;
429
+ transient boolean keepdontselect;
418430 boolean dontselect = false;
419431 boolean hide = false;
420432 boolean link2master = false; // performs reset support/master at each frame
....@@ -2555,7 +2567,8 @@
25552567 private static final int editSelf = 1;
25562568 private static final int editChild = 2;
25572569
2558
- void drawEditHandles(ClickInfo info, int level)
2570
+ void drawEditHandles(//ClickInfo info,
2571
+ int level)
25592572 {
25602573 if (level == 0)
25612574 {
....@@ -2563,7 +2576,8 @@
25632576 return;
25642577
25652578 Object3D selectee;
2566
- 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))
25672581 {
25682582 selectee = (Object3D) e.nextElement();
25692583 }
....@@ -2571,19 +2585,22 @@
25712585 } else
25722586 {
25732587 //super.
2574
- drawEditHandles0(info, level + 1);
2588
+ drawEditHandles0(//info,
2589
+ level + 1);
25752590 }
25762591 }
25772592
2578
- boolean doEditClick(ClickInfo info, int level)
2593
+ boolean doEditClick(//ClickInfo info,
2594
+ int level)
25792595 {
25802596 doSomething = 0;
25812597 if (level == 0)
25822598 {
2583
- return doParentClick(info);
2599
+ return doParentClick(); //info);
25842600 }
25852601 if (//super.
2586
- doEditClick0(info, level))
2602
+ doEditClick0(//info,
2603
+ level))
25872604 {
25882605 doSomething = 1;
25892606 return true;
....@@ -2593,7 +2610,7 @@
25932610 }
25942611 }
25952612
2596
- boolean doParentClick(ClickInfo info)
2613
+ boolean doParentClick() //ClickInfo info)
25972614 {
25982615 if (selection == null)
25992616 {
....@@ -2606,7 +2623,8 @@
26062623 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
26072624 {
26082625 Object3D selectee = (Object3D) e.nextElement();
2609
- if (selectee.doEditClick(info, 1))
2626
+ if (selectee.doEditClick(//info,
2627
+ 1))
26102628 {
26112629 childToDrag = selectee;
26122630 doSomething = 2;
....@@ -2618,13 +2636,15 @@
26182636 return retval;
26192637 }
26202638
2621
- void doEditDrag(ClickInfo info, boolean opposite)
2639
+ void doEditDrag(//ClickInfo clickInfo,
2640
+ boolean opposite)
26222641 {
26232642 switch (doSomething)
26242643 {
26252644 case 1: // '\001'
26262645 //super.
2627
- doEditDrag0(info, opposite);
2646
+ doEditDrag0(//clickInfo,
2647
+ opposite);
26282648 break;
26292649
26302650 case 2: // '\002'
....@@ -2637,11 +2657,13 @@
26372657 {
26382658 //sel.hitSomething = childToDrag.hitSomething;
26392659 //childToDrag.doEditDrag(info);
2640
- sel.doEditDrag(info, opposite);
2660
+ sel.doEditDrag(//clickInfo,
2661
+ opposite);
26412662 } else
26422663 {
26432664 //super.
2644
- doEditDrag0(info, opposite);
2665
+ doEditDrag0(//clickInfo,
2666
+ opposite);
26452667 }
26462668 }
26472669 break;
....@@ -2659,6 +2681,9 @@
26592681 {
26602682 deselectAll();
26612683 }
2684
+
2685
+ new Exception().printStackTrace();
2686
+
26622687 ClickInfo newInfo = new ClickInfo();
26632688 newInfo.flags = info.flags;
26642689 newInfo.bounds = info.bounds;
....@@ -3106,7 +3131,7 @@
31063131 {
31073132 if (bRep != null)
31083133 {
3109
- bRep.GenerateNormalsMINE();
3134
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
31103135 Touch();
31113136 }
31123137 }
....@@ -5409,6 +5434,51 @@
54095434 blockloop = false;
54105435 }
54115436
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
+
54125482 boolean IsSelected()
54135483 {
54145484 if (parent == null)
....@@ -5718,6 +5788,38 @@
57185788 }
57195789 }
57205790
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
+
57215823 void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57225824 {
57235825 Draw(display, root, selected, blocked);
....@@ -5805,7 +5907,7 @@
58055907 support = support;
58065908
58075909 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5808
- 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);
58095911
58105912 if (!usecalllists && bRep != null && bRep.displaylist > 0)
58115913 {
....@@ -7209,20 +7311,23 @@
72097311 }
72107312 }
72117313
7212
- 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)
72137318 {
7214
- int hc = info.bounds.x + info.bounds.width / 2;
7215
- int vc = info.bounds.y + info.bounds.height / 2;
7216
- 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;
72177322 if (toscreen == null)
72187323 {
7219
- toscreen = new Camera(info.camera.viewCode).toScreen;
7324
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
72207325 }
72217326 cVector vec = in;
72227327 LA.xformPos(in, toscreen, in);
72237328 //System.out.println("Distance = " + info.camera.Distance());
7224
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7225
- 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();
72267331 outPt.x = hc + (int) vec.x;
72277332 outPt.y = vc - (int) vec.y;
72287333 outRec.x = outPt.x - 3;
....@@ -7230,15 +7335,18 @@
72307335 outRec.width = outRec.height = 6;
72317336 }
72327337
7233
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7338
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7339
+ )
72347340 {
72357341 Point pt = new Point(0, 0);
72367342 Rectangle rec = new Rectangle();
7237
- calcHotSpot(in, info, pt, rec);
7343
+ calcHotSpot(in, //clickInfo,
7344
+ pt, rec);
72387345 return rec;
72397346 }
72407347
7241
- void drawEditHandles0(ClickInfo info, int level)
7348
+ void drawEditHandles0(//ClickInfo clickInfo,
7349
+ int level)
72427350 {
72437351 if (level == 0)
72447352 {
....@@ -7247,16 +7355,19 @@
72477355 {
72487356 cVector origin = new cVector();
72497357 //LA.xformPos(origin, toParent, origin);
7250
- Rectangle spot = calcHotSpot(origin, info);
7358
+ if (this.clickInfo == null)
7359
+ this.clickInfo = new ClickInfo();
7360
+
7361
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
72517362 Rectangle boundary = new Rectangle();
72527363 boundary.x = spot.x - 30;
72537364 boundary.y = spot.y - 30;
72547365 boundary.width = spot.width + 60;
72557366 boundary.height = spot.height + 60;
7256
- info.g.setColor(Color.red);
7367
+ clickInfo.g.setColor(Color.red);
72577368 int spotw = spot.x + spot.width;
72587369 int spoth = spot.y + spot.height;
7259
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7370
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
72607371 // if (CameraPane.Xmin > spot.x)
72617372 // {
72627373 // CameraPane.Xmin = spot.x;
....@@ -7276,8 +7387,8 @@
72767387 spot.translate(32, 32);
72777388 spotw = spot.x + spot.width;
72787389 spoth = spot.y + spot.height;
7279
- info.g.setColor(Color.cyan);
7280
- 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);
72817392 // if (CameraPane.Xmin > spot.x)
72827393 // {
72837394 // CameraPane.Xmin = spot.x;
....@@ -7297,9 +7408,9 @@
72977408 // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
72987409 //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
72997410 spot.translate(0, -32);
7300
- info.g.setColor(Color.yellow);
7301
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7302
- 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);
73037414 // if (CameraPane.Xmin > spot.x)
73047415 // {
73057416 // CameraPane.Xmin = spot.x;
....@@ -7316,8 +7427,8 @@
73167427 // {
73177428 // CameraPane.Ymax = spoth;
73187429 // }
7319
- info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY,
7320
- (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);
73217432 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
73227433 // if (CameraPane.Xmin > boundary.x)
73237434 // {
....@@ -7339,7 +7450,8 @@
73397450 }
73407451 }
73417452
7342
- boolean doEditClick0(ClickInfo info, int level)
7453
+ boolean doEditClick0(//ClickInfo clickInfo,
7454
+ int level)
73437455 {
73447456 if (level == 0)
73457457 {
....@@ -7348,8 +7460,8 @@
73487460
73497461 boolean retval = false;
73507462
7351
- startX = info.x;
7352
- startY = info.y;
7463
+ startX = clickInfo.x;
7464
+ startY = clickInfo.y;
73537465
73547466 hitSomething = -1;
73557467 cVector origin = new cVector();
....@@ -7359,22 +7471,51 @@
73597471 {
73607472 centerPt = new Point(0, 0);
73617473 }
7362
- calcHotSpot(origin, info, centerPt, spot);
7363
- if (spot.contains(info.x, info.y))
7474
+ calcHotSpot(origin, //info,
7475
+ centerPt, spot);
7476
+ if (spot.contains(clickInfo.x, clickInfo.y))
73647477 {
73657478 hitSomething = hitCenter;
73667479 retval = true;
73677480 }
73687481 spot.translate(32, 0);
7369
- if (spot.contains(info.x, info.y))
7482
+ if (spot.contains(clickInfo.x, clickInfo.y))
73707483 {
73717484 hitSomething = hitRotate;
73727485 retval = true;
73737486 }
73747487 spot.translate(0, 32);
7375
- if (spot.contains(info.x, info.y))
7488
+ if (spot.contains(clickInfo.x, clickInfo.y))
73767489 {
73777490 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
+
73787519 retval = true;
73797520 }
73807521
....@@ -7384,7 +7525,7 @@
73847525 }
73857526
73867527 //System.out.println("info.modifiers = " + info.modifiers);
7387
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7528
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
73887529 //System.out.println("modified = " + modified);
73897530 //new Exception().printStackTrace();
73907531 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7412,7 +7553,8 @@
74127553 return true;
74137554 }
74147555
7415
- void doEditDrag0(ClickInfo info, boolean opposite)
7556
+ void doEditDrag0(//ClickInfo info,
7557
+ boolean opposite)
74167558 {
74177559 if (hitSomething == 0)
74187560 {
....@@ -7426,7 +7568,7 @@
74267568
74277569 //System.out.println("hitSomething = " + hitSomething);
74287570
7429
- double scale = 0.005f * info.camera.Distance();
7571
+ double scale = 0.005f * clickInfo.camera.Distance();
74307572
74317573 cVector xlate = new cVector();
74327574 //cVector xlate2 = new cVector();
....@@ -7460,8 +7602,8 @@
74607602 toParent[3][i] = xlate.get(i);
74617603 LA.matInvert(toParent, fromParent);
74627604 */
7463
- cVector delta = LA.newVector(0, 0, startY - info.y);
7464
- 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);
74657607
74667608 LA.matCopy(startMat, toParent);
74677609 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7470,7 +7612,7 @@
74707612 } else
74717613 {
74727614 //LA.xformDir(delta, info.camera.fromScreen, delta);
7473
- cVector up = new cVector(info.camera.up);
7615
+ cVector up = new cVector(clickInfo.camera.up);
74747616 cVector away = new cVector();
74757617 //cVector right2 = new cVector();
74767618 //LA.vecCross(up, cVector.Z, right);
....@@ -7487,19 +7629,19 @@
74877629 LA.xformDir(up, ClickInfo.matbuffer, up);
74887630 // if (!CameraPane.LOCALTRANSFORM)
74897631 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7490
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7632
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
74917633 // if (!CameraPane.LOCALTRANSFORM)
74927634 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
74937635 //LA.vecCross(up, cVector.Z, right2);
74947636
7495
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7637
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
74967638
74977639 //System.out.println("DELTA0 = " + delta);
74987640 //System.out.println("AWAY = " + info.camera.away);
74997641 //System.out.println("UP = " + info.camera.up);
75007642 if (away.z > 0)
75017643 {
7502
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7644
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
75037645 {
75047646 delta.x = -delta.x;
75057647 } else
....@@ -7514,7 +7656,7 @@
75147656 //System.out.println("DELTA1 = " + delta);
75157657 LA.xformDir(delta, ClickInfo.matbuffer, delta);
75167658 //System.out.println("DELTA2 = " + delta);
7517
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7659
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
75187660 LA.matCopy(startMat, toParent);
75197661 //System.out.println("DELTA3 = " + delta);
75207662 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7524,8 +7666,8 @@
75247666 break;
75257667
75267668 case hitRotate: // rotate
7527
- int dx = info.x - centerPt.x;
7528
- int dy = -(info.y - centerPt.y);
7669
+ int dx = clickInfo.x - centerPt.x;
7670
+ int dy = -(clickInfo.y - centerPt.y);
75297671 double angle = (double) Math.atan2(dx, dy);
75307672 angle = -(1.570796 - angle);
75317673
....@@ -7548,7 +7690,7 @@
75487690 }
75497691 /**/
75507692
7551
- switch (info.pane.RenderCamera().viewCode)
7693
+ switch (clickInfo.pane.RenderCamera().viewCode)
75527694 {
75537695 case 1: // '\001'
75547696 LA.matZRotate(toParent, angle);
....@@ -7575,7 +7717,7 @@
75757717 break;
75767718
75777719 case hitScale: // scale
7578
- double hScale = (double) (info.x - centerPt.x) / 32;
7720
+ double hScale = (double) (clickInfo.x /*- centerPt.x*/) / 32;
75797721 double sign = 1;
75807722 if (hScale < 0)
75817723 {
....@@ -7587,7 +7729,7 @@
75877729 //hScale = 0.01;
75887730 }
75897731
7590
- double vScale = (double) (info.y - centerPt.y) / 32;
7732
+ double vScale = (double) (clickInfo.y /*- centerPt.y*/) / 32;
75917733 sign = 1;
75927734 if (vScale < 0)
75937735 {
....@@ -7598,6 +7740,7 @@
75987740 {
75997741 //vScale = 0.01;
76007742 }
7743
+
76017744 LA.matCopy(startMat, toParent);
76027745 /**/
76037746 for (int i = 0; i < 3; i++)
....@@ -7607,14 +7750,14 @@
76077750 }
76087751 /**/
76097752
7610
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7753
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
76117754
76127755 if (totalScale < 0.01)
76137756 {
76147757 totalScale = 0.01;
76157758 }
76167759
7617
- switch (info.pane.RenderCamera().viewCode)
7760
+ switch (clickInfo.pane.RenderCamera().viewCode)
76187761 {
76197762 case 3: // '\001'
76207763 if (modified || opposite)
....@@ -7681,7 +7824,7 @@
76817824 } // NEW ...
76827825
76837826
7684
- info.pane.repaint();
7827
+ clickInfo.pane.repaint();
76857828 }
76867829
76877830 boolean overflow = false;