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::CylinderWide;
use crate::traits::PairWideTest;
use crate::Cylinder;
wasm_bindgen_test_configure!(run_in_browser);
type InputType = TestInput<Cylinder, Cylinder>;
const ADJUST_DEPTH_FACTOR: f32 = 1.0;
#[test]
#[wasm_bindgen_test]
fn test_cylinder_cylinder_001_cylinder_a_in_cylinder_b() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input = include_bytes!("resource/cylinder_cylinder/001_cylinder_a_in_cylinder_b.json");
let input0: InputType = serde_json::from_slice(file_input).expect("file should be proper JSON");
let output0 = Convex4ContactManifold {
OffsetA0: Mvec3 {
x: 0.07071093,
y: -0.5000001,
z: 0.07071093,
},
OffsetA1: Mvec3 {
x: 0.07071093,
y: 0.49999988,
z: 0.07071093,
},
OffsetA2: Mvec3 {
x: 0.070710935,
y: -0.099999994,
z: 0.070710935,
},
OffsetA3: Mvec3 {
x: 0.070710935,
y: -0.099999994,
z: 0.070710935,
},
Normal: Mvec3 {
x: -0.70710677,
y: 2.3507727e-7,
z: -0.70710677,
},
Depth0: 0.45857906,
Depth1: 0.45857906,
Depth2: -0.041421,
Depth3: -0.041421,
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!(
CylinderWide,
CylinderWide,
array,
pair_count,
outputs,
convex4manifold_wide2convex4contact_manifold
);
}
#[test]
#[wasm_bindgen_test]
fn test_cylinder_cylinder_002_cylinder_b_in_cylinder_a() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input = include_bytes!("resource/cylinder_cylinder/002_cylinder_b_in_cylinder_a.json");
let input0: InputType = serde_json::from_slice(file_input).expect("file should be proper JSON");
let output0 = Convex4ContactManifold {
OffsetA0: Mvec3 {
x: 0.3535536,
y: -0.59999996,
z: 0.3535536,
},
OffsetA1: Mvec3 {
x: 0.3535536,
y: 0.40000007,
z: 0.3535536,
},
OffsetA2: Mvec3 {
x: 0.35355356,
y: -0.09999996,
z: 0.35355356,
},
OffsetA3: Mvec3 {
x: 0.35355356,
y: -0.09999996,
z: 0.35355356,
},
Normal: Mvec3 {
x: -0.70710677,
y: -1.1753862e-7,
z: -0.70710677,
},
Depth0: 0.4585789,
Depth1: 0.4585789,
Depth2: 0.3585789,
Depth3: 0.3585789,
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!(
CylinderWide,
CylinderWide,
array,
pair_count,
outputs,
convex4manifold_wide2convex4contact_manifold
);
}
#[test]
#[wasm_bindgen_test]
fn test_cylinder_cylinder_003_cylinder_a_cap_in_cylinder_b_side() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input =
include_bytes!("resource/cylinder_cylinder/003_cylinder_a_cap_in_cylinder_b_side.json");
let input0: InputType = serde_json::from_slice(file_input).expect("file should be proper JSON");
let mut output0 = Convex4ContactManifold {
OffsetA0: Mvec3 {
x: -0.23401044,
y: 0.45443374,
z: -0.17763674,
},
OffsetA1: Mvec3 {
x: 0.46288264,
y: 0.78515255,
z: 0.3514805,
},
OffsetA2: Mvec3 {
x: -7.4505806e-8,
y: 1.1000001,
z: 0.0,
},
OffsetA3: Mvec3 {
x: -7.4505806e-8,
y: 1.1000001,
z: 0.0,
},
Normal: Mvec3 {
x: 0.28147334,
y: -0.93541443,
z: 0.21394578,
},
Depth0: 0.5832349,
Depth1: 0.22968166,
Depth2: -0.10690454,
Depth3: -0.10690454,
FeatureId0: 0,
FeatureId1: 1,
FeatureId2: 2,
FeatureId3: 3,
Contact0Exists: true,
Contact1Exists: true,
Contact2Exists: false,
Contact3Exists: false,
};
output0.adjust_offset_a_to_shape_surface(ADJUST_DEPTH_FACTOR);
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
CylinderWide,
CylinderWide,
array,
pair_count,
outputs,
convex4manifold_wide2convex4contact_manifold,
None,
epsilon = 1e-3f32
);
}
#[test]
#[wasm_bindgen_test]
fn test_cylinder_cylinder_004_cylinder_a_cap_part_in_cylinder_b_side() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input = include_bytes!(
"resource/cylinder_cylinder/004_cylinder_a_cap_part_in_cylinder_b_side.json"
);
let input0: InputType = serde_json::from_slice(file_input).expect("file should be proper JSON");
let output0 = Convex4ContactManifold {
OffsetA0: Mvec3 {
x: -0.46060154,
y: 0.90158015,
z: -0.19768102,
},
OffsetA1: Mvec3 {
x: -0.46060154,
y: 0.90158015,
z: -0.19768102,
},
OffsetA2: Mvec3 {
x: -0.5046433,
y: 1.289778,
z: -0.07133457,
},
OffsetA3: Mvec3 {
x: -0.5046433,
y: 1.289778,
z: -0.07133457,
},
Normal: Mvec3 {
x: 0.7103995,
y: -0.6587957,
z: 0.2476312,
},
Depth0: 0.53231347,
Depth1: 0.53231347,
Depth2: 0.2880678,
Depth3: 0.2880678,
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!(
CylinderWide,
CylinderWide,
array,
pair_count,
outputs,
convex4manifold_wide2convex4contact_manifold
);
}
#[test]
#[wasm_bindgen_test]
fn test_cylinder_cylinder_006_cylinder_a_cap_full_in_cylinder_b_cap_diff_radius() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input = include_bytes!(
"resource/cylinder_cylinder/006_cylinder_a_cap_full_in_cylinder_b_cap_diff_radius.json"
);
let input0: InputType = serde_json::from_slice(file_input).expect("file should be proper JSON");
let mut output0 = Convex4ContactManifold {
OffsetA0: Mvec3 {
x: 0.3,
y: 0.20000005,
z: 0.0,
},
OffsetA1: Mvec3 {
x: -0.3,
y: 0.20000005,
z: 0.0,
},
OffsetA2: Mvec3 {
x: 0.0,
y: 0.20000005,
z: 0.3,
},
OffsetA3: Mvec3 {
x: 0.0,
y: 0.20000005,
z: -0.3,
},
Normal: Mvec3 {
x: 0.0,
y: -1.0,
z: 0.0,
},
Depth0: 0.79999995,
Depth1: 0.79999995,
Depth2: 0.79999995,
Depth3: 0.79999995,
FeatureId0: 0,
FeatureId1: 1,
FeatureId2: 2,
FeatureId3: 3,
Contact0Exists: true,
Contact1Exists: true,
Contact2Exists: true,
Contact3Exists: true,
};
output0.adjust_offset_a_to_shape_surface(ADJUST_DEPTH_FACTOR);
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
CylinderWide,
CylinderWide,
array,
pair_count,
outputs,
convex4manifold_wide2convex4contact_manifold
);
}
#[test]
#[wasm_bindgen_test]
fn test_cylinder_cylinder_007_cylinder_a_side_cross_cylinder_b_side_parallel() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input = include_bytes!(
"resource/cylinder_cylinder/007_cylinder_a_side_cross_cylinder_b_side_parallel.json"
);
let input0: InputType = serde_json::from_slice(file_input).expect("file should be proper JSON");
let mut output0 = Convex4ContactManifold {
OffsetA0: Mvec3 {
x: -0.023606807,
y: -1.0,
z: -0.047213614,
},
OffsetA1: Mvec3 {
x: -0.023606807,
y: 1.0,
z: -0.047213614,
},
OffsetA2: Mvec3 {
x: 0.2,
y: 0.0,
z: 0.4,
},
OffsetA3: Mvec3 {
x: 0.2,
y: 0.0,
z: 0.4,
},
Normal: Mvec3 {
x: -0.44721356,
y: 0.0,
z: -0.8944271,
},
Depth0: 0.5527864,
Depth1: 0.5527864,
Depth2: 0.052786335,
Depth3: 0.052786335,
FeatureId0: 0,
FeatureId1: 1,
FeatureId2: 2,
FeatureId3: 3,
Contact0Exists: true,
Contact1Exists: true,
Contact2Exists: false,
Contact3Exists: false,
};
output0.adjust_offset_a_to_shape_surface(ADJUST_DEPTH_FACTOR);
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
CylinderWide,
CylinderWide,
array,
pair_count,
outputs,
convex4manifold_wide2convex4contact_manifold
);
}
#[test]
#[wasm_bindgen_test]
fn test_cylinder_cylinder_008_cylinder_a_side_cross_cylinder_b_side_rotation() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input = include_bytes!(
"resource/cylinder_cylinder/008_cylinder_a_side_cross_cylinder_b_side_rotation.json"
);
let input0: InputType = serde_json::from_slice(file_input).expect("file should be proper JSON");
let mut output0 = Convex4ContactManifold {
OffsetA0: Mvec3 {
x: -0.3373449,
y: -0.04493175,
z: -0.16579545,
},
OffsetA1: Mvec3 {
x: -0.3373449,
y: -0.04493175,
z: -0.16579545,
},
OffsetA2: Mvec3 {
x: 0.03999999,
y: 0.009999998,
z: 0.2,
},
OffsetA3: Mvec3 {
x: 0.03999999,
y: 0.009999998,
z: 0.2,
},
Normal: Mvec3 {
x: -0.89746773,
y: -1.7136335e-7,
z: -0.44108033,
},
Depth0: 0.8758856,
Depth1: 0.8758856,
Depth2: 0.37588564,
Depth3: 0.37588564,
FeatureId0: 0,
FeatureId1: 1,
FeatureId2: 2,
FeatureId3: 3,
Contact0Exists: true,
Contact1Exists: false,
Contact2Exists: false,
Contact3Exists: false,
};
output0.adjust_offset_a_to_shape_surface(ADJUST_DEPTH_FACTOR);
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
CylinderWide,
CylinderWide,
array,
pair_count,
outputs,
convex4manifold_wide2convex4contact_manifold
);
}
#[test]
#[wasm_bindgen_test]
fn test_cylinder_cylinder_009_cylinder_a_side_cross_cylinder_b_side_perpendicular() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input = include_bytes!(
"resource/cylinder_cylinder/009_cylinder_a_side_cross_cylinder_b_side_perpendicular.json"
);
let input0: InputType = serde_json::from_slice(file_input).expect("file should be proper JSON");
let mut output0 = Convex4ContactManifold {
OffsetA0: Mvec3 {
x: 3.4049153e-6,
y: 0.009997733,
z: -0.3,
},
OffsetA1: Mvec3 {
x: 3.4049153e-6,
y: 0.009997733,
z: -0.3,
},
OffsetA2: Mvec3 {
x: 0.04,
y: 0.01,
z: 0.2,
},
OffsetA3: Mvec3 {
x: 0.04,
y: 0.01,
z: 0.2,
},
Normal: Mvec3 {
x: 0.0,
y: 0.0,
z: -1.0,
},
Depth0: 0.8,
Depth1: 0.8,
Depth2: 0.3,
Depth3: 0.3,
FeatureId0: 0,
FeatureId1: 1,
FeatureId2: 2,
FeatureId3: 3,
Contact0Exists: true,
Contact1Exists: false,
Contact2Exists: false,
Contact3Exists: false,
};
output0.adjust_offset_a_to_shape_surface(ADJUST_DEPTH_FACTOR);
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
CylinderWide,
CylinderWide,
array,
pair_count,
outputs,
convex4manifold_wide2convex4contact_manifold
);
}
#[test]
#[wasm_bindgen_test]
fn test_cylinder_cylinder_010_cylinder_a_cap_cross_cylinder_b_cap() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input =
include_bytes!("resource/cylinder_cylinder/010_cylinder_a_cap_cross_cylinder_b_cap.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: 1.0,
z: 0.14023471,
},
OffsetA1: Mvec3 {
x: 0.0,
y: 1.0,
z: -0.5,
},
OffsetA2: Mvec3 {
x: -0.47422338,
y: 1.0,
z: -0.1213938,
},
OffsetA3: Mvec3 {
x: 0.47422338,
y: 1.0,
z: -0.1213938,
},
Normal: Mvec3 {
x: 0.0,
y: -1.0,
z: 0.0,
},
Depth0: 0.2874384,
Depth1: -0.2497822,
Depth2: 0.06790607,
Depth3: 0.06790607,
FeatureId0: 0,
FeatureId1: 1,
FeatureId2: 2,
FeatureId3: 3,
Contact0Exists: true,
Contact1Exists: false,
Contact2Exists: true,
Contact3Exists: true,
};
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
CylinderWide,
CylinderWide,
array,
pair_count,
outputs,
convex4manifold_wide2convex4contact_manifold
);
}
#[test]
#[wasm_bindgen_test]
fn test_cylinder_cylinder_011_cylinder_a_cross_cylinder_b_both_side_and_cap() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input = include_bytes!(
"resource/cylinder_cylinder/011_cylinder_a_cross_cylinder_b_both_side_and_cap.json"
);
let input0: InputType = serde_json::from_slice(file_input).expect("file should be proper JSON");
let mut output0 = Convex4ContactManifold {
OffsetA0: Mvec3 {
x: -0.4,
y: -0.1499264,
z: 1.37239695e-5,
},
OffsetA1: Mvec3 {
x: -0.4,
y: -0.1499264,
z: 1.37239695e-5,
},
OffsetA2: Mvec3 {
x: 0.1,
y: -0.10000001,
z: 0.050000004,
},
OffsetA3: Mvec3 {
x: 0.1,
y: -0.10000001,
z: 0.050000004,
},
Normal: Mvec3 {
x: -1.0,
y: 1.19147444e-7,
z: -1.1899542e-7,
},
Depth0: 0.9000001,
Depth1: 0.9000001,
Depth2: 0.40000013,
Depth3: 0.40000013,
FeatureId0: 0,
FeatureId1: 1,
FeatureId2: 2,
FeatureId3: 3,
Contact0Exists: true,
Contact1Exists: false,
Contact2Exists: false,
Contact3Exists: false,
};
output0.adjust_offset_a_to_shape_surface(ADJUST_DEPTH_FACTOR);
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
CylinderWide,
CylinderWide,
array,
pair_count,
outputs,
convex4manifold_wide2convex4contact_manifold,
None,
epsilon = 1e-3f32
);
}
#[test]
#[wasm_bindgen_test]
fn test_cylinder_cylinder_012_cylinder_a_cap_and_side_part_in_cylinder_b_side() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input = include_bytes!(
"resource/cylinder_cylinder/012_cylinder_a_cap_and_side_part_in_cylinder_b_side.json"
);
let input0: InputType = serde_json::from_slice(file_input).expect("file should be proper JSON");
let output0 = Convex4ContactManifold {
OffsetA0: Mvec3 {
x: -0.15965775,
y: -0.18314391,
z: -0.47382605,
},
OffsetA1: Mvec3 {
x: -0.15965766,
y: 0.67507315,
z: -0.473826,
},
OffsetA2: Mvec3 {
x: -0.14834705,
y: -0.24999997,
z: -0.47763208,
},
OffsetA3: Mvec3 {
x: -0.14834705,
y: -0.24999997,
z: -0.47763208,
},
Normal: Mvec3 {
x: 0.3189314,
y: 5.9604645e-8,
z: 0.947778,
},
Depth0: 0.8285941,
Depth1: 0.34039643,
Depth2: -0.2873753,
Depth3: -0.2873753,
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!(
CylinderWide,
CylinderWide,
array,
pair_count,
outputs,
convex4manifold_wide2convex4contact_manifold
);
}
#[test]
#[wasm_bindgen_test]
fn test_cylinder_cylinder_013_cylinder_a_cap_and_side_part_in_cylinder_b_cap() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input = include_bytes!(
"resource/cylinder_cylinder/013_cylinder_a_cap_and_side_part_in_cylinder_b_cap.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.3913837,
z: -0.5000001,
},
OffsetA1: Mvec3 {
x: 0.0,
y: 0.9999999,
z: -0.50000024,
},
OffsetA2: Mvec3 {
x: 0.0,
y: 0.6727941,
z: -0.5000001,
},
OffsetA3: Mvec3 {
x: 0.0,
y: 0.6727941,
z: -0.5000001,
},
Normal: Mvec3 {
x: 0.0,
y: -0.34202003,
z: 0.93969274,
},
Depth0: 0.3488654,
Depth1: 0.82474667,
Depth2: 0.21283567,
Depth3: 0.21283567,
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!(
CylinderWide,
CylinderWide,
array,
pair_count,
outputs,
convex4manifold_wide2convex4contact_manifold
);
}
#[test]
#[wasm_bindgen_test]
fn test_cylinder_cylinder_014_cylinder_a_side_tangent_with_cylinder_b_side_parallel() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input = include_bytes!(
"resource/cylinder_cylinder/014_cylinder_a_side_tangent_with_cylinder_b_side_parallel.json"
);
let input0: InputType = serde_json::from_slice(file_input).expect("file should be proper JSON");
let mut output0 = Convex4ContactManifold::default();
output0.adjust_offset_a_to_shape_surface(ADJUST_DEPTH_FACTOR);
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
CylinderWide,
CylinderWide,
array,
pair_count,
outputs,
convex4manifold_wide2convex4contact_manifold
);
}
#[test]
#[wasm_bindgen_test]
fn test_cylinder_cylinder_015_cylinder_a_side_tangent_with_cylinder_b_side_one_point() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input = include_bytes!(
"resource/cylinder_cylinder/015_cylinder_a_side_tangent_with_cylinder_b_side_one_point.json"
);
let input0: InputType = serde_json::from_slice(file_input).expect("file should be proper JSON");
let mut output0 = Convex4ContactManifold::default();
output0.adjust_offset_a_to_shape_surface(ADJUST_DEPTH_FACTOR);
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
CylinderWide,
CylinderWide,
array,
pair_count,
outputs,
convex4manifold_wide2convex4contact_manifold
);
}
#[test]
#[wasm_bindgen_test]
fn test_cylinder_cylinder_016_cylinder_a_side_tangent_with_cylinder_b_cap_parallel() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input = include_bytes!(
"resource/cylinder_cylinder/016_cylinder_a_side_tangent_with_cylinder_b_cap_parallel.json"
);
let input0: InputType = serde_json::from_slice(file_input).expect("file should be proper JSON");
let mut output0 = Convex4ContactManifold::default();
output0.adjust_offset_a_to_shape_surface(ADJUST_DEPTH_FACTOR);
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
CylinderWide,
CylinderWide,
array,
pair_count,
outputs,
convex4manifold_wide2convex4contact_manifold,
None,
epsilon = 1e-3f32
);
}
#[test]
#[wasm_bindgen_test]
fn test_cylinder_cylinder_017_cylinder_a_side_tangent_with_cylinder_b_cap_circle() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input = include_bytes!(
"resource/cylinder_cylinder/017_cylinder_a_side_tangent_with_cylinder_b_cap_circle.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: 1.0,
z: -0.5,
},
OffsetA1: Mvec3 {
x: 0.0,
y: 1.0,
z: -0.5,
},
OffsetA2: Mvec3 {
x: 0.0,
y: 1.0,
z: -0.5,
},
OffsetA3: Mvec3 {
x: 0.0,
y: 1.0,
z: -0.5,
},
Normal: Mvec3 {
x: 0.0,
y: 0.0,
z: 1.0,
},
Depth0: 0.0,
Depth1: 0.0,
Depth2: -0.5,
Depth3: -0.5,
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!(
CylinderWide,
CylinderWide,
array,
pair_count,
outputs,
convex4manifold_wide2convex4contact_manifold
);
}
#[test]
#[wasm_bindgen_test]
fn test_cylinder_cylinder_018_cylinder_a_circle_tangent_with_cylinder_b_circle() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input = include_bytes!(
"resource/cylinder_cylinder/018_cylinder_a_circle_tangent_with_cylinder_b_circle.json"
);
let input0: InputType = serde_json::from_slice(file_input).expect("file should be proper JSON");
let output0 = Convex4ContactManifold {
OffsetA0: Mvec3 {
x: 0.00016194589,
y: 0.9998382,
z: -0.5000001,
},
OffsetA1: Mvec3 {
x: 0.00016194589,
y: 0.9998382,
z: -0.5000001,
},
OffsetA2: Mvec3 {
x: 0.9998382,
y: 0.9998382,
z: -0.49967623,
},
OffsetA3: Mvec3 {
x: 0.9998382,
y: 0.9998382,
z: -0.49967623,
},
Normal: Mvec3 {
x: -0.00032396993,
y: -0.00032395025,
z: 1.0,
},
Depth0: 1.1920928e-7,
Depth1: 1.1920928e-7,
Depth2: -0.5003238,
Depth3: -0.5003238,
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!(
CylinderWide,
CylinderWide,
array,
pair_count,
outputs,
convex4manifold_wide2convex4contact_manifold
);
}
#[test]
#[wasm_bindgen_test]
fn test_cylinder_cylinder_020_cylinder_a_cap_tangent_with_cylinder_b_cap_part() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input = include_bytes!(
"resource/cylinder_cylinder/020_cylinder_a_cap_tangent_with_cylinder_b_cap_part.json"
);
let input0: InputType = serde_json::from_slice(file_input).expect("file should be proper JSON");
let mut output0 = Convex4ContactManifold {
OffsetA0: Mvec3 {
x: -0.12360678,
y: 1.0,
z: 0.24721356,
},
OffsetA1: Mvec3 {
x: 0.2236068,
y: 1.0,
z: -0.4472136,
},
OffsetA2: Mvec3 {
x: -0.38588986,
y: 1.0,
z: -0.31794494,
},
OffsetA3: Mvec3 {
x: 0.48588988,
y: 1.0,
z: 0.11794494,
},
Normal: Mvec3 {
x: -1.2800001e-7,
y: -1.0,
z: 2.5600002e-7,
},
Depth0: 0.0,
Depth1: 0.0,
Depth2: 0.0,
Depth3: 0.0,
FeatureId0: 0,
FeatureId1: 1,
FeatureId2: 2,
FeatureId3: 3,
Contact0Exists: true,
Contact1Exists: true,
Contact2Exists: true,
Contact3Exists: true,
};
output0.adjust_offset_a_to_shape_surface(ADJUST_DEPTH_FACTOR);
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
CylinderWide,
CylinderWide,
array,
pair_count,
outputs,
convex4manifold_wide2convex4contact_manifold
);
}
#[test]
#[wasm_bindgen_test]
fn test_cylinder_cylinder_021_cylinder_a_cap_close_to_cylinder_b_cap_parallel() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input = include_bytes!(
"resource/cylinder_cylinder/021_cylinder_a_cap_close_to_cylinder_b_cap_parallel.json"
);
let input0: InputType = serde_json::from_slice(file_input).expect("file should be proper JSON");
let mut output0 = Convex4ContactManifold::default();
output0.adjust_offset_a_to_shape_surface(ADJUST_DEPTH_FACTOR);
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
CylinderWide,
CylinderWide,
array,
pair_count,
outputs,
convex4manifold_wide2convex4contact_manifold
);
}
#[test]
#[wasm_bindgen_test]
fn test_cylinder_cylinder_022_cylinder_a_cap_close_to_cylinder_b_cap_perpendicular() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input = include_bytes!(
"resource/cylinder_cylinder/022_cylinder_a_cap_close_to_cylinder_b_cap_perpendicular.json"
);
let input0: InputType = serde_json::from_slice(file_input).expect("file should be proper JSON");
let mut output0 = Convex4ContactManifold::default();
output0.adjust_offset_a_to_shape_surface(ADJUST_DEPTH_FACTOR);
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
CylinderWide,
CylinderWide,
array,
pair_count,
outputs,
convex4manifold_wide2convex4contact_manifold
);
}
#[test]
#[wasm_bindgen_test]
fn test_cylinder_cylinder_023_cylinder_a_cap_close_to_cylinder_b_side_parallel() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input = include_bytes!(
"resource/cylinder_cylinder/023_cylinder_a_cap_close_to_cylinder_b_side_parallel.json"
);
let input0: InputType = serde_json::from_slice(file_input).expect("file should be proper JSON");
let mut output0 = Convex4ContactManifold::default();
output0.adjust_offset_a_to_shape_surface(ADJUST_DEPTH_FACTOR);
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
CylinderWide,
CylinderWide,
array,
pair_count,
outputs,
convex4manifold_wide2convex4contact_manifold
);
}
#[test]
#[wasm_bindgen_test]
fn test_cylinder_cylinder_024_cylinder_a_cap_close_to_cylinder_b_side_with_rotation() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input = include_bytes!(
"resource/cylinder_cylinder/024_cylinder_a_cap_close_to_cylinder_b_side_with_rotation.json"
);
let input0: InputType = serde_json::from_slice(file_input).expect("file should be proper JSON");
let mut output0 = Convex4ContactManifold::default();
output0.adjust_offset_a_to_shape_surface(ADJUST_DEPTH_FACTOR);
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
CylinderWide,
CylinderWide,
array,
pair_count,
outputs,
convex4manifold_wide2convex4contact_manifold
);
}
#[test]
#[wasm_bindgen_test]
fn test_cylinder_cylinder_025_cylinder_a_side_close_to_cylinder_b_side_parallel() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input = include_bytes!(
"resource/cylinder_cylinder/025_cylinder_a_side_close_to_cylinder_b_side_parallel.json"
);
let input0: InputType = serde_json::from_slice(file_input).expect("file should be proper JSON");
let mut output0 = Convex4ContactManifold::default();
output0.adjust_offset_a_to_shape_surface(ADJUST_DEPTH_FACTOR);
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
CylinderWide,
CylinderWide,
array,
pair_count,
outputs,
convex4manifold_wide2convex4contact_manifold
);
}
#[test]
#[wasm_bindgen_test]
fn test_cylinder_cylinder_026_cylinder_a_far_away_to_cylinder_b() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input =
include_bytes!("resource/cylinder_cylinder/026_cylinder_a_far_away_to_cylinder_b.json");
let input0: InputType = serde_json::from_slice(file_input).expect("file should be proper JSON");
let mut output0 = Convex4ContactManifold::default();
output0.adjust_offset_a_to_shape_surface(ADJUST_DEPTH_FACTOR);
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
CylinderWide,
CylinderWide,
array,
pair_count,
outputs,
convex4manifold_wide2convex4contact_manifold
);
}
#[cfg(all(test, feature = "serde"))]
mod cylinder_cylinder_bepu_nan_test {
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::CylinderWide;
use crate::traits::PairWideTest;
use crate::Cylinder;
wasm_bindgen_test_configure!(run_in_browser);
type InputType = TestInput<Cylinder, Cylinder>;
const ADJUST_DEPTH_FACTOR: f32 = 1.0;
#[test]
#[ignore = "todo: issue #1259"]
fn test_cylinder_cylinder_000_duplicate() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input = include_bytes!("resource/cylinder_cylinder/000_duplicate.json");
let input0: InputType =
serde_json::from_slice(file_input).expect("file should be proper JSON");
let mut output0 = Convex4ContactManifold {
OffsetA0: Mvec3 {
x: 0.5,
y: 1.0,
z: 0.0,
},
OffsetA1: Mvec3 {
x: -0.5,
y: 1.0,
z: 0.0,
},
OffsetA2: Mvec3 {
x: f32::NAN,
y: f32::NAN,
z: f32::NAN,
},
OffsetA3: Mvec3 {
x: f32::NAN,
y: f32::NAN,
z: f32::NAN,
},
Normal: Mvec3 {
x: 0.0,
y: 1.0,
z: 0.0,
},
Depth0: 2.0,
Depth1: 2.0,
Depth2: f32::NAN,
Depth3: f32::NAN,
FeatureId0: 0,
FeatureId1: 1,
FeatureId2: 2,
FeatureId3: 3,
Contact0Exists: true,
Contact1Exists: true,
Contact2Exists: false,
Contact3Exists: false,
};
output0.adjust_offset_a_to_shape_surface(ADJUST_DEPTH_FACTOR);
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
CylinderWide,
CylinderWide,
array,
pair_count,
outputs,
convex4manifold_wide2convex4contact_manifold
);
}
#[test]
#[ignore = "todo: issue #1259"]
fn test_cylinder_cylinder_005_cylinder_a_cap_full_in_cylinder_b_cap_same_radius() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input = include_bytes!(
"resource/cylinder_cylinder/005_cylinder_a_cap_full_in_cylinder_b_cap_same_radius.json"
);
let input0: InputType =
serde_json::from_slice(file_input).expect("file should be proper JSON");
let mut output0 = Convex4ContactManifold {
OffsetA0: Mvec3 {
x: 0.5,
y: 0.20000005,
z: 0.0,
},
OffsetA1: Mvec3 {
x: -0.5,
y: 0.20000005,
z: 0.0,
},
OffsetA2: Mvec3 {
x: f32::NAN,
y: f32::NAN,
z: f32::NAN,
},
OffsetA3: Mvec3 {
x: f32::NAN,
y: f32::NAN,
z: f32::NAN,
},
Normal: Mvec3 {
x: 0.0,
y: -1.0,
z: 0.0,
},
Depth0: 0.79999995,
Depth1: 0.79999995,
Depth2: f32::NAN,
Depth3: f32::NAN,
FeatureId0: 0,
FeatureId1: 1,
FeatureId2: 2,
FeatureId3: 3,
Contact0Exists: true,
Contact1Exists: true,
Contact2Exists: false,
Contact3Exists: false,
};
output0.adjust_offset_a_to_shape_surface(ADJUST_DEPTH_FACTOR);
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
CylinderWide,
CylinderWide,
array,
pair_count,
outputs,
convex4manifold_wide2convex4contact_manifold
);
}
#[test]
#[ignore = "todo: issue #1259"]
fn test_cylinder_cylinder_019_cylinder_a_cap_tangent_with_cylinder_b_cap_full() {
let _ = env_logger::builder().is_test(true).try_init();
let file_input = include_bytes!(
"resource/cylinder_cylinder/019_cylinder_a_cap_tangent_with_cylinder_b_cap_full.json"
);
let input0: InputType =
serde_json::from_slice(file_input).expect("file should be proper JSON");
let mut output0 = Convex4ContactManifold {
OffsetA0: Mvec3 {
x: 0.5,
y: 1.0,
z: 0.0,
},
OffsetA1: Mvec3 {
x: -0.5,
y: 1.0,
z: 0.0,
},
OffsetA2: Mvec3 {
x: f32::NAN,
y: f32::NAN,
z: f32::NAN,
},
OffsetA3: Mvec3 {
x: f32::NAN,
y: f32::NAN,
z: f32::NAN,
},
Normal: Mvec3 {
x: 0.0,
y: -1.0,
z: 0.0,
},
Depth0: 0.0,
Depth1: 0.0,
Depth2: f32::NAN,
Depth3: f32::NAN,
FeatureId0: 0,
FeatureId1: 1,
FeatureId2: 2,
FeatureId3: 3,
Contact0Exists: true,
Contact1Exists: true,
Contact2Exists: false,
Contact3Exists: false,
};
output0.adjust_offset_a_to_shape_surface(ADJUST_DEPTH_FACTOR);
let array = [input0];
let outputs = [output0];
let pair_count = array.len();
TestWide!(
CylinderWide,
CylinderWide,
array,
pair_count,
outputs,
convex4manifold_wide2convex4contact_manifold
);
}
}