MergeAndTakeOwnership method
void
MergeAndTakeOwnership(
- GeometryBuilder other, [
- Matrix4? mat,
- Matrix3? matNormal
])
Implementation
void MergeAndTakeOwnership(GeometryBuilder other,
[VM.Matrix4? mat, VM.Matrix3? matNormal]) {
if (other.vertices.length == 0) return;
final int offset = vertices.length;
assert(pointsOnly == other.pointsOnly);
for (String a in attributes.keys) {
assert(other.attributes.containsKey(a));
}
for (String a in other.attributes.keys) {
assert(attributes.containsKey(a));
switch (a) {
case aNormal:
assert(matNormal != null, "no normal matrix provided");
for (VM.Vector3 v in other.attributes[a] as List<VM.Vector3>) {
attributes[a]!.add(v..applyMatrix3(matNormal!));
}
break;
default:
attributes[a]!.addAll(other.attributes[a] as List);
}
}
other.attributes.clear();
for (VM.Vector3 v in other.vertices) {
if (mat == null) {
vertices.add(v);
} else {
vertices.add(v..applyMatrix4(mat));
}
}
other.vertices.clear();
for (Face3 face in other.faces3) {
face.a += offset;
face.b += offset;
face.c += offset;
faces3.add(face);
}
other.faces3.clear();
for (Face4 face in other.faces4) {
face.a += offset;
face.b += offset;
face.c += offset;
face.d += offset;
faces4.add(face);
}
other.faces4.clear();
}