Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2017-06-19 21:44:34 +0300
committerCampbell Barton <ideasman42@gmail.com>2017-06-19 21:44:34 +0300
commitc31f24c63b875e8c9a7cacd2733d3e8614eff74d (patch)
tree04556ea0daeb869a3e6a12676429a163f28b1a0b /source/blender/windowmanager
parent56dea4b7cd6927dc3676a53c8a9c339545d93d63 (diff)
Manipulators: store operator type instead of id
Avoids lookups on each access.
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r--source/blender/windowmanager/manipulators/WM_manipulator_api.h2
-rw-r--r--source/blender/windowmanager/manipulators/WM_manipulator_types.h10
-rw-r--r--source/blender/windowmanager/manipulators/intern/wm_manipulator.c25
-rw-r--r--source/blender/windowmanager/manipulators/intern/wm_manipulator_group.c5
-rw-r--r--source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c41
-rw-r--r--source/blender/windowmanager/manipulators/intern/wm_manipulator_property.c4
6 files changed, 35 insertions, 52 deletions
diff --git a/source/blender/windowmanager/manipulators/WM_manipulator_api.h b/source/blender/windowmanager/manipulators/WM_manipulator_api.h
index f613ca60329..f435ced75e7 100644
--- a/source/blender/windowmanager/manipulators/WM_manipulator_api.h
+++ b/source/blender/windowmanager/manipulators/WM_manipulator_api.h
@@ -64,7 +64,7 @@ void WM_manipulator_free(
ListBase *manipulatorlist, struct wmManipulatorMap *mmap, struct wmManipulator *mpr,
struct bContext *C);
-struct PointerRNA *WM_manipulator_set_operator(struct wmManipulator *, const char *opname);
+struct PointerRNA *WM_manipulator_set_operator(struct wmManipulator *, struct wmOperatorType *ot);
/* callbacks */
void WM_manipulator_set_fn_custom_modal(struct wmManipulator *mpr, wmManipulatorFnModal fn);
diff --git a/source/blender/windowmanager/manipulators/WM_manipulator_types.h b/source/blender/windowmanager/manipulators/WM_manipulator_types.h
index 6fd9f38671c..ae27de60805 100644
--- a/source/blender/windowmanager/manipulators/WM_manipulator_types.h
+++ b/source/blender/windowmanager/manipulators/WM_manipulator_types.h
@@ -100,10 +100,12 @@ struct wmManipulator {
void *interaction_data;
/* name of operator to spawn when activating the manipulator */
- const char *opname;
- /* operator properties if manipulator spawns and controls an operator,
- * or owner pointer if manipulator spawns and controls a property */
- PointerRNA opptr;
+ struct {
+ struct wmOperatorType *type;
+ /* operator properties if manipulator spawns and controls an operator,
+ * or owner pointer if manipulator spawns and controls a property */
+ PointerRNA ptr;
+ } op_data;
/* Properties 'wmManipulatorProperty' attached to various manipulator parameters.
* As the manipulator is interacted with, those properties get updated.
diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator.c
index 6ba4d55e1e4..6a36a99d9c5 100644
--- a/source/blender/windowmanager/manipulators/intern/wm_manipulator.c
+++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator.c
@@ -171,8 +171,8 @@ void WM_manipulator_free(ListBase *manipulatorlist, wmManipulatorMap *mmap, wmMa
wm_manipulator_deselect(mmap, mpr);
}
- if (mpr->opptr.data) {
- WM_operator_properties_free(&mpr->opptr);
+ if (mpr->op_data.ptr.data) {
+ WM_operator_properties_free(&mpr->op_data.ptr);
}
BLI_freelistN(&mpr->properties);
@@ -194,25 +194,16 @@ void WM_manipulator_free(ListBase *manipulatorlist, wmManipulatorMap *mmap, wmMa
* \{ */
-PointerRNA *WM_manipulator_set_operator(wmManipulator *mpr, const char *opname)
+PointerRNA *WM_manipulator_set_operator(wmManipulator *mpr, wmOperatorType *ot)
{
- wmOperatorType *ot = WM_operatortype_find(opname, 0);
+ mpr->op_data.type = ot;
- if (ot) {
- mpr->opname = opname;
-
- if (mpr->opptr.data) {
- WM_operator_properties_free(&mpr->opptr);
- }
- WM_operator_properties_create_ptr(&mpr->opptr, ot);
-
- return &mpr->opptr;
- }
- else {
- fprintf(stderr, "Error binding operator to manipulator: operator %s not found!\n", opname);
+ if (mpr->op_data.ptr.data) {
+ WM_operator_properties_free(&mpr->op_data.ptr);
}
+ WM_operator_properties_create_ptr(&mpr->op_data.ptr, ot);
- return NULL;
+ return &mpr->op_data.ptr;
}
static void wm_manipulator_set_matrix_rotation_from_z_axis__internal(
diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator_group.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator_group.c
index cee50c4e155..e9d7356df3a 100644
--- a/source/blender/windowmanager/manipulators/intern/wm_manipulator_group.c
+++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator_group.c
@@ -356,9 +356,8 @@ static int manipulator_tweak_invoke(bContext *C, wmOperator *op, const wmEvent *
/* XXX temporary workaround for modal manipulator operator
* conflicting with modal operator attached to manipulator */
- if (mpr->opname) {
- wmOperatorType *ot = WM_operatortype_find(mpr->opname, true);
- if (ot->modal) {
+ if (mpr->op_data.type) {
+ if (mpr->op_data.type->modal) {
return OPERATOR_FINISHED;
}
}
diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c
index 6bca825fd16..0f1a6e9d96e 100644
--- a/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c
+++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c
@@ -424,8 +424,8 @@ void wm_manipulatormaps_handled_modal_update(
/* regular update for running operator */
if (modal_running) {
- if (mpr && mpr->opname &&
- STREQ(mpr->opname, handler->op->idname))
+ if (mpr && (mpr->op_data.type != NULL) &&
+ (mpr->op_data.type == handler->op->type))
{
if (mpr->custom_modal) {
mpr->custom_modal(C, mpr, event, 0);
@@ -640,32 +640,23 @@ void wm_manipulatormap_active_set(
mpr->state |= WM_MANIPULATOR_STATE_ACTIVE;
mmap->mmap_context.active = mpr;
- if (mpr->opname) {
- wmOperatorType *ot = WM_operatortype_find(mpr->opname, 0);
-
- if (ot) {
- /* first activate the manipulator itself */
- if (mpr->type->invoke &&
- (mpr->type->modal || mpr->custom_modal))
- {
- mpr->type->invoke(C, mpr, event);
- }
+ if (mpr->op_data.type) {
+ /* first activate the manipulator itself */
+ if (mpr->type->invoke &&
+ (mpr->type->modal || mpr->custom_modal))
+ {
+ mpr->type->invoke(C, mpr, event);
+ }
- WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &mpr->opptr);
+ WM_operator_name_call_ptr(C, mpr->op_data.type, WM_OP_INVOKE_DEFAULT, &mpr->op_data.ptr);
- /* we failed to hook the manipulator to the operator handler or operator was cancelled, return */
- if (!mmap->mmap_context.active) {
- mpr->state &= ~WM_MANIPULATOR_STATE_ACTIVE;
- /* first activate the manipulator itself */
- MEM_SAFE_FREE(mpr->interaction_data);
- }
- return;
- }
- else {
- printf("Manipulator error: operator not found");
- mmap->mmap_context.active = NULL;
- return;
+ /* we failed to hook the manipulator to the operator handler or operator was cancelled, return */
+ if (!mmap->mmap_context.active) {
+ mpr->state &= ~WM_MANIPULATOR_STATE_ACTIVE;
+ /* first activate the manipulator itself */
+ MEM_SAFE_FREE(mpr->interaction_data);
}
+ return;
}
else {
if (mpr->type->invoke &&
diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator_property.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator_property.c
index e280fc6db79..58dcfa586d8 100644
--- a/source/blender/windowmanager/manipulators/intern/wm_manipulator_property.c
+++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator_property.c
@@ -79,7 +79,7 @@ void WM_manipulator_property_def_rna(
wmManipulatorProperty *mpr_prop = wm_manipulator_property_def_internal(mpr, idname);
/* if manipulator evokes an operator we cannot use it for property manipulation */
- mpr->opname = NULL;
+ mpr->op_data.type = NULL;
mpr_prop->ptr = *ptr;
mpr_prop->prop = RNA_struct_find_property(ptr, propname);
@@ -97,7 +97,7 @@ void WM_manipulator_property_def_func(
wmManipulatorProperty *mpr_prop = wm_manipulator_property_def_internal(mpr, idname);
/* if manipulator evokes an operator we cannot use it for property manipulation */
- mpr->opname = NULL;
+ mpr->op_data.type = NULL;
mpr_prop->custom_func.value_get_fn = params->value_get_fn;
mpr_prop->custom_func.value_set_fn = params->value_set_fn;