Cleanup: Clang format
This commit is contained in:
parent
caf5f5767f
commit
ecbf642ddd
|
@ -1446,12 +1446,19 @@ typedef enum eSculpClothFilterPinchOriginType {
|
|||
} eSculptClothFilterPinchOriginType;
|
||||
|
||||
static EnumPropertyItem prop_cloth_filter_pinch_origin_type[] = {
|
||||
{CLOTH_FILTER_PINCH_ORIGIN_CURSOR, "CURSOR", 0, "Cursor", "Pinches to the location of the cursor"},
|
||||
{CLOTH_FILTER_PINCH_ORIGIN_FACE_SET, "FACE_SET", 0, "Face Set", "Pinches to the average location of the Face Set"},
|
||||
{CLOTH_FILTER_PINCH_ORIGIN_CURSOR,
|
||||
"CURSOR",
|
||||
0,
|
||||
"Cursor",
|
||||
"Pinches to the location of the cursor"},
|
||||
{CLOTH_FILTER_PINCH_ORIGIN_FACE_SET,
|
||||
"FACE_SET",
|
||||
0,
|
||||
"Face Set",
|
||||
"Pinches to the average location of the Face Set"},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
};
|
||||
|
||||
|
||||
static EnumPropertyItem prop_cloth_filter_orientation_items[] = {
|
||||
{SCULPT_FILTER_ORIENTATION_LOCAL,
|
||||
"LOCAL",
|
||||
|
@ -1580,7 +1587,8 @@ static void cloth_filter_apply_forces_task_cb(void *__restrict userdata,
|
|||
char symm_area = SCULPT_get_vertex_symm_area(orig_data.co);
|
||||
float pinch_point[3];
|
||||
copy_v3_v3(pinch_point, ss->filter_cache->cloth_sim_pinch_point);
|
||||
SCULPT_flip_v3_by_symm_area(pinch_point, symm, symm_area, ss->filter_cache->cloth_sim_pinch_point);
|
||||
SCULPT_flip_v3_by_symm_area(
|
||||
pinch_point, symm, symm_area, ss->filter_cache->cloth_sim_pinch_point);
|
||||
sub_v3_v3v3(force, pinch_point, vd.co);
|
||||
normalize_v3(force);
|
||||
mul_v3_fl(force, fade * data->filter_strength);
|
||||
|
@ -1670,25 +1678,26 @@ static int sculpt_cloth_filter_modal(bContext *C, wmOperator *op, const wmEvent
|
|||
return OPERATOR_RUNNING_MODAL;
|
||||
}
|
||||
|
||||
|
||||
static void sculpt_cloth_filter_face_set_pinch_origin_calculate(float r_pinch_origin[3], SculptSession *ss) {
|
||||
const int totvert = SCULPT_vertex_count_get(ss);
|
||||
const int active_face_set = SCULPT_active_face_set_get(ss);
|
||||
float accum[3] = {0.0f};
|
||||
int tot = 0;
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
if (!SCULPT_vertex_has_face_set(ss, i, active_face_set)) {
|
||||
continue;
|
||||
}
|
||||
add_v3_v3(accum, SCULPT_vertex_co_get(ss, i));
|
||||
tot++;
|
||||
}
|
||||
if (tot > 0) {
|
||||
mul_v3_v3fl(r_pinch_origin, accum, 1.0f/ tot);
|
||||
}
|
||||
else {
|
||||
copy_v3_v3(r_pinch_origin, SCULPT_active_vertex_co_get(ss));
|
||||
static void sculpt_cloth_filter_face_set_pinch_origin_calculate(float r_pinch_origin[3],
|
||||
SculptSession *ss)
|
||||
{
|
||||
const int totvert = SCULPT_vertex_count_get(ss);
|
||||
const int active_face_set = SCULPT_active_face_set_get(ss);
|
||||
float accum[3] = {0.0f};
|
||||
int tot = 0;
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
if (!SCULPT_vertex_has_face_set(ss, i, active_face_set)) {
|
||||
continue;
|
||||
}
|
||||
add_v3_v3(accum, SCULPT_vertex_co_get(ss, i));
|
||||
tot++;
|
||||
}
|
||||
if (tot > 0) {
|
||||
mul_v3_v3fl(r_pinch_origin, accum, 1.0f / tot);
|
||||
}
|
||||
else {
|
||||
copy_v3_v3(r_pinch_origin, SCULPT_active_vertex_co_get(ss));
|
||||
}
|
||||
}
|
||||
|
||||
static int sculpt_cloth_filter_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
|
@ -1729,14 +1738,14 @@ static int sculpt_cloth_filter_invoke(bContext *C, wmOperator *op, const wmEvent
|
|||
use_collisions,
|
||||
cloth_filter_is_deformation_filter(filter_type));
|
||||
|
||||
switch (pinch_origin)
|
||||
{
|
||||
case CLOTH_FILTER_PINCH_ORIGIN_CURSOR:
|
||||
copy_v3_v3(ss->filter_cache->cloth_sim_pinch_point, SCULPT_active_vertex_co_get(ss));
|
||||
break;
|
||||
case CLOTH_FILTER_PINCH_ORIGIN_FACE_SET:
|
||||
sculpt_cloth_filter_face_set_pinch_origin_calculate(ss->filter_cache->cloth_sim_pinch_point, ss);
|
||||
break;
|
||||
switch (pinch_origin) {
|
||||
case CLOTH_FILTER_PINCH_ORIGIN_CURSOR:
|
||||
copy_v3_v3(ss->filter_cache->cloth_sim_pinch_point, SCULPT_active_vertex_co_get(ss));
|
||||
break;
|
||||
case CLOTH_FILTER_PINCH_ORIGIN_FACE_SET:
|
||||
sculpt_cloth_filter_face_set_pinch_origin_calculate(ss->filter_cache->cloth_sim_pinch_point,
|
||||
ss);
|
||||
break;
|
||||
}
|
||||
|
||||
SCULPT_cloth_brush_simulation_init(ss, ss->filter_cache->cloth_sim);
|
||||
|
|
|
@ -705,9 +705,8 @@ static float *sculpt_expand_diagonals_falloff_create(Object *ob, const int v)
|
|||
return dists;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Poly Loop:
|
||||
* Poly Loop:
|
||||
*/
|
||||
static float *sculpt_expand_poly_loop_falloff_create(Object *ob, const int v)
|
||||
{
|
||||
|
@ -717,7 +716,7 @@ static float *sculpt_expand_poly_loop_falloff_create(Object *ob, const int v)
|
|||
BLI_bitmap *visited_vertices = BLI_BITMAP_NEW(totvert, "visited vertices");
|
||||
GSQueue *queue = BLI_gsqueue_new(sizeof(int));
|
||||
|
||||
printf("POLY LOOP FALLOFF\n");
|
||||
printf("POLY LOOP FALLOFF\n");
|
||||
|
||||
/* Search and initialize a boundary per symmetry pass, then mark those vertices as visited. */
|
||||
const char symm = SCULPT_mesh_symmetry_xyz_get(ob);
|
||||
|
@ -1808,19 +1807,19 @@ static int sculpt_expand_modal(bContext *C, wmOperator *op, const wmEvent *event
|
|||
break;
|
||||
}
|
||||
case SCULPT_EXPAND_MODAL_SNAP_ENABLE: {
|
||||
expand_cache->snap = true;
|
||||
if (!expand_cache->snap_enabled_face_sets) {
|
||||
expand_cache->snap_enabled_face_sets = BLI_gset_int_new("snap face sets");
|
||||
}
|
||||
sculpt_expand_snap_initialize_from_enabled(ss, expand_cache);
|
||||
expand_cache->snap = true;
|
||||
if (!expand_cache->snap_enabled_face_sets) {
|
||||
expand_cache->snap_enabled_face_sets = BLI_gset_int_new("snap face sets");
|
||||
}
|
||||
sculpt_expand_snap_initialize_from_enabled(ss, expand_cache);
|
||||
} break;
|
||||
case SCULPT_EXPAND_MODAL_SNAP_DISABLE: {
|
||||
expand_cache->snap = false;
|
||||
if (expand_cache->snap_enabled_face_sets) {
|
||||
BLI_gset_free(expand_cache->snap_enabled_face_sets, NULL);
|
||||
expand_cache->snap_enabled_face_sets = NULL;
|
||||
}
|
||||
}break;
|
||||
expand_cache->snap = false;
|
||||
if (expand_cache->snap_enabled_face_sets) {
|
||||
BLI_gset_free(expand_cache->snap_enabled_face_sets, NULL);
|
||||
expand_cache->snap_enabled_face_sets = NULL;
|
||||
}
|
||||
} break;
|
||||
case SCULPT_EXPAND_MODAL_MOVE_TOGGLE: {
|
||||
if (expand_cache->move) {
|
||||
expand_cache->move = false;
|
||||
|
@ -2192,7 +2191,11 @@ void sculpt_expand_modal_keymap(wmKeyConfig *keyconf)
|
|||
""},
|
||||
{SCULPT_EXPAND_MODAL_FALLOFF_SPHERICAL, "FALLOFF_SPHERICAL", 0, "Spherical Falloff", ""},
|
||||
{SCULPT_EXPAND_MODAL_SNAP_ENABLE, "SNAP_ENABLE", 0, "Snap expand to Face Sets", ""},
|
||||
{SCULPT_EXPAND_MODAL_SNAP_DISABLE, "SNAP_DISABLE", 0, "Disable Snap expand to Face Sets", ""},
|
||||
{SCULPT_EXPAND_MODAL_SNAP_DISABLE,
|
||||
"SNAP_DISABLE",
|
||||
0,
|
||||
"Disable Snap expand to Face Sets",
|
||||
""},
|
||||
{SCULPT_EXPAND_MODAL_LOOP_COUNT_INCREASE,
|
||||
"LOOP_COUNT_INCREASE",
|
||||
0,
|
||||
|
|
|
@ -77,7 +77,6 @@ typedef enum eSculptFaceSetByTopologyMode {
|
|||
SCULPT_FACE_SET_TOPOLOGY_POLY_LOOP = 1,
|
||||
};
|
||||
|
||||
|
||||
static EnumPropertyItem prop_sculpt_face_set_by_topology[] = {
|
||||
{
|
||||
SCULPT_FACE_SET_TOPOLOGY_LOOSE_PART,
|
||||
|
@ -96,11 +95,11 @@ static EnumPropertyItem prop_sculpt_face_set_by_topology[] = {
|
|||
{0, NULL, 0, NULL, NULL},
|
||||
};
|
||||
|
||||
|
||||
static void sculpt_face_set_by_topology_poly_loop(Object *ob, const int next_face_set_id) {
|
||||
static void sculpt_face_set_by_topology_poly_loop(Object *ob, const int next_face_set_id)
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
BLI_bitmap *poly_loop = sculpt_poly_loop_from_cursor(ob);
|
||||
for (int i = 0; i < ss->totfaces; i++) {
|
||||
for (int i = 0; i < ss->totfaces; i++) {
|
||||
if (BLI_BITMAP_TEST(poly_loop, i)) {
|
||||
ss->face_sets[i] = next_face_set_id;
|
||||
}
|
||||
|
@ -134,15 +133,14 @@ static int sculpt_face_set_by_topology_invoke(bContext *C, wmOperator *op, const
|
|||
SCULPT_undo_push_begin(ob, "face set edit");
|
||||
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 && initial_poly != ss->face_set_last_poly && initial_edge != ss->face_set_last_edge) {
|
||||
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 {
|
||||
|
@ -157,11 +155,9 @@ static int sculpt_face_set_by_topology_invoke(bContext *C, wmOperator *op, const
|
|||
break;
|
||||
}
|
||||
|
||||
|
||||
ss->face_set_last_created = new_face_set;
|
||||
ss->face_set_last_edge = initial_edge;
|
||||
ss->face_set_last_poly = initial_poly;
|
||||
|
||||
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. */
|
||||
SCULPT_visibility_sync_all_face_sets_to_vertices(ob);
|
||||
|
@ -197,9 +193,16 @@ void SCULPT_OT_face_set_by_topology(struct wmOperatorType *ot)
|
|||
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
RNA_def_enum(
|
||||
ot->srna, "mode", prop_sculpt_face_set_by_topology, SCULPT_FACE_SET_TOPOLOGY_POLY_LOOP, "Mode", "");
|
||||
RNA_def_enum(ot->srna,
|
||||
"mode",
|
||||
prop_sculpt_face_set_by_topology,
|
||||
SCULPT_FACE_SET_TOPOLOGY_POLY_LOOP,
|
||||
"Mode",
|
||||
"");
|
||||
|
||||
RNA_def_boolean(
|
||||
ot->srna, "repeat_previous", true, "Repeat previous Face Set", "Repeat the latest created Face Set instead of a new one");
|
||||
RNA_def_boolean(ot->srna,
|
||||
"repeat_previous",
|
||||
true,
|
||||
"Repeat previous Face Set",
|
||||
"Repeat the latest created Face Set instead of a new one");
|
||||
}
|
||||
|
|
|
@ -1421,11 +1421,9 @@ bool SCULPT_get_redraw_rect(struct ARegion *region,
|
|||
Object *ob,
|
||||
rcti *rect);
|
||||
|
||||
|
||||
/* Poly Loops. */
|
||||
int sculpt_poly_loop_initial_edge_from_cursor(Object *ob);
|
||||
BLI_bitmap * sculpt_poly_loop_from_cursor(struct Object *ob);
|
||||
|
||||
BLI_bitmap *sculpt_poly_loop_from_cursor(struct Object *ob);
|
||||
|
||||
/* Operators. */
|
||||
|
||||
|
|
|
@ -72,7 +72,8 @@
|
|||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static void sculpt_poly_loop_topology_data_ensure(Object *ob) {
|
||||
static void sculpt_poly_loop_topology_data_ensure(Object *ob)
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
Mesh *mesh = BKE_object_get_original_mesh(ob);
|
||||
|
||||
|
@ -93,44 +94,52 @@ static void sculpt_poly_loop_topology_data_ensure(Object *ob) {
|
|||
}
|
||||
|
||||
#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) {
|
||||
if (!ss->epmap) {
|
||||
return false;
|
||||
}
|
||||
static bool sculpt_poly_loop_step(SculptSession *ss,
|
||||
const int from_poly,
|
||||
const int edge,
|
||||
int *r_next_poly)
|
||||
{
|
||||
if (!ss->epmap) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int next_poly = SCULPT_FACE_SET_LOOP_STEP_NONE;
|
||||
for (int i = 0; i < ss->epmap[edge].count; i++) {
|
||||
if (ss->epmap[edge].indices[i] != from_poly) {
|
||||
next_poly = ss->epmap[edge].indices[i];
|
||||
}
|
||||
}
|
||||
int next_poly = SCULPT_FACE_SET_LOOP_STEP_NONE;
|
||||
for (int i = 0; i < ss->epmap[edge].count; i++) {
|
||||
if (ss->epmap[edge].indices[i] != from_poly) {
|
||||
next_poly = ss->epmap[edge].indices[i];
|
||||
}
|
||||
}
|
||||
|
||||
if (next_poly == SCULPT_FACE_SET_LOOP_STEP_NONE) {
|
||||
return false;
|
||||
}
|
||||
if (next_poly == SCULPT_FACE_SET_LOOP_STEP_NONE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*r_next_poly = next_poly;
|
||||
return true;
|
||||
*r_next_poly = next_poly;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int sculpt_poly_loop_opposite_edge_in_quad(SculptSession *ss, const int poly, const int edge) {
|
||||
static int sculpt_poly_loop_opposite_edge_in_quad(SculptSession *ss,
|
||||
const int poly,
|
||||
const int edge)
|
||||
{
|
||||
if (ss->mpoly[poly].totloop != 4) {
|
||||
return edge;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int edge_index_in_poly = 0;
|
||||
for (int i = 0; i < ss->mpoly[poly].totloop; i++) {
|
||||
if (edge == ss->mloop[ss->mpoly[poly].loopstart + i].e) {
|
||||
edge_index_in_poly = i;
|
||||
break;
|
||||
}
|
||||
if (edge == ss->mloop[ss->mpoly[poly].loopstart + i].e) {
|
||||
edge_index_in_poly = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const int next_edge_index_in_poly = (edge_index_in_poly + 2) % 4;
|
||||
return ss->mloop[ss->mpoly[poly].loopstart + next_edge_index_in_poly].e;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
|
@ -147,17 +156,24 @@ int sculpt_poly_loop_initial_edge_from_cursor(Object *ob) {
|
|||
|
||||
int closest_vert = mesh->mloop[initial_poly->loopstart].v;
|
||||
for (int i = 0; i < initial_poly->totloop; i++) {
|
||||
if (len_squared_v3v3(mvert[ss->mloop[initial_poly->loopstart + i].v].co, location) < len_squared_v3v3(mvert[closest_vert].co, location)) {
|
||||
if (len_squared_v3v3(mvert[ss->mloop[initial_poly->loopstart + i].v].co, location) <
|
||||
len_squared_v3v3(mvert[closest_vert].co, location)) {
|
||||
closest_vert = ss->mloop[initial_poly->loopstart + i].v;
|
||||
}
|
||||
}
|
||||
|
||||
int initial_edge = ss->vemap[closest_vert].indices[0];
|
||||
int closest_vert_on_initial_edge = mesh->medge[initial_edge].v1 == closest_vert ? mesh->medge[initial_edge].v2 : mesh->medge[initial_edge].v1;
|
||||
int closest_vert_on_initial_edge = mesh->medge[initial_edge].v1 == closest_vert ?
|
||||
mesh->medge[initial_edge].v2 :
|
||||
mesh->medge[initial_edge].v1;
|
||||
for (int i = 0; i < ss->vemap[closest_vert].count; i++) {
|
||||
const int edge_index = ss->vemap[closest_vert].indices[i];
|
||||
const int other_vert = mesh->medge[edge_index].v1 == closest_vert ? mesh->medge[edge_index].v2 : mesh->medge[edge_index].v1;
|
||||
if (dist_to_line_segment_v3(location, mvert[closest_vert].co, mvert[other_vert].co) < dist_to_line_segment_v3(location, mvert[closest_vert].co, mvert[closest_vert_on_initial_edge].co)) {
|
||||
const int other_vert = mesh->medge[edge_index].v1 == closest_vert ?
|
||||
mesh->medge[edge_index].v2 :
|
||||
mesh->medge[edge_index].v1;
|
||||
if (dist_to_line_segment_v3(location, mvert[closest_vert].co, mvert[other_vert].co) <
|
||||
dist_to_line_segment_v3(
|
||||
location, mvert[closest_vert].co, mvert[closest_vert_on_initial_edge].co)) {
|
||||
initial_edge = edge_index;
|
||||
closest_vert_on_initial_edge = other_vert;
|
||||
}
|
||||
|
@ -165,7 +181,11 @@ int sculpt_poly_loop_initial_edge_from_cursor(Object *ob) {
|
|||
return initial_edge;
|
||||
}
|
||||
|
||||
static void sculpt_poly_loop_iterate_and_fill(SculptSession *ss, const int initial_poly, const int initial_edge, BLI_bitmap *poly_loop) {
|
||||
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;
|
||||
int next_poly = SCULPT_FACE_SET_LOOP_STEP_NONE;
|
||||
|
@ -173,7 +193,7 @@ static void sculpt_poly_loop_iterate_and_fill(SculptSession *ss, const int initi
|
|||
|
||||
BLI_BITMAP_ENABLE(poly_loop, initial_poly);
|
||||
|
||||
while(max_steps && sculpt_poly_loop_step(ss, current_poly, current_edge, &next_poly)) {
|
||||
while (max_steps && sculpt_poly_loop_step(ss, current_poly, current_edge, &next_poly)) {
|
||||
if (ss->face_sets[next_poly] == initial_poly) {
|
||||
break;
|
||||
}
|
||||
|
@ -191,7 +211,8 @@ static void sculpt_poly_loop_iterate_and_fill(SculptSession *ss, const int initi
|
|||
}
|
||||
}
|
||||
|
||||
BLI_bitmap * sculpt_poly_loop_from_cursor(Object *ob) {
|
||||
BLI_bitmap *sculpt_poly_loop_from_cursor(Object *ob)
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
Mesh *mesh = BKE_object_get_original_mesh(ob);
|
||||
BLI_bitmap *poly_loop = BLI_BITMAP_NEW(mesh->totpoly, "poly loop");
|
||||
|
@ -199,7 +220,8 @@ BLI_bitmap * sculpt_poly_loop_from_cursor(Object *ob) {
|
|||
sculpt_poly_loop_topology_data_ensure(ob);
|
||||
const int initial_edge = sculpt_poly_loop_initial_edge_from_cursor(ob);
|
||||
const int initial_poly = ss->active_face_index;
|
||||
const int initial_edge_opposite = sculpt_poly_loop_opposite_edge_in_quad(ss, initial_poly, initial_edge);
|
||||
const int initial_edge_opposite = sculpt_poly_loop_opposite_edge_in_quad(
|
||||
ss, initial_poly, initial_edge);
|
||||
sculpt_poly_loop_iterate_and_fill(ss, initial_poly, initial_edge, poly_loop);
|
||||
sculpt_poly_loop_iterate_and_fill(ss, initial_poly, initial_edge_opposite, poly_loop);
|
||||
|
||||
|
|
Loading…
Reference in New Issue