.. | .. |
---|
45 | 45 | |
---|
46 | 46 | ScriptNode scriptnode; |
---|
47 | 47 | |
---|
| 48 | + void GetOrigin(cVector o) |
---|
| 49 | + { |
---|
| 50 | + o.x = this.toParent[3][0]; |
---|
| 51 | + o.y = this.toParent[3][1]; |
---|
| 52 | + o.z = this.toParent[3][2]; |
---|
| 53 | + } |
---|
| 54 | + |
---|
| 55 | + void SetOrigin(cVector o) |
---|
| 56 | + { |
---|
| 57 | + this.toParent[3][0] = o.x; |
---|
| 58 | + this.toParent[3][1] = o.y; |
---|
| 59 | + this.toParent[3][2] = o.z; |
---|
| 60 | + } |
---|
| 61 | + |
---|
48 | 62 | void deepCopyNode(Object3D other) |
---|
49 | 63 | { |
---|
50 | 64 | other.skyboxname = skyboxname; |
---|
.. | .. |
---|
659 | 673 | return this; |
---|
660 | 674 | } |
---|
661 | 675 | |
---|
| 676 | + class SizeCompare implements Comparable |
---|
| 677 | + { |
---|
| 678 | + int size; |
---|
| 679 | + Object3D child; |
---|
| 680 | + |
---|
| 681 | + SizeCompare(Object3D c) |
---|
| 682 | + { |
---|
| 683 | + child = c; |
---|
| 684 | + size = c.MemorySize(); |
---|
| 685 | + } |
---|
| 686 | + |
---|
| 687 | + public int compareTo(Object o) |
---|
| 688 | + { |
---|
| 689 | + SizeCompare comp = (SizeCompare) o; |
---|
| 690 | + |
---|
| 691 | + return comp.size < size ? 1 : -1; |
---|
| 692 | + } |
---|
| 693 | + } |
---|
| 694 | + |
---|
| 695 | + transient SizeCompare[] sizecompare = null; |
---|
| 696 | + |
---|
662 | 697 | void SortBySize() |
---|
663 | 698 | { |
---|
664 | | - boolean sorted = false; |
---|
| 699 | +// boolean sorted = false; |
---|
| 700 | +// |
---|
| 701 | +// while (!sorted) |
---|
| 702 | +// { |
---|
| 703 | +// sorted = true; |
---|
| 704 | +// |
---|
| 705 | +// for (int i=0; i<Size()-1; i++) |
---|
| 706 | +// { |
---|
| 707 | +// Object3D obji = get(i); |
---|
| 708 | +// Object3D objj = get(i+1); |
---|
| 709 | +// |
---|
| 710 | +// if (obji.MemorySize() < objj.MemorySize()) |
---|
| 711 | +// { |
---|
| 712 | +// set(i, objj); |
---|
| 713 | +// set(i+1, obji); |
---|
| 714 | +// |
---|
| 715 | +// sorted = false; |
---|
| 716 | +// } |
---|
| 717 | +// } |
---|
| 718 | +// } |
---|
| 719 | + |
---|
| 720 | + int count = Size(); |
---|
665 | 721 | |
---|
666 | | - while (!sorted) |
---|
| 722 | + if (sizecompare == null || sizecompare.length != count) |
---|
667 | 723 | { |
---|
668 | | - sorted = true; |
---|
669 | | - |
---|
670 | | - for (int i=0; i<Size()-1; i++) |
---|
| 724 | + sizecompare = new SizeCompare[count]; |
---|
| 725 | + |
---|
| 726 | + for (int k=0; k<count; k++) |
---|
671 | 727 | { |
---|
672 | | - Object3D obji = get(i); |
---|
673 | | - Object3D objj = get(i+1); |
---|
674 | | - |
---|
675 | | - if (obji.MemorySize() < objj.MemorySize()) |
---|
676 | | - { |
---|
677 | | - set(i, objj); |
---|
678 | | - set(i+1, obji); |
---|
679 | | - |
---|
680 | | - sorted = false; |
---|
681 | | - } |
---|
| 728 | + sizecompare[k] = new SizeCompare(get(k)); |
---|
682 | 729 | } |
---|
| 730 | + } |
---|
| 731 | + else |
---|
| 732 | + { |
---|
| 733 | + for (int k=0; k<count; k++) |
---|
| 734 | + { |
---|
| 735 | + sizecompare[k].size = get(k).MemorySize(); |
---|
| 736 | + } |
---|
| 737 | + } |
---|
| 738 | + |
---|
| 739 | + java.util.Arrays.sort(sizecompare); |
---|
| 740 | + |
---|
| 741 | + for (int i=0; i<count; i++) |
---|
| 742 | + { |
---|
| 743 | + set(i, sizecompare[i].child); |
---|
683 | 744 | } |
---|
684 | 745 | } |
---|
685 | 746 | |
---|
.. | .. |
---|
711 | 772 | |
---|
712 | 773 | int MemorySize() |
---|
713 | 774 | { |
---|
714 | | - if (memorysize == 0) |
---|
| 775 | +// if (memorysize == 0) |
---|
| 776 | +// { |
---|
| 777 | +// try |
---|
| 778 | +// { |
---|
| 779 | +// Object3D obj = this; |
---|
| 780 | +// |
---|
| 781 | +// Object3D parent = obj.parent; |
---|
| 782 | +// obj.parent = null; |
---|
| 783 | +// Object3D support = obj.support; |
---|
| 784 | +// obj.support = null; |
---|
| 785 | +// |
---|
| 786 | +// java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream(); |
---|
| 787 | +// java.io.ObjectOutputStream out = new java.io.ObjectOutputStream(baos); |
---|
| 788 | +// |
---|
| 789 | +// out.writeObject(obj); |
---|
| 790 | +// |
---|
| 791 | +// obj.parent = parent; |
---|
| 792 | +// obj.support = support; |
---|
| 793 | +// |
---|
| 794 | +// memorysize = baos.toByteArray().length; |
---|
| 795 | +// } |
---|
| 796 | +// catch (Exception e) |
---|
| 797 | +// { |
---|
| 798 | +// e.printStackTrace(); |
---|
| 799 | +// } |
---|
| 800 | +// } |
---|
| 801 | +// |
---|
| 802 | +// return memorysize; |
---|
| 803 | + |
---|
| 804 | + if (blockloop) |
---|
715 | 805 | { |
---|
716 | | - try |
---|
717 | | - { |
---|
718 | | - Object3D obj = this; |
---|
| 806 | + return 0; |
---|
| 807 | + } |
---|
719 | 808 | |
---|
720 | | - Object3D parent = obj.parent; |
---|
721 | | - obj.parent = null; |
---|
722 | | - Object3D support = obj.support; |
---|
723 | | - obj.support = null; |
---|
724 | | - |
---|
725 | | - java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream(); |
---|
726 | | - java.io.ObjectOutputStream out = new java.io.ObjectOutputStream(baos); |
---|
727 | | - |
---|
728 | | - out.writeObject(obj); |
---|
729 | | - |
---|
730 | | - obj.parent = parent; |
---|
731 | | - obj.support = support; |
---|
732 | | - |
---|
733 | | - memorysize = baos.toByteArray().length; |
---|
734 | | - } |
---|
735 | | - catch (Exception e) |
---|
736 | | - { |
---|
737 | | - e.printStackTrace(); |
---|
738 | | - } |
---|
| 809 | + int memory = 0; |
---|
| 810 | + |
---|
| 811 | + if (bRep != null) |
---|
| 812 | + { |
---|
| 813 | + memory = bRep.VertexCount(); |
---|
739 | 814 | } |
---|
740 | 815 | |
---|
741 | | - return memorysize; |
---|
| 816 | + blockloop = true; |
---|
| 817 | + |
---|
| 818 | + for (int i = 0; i < Size(); i++) |
---|
| 819 | + { |
---|
| 820 | + Object3D obj = (Object3D) Children().get(i); |
---|
| 821 | + |
---|
| 822 | + memory += obj.MemorySize(); |
---|
| 823 | + } |
---|
| 824 | + |
---|
| 825 | + blockloop = false; |
---|
| 826 | + |
---|
| 827 | + return memory; |
---|
742 | 828 | } |
---|
743 | 829 | |
---|
744 | 830 | void Slower() |
---|
.. | .. |
---|
6193 | 6279 | static cVector maxima = new cVector(); |
---|
6194 | 6280 | static javax.vecmath.Point3d center = new javax.vecmath.Point3d(); |
---|
6195 | 6281 | |
---|
| 6282 | + boolean compiling; |
---|
| 6283 | + |
---|
6196 | 6284 | void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
6197 | 6285 | { |
---|
6198 | 6286 | Invariants(); // june 2013 |
---|
.. | .. |
---|
6278 | 6366 | |
---|
6279 | 6367 | boolean usecalllists = !IsDynamic() && |
---|
6280 | 6368 | IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !Link2Support()); // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
6281 | | - //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
| 6369 | + |
---|
| 6370 | + //usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
6282 | 6371 | |
---|
6283 | 6372 | //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass. |
---|
6284 | 6373 | |
---|
.. | .. |
---|
6332 | 6421 | display.NewList(bRep.displaylist); |
---|
6333 | 6422 | } |
---|
6334 | 6423 | |
---|
| 6424 | + compiling = true; |
---|
6335 | 6425 | CallList(display, root, selected, blocked); |
---|
| 6426 | + compiling = false; |
---|
6336 | 6427 | |
---|
6337 | 6428 | // compiled = true; |
---|
6338 | 6429 | if (usecalllists && bRep.displaylist > 0) |
---|
.. | .. |
---|
6807 | 6898 | |
---|
6808 | 6899 | void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected) |
---|
6809 | 6900 | { |
---|
6810 | | - if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000) |
---|
6811 | | - return; // no shadow for transparent objects |
---|
6812 | | - |
---|
6813 | | - if (display.DrawMode() == iCameraPane.SELECTION && dontselect) |
---|
6814 | | - return; |
---|
6815 | | - |
---|
6816 | | - if (hide) |
---|
6817 | | - return; |
---|
| 6901 | + if (!compiling) |
---|
| 6902 | + { |
---|
| 6903 | + if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000) |
---|
| 6904 | + return; // no shadow for transparent objects |
---|
| 6905 | + |
---|
| 6906 | + if (display.DrawMode() == iCameraPane.SELECTION && dontselect) |
---|
| 6907 | + return; |
---|
| 6908 | + |
---|
| 6909 | + if (hide) |
---|
| 6910 | + return; |
---|
| 6911 | + } |
---|
6818 | 6912 | |
---|
6819 | 6913 | if (scriptnode != null) |
---|
6820 | 6914 | { |
---|
.. | .. |
---|
8351 | 8445 | objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")"; |
---|
8352 | 8446 | } else |
---|
8353 | 8447 | { |
---|
8354 | | - objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ ""; |
---|
| 8448 | + objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + ((bRep==null)?(count - 1):bRep.VertexCount()) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ ""; |
---|
8355 | 8449 | } // + super.toString(); |
---|
8356 | 8450 | //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName(); |
---|
8357 | 8451 | |
---|