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::{InfinitePlaneWide, SphereWide};
use crate::traits::PairWideTest;
use crate::{InfinitePlane, Sphere};
wasm_bindgen_test_configure!(run_in_browser);
type InputType = TestInput<Sphere, InfinitePlane>;
#[test]
#[wasm_bindgen_test]
#[cfg(feature = "serde")]
fn test_no_collide() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input = include_bytes!("resource/sphere_infinite_plane/nocollide.json");
let input0: InputType = serde_json::from_slice(file_input).expect("file should be proper JSON");
let output0 = Convex1ContactManifold {
offset_a: Mvec3 {
x: -0.0,
y: -1.0,
z: -0.0,
},
normal: Mvec3 {
x: 0.0,
y: 1.0,
z: 0.0,
},
depth: -99.0,
feature_id: 0,
contact_exists: false,
};
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
SphereWide,
InfinitePlaneWide,
array,
pair_count,
outputs,
convex1contact_manifold_wide_to_convex1contact_manifold
);
}
#[test]
#[wasm_bindgen_test]
#[cfg(feature = "serde")]
fn test_tangent_on_plane() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input = include_bytes!("resource/sphere_infinite_plane/tangent_on_plane.json");
let input0: InputType = serde_json::from_slice(file_input).expect("file should be proper JSON");
let output0 = Convex1ContactManifold {
offset_a: Mvec3 {
x: -0.0,
y: -1.0,
z: -0.0,
},
normal: Mvec3 {
x: 0.0,
y: 1.0,
z: 0.0,
},
depth: 0.0,
feature_id: 0,
contact_exists: true,
};
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
SphereWide,
InfinitePlaneWide,
array,
pair_count,
outputs,
convex1contact_manifold_wide_to_convex1contact_manifold
);
}
#[test]
#[wasm_bindgen_test]
#[cfg(feature = "serde")]
fn test_under_plane() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input = include_bytes!("resource/sphere_infinite_plane/sphere_under_plane.json");
let input0: InputType = serde_json::from_slice(file_input).expect("file should be proper JSON");
let output0 = Convex1ContactManifold {
offset_a: Mvec3 {
x: -0.0,
y: -1.0,
z: -0.0,
},
normal: Mvec3 {
x: 0.0,
y: 1.0,
z: 0.0,
},
depth: 11.0,
feature_id: 0,
contact_exists: true,
};
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
SphereWide,
InfinitePlaneWide,
array,
pair_count,
outputs,
convex1contact_manifold_wide_to_convex1contact_manifold
);
}