first set of renames
This commit is contained in:
@@ -80,14 +80,14 @@ fn setup_scene(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
struct CreateActionSet {
|
struct XRUtilsActionSet {
|
||||||
name: Cow<'static, str>,
|
name: Cow<'static, str>,
|
||||||
pretty_name: Cow<'static, str>,
|
pretty_name: Cow<'static, str>,
|
||||||
priority: u32,
|
priority: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component, Clone)]
|
#[derive(Component, Clone)]
|
||||||
struct OXRActionSet(openxr::ActionSet);
|
struct XRUtilsActionSetReference(openxr::ActionSet);
|
||||||
|
|
||||||
//I want to use this to indicate when an action set is attached
|
//I want to use this to indicate when an action set is attached
|
||||||
// #[derive(Component)]
|
// #[derive(Component)]
|
||||||
@@ -97,14 +97,14 @@ struct OXRActionSet(openxr::ActionSet);
|
|||||||
struct ActiveSet;
|
struct ActiveSet;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
struct CreateAction {
|
struct XRUtilsAction {
|
||||||
action_name: Cow<'static, str>,
|
action_name: Cow<'static, str>,
|
||||||
localized_name: Cow<'static, str>,
|
localized_name: Cow<'static, str>,
|
||||||
action_type: bevy_xr::actions::ActionType,
|
action_type: bevy_xr::actions::ActionType,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
struct CreateBinding {
|
struct XRUtilsBinding {
|
||||||
profile: Cow<'static, str>,
|
profile: Cow<'static, str>,
|
||||||
binding: Cow<'static, str>,
|
binding: Cow<'static, str>,
|
||||||
}
|
}
|
||||||
@@ -131,7 +131,7 @@ fn create_action_entities(mut commands: Commands) {
|
|||||||
//create a set
|
//create a set
|
||||||
let set = commands
|
let set = commands
|
||||||
.spawn((
|
.spawn((
|
||||||
CreateActionSet {
|
XRUtilsActionSet {
|
||||||
name: "flight".into(),
|
name: "flight".into(),
|
||||||
pretty_name: "pretty flight set".into(),
|
pretty_name: "pretty flight set".into(),
|
||||||
priority: u32::MIN,
|
priority: u32::MIN,
|
||||||
@@ -142,7 +142,7 @@ fn create_action_entities(mut commands: Commands) {
|
|||||||
//create an action
|
//create an action
|
||||||
let action = commands
|
let action = commands
|
||||||
.spawn((
|
.spawn((
|
||||||
CreateAction {
|
XRUtilsAction {
|
||||||
action_name: "flight_input".into(),
|
action_name: "flight_input".into(),
|
||||||
localized_name: "flight_input_localized".into(),
|
localized_name: "flight_input_localized".into(),
|
||||||
action_type: bevy_xr::actions::ActionType::Vector,
|
action_type: bevy_xr::actions::ActionType::Vector,
|
||||||
@@ -153,7 +153,7 @@ fn create_action_entities(mut commands: Commands) {
|
|||||||
|
|
||||||
//create a binding
|
//create a binding
|
||||||
let binding = commands
|
let binding = commands
|
||||||
.spawn(CreateBinding {
|
.spawn(XRUtilsBinding {
|
||||||
profile: "/interaction_profiles/valve/index_controller".into(),
|
profile: "/interaction_profiles/valve/index_controller".into(),
|
||||||
binding: "/user/hand/right/input/thumbstick".into(),
|
binding: "/user/hand/right/input/thumbstick".into(),
|
||||||
})
|
})
|
||||||
@@ -166,9 +166,9 @@ fn create_action_entities(mut commands: Commands) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn create_openxr_events(
|
fn create_openxr_events(
|
||||||
action_sets_query: Query<(&CreateActionSet, &Children, Entity)>,
|
action_sets_query: Query<(&XRUtilsActionSet, &Children, Entity)>,
|
||||||
actions_query: Query<(&CreateAction, &Children)>,
|
actions_query: Query<(&XRUtilsAction, &Children)>,
|
||||||
bindings_query: Query<&CreateBinding>,
|
bindings_query: Query<&XRUtilsBinding>,
|
||||||
instance: ResMut<OxrInstance>,
|
instance: ResMut<OxrInstance>,
|
||||||
mut binding_writer: EventWriter<OxrSuggestActionBinding>,
|
mut binding_writer: EventWriter<OxrSuggestActionBinding>,
|
||||||
mut attach_writer: EventWriter<OxrAttachActionSet>,
|
mut attach_writer: EventWriter<OxrAttachActionSet>,
|
||||||
@@ -184,7 +184,7 @@ fn create_openxr_events(
|
|||||||
.create_action_set(&set.name, &set.pretty_name, set.priority)
|
.create_action_set(&set.name, &set.pretty_name, set.priority)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
//now that we have the action set we need to put it back onto the entity for later
|
//now that we have the action set we need to put it back onto the entity for later
|
||||||
let oxr_action_set = OXRActionSet(action_set.clone());
|
let oxr_action_set = XRUtilsActionSetReference(action_set.clone());
|
||||||
commands.entity(id).insert(oxr_action_set);
|
commands.entity(id).insert(oxr_action_set);
|
||||||
|
|
||||||
//since the actions are made from the sets lets go
|
//since the actions are made from the sets lets go
|
||||||
@@ -207,7 +207,7 @@ fn create_openxr_events(
|
|||||||
ActionBooleference {
|
ActionBooleference {
|
||||||
action: action.clone(),
|
action: action.clone(),
|
||||||
},
|
},
|
||||||
MyActionState::Bool(ActionStateBool {
|
XRUtilsActionState::Bool(ActionStateBool {
|
||||||
current_state: false,
|
current_state: false,
|
||||||
changed_since_last_sync: false,
|
changed_since_last_sync: false,
|
||||||
last_change_time: i64::MIN,
|
last_change_time: i64::MIN,
|
||||||
@@ -246,7 +246,7 @@ fn create_openxr_events(
|
|||||||
Actionf32Reference {
|
Actionf32Reference {
|
||||||
action: action.clone(),
|
action: action.clone(),
|
||||||
},
|
},
|
||||||
MyActionState::Float(ActionStateFloat {
|
XRUtilsActionState::Float(ActionStateFloat {
|
||||||
current_state: 0.0,
|
current_state: 0.0,
|
||||||
changed_since_last_sync: false,
|
changed_since_last_sync: false,
|
||||||
last_change_time: i64::MIN,
|
last_change_time: i64::MIN,
|
||||||
@@ -285,7 +285,7 @@ fn create_openxr_events(
|
|||||||
ActionVector2fReference {
|
ActionVector2fReference {
|
||||||
action: action.clone(),
|
action: action.clone(),
|
||||||
},
|
},
|
||||||
MyActionState::Vector(ActionStateVector {
|
XRUtilsActionState::Vector(ActionStateVector {
|
||||||
current_state: [0.0, 0.0],
|
current_state: [0.0, 0.0],
|
||||||
changed_since_last_sync: false,
|
changed_since_last_sync: false,
|
||||||
last_change_time: i64::MIN,
|
last_change_time: i64::MIN,
|
||||||
@@ -318,7 +318,7 @@ fn create_openxr_events(
|
|||||||
|
|
||||||
fn sync_active_action_sets(
|
fn sync_active_action_sets(
|
||||||
session: Res<OxrSession>,
|
session: Res<OxrSession>,
|
||||||
active_action_set_query: Query<&OXRActionSet, With<ActiveSet>>,
|
active_action_set_query: Query<&XRUtilsActionSetReference, With<ActiveSet>>,
|
||||||
) {
|
) {
|
||||||
let active_sets = active_action_set_query
|
let active_sets = active_action_set_query
|
||||||
.iter()
|
.iter()
|
||||||
@@ -333,7 +333,7 @@ fn sync_active_action_sets(
|
|||||||
|
|
||||||
fn sync_and_update_action_states_f32(
|
fn sync_and_update_action_states_f32(
|
||||||
session: Res<OxrSession>,
|
session: Res<OxrSession>,
|
||||||
mut f32_query: Query<(&Actionf32Reference, &mut MyActionState)>,
|
mut f32_query: Query<(&Actionf32Reference, &mut XRUtilsActionState)>,
|
||||||
) {
|
) {
|
||||||
//now we do the action state for f32
|
//now we do the action state for f32
|
||||||
for (reference, mut silly_state) in f32_query.iter_mut() {
|
for (reference, mut silly_state) in f32_query.iter_mut() {
|
||||||
@@ -341,7 +341,7 @@ fn sync_and_update_action_states_f32(
|
|||||||
match state {
|
match state {
|
||||||
Ok(s) => {
|
Ok(s) => {
|
||||||
info!("we found a state");
|
info!("we found a state");
|
||||||
let new_state = MyActionState::Float(ActionStateFloat {
|
let new_state = XRUtilsActionState::Float(ActionStateFloat {
|
||||||
current_state: s.current_state,
|
current_state: s.current_state,
|
||||||
changed_since_last_sync: s.changed_since_last_sync,
|
changed_since_last_sync: s.changed_since_last_sync,
|
||||||
last_change_time: s.last_change_time.as_nanos(),
|
last_change_time: s.last_change_time.as_nanos(),
|
||||||
@@ -359,7 +359,7 @@ fn sync_and_update_action_states_f32(
|
|||||||
|
|
||||||
fn sync_and_update_action_states_bool(
|
fn sync_and_update_action_states_bool(
|
||||||
session: Res<OxrSession>,
|
session: Res<OxrSession>,
|
||||||
mut f32_query: Query<(&ActionBooleference, &mut MyActionState)>,
|
mut f32_query: Query<(&ActionBooleference, &mut XRUtilsActionState)>,
|
||||||
) {
|
) {
|
||||||
//now we do the action state for f32
|
//now we do the action state for f32
|
||||||
for (reference, mut silly_state) in f32_query.iter_mut() {
|
for (reference, mut silly_state) in f32_query.iter_mut() {
|
||||||
@@ -367,7 +367,7 @@ fn sync_and_update_action_states_bool(
|
|||||||
match state {
|
match state {
|
||||||
Ok(s) => {
|
Ok(s) => {
|
||||||
info!("we found a state");
|
info!("we found a state");
|
||||||
let new_state = MyActionState::Bool(ActionStateBool {
|
let new_state = XRUtilsActionState::Bool(ActionStateBool {
|
||||||
current_state: s.current_state,
|
current_state: s.current_state,
|
||||||
changed_since_last_sync: s.changed_since_last_sync,
|
changed_since_last_sync: s.changed_since_last_sync,
|
||||||
last_change_time: s.last_change_time.as_nanos(),
|
last_change_time: s.last_change_time.as_nanos(),
|
||||||
@@ -385,7 +385,7 @@ fn sync_and_update_action_states_bool(
|
|||||||
|
|
||||||
fn sync_and_update_action_states_vector(
|
fn sync_and_update_action_states_vector(
|
||||||
session: Res<OxrSession>,
|
session: Res<OxrSession>,
|
||||||
mut vector_query: Query<(&ActionVector2fReference, &mut MyActionState)>,
|
mut vector_query: Query<(&ActionVector2fReference, &mut XRUtilsActionState)>,
|
||||||
) {
|
) {
|
||||||
//now we do the action state for f32
|
//now we do the action state for f32
|
||||||
for (reference, mut silly_state) in vector_query.iter_mut() {
|
for (reference, mut silly_state) in vector_query.iter_mut() {
|
||||||
@@ -393,7 +393,7 @@ fn sync_and_update_action_states_vector(
|
|||||||
match state {
|
match state {
|
||||||
Ok(s) => {
|
Ok(s) => {
|
||||||
info!("we found a state");
|
info!("we found a state");
|
||||||
let new_state = MyActionState::Vector(ActionStateVector {
|
let new_state = XRUtilsActionState::Vector(ActionStateVector {
|
||||||
current_state: [s.current_state.x, s.current_state.y],
|
current_state: [s.current_state.x, s.current_state.y],
|
||||||
changed_since_last_sync: s.changed_since_last_sync,
|
changed_since_last_sync: s.changed_since_last_sync,
|
||||||
last_change_time: s.last_change_time.as_nanos(),
|
last_change_time: s.last_change_time.as_nanos(),
|
||||||
@@ -410,7 +410,7 @@ fn sync_and_update_action_states_vector(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn read_action_with_marker_component(
|
fn read_action_with_marker_component(
|
||||||
mut action_query: Query<&MyActionState, With<FlightActionMarker>>,
|
mut action_query: Query<&XRUtilsActionState, With<FlightActionMarker>>,
|
||||||
) {
|
) {
|
||||||
//now for the actual checking
|
//now for the actual checking
|
||||||
for state in action_query.iter_mut() {
|
for state in action_query.iter_mut() {
|
||||||
@@ -420,7 +420,7 @@ fn read_action_with_marker_component(
|
|||||||
|
|
||||||
//lets add some flycam stuff
|
//lets add some flycam stuff
|
||||||
fn handle_flight_input(
|
fn handle_flight_input(
|
||||||
action_query: Query<&MyActionState, With<FlightActionMarker>>,
|
action_query: Query<&XRUtilsActionState, With<FlightActionMarker>>,
|
||||||
mut oxr_root: Query<&mut Transform, With<OxrTrackingRoot>>,
|
mut oxr_root: Query<&mut Transform, With<OxrTrackingRoot>>,
|
||||||
time: Res<Time>,
|
time: Res<Time>,
|
||||||
//use the views for hmd orientation
|
//use the views for hmd orientation
|
||||||
@@ -430,9 +430,9 @@ fn handle_flight_input(
|
|||||||
for state in action_query.iter() {
|
for state in action_query.iter() {
|
||||||
// info!("action state is: {:?}", state);
|
// info!("action state is: {:?}", state);
|
||||||
match state {
|
match state {
|
||||||
MyActionState::Bool(_) => (),
|
XRUtilsActionState::Bool(_) => (),
|
||||||
MyActionState::Float(_) => (),
|
XRUtilsActionState::Float(_) => (),
|
||||||
MyActionState::Vector(vector_state) => {
|
XRUtilsActionState::Vector(vector_state) => {
|
||||||
//assuming we are mapped to a vector lets fly
|
//assuming we are mapped to a vector lets fly
|
||||||
let input_vector = vec3(
|
let input_vector = vec3(
|
||||||
vector_state.current_state[0],
|
vector_state.current_state[0],
|
||||||
@@ -469,7 +469,7 @@ fn handle_flight_input(
|
|||||||
|
|
||||||
//the things i do for bad prototyping and lack of understanding
|
//the things i do for bad prototyping and lack of understanding
|
||||||
#[derive(Component, Debug)]
|
#[derive(Component, Debug)]
|
||||||
pub enum MyActionState {
|
pub enum XRUtilsActionState {
|
||||||
Bool(ActionStateBool),
|
Bool(ActionStateBool),
|
||||||
Float(ActionStateFloat),
|
Float(ActionStateFloat),
|
||||||
Vector(ActionStateVector),
|
Vector(ActionStateVector),
|
||||||
|
|||||||
Reference in New Issue
Block a user