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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#![warn(clippy::all)]
#![warn(rust_2018_idioms)]
use super::{base::Base, math::*, px_type::*};
use enumflags2::*;
use physx_macros::*;
use physx_sys::{
PxActor, PxActorFlag, PxActorFlags, PxActorType, PxActor_getActorFlags, PxActor_getAggregate,
PxActor_getDominanceGroup, PxActor_getOwnerClient, PxActor_getScene, PxActor_getType,
PxActor_getWorldBounds, PxActor_release_mut, PxActor_setActorFlag_mut,
PxActor_setActorFlags_mut, PxActor_setDominanceGroup_mut, PxActor_setOwnerClient_mut,
PxAggregate, PxScene,
};
#[derive(Debug, Copy, Clone, BitFlags)]
#[repr(u8)]
pub enum ActorFlag {
Visualization = 1,
DisableGravity = 2,
SendSleepNotifies = 4,
DisableSimulation = 8,
}
impl Into<PxActorFlag::Enum> for ActorFlag {
fn into(self) -> PxActorFlag::Enum {
match self {
ActorFlag::Visualization => 1,
ActorFlag::DisableGravity => 2,
ActorFlag::SendSleepNotifies => 4,
ActorFlag::DisableSimulation => 8,
}
}
}
impl From<PxActorFlag::Enum> for ActorFlag {
fn from(other: PxActorFlag::Enum) -> Self {
match other {
1 => ActorFlag::Visualization,
2 => ActorFlag::DisableGravity,
4 => ActorFlag::SendSleepNotifies,
8 => ActorFlag::DisableSimulation,
_ => unreachable!("InvalidActorFlag"),
}
}
}
#[physx_type(inherit = "Base")]
impl Actor {
pub fn release(&mut self) {
unsafe { PxActor_release_mut(self.get_raw_mut()) }
}
pub fn get_type(&self) -> PxActorType::Enum {
unsafe { PxActor_getType(self.get_raw()) }
}
pub fn get_scene(&self) -> *mut PxScene {
unsafe { PxActor_getScene(self.get_raw()) }
}
pub fn get_world_bounds(&self, inflation: f32) -> Bounds {
unsafe { PxActor_getWorldBounds(self.get_raw(), inflation).into() }
}
pub fn set_actor_flag(&mut self, flag: ActorFlag, value: bool) {
unsafe { PxActor_setActorFlag_mut(self.get_raw_mut(), flag.into(), value) }
}
pub fn set_actor_flags(&mut self, flags: BitFlags<ActorFlag>) {
unsafe {
PxActor_setActorFlags_mut(
self.get_raw_mut(),
PxActorFlags {
mBits: flags.bits(),
},
)
}
}
pub fn get_actor_flags(&self) -> PxActorFlags {
unsafe { PxActor_getActorFlags(self.get_raw()) }
}
pub fn set_dominance_group(&mut self, group: u8) {
unsafe { PxActor_setDominanceGroup_mut(self.get_raw_mut(), group) }
}
pub fn get_dominance_group(&self) -> u8 {
unsafe { PxActor_getDominanceGroup(self.get_raw()) }
}
pub fn set_owner_client(&mut self, client: u8) {
unsafe { PxActor_setOwnerClient_mut(self.get_raw_mut(), client) }
}
pub fn get_owner_client(&self) -> u8 {
unsafe { PxActor_getOwnerClient(self.get_raw()) }
}
pub fn get_aggregate(&self) -> *mut PxAggregate {
unsafe { PxActor_getAggregate(self.get_raw()) }
}
pub fn enable_visualization(&mut self, enable: bool) {
unsafe {
PxActor_setActorFlag_mut(self.get_raw_mut(), PxActorFlag::eVISUALIZATION, enable);
}
}
pub fn enable_gravity(&mut self, enable: bool) {
unsafe {
PxActor_setActorFlag_mut(self.get_raw_mut(), PxActorFlag::eDISABLE_GRAVITY, !enable);
}
}
}