phys-collision 2.0.1-beta.0

Provides collision detection ability
// Copyright (C) 2020-2025 phys-collision authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

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::SphereWide;
use crate::traits::PairWideTest;
use crate::Sphere;
wasm_bindgen_test_configure!(run_in_browser);
pub(crate) type InputType = TestInput<Sphere, Sphere>;
const ADJUST_DEPTH_FACTOR: f32 = 0.5;

#[test]
#[wasm_bindgen_test]
#[cfg(feature = "serde")]
fn test_sphere_sphere_tester_tangent() {
    let _ = env_logger::builder().is_test(true).try_init();

    let file_input = include_bytes!("resource/sphere_sphere/tangent.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.0,
            y: 0.5,
            z: 0.0,
        },
        normal: Mvec3 {
            x: 0.0,
            y: -1.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,
        SphereWide,
        array,
        pair_count,
        outputs,
        convex1contact_manifold_wide_to_convex1contact_manifold
    );
}