pub fn new(
        operation: Operation,
        mut left: Arc<dyn Shape>,
        mut right: Arc<dyn Shape>,
        transform: Matrix,
    ) -> Arc<Csg> {
        let mut csg = Arc::new(Csg {
            operation,
            transform,
            ..Csg::default()
        });

        // Children needs to be unchecked as well, otherwise shapes can't be nested.

        let left_mut = unsafe { Arc::get_mut_unchecked(&mut left) };
        let left_parent_ref = left_mut.parent_mut();
        *left_parent_ref = Arc::downgrade(&(Arc::clone(&csg) as Arc<dyn Shape>));

        let right_mut = unsafe { Arc::get_mut_unchecked(&mut right) };
        let right_parent_ref = right_mut.parent_mut();
        *right_parent_ref = Arc::downgrade(&(Arc::clone(&csg) as Arc<dyn Shape>));

        let csg_mut = unsafe { Arc::get_mut_unchecked(&mut csg) };

        csg_mut.children = (left, right);

        csg
    }
// Sets the children's parent to the new Csg instance.
//
Sets the children's parent to the new Csg instance.
Sets the children ' s parent to the new Csg instance .
pub fn new(
        operation: Operation,
        mut left: Arc<dyn Shape>,
        mut right: Arc<dyn Shape>,
        transform: Matrix,
    ) -> Arc<Csg> {
        let mut csg = Arc::new(Csg {
            operation,
            transform,
            ..Csg::default()
        });
        // Children needs to be unchecked as well, otherwise shapes can't be nested.
        let left_mut = unsafe { Arc::get_mut_unchecked(&mut left) };
        let left_parent_ref = left_mut.parent_mut();
        *left_parent_ref = Arc::downgrade(&(Arc::clone(&csg) as Arc<dyn Shape>));
        let right_mut = unsafe { Arc::get_mut_unchecked(&mut right) };
        let right_parent_ref = right_mut.parent_mut();
        *right_parent_ref = Arc::downgrade(&(Arc::clone(&csg) as Arc<dyn Shape>));
        let csg_mut = unsafe { Arc::get_mut_unchecked(&mut csg) };
        csg_mut.children = (left, right);
        csg
    }
pub fn new ( operation : Operation , mut left : Arc < dyn Shape > , mut right : Arc < dyn Shape > , transform : Matrix , ) -> Arc < Csg > { let mut csg = Arc :: new ( Csg { operation , transform , .. Csg :: default ( ) } ) ; // Children needs to be unchecked as well, otherwise shapes can't be nested. let left_mut = unsafe { Arc :: get_mut_unchecked ( & mut left ) } ; let left_parent_ref = left_mut . parent_mut ( ) ; * left_parent_ref = Arc :: downgrade ( & ( Arc :: clone ( & csg ) as Arc < dyn Shape > ) ) ; let right_mut = unsafe { Arc :: get_mut_unchecked ( & mut right ) } ; let right_parent_ref = right_mut . parent_mut ( ) ; * right_parent_ref = Arc :: downgrade ( & ( Arc :: clone ( & csg ) as Arc < dyn Shape > ) ) ; let csg_mut = unsafe { Arc :: get_mut_unchecked ( & mut csg ) } ; csg_mut . children = ( left , right ) ; csg }
Sets the children's parent to the new Csg instance.
Sets the children ' s parent to the new Csg instance .
operation
Operation
left
Arc<dyn Shape>
right
Arc<dyn Shape>
transform
Matrix