#[cfg(test)]
#[cfg(feature = "serde")]
mod tests {
use std::f32::consts::*;
use approx_det::assert_relative_eq;
use wasm_bindgen_test::*;
use crate::collision_tasks::tests::common::{
convex4manifold_wide2convex4contact_manifold, get_input_wide, Convex4ContactManifold,
Mvec3, TestInput,
};
use crate::collision_tasks::ShapeWideTester;
use crate::shapes::{CuboidWide, InfinitePlaneWide};
use crate::traits::PairWideTest;
use crate::{Cuboid, InfinitePlane};
type InputType = TestInput<Cuboid, InfinitePlane>;
wasm_bindgen_test_configure!(run_in_browser);
#[test]
#[cfg(feature = "serde")]
#[wasm_bindgen_test]
fn test_cuboid_infinite_plane_000_4contacts_no_rotation() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input =
include_bytes!("resource/cuboid_infinite_plane/000_4contacts_no_rotation.json");
let input0: InputType =
serde_json::from_slice(file_input).expect("file should be proper JSON");
let output0 = Convex4ContactManifold {
OffsetA0: Mvec3 {
x: 0.5,
y: -0.5,
z: 0.5,
},
OffsetA1: Mvec3 {
x: -0.5,
y: -0.5,
z: -0.5,
},
OffsetA2: Mvec3 {
x: 0.5,
y: -0.5,
z: -0.5,
},
OffsetA3: Mvec3 {
x: -0.5,
y: -0.5,
z: 0.5,
},
Normal: Mvec3 {
x: 0.0,
y: 1.0,
z: 0.0,
},
Depth0: 0.5,
Depth1: 0.5,
Depth2: 0.5,
Depth3: 0.5,
FeatureId0: 0,
FeatureId1: 1,
FeatureId2: 2,
FeatureId3: 3,
Contact0Exists: true,
Contact1Exists: true,
Contact2Exists: true,
Contact3Exists: true,
};
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
CuboidWide,
InfinitePlaneWide,
array,
pair_count,
outputs,
convex4manifold_wide2convex4contact_manifold
);
}
#[test]
#[cfg(feature = "serde")]
#[wasm_bindgen_test]
fn test_cuboid_infinite_plane_001_2contacts_rotate_x_45() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input =
include_bytes!("resource/cuboid_infinite_plane/001_2contacts_rotate_x_45.json");
let input0: InputType =
serde_json::from_slice(file_input).expect("file should be proper JSON");
let output0 = Convex4ContactManifold {
OffsetA0: Mvec3 {
x: 0.5,
y: -FRAC_1_SQRT_2,
z: 0.0,
},
OffsetA1: Mvec3 {
x: -0.5,
y: -FRAC_1_SQRT_2,
z: -0.0,
},
OffsetA2: Mvec3 {
x: 0.0,
y: 0.0,
z: -0.0,
},
OffsetA3: Mvec3 {
x: -0.0,
y: 0.0,
z: 0.0,
},
Normal: Mvec3 {
x: 0.0,
y: 1.0,
z: 0.0,
},
Depth0: 0.207106,
Depth1: 0.207106,
Depth2: 0.0,
Depth3: 0.0,
FeatureId0: 0,
FeatureId1: 1,
FeatureId2: 2,
FeatureId3: 3,
Contact0Exists: true,
Contact1Exists: true,
Contact2Exists: false,
Contact3Exists: false,
};
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
CuboidWide,
InfinitePlaneWide,
array,
pair_count,
outputs,
convex4manifold_wide2convex4contact_manifold
);
}
#[test]
#[cfg(feature = "serde")]
#[wasm_bindgen_test]
fn test_cuboid_infinite_plane_002_4contacts_fully_penetrate_no_rotation() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input = include_bytes!(
"resource/cuboid_infinite_plane/002_4contacts_fully_penetrate_no_rotation.json"
);
let input0: InputType =
serde_json::from_slice(file_input).expect("file should be proper JSON");
let output0 = Convex4ContactManifold {
OffsetA0: Mvec3 {
x: 0.5,
y: -0.5,
z: 0.5,
},
OffsetA1: Mvec3 {
x: -0.5,
y: -0.5,
z: -0.5,
},
OffsetA2: Mvec3 {
x: 0.5,
y: -0.5,
z: -0.5,
},
OffsetA3: Mvec3 {
x: -0.5,
y: -0.5,
z: 0.5,
},
Normal: Mvec3 {
x: 0.0,
y: 1.0,
z: 0.0,
},
Depth0: 5.5,
Depth1: 5.5,
Depth2: 5.5,
Depth3: 5.5,
FeatureId0: 0,
FeatureId1: 1,
FeatureId2: 2,
FeatureId3: 3,
Contact0Exists: true,
Contact1Exists: true,
Contact2Exists: true,
Contact3Exists: true,
};
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
CuboidWide,
InfinitePlaneWide,
array,
pair_count,
outputs,
convex4manifold_wide2convex4contact_manifold
);
}
#[test]
#[cfg(feature = "serde")]
#[wasm_bindgen_test]
#[allow(clippy::approx_constant)]
fn test_cuboid_infinite_plane_003_4contacts_fully_penetrate_rotate_x_45() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input = include_bytes!(
"resource/cuboid_infinite_plane/003_4contacts_fully_penetrate_rotate_x_45.json"
);
let input0: InputType =
serde_json::from_slice(file_input).expect("file should be proper JSON");
let output0 = Convex4ContactManifold {
OffsetA0: Mvec3 {
x: 0.5,
y: -0.707106,
z: 0.0,
},
OffsetA1: Mvec3 {
x: -0.5,
y: 0.0,
z: -0.707106,
},
OffsetA2: Mvec3 {
x: 0.5,
y: 0.0,
z: 0.707106,
},
OffsetA3: Mvec3 {
x: -0.5,
y: -0.707106,
z: 0.0,
},
Normal: Mvec3 {
x: 0.0,
y: 1.0,
z: 0.0,
},
Depth0: 10.707106,
Depth1: 10.0,
Depth2: 10.0,
Depth3: 10.707106,
FeatureId0: 0,
FeatureId1: 1,
FeatureId2: 2,
FeatureId3: 3,
Contact0Exists: true,
Contact1Exists: true,
Contact2Exists: true,
Contact3Exists: true,
};
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
CuboidWide,
InfinitePlaneWide,
array,
pair_count,
outputs,
convex4manifold_wide2convex4contact_manifold
);
}
#[test]
#[cfg(feature = "serde")]
#[wasm_bindgen_test]
fn test_cuboid_infinite_plane_004_1contacts_rotate_x_45_z_45() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input =
include_bytes!("resource/cuboid_infinite_plane/004_1contacts_rotate_x_45_z_45.json");
let input0: InputType =
serde_json::from_slice(file_input).expect("file should be proper JSON");
let output0 = Convex4ContactManifold {
OffsetA0: Mvec3 {
x: 0.0,
y: -0.8535535,
z: -0.1464,
},
OffsetA1: Mvec3 {
x: -0.0,
y: -0.0,
z: 0.0,
},
OffsetA2: Mvec3 {
x: 0.0,
y: 0.0,
z: 0.0,
},
OffsetA3: Mvec3 {
x: -0.0,
y: -0.0,
z: 0.0,
},
Normal: Mvec3 {
x: 0.0,
y: 1.0,
z: 0.0,
},
Depth0: 0.053553,
Depth1: 0.0,
Depth2: 0.0,
Depth3: 0.0,
FeatureId0: 0,
FeatureId1: 1,
FeatureId2: 2,
FeatureId3: 3,
Contact0Exists: true,
Contact1Exists: false,
Contact2Exists: false,
Contact3Exists: false,
};
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
CuboidWide,
InfinitePlaneWide,
array,
pair_count,
outputs,
convex4manifold_wide2convex4contact_manifold
);
}
#[test]
#[cfg(feature = "serde")]
#[wasm_bindgen_test]
fn test_cuboid_infinite_plane_005_nocollide() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input = include_bytes!("resource/cuboid_infinite_plane/005_nocollide.json");
let input0: InputType =
serde_json::from_slice(file_input).expect("file should be proper JSON");
let output0 = Convex4ContactManifold {
OffsetA0: Mvec3 {
x: 0.0,
y: -0.0,
z: -0.0,
},
OffsetA1: Mvec3 {
x: -0.0,
y: -0.0,
z: 0.0,
},
OffsetA2: Mvec3 {
x: 0.0,
y: 0.0,
z: 0.0,
},
OffsetA3: Mvec3 {
x: -0.0,
y: -0.0,
z: 0.0,
},
Normal: Mvec3 {
x: 1.0,
y: 0.0,
z: 0.0,
},
Depth0: 0.0,
Depth1: 0.0,
Depth2: 0.0,
Depth3: 0.0,
FeatureId0: 0,
FeatureId1: 1,
FeatureId2: 2,
FeatureId3: 3,
Contact0Exists: false,
Contact1Exists: false,
Contact2Exists: false,
Contact3Exists: false,
};
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
CuboidWide,
InfinitePlaneWide,
array,
pair_count,
outputs,
convex4manifold_wide2convex4contact_manifold
);
}
#[test]
#[allow(clippy::approx_constant)]
#[cfg(feature = "serde")]
#[wasm_bindgen_test]
fn test_cuboid_infinite_plane_006_3contacts_rotate_x_45_z_45() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input =
include_bytes!("resource/cuboid_infinite_plane/006_3contacts_rotate_x_45_z_45.json");
let input0: InputType =
serde_json::from_slice(file_input).expect("file should be proper JSON");
let output0 = Convex4ContactManifold {
OffsetA0: Mvec3 {
x: 0.0,
y: -0.8535535,
z: -0.146446,
},
OffsetA1: Mvec3 {
x: 0.707106,
y: -0.353553,
z: 0.353553,
},
OffsetA2: Mvec3 {
x: -0.707106,
y: -0.353553,
z: 0.353553,
},
OffsetA3: Mvec3 {
x: -0.0,
y: -0.0,
z: 0.0,
},
Normal: Mvec3 {
x: 0.0,
y: 1.0,
z: 0.0,
},
Depth0: 0.603553,
Depth1: 0.103553,
Depth2: 0.103553,
Depth3: 0.0,
FeatureId0: 0,
FeatureId1: 1,
FeatureId2: 2,
FeatureId3: 3,
Contact0Exists: true,
Contact1Exists: true,
Contact2Exists: true,
Contact3Exists: false,
};
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
CuboidWide,
InfinitePlaneWide,
array,
pair_count,
outputs,
convex4manifold_wide2convex4contact_manifold
);
}
#[test]
#[cfg(feature = "serde")]
#[wasm_bindgen_test]
fn test_cuboid_infinite_plane_007_4contacts_fully_penetrate_2_rotate_x_30_z_30() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input = include_bytes!(
"resource/cuboid_infinite_plane/007_4contacts_fully_penetrate_2_rotate_x_30_z_30.json"
);
let input0: InputType =
serde_json::from_slice(file_input).expect("file should be proper JSON");
let output0 = Convex4ContactManifold {
OffsetA0: Mvec3 {
x: -0.18301274,
y: -0.84150636,
z: 0.09150636,
},
OffsetA1: Mvec3 {
x: 0.6830127,
y: 0.09150633,
z: -0.5245191,
},
OffsetA2: Mvec3 {
x: 0.6830127,
y: -0.40849367,
z: 0.34150636,
},
OffsetA3: Mvec3 {
x: -0.18301272,
y: -0.34150636,
z: -0.7745191,
},
Normal: Mvec3 {
x: 0.0,
y: 1.0,
z: 0.0,
},
Depth0: 10.841506,
Depth1: 9.908494,
Depth2: 10.408494,
Depth3: 10.341506,
FeatureId0: 0,
FeatureId1: 1,
FeatureId2: 2,
FeatureId3: 3,
Contact0Exists: true,
Contact1Exists: true,
Contact2Exists: true,
Contact3Exists: true,
};
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
CuboidWide,
InfinitePlaneWide,
array,
pair_count,
outputs,
convex4manifold_wide2convex4contact_manifold
);
}
#[test]
#[cfg(feature = "serde")]
#[wasm_bindgen_test]
fn test_cuboid_infinite_plane_008_4contacts_fully_penetrate_3_rotate_z_60() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input = include_bytes!(
"resource/cuboid_infinite_plane/008_4contacts_fully_penetrate_3_rotate_z_60.json"
);
let input0: InputType =
serde_json::from_slice(file_input).expect("file should be proper JSON");
let output0 = Convex4ContactManifold {
OffsetA0: Mvec3 {
x: 0.1830127,
y: -0.6830127,
z: 0.5,
},
OffsetA1: Mvec3 {
x: -0.6830127,
y: -0.1830127,
z: -0.5,
},
OffsetA2: Mvec3 {
x: 0.1830127,
y: -0.6830127,
z: -0.5,
},
OffsetA3: Mvec3 {
x: -0.6830127,
y: -0.183013,
z: 0.5,
},
Normal: Mvec3 {
x: 0.0,
y: 1.0,
z: 0.0,
},
Depth0: 10.683013,
Depth1: 10.183013,
Depth2: 10.683013,
Depth3: 10.183013,
FeatureId0: 0,
FeatureId1: 1,
FeatureId2: 2,
FeatureId3: 3,
Contact0Exists: true,
Contact1Exists: true,
Contact2Exists: true,
Contact3Exists: true,
};
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
CuboidWide,
InfinitePlaneWide,
array,
pair_count,
outputs,
convex4manifold_wide2convex4contact_manifold
);
}
}