forked from bartvdbraak/blender
code cleanup and minor changes
- use DummyRNA_NULL_items to replace empty enums. - replace calloc with malloc in copy_dverts since its copied over after. - add wmGesture->userdata, so operators that use gestures have somewhere to store their own data (not used yet).
This commit is contained in:
parent
78e688b71c
commit
2a5cabb039
@ -152,7 +152,7 @@ void BKE_mesh_from_nurbs_displist(struct Object *ob, struct ListBase *dispbase,
|
||||
int **orco_index_ptr);
|
||||
void BKE_mesh_from_curve(struct Scene *scene, struct Object *ob);
|
||||
void free_dverts(struct MDeformVert *dvert, int totvert);
|
||||
void copy_dverts(struct MDeformVert *dst, struct MDeformVert *src, int totvert); /* __NLA */
|
||||
void copy_dverts(struct MDeformVert *dst, const struct MDeformVert *src, int totvert);
|
||||
void BKE_mesh_delete_material_index(struct Mesh *me, short index);
|
||||
void BKE_mesh_smooth_flag_set(struct Object *meshOb, int enableSmooth);
|
||||
void BKE_mesh_convert_mfaces_to_mpolys(struct Mesh *mesh);
|
||||
|
@ -430,7 +430,7 @@ void BKE_mesh_free(Mesh *me, int unlink)
|
||||
if (me->edit_btmesh) MEM_freeN(me->edit_btmesh);
|
||||
}
|
||||
|
||||
void copy_dverts(MDeformVert *dst, MDeformVert *src, int copycount)
|
||||
void copy_dverts(MDeformVert *dst, const MDeformVert *src, int copycount)
|
||||
{
|
||||
/* Assumes dst is already set up */
|
||||
int i;
|
||||
@ -442,7 +442,7 @@ void copy_dverts(MDeformVert *dst, MDeformVert *src, int copycount)
|
||||
|
||||
for (i = 0; i < copycount; i++) {
|
||||
if (src[i].dw) {
|
||||
dst[i].dw = MEM_callocN(sizeof(MDeformWeight) * src[i].totweight, "copy_deformWeight");
|
||||
dst[i].dw = MEM_mallocN(sizeof(MDeformWeight) * src[i].totweight, "copy_deformWeight");
|
||||
memcpy(dst[i].dw, src[i].dw, sizeof(MDeformWeight) * src[i].totweight);
|
||||
}
|
||||
}
|
||||
|
@ -687,9 +687,6 @@ static int poselib_rename_exec(bContext *C, wmOperator *op)
|
||||
void POSELIB_OT_pose_rename(wmOperatorType *ot)
|
||||
{
|
||||
PropertyRNA *prop;
|
||||
static EnumPropertyItem prop_poses_dummy_types[] = {
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
/* identifiers */
|
||||
ot->name = "PoseLib Rename Pose";
|
||||
@ -707,7 +704,7 @@ void POSELIB_OT_pose_rename(wmOperatorType *ot)
|
||||
/* properties */
|
||||
/* NOTE: name not pose is the operator's "main" property, so that it will get activated in the popup for easy renaming */
|
||||
ot->prop = RNA_def_string(ot->srna, "name", "RenamedPose", 64, "New Pose Name", "New name for pose");
|
||||
prop = RNA_def_enum(ot->srna, "pose", prop_poses_dummy_types, 0, "Pose", "The pose to rename");
|
||||
prop = RNA_def_enum(ot->srna, "pose", DummyRNA_NULL_items, 0, "Pose", "The pose to rename");
|
||||
RNA_def_enum_funcs(prop, poselib_stored_pose_itemf);
|
||||
}
|
||||
|
||||
|
@ -1020,7 +1020,7 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, wmEvent *event)
|
||||
|
||||
/* y-axis transform */
|
||||
dist = BLI_rcti_size_y(&v2d->mask) / 2.0f;
|
||||
dy = 1.0f - (fabsf(vzd->lasty - vzd->ar->winrct.ymin- dist) + 2.0f) / (fabsf(event->mval[1] - dist) + 2.0f);
|
||||
dy = 1.0f - (fabsf(vzd->lasty - vzd->ar->winrct.ymin - dist) + 2.0f) / (fabsf(event->mval[1] - dist) + 2.0f);
|
||||
dy *= 0.5f * BLI_rctf_size_y(&v2d->cur);
|
||||
}
|
||||
else {
|
||||
|
@ -40,6 +40,7 @@
|
||||
|
||||
#include "RNA_define.h"
|
||||
#include "RNA_access.h"
|
||||
#include "RNA_enum_types.h"
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_noise.h"
|
||||
@ -2528,7 +2529,6 @@ static void edbm_blend_from_shape_ui(bContext *C, wmOperator *op)
|
||||
void MESH_OT_blend_from_shape(wmOperatorType *ot)
|
||||
{
|
||||
PropertyRNA *prop;
|
||||
static EnumPropertyItem shape_items[] = {{0, NULL, 0, NULL, NULL}};
|
||||
|
||||
/* identifiers */
|
||||
ot->name = "Blend From Shape";
|
||||
@ -2545,7 +2545,7 @@ void MESH_OT_blend_from_shape(wmOperatorType *ot)
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
prop = RNA_def_enum(ot->srna, "shape", shape_items, 0, "Shape", "Shape key to use for blending");
|
||||
prop = RNA_def_enum(ot->srna, "shape", DummyRNA_NULL_items, 0, "Shape", "Shape key to use for blending");
|
||||
RNA_def_enum_funcs(prop, shape_itemf);
|
||||
RNA_def_float(ot->srna, "blend", 1.0f, -FLT_MAX, FLT_MAX, "Blend", "Blending factor", -2.0f, 2.0f);
|
||||
RNA_def_boolean(ot->srna, "add", 1, "Add", "Add rather than blend between shapes");
|
||||
|
@ -1676,10 +1676,6 @@ static EnumPropertyItem game_properties_copy_operations[] = {
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
static EnumPropertyItem gameprops_items[] = {
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
static EnumPropertyItem *gameprops_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free)
|
||||
{
|
||||
Object *ob = ED_object_active_context(C);
|
||||
@ -1689,7 +1685,7 @@ static EnumPropertyItem *gameprops_itemf(bContext *C, PointerRNA *UNUSED(ptr), P
|
||||
int a, totitem = 0;
|
||||
|
||||
if (!ob)
|
||||
return gameprops_items;
|
||||
return DummyRNA_NULL_items;
|
||||
|
||||
for (a = 1, prop = ob->prop.first; prop; prop = prop->next, a++) {
|
||||
tmp.value = a;
|
||||
@ -1760,7 +1756,7 @@ void OBJECT_OT_game_property_copy(wmOperatorType *ot)
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
RNA_def_enum(ot->srna, "operation", game_properties_copy_operations, 3, "Operation", "");
|
||||
prop = RNA_def_enum(ot->srna, "property", gameprops_items, 0, "Property", "Properties to copy");
|
||||
prop = RNA_def_enum(ot->srna, "property", DummyRNA_NULL_items, 0, "Property", "Properties to copy");
|
||||
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
||||
RNA_def_enum_funcs(prop, gameprops_itemf);
|
||||
ot->prop = prop;
|
||||
|
@ -65,6 +65,7 @@
|
||||
|
||||
#include "RNA_access.h"
|
||||
#include "RNA_define.h"
|
||||
#include "RNA_enum_types.h"
|
||||
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
@ -3369,10 +3370,6 @@ void OBJECT_OT_vertex_group_transfer_weight(wmOperatorType *ot)
|
||||
ot->prop = RNA_def_enum(ot->srna, "WT_replace_mode", WT_replace_mode_item, 1, "Replace", "");
|
||||
}
|
||||
|
||||
static EnumPropertyItem vgroup_items[] = {
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
static int set_active_group_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *ob = ED_object_context(C);
|
||||
@ -3396,7 +3393,7 @@ static EnumPropertyItem *vgroup_itemf(bContext *C, PointerRNA *UNUSED(ptr), Prop
|
||||
int a, totitem = 0;
|
||||
|
||||
if (!ob)
|
||||
return vgroup_items;
|
||||
return DummyRNA_NULL_items;
|
||||
|
||||
for (a = 0, def = ob->defbase.first; def; def = def->next, a++) {
|
||||
tmp.value = a;
|
||||
@ -3430,7 +3427,7 @@ void OBJECT_OT_vertex_group_set_active(wmOperatorType *ot)
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
prop = RNA_def_enum(ot->srna, "group", vgroup_items, 0, "Group", "Vertex group to set as active");
|
||||
prop = RNA_def_enum(ot->srna, "group", DummyRNA_NULL_items, 0, "Group", "Vertex group to set as active");
|
||||
RNA_def_enum_funcs(prop, vgroup_itemf);
|
||||
ot->prop = prop;
|
||||
}
|
||||
|
@ -402,12 +402,28 @@ static int wpaint_mirror_vgroup_ensure(Object *ob, const int vgroup_active)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void copy_vpaint_prev(VPaint *vp, unsigned int *lcol, int tot)
|
||||
static void free_vpaint_prev(VPaint *vp)
|
||||
{
|
||||
if (vp->vpaint_prev) {
|
||||
MEM_freeN(vp->vpaint_prev);
|
||||
vp->vpaint_prev = NULL;
|
||||
vp->tot = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void free_wpaint_prev(VPaint *vp)
|
||||
{
|
||||
if (vp->wpaint_prev) {
|
||||
MEM_freeN(vp->wpaint_prev);
|
||||
vp->wpaint_prev = NULL;
|
||||
vp->tot = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void copy_vpaint_prev(VPaint *vp, unsigned int *lcol, int tot)
|
||||
{
|
||||
free_vpaint_prev(vp);
|
||||
|
||||
vp->tot = tot;
|
||||
|
||||
if (lcol == NULL || tot == 0) return;
|
||||
@ -419,10 +435,7 @@ static void copy_vpaint_prev(VPaint *vp, unsigned int *lcol, int tot)
|
||||
|
||||
static void copy_wpaint_prev(VPaint *wp, MDeformVert *dverts, int dcount)
|
||||
{
|
||||
if (wp->wpaint_prev) {
|
||||
free_dverts(wp->wpaint_prev, wp->tot);
|
||||
wp->wpaint_prev = NULL;
|
||||
}
|
||||
free_wpaint_prev(wp);
|
||||
|
||||
if (dverts && dcount) {
|
||||
|
||||
@ -432,7 +445,6 @@ static void copy_wpaint_prev(VPaint *wp, MDeformVert *dverts, int dcount)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void vpaint_fill(Object *ob, unsigned int paintcol)
|
||||
{
|
||||
Mesh *me;
|
||||
|
@ -764,7 +764,7 @@ static EnumPropertyItem prop_id_op_types[] = {
|
||||
{OUTLINER_IDOP_LOCAL, "LOCAL", 0, "Make Local", ""},
|
||||
{OUTLINER_IDOP_SINGLE, "SINGLE", 0, "Make Single User", ""},
|
||||
{OUTLINER_IDOP_FAKE_ADD, "ADD_FAKE", 0, "Add Fake User",
|
||||
"Ensure datablock gets saved even if it isn't in use (e.g. for motion and material libraries)"},
|
||||
"Ensure datablock gets saved even if it isn't in use (e.g. for motion and material libraries)"},
|
||||
{OUTLINER_IDOP_FAKE_CLEAR, "CLEAR_FAKE", 0, "Clear Fake User", ""},
|
||||
{OUTLINER_IDOP_RENAME, "RENAME", 0, "Rename", ""},
|
||||
{OUTLINER_IDOP_SELECT_LINKED, "SELECT_LINKED", 0, "Select Linked", ""},
|
||||
|
@ -407,6 +407,9 @@ typedef struct wmGesture {
|
||||
/* customdata for circle is recti, (xmin, ymin) is center, xmax radius */
|
||||
/* customdata for lasso is short array */
|
||||
/* customdata for straight line is a recti: (xmin,ymin) is start, (xmax, ymax) is end */
|
||||
|
||||
/* free pointer to use for operator allocs (if set, its freed on exit)*/
|
||||
void *userdata;
|
||||
} wmGesture;
|
||||
|
||||
/* ************** wmEvent ************************ */
|
||||
|
@ -113,6 +113,9 @@ void WM_gesture_end(bContext *C, wmGesture *gesture)
|
||||
win->tweak = NULL;
|
||||
BLI_remlink(&win->gesture, gesture);
|
||||
MEM_freeN(gesture->customdata);
|
||||
if (gesture->userdata) {
|
||||
MEM_freeN(gesture->userdata);
|
||||
}
|
||||
MEM_freeN(gesture);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user