Commit: ce4e980d3dc89aeff940c138ef36629b57e3e608
Author: Campbell Barton
Date: Thu Jun 22 09:40:24 2017 +1000
Branches: custom-manipulators
https://developer.blender.org/rBce4e980d3dc89aeff940c138ef36629b57e3e608
Manipulator: properties into 'wmManipulator'
We normally only have one or two, don't have a separate linked list.
Also store type in the property.
===================================================================
M
source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c
M
source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c
M
source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c
M source/blender/windowmanager/manipulators/WM_manipulator_api.h
M source/blender/windowmanager/manipulators/WM_manipulator_types.h
M source/blender/windowmanager/manipulators/intern/wm_manipulator.c
M
source/blender/windowmanager/manipulators/intern/wm_manipulator_target_props.c
===================================================================
diff --git
a/source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c
b/source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c
index 42724007176..88ad75ee8c8 100644
---
a/source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c
+++
b/source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c
@@ -424,8 +424,8 @@ void ED_manipulator_arrow3d_set_ui_range(wmManipulator
*mpr, const float min, co
ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr;
BLI_assert(min < max);
- BLI_assert(!(WM_manipulator_target_property_find(mpr, "offset") &&
"Make sure this function "
- "is called before WM_manipulator_target_property_def_rna"));
+
BLI_assert(!(WM_manipulator_target_property_is_valid(WM_manipulator_target_property_find(mpr,
"offset")) &&
+ "Make sure this function is called before
WM_manipulator_target_property_def_rna"));
arrow->data.range = max - min;
arrow->data.min = min;
@@ -440,8 +440,8 @@ void ED_manipulator_arrow3d_set_ui_range(wmManipulator
*mpr, const float min, co
void ED_manipulator_arrow3d_set_range_fac(wmManipulator *mpr, const float
range_fac)
{
ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr;
- BLI_assert(!(WM_manipulator_target_property_find(mpr, "offset") &&
"Make sure this function "
- "is called before WM_manipulator_target_property_def_rna"));
+
BLI_assert(!(WM_manipulator_target_property_is_valid(WM_manipulator_target_property_find(mpr,
"offset")) &&
+ "Make sure this function is called before
WM_manipulator_target_property_def_rna"));
arrow->data.range_fac = range_fac;
}
diff --git
a/source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c
b/source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c
index 9ef81481638..72db4a89f08 100644
---
a/source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c
+++
b/source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c
@@ -383,14 +383,14 @@ static bool manipulator_rect_transform_get_prop_value(
return false;
}
else {
- if (STREQ(mpr_prop->idname, "offset")) {
+ if (STREQ(mpr_prop->type->idname, "offset")) {
if (RNA_property_array_length(&mpr_prop->ptr,
mpr_prop->prop) != 2) {
fprintf(stderr, "Rect Transform manipulator
offset not only be bound to array float property");
return false;
}
RNA_property_float_get_array(&mpr_prop->ptr,
mpr_prop->prop, value);
}
- else if (STREQ(mpr_prop->idname, "scale")) {
+ else if (STREQ(mpr_prop->type->idname, "scale")) {
const int transform_flag = RNA_enum_get(mpr->ptr,
"transform");
if (transform_flag &
ED_MANIPULATOR_RECT_TRANSFORM_FLAG_SCALE_UNIFORM) {
*value = RNA_property_float_get(&mpr_prop->ptr,
mpr_prop->prop);
@@ -533,10 +533,10 @@ static void manipulator_rect_transform_modal(
static void manipulator_rect_transform_property_update(wmManipulator *mpr,
wmManipulatorProperty *mpr_prop)
{
- if (STREQ(mpr_prop->idname, "offset")) {
+ if (STREQ(mpr_prop->type->idname, "offset")) {
manipulator_rect_transform_get_prop_value(mpr, mpr_prop,
mpr->matrix_offset[3]);
}
- else if (STREQ(mpr_prop->idname, "scale")) {
+ else if (STREQ(mpr_prop->type->idname, "scale")) {
float scale[2];
RNA_float_get_array(mpr->ptr, "scale", scale);
manipulator_rect_transform_get_prop_value(mpr, mpr_prop, scale);
diff --git
a/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c
b/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c
index 098bd7c495f..c4c572dde2b 100644
---
a/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c
+++
b/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c
@@ -293,7 +293,7 @@ static void dial_draw_intern(
DialInteraction *inter = mpr->interaction_data;
/* XXX, View3D rotation manipulator doesn't call modal. */
- if (mpr->target_properties.first == NULL) {
+ if (mpr->target_properties_len_set == 0) {
wmWindow *win = CTX_wm_window(C);
manipulator_dial_modal((bContext *)C, mpr,
win->eventstate, 0);
}
diff --git a/source/blender/windowmanager/manipulators/WM_manipulator_api.h
b/source/blender/windowmanager/manipulators/WM_manipulator_api.h
index e63e27372eb..6bcd83dce3b 100644
--- a/source/blender/windowmanager/manipulators/WM_manipulator_api.h
+++ b/source/blender/windowmanager/manipulators/WM_manipulator_api.h
@@ -134,6 +134,9 @@ void WM_manipulatorconfig_update(struct Main *bmain);
/* wm_maniulator_target_props.c */
+struct wmManipulatorProperty *WM_manipulator_target_property_array(struct
wmManipulator *mpr);
+struct wmManipulatorProperty *WM_manipulator_target_property_at_index(
+ struct wmManipulator *mpr, int index);
struct wmManipulatorProperty *WM_manipulator_target_property_find(
struct wmManipulator *mpr, const char *idname);
diff --git a/source/blender/windowmanager/manipulators/WM_manipulator_types.h
b/source/blender/windowmanager/manipulators/WM_manipulator_types.h
index 11b5be412b5..601247c72ea 100644
--- a/source/blender/windowmanager/manipulators/WM_manipulator_types.h
+++ b/source/blender/windowmanager/manipulators/WM_manipulator_types.h
@@ -110,15 +110,11 @@ struct wmManipulator {
PointerRNA ptr;
} op_data;
- /* Properties 'wmManipulatorProperty' attached to various manipulator
parameters.
- * As the manipulator is interacted with, those properties get updated.
- *
- * Public API's should use string names,
- * private API's can pass 'wmManipulatorProperty' directly.
- */
- ListBase target_properties;
-
struct IDProperty *properties;
+
+ int target_properties_len_set;
+
+ /* over alloc target_properties after 'wmManipulatorType.struct_size' */
};
typedef void (*wmManipulatorGroupFnInit)(
@@ -126,11 +122,13 @@ typedef void (*wmManipulatorGroupFnInit)(
/* Similar to PropertyElemRNA, but has an identifier. */
typedef struct wmManipulatorProperty {
- struct wmManipulatorProperty *next, *prev;
+ const struct wmManipulatorPropertyType *type;
+
PointerRNA ptr;
PropertyRNA *prop;
int index;
+
/* Optional functions for converting to/from RNA */
struct {
wmManipulatorPropertyFnGet value_get_fn;
@@ -139,9 +137,6 @@ typedef struct wmManipulatorProperty {
const struct bContext *context;
void *user_data;
} custom_func;
-
- /* over alloc */
- char idname[0];
} wmManipulatorProperty;
typedef struct wmManipulatorPropertyType {
@@ -150,6 +145,9 @@ typedef struct wmManipulatorPropertyType {
int type;
int array_length;
+ /* index within 'wmManipulatorType' */
+ int index_in_type;
+
/* over alloc */
char idname[0];
} wmManipulatorPropertyType;
@@ -247,6 +245,7 @@ typedef struct wmManipulatorType {
ExtensionRNA ext;
ListBase target_property_defs;
+ int target_property_defs_len;
} wmManipulatorType;
diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator.c
b/source/blender/windowmanager/manipulators/intern/wm_manipulator.c
index 1156298c51a..9c3e9a635b2 100644
--- a/source/blender/windowmanager/manipulators/intern/wm_manipulator.c
+++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator.c
@@ -77,7 +77,8 @@ static wmManipulator *wm_manipulator_create(
BLI_assert(wt != NULL);
BLI_assert(wt->struct_size >= sizeof(wmManipulator));
- wmManipulator *mpr = MEM_callocN(wt->struct_size, __func__);
+ wmManipulator *mpr = MEM_callocN(
+ wt->struct_size + (sizeof(wmManipulatorProperty) *
wt->target_property_defs_len), __func__);
mpr->type = wt;
/* initialize properties, either copy or create */
@@ -197,7 +198,6 @@ void WM_manipulator_free(ListBase *manipulatorlist,
wmManipulatorMap *mmap, wmMa
if (mpr->op_data.ptr.data) {
WM_operator_properties_free(&mpr->op_data.ptr);
}
- BLI_freelistN(&mpr->target_properties);
if (mpr->ptr != NULL) {
WM_manipulator_properties_free(mpr->ptr);
@@ -461,8 +461,10 @@ void wm_manipulator_calculate_scale(wmManipulator *mpr,
const bContext *C)
static void manipulator_update_prop_data(wmManipulator *mpr)
{
/* manipulator property might have been changed, so update manipulator
*/
- if (mpr->type->property_update &&
!BLI_listbase_is_empty(&mpr->target_properties)) {
- for (wmManipulatorProperty *mpr_prop =
mpr->target_properties.first; mpr_prop; mpr_prop = mpr_prop->next) {
+ if (mpr->type->property_update && mpr->target_properties_len_set) {
+ wmManipulatorProperty *mpr_prop_array =
WM_manipulator_target_property_array(mpr);
+ for (int i = 0; i < mpr->type->target_property_defs_len; i++) {
+ wmManipulatorProperty *mpr_prop = &mpr_prop_array[i];
if (WM_manipulator_target_property_is_valid(mpr_prop)) {
mpr->type->property_update(mpr, mpr_prop);
}
diff --git
a/source/blender/windowmanager/manipulators/intern/wm_manipulator_target_props.c
b/source/blender/windowmanager/manipulators/intern/wm_manipulator_target_props.c
index b629213b11b..5eb72c5be3f 100644
---
a/source/blender/windowmanager/manipulators/intern/wm_manipulator_target_props.c
+++
b/source/blender/windowmanager/manipulators/intern/wm_manipulator_target_props.c
@@ -53,34 +53,47 @@
/** \name Property Definition
* \{ */
-wmManipulatorProperty *WM_manipulator_target_property_find(wmManipulator *mpr,
const char *idname)
+BLI_INLINE wmManipulatorProperty
*wm_manipulator_target_property_array(wmManipulator *mpr)
{
- return BLI_findstring(&mpr->target_properties, idname,
offsetof(wmManipulatorProperty, idname));
+ return (wmManipulatorProperty *)(POINTER_OFFSET(mpr,
mpr->type->struct_size));
}
-static wmManipulatorProperty *wm_manipulator_target_property_def_internal(
- wmManipulator *mpr, const wmManipulatorPropertyType *mpr_prop_type)
+wmManipulatorProperty *WM_manipulator_target_property_array(wmManipulator *mpr)
{
- wmManipulatorProperty *mpr_prop =
WM_manipulator_target_property_find(mpr, mpr_prop_type->idname);
+ return wm_manipulator_target_property_array(mpr);
+}
+
+wmManipulatorProperty *WM_manipulator_target_property_at_index(wmManipulator
*mpr, int index)
+{
+ BLI_assert(index < mpr->type->target_property_defs_len)
@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs