use approx_det::assert_relative_eq;
use wasm_bindgen_test::*;
use crate::collision_tasks::tests::common::{
convex2contact_manifold_wide_to_convex2contact_manifold, get_input_wide,
Convex2ContactManifold, Mvec3, TestInput,
};
use crate::collision_tasks::ShapeWideTester;
use crate::shapes::{CapsuleWide, InfinitePlaneWide};
use crate::traits::PairWideTest;
use crate::{Capsule, InfinitePlane};
wasm_bindgen_test_configure!(run_in_browser);
type InputType = TestInput<Capsule, InfinitePlane>;
#[test]
#[wasm_bindgen_test]
#[cfg(feature = "serde")]
fn test_capule_infinite_plane_000_nocollide() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input = include_bytes!("resource/capsule_infinite_plane/000_nocollide.json");
let input0: InputType = serde_json::from_slice(file_input).expect("file should be proper JSON");
let output0 = Convex2ContactManifold {
OffsetA0: Mvec3 {
x: 0.0,
y: 0.0,
z: 0.0,
},
OffsetA1: Mvec3 {
x: 0.0,
y: -1.0,
z: 0.0,
},
Normal: Mvec3 {
x: 0.0,
y: 1.0,
z: 0.0,
},
Depth0: -5.0,
Depth1: -4.0,
FeatureId0: 0,
FeatureId1: 1,
Contact0Exists: false,
Contact1Exists: false,
};
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
CapsuleWide,
InfinitePlaneWide,
array,
pair_count,
outputs,
convex2contact_manifold_wide_to_convex2contact_manifold
);
}
#[test]
#[wasm_bindgen_test]
#[cfg(feature = "serde")]
fn test_capule_infinite_plane_001_capsule_hemishpere_tangent() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input =
include_bytes!("resource/capsule_infinite_plane/001_capsule_one_hemisphere_tangent.json");
let input0: InputType = serde_json::from_slice(file_input).expect("file should be proper JSON");
let output0 = Convex2ContactManifold {
OffsetA0: Mvec3 {
x: 0.0,
y: -0.0,
z: 0.0,
},
OffsetA1: Mvec3 {
x: 0.0,
y: -1.0,
z: 0.0,
},
Normal: Mvec3 {
x: 0.0,
y: 1.0,
z: 0.0,
},
Depth0: -1.0,
Depth1: -0.0,
FeatureId0: 0,
FeatureId1: 1,
Contact0Exists: false,
Contact1Exists: true,
};
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
CapsuleWide,
InfinitePlaneWide,
array,
pair_count,
outputs,
convex2contact_manifold_wide_to_convex2contact_manifold
);
}
#[test]
#[wasm_bindgen_test]
#[cfg(feature = "serde")]
fn test_capule_infinite_plane_002_capsule_one_hemishpere_penetrate() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input =
include_bytes!("resource/capsule_infinite_plane/002_capsule_one_hemisphere_penetrate.json");
let input0: InputType = serde_json::from_slice(file_input).expect("file should be proper JSON");
let output0 = Convex2ContactManifold {
OffsetA0: Mvec3 {
x: 0.0,
y: -0.0,
z: 0.0,
},
OffsetA1: Mvec3 {
x: 0.0,
y: -1.0,
z: 0.0,
},
Normal: Mvec3 {
x: 0.0,
y: 1.0,
z: 0.0,
},
Depth0: -0.8,
Depth1: 0.2,
FeatureId0: 0,
FeatureId1: 1,
Contact0Exists: false,
Contact1Exists: true,
};
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
CapsuleWide,
InfinitePlaneWide,
array,
pair_count,
outputs,
convex2contact_manifold_wide_to_convex2contact_manifold
);
}
#[test]
#[wasm_bindgen_test]
#[cfg(feature = "serde")]
fn test_capule_infinite_plane_003_capsule_both_hemishpere_tangent() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input =
include_bytes!("resource/capsule_infinite_plane/003_capsule_both_hemisphere_tangent.json");
let input0: InputType = serde_json::from_slice(file_input).expect("file should be proper JSON");
let output0 = Convex2ContactManifold {
OffsetA0: Mvec3 {
x: -0.5,
y: -0.5,
z: 0.0,
},
OffsetA1: Mvec3 {
x: 0.5,
y: -0.5,
z: 0.0,
},
Normal: Mvec3 {
x: 0.0,
y: 1.0,
z: 0.0,
},
Depth0: 0.0,
Depth1: 0.0,
FeatureId0: 0,
FeatureId1: 1,
Contact0Exists: true,
Contact1Exists: true,
};
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
CapsuleWide,
InfinitePlaneWide,
array,
pair_count,
outputs,
convex2contact_manifold_wide_to_convex2contact_manifold
);
}
#[test]
#[wasm_bindgen_test]
#[cfg(feature = "serde")]
fn test_capule_infinite_plane_004_capsule_both_hemishpere_penetrate() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input = include_bytes!(
"resource/capsule_infinite_plane/004_capsule_both_hemisphere_penetrate.json"
);
let input0: InputType = serde_json::from_slice(file_input).expect("file should be proper JSON");
let output0 = Convex2ContactManifold {
OffsetA0: Mvec3 {
x: -0.5,
y: -0.5,
z: 0.0,
},
OffsetA1: Mvec3 {
x: 0.5,
y: -0.5,
z: 0.0,
},
Normal: Mvec3 {
x: 0.0,
y: 1.0,
z: 0.0,
},
Depth0: 0.5,
Depth1: 0.5,
FeatureId0: 0,
FeatureId1: 1,
Contact0Exists: true,
Contact1Exists: true,
};
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
CapsuleWide,
InfinitePlaneWide,
array,
pair_count,
outputs,
convex2contact_manifold_wide_to_convex2contact_manifold
);
}