use approx_det::assert_relative_eq;
use wasm_bindgen_test::*;
use crate::collision_tasks::tests::common::{
convex1contact_manifold_wide_to_convex1contact_manifold, get_input_wide,
Convex1ContactManifold, Mvec3, TestInput,
};
use crate::collision_tasks::ShapeWideTester;
use crate::shapes::{CuboidWide, SphereWide};
use crate::traits::PairWideTest;
use crate::{Cuboid, Sphere};
wasm_bindgen_test_configure!(run_in_browser);
type InputType = TestInput<Sphere, Cuboid>;
const ADJUST_DEPTH_FACTOR: f32 = 0.5;
#[test]
#[wasm_bindgen_test]
fn test_sphere_cuboid_tester_random() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input = include_bytes!("resource/sphere_cuboid/random.json");
let input0: InputType = serde_json::from_slice(file_input).expect("file should be proper JSON");
let mut output0 = Convex1ContactManifold {
offset_a: Mvec3 {
x: -2.210208,
y: -2.4443378,
z: 1.0203364,
},
normal: Mvec3 {
x: 0.6406833,
y: 0.7085516,
z: -0.29576966,
},
depth: -0.89953375,
feature_id: 0,
contact_exists: false,
};
output0.adjust_offset_a_to_shape_surface(ADJUST_DEPTH_FACTOR);
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
SphereWide,
CuboidWide,
array,
pair_count,
outputs,
convex1contact_manifold_wide_to_convex1contact_manifold
);
}
#[test]
#[wasm_bindgen_test]
fn test_sphere_cuboid_tester_close_at_face() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input = include_bytes!("resource/sphere_cuboid/close_at_face.json");
let input0: InputType = serde_json::from_slice(file_input).expect("file should be proper JSON");
let mut output0 = Convex1ContactManifold {
offset_a: Mvec3 {
x: -2.0001726,
y: -0.00024140495,
z: -1.03123385E-8,
},
normal: Mvec3 {
x: 1.0,
y: 0.00012069206,
z: 5.1557243E-9,
},
depth: -0.0003452301,
feature_id: 0,
contact_exists: true,
};
output0.adjust_offset_a_to_shape_surface(ADJUST_DEPTH_FACTOR);
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
SphereWide,
CuboidWide,
array,
pair_count,
outputs,
convex1contact_manifold_wide_to_convex1contact_manifold
);
}
#[test]
#[wasm_bindgen_test]
fn test_sphere_cuboid_tester_tangent_at_face() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input = include_bytes!("resource/sphere_cuboid/tangent_at_face.json");
let input0: InputType = serde_json::from_slice(file_input).expect("file should be proper JSON");
let mut output0 = Convex1ContactManifold {
offset_a: Mvec3 {
x: -2.0,
y: 0.0,
z: 0.0,
},
normal: Mvec3 {
x: 1.0,
y: 0.0,
z: 0.0,
},
depth: 0.0,
feature_id: 0,
contact_exists: true,
};
output0.adjust_offset_a_to_shape_surface(ADJUST_DEPTH_FACTOR);
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
SphereWide,
CuboidWide,
array,
pair_count,
outputs,
convex1contact_manifold_wide_to_convex1contact_manifold
);
}
#[test]
#[wasm_bindgen_test]
fn test_sphere_cuboid_tester_penetrate_at_face() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input = include_bytes!("resource/sphere_cuboid/penetrate_at_face.json");
let input0: InputType = serde_json::from_slice(file_input).expect("file should be proper JSON");
let mut output0 = Convex1ContactManifold {
offset_a: Mvec3 {
x: -1.95,
y: 0.0,
z: 0.0,
},
normal: Mvec3 {
x: 1.0,
y: 0.0,
z: 0.0,
},
depth: 0.099999905,
feature_id: 0,
contact_exists: true,
};
output0.adjust_offset_a_to_shape_surface(ADJUST_DEPTH_FACTOR);
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
SphereWide,
CuboidWide,
array,
pair_count,
outputs,
convex1contact_manifold_wide_to_convex1contact_manifold
);
}
#[test]
#[wasm_bindgen_test]
fn test_sphere_cuboid_tester_close_at_edge() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input = include_bytes!("resource/sphere_cuboid/close_at_edge.json");
let input0: InputType = serde_json::from_slice(file_input).expect("file should be proper JSON");
#[allow(clippy::approx_constant)]
let mut output0 = Convex1ContactManifold {
offset_a: Mvec3 {
x: -0.3540517,
y: 0.0,
z: -0.3540517,
},
normal: Mvec3 {
x: 0.7071068,
y: 0.0,
z: 0.7071068,
},
depth: -0.0014094114,
feature_id: 0,
contact_exists: true,
};
output0.adjust_offset_a_to_shape_surface(ADJUST_DEPTH_FACTOR);
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
SphereWide,
CuboidWide,
array,
pair_count,
outputs,
convex1contact_manifold_wide_to_convex1contact_manifold
);
}
#[test]
#[wasm_bindgen_test]
fn test_sphere_cuboid_tester_tangent_at_edge() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input = include_bytes!("resource/sphere_cuboid/tangent_at_edge.json");
let input0: InputType = serde_json::from_slice(file_input).expect("file should be proper JSON");
let mut output0 = Convex1ContactManifold {
offset_a: Mvec3 {
x: -0.3535517,
y: 0.0,
z: -0.3535517,
},
normal: Mvec3 {
x: 0.70710677,
y: 0.0,
z: 0.70710677,
},
depth: 4.7683716E-6,
feature_id: 0,
contact_exists: true,
};
output0.adjust_offset_a_to_shape_surface(ADJUST_DEPTH_FACTOR);
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
SphereWide,
CuboidWide,
array,
pair_count,
outputs,
convex1contact_manifold_wide_to_convex1contact_manifold
);
}
#[test]
#[wasm_bindgen_test]
fn test_sphere_cuboid_tester_penetrate_at_edge() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input = include_bytes!("resource/sphere_cuboid/penetrate_at_edge.json");
let input0: InputType = serde_json::from_slice(file_input).expect("file should be proper JSON");
let mut output0 = Convex1ContactManifold {
offset_a: Mvec3 {
x: -0.3485517,
y: 0.0,
z: -0.3485517,
},
normal: Mvec3 {
x: 0.70710677,
y: 0.0,
z: 0.70710677,
},
depth: 0.014146894,
feature_id: 0,
contact_exists: true,
};
output0.adjust_offset_a_to_shape_surface(ADJUST_DEPTH_FACTOR);
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
SphereWide,
CuboidWide,
array,
pair_count,
outputs,
convex1contact_manifold_wide_to_convex1contact_manifold
);
}
#[test]
#[wasm_bindgen_test]
fn test_sphere_cuboid_tester_close_at_vertex() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input = include_bytes!("resource/sphere_cuboid/close_at_vertex.json");
let input0: InputType = serde_json::from_slice(file_input).expect("file should be proper JSON");
let mut output0 = Convex1ContactManifold {
offset_a: Mvec3 {
x: -9.664636E-7,
y: -0.5008364,
z: -9.701952E-7,
},
normal: Mvec3 {
x: 1.9297004E-6,
y: 1.0000005,
z: 1.937151E-6,
},
depth: -0.0016723275,
feature_id: 0,
contact_exists: true,
};
output0.adjust_offset_a_to_shape_surface(ADJUST_DEPTH_FACTOR);
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
SphereWide,
CuboidWide,
array,
pair_count,
outputs,
convex1contact_manifold_wide_to_convex1contact_manifold
);
}
#[test]
#[wasm_bindgen_test]
fn test_sphere_cuboid_tester_tangent_at_vertex() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input = include_bytes!("resource/sphere_cuboid/tangent_at_vertex.json");
let input0: InputType = serde_json::from_slice(file_input).expect("file should be proper JSON");
let mut output0 = Convex1ContactManifold {
offset_a: Mvec3 {
x: -9.872019E-7,
y: -0.50000024,
z: -9.834766E-7,
},
normal: Mvec3 {
x: 1.9744039E-6,
y: 1.0000005,
z: 1.9669533E-6,
},
depth: -5.9604645E-8,
feature_id: 0,
contact_exists: true,
};
output0.adjust_offset_a_to_shape_surface(ADJUST_DEPTH_FACTOR);
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
SphereWide,
CuboidWide,
array,
pair_count,
outputs,
convex1contact_manifold_wide_to_convex1contact_manifold
);
}
#[test]
#[wasm_bindgen_test]
fn test_sphere_cuboid_tester_penetrate_at_vertex() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input = include_bytes!("resource/sphere_cuboid/penetrate_at_vertex.json");
let input0: InputType = serde_json::from_slice(file_input).expect("file should be proper JSON");
let mut output0 = Convex1ContactManifold {
offset_a: Mvec3 {
x: -1.0068344E-6,
y: -0.49500024,
z: -1.0031463E-6,
},
normal: Mvec3 {
x: 2.0340085E-6,
y: 1.0000004,
z: 2.026558E-6,
},
depth: 0.009999871,
feature_id: 0,
contact_exists: true,
};
output0.adjust_offset_a_to_shape_surface(ADJUST_DEPTH_FACTOR);
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
SphereWide,
CuboidWide,
array,
pair_count,
outputs,
convex1contact_manifold_wide_to_convex1contact_manifold
);
}