Merges the geometry contained by "source" into this MeshBuilder. This is a relatively fast operation, consider caching sub-geometry inside individual MeshBuilders (and, of course, protecting this merge operation between two bookmarks).
(MeshBuilder source)
| 856 | if (target.elements == null && source.target.elements != null) |
| 857 | throw new IllegalArgumentException(" cannot merge, mismatch in element dimension "); |
| 858 | if (target.elements != null && source.target.elements == null) |
| 859 | throw new IllegalArgumentException(" cannot merge, mismatch in element dimension "); |
| 860 | if (target.elements == null && source.target.elements == null) { |
| 861 | } else if (target.elements.getDimension() != source.target.elements.getDimension()) |
| 862 | throw new IllegalArgumentException(" cannot merge, mismatch in element dimension "); |
| 863 | |
| 864 | // thread shenanigans |
| 865 | int sc = source.vertexCursor; |
| 866 | FloatBuffer vv = source.target.vertex(true).asReadOnlyBuffer(); |
| 867 | vv.clear(); |
| 868 | vv.limit(sc * 3); |
| 869 | FloatBuffer v = ensureSize(0, 3, vertexCursor + sc); |
| 870 | v.put(vv); |
| 871 | if (target.elements==null) |
| 872 | {} |
| 873 | else { |
| 874 | IntBuffer e = ensureElementSize(target.elements.getDimension(), elementCursor + source.elementCursor); |
| 875 | IntBuffer e2 = source.target.elements(true); |
| 876 | for (int i = 0; i < source.elementCursor * target.elements.getDimension(); i++) |
| 877 | e.put(e2.get() + vertexCursor); |
| 878 | } |
| 879 | |
| 880 | |
| 881 | Set<Integer> auxes = new LinkedHashSet<>(); |
| 882 | auxes.addAll(this.target.buffers() |
| 883 | .keySet()); |
| 884 | auxes.addAll(source.target.buffers() |
| 885 | .keySet()); |
| 886 | auxes.remove(0); |
| 887 | |
| 888 | for (Integer ii : auxes) { |
| 889 | ArrayBuffer a = this.target.buffers[ii]; |
| 890 | ArrayBuffer b = source.target.buffers[ii]; |
| 891 | if (a == null && b == null) continue; |
| 892 | |
| 893 | if (a != null && b != null && a.getDimension() != b.getDimension()) |
| 894 | throw new IllegalArgumentException( |
| 895 | " dimension mismatch in merge " + a.getDimension() + "!=" + b.getDimension()); |
| 896 | if (b != null) { |
| 897 | FloatBuffer left = ensureSize(ii, b.getDimension(), vertexCursor + source.vertexCursor); |
| 898 | FloatBuffer right = b.floats(); |
| 899 | try { |
| 900 | right.limit(sc * b.getDimension()); |
| 901 | left.put(right); // fill with blank ? |
| 902 | } |
| 903 | catch(BufferUnderflowException e) |
| 904 | { |
| 905 | e.printStackTrace(); |
| 906 | } |
| 907 | } |
| 908 | if (b == null) |
| 909 | ensureSize(ii, a.getDimension(), vertexCursor + source.vertexCursor); // fill with blank? |
| 910 | } |
| 911 | |
| 912 | elementCursor += source.elementCursor; |
| 913 | vertexCursor += source.vertexCursor; |
| 914 | |
| 915 | return this; |
nothing calls this directly
no test coverage detected