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>2019-04-17 07:17:24 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-04-17 07:21:24 +0300
commite12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch)
tree8cf3453d12edb177a218ef8009357518ec6cab6a /source/blender/editors/lattice
parentb3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff)
ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211. For details on usage and instructions for migrating branches without conflicts, see: https://wiki.blender.org/wiki/Tools/ClangFormat
Diffstat (limited to 'source/blender/editors/lattice')
-rw-r--r--source/blender/editors/lattice/CMakeLists.txt30
-rw-r--r--source/blender/editors/lattice/editlattice_select.c963
-rw-r--r--source/blender/editors/lattice/editlattice_tools.c531
-rw-r--r--source/blender/editors/lattice/editlattice_undo.c225
-rw-r--r--source/blender/editors/lattice/lattice_intern.h3
-rw-r--r--source/blender/editors/lattice/lattice_ops.c20
6 files changed, 902 insertions, 870 deletions
diff --git a/source/blender/editors/lattice/CMakeLists.txt b/source/blender/editors/lattice/CMakeLists.txt
index 5a231837d0b..f9c08727128 100644
--- a/source/blender/editors/lattice/CMakeLists.txt
+++ b/source/blender/editors/lattice/CMakeLists.txt
@@ -16,16 +16,16 @@
# ***** END GPL LICENSE BLOCK *****
set(INC
- ../include
- ../../blenkernel
- ../../blenlib
- ../../depsgraph
- ../../makesdna
- ../../makesrna
- ../../render/extern/include
- ../../windowmanager
- ../../../../intern/clog
- ../../../../intern/guardedalloc
+ ../include
+ ../../blenkernel
+ ../../blenlib
+ ../../depsgraph
+ ../../makesdna
+ ../../makesrna
+ ../../render/extern/include
+ ../../windowmanager
+ ../../../../intern/clog
+ ../../../../intern/guardedalloc
)
set(INC_SYS
@@ -33,12 +33,12 @@ set(INC_SYS
)
set(SRC
- editlattice_select.c
- editlattice_tools.c
- editlattice_undo.c
- lattice_ops.c
+ editlattice_select.c
+ editlattice_tools.c
+ editlattice_undo.c
+ lattice_ops.c
- lattice_intern.h
+ lattice_intern.h
)
set(LIB
diff --git a/source/blender/editors/lattice/editlattice_select.c b/source/blender/editors/lattice/editlattice_select.c
index a92ed02c483..782c0644313 100644
--- a/source/blender/editors/lattice/editlattice_select.c
+++ b/source/blender/editors/lattice/editlattice_select.c
@@ -65,37 +65,38 @@
static void bpoint_select_set(BPoint *bp, bool select)
{
- if (select) {
- if (!bp->hide) {
- bp->f1 |= SELECT;
- }
- }
- else {
- bp->f1 &= ~SELECT;
- }
+ if (select) {
+ if (!bp->hide) {
+ bp->f1 |= SELECT;
+ }
+ }
+ else {
+ bp->f1 &= ~SELECT;
+ }
}
bool ED_lattice_deselect_all_multi_ex(struct Base **bases, const uint bases_len)
{
- bool changed_multi = false;
- for (uint base_index = 0; base_index < bases_len; base_index++) {
- Base *base_iter = bases[base_index];
- Object *ob_iter = base_iter->object;
- changed_multi |= ED_lattice_flags_set(ob_iter, 0);
- DEG_id_tag_update(ob_iter->data, ID_RECALC_SELECT);
- }
- return changed_multi;
+ bool changed_multi = false;
+ for (uint base_index = 0; base_index < bases_len; base_index++) {
+ Base *base_iter = bases[base_index];
+ Object *ob_iter = base_iter->object;
+ changed_multi |= ED_lattice_flags_set(ob_iter, 0);
+ DEG_id_tag_update(ob_iter->data, ID_RECALC_SELECT);
+ }
+ return changed_multi;
}
bool ED_lattice_deselect_all_multi(struct bContext *C)
{
- ViewContext vc;
- ED_view3d_viewcontext_init(C, &vc);
- uint bases_len = 0;
- Base **bases = BKE_view_layer_array_from_bases_in_edit_mode_unique_data(vc.view_layer, vc.v3d, &bases_len);
- bool changed_multi = ED_lattice_deselect_all_multi_ex(bases, bases_len);
- MEM_freeN(bases);
- return changed_multi;
+ ViewContext vc;
+ ED_view3d_viewcontext_init(C, &vc);
+ uint bases_len = 0;
+ Base **bases = BKE_view_layer_array_from_bases_in_edit_mode_unique_data(
+ vc.view_layer, vc.v3d, &bases_len);
+ bool changed_multi = ED_lattice_deselect_all_multi_ex(bases, bases_len);
+ MEM_freeN(bases);
+ return changed_multi;
}
/** \} */
@@ -106,64 +107,64 @@ bool ED_lattice_deselect_all_multi(struct bContext *C)
static int lattice_select_random_exec(bContext *C, wmOperator *op)
{
- const float randfac = RNA_float_get(op->ptr, "percent") / 100.0f;
- const int seed = WM_operator_properties_select_random_seed_increment_get(op);
- const bool select = (RNA_enum_get(op->ptr, "action") == SEL_SELECT);
-
- ViewLayer *view_layer = CTX_data_view_layer(C);
- uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
- for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
- Object *obedit = objects[ob_index];
- Lattice *lt = ((Lattice *)obedit->data)->editlatt->latt;
-
- RNG *rng = BLI_rng_new_srandom(seed);
-
- int tot;
- BPoint *bp;
-
- tot = lt->pntsu * lt->pntsv * lt->pntsw;
- bp = lt->def;
- while (tot--) {
- if (!bp->hide) {
- if (BLI_rng_get_float(rng) < randfac) {
- bpoint_select_set(bp, select);
- }
- }
- bp++;
- }
-
- if (select == false) {
- lt->actbp = LT_ACTBP_NONE;
- }
-
- BLI_rng_free(rng);
-
- DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
-
- }
- MEM_freeN(objects);
-
- return OPERATOR_FINISHED;
+ const float randfac = RNA_float_get(op->ptr, "percent") / 100.0f;
+ const int seed = WM_operator_properties_select_random_seed_increment_get(op);
+ const bool select = (RNA_enum_get(op->ptr, "action") == SEL_SELECT);
+
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(
+ view_layer, CTX_wm_view3d(C), &objects_len);
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ Lattice *lt = ((Lattice *)obedit->data)->editlatt->latt;
+
+ RNG *rng = BLI_rng_new_srandom(seed);
+
+ int tot;
+ BPoint *bp;
+
+ tot = lt->pntsu * lt->pntsv * lt->pntsw;
+ bp = lt->def;
+ while (tot--) {
+ if (!bp->hide) {
+ if (BLI_rng_get_float(rng) < randfac) {
+ bpoint_select_set(bp, select);
+ }
+ }
+ bp++;
+ }
+
+ if (select == false) {
+ lt->actbp = LT_ACTBP_NONE;
+ }
+
+ BLI_rng_free(rng);
+
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
+ }
+ MEM_freeN(objects);
+
+ return OPERATOR_FINISHED;
}
void LATTICE_OT_select_random(wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Select Random";
- ot->description = "Randomly select UVW control points";
- ot->idname = "LATTICE_OT_select_random";
+ /* identifiers */
+ ot->name = "Select Random";
+ ot->description = "Randomly select UVW control points";
+ ot->idname = "LATTICE_OT_select_random";
- /* api callbacks */
- ot->exec = lattice_select_random_exec;
- ot->poll = ED_operator_editlattice;
+ /* api callbacks */
+ ot->exec = lattice_select_random_exec;
+ ot->poll = ED_operator_editlattice;
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- /* props */
- WM_operator_properties_select_random(ot);
+ /* props */
+ WM_operator_properties_select_random(ot);
}
/** \} */
@@ -174,89 +175,89 @@ void LATTICE_OT_select_random(wmOperatorType *ot)
static void ed_lattice_select_mirrored(Lattice *lt, const int axis, const bool extend)
{
- const int tot = lt->pntsu * lt->pntsv * lt->pntsw;
- int i;
- BPoint *bp;
- BLI_bitmap *selpoints;
-
- bool flip_uvw[3] = {false};
- flip_uvw[axis] = true;
-
- /* we could flip this too */
- if (!extend) {
- lt->actbp = LT_ACTBP_NONE;
- }
-
- /* store "original" selection */
- selpoints = BLI_BITMAP_NEW(tot, __func__);
- BKE_lattice_bitmap_from_flag(lt, selpoints, SELECT, false, false);
-
- /* actual (de)selection */
- for (i = 0; i < tot; i++) {
- const int i_flip = BKE_lattice_index_flip(lt, i, flip_uvw[0], flip_uvw[1], flip_uvw[2]);
- bp = &lt->def[i];
- if (!bp->hide) {
- if (BLI_BITMAP_TEST(selpoints, i_flip)) {
- bp->f1 |= SELECT;
- }
- else {
- if (!extend) {
- bp->f1 &= ~SELECT;
- }
- }
- }
- }
-
-
- MEM_freeN(selpoints);
+ const int tot = lt->pntsu * lt->pntsv * lt->pntsw;
+ int i;
+ BPoint *bp;
+ BLI_bitmap *selpoints;
+
+ bool flip_uvw[3] = {false};
+ flip_uvw[axis] = true;
+
+ /* we could flip this too */
+ if (!extend) {
+ lt->actbp = LT_ACTBP_NONE;
+ }
+
+ /* store "original" selection */
+ selpoints = BLI_BITMAP_NEW(tot, __func__);
+ BKE_lattice_bitmap_from_flag(lt, selpoints, SELECT, false, false);
+
+ /* actual (de)selection */
+ for (i = 0; i < tot; i++) {
+ const int i_flip = BKE_lattice_index_flip(lt, i, flip_uvw[0], flip_uvw[1], flip_uvw[2]);
+ bp = &lt->def[i];
+ if (!bp->hide) {
+ if (BLI_BITMAP_TEST(selpoints, i_flip)) {
+ bp->f1 |= SELECT;
+ }
+ else {
+ if (!extend) {
+ bp->f1 &= ~SELECT;
+ }
+ }
+ }
+ }
+
+ MEM_freeN(selpoints);
}
static int lattice_select_mirror_exec(bContext *C, wmOperator *op)
{
- const int axis_flag = RNA_enum_get(op->ptr, "axis");
- const bool extend = RNA_boolean_get(op->ptr, "extend");
-
- ViewLayer *view_layer = CTX_data_view_layer(C);
- uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
-
- for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
- Object *obedit = objects[ob_index];
- Lattice *lt = ((Lattice *)obedit->data)->editlatt->latt;
-
- for (int axis = 0; axis < 3; axis++) {
- if ((1 << axis) & axis_flag) {
- ed_lattice_select_mirrored(lt, axis, extend);
- }
- }
-
- /* TODO, only notify changes */
- DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
- }
- MEM_freeN(objects);
-
- return OPERATOR_FINISHED;
+ const int axis_flag = RNA_enum_get(op->ptr, "axis");
+ const bool extend = RNA_boolean_get(op->ptr, "extend");
+
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(
+ view_layer, CTX_wm_view3d(C), &objects_len);
+
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ Lattice *lt = ((Lattice *)obedit->data)->editlatt->latt;
+
+ for (int axis = 0; axis < 3; axis++) {
+ if ((1 << axis) & axis_flag) {
+ ed_lattice_select_mirrored(lt, axis, extend);
+ }
+ }
+
+ /* TODO, only notify changes */
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
+ }
+ MEM_freeN(objects);
+
+ return OPERATOR_FINISHED;
}
void LATTICE_OT_select_mirror(wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Select Mirror";
- ot->description = "Select mirrored lattice points";
- ot->idname = "LATTICE_OT_select_mirror";
+ /* identifiers */
+ ot->name = "Select Mirror";
+ ot->description = "Select mirrored lattice points";
+ ot->idname = "LATTICE_OT_select_mirror";
- /* api callbacks */
- ot->exec = lattice_select_mirror_exec;
- ot->poll = ED_operator_editlattice;
+ /* api callbacks */
+ ot->exec = lattice_select_mirror_exec;
+ ot->poll = ED_operator_editlattice;
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- /* props */
- RNA_def_enum_flag(ot->srna, "axis", rna_enum_axis_flag_xyz_items, (1 << 0), "Axis", "");
+ /* props */
+ RNA_def_enum_flag(ot->srna, "axis", rna_enum_axis_flag_xyz_items, (1 << 0), "Axis", "");
- RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection");
+ RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection");
}
/** \} */
@@ -265,112 +266,110 @@ void LATTICE_OT_select_mirror(wmOperatorType *ot)
/** \name Select More/Less Operator
* \{ */
-static bool lattice_test_bitmap_uvw(Lattice *lt, BLI_bitmap *selpoints, int u, int v, int w, const bool selected)
+static bool lattice_test_bitmap_uvw(
+ Lattice *lt, BLI_bitmap *selpoints, int u, int v, int w, const bool selected)
{
- if ((u < 0 || u >= lt->pntsu) ||
- (v < 0 || v >= lt->pntsv) ||
- (w < 0 || w >= lt->pntsw))
- {
- return false;
- }
- else {
- int i = BKE_lattice_index_from_uvw(lt, u, v, w);
- if (lt->def[i].hide == 0) {
- return (BLI_BITMAP_TEST(selpoints, i) != 0) == selected;
- }
- return false;
- }
+ if ((u < 0 || u >= lt->pntsu) || (v < 0 || v >= lt->pntsv) || (w < 0 || w >= lt->pntsw)) {
+ return false;
+ }
+ else {
+ int i = BKE_lattice_index_from_uvw(lt, u, v, w);
+ if (lt->def[i].hide == 0) {
+ return (BLI_BITMAP_TEST(selpoints, i) != 0) == selected;
+ }
+ return false;
+ }
}
static int lattice_select_more_less(bContext *C, const bool select)
{
- ViewLayer *view_layer = CTX_data_view_layer(C);
- uint objects_len;
- bool changed = false;
-
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
- for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
- Object *obedit = objects[ob_index];
- Lattice *lt = ((Lattice *)obedit->data)->editlatt->latt;
- BPoint *bp;
- const int tot = lt->pntsu * lt->pntsv * lt->pntsw;
- int u, v, w;
- BLI_bitmap *selpoints;
-
- lt->actbp = LT_ACTBP_NONE;
-
- selpoints = BLI_BITMAP_NEW(tot, __func__);
- BKE_lattice_bitmap_from_flag(lt, selpoints, SELECT, false, false);
-
- bp = lt->def;
- for (w = 0; w < lt->pntsw; w++) {
- for (v = 0; v < lt->pntsv; v++) {
- for (u = 0; u < lt->pntsu; u++) {
- if ((bp->hide == 0) && (((bp->f1 & SELECT) == 0) == select)) {
- if (lattice_test_bitmap_uvw(lt, selpoints, u + 1, v, w, select) ||
- lattice_test_bitmap_uvw(lt, selpoints, u - 1, v, w, select) ||
- lattice_test_bitmap_uvw(lt, selpoints, u, v + 1, w, select) ||
- lattice_test_bitmap_uvw(lt, selpoints, u, v - 1, w, select) ||
- lattice_test_bitmap_uvw(lt, selpoints, u, v, w + 1, select) ||
- lattice_test_bitmap_uvw(lt, selpoints, u, v, w - 1, select))
- {
- SET_FLAG_FROM_TEST(bp->f1, select, SELECT);
- }
- }
- bp++;
- }
- }
- }
-
- MEM_freeN(selpoints);
-
- changed = true;
- DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
- }
- MEM_freeN(objects);
-
- return changed ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ uint objects_len;
+ bool changed = false;
+
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(
+ view_layer, CTX_wm_view3d(C), &objects_len);
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ Lattice *lt = ((Lattice *)obedit->data)->editlatt->latt;
+ BPoint *bp;
+ const int tot = lt->pntsu * lt->pntsv * lt->pntsw;
+ int u, v, w;
+ BLI_bitmap *selpoints;
+
+ lt->actbp = LT_ACTBP_NONE;
+
+ selpoints = BLI_BITMAP_NEW(tot, __func__);
+ BKE_lattice_bitmap_from_flag(lt, selpoints, SELECT, false, false);
+
+ bp = lt->def;
+ for (w = 0; w < lt->pntsw; w++) {
+ for (v = 0; v < lt->pntsv; v++) {
+ for (u = 0; u < lt->pntsu; u++) {
+ if ((bp->hide == 0) && (((bp->f1 & SELECT) == 0) == select)) {
+ if (lattice_test_bitmap_uvw(lt, selpoints, u + 1, v, w, select) ||
+ lattice_test_bitmap_uvw(lt, selpoints, u - 1, v, w, select) ||
+ lattice_test_bitmap_uvw(lt, selpoints, u, v + 1, w, select) ||
+ lattice_test_bitmap_uvw(lt, selpoints, u, v - 1, w, select) ||
+ lattice_test_bitmap_uvw(lt, selpoints, u, v, w + 1, select) ||
+ lattice_test_bitmap_uvw(lt, selpoints, u, v, w - 1, select)) {
+ SET_FLAG_FROM_TEST(bp->f1, select, SELECT);
+ }
+ }
+ bp++;
+ }
+ }
+ }
+
+ MEM_freeN(selpoints);
+
+ changed = true;
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
+ }
+ MEM_freeN(objects);
+
+ return changed ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
static int lattice_select_more_exec(bContext *C, wmOperator *UNUSED(op))
{
- return lattice_select_more_less(C, true);
+ return lattice_select_more_less(C, true);
}
static int lattice_select_less_exec(bContext *C, wmOperator *UNUSED(op))
{
- return lattice_select_more_less(C, false);
+ return lattice_select_more_less(C, false);
}
void LATTICE_OT_select_more(wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Select More";
- ot->description = "Select vertex directly linked to already selected ones";
- ot->idname = "LATTICE_OT_select_more";
+ /* identifiers */
+ ot->name = "Select More";
+ ot->description = "Select vertex directly linked to already selected ones";
+ ot->idname = "LATTICE_OT_select_more";
- /* api callbacks */
- ot->exec = lattice_select_more_exec;
- ot->poll = ED_operator_editlattice;
+ /* api callbacks */
+ ot->exec = lattice_select_more_exec;
+ ot->poll = ED_operator_editlattice;
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
void LATTICE_OT_select_less(wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Select Less";
- ot->description = "Deselect vertices at the boundary of each selection region";
- ot->idname = "LATTICE_OT_select_less";
+ /* identifiers */
+ ot->name = "Select Less";
+ ot->description = "Deselect vertices at the boundary of each selection region";
+ ot->idname = "LATTICE_OT_select_less";
- /* api callbacks */
- ot->exec = lattice_select_less_exec;
- ot->poll = ED_operator_editlattice;
+ /* api callbacks */
+ ot->exec = lattice_select_less_exec;
+ ot->poll = ED_operator_editlattice;
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/** \} */
@@ -381,111 +380,112 @@ void LATTICE_OT_select_less(wmOperatorType *ot)
bool ED_lattice_flags_set(Object *obedit, int flag)
{
- Lattice *lt = obedit->data;
- BPoint *bp;
- int a;
- bool changed = false;
-
- bp = lt->editlatt->latt->def;
-
- a = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw;
-
- if (lt->editlatt->latt->actbp != LT_ACTBP_NONE) {
- lt->editlatt->latt->actbp = LT_ACTBP_NONE;
- changed = true;
- }
-
- while (a--) {
- if (bp->hide == 0) {
- if (bp->f1 != flag) {
- bp->f1 = flag;
- changed = true;
- }
- }
- bp++;
- }
- return changed;
+ Lattice *lt = obedit->data;
+ BPoint *bp;
+ int a;
+ bool changed = false;
+
+ bp = lt->editlatt->latt->def;
+
+ a = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw;
+
+ if (lt->editlatt->latt->actbp != LT_ACTBP_NONE) {
+ lt->editlatt->latt->actbp = LT_ACTBP_NONE;
+ changed = true;
+ }
+
+ while (a--) {
+ if (bp->hide == 0) {
+ if (bp->f1 != flag) {
+ bp->f1 = flag;
+ changed = true;
+ }
+ }
+ bp++;
+ }
+ return changed;
}
static int lattice_select_all_exec(bContext *C, wmOperator *op)
{
- ViewLayer *view_layer = CTX_data_view_layer(C);
- int action = RNA_enum_get(op->ptr, "action");
-
- uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
-
- if (action == SEL_TOGGLE) {
- action = SEL_SELECT;
- for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
- Object *obedit = objects[ob_index];
- Lattice *lt = obedit->data;
- if (BKE_lattice_is_any_selected(lt->editlatt->latt)) {
- action = SEL_DESELECT;
- break;
- }
- }
- }
-
- bool changed_multi = false;
- for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
- Object *obedit = objects[ob_index];
- Lattice *lt;
- BPoint *bp;
- int a;
- bool changed = false;
-
- switch (action) {
- case SEL_SELECT:
- changed = ED_lattice_flags_set(obedit, 1);
- break;
- case SEL_DESELECT:
- changed = ED_lattice_flags_set(obedit, 0);
- break;
- case SEL_INVERT:
- lt = obedit->data;
- bp = lt->editlatt->latt->def;
- a = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw;
- lt->editlatt->latt->actbp = LT_ACTBP_NONE;
-
- while (a--) {
- if (bp->hide == 0) {
- bp->f1 ^= SELECT;
- changed = true;
- }
- bp++;
- }
- break;
- }
- if (changed) {
- changed_multi = true;
- DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
- }
- }
- MEM_freeN(objects);
-
- if (changed_multi) {
- return OPERATOR_FINISHED;
- }
- return OPERATOR_CANCELLED;
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ int action = RNA_enum_get(op->ptr, "action");
+
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(
+ view_layer, CTX_wm_view3d(C), &objects_len);
+
+ if (action == SEL_TOGGLE) {
+ action = SEL_SELECT;
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ Lattice *lt = obedit->data;
+ if (BKE_lattice_is_any_selected(lt->editlatt->latt)) {
+ action = SEL_DESELECT;
+ break;
+ }
+ }
+ }
+
+ bool changed_multi = false;
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ Lattice *lt;
+ BPoint *bp;
+ int a;
+ bool changed = false;
+
+ switch (action) {
+ case SEL_SELECT:
+ changed = ED_lattice_flags_set(obedit, 1);
+ break;
+ case SEL_DESELECT:
+ changed = ED_lattice_flags_set(obedit, 0);
+ break;
+ case SEL_INVERT:
+ lt = obedit->data;
+ bp = lt->editlatt->latt->def;
+ a = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw;
+ lt->editlatt->latt->actbp = LT_ACTBP_NONE;
+
+ while (a--) {
+ if (bp->hide == 0) {
+ bp->f1 ^= SELECT;
+ changed = true;
+ }
+ bp++;
+ }
+ break;
+ }
+ if (changed) {
+ changed_multi = true;
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
+ }
+ }
+ MEM_freeN(objects);
+
+ if (changed_multi) {
+ return OPERATOR_FINISHED;
+ }
+ return OPERATOR_CANCELLED;
}
void LATTICE_OT_select_all(wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "(De)select All";
- ot->description = "Change selection of all UVW control points";
- ot->idname = "LATTICE_OT_select_all";
+ /* identifiers */
+ ot->name = "(De)select All";
+ ot->description = "Change selection of all UVW control points";
+ ot->idname = "LATTICE_OT_select_all";
- /* api callbacks */
- ot->exec = lattice_select_all_exec;
- ot->poll = ED_operator_editlattice;
+ /* api callbacks */
+ ot->exec = lattice_select_all_exec;
+ ot->poll = ED_operator_editlattice;
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- WM_operator_properties_select_all(ot);
+ WM_operator_properties_select_all(ot);
}
/** \} */
@@ -496,74 +496,74 @@ void LATTICE_OT_select_all(wmOperatorType *ot)
static int lattice_select_ungrouped_exec(bContext *C, wmOperator *op)
{
- ViewLayer *view_layer = CTX_data_view_layer(C);
- uint objects_len;
- const bool is_extend = RNA_boolean_get(op->ptr, "extend");
- bool changed = false;
-
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
- for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
- Object *obedit = objects[ob_index];
- Lattice *lt = ((Lattice *)obedit->data)->editlatt->latt;
- MDeformVert *dv;
- BPoint *bp;
- int a, tot;
-
- if (BLI_listbase_is_empty(&obedit->defbase) || lt->dvert == NULL) {
- continue;
- }
-
- if (!is_extend) {
- ED_lattice_flags_set(obedit, 0);
- }
-
- dv = lt->dvert;
- tot = lt->pntsu * lt->pntsv * lt->pntsw;
-
- for (a = 0, bp = lt->def; a < tot; a++, bp++, dv++) {
- if (bp->hide == 0) {
- if (dv->dw == NULL) {
- bp->f1 |= SELECT;
- }
- }
- }
-
- changed = true;
- DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
- }
- MEM_freeN(objects);
-
- if (!changed) {
- BKE_report(op->reports,
- RPT_ERROR,
- objects_len > 1 ? "No weights/vertex groups on objects" :
- "No weights/vertex groups on object");
- return OPERATOR_CANCELLED;
- }
- return OPERATOR_FINISHED;
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ uint objects_len;
+ const bool is_extend = RNA_boolean_get(op->ptr, "extend");
+ bool changed = false;
+
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(
+ view_layer, CTX_wm_view3d(C), &objects_len);
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ Lattice *lt = ((Lattice *)obedit->data)->editlatt->latt;
+ MDeformVert *dv;
+ BPoint *bp;
+ int a, tot;
+
+ if (BLI_listbase_is_empty(&obedit->defbase) || lt->dvert == NULL) {
+ continue;
+ }
+
+ if (!is_extend) {
+ ED_lattice_flags_set(obedit, 0);
+ }
+
+ dv = lt->dvert;
+ tot = lt->pntsu * lt->pntsv * lt->pntsw;
+
+ for (a = 0, bp = lt->def; a < tot; a++, bp++, dv++) {
+ if (bp->hide == 0) {
+ if (dv->dw == NULL) {
+ bp->f1 |= SELECT;
+ }
+ }
+ }
+
+ changed = true;
+ DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
+ }
+ MEM_freeN(objects);
+
+ if (!changed) {
+ BKE_report(op->reports,
+ RPT_ERROR,
+ objects_len > 1 ? "No weights/vertex groups on objects" :
+ "No weights/vertex groups on object");
+ return OPERATOR_CANCELLED;
+ }
+ return OPERATOR_FINISHED;
}
void LATTICE_OT_select_ungrouped(wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Select Ungrouped";
- ot->idname = "LATTICE_OT_select_ungrouped";
- ot->description = "Select vertices without a group";
+ /* identifiers */
+ ot->name = "Select Ungrouped";
+ ot->idname = "LATTICE_OT_select_ungrouped";
+ ot->description = "Select vertices without a group";
- /* api callbacks */
- ot->exec = lattice_select_ungrouped_exec;
- ot->poll = ED_operator_editlattice;
+ /* api callbacks */
+ ot->exec = lattice_select_ungrouped_exec;
+ ot->poll = ED_operator_editlattice;
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection");
+ RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection");
}
/** \} */
-
/* -------------------------------------------------------------------- */
/** \name Select Picking API
*
@@ -571,112 +571,127 @@ void LATTICE_OT_select_ungrouped(wmOperatorType *ot)
* Gets called via generic mouse select operator.
* \{ */
-
static void findnearestLattvert__doClosest(void *userData, BPoint *bp, const float screen_co[2])
{
- struct { BPoint *bp; float dist; int select; float mval_fl[2]; bool is_changed; } *data = userData;
- float dist_test = len_manhattan_v2v2(data->mval_fl, screen_co);
-
- if ((bp->f1 & SELECT) && data->select)
- dist_test += 5.0f;
-
- if (dist_test < data->dist) {
- data->dist = dist_test;
- data->bp = bp;
- data->is_changed = true;
- }
+ struct {
+ BPoint *bp;
+ float dist;
+ int select;
+ float mval_fl[2];
+ bool is_changed;
+ } *data = userData;
+ float dist_test = len_manhattan_v2v2(data->mval_fl, screen_co);
+
+ if ((bp->f1 & SELECT) && data->select)
+ dist_test += 5.0f;
+
+ if (dist_test < data->dist) {
+ data->dist = dist_test;
+ data->bp = bp;
+ data->is_changed = true;
+ }
}
static BPoint *findnearestLattvert(ViewContext *vc, int sel, Base **r_base)
{
- /* (sel == 1): selected gets a disadvantage */
- /* in nurb and bezt or bp the nearest is written */
- /* return 0 1 2: handlepunt */
- struct { BPoint *bp; float dist; int select; float mval_fl[2]; bool is_changed; } data = {NULL};
-
- data.dist = ED_view3d_select_dist_px();
- data.select = sel;
- data.mval_fl[0] = vc->mval[0];
- data.mval_fl[1] = vc->mval[1];
-
- uint bases_len;
- Base **bases = BKE_view_layer_array_from_bases_in_edit_mode_unique_data(vc->view_layer, vc->v3d, &bases_len);
- for (uint base_index = 0; base_index < bases_len; base_index++) {
- Base *base = bases[base_index];
- data.is_changed = false;
-
- ED_view3d_viewcontext_init_object(vc, base->object);
- ED_view3d_init_mats_rv3d(base->object, vc->rv3d);
- lattice_foreachScreenVert(vc, findnearestLattvert__doClosest, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
-
- if (data.is_changed) {
- *r_base = base;
- }
- }
- MEM_freeN(bases);
- return data.bp;
+ /* (sel == 1): selected gets a disadvantage */
+ /* in nurb and bezt or bp the nearest is written */
+ /* return 0 1 2: handlepunt */
+ struct {
+ BPoint *bp;
+ float dist;
+ int select;
+ float mval_fl[2];
+ bool is_changed;
+ } data = {NULL};
+
+ data.dist = ED_view3d_select_dist_px();
+ data.select = sel;
+ data.mval_fl[0] = vc->mval[0];
+ data.mval_fl[1] = vc->mval[1];
+
+ uint bases_len;
+ Base **bases = BKE_view_layer_array_from_bases_in_edit_mode_unique_data(
+ vc->view_layer, vc->v3d, &bases_len);
+ for (uint base_index = 0; base_index < bases_len; base_index++) {
+ Base *base = bases[base_index];
+ data.is_changed = false;
+
+ ED_view3d_viewcontext_init_object(vc, base->object);
+ ED_view3d_init_mats_rv3d(base->object, vc->rv3d);
+ lattice_foreachScreenVert(
+ vc, findnearestLattvert__doClosest, &data, V3D_PROJ_TEST_CLIP_DEFAULT);
+
+ if (data.is_changed) {
+ *r_base = base;
+ }
+ }
+ MEM_freeN(bases);
+ return data.bp;
}
-bool ED_lattice_select_pick(bContext *C, const int mval[2], bool extend, bool deselect, bool toggle)
+bool ED_lattice_select_pick(
+ bContext *C, const int mval[2], bool extend, bool deselect, bool toggle)
{
- ViewContext vc;
- BPoint *bp = NULL;
- Base *basact = NULL;
-
- ED_view3d_viewcontext_init(C, &vc);
- vc.mval[0] = mval[0];
- vc.mval[1] = mval[1];
-
- bp = findnearestLattvert(&vc, true, &basact);
- if (bp) {
- ED_view3d_viewcontext_init_object(&vc, basact->object);
- Lattice *lt = ((Lattice *)vc.obedit->data)->editlatt->latt;
-
- if (!extend && !deselect && !toggle) {
- uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(vc.view_layer, vc.v3d, &objects_len);
- for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
- Object *ob = objects[ob_index];
- if (ED_lattice_flags_set(ob, 0)) {
- DEG_id_tag_update(ob->data, ID_RECALC_SELECT);
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data);
- }
- }
- MEM_freeN(objects);
- }
-
- if (extend) {
- bp->f1 |= SELECT;
- }
- else if (deselect) {
- bp->f1 &= ~SELECT;
- }
- else if (toggle) {
- bp->f1 ^= SELECT; /* swap */
- }
- else {
- ED_lattice_flags_set(vc.obedit, 0);
- bp->f1 |= SELECT;
- }
-
- if (bp->f1 & SELECT) {
- lt->actbp = bp - lt->def;
- }
- else {
- lt->actbp = LT_ACTBP_NONE;
- }
-
- if (vc.view_layer->basact != basact) {
- ED_object_base_activate(C, basact);
- }
-
- DEG_id_tag_update(vc.obedit->data, ID_RECALC_SELECT);
- WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit->data);
-
- return true;
- }
-
- return false;
+ ViewContext vc;
+ BPoint *bp = NULL;
+ Base *basact = NULL;
+
+ ED_view3d_viewcontext_init(C, &vc);
+ vc.mval[0] = mval[0];
+ vc.mval[1] = mval[1];
+
+ bp = findnearestLattvert(&vc, true, &basact);
+ if (bp) {
+ ED_view3d_viewcontext_init_object(&vc, basact->object);
+ Lattice *lt = ((Lattice *)vc.obedit->data)->editlatt->latt;
+
+ if (!extend && !deselect && !toggle) {
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(
+ vc.view_layer, vc.v3d, &objects_len);
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *ob = objects[ob_index];
+ if (ED_lattice_flags_set(ob, 0)) {
+ DEG_id_tag_update(ob->data, ID_RECALC_SELECT);
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data);
+ }
+ }
+ MEM_freeN(objects);
+ }
+
+ if (extend) {
+ bp->f1 |= SELECT;
+ }
+ else if (deselect) {
+ bp->f1 &= ~SELECT;
+ }
+ else if (toggle) {
+ bp->f1 ^= SELECT; /* swap */
+ }
+ else {
+ ED_lattice_flags_set(vc.obedit, 0);
+ bp->f1 |= SELECT;
+ }
+
+ if (bp->f1 & SELECT) {
+ lt->actbp = bp - lt->def;
+ }
+ else {
+ lt->actbp = LT_ACTBP_NONE;
+ }
+
+ if (vc.view_layer->basact != basact) {
+ ED_object_base_activate(C, basact);
+ }
+
+ DEG_id_tag_update(vc.obedit->data, ID_RECALC_SELECT);
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit->data);
+
+ return true;
+ }
+
+ return false;
}
/** \} */
diff --git a/source/blender/editors/lattice/editlattice_tools.c b/source/blender/editors/lattice/editlattice_tools.c
index edb79797c2a..8ef383de552 100644
--- a/source/blender/editors/lattice/editlattice_tools.c
+++ b/source/blender/editors/lattice/editlattice_tools.c
@@ -21,7 +21,6 @@
* \ingroup edlattice
*/
-
#include "MEM_guardedalloc.h"
#include "BLI_math.h"
@@ -56,67 +55,70 @@
static bool make_regular_poll(bContext *C)
{
- Object *ob;
+ Object *ob;
- if (ED_operator_editlattice(C)) return 1;
+ if (ED_operator_editlattice(C))
+ return 1;
- ob = CTX_data_active_object(C);
- return (ob && ob->type == OB_LATTICE);
+ ob = CTX_data_active_object(C);
+ return (ob && ob->type == OB_LATTICE);
}
static int make_regular_exec(bContext *C, wmOperator *UNUSED(op))
{
- ViewLayer *view_layer = CTX_data_view_layer(C);
- View3D *v3d = CTX_wm_view3d(C);
- const bool is_editmode = CTX_data_edit_object(C) != NULL;
-
- if (is_editmode) {
- uint objects_len;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
- for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
- Object *ob = objects[ob_index];
- Lattice *lt = ob->data;
-
- if (lt->editlatt->latt == NULL) {
- continue;
- }
-
- BKE_lattice_resize(lt->editlatt->latt, lt->pntsu, lt->pntsv, lt->pntsw, NULL);
-
- DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
- WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
- }
- MEM_freeN(objects);
- }
- else {
- FOREACH_SELECTED_OBJECT_BEGIN(view_layer, v3d, ob) {
- if (ob->type != OB_LATTICE) {
- continue;
- }
-
- Lattice *lt = ob->data;
- BKE_lattice_resize(lt, lt->pntsu, lt->pntsv, lt->pntsw, NULL);
-
- DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
- WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
- } FOREACH_SELECTED_OBJECT_END;
- }
- return OPERATOR_FINISHED;
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ View3D *v3d = CTX_wm_view3d(C);
+ const bool is_editmode = CTX_data_edit_object(C) != NULL;
+
+ if (is_editmode) {
+ uint objects_len;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(
+ view_layer, CTX_wm_view3d(C), &objects_len);
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *ob = objects[ob_index];
+ Lattice *lt = ob->data;
+
+ if (lt->editlatt->latt == NULL) {
+ continue;
+ }
+
+ BKE_lattice_resize(lt->editlatt->latt, lt->pntsu, lt->pntsv, lt->pntsw, NULL);
+
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
+ WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
+ }
+ MEM_freeN(objects);
+ }
+ else {
+ FOREACH_SELECTED_OBJECT_BEGIN (view_layer, v3d, ob) {
+ if (ob->type != OB_LATTICE) {
+ continue;
+ }
+
+ Lattice *lt = ob->data;
+ BKE_lattice_resize(lt, lt->pntsu, lt->pntsv, lt->pntsw, NULL);
+
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
+ WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
+ }
+ FOREACH_SELECTED_OBJECT_END;
+ }
+ return OPERATOR_FINISHED;
}
void LATTICE_OT_make_regular(wmOperatorType *ot)
{
- /* identifiers */
- ot->name = "Make Regular";
- ot->description = "Set UVW control points a uniform distance apart";
- ot->idname = "LATTICE_OT_make_regular";
+ /* identifiers */
+ ot->name = "Make Regular";
+ ot->description = "Set UVW control points a uniform distance apart";
+ ot->idname = "LATTICE_OT_make_regular";
- /* api callbacks */
- ot->exec = make_regular_exec;
- ot->poll = make_regular_poll;
+ /* api callbacks */
+ ot->exec = make_regular_exec;
+ ot->poll = make_regular_poll;
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/** \} */
@@ -127,9 +129,9 @@ void LATTICE_OT_make_regular(wmOperatorType *ot)
/* flipping options */
typedef enum eLattice_FlipAxes {
- LATTICE_FLIP_U = 0,
- LATTICE_FLIP_V = 1,
- LATTICE_FLIP_W = 2,
+ LATTICE_FLIP_U = 0,
+ LATTICE_FLIP_V = 1,
+ LATTICE_FLIP_W = 2,
} eLattice_FlipAxes;
/**
@@ -137,233 +139,238 @@ typedef enum eLattice_FlipAxes {
* Assumes that uvw <=> xyz (i.e. axis-aligned index-axes with coordinate-axes).
* - Helper for #lattice_flip_exec()
*/
-static void lattice_flip_point_value(Lattice *lt, int u, int v, int w, float mid, eLattice_FlipAxes axis)
+static void lattice_flip_point_value(
+ Lattice *lt, int u, int v, int w, float mid, eLattice_FlipAxes axis)
{
- BPoint *bp;
- float diff;
+ BPoint *bp;
+ float diff;
- /* just the point in the middle (unpaired) */
- bp = &lt->def[BKE_lattice_index_from_uvw(lt, u, v, w)];
+ /* just the point in the middle (unpaired) */
+ bp = &lt->def[BKE_lattice_index_from_uvw(lt, u, v, w)];
- /* flip over axis */
- diff = mid - bp->vec[axis];
- bp->vec[axis] = mid + diff;
+ /* flip over axis */
+ diff = mid - bp->vec[axis];
+ bp->vec[axis] = mid + diff;
}
/**
* Swap pairs of lattice points along a specified axis.
* - Helper for #lattice_flip_exec()
*/
-static void lattice_swap_point_pairs(Lattice *lt, int u, int v, int w, float mid, eLattice_FlipAxes axis)
+static void lattice_swap_point_pairs(
+ Lattice *lt, int u, int v, int w, float mid, eLattice_FlipAxes axis)
{
- BPoint *bpA, *bpB;
-
- int numU = lt->pntsu;
- int numV = lt->pntsv;
- int numW = lt->pntsw;
-
- int u0 = u, u1 = u;
- int v0 = v, v1 = v;
- int w0 = w, w1 = w;
-
- /* get pair index by just overriding the relevant pair-value
- * - "-1" else buffer overflow
- */
- switch (axis) {
- case LATTICE_FLIP_U:
- u1 = numU - u - 1;
- break;
- case LATTICE_FLIP_V:
- v1 = numV - v - 1;
- break;
- case LATTICE_FLIP_W:
- w1 = numW - w - 1;
- break;
- }
-
- /* get points to operate on */
- bpA = &lt->def[BKE_lattice_index_from_uvw(lt, u0, v0, w0)];
- bpB = &lt->def[BKE_lattice_index_from_uvw(lt, u1, v1, w1)];
-
- /* Swap all coordinates, so that flipped coordinates belong to
- * the indices on the correct side of the lattice.
- *
- * Coords: (-2 4) |0| (3 4) --> (3 4) |0| (-2 4)
- * Indices: (0,L) (1,R) --> (0,L) (1,R)
- */
- swap_v3_v3(bpA->vec, bpB->vec);
-
- /* However, we need to mirror the coordinate values on the axis we're dealing with,
- * otherwise we'd have effectively only rotated the points around. If we don't do this,
- * we'd just be reimplementing the naive mirroring algorithm, which causes unwanted deforms
- * such as flipped normals, etc.
- *
- * Coords: (3 4) |0| (-2 4) --\
- * \-> (-3 4) |0| (2 4)
- * Indices: (0,L) (1,R) --> (0,L) (1,R)
- */
- lattice_flip_point_value(lt, u0, v0, w0, mid, axis);
- lattice_flip_point_value(lt, u1, v1, w1, mid, axis);
+ BPoint *bpA, *bpB;
+
+ int numU = lt->pntsu;
+ int numV = lt->pntsv;
+ int numW = lt->pntsw;
+
+ int u0 = u, u1 = u;
+ int v0 = v, v1 = v;
+ int w0 = w, w1 = w;
+
+ /* get pair index by just overriding the relevant pair-value
+ * - "-1" else buffer overflow
+ */
+ switch (axis) {
+ case LATTICE_FLIP_U:
+ u1 = numU - u - 1;
+ break;
+ case LATTICE_FLIP_V:
+ v1 = numV - v - 1;
+ break;
+ case LATTICE_FLIP_W:
+ w1 = numW - w - 1;
+ break;
+ }
+
+ /* get points to operate on */
+ bpA = &lt->def[BKE_lattice_index_from_uvw(lt, u0, v0, w0)];
+ bpB = &lt->def[BKE_lattice_index_from_uvw(lt, u1, v1, w1)];
+
+ /* Swap all coordinates, so that flipped coordinates belong to
+ * the indices on the correct side of the lattice.
+ *
+ * Coords: (-2 4) |0| (3 4) --> (3 4) |0| (-2 4)
+ * Indices: (0,L) (1,R) --> (0,L) (1,R)
+ */
+ swap_v3_v3(bpA->vec, bpB->vec);
+
+ /* However, we need to mirror the coordinate values on the axis we're dealing with,
+ * otherwise we'd have effectively only rotated the points around. If we don't do this,
+ * we'd just be reimplementing the naive mirroring algorithm, which causes unwanted deforms
+ * such as flipped normals, etc.
+ *
+ * Coords: (3 4) |0| (-2 4) --\
+ * \-> (-3 4) |0| (2 4)
+ * Indices: (0,L) (1,R) --> (0,L) (1,R)
+ */
+ lattice_flip_point_value(lt, u0, v0, w0, mid, axis);
+ lattice_flip_point_value(lt, u1, v1, w1, mid, axis);
}
static int lattice_flip_exec(bContext *C, wmOperator *op)
{
- ViewLayer *view_layer = CTX_data_view_layer(C);
- uint objects_len;
- bool changed = false;
- const eLattice_FlipAxes axis = RNA_enum_get(op->ptr, "axis");
-
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
- for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
- Object *obedit = objects[ob_index];
- Lattice *lt;
-
- int numU, numV, numW;
- int totP;
-
- float mid = 0.0f;
- short isOdd = 0;
-
- /* get lattice - we need the "edit lattice" from the lattice... confusing... */
- lt = (Lattice *)obedit->data;
- lt = lt->editlatt->latt;
-
- numU = lt->pntsu;
- numV = lt->pntsv;
- numW = lt->pntsw;
- totP = numU * numV * numW;
-
- /* First Pass: determine midpoint - used for flipping center verts if there
- * are odd number of points on axis */
- switch (axis) {
- case LATTICE_FLIP_U:
- isOdd = numU & 1;
- break;
- case LATTICE_FLIP_V:
- isOdd = numV & 1;
- break;
- case LATTICE_FLIP_W:
- isOdd = numW & 1;
- break;
-
- default:
- printf("lattice_flip(): Unknown flipping axis (%u)\n", axis);
- return OPERATOR_CANCELLED;
- }
-
- if (isOdd) {
- BPoint *bp;
- float avgInv = 1.0f / (float)totP;
- int i;
-
- /* midpoint calculation - assuming that u/v/w are axis-aligned */
- for (i = 0, bp = lt->def; i < totP; i++, bp++) {
- mid += bp->vec[axis] * avgInv;
- }
- }
-
- /* Second Pass: swap pairs of vertices per axis, assuming they are all sorted */
- switch (axis) {
- case LATTICE_FLIP_U:
- {
- int u, v, w;
-
- /* v/w strips - front to back, top to bottom */
- for (w = 0; w < numW; w++) {
- for (v = 0; v < numV; v++) {
- /* swap coordinates of pairs of vertices on u */
- for (u = 0; u < (numU / 2); u++) {
- lattice_swap_point_pairs(lt, u, v, w, mid, axis);
- }
-
- /* flip u-coordinate of midpoint (i.e. unpaired point on u) */
- if (isOdd) {
- u = (numU / 2);
- lattice_flip_point_value(lt, u, v, w, mid, axis);
- }
- }
- }
- break;
- }
- case LATTICE_FLIP_V:
- {
- int u, v, w;
-
- /* u/w strips - front to back, left to right */
- for (w = 0; w < numW; w++) {
- for (u = 0; u < numU; u++) {
- /* swap coordinates of pairs of vertices on v */
- for (v = 0; v < (numV / 2); v++) {
- lattice_swap_point_pairs(lt, u, v, w, mid, axis);
- }
-
- /* flip v-coordinate of midpoint (i.e. unpaired point on v) */
- if (isOdd) {
- v = (numV / 2);
- lattice_flip_point_value(lt, u, v, w, mid, axis);
- }
- }
- }
- break;
- }
- case LATTICE_FLIP_W:
- {
- int u, v, w;
-
- for (v = 0; v < numV; v++) {
- for (u = 0; u < numU; u++) {
- /* swap coordinates of pairs of vertices on w */
- for (w = 0; w < (numW / 2); w++) {
- lattice_swap_point_pairs(lt, u, v, w, mid, axis);
- }
-
- /* flip w-coordinate of midpoint (i.e. unpaired point on w) */
- if (isOdd) {
- w = (numW / 2);
- lattice_flip_point_value(lt, u, v, w, mid, axis);
- }
- }
- }
- break;
- }
- default: /* shouldn't happen, but just in case */
- break;
- }
-
- /* updates */
- DEG_id_tag_update(&obedit->id, ID_RECALC_GEOMETRY);
- WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
- changed = true;
- }
- MEM_freeN(objects);
-
- return changed ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ uint objects_len;
+ bool changed = false;
+ const eLattice_FlipAxes axis = RNA_enum_get(op->ptr, "axis");
+
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(
+ view_layer, CTX_wm_view3d(C), &objects_len);
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ Lattice *lt;
+
+ int numU, numV, numW;
+ int totP;
+
+ float mid = 0.0f;
+ short isOdd = 0;
+
+ /* get lattice - we need the "edit lattice" from the lattice... confusing... */
+ lt = (Lattice *)obedit->data;
+ lt = lt->editlatt->latt;
+
+ numU = lt->pntsu;
+ numV = lt->pntsv;
+ numW = lt->pntsw;
+ totP = numU * numV * numW;
+
+ /* First Pass: determine midpoint - used for flipping center verts if there
+ * are odd number of points on axis */
+ switch (axis) {
+ case LATTICE_FLIP_U:
+ isOdd = numU & 1;
+ break;
+ case LATTICE_FLIP_V:
+ isOdd = numV & 1;
+ break;
+ case LATTICE_FLIP_W:
+ isOdd = numW & 1;
+ break;
+
+ default:
+ printf("lattice_flip(): Unknown flipping axis (%u)\n", axis);
+ return OPERATOR_CANCELLED;
+ }
+
+ if (isOdd) {
+ BPoint *bp;
+ float avgInv = 1.0f / (float)totP;
+ int i;
+
+ /* midpoint calculation - assuming that u/v/w are axis-aligned */
+ for (i = 0, bp = lt->def; i < totP; i++, bp++) {
+ mid += bp->vec[axis] * avgInv;
+ }
+ }
+
+ /* Second Pass: swap pairs of vertices per axis, assuming they are all sorted */
+ switch (axis) {
+ case LATTICE_FLIP_U: {
+ int u, v, w;
+
+ /* v/w strips - front to back, top to bottom */
+ for (w = 0; w < numW; w++) {
+ for (v = 0; v < numV; v++) {
+ /* swap coordinates of pairs of vertices on u */
+ for (u = 0; u < (numU / 2); u++) {
+ lattice_swap_point_pairs(lt, u, v, w, mid, axis);
+ }
+
+ /* flip u-coordinate of midpoint (i.e. unpaired point on u) */
+ if (isOdd) {
+ u = (numU / 2);
+ lattice_flip_point_value(lt, u, v, w, mid, axis);
+ }
+ }
+ }
+ break;
+ }
+ case LATTICE_FLIP_V: {
+ int u, v, w;
+
+ /* u/w strips - front to back, left to right */
+ for (w = 0; w < numW; w++) {
+ for (u = 0; u < numU; u++) {
+ /* swap coordinates of pairs of vertices on v */
+ for (v = 0; v < (numV / 2); v++) {
+ lattice_swap_point_pairs(lt, u, v, w, mid, axis);
+ }
+
+ /* flip v-coordinate of midpoint (i.e. unpaired point on v) */
+ if (isOdd) {
+ v = (numV / 2);
+ lattice_flip_point_value(lt, u, v, w, mid, axis);
+ }
+ }
+ }
+ break;
+ }
+ case LATTICE_FLIP_W: {
+ int u, v, w;
+
+ for (v = 0; v < numV; v++) {
+ for (u = 0; u < numU; u++) {
+ /* swap coordinates of pairs of vertices on w */
+ for (w = 0; w < (numW / 2); w++) {
+ lattice_swap_point_pairs(lt, u, v, w, mid, axis);
+ }
+
+ /* flip w-coordinate of midpoint (i.e. unpaired point on w) */
+ if (isOdd) {
+ w = (numW / 2);
+ lattice_flip_point_value(lt, u, v, w, mid, axis);
+ }
+ }
+ }
+ break;
+ }
+ default: /* shouldn't happen, but just in case */
+ break;
+ }
+
+ /* updates */
+ DEG_id_tag_update(&obedit->id, ID_RECALC_GEOMETRY);
+ WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
+ changed = true;
+ }
+ MEM_freeN(objects);
+
+ return changed ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
void LATTICE_OT_flip(wmOperatorType *ot)
{
- static const EnumPropertyItem flip_items[] = {
- {LATTICE_FLIP_U, "U", 0, "U (X) Axis", ""},
- {LATTICE_FLIP_V, "V", 0, "V (Y) Axis", ""},
- {LATTICE_FLIP_W, "W", 0, "W (Z) Axis", ""},
- {0, NULL, 0, NULL, NULL},
- };
-
- /* identifiers */
- ot->name = "Flip (Distortion Free)";
- ot->description = "Mirror all control points without inverting the lattice deform";
- ot->idname = "LATTICE_OT_flip";
-
- /* api callbacks */
- ot->poll = ED_operator_editlattice;
- ot->invoke = WM_menu_invoke;
- ot->exec = lattice_flip_exec;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
- /* properties */
- ot->prop = RNA_def_enum(ot->srna, "axis", flip_items, LATTICE_FLIP_U, "Flip Axis", "Coordinates along this axis get flipped");
+ static const EnumPropertyItem flip_items[] = {
+ {LATTICE_FLIP_U, "U", 0, "U (X) Axis", ""},
+ {LATTICE_FLIP_V, "V", 0, "V (Y) Axis", ""},
+ {LATTICE_FLIP_W, "W", 0, "W (Z) Axis", ""},
+ {0, NULL, 0, NULL, NULL},
+ };
+
+ /* identifiers */
+ ot->name = "Flip (Distortion Free)";
+ ot->description = "Mirror all control points without inverting the lattice deform";
+ ot->idname = "LATTICE_OT_flip";
+
+ /* api callbacks */
+ ot->poll = ED_operator_editlattice;
+ ot->invoke = WM_menu_invoke;
+ ot->exec = lattice_flip_exec;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* properties */
+ ot->prop = RNA_def_enum(ot->srna,
+ "axis",
+ flip_items,
+ LATTICE_FLIP_U,
+ "Flip Axis",
+ "Coordinates along this axis get flipped");
}
/** \} */
diff --git a/source/blender/editors/lattice/editlattice_undo.c b/source/blender/editors/lattice/editlattice_undo.c
index be8e0ae0633..9ee2e8b563b 100644
--- a/source/blender/editors/lattice/editlattice_undo.c
+++ b/source/blender/editors/lattice/editlattice_undo.c
@@ -61,64 +61,64 @@ static CLG_LogRef LOG = {"ed.undo.lattice"};
* \{ */
typedef struct UndoLattice {
- BPoint *def;
- int pntsu, pntsv, pntsw, actbp;
- size_t undo_size;
+ BPoint *def;
+ int pntsu, pntsv, pntsw, actbp;
+ size_t undo_size;
} UndoLattice;
static void undolatt_to_editlatt(UndoLattice *ult, EditLatt *editlatt)
{
- int len = editlatt->latt->pntsu * editlatt->latt->pntsv * editlatt->latt->pntsw;
+ int len = editlatt->latt->pntsu * editlatt->latt->pntsv * editlatt->latt->pntsw;
- memcpy(editlatt->latt->def, ult->def, sizeof(BPoint) * len);
- editlatt->latt->actbp = ult->actbp;
+ memcpy(editlatt->latt->def, ult->def, sizeof(BPoint) * len);
+ editlatt->latt->actbp = ult->actbp;
}
static void *undolatt_from_editlatt(UndoLattice *ult, EditLatt *editlatt)
{
- BLI_assert(BLI_array_is_zeroed(ult, 1));
+ BLI_assert(BLI_array_is_zeroed(ult, 1));
- ult->def = MEM_dupallocN(editlatt->latt->def);
- ult->pntsu = editlatt->latt->pntsu;
- ult->pntsv = editlatt->latt->pntsv;
- ult->pntsw = editlatt->latt->pntsw;
- ult->actbp = editlatt->latt->actbp;
+ ult->def = MEM_dupallocN(editlatt->latt->def);
+ ult->pntsu = editlatt->latt->pntsu;
+ ult->pntsv = editlatt->latt->pntsv;
+ ult->pntsw = editlatt->latt->pntsw;
+ ult->actbp = editlatt->latt->actbp;
- ult->undo_size += sizeof(*ult->def) * ult->pntsu * ult->pntsv * ult->pntsw;
+ ult->undo_size += sizeof(*ult->def) * ult->pntsu * ult->pntsv * ult->pntsw;
- return ult;
+ return ult;
}
static void undolatt_free_data(UndoLattice *ult)
{
- if (ult->def) {
- MEM_freeN(ult->def);
- }
+ if (ult->def) {
+ MEM_freeN(ult->def);
+ }
}
#if 0
static int validate_undoLatt(void *data, void *edata)
{
- UndoLattice *ult = (UndoLattice *)data;
- EditLatt *editlatt = (EditLatt *)edata;
+ UndoLattice *ult = (UndoLattice *)data;
+ EditLatt *editlatt = (EditLatt *)edata;
- return (ult->pntsu == editlatt->latt->pntsu &&
- ult->pntsv == editlatt->latt->pntsv &&
- ult->pntsw == editlatt->latt->pntsw);
+ return (ult->pntsu == editlatt->latt->pntsu &&
+ ult->pntsv == editlatt->latt->pntsv &&
+ ult->pntsw == editlatt->latt->pntsw);
}
#endif
static Object *editlatt_object_from_context(bContext *C)
{
- Object *obedit = CTX_data_edit_object(C);
- if (obedit && obedit->type == OB_LATTICE) {
- Lattice *lt = obedit->data;
- if (lt->editlatt != NULL) {
- return obedit;
- }
- }
-
- return NULL;
+ Object *obedit = CTX_data_edit_object(C);
+ if (obedit && obedit->type == OB_LATTICE) {
+ Lattice *lt = obedit->data;
+ if (lt->editlatt != NULL) {
+ return obedit;
+ }
+ }
+
+ return NULL;
}
/** \} */
@@ -130,112 +130,123 @@ static Object *editlatt_object_from_context(bContext *C)
* \{ */
typedef struct LatticeUndoStep_Elem {
- UndoRefID_Object obedit_ref;
- UndoLattice data;
+ UndoRefID_Object obedit_ref;
+ UndoLattice data;
} LatticeUndoStep_Elem;
typedef struct LatticeUndoStep {
- UndoStep step;
- LatticeUndoStep_Elem *elems;
- uint elems_len;
+ UndoStep step;
+ LatticeUndoStep_Elem *elems;
+ uint elems_len;
} LatticeUndoStep;
static bool lattice_undosys_poll(bContext *C)
{
- return editlatt_object_from_context(C) != NULL;
+ return editlatt_object_from_context(C) != NULL;
}
-static bool lattice_undosys_step_encode(struct bContext *C, struct Main *UNUSED(bmain), UndoStep *us_p)
+static bool lattice_undosys_step_encode(struct bContext *C,
+ struct Main *UNUSED(bmain),
+ UndoStep *us_p)
{
- LatticeUndoStep *us = (LatticeUndoStep *)us_p;
-
- /* Important not to use the 3D view when getting objects because all objects
- * outside of this list will be moved out of edit-mode when reading back undo steps. */
- ViewLayer *view_layer = CTX_data_view_layer(C);
- uint objects_len = 0;
- Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, NULL, &objects_len);
-
- us->elems = MEM_callocN(sizeof(*us->elems) * objects_len, __func__);
- us->elems_len = objects_len;
-
- for (uint i = 0; i < objects_len; i++) {
- Object *ob = objects[i];
- LatticeUndoStep_Elem *elem = &us->elems[i];
-
- elem->obedit_ref.ptr = ob;
- Lattice *lt = ob->data;
- undolatt_from_editlatt(&elem->data, lt->editlatt);
- us->step.data_size += elem->data.undo_size;
- }
- MEM_freeN(objects);
- return true;
+ LatticeUndoStep *us = (LatticeUndoStep *)us_p;
+
+ /* Important not to use the 3D view when getting objects because all objects
+ * outside of this list will be moved out of edit-mode when reading back undo steps. */
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(
+ view_layer, NULL, &objects_len);
+
+ us->elems = MEM_callocN(sizeof(*us->elems) * objects_len, __func__);
+ us->elems_len = objects_len;
+
+ for (uint i = 0; i < objects_len; i++) {
+ Object *ob = objects[i];
+ LatticeUndoStep_Elem *elem = &us->elems[i];
+
+ elem->obedit_ref.ptr = ob;
+ Lattice *lt = ob->data;
+ undolatt_from_editlatt(&elem->data, lt->editlatt);
+ us->step.data_size += elem->data.undo_size;
+ }
+ MEM_freeN(objects);
+ return true;
}
-static void lattice_undosys_step_decode(struct bContext *C, struct Main *UNUSED(bmain), UndoStep *us_p, int UNUSED(dir))
+static void lattice_undosys_step_decode(struct bContext *C,
+ struct Main *UNUSED(bmain),
+ UndoStep *us_p,
+ int UNUSED(dir))
{
- LatticeUndoStep *us = (LatticeUndoStep *)us_p;
-
- /* Load all our objects into edit-mode, clear everything else. */
- ED_undo_object_editmode_restore_helper(C, &us->elems[0].obedit_ref.ptr, us->elems_len, sizeof(*us->elems));
-
- BLI_assert(lattice_undosys_poll(C));
-
- for (uint i = 0; i < us->elems_len; i++) {
- LatticeUndoStep_Elem *elem = &us->elems[i];
- Object *obedit = elem->obedit_ref.ptr;
- Lattice *lt = obedit->data;
- if (lt->editlatt == NULL) {
- /* Should never fail, may not crash but can give odd behavior. */
- CLOG_ERROR(&LOG, "name='%s', failed to enter edit-mode for object '%s', undo state invalid",
- us_p->name, obedit->id.name);
- continue;
- }
- undolatt_to_editlatt(&elem->data, lt->editlatt);
- DEG_id_tag_update(&obedit->id, ID_RECALC_GEOMETRY);
- }
-
- /* The first element is always active */
- ED_undo_object_set_active_or_warn(CTX_data_view_layer(C), us->elems[0].obedit_ref.ptr, us_p->name, &LOG);
-
- WM_event_add_notifier(C, NC_GEOM | ND_DATA, NULL);
+ LatticeUndoStep *us = (LatticeUndoStep *)us_p;
+
+ /* Load all our objects into edit-mode, clear everything else. */
+ ED_undo_object_editmode_restore_helper(
+ C, &us->elems[0].obedit_ref.ptr, us->elems_len, sizeof(*us->elems));
+
+ BLI_assert(lattice_undosys_poll(C));
+
+ for (uint i = 0; i < us->elems_len; i++) {
+ LatticeUndoStep_Elem *elem = &us->elems[i];
+ Object *obedit = elem->obedit_ref.ptr;
+ Lattice *lt = obedit->data;
+ if (lt->editlatt == NULL) {
+ /* Should never fail, may not crash but can give odd behavior. */
+ CLOG_ERROR(&LOG,
+ "name='%s', failed to enter edit-mode for object '%s', undo state invalid",
+ us_p->name,
+ obedit->id.name);
+ continue;
+ }
+ undolatt_to_editlatt(&elem->data, lt->editlatt);
+ DEG_id_tag_update(&obedit->id, ID_RECALC_GEOMETRY);
+ }
+
+ /* The first element is always active */
+ ED_undo_object_set_active_or_warn(
+ CTX_data_view_layer(C), us->elems[0].obedit_ref.ptr, us_p->name, &LOG);
+
+ WM_event_add_notifier(C, NC_GEOM | ND_DATA, NULL);
}
static void lattice_undosys_step_free(UndoStep *us_p)
{
- LatticeUndoStep *us = (LatticeUndoStep *)us_p;
+ LatticeUndoStep *us = (LatticeUndoStep *)us_p;
- for (uint i = 0; i < us->elems_len; i++) {
- LatticeUndoStep_Elem *elem = &us->elems[i];
- undolatt_free_data(&elem->data);
- }
- MEM_freeN(us->elems);
+ for (uint i = 0; i < us->elems_len; i++) {
+ LatticeUndoStep_Elem *elem = &us->elems[i];
+ undolatt_free_data(&elem->data);
+ }
+ MEM_freeN(us->elems);
}
-static void lattice_undosys_foreach_ID_ref(
- UndoStep *us_p, UndoTypeForEachIDRefFn foreach_ID_ref_fn, void *user_data)
+static void lattice_undosys_foreach_ID_ref(UndoStep *us_p,
+ UndoTypeForEachIDRefFn foreach_ID_ref_fn,
+ void *user_data)
{
- LatticeUndoStep *us = (LatticeUndoStep *)us_p;
+ LatticeUndoStep *us = (LatticeUndoStep *)us_p;
- for (uint i = 0; i < us->elems_len; i++) {
- LatticeUndoStep_Elem *elem = &us->elems[i];
- foreach_ID_ref_fn(user_data, ((UndoRefID *)&elem->obedit_ref));
- }
+ for (uint i = 0; i < us->elems_len; i++) {
+ LatticeUndoStep_Elem *elem = &us->elems[i];
+ foreach_ID_ref_fn(user_data, ((UndoRefID *)&elem->obedit_ref));
+ }
}
/* Export for ED_undo_sys. */
void ED_lattice_undosys_type(UndoType *ut)
{
- ut->name = "Edit Lattice";
- ut->poll = lattice_undosys_poll;
- ut->step_encode = lattice_undosys_step_encode;
- ut->step_decode = lattice_undosys_step_decode;
- ut->step_free = lattice_undosys_step_free;
+ ut->name = "Edit Lattice";
+ ut->poll = lattice_undosys_poll;
+ ut->step_encode = lattice_undosys_step_encode;
+ ut->step_decode = lattice_undosys_step_decode;
+ ut->step_free = lattice_undosys_step_free;
- ut->step_foreach_ID_ref = lattice_undosys_foreach_ID_ref;
+ ut->step_foreach_ID_ref = lattice_undosys_foreach_ID_ref;
- ut->use_context = true;
+ ut->use_context = true;
- ut->step_size = sizeof(LatticeUndoStep);
+ ut->step_size = sizeof(LatticeUndoStep);
}
/** \} */
diff --git a/source/blender/editors/lattice/lattice_intern.h b/source/blender/editors/lattice/lattice_intern.h
index c08e6b6adb5..fe3f35b9223 100644
--- a/source/blender/editors/lattice/lattice_intern.h
+++ b/source/blender/editors/lattice/lattice_intern.h
@@ -21,7 +21,6 @@
* \ingroup edlattice
*/
-
#ifndef __LATTICE_INTERN_H__
#define __LATTICE_INTERN_H__
@@ -37,4 +36,4 @@ void LATTICE_OT_select_mirror(struct wmOperatorType *ot);
void LATTICE_OT_make_regular(struct wmOperatorType *ot);
void LATTICE_OT_flip(struct wmOperatorType *ot);
-#endif /* __LATTICE_INTERN_H__ */
+#endif /* __LATTICE_INTERN_H__ */
diff --git a/source/blender/editors/lattice/lattice_ops.c b/source/blender/editors/lattice/lattice_ops.c
index 49be5a6a4c9..a665d138163 100644
--- a/source/blender/editors/lattice/lattice_ops.c
+++ b/source/blender/editors/lattice/lattice_ops.c
@@ -37,18 +37,18 @@
void ED_operatortypes_lattice(void)
{
- WM_operatortype_append(LATTICE_OT_select_all);
- WM_operatortype_append(LATTICE_OT_select_more);
- WM_operatortype_append(LATTICE_OT_select_less);
- WM_operatortype_append(LATTICE_OT_select_ungrouped);
- WM_operatortype_append(LATTICE_OT_select_random);
- WM_operatortype_append(LATTICE_OT_select_mirror);
- WM_operatortype_append(LATTICE_OT_make_regular);
- WM_operatortype_append(LATTICE_OT_flip);
+ WM_operatortype_append(LATTICE_OT_select_all);
+ WM_operatortype_append(LATTICE_OT_select_more);
+ WM_operatortype_append(LATTICE_OT_select_less);
+ WM_operatortype_append(LATTICE_OT_select_ungrouped);
+ WM_operatortype_append(LATTICE_OT_select_random);
+ WM_operatortype_append(LATTICE_OT_select_mirror);
+ WM_operatortype_append(LATTICE_OT_make_regular);
+ WM_operatortype_append(LATTICE_OT_flip);
}
void ED_keymap_lattice(wmKeyConfig *keyconf)
{
- wmKeyMap *keymap = WM_keymap_ensure(keyconf, "Lattice", 0, 0);
- keymap->poll = ED_operator_editlattice;
+ wmKeyMap *keymap = WM_keymap_ensure(keyconf, "Lattice", 0, 0);
+ keymap->poll = ED_operator_editlattice;
}