File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,20 @@ impl Mesh {
4646 } )
4747 }
4848
49+ /// Merge the vertices and faces from a mesh into this one.
50+ pub fn merge ( & mut self , mut other : Mesh ) {
51+ let offset = self . vertices . len ( ) as u32 ;
52+
53+ // Vertices from the second mesh are tacked on to the end of the vertex
54+ // buffer.
55+ self . vertices . append ( & mut other. vertices ) ;
56+
57+ // Indices from the second mesh must be offset to point to the new
58+ // vertex locations in the combined mesh.
59+ self . faces
60+ . extend ( other. faces . into_iter ( ) . map ( |f| f. map ( |f| f + offset) ) ) ;
61+ }
62+
4963 /// Transform such that the mesh is centered and on the range (-1, 1) along
5064 /// the longest extent.
5165 pub fn normalization_transform ( & self ) -> Matrix4 < f64 > {
You can’t perform that action at this time.
0 commit comments