Face Sets Topology: Improve keymap and creation delay
This commit is contained in:
parent
3d70805a68
commit
dd77b22626
|
@ -4477,10 +4477,8 @@ def km_sculpt(params):
|
|||
("sculpt.brush_stroke", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
|
||||
{"properties": [("mode", 'SMOOTH')]}),
|
||||
# Face Set by Topology
|
||||
("sculpt.face_set_by_topology", {"type": 'W', "value": 'RELEASE', "ctrl": True},
|
||||
("sculpt.face_set_by_topology", {"type": 'W', "value": 'PRESS', "ctrl": True},
|
||||
{"properties": [("mode", "POLY_LOOP"), ("repeat_previous", True)]}),
|
||||
("sculpt.face_set_by_topology", {"type": 'W', "value": 'DOUBLE_CLICK', "ctrl": True},
|
||||
{"properties": [("mode", "POLY_LOOP"), ("repeat_previous", False)]}),
|
||||
# Expand
|
||||
("sculpt.expand", {"type": 'A', "value": 'PRESS', "shift": True},
|
||||
{"properties": [("target", "MASK"), ("falloff_type", "GEODESIC"), ("invert", True)]}),
|
||||
|
|
|
@ -560,6 +560,8 @@ typedef struct SculptSession {
|
|||
|
||||
/* Face Sets by topology. */
|
||||
int face_set_last_created;
|
||||
int face_set_last_poly;
|
||||
int face_set_last_edge;
|
||||
|
||||
/* Dynamic mesh preview */
|
||||
int *preview_vert_index_list;
|
||||
|
|
|
@ -135,9 +135,14 @@ static int sculpt_face_set_by_topology_invoke(bContext *C, wmOperator *op, const
|
|||
SCULPT_undo_push_node(ob, nodes[0], SCULPT_UNDO_FACE_SETS);
|
||||
|
||||
|
||||
const int initial_poly = ss->active_face_index;
|
||||
const int initial_edge = sculpt_poly_loop_initial_edge_from_cursor(ob);
|
||||
|
||||
Mesh *mesh = BKE_object_get_original_mesh(ob);
|
||||
int new_face_set = SCULPT_FACE_SET_NONE;
|
||||
if (repeat_previous && ss->face_set_last_created != SCULPT_FACE_SET_NONE) {
|
||||
|
||||
|
||||
if (repeat_previous && ss->face_set_last_created != SCULPT_FACE_SET_NONE && initial_poly != ss->face_set_last_poly && initial_edge != ss->face_set_last_edge) {
|
||||
new_face_set = ss->face_set_last_created;
|
||||
}
|
||||
else {
|
||||
|
@ -147,7 +152,6 @@ static int sculpt_face_set_by_topology_invoke(bContext *C, wmOperator *op, const
|
|||
switch (mode) {
|
||||
case SCULPT_FACE_SET_TOPOLOGY_LOOSE_PART:
|
||||
break;
|
||||
|
||||
case SCULPT_FACE_SET_TOPOLOGY_POLY_LOOP:
|
||||
sculpt_face_set_by_topology_poly_loop(ob, new_face_set);
|
||||
break;
|
||||
|
@ -155,6 +159,8 @@ static int sculpt_face_set_by_topology_invoke(bContext *C, wmOperator *op, const
|
|||
|
||||
|
||||
ss->face_set_last_created = new_face_set;
|
||||
ss->face_set_last_edge = initial_edge;
|
||||
ss->face_set_last_poly = initial_poly;
|
||||
|
||||
|
||||
/* Sync face sets visibility and vertex visibility as now all Face Sets are visible. */
|
||||
|
@ -195,5 +201,5 @@ void SCULPT_OT_face_set_by_topology(struct wmOperatorType *ot)
|
|||
ot->srna, "mode", prop_sculpt_face_set_by_topology, SCULPT_FACE_SET_TOPOLOGY_POLY_LOOP, "Mode", "");
|
||||
|
||||
RNA_def_boolean(
|
||||
ot->srna, "repeat_previous", false, "Repeat previous Face Set", "Repeat the latest created Face Set instead of a new one");
|
||||
ot->srna, "repeat_previous", true, "Repeat previous Face Set", "Repeat the latest created Face Set instead of a new one");
|
||||
}
|
||||
|
|
|
@ -1422,6 +1422,7 @@ bool SCULPT_get_redraw_rect(struct ARegion *region,
|
|||
|
||||
|
||||
/* Poly Loops. */
|
||||
int sculpt_poly_loop_initial_edge_from_cursor(Object *ob);
|
||||
BLI_bitmap * sculpt_poly_loop_from_cursor(struct Object *ob);
|
||||
|
||||
|
||||
|
|
|
@ -72,30 +72,25 @@
|
|||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef enum eSculptFaceSetByTopologyMode {
|
||||
SCULPT_FACE_SET_TOPOLOGY_LOOSE_PART = 0,
|
||||
SCULPT_FACE_SET_TOPOLOGY_POLY_LOOP = 1,
|
||||
};
|
||||
|
||||
|
||||
static EnumPropertyItem prop_sculpt_face_set_by_topology[] = {
|
||||
{
|
||||
SCULPT_FACE_SET_TOPOLOGY_LOOSE_PART,
|
||||
"LOOSE_PART",
|
||||
0,
|
||||
"Loose Part",
|
||||
"",
|
||||
},
|
||||
{
|
||||
SCULPT_FACE_SET_TOPOLOGY_POLY_LOOP,
|
||||
"POLY_LOOP",
|
||||
0,
|
||||
"Face Loop",
|
||||
"",
|
||||
},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
};
|
||||
static void sculpt_poly_loop_topology_data_ensure(Object *ob) {
|
||||
SculptSession *ss = ob->sculpt;
|
||||
Mesh *mesh = BKE_object_get_original_mesh(ob);
|
||||
|
||||
if (!ss->epmap) {
|
||||
BKE_mesh_edge_poly_map_create(&ss->epmap,
|
||||
&ss->epmap_mem,
|
||||
mesh->medge,
|
||||
mesh->totedge,
|
||||
mesh->mpoly,
|
||||
mesh->totpoly,
|
||||
mesh->mloop,
|
||||
mesh->totloop);
|
||||
}
|
||||
if (!ss->vemap) {
|
||||
BKE_mesh_vert_edge_map_create(
|
||||
&ss->vemap, &ss->vemap_mem, mesh->medge, mesh->totvert, mesh->totedge);
|
||||
}
|
||||
}
|
||||
|
||||
#define SCULPT_FACE_SET_LOOP_STEP_NONE -1
|
||||
static bool sculpt_poly_loop_step(SculptSession *ss, const int from_poly, const int edge, int *r_next_poly) {
|
||||
|
@ -135,10 +130,12 @@ static int sculpt_poly_loop_opposite_edge_in_quad(SculptSession *ss, const int p
|
|||
return ss->mloop[ss->mpoly[poly].loopstart + next_edge_index_in_poly].e;
|
||||
}
|
||||
|
||||
static int sculpt_poly_loop_initial_edge_from_cursor(Object *ob) {
|
||||
int sculpt_poly_loop_initial_edge_from_cursor(Object *ob) {
|
||||
SculptSession *ss = ob->sculpt;
|
||||
Mesh *mesh = BKE_object_get_original_mesh(ob);
|
||||
|
||||
sculpt_poly_loop_topology_data_ensure(ob);
|
||||
|
||||
float *location = ss->cursor_location;
|
||||
|
||||
MVert *mvert = SCULPT_mesh_deformed_mverts_get(ss);
|
||||
|
@ -168,26 +165,6 @@ static int sculpt_poly_loop_initial_edge_from_cursor(Object *ob) {
|
|||
return initial_edge;
|
||||
}
|
||||
|
||||
static void sculpt_poly_loop_topology_data_ensure(Object *ob) {
|
||||
SculptSession *ss = ob->sculpt;
|
||||
Mesh *mesh = BKE_object_get_original_mesh(ob);
|
||||
|
||||
if (!ss->epmap) {
|
||||
BKE_mesh_edge_poly_map_create(&ss->epmap,
|
||||
&ss->epmap_mem,
|
||||
mesh->medge,
|
||||
mesh->totedge,
|
||||
mesh->mpoly,
|
||||
mesh->totpoly,
|
||||
mesh->mloop,
|
||||
mesh->totloop);
|
||||
}
|
||||
if (!ss->vemap) {
|
||||
BKE_mesh_vert_edge_map_create(
|
||||
&ss->vemap, &ss->vemap_mem, mesh->medge, mesh->totvert, mesh->totedge);
|
||||
}
|
||||
}
|
||||
|
||||
static void sculpt_poly_loop_iterate_and_fill(SculptSession *ss, const int initial_poly, const int initial_edge, BLI_bitmap *poly_loop) {
|
||||
int current_poly = initial_poly;
|
||||
int current_edge = initial_edge;
|
||||
|
|
Loading…
Reference in New Issue