Skip to content

Commit

Permalink
Add functions to modify shape meshes
Browse files Browse the repository at this point in the history
  • Loading branch information
redstrate committed May 26, 2024
1 parent 5512181 commit 8c2274c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
use std::os::raw::c_char;
use std::ptr::{null, null_mut};
use std::{mem, slice};
use std::ptr::slice_from_raw_parts;
use physis::model::NewShapeValue;

use physis::model::{SubMesh, Vertex, MDL};

Expand Down Expand Up @@ -201,6 +203,26 @@ pub extern "C" fn physis_mdl_replace_vertices(
&*std::ptr::slice_from_raw_parts(submeshes_ptr, num_submeshes as usize),
);


// We need to update the C version of these LODs as well
let mut new_lods = physis_mdl_update_vertices((*mdl).p_ptr.as_ref().unwrap());

(*mdl).lods = new_lods.as_mut_ptr();

mem::forget(new_lods);
}
}

#[no_mangle] pub extern "C" fn physis_mdl_remove_shape_meshes(mdl: *mut physis_MDL) {
unsafe {
(*(*mdl).p_ptr).remove_shape_meshes();
}
}

#[no_mangle] pub extern "C" fn physis_mdl_add_shape_mesh(mdl: *mut physis_MDL, lod_index: u32, shape_index: u32, shape_mesh_index: u32, part_index: u32, num_shape_Values: u32, shape_values: *const NewShapeValue) {
unsafe {
(*(*mdl).p_ptr).add_shape_mesh(lod_index as usize, shape_index as usize, shape_mesh_index as usize, part_index as usize, &*slice_from_raw_parts(shape_values, num_shape_Values as usize));

// We need to update the C version of these LODs as well
let mut new_lods = physis_mdl_update_vertices((*mdl).p_ptr.as_ref().unwrap());

Expand Down

0 comments on commit 8c2274c

Please sign in to comment.