[Bf-blender-cvs] [9ce38d17edb] xr-controller-support: XR: Add bimanual scale mode for grab operator
Peter Kim
noreply at git.blender.org
Sat Jun 12 12:33:33 CEST 2021
Commit: 9ce38d17edb0e015806f2952db920f3abc180d85
Author: Peter Kim
Date: Sat Jun 12 19:25:42 2021 +0900
Branches: xr-controller-support
https://developer.blender.org/rB9ce38d17edb0e015806f2952db920f3abc180d85
XR: Add bimanual scale mode for grab operator
Also renamed operator to "Transform Grab".
===================================================================
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_draw.c
M source/blender/windowmanager/xr/intern/wm_xr_operators.c
M source/blender/windowmanager/xr/intern/wm_xr_session.c
===================================================================
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c
index c3c43a77244..579a257e540 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -712,7 +712,8 @@ 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);
+ WM_event_xr_data(
+ event, &value, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
}
else {
value[0] = '\0';
@@ -735,7 +736,8 @@ 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);
+ WM_event_xr_data(
+ event, NULL, &value, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
}
else {
value[0] = '\0';
@@ -760,7 +762,7 @@ static int rna_Event_xr_type_get(PointerRNA *ptr)
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);
+ event, NULL, NULL, (char *)&type, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
return type;
}
else {
@@ -772,7 +774,8 @@ 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);
+ WM_event_xr_data(
+ event, NULL, NULL, NULL, value, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
}
else {
memset(value, 0, sizeof(float[2]));
@@ -783,7 +786,8 @@ 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);
+ WM_event_xr_data(
+ event, NULL, NULL, NULL, NULL, value, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
}
else {
memset(value, 0, sizeof(float[2]));
@@ -794,7 +798,8 @@ 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);
+ WM_event_xr_data(
+ event, NULL, NULL, NULL, NULL, NULL, value, NULL, NULL, NULL, NULL, NULL, NULL);
}
else {
memset(value, 0, sizeof(float[3]));
@@ -805,7 +810,8 @@ 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);
+ WM_event_xr_data(
+ event, NULL, NULL, NULL, NULL, NULL, NULL, value, NULL, NULL, NULL, NULL, NULL);
}
else {
value[0] = 1.0f;
@@ -817,7 +823,8 @@ 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);
+ WM_event_xr_data(
+ event, NULL, NULL, NULL, NULL, NULL, NULL, NULL, value, NULL, NULL, NULL, NULL);
}
else {
memset(value, 0, sizeof(float[3]));
@@ -828,7 +835,8 @@ 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);
+ WM_event_xr_data(
+ event, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, value, NULL, NULL, NULL);
}
else {
value[0] = 1.0f;
@@ -840,8 +848,19 @@ static void rna_Event_xr_view_matrix_get(PointerRNA *ptr, float values[16])
{
const wmEvent *event = ptr->data;
if (WM_event_is_xr(event)) {
- WM_event_xr_data(
- event, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, (float(*)[4])values, NULL);
+ WM_event_xr_data(event,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ (float(*)[4])values,
+ NULL,
+ NULL);
}
else {
memset(values, 0, sizeof(float[16]));
@@ -854,7 +873,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);
+ event, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &focal_len, NULL);
return focal_len;
}
else {
@@ -862,6 +881,20 @@ static float rna_Event_xr_focal_length_get(PointerRNA *ptr)
}
}
+static bool rna_Event_xr_bimanual_get(PointerRNA *ptr)
+{
+ const wmEvent *event = ptr->data;
+ 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);
+ return bimanual;
+ }
+ else {
+ return false;
+ }
+}
+
static PointerRNA rna_PopupMenu_layout_get(PointerRNA *ptr)
{
struct uiPopupMenu *pup = ptr->data;
@@ -2503,6 +2536,11 @@ static void rna_def_event(BlenderRNA *brna)
RNA_def_property_float_funcs(prop, "rna_Event_xr_focal_length_get", NULL, NULL);
RNA_def_property_ui_text(prop, "XR Focal Length", "Focal length of the XR selection eye");
+ prop = RNA_def_property(srna, "xr_bimanual", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_boolean_funcs(prop, "rna_Event_xr_bimanual_get", NULL);
+ RNA_def_property_ui_text(prop, "XR Bimanual", "Bimanual interaction is occurring");
+
RNA_define_verify_sdna(1); /* not in sdna */
}
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 7c47673cbcc..8a70d6c74da 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -909,7 +909,8 @@ void WM_event_xr_data(const struct wmEvent *event,
float controller_loc_other[3],
float controller_rot_other[4],
float eye_viewmat[4][4],
- float *eye_lens);
+ float *eye_lens,
+ bool *bimanual);
bool WM_event_is_xr(const struct wmEvent *event);
#ifdef WITH_INPUT_IME
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h
index bf51565a71f..47cf652fb43 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -734,8 +734,8 @@ typedef struct wmXrActionData {
struct wmOperatorType *ot;
struct IDProperty *op_properties;
- /** Flag. */
- eXrActionFlag flag;
+ /** Whether bimanual interaction is occuring. */
+ bool bimanual;
} wmXrActionData;
/** Timer flags. */
diff --git a/source/blender/windowmanager/intern/wm_event_query.c b/source/blender/windowmanager/intern/wm_event_query.c
index 5fb8b756046..1965406fa26 100644
--- a/source/blender/windowmanager/intern/wm_event_query.c
+++ b/source/blender/windowmanager/intern/wm_event_query.c
@@ -494,7 +494,8 @@ void WM_event_xr_data(const wmEvent *event,
float controller_loc_other[3],
float controller_rot_other[4],
float eye_viewmat[4][4],
- float *eye_lens)
+ float *eye_lens,
+ bool *bimanual)
{
const wmXrActionData *data = event->customdata;
@@ -531,6 +532,9 @@ void WM_event_xr_data(const wmEvent *event,
if (eye_lens) {
*eye_lens = data->eye_lens;
}
+ if (bimanual) {
+ *bimanual = data->bimanual;
+ }
}
bool WM_event_is_xr(const struct wmEvent *event)
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index f7dcd2db4bf..69ce2ea8777 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -5045,9 +5045,10 @@ void wm_event_add_xrevent(const char *action_set_name,
BLI_assert(surface->is_xr && surface->customdata);
BLI_assert(val == KM_PRESS || val == KM_RELEASE);
- wmXrSurfaceData *surface_data = surface->customdata;
const bool add_win_event = ((action->ot->modal || action->ot->modal_3d) &&
((val == KM_PRESS && !press_start) || val == KM_RELEASE));
+ const bool bimanual = (((action->flag & XR_ACTION_BIMANUAL) != 0) &&
+ (subaction_idx_other != subaction_idx));
wmEvent _event;
wmEvent *event = add_win_event ? &_event : MEM_callocN(sizeof(wmEvent), __func__);
@@ -5063,19 +5064,19 @@ void wm_event_add_xrevent(const char *action_set_name,
switch (action->type) {
case XR_BOOLEAN_INPUT:
data->state[0] = ((bool *)action->states)[subaction_idx] ? 1.0f : 0.0f;
- if (subaction_idx_other != subaction_idx) {
+ if (bimanual) {
data->state_other[0] = ((bool *)action->states)[subaction_idx_other] ? 1.0f : 0.0f;
}
break;
case XR_FLOAT_INPUT:
data->state[0] = ((float *)action->states)[subaction_idx];
- if (subaction_idx_other != subaction_idx) {
+ if (bimanual) {
data->state_other[0] = ((float *)action->states)[subaction_idx_other];
}
break;
case XR_VECTOR2F_INPUT:
copy_v2_v2(data->state, ((float(*)[2])action->states)[subaction_idx]);
- if (subaction_idx_other != subaction_idx) {
+ if (bimanual) {
copy_v2_v2(data->state_other, ((float(*)[2])action->states)[subaction_idx_other]);
}
break;
@@ -5089,7 +5090,7 @@ void wm_event_add_xrevent(const char *action_set_name,
copy_v3_
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list