Fixed incorrect foreign function signature

Former-commit-id: 909221683bc0bf7a15458b710e98c4e1565b71fb
This commit is contained in:
alteous 2017-08-30 20:02:20 +01:00
parent 4f7c63a945
commit 94705b0ac1
3 changed files with 8 additions and 15 deletions

View File

@ -132,12 +132,9 @@ fn make_cube() -> (Vec<Face>, Vec<Vertex>) {
fn main() {
let (faces, vertices) = make_cube();
//println!("{:#?}", faces);
//println!("{:#?}", vertices);
let vertex = |face, vert| {
let vs: &[u32; 3] = &faces[face % faces.len()];
println!("reading {}, {}", face, vert);
&vertices[vs[vert] as usize % vertices.len()]
};
let vertices_per_face = || 3;
@ -147,10 +144,8 @@ fn main() {
let tex_coord = |face, vert| &vertex(face, vert).tex_coord;
let mut new_vertices = Vec::new();
{
let mut set_tangent = |face, vert, tangent| {
println!("setting {}, {}", face, vert);
new_vertices.push(NewVertex {
position: *position(face, vert),
normal: *normal(face, vert),

View File

@ -60,7 +60,7 @@ pub struct SMikkTSpaceInterface {
pub m_setTSpaceBasic: extern "C" fn(
pContext: *mut SMikkTSpaceContext,
fvTangent: *const c_float,
fSign: *const c_float,
fSign: c_float,
iFace: c_int,
iVert: c_int,
),
@ -80,8 +80,8 @@ pub struct SMikkTSpaceInterface {
pContext: *mut SMikkTSpaceContext,
fvTangent: *const c_float,
fvBiTangent: *const c_float,
fMagS: *const c_float,
fMagT: *const c_float,
fMagS: c_float,
fMagT: c_float,
bIsOrientationPreserving: tbool,
iFace: c_int,
iVert: c_int,

View File

@ -110,7 +110,7 @@ extern "C" fn tex_coord(
extern "C" fn set_tspace_basic(
pContext: *mut ffi::SMikkTSpaceContext,
fvTangent: *const c_float,
fSign: *const c_float,
fSign: c_float,
iFace: c_int,
iVert: c_int,
) {
@ -119,7 +119,7 @@ extern "C" fn set_tspace_basic(
let mut tangent: [f32; 4] = mem::uninitialized();
let dst: *mut c_float = tangent.as_mut_ptr();
ptr::copy_nonoverlapping::<c_float>(fvTangent, dst, 3);
tangent[3] = *fSign;
tangent[3] = fSign;
((*x).set_tangent)(iFace as usize, iVert as usize, tangent);
}
}
@ -129,15 +129,13 @@ extern "C" fn set_tspace(
pContext: *mut ffi::SMikkTSpaceContext,
fvTangent: *const c_float,
_fvBiTangent: *const c_float,
_fMagS: *const c_float,
_fMagT: *const c_float,
_fMagS: c_float,
_fMagT: c_float,
bIsOrientationPreserving: ffi::tbool,
iFace: c_int,
iVert: c_int,
) {
const POSITIVE: f32 = 1.0;
const NEGATIVE: f32 = -1.0;
let fSign = if bIsOrientationPreserving != 0 { &POSITIVE } else { &NEGATIVE };
let fSign = if bIsOrientationPreserving != 0 { 1.0 } else { -1.0 };
set_tspace_basic(pContext, fvTangent, fSign, iFace, iVert);
}