pub fn update_vertex_buffer<T: bytemuck::Pod + Copy + 'static>(&mut self, vertices: &[T], buffer: &mut VertexBuffer) -> Option<VertexBuffer> {
        let bytes: &[u8] = bytemuck::cast_slice(vertices);
        // Check if the vertex buffer is big enough to fit the vertices
        if bytes.len() <= buffer.size as usize {
            log::info!("Updating vertex buffer >> Current max: {} || Updated size: {}", buffer.size, bytes.len());
            self.device.update_vertex_buffer(vertices, buffer);
            None
        } else {
            log::info!("Creating new vertex buffer >> Current max: {} || Updated size: {}", buffer.size, bytes.len());
            if let Some(name) = buffer.name.clone() {
                Some(self.vertex_buffer(vertices, Some(name.as_str())))
            } else {
                Some(self.vertex_buffer(vertices, None))
            }
        }
    }
/// Updates the vertex buffer or, if too big, creates a new one big enough to fit the data
Updates the vertex buffer or, if too big, creates a new one big enough to fit the data
Updates the vertex buffer or if too big creates a new one big enough to fit the data
pub fn update_vertex_buffer<T: bytemuck::Pod + Copy + 'static>(&mut self, vertices: &[T], buffer: &mut VertexBuffer) -> Option<VertexBuffer> {
        let bytes: &[u8] = bytemuck::cast_slice(vertices);
        // Check if the vertex buffer is big enough to fit the vertices
        if bytes.len() <= buffer.size as usize {
            log::info!("Updating vertex buffer >> Current max: {} || Updated size: {}", buffer.size, bytes.len());
            self.device.update_vertex_buffer(vertices, buffer);
            None
        } else {
            log::info!("Creating new vertex buffer >> Current max: {} || Updated size: {}", buffer.size, bytes.len());
            if let Some(name) = buffer.name.clone() {
                Some(self.vertex_buffer(vertices, Some(name.as_str())))
            } else {
                Some(self.vertex_buffer(vertices, None))
            }
        }
    }
pub fn update_vertex_buffer < T : bytemuck :: Pod + Copy + ' static > ( & mut self , vertices : & [ T ] , buffer : & mut VertexBuffer ) -> Option < VertexBuffer > { let bytes : & [ u8 ] = bytemuck :: cast_slice ( vertices ) ; // Check if the vertex buffer is big enough to fit the vertices if bytes . len ( ) <= buffer . size as usize { log :: info ! ( " " buffer size bytes len ( ) ) ; self . device . update_vertex_buffer ( vertices , buffer ) ; None } else { log :: info ! ( " " buffer size bytes len ( ) ) ; if let Some ( name ) = buffer . name . clone ( ) { Some ( self . vertex_buffer ( vertices , Some ( name . as_str ( ) ) ) ) } else { Some ( self . vertex_buffer ( vertices , None ) ) } } }
Updates the vertex buffer or, if too big, creates a new one big enough to fit the data
Updates the vertex buffer or if too big creates a new one big enough to fit the data
&mut self
vertices
&[T]
buffer
&mut VertexBuffer