Cleanup: clang format for particle loop macros

See https://developer.blender.org/D5903

Reviewers: JacquesLucke
This commit is contained in:
2019-09-26 16:31:42 +02:00
parent b0d3ed3d20
commit 7ac581cb1b
3 changed files with 93 additions and 186 deletions

View File

@@ -151,8 +151,7 @@ void PE_free_ptcache_edit(PTCacheEdit *edit)
} }
if (edit->points) { if (edit->points) {
LOOP_POINTS LOOP_POINTS {
{
if (point->keys) { if (point->keys) {
MEM_freeN(point->keys); MEM_freeN(point->keys);
} }
@@ -382,10 +381,8 @@ void PE_hide_keys_time(Scene *scene, PTCacheEdit *edit, float cfra)
KEY_K; KEY_K;
if (pset->flag & PE_FADE_TIME && pset->selectmode == SCE_SELECT_POINT) { if (pset->flag & PE_FADE_TIME && pset->selectmode == SCE_SELECT_POINT) {
LOOP_POINTS LOOP_POINTS {
{ LOOP_KEYS {
LOOP_KEYS
{
if (fabsf(cfra - *key->time) < pset->fade_frames) { if (fabsf(cfra - *key->time) < pset->fade_frames) {
key->flag &= ~PEK_HIDE; key->flag &= ~PEK_HIDE;
} }
@@ -397,10 +394,8 @@ void PE_hide_keys_time(Scene *scene, PTCacheEdit *edit, float cfra)
} }
} }
else { else {
LOOP_POINTS LOOP_POINTS {
{ LOOP_KEYS {
LOOP_KEYS
{
key->flag &= ~PEK_HIDE; key->flag &= ~PEK_HIDE;
} }
} }
@@ -636,8 +631,7 @@ static bool point_is_selected(PTCacheEditPoint *point)
return 0; return 0;
} }
LOOP_SELECTED_KEYS LOOP_SELECTED_KEYS {
{
return 1; return 1;
} }
@@ -687,8 +681,7 @@ static void for_mouse_hit_keys(PEData *data, ForKeyFunc func, const enum ePartic
nearest_point = -1; nearest_point = -1;
nearest_key = -1; nearest_key = -1;
LOOP_VISIBLE_POINTS LOOP_VISIBLE_POINTS {
{
if (pset->selectmode == SCE_SELECT_END) { if (pset->selectmode == SCE_SELECT_END) {
if (point->totkey) { if (point->totkey) {
/* only do end keys */ /* only do end keys */
@@ -710,8 +703,7 @@ static void for_mouse_hit_keys(PEData *data, ForKeyFunc func, const enum ePartic
} }
else { else {
/* do all keys */ /* do all keys */
LOOP_VISIBLE_KEYS LOOP_VISIBLE_KEYS {
{
if (flag & PSEL_NEAREST) { if (flag & PSEL_NEAREST) {
if (key_inside_circle(data, dist, KEY_WCO, &dist)) { if (key_inside_circle(data, dist, KEY_WCO, &dist)) {
nearest_point = p; nearest_point = p;
@@ -748,8 +740,7 @@ static void foreach_mouse_hit_point(PEData *data, ForHitPointFunc func, int sele
selected = 0; selected = 0;
} }
LOOP_VISIBLE_POINTS LOOP_VISIBLE_POINTS {
{
if (pset->selectmode == SCE_SELECT_END) { if (pset->selectmode == SCE_SELECT_END) {
if (point->totkey) { if (point->totkey) {
/* only do end keys */ /* only do end keys */
@@ -765,8 +756,7 @@ static void foreach_mouse_hit_point(PEData *data, ForHitPointFunc func, int sele
} }
else { else {
/* do all keys */ /* do all keys */
LOOP_VISIBLE_KEYS LOOP_VISIBLE_KEYS {
{
if (selected == 0 || key->flag & PEK_SELECT) { if (selected == 0 || key->flag & PEK_SELECT) {
float mouse_distance; float mouse_distance;
if (key_inside_circle(data, data->rad, KEY_WCO, &mouse_distance)) { if (key_inside_circle(data, data->rad, KEY_WCO, &mouse_distance)) {
@@ -826,8 +816,7 @@ static void foreach_mouse_hit_key_iter(void *__restrict iter_data_v,
/* do all keys */ /* do all keys */
PTCacheEditKey *key; PTCacheEditKey *key;
int k; int k;
LOOP_VISIBLE_KEYS LOOP_VISIBLE_KEYS {
{
if (selected == 0 || key->flag & PEK_SELECT) { if (selected == 0 || key->flag & PEK_SELECT) {
float mouse_distance; float mouse_distance;
if (key_inside_circle(data, data->rad, KEY_WCO, &mouse_distance)) { if (key_inside_circle(data, data->rad, KEY_WCO, &mouse_distance)) {
@@ -869,8 +858,7 @@ static void foreach_selected_point(PEData *data, ForPointFunc func)
PTCacheEdit *edit = data->edit; PTCacheEdit *edit = data->edit;
POINT_P; POINT_P;
LOOP_SELECTED_POINTS LOOP_SELECTED_POINTS {
{
func(data, p); func(data, p);
} }
} }
@@ -881,10 +869,8 @@ static void foreach_selected_key(PEData *data, ForKeyFunc func)
POINT_P; POINT_P;
KEY_K; KEY_K;
LOOP_VISIBLE_POINTS LOOP_VISIBLE_POINTS {
{ LOOP_SELECTED_KEYS {
LOOP_SELECTED_KEYS
{
func(data, p, k, true); func(data, p, k, true);
} }
} }
@@ -895,8 +881,7 @@ static void foreach_point(PEData *data, ForPointFunc func)
PTCacheEdit *edit = data->edit; PTCacheEdit *edit = data->edit;
POINT_P; POINT_P;
LOOP_POINTS LOOP_POINTS {
{
func(data, p); func(data, p);
} }
} }
@@ -908,11 +893,9 @@ static int count_selected_keys(Scene *scene, PTCacheEdit *edit)
KEY_K; KEY_K;
int sel = 0; int sel = 0;
LOOP_VISIBLE_POINTS LOOP_VISIBLE_POINTS {
{
if (pset->selectmode == SCE_SELECT_POINT) { if (pset->selectmode == SCE_SELECT_POINT) {
LOOP_SELECTED_KEYS LOOP_SELECTED_KEYS {
{
sel++; sel++;
} }
} }
@@ -1120,8 +1103,7 @@ static void PE_apply_mirror(Object *ob, ParticleSystem *psys)
/* we delay settings the PARS_EDIT_RECALC for mirrored particles /* we delay settings the PARS_EDIT_RECALC for mirrored particles
* to avoid doing mirror twice */ * to avoid doing mirror twice */
LOOP_POINTS LOOP_POINTS {
{
if (point->flag & PEP_EDIT_RECALC) { if (point->flag & PEP_EDIT_RECALC) {
PE_mirror_particle(ob, psmd_eval->mesh_final, psys, psys->particles + p, NULL); PE_mirror_particle(ob, psmd_eval->mesh_final, psys, psys->particles + p, NULL);
@@ -1131,8 +1113,7 @@ static void PE_apply_mirror(Object *ob, ParticleSystem *psys)
} }
} }
LOOP_POINTS LOOP_POINTS {
{
if (point->flag & PEP_EDIT_RECALC) { if (point->flag & PEP_EDIT_RECALC) {
if (edit->mirror_cache[p] != -1) { if (edit->mirror_cache[p] != -1) {
edit->points[edit->mirror_cache[p]].flag |= PEP_EDIT_RECALC; edit->points[edit->mirror_cache[p]].flag |= PEP_EDIT_RECALC;
@@ -1176,13 +1157,11 @@ static void deflect_emitter_iter(void *__restrict iter_data_v,
psys_mat_hair_to_object( psys_mat_hair_to_object(
object, psmd_eval->mesh_final, psys->part->from, psys->particles + iter, hairmat); object, psmd_eval->mesh_final, psys->part->from, psys->particles + iter, hairmat);
LOOP_KEYS LOOP_KEYS {
{
mul_m4_v3(hairmat, key->co); mul_m4_v3(hairmat, key->co);
} }
LOOP_KEYS LOOP_KEYS {
{
if (k == 0) { if (k == 0) {
dist_1st = len_v3v3((key + 1)->co, key->co); dist_1st = len_v3v3((key + 1)->co, key->co);
dist_1st *= dist * emitterdist; dist_1st *= dist * emitterdist;
@@ -1218,8 +1197,7 @@ static void deflect_emitter_iter(void *__restrict iter_data_v,
invert_m4_m4(hairimat, hairmat); invert_m4_m4(hairimat, hairmat);
LOOP_KEYS LOOP_KEYS {
{
mul_m4_v3(hairimat, key->co); mul_m4_v3(hairimat, key->co);
} }
} }
@@ -1271,8 +1249,7 @@ static void apply_lengths_iter(void *__restrict iter_data_v,
} }
PTCacheEditKey *key; PTCacheEditKey *key;
int k; int k;
LOOP_KEYS LOOP_KEYS {
{
if (k) { if (k) {
float dv1[3]; float dv1[3];
sub_v3_v3v3(dv1, key->co, (key - 1)->co); sub_v3_v3v3(dv1, key->co, (key - 1)->co);
@@ -1390,8 +1367,7 @@ void recalc_lengths(PTCacheEdit *edit)
return; return;
} }
LOOP_EDITED_POINTS LOOP_EDITED_POINTS {
{
key = point->keys; key = point->keys;
for (k = 0; k < point->totkey - 1; k++, key++) { for (k = 0; k < point->totkey - 1; k++, key++) {
key->length = len_v3v3(key->co, (key + 1)->co); key->length = len_v3v3(key->co, (key + 1)->co);
@@ -1471,8 +1447,7 @@ static void PE_update_selection(Depsgraph *depsgraph, Scene *scene, Object *ob,
/* flag all particles to be updated if not using flag */ /* flag all particles to be updated if not using flag */
if (!useflag) { if (!useflag) {
LOOP_POINTS LOOP_POINTS {
{
point->flag |= PEP_EDIT_RECALC; point->flag |= PEP_EDIT_RECALC;
} }
} }
@@ -1480,11 +1455,9 @@ static void PE_update_selection(Depsgraph *depsgraph, Scene *scene, Object *ob,
/* flush edit key flag to hair key flag to preserve selection /* flush edit key flag to hair key flag to preserve selection
* on save */ * on save */
if (edit->psys) { if (edit->psys) {
LOOP_POINTS LOOP_POINTS {
{
hkey = edit->psys->particles[p].hair; hkey = edit->psys->particles[p].hair;
LOOP_KEYS LOOP_KEYS {
{
hkey->editflag = key->flag; hkey->editflag = key->flag;
hkey++; hkey++;
} }
@@ -1494,8 +1467,7 @@ static void PE_update_selection(Depsgraph *depsgraph, Scene *scene, Object *ob,
psys_cache_edit_paths(depsgraph, scene, ob, edit, CFRA, G.is_rendering); psys_cache_edit_paths(depsgraph, scene, ob, edit, CFRA, G.is_rendering);
/* disable update flag */ /* disable update flag */
LOOP_POINTS LOOP_POINTS {
{
point->flag &= ~PEP_EDIT_RECALC; point->flag &= ~PEP_EDIT_RECALC;
} }
@@ -1514,15 +1486,13 @@ void update_world_cos(Object *ob, PTCacheEdit *edit)
return; return;
} }
LOOP_POINTS LOOP_POINTS {
{
if (!(psys->flag & PSYS_GLOBAL_HAIR)) { if (!(psys->flag & PSYS_GLOBAL_HAIR)) {
psys_mat_hair_to_global( psys_mat_hair_to_global(
ob, psmd_eval->mesh_final, psys->part->from, psys->particles + p, hairmat); ob, psmd_eval->mesh_final, psys->part->from, psys->particles + p, hairmat);
} }
LOOP_KEYS LOOP_KEYS {
{
copy_v3_v3(key->world_co, key->co); copy_v3_v3(key->world_co, key->co);
if (!(psys->flag & PSYS_GLOBAL_HAIR)) { if (!(psys->flag & PSYS_GLOBAL_HAIR)) {
mul_m4_v3(hairmat, key->world_co); mul_m4_v3(hairmat, key->world_co);
@@ -1544,10 +1514,8 @@ static void update_velocities(PTCacheEdit *edit)
frs_sec = edit->pid.flag & PTCACHE_VEL_PER_SEC ? 25.0f : 1.0f; frs_sec = edit->pid.flag & PTCACHE_VEL_PER_SEC ? 25.0f : 1.0f;
LOOP_EDITED_POINTS LOOP_EDITED_POINTS {
{ LOOP_KEYS {
LOOP_KEYS
{
if (k == 0) { if (k == 0) {
dfra = *(key + 1)->time - *key->time; dfra = *(key + 1)->time - *key->time;
@@ -1608,8 +1576,7 @@ void PE_update_object(Depsgraph *depsgraph, Scene *scene, Object *ob, int usefla
/* flag all particles to be updated if not using flag */ /* flag all particles to be updated if not using flag */
if (!useflag) { if (!useflag) {
LOOP_POINTS LOOP_POINTS {
{
point->flag |= PEP_EDIT_RECALC; point->flag |= PEP_EDIT_RECALC;
} }
} }
@@ -1639,8 +1606,7 @@ void PE_update_object(Depsgraph *depsgraph, Scene *scene, Object *ob, int usefla
psys_cache_edit_paths(depsgraph, scene, ob, edit, CFRA, G.is_rendering); psys_cache_edit_paths(depsgraph, scene, ob, edit, CFRA, G.is_rendering);
/* disable update flag */ /* disable update flag */
LOOP_POINTS LOOP_POINTS {
{
point->flag &= ~PEP_EDIT_RECALC; point->flag &= ~PEP_EDIT_RECALC;
} }
@@ -1695,8 +1661,7 @@ static void select_keys(PEData *data,
PTCacheEditPoint *point = edit->points + point_index; PTCacheEditPoint *point = edit->points + point_index;
KEY_K; KEY_K;
LOOP_KEYS LOOP_KEYS {
{
if (data->select) { if (data->select) {
key->flag |= PEK_SELECT; key->flag |= PEK_SELECT;
} }
@@ -1796,10 +1761,8 @@ static int pe_select_all_exec(bContext *C, wmOperator *op)
if (action == SEL_TOGGLE) { if (action == SEL_TOGGLE) {
action = SEL_SELECT; action = SEL_SELECT;
LOOP_VISIBLE_POINTS LOOP_VISIBLE_POINTS {
{ LOOP_SELECTED_KEYS {
LOOP_SELECTED_KEYS
{
action = SEL_DESELECT; action = SEL_DESELECT;
break; break;
} }
@@ -1811,10 +1774,8 @@ static int pe_select_all_exec(bContext *C, wmOperator *op)
} }
bool changed = false; bool changed = false;
LOOP_VISIBLE_POINTS LOOP_VISIBLE_POINTS {
{ LOOP_VISIBLE_KEYS {
LOOP_VISIBLE_KEYS
{
changed |= select_action_apply(point, key, action); changed |= select_action_apply(point, key, action);
} }
} }
@@ -1859,10 +1820,8 @@ bool PE_mouse_particles(bContext *C, const int mval[2], bool extend, bool desele
} }
if (!extend && !deselect && !toggle) { if (!extend && !deselect && !toggle) {
LOOP_VISIBLE_POINTS LOOP_VISIBLE_POINTS {
{ LOOP_SELECTED_KEYS {
LOOP_SELECTED_KEYS
{
key->flag &= ~PEK_SELECT; key->flag &= ~PEK_SELECT;
point->flag |= PEP_EDIT_RECALC; point->flag |= PEP_EDIT_RECALC;
} }
@@ -2064,20 +2023,16 @@ static int select_random_exec(bContext *C, wmOperator *op)
switch (type) { switch (type) {
case RAN_HAIR: case RAN_HAIR:
LOOP_VISIBLE_POINTS LOOP_VISIBLE_POINTS {
{
int flag = ((BLI_rng_get_float(rng) < randfac) == select) ? SEL_SELECT : SEL_DESELECT; int flag = ((BLI_rng_get_float(rng) < randfac) == select) ? SEL_SELECT : SEL_DESELECT;
LOOP_KEYS LOOP_KEYS {
{
data.is_changed |= select_action_apply(point, key, flag); data.is_changed |= select_action_apply(point, key, flag);
} }
} }
break; break;
case RAN_POINTS: case RAN_POINTS:
LOOP_VISIBLE_POINTS LOOP_VISIBLE_POINTS {
{ LOOP_VISIBLE_KEYS {
LOOP_VISIBLE_KEYS
{
int flag = ((BLI_rng_get_float(rng) < randfac) == select) ? SEL_SELECT : SEL_DESELECT; int flag = ((BLI_rng_get_float(rng) < randfac) == select) ? SEL_SELECT : SEL_DESELECT;
data.is_changed |= select_action_apply(point, key, flag); data.is_changed |= select_action_apply(point, key, flag);
} }
@@ -2176,10 +2131,8 @@ bool PE_deselect_all_visible_ex(PTCacheEdit *edit)
POINT_P; POINT_P;
KEY_K; KEY_K;
LOOP_VISIBLE_POINTS LOOP_VISIBLE_POINTS {
{ LOOP_SELECTED_KEYS {
LOOP_SELECTED_KEYS
{
if ((key->flag & PEK_SELECT) != 0) { if ((key->flag & PEK_SELECT) != 0) {
key->flag &= ~PEK_SELECT; key->flag &= ~PEK_SELECT;
point->flag |= PEP_EDIT_RECALC; point->flag |= PEP_EDIT_RECALC;
@@ -2301,16 +2254,14 @@ int PE_lasso_select(bContext *C, const int mcords[][2], const short moves, const
data.is_changed |= PE_deselect_all_visible_ex(edit); data.is_changed |= PE_deselect_all_visible_ex(edit);
} }
LOOP_VISIBLE_POINTS LOOP_VISIBLE_POINTS {
{
if (edit->psys && !(psys->flag & PSYS_GLOBAL_HAIR)) { if (edit->psys && !(psys->flag & PSYS_GLOBAL_HAIR)) {
psys_mat_hair_to_global( psys_mat_hair_to_global(
ob, psmd_eval->mesh_final, psys->part->from, psys->particles + p, mat); ob, psmd_eval->mesh_final, psys->part->from, psys->particles + p, mat);
} }
if (pset->selectmode == SCE_SELECT_POINT) { if (pset->selectmode == SCE_SELECT_POINT) {
LOOP_VISIBLE_KEYS LOOP_VISIBLE_KEYS {
{
copy_v3_v3(co, key->co); copy_v3_v3(co, key->co);
mul_m4_v3(mat, co); mul_m4_v3(mat, co);
const bool is_select = key->flag & PEK_SELECT; const bool is_select = key->flag & PEK_SELECT;
@@ -2369,25 +2320,21 @@ static int hide_exec(bContext *C, wmOperator *op)
KEY_K; KEY_K;
if (RNA_boolean_get(op->ptr, "unselected")) { if (RNA_boolean_get(op->ptr, "unselected")) {
LOOP_UNSELECTED_POINTS LOOP_UNSELECTED_POINTS {
{
point->flag |= PEP_HIDE; point->flag |= PEP_HIDE;
point->flag |= PEP_EDIT_RECALC; point->flag |= PEP_EDIT_RECALC;
LOOP_KEYS LOOP_KEYS {
{
key->flag &= ~PEK_SELECT; key->flag &= ~PEK_SELECT;
} }
} }
} }
else { else {
LOOP_SELECTED_POINTS LOOP_SELECTED_POINTS {
{
point->flag |= PEP_HIDE; point->flag |= PEP_HIDE;
point->flag |= PEP_EDIT_RECALC; point->flag |= PEP_EDIT_RECALC;
LOOP_KEYS LOOP_KEYS {
{
key->flag &= ~PEK_SELECT; key->flag &= ~PEK_SELECT;
} }
} }
@@ -2429,14 +2376,12 @@ static int reveal_exec(bContext *C, wmOperator *op)
POINT_P; POINT_P;
KEY_K; KEY_K;
LOOP_POINTS LOOP_POINTS {
{
if (point->flag & PEP_HIDE) { if (point->flag & PEP_HIDE) {
point->flag &= ~PEP_HIDE; point->flag &= ~PEP_HIDE;
point->flag |= PEP_EDIT_RECALC; point->flag |= PEP_EDIT_RECALC;
LOOP_KEYS LOOP_KEYS {
{
SET_FLAG_FROM_TEST(key->flag, select, PEK_SELECT); SET_FLAG_FROM_TEST(key->flag, select, PEK_SELECT);
} }
} }
@@ -2474,8 +2419,7 @@ static void select_less_keys(PEData *data, int point_index)
PTCacheEditPoint *point = edit->points + point_index; PTCacheEditPoint *point = edit->points + point_index;
KEY_K; KEY_K;
LOOP_SELECTED_KEYS LOOP_SELECTED_KEYS {
{
if (k == 0) { if (k == 0) {
if (((key + 1)->flag & PEK_SELECT) == 0) { if (((key + 1)->flag & PEK_SELECT) == 0) {
key->flag |= PEK_TAG; key->flag |= PEK_TAG;
@@ -2493,8 +2437,7 @@ static void select_less_keys(PEData *data, int point_index)
} }
} }
LOOP_KEYS LOOP_KEYS {
{
if ((key->flag & PEK_TAG) && (key->flag & PEK_SELECT)) { if ((key->flag & PEK_TAG) && (key->flag & PEK_SELECT)) {
key->flag &= ~(PEK_TAG | PEK_SELECT); key->flag &= ~(PEK_TAG | PEK_SELECT);
point->flag |= PEP_EDIT_RECALC; /* redraw selection only */ point->flag |= PEP_EDIT_RECALC; /* redraw selection only */
@@ -2539,8 +2482,7 @@ static void select_more_keys(PEData *data, int point_index)
PTCacheEditPoint *point = edit->points + point_index; PTCacheEditPoint *point = edit->points + point_index;
KEY_K; KEY_K;
LOOP_KEYS LOOP_KEYS {
{
if (key->flag & PEK_SELECT) { if (key->flag & PEK_SELECT) {
continue; continue;
} }
@@ -2562,8 +2504,7 @@ static void select_more_keys(PEData *data, int point_index)
} }
} }
LOOP_KEYS LOOP_KEYS {
{
if ((key->flag & PEK_TAG) && (key->flag & PEK_SELECT) == 0) { if ((key->flag & PEK_TAG) && (key->flag & PEK_SELECT) == 0) {
key->flag &= ~PEK_TAG; key->flag &= ~PEK_TAG;
key->flag |= PEK_SELECT; key->flag |= PEK_SELECT;
@@ -2773,14 +2714,12 @@ static int remove_tagged_particles(Object *ob, ParticleSystem *psys, int mirror)
/* mirror tags */ /* mirror tags */
psmd_eval = edit->psmd_eval; psmd_eval = edit->psmd_eval;
LOOP_TAGGED_POINTS LOOP_TAGGED_POINTS {
{
PE_mirror_particle(ob, psmd_eval->mesh_final, psys, psys->particles + p, NULL); PE_mirror_particle(ob, psmd_eval->mesh_final, psys, psys->particles + p, NULL);
} }
} }
LOOP_TAGGED_POINTS LOOP_TAGGED_POINTS {
{
new_totpart--; new_totpart--;
removed++; removed++;
} }
@@ -2865,21 +2804,17 @@ static void remove_tagged_keys(Depsgraph *depsgraph, Object *ob, ParticleSystem
ParticleSystemModifierData *psmd_eval = (ParticleSystemModifierData *)modifier_get_evaluated( ParticleSystemModifierData *psmd_eval = (ParticleSystemModifierData *)modifier_get_evaluated(
depsgraph, ob, &psmd->modifier); depsgraph, ob, &psmd->modifier);
LOOP_POINTS LOOP_POINTS {
{ LOOP_TAGGED_KEYS {
LOOP_TAGGED_KEYS
{
PE_mirror_particle(ob, psmd_eval->mesh_final, psys, psys->particles + p, NULL); PE_mirror_particle(ob, psmd_eval->mesh_final, psys, psys->particles + p, NULL);
break; break;
} }
} }
} }
LOOP_POINTS LOOP_POINTS {
{
new_totkey = point->totkey; new_totkey = point->totkey;
LOOP_TAGGED_KEYS LOOP_TAGGED_KEYS {
{
new_totkey--; new_totkey--;
} }
/* we can't have elements with less than two keys*/ /* we can't have elements with less than two keys*/
@@ -2889,13 +2824,11 @@ static void remove_tagged_keys(Depsgraph *depsgraph, Object *ob, ParticleSystem
} }
remove_tagged_particles(ob, psys, pe_x_mirror(ob)); remove_tagged_particles(ob, psys, pe_x_mirror(ob));
LOOP_POINTS LOOP_POINTS {
{
pa = psys->particles + p; pa = psys->particles + p;
new_totkey = pa->totkey; new_totkey = pa->totkey;
LOOP_TAGGED_KEYS LOOP_TAGGED_KEYS {
{
new_totkey--; new_totkey--;
} }
@@ -2904,8 +2837,7 @@ static void remove_tagged_keys(Depsgraph *depsgraph, Object *ob, ParticleSystem
nkey = new_keys = MEM_callocN(new_totkey * sizeof(PTCacheEditKey), "particle edit keys"); nkey = new_keys = MEM_callocN(new_totkey * sizeof(PTCacheEditKey), "particle edit keys");
hkey = pa->hair; hkey = pa->hair;
LOOP_KEYS LOOP_KEYS {
{
while (key->flag & PEK_TAG && hkey < pa->hair + pa->totkey) { while (key->flag & PEK_TAG && hkey < pa->hair + pa->totkey) {
key++; key++;
hkey++; hkey++;
@@ -3103,8 +3035,7 @@ static int remove_doubles_exec(bContext *C, wmOperator *op)
tree = BLI_kdtree_3d_new(psys->totpart); tree = BLI_kdtree_3d_new(psys->totpart);
/* insert particles into kd tree */ /* insert particles into kd tree */
LOOP_SELECTED_POINTS LOOP_SELECTED_POINTS {
{
psys_mat_hair_to_object( psys_mat_hair_to_object(
ob, psmd_eval->mesh_final, psys->part->from, psys->particles + p, mat); ob, psmd_eval->mesh_final, psys->part->from, psys->particles + p, mat);
copy_v3_v3(co, point->keys->co); copy_v3_v3(co, point->keys->co);
@@ -3115,8 +3046,7 @@ static int remove_doubles_exec(bContext *C, wmOperator *op)
BLI_kdtree_3d_balance(tree); BLI_kdtree_3d_balance(tree);
/* tag particles to be removed */ /* tag particles to be removed */
LOOP_SELECTED_POINTS LOOP_SELECTED_POINTS {
{
psys_mat_hair_to_object( psys_mat_hair_to_object(
ob, psmd_eval->mesh_final, psys->part->from, psys->particles + p, mat); ob, psmd_eval->mesh_final, psys->part->from, psys->particles + p, mat);
copy_v3_v3(co, point->keys->co); copy_v3_v3(co, point->keys->co);
@@ -3198,12 +3128,10 @@ static int weight_set_exec(bContext *C, wmOperator *op)
weight = brush->strength; weight = brush->strength;
edit = psys->edit; edit = psys->edit;
LOOP_SELECTED_POINTS LOOP_SELECTED_POINTS {
{
ParticleData *pa = psys->particles + p; ParticleData *pa = psys->particles + p;
LOOP_SELECTED_KEYS LOOP_SELECTED_KEYS {
{
hkey = pa->hair + k; hkey = pa->hair + k;
hkey->weight = interpf(weight, hkey->weight, factor); hkey->weight = interpf(weight, hkey->weight, factor);
} }
@@ -3404,8 +3332,7 @@ static void PE_mirror_x(Depsgraph *depsgraph, Scene *scene, Object *ob, int tagg
totpart = psys->totpart; totpart = psys->totpart;
newtotpart = psys->totpart; newtotpart = psys->totpart;
LOOP_VISIBLE_POINTS LOOP_VISIBLE_POINTS {
{
pa = psys->particles + p; pa = psys->particles + p;
if (!tagged) { if (!tagged) {
@@ -3521,8 +3448,7 @@ static void PE_mirror_x(Depsgraph *depsgraph, Scene *scene, Object *ob, int tagg
} }
} }
LOOP_POINTS LOOP_POINTS {
{
point->flag &= ~PEP_TAG; point->flag &= ~PEP_TAG;
} }
@@ -3703,8 +3629,7 @@ static void brush_length(PEData *data, int point_index, float UNUSED(mouse_dista
KEY_K; KEY_K;
float dvec[3], pvec[3] = {0.0f, 0.0f, 0.0f}; float dvec[3], pvec[3] = {0.0f, 0.0f, 0.0f};
LOOP_KEYS LOOP_KEYS {
{
if (k == 0) { if (k == 0) {
copy_v3_v3(pvec, key->co); copy_v3_v3(pvec, key->co);
} }
@@ -3753,8 +3678,7 @@ static void brush_puff(PEData *data, int point_index, float mouse_distance)
unit_m4(imat); unit_m4(imat);
} }
LOOP_KEYS LOOP_KEYS {
{
float kco[3]; float kco[3];
if (k == 0) { if (k == 0) {
@@ -5121,15 +5045,13 @@ int PE_minmax(
unit_m4(mat); unit_m4(mat);
} }
LOOP_VISIBLE_POINTS LOOP_VISIBLE_POINTS {
{
if (psys) { if (psys) {
psys_mat_hair_to_global( psys_mat_hair_to_global(
ob, psmd_eval->mesh_final, psys->part->from, psys->particles + p, mat); ob, psmd_eval->mesh_final, psys->part->from, psys->particles + p, mat);
} }
LOOP_SELECTED_KEYS LOOP_SELECTED_KEYS {
{
copy_v3_v3(co, key->co); copy_v3_v3(co, key->co);
mul_m4_v3(mat, co); mul_m4_v3(mat, co);
DO_MINMAX(co, min, max); DO_MINMAX(co, min, max);
@@ -5206,15 +5128,13 @@ void PE_create_particle_edit(
BLI_listbase_clear(&edit->pathcachebufs); BLI_listbase_clear(&edit->pathcachebufs);
pa = psys->particles; pa = psys->particles;
LOOP_POINTS LOOP_POINTS {
{
point->totkey = pa->totkey; point->totkey = pa->totkey;
point->keys = MEM_callocN(point->totkey * sizeof(PTCacheEditKey), "ParticleEditKeys"); point->keys = MEM_callocN(point->totkey * sizeof(PTCacheEditKey), "ParticleEditKeys");
point->flag |= PEP_EDIT_RECALC; point->flag |= PEP_EDIT_RECALC;
hkey = pa->hair; hkey = pa->hair;
LOOP_KEYS LOOP_KEYS {
{
key->co = hkey->co; key->co = hkey->co;
key->time = &hkey->time; key->time = &hkey->time;
key->flag = hkey->editflag; key->flag = hkey->editflag;
@@ -5242,8 +5162,7 @@ void PE_create_particle_edit(
} }
for (pm = cache->mem_cache.first; pm; pm = pm->next) { for (pm = cache->mem_cache.first; pm; pm = pm->next) {
LOOP_POINTS LOOP_POINTS {
{
if (BKE_ptcache_mem_pointers_seek(p, pm) == 0) { if (BKE_ptcache_mem_pointers_seek(p, pm) == 0) {
continue; continue;
} }
@@ -5446,8 +5365,7 @@ static float calculate_point_length(PTCacheEditPoint *point)
{ {
float length = 0.0f; float length = 0.0f;
KEY_K; KEY_K;
LOOP_KEYS LOOP_KEYS {
{
if (k > 0) { if (k > 0) {
length += len_v3v3((key - 1)->co, key->co); length += len_v3v3((key - 1)->co, key->co);
} }
@@ -5460,8 +5378,7 @@ static float calculate_average_length(PTCacheEdit *edit)
int num_selected = 0; int num_selected = 0;
float total_length = 0; float total_length = 0;
POINT_P; POINT_P;
LOOP_SELECTED_POINTS LOOP_SELECTED_POINTS {
{
total_length += calculate_point_length(point); total_length += calculate_point_length(point);
num_selected++; num_selected++;
} }
@@ -5475,8 +5392,7 @@ static void scale_point_factor(PTCacheEditPoint *point, float factor)
{ {
float orig_prev_co[3], prev_co[3]; float orig_prev_co[3], prev_co[3];
KEY_K; KEY_K;
LOOP_KEYS LOOP_KEYS {
{
if (k == 0) { if (k == 0) {
copy_v3_v3(orig_prev_co, key->co); copy_v3_v3(orig_prev_co, key->co);
copy_v3_v3(prev_co, key->co); copy_v3_v3(prev_co, key->co);
@@ -5509,8 +5425,7 @@ static void scale_point_to_length(PTCacheEditPoint *point, float length)
static void scale_points_to_length(PTCacheEdit *edit, float length) static void scale_points_to_length(PTCacheEdit *edit, float length)
{ {
POINT_P; POINT_P;
LOOP_SELECTED_POINTS LOOP_SELECTED_POINTS {
{
scale_point_to_length(point, length); scale_point_to_length(point, length);
} }
recalc_lengths(edit); recalc_lengths(edit);

View File

@@ -109,8 +109,7 @@ static void undoptcache_to_editcache(PTCacheUndo *undo, PTCacheEdit *edit)
POINT_P; POINT_P;
KEY_K; KEY_K;
LOOP_POINTS LOOP_POINTS {
{
if (psys && psys->particles[p].hair) { if (psys && psys->particles[p].hair) {
MEM_freeN(psys->particles[p].hair); MEM_freeN(psys->particles[p].hair);
} }
@@ -133,8 +132,7 @@ static void undoptcache_to_editcache(PTCacheUndo *undo, PTCacheEdit *edit)
edit->points = MEM_dupallocN(undo->points); edit->points = MEM_dupallocN(undo->points);
edit->totpoint = undo->totpoint; edit->totpoint = undo->totpoint;
LOOP_POINTS LOOP_POINTS {
{
point->keys = MEM_dupallocN(point->keys); point->keys = MEM_dupallocN(point->keys);
} }
@@ -143,13 +141,11 @@ static void undoptcache_to_editcache(PTCacheUndo *undo, PTCacheEdit *edit)
psys->totpart = undo->totpoint; psys->totpart = undo->totpoint;
LOOP_POINTS LOOP_POINTS {
{
pa = psys->particles + p; pa = psys->particles + p;
hkey = pa->hair = MEM_dupallocN(pa->hair); hkey = pa->hair = MEM_dupallocN(pa->hair);
LOOP_KEYS LOOP_KEYS {
{
key->co = hkey->co; key->co = hkey->co;
key->time = &hkey->time; key->time = &hkey->time;
hkey++; hkey++;
@@ -174,10 +170,8 @@ static void undoptcache_to_editcache(PTCacheUndo *undo, PTCacheEdit *edit)
} }
BKE_ptcache_mem_pointers_init(pm); BKE_ptcache_mem_pointers_init(pm);
LOOP_POINTS LOOP_POINTS {
{ LOOP_KEYS {
LOOP_KEYS
{
if ((int)key->ftime == (int)pm->frame) { if ((int)key->ftime == (int)pm->frame) {
key->co = pm->cur[BPHYS_DATA_LOCATION]; key->co = pm->cur[BPHYS_DATA_LOCATION];
key->vel = pm->cur[BPHYS_DATA_VELOCITY]; key->vel = pm->cur[BPHYS_DATA_VELOCITY];

View File

@@ -1017,13 +1017,11 @@ static void copy_particle_edit(Depsgraph *depsgraph,
edit->points = MEM_dupallocN(edit_from->points); edit->points = MEM_dupallocN(edit_from->points);
pa = psys->particles; pa = psys->particles;
LOOP_POINTS LOOP_POINTS {
{
HairKey *hkey = pa->hair; HairKey *hkey = pa->hair;
point->keys = MEM_dupallocN(point->keys); point->keys = MEM_dupallocN(point->keys);
LOOP_KEYS LOOP_KEYS {
{
key->co = hkey->co; key->co = hkey->co;
key->time = &hkey->time; key->time = &hkey->time;
key->flag = hkey->editflag; key->flag = hkey->editflag;