1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Author: Tom Olsson <tom.olsson@embark-studios.com>
// Copyright © 2019, Embark Studios, all rights reserved.
// Created: 16 April 2019

#![warn(clippy::all)]
#![warn(rust_2018_idioms)]

/*!

*/

use super::articulation_joint_base::ArticulationJointBase;
use super::px_type::*;
use super::transform::gl_to_px_q;
use glam::Quat;
use log::*;
use physx_macros::*;
use physx_sys::*;

/*******************************************************************************
 * Section ENUMS                                                               *
 ******************************************************************************/

#[derive(Debug, Clone, Copy)]
pub enum ArticulationJointDriveType {
    Target,
    Error,
}

impl Into<PxArticulationJointDriveType::Enum> for ArticulationJointDriveType {
    fn into(self) -> PxArticulationJointDriveType::Enum {
        match self {
            ArticulationJointDriveType::Target => PxArticulationJointDriveType::eTARGET,
            ArticulationJointDriveType::Error => PxArticulationJointDriveType::eERROR,
        }
    }
}

/*******************************************************************************
 * Section ARTICULATIONJOINT                                                   *
 ******************************************************************************/

#[physx_type(inherit = "ArticulationJointBase")]
impl ArticulationJoint {
    /// set drive type of the associated joints
    pub fn set_drive_type(&mut self, _type: ArticulationJointDriveType) {
        unsafe { PxArticulationJoint_setDriveType_mut(self.get_raw_mut(), _type.into()) }
    }

    /// not implemented yet, not work for reduced coordinate
    pub fn set_orientation(&mut self, quat: Quat) {
        unsafe {
            PxArticulationJoint_setTargetOrientation_mut(self.get_raw_mut(), &gl_to_px_q(quat))
        };
    }
}