[Bf-blender-cvs] [e3cab5c206d] xr-controller-support: XR: Add fly navigation operator
Peter Kim
noreply at git.blender.org
Wed Jun 23 13:36:32 CEST 2021
Commit: e3cab5c206de6e075aa3c24a8026a0eb9ebb332b
Author: Peter Kim
Date: Wed Jun 23 20:30:32 2021 +0900
Branches: xr-controller-support
https://developer.blender.org/rBe3cab5c206de6e075aa3c24a8026a0eb9ebb332b
XR: Add fly navigation operator
Navigates the scene by moving/turning relative to navigation space
or the XR viewer/controller. Users can select from a variety of
these modes as well as specify the min/max speed and whether to lock
elevation.
Also: pass float threshold to XR action events.
===================================================================
M source/blender/makesrna/intern/rna_wm.c
M source/blender/windowmanager/WM_api.h
M source/blender/windowmanager/WM_types.h
M source/blender/windowmanager/intern/wm_event_query.c
M source/blender/windowmanager/intern/wm_event_system.c
M source/blender/windowmanager/xr/intern/wm_xr_operators.c
===================================================================
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c
index 579a257e540..6212df7a859 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -713,7 +713,7 @@ static void rna_Event_xr_actionmap_get(PointerRNA *ptr, char *value)
const wmEvent *event = ptr->data;
if (WM_event_is_xr(event)) {
WM_event_xr_data(
- event, &value, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+ event, &value, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
}
else {
value[0] = '\0';
@@ -737,7 +737,7 @@ static void rna_Event_xr_action_get(PointerRNA *ptr, char *value)
const wmEvent *event = ptr->data;
if (WM_event_is_xr(event)) {
WM_event_xr_data(
- event, NULL, &value, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+ event, NULL, &value, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
}
else {
value[0] = '\0';
@@ -761,8 +761,20 @@ static int rna_Event_xr_type_get(PointerRNA *ptr)
const wmEvent *event = ptr->data;
if (WM_event_is_xr(event)) {
int type;
- WM_event_xr_data(
- event, NULL, NULL, (char *)&type, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+ WM_event_xr_data(event,
+ NULL,
+ NULL,
+ (char *)&type,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL);
return type;
}
else {
@@ -775,7 +787,7 @@ static void rna_Event_xr_state_get(PointerRNA *ptr, float *value)
const wmEvent *event = ptr->data;
if (WM_event_is_xr(event)) {
WM_event_xr_data(
- event, NULL, NULL, NULL, value, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+ event, NULL, NULL, NULL, value, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
}
else {
memset(value, 0, sizeof(float[2]));
@@ -787,19 +799,45 @@ static void rna_Event_xr_state_other_get(PointerRNA *ptr, float *value)
const wmEvent *event = ptr->data;
if (WM_event_is_xr(event)) {
WM_event_xr_data(
- event, NULL, NULL, NULL, NULL, value, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+ event, NULL, NULL, NULL, NULL, value, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
}
else {
memset(value, 0, sizeof(float[2]));
}
}
+static float rna_Event_xr_float_threshold_get(PointerRNA *ptr)
+{
+ const wmEvent *event = ptr->data;
+ if (WM_event_is_xr(event)) {
+ float float_threshold;
+ WM_event_xr_data(event,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ &float_threshold,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL);
+ return float_threshold;
+ }
+ else {
+ return 0.0f;
+ }
+}
+
static void rna_Event_xr_controller_location_get(PointerRNA *ptr, float *value)
{
const wmEvent *event = ptr->data;
if (WM_event_is_xr(event)) {
WM_event_xr_data(
- event, NULL, NULL, NULL, NULL, NULL, value, NULL, NULL, NULL, NULL, NULL, NULL);
+ event, NULL, NULL, NULL, NULL, NULL, NULL, value, NULL, NULL, NULL, NULL, NULL, NULL);
}
else {
memset(value, 0, sizeof(float[3]));
@@ -811,7 +849,7 @@ static void rna_Event_xr_controller_rotation_get(PointerRNA *ptr, float *value)
const wmEvent *event = ptr->data;
if (WM_event_is_xr(event)) {
WM_event_xr_data(
- event, NULL, NULL, NULL, NULL, NULL, NULL, value, NULL, NULL, NULL, NULL, NULL);
+ event, NULL, NULL, NULL, NULL, NULL, NULL, NULL, value, NULL, NULL, NULL, NULL, NULL);
}
else {
value[0] = 1.0f;
@@ -824,7 +862,7 @@ static void rna_Event_xr_controller_location_other_get(PointerRNA *ptr, float *v
const wmEvent *event = ptr->data;
if (WM_event_is_xr(event)) {
WM_event_xr_data(
- event, NULL, NULL, NULL, NULL, NULL, NULL, NULL, value, NULL, NULL, NULL, NULL);
+ event, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, value, NULL, NULL, NULL, NULL);
}
else {
memset(value, 0, sizeof(float[3]));
@@ -836,7 +874,7 @@ static void rna_Event_xr_controller_rotation_other_get(PointerRNA *ptr, float *v
const wmEvent *event = ptr->data;
if (WM_event_is_xr(event)) {
WM_event_xr_data(
- event, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, value, NULL, NULL, NULL);
+ event, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, value, NULL, NULL, NULL);
}
else {
value[0] = 1.0f;
@@ -858,6 +896,7 @@ static void rna_Event_xr_view_matrix_get(PointerRNA *ptr, float values[16])
NULL,
NULL,
NULL,
+ NULL,
(float(*)[4])values,
NULL,
NULL);
@@ -873,7 +912,7 @@ static float rna_Event_xr_focal_length_get(PointerRNA *ptr)
if (WM_event_is_xr(event)) {
float focal_len;
WM_event_xr_data(
- event, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &focal_len, NULL);
+ event, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &focal_len, NULL);
return focal_len;
}
else {
@@ -887,7 +926,7 @@ static bool rna_Event_xr_bimanual_get(PointerRNA *ptr)
if (WM_event_is_xr(event)) {
bool bimanual;
WM_event_xr_data(
- event, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &bimanual);
+ event, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &bimanual);
return bimanual;
}
else {
@@ -2491,6 +2530,12 @@ static void rna_def_event(BlenderRNA *brna)
RNA_def_property_ui_text(
prop, "XR State Other", "State of the other user path for bimanual actions");
+ prop = RNA_def_property(srna, "xr_float_threshold", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_float_funcs(prop, "rna_Event_xr_float_threshold_get", NULL, NULL);
+ RNA_def_property_ui_text(
+ prop, "XR Float Threshold", "Input threshold for Float/Vector2f actions");
+
prop = RNA_def_property(srna, "xr_controller_location", PROP_FLOAT, PROP_TRANSLATION);
RNA_def_property_array(prop, 3);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 82ba0ec7dfc..48a7f4bb907 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -912,6 +912,7 @@ void WM_event_xr_data(const struct wmEvent *event,
char *type,
float state[2],
float state_other[2],
+ float *float_threshold,
float controller_loc[3],
float controller_rot[4],
float controller_loc_other[3],
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h
index 745dab9b7c9..1efacf3c48a 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -718,6 +718,9 @@ typedef struct wmXrActionData {
/** State of the other subaction path for bimanual actions. */
float state_other[2];
+ /** Input threshold for float/vector2f actions. */
+ float float_threshold;
+
/** Controller pose corresponding to the action's subaction path. */
float controller_loc[3];
float controller_rot[4];
diff --git a/source/blender/windowmanager/intern/wm_event_query.c b/source/blender/windowmanager/intern/wm_event_query.c
index 1965406fa26..a0a0abfd43a 100644
--- a/source/blender/windowmanager/intern/wm_event_query.c
+++ b/source/blender/windowmanager/intern/wm_event_query.c
@@ -489,6 +489,7 @@ void WM_event_xr_data(const wmEvent *event,
char *type,
float state[2],
float state_other[2],
+ float *float_threshold,
float controller_loc[3],
float controller_rot[4],
float controller_loc_other[3],
@@ -514,6 +515,9 @@ void WM_event_xr_data(const wmEvent *event,
if (state_other) {
copy_v2_v2(state_other, data->state_other);
}
+ if (float_threshold) {
+ *float_threshold = data->float_threshold;
+ }
if (controller_loc) {
copy_v3_v3(controller_loc, data->controller_loc);
}
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 0ceb79d3f3f..d2440cc3874 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -5086,6 +5086,8 @@ void wm_event_add_xrevent(const char *action_set_name,
return;
}
+ data->float_threshold = action->float_threshold;
+
if (controller_pose) {
copy_v3_v3(data->controller_loc, controller_pose->position);
copy_qt_qt(data->controller_rot, controller_pose->orientation_quat);
diff --git a/source/blender/windowmanager/xr/intern/wm_xr_operators.c b/source/blender/windowmanager/xr/intern/wm_xr_operators.c
index c9d5a8de0c7..9963feb4a2c 100644
--- a/source/blender/windowmanager/xr/intern/wm_xr_operators.c
+++ b/source/blender/windowmanager/xr/intern/wm_xr_operators.c
@@ -216,13 +216,13 @@ static void orient_mat_z_normalized(float R[4][4], const float z_axis[3])
mul_v3_v3fl(R[2], z_axis, scale);
}
-static void wm_xr_grab_navlocks_apply(const float nav_mat[4][4],
- const float nav_inv[4][4],
- bool loc_lock,
- bool locz_lock,
- bool rotz_lock,
- float r_prev[4][4],
-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list