use crate::b2_collision::*;
use crate::b2_math::*;
use crate::b2_common::*;
use crate::b2_shape::*;
use crate::private::collision::b2_edge_shape as private;
use std::rc::Rc;
#[cfg(feature="serde_support")]
use serde::{Serialize, Deserialize};
#[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "serde_support", derive(Serialize, Deserialize))]
pub struct B2edgeShape {
pub base: B2Shape,
pub m_vertex1: B2vec2,
pub m_vertex2: B2vec2,
pub m_vertex0: B2vec2,
pub m_vertex3: B2vec2,
pub m_one_sided: bool
}
impl Default for B2edgeShape {
fn default() -> Self {
return inline::b2_edge_shape();
}
}
impl B2edgeShape {
pub fn set_one_sided(&mut self, v0: B2vec2, v1: B2vec2, v2: B2vec2, v3: B2vec2)
{
private::b2_set_one_sided(self, v0, v1, v2, v3);
}
pub fn set_two_sided(&mut self, v1: B2vec2, v2: B2vec2)
{
private::b2_set_two_sided(self, v1, v2);
}
}
impl B2shapeDynTrait for B2edgeShape {
fn get_base(&self) -> &B2Shape
{
return &self.base;
}
fn get_type(&self) -> B2ShapeType {
return self.base.get_type();
}
fn clone_box(&self) -> Box<dyn B2shapeDynTrait> {
return private::b2_shape_dyn_trait_clone(self);
}
fn clone_rc(&self) -> ShapePtr
{
return Rc::new(self.clone());
}
fn get_child_count(&self) -> usize {
return private::b2_shape_dyn_trait_get_child_count(self);
}
fn test_point(&self, transform: B2Transform, p: B2vec2) -> bool {
return private::b2_shape_dyn_trait_test_point(self, transform, p);
}
fn ray_cast(
&self,
output: &mut B2rayCastOutput,
input: &B2rayCastInput,
xf: B2Transform,
child_index: usize,
) -> bool {
return private::b2_shape_dyn_trait_ray_cast(
&self, output, input, xf, child_index,
);
}
fn compute_aabb(&self, aabb: &mut B2AABB, xf: B2Transform, child_index: usize) {
private::b2_shape_dyn_trait_compute_aabb(self, aabb, xf, child_index);
}
fn compute_mass(&self, mass_data: &mut B2massData, density: f32) {
private::b2_shape_dyn_trait_compute_mass(self, mass_data, density);
}
}
mod inline
{
use super::*;
pub fn b2_edge_shape() -> B2edgeShape {
return B2edgeShape {
base: B2Shape {
m_type: B2ShapeType::EEdge,
m_radius: B2_POLYGON_RADIUS,
},
m_vertex1: B2vec2 { x: 0.0, y: 0.0 },
m_vertex2: B2vec2 { x: 0.0, y: 0.0 },
m_vertex0: B2vec2 { x: 0.0, y: 0.0 },
m_vertex3: B2vec2 { x: 0.0, y: 0.0 },
m_one_sided: false,
};
}
}