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-22 02:19:45 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-04-22 12:48:16 +0300
commit620b960d3d8cfd90b9f0df6ba3671c33eccb8309 (patch)
tree64f69db4bf9d44f0a32d1c92b0714bf2dc98ff2d /source/blender/editors/physics
parentbba60bb564cf5a16cfcac744d4ba82cf8eba3da9 (diff)
Cleanup: style, use braces for editors
Diffstat (limited to 'source/blender/editors/physics')
-rw-r--r--source/blender/editors/physics/dynamicpaint_ops.c33
-rw-r--r--source/blender/editors/physics/particle_boids.c36
-rw-r--r--source/blender/editors/physics/particle_edit.c506
-rw-r--r--source/blender/editors/physics/particle_object.c138
-rw-r--r--source/blender/editors/physics/physics_fluid.c72
-rw-r--r--source/blender/editors/physics/rigidbody_constraint.c3
-rw-r--r--source/blender/editors/physics/rigidbody_object.c9
-rw-r--r--source/blender/editors/physics/rigidbody_world.c6
8 files changed, 535 insertions, 268 deletions
diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c
index e0ea53b06ec..7178a485a6e 100644
--- a/source/blender/editors/physics/dynamicpaint_ops.c
+++ b/source/blender/editors/physics/dynamicpaint_ops.c
@@ -72,14 +72,16 @@ static int surface_slot_add_exec(bContext *C, wmOperator *UNUSED(op))
/* Make sure we're dealing with a canvas */
pmd = (DynamicPaintModifierData *)modifiers_findByType(cObject, eModifierType_DynamicPaint);
- if (!pmd || !pmd->canvas)
+ if (!pmd || !pmd->canvas) {
return OPERATOR_CANCELLED;
+ }
canvas = pmd->canvas;
surface = dynamicPaint_createNewSurface(canvas, CTX_data_scene(C));
- if (!surface)
+ if (!surface) {
return OPERATOR_CANCELLED;
+ }
/* set preview for this surface only and set active */
canvas->active_sur = 0;
@@ -117,8 +119,9 @@ static int surface_slot_remove_exec(bContext *C, wmOperator *UNUSED(op))
/* Make sure we're dealing with a canvas */
pmd = (DynamicPaintModifierData *)modifiers_findByType(obj_ctx, eModifierType_DynamicPaint);
- if (!pmd || !pmd->canvas)
+ if (!pmd || !pmd->canvas) {
return OPERATOR_CANCELLED;
+ }
canvas = pmd->canvas;
surface = canvas->surfaces.first;
@@ -165,8 +168,9 @@ static int type_toggle_exec(bContext *C, wmOperator *op)
cObject, eModifierType_DynamicPaint);
int type = RNA_enum_get(op->ptr, "type");
- if (!pmd)
+ if (!pmd) {
return OPERATOR_CANCELLED;
+ }
/* if type is already enabled, toggle it off */
if (type == MOD_DYNAMICPAINT_TYPE_CANVAS && pmd->canvas) {
@@ -177,8 +181,9 @@ static int type_toggle_exec(bContext *C, wmOperator *op)
}
/* else create a new type */
else {
- if (!dynamicPaint_createType(pmd, type, scene))
+ if (!dynamicPaint_createType(pmd, type, scene)) {
return OPERATOR_CANCELLED;
+ }
}
/* update dependency */
@@ -223,8 +228,9 @@ static int output_toggle_exec(bContext *C, wmOperator *op)
ob, eModifierType_DynamicPaint);
int output = RNA_enum_get(op->ptr, "output"); /* currently only 1/0 */
- if (!pmd || !pmd->canvas)
+ if (!pmd || !pmd->canvas) {
return OPERATOR_CANCELLED;
+ }
surface = get_activeSurface(pmd->canvas);
/* if type is already enabled, toggle it off */
@@ -232,17 +238,21 @@ static int output_toggle_exec(bContext *C, wmOperator *op)
int exists = dynamicPaint_outputLayerExists(surface, ob, output);
const char *name;
- if (output == 0)
+ if (output == 0) {
name = surface->output_name;
- else
+ }
+ else {
name = surface->output_name2;
+ }
/* Vertex Color Layer */
if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) {
- if (!exists)
+ if (!exists) {
ED_mesh_color_add(ob->data, name, true, true);
- else
+ }
+ else {
ED_mesh_color_remove_named(ob->data, name);
+ }
}
/* Vertex Weight Layer */
else if (surface->type == MOD_DPAINT_SURFACE_T_WEIGHT) {
@@ -251,8 +261,9 @@ static int output_toggle_exec(bContext *C, wmOperator *op)
}
else {
bDeformGroup *defgroup = defgroup_find_name(ob, name);
- if (defgroup)
+ if (defgroup) {
BKE_object_defgroup_remove(ob, defgroup);
+ }
}
}
}
diff --git a/source/blender/editors/physics/particle_boids.c b/source/blender/editors/physics/particle_boids.c
index cedb7d6cbc1..55fc49165c9 100644
--- a/source/blender/editors/physics/particle_boids.c
+++ b/source/blender/editors/physics/particle_boids.c
@@ -57,13 +57,15 @@ static int rule_add_exec(bContext *C, wmOperator *op)
BoidRule *rule;
BoidState *state;
- if (!part || part->phystype != PART_PHYS_BOIDS)
+ if (!part || part->phystype != PART_PHYS_BOIDS) {
return OPERATOR_CANCELLED;
+ }
state = boid_get_current_state(part->boids);
- for (rule = state->rules.first; rule; rule = rule->next)
+ for (rule = state->rules.first; rule; rule = rule->next) {
rule->flag &= ~BOIDRULE_CURRENT;
+ }
rule = boid_new_rule(type);
rule->flag |= BOIDRULE_CURRENT;
@@ -99,8 +101,9 @@ static int rule_del_exec(bContext *C, wmOperator *UNUSED(op))
BoidRule *rule;
BoidState *state;
- if (!part || part->phystype != PART_PHYS_BOIDS)
+ if (!part || part->phystype != PART_PHYS_BOIDS) {
return OPERATOR_CANCELLED;
+ }
state = boid_get_current_state(part->boids);
@@ -113,8 +116,9 @@ static int rule_del_exec(bContext *C, wmOperator *UNUSED(op))
}
rule = state->rules.first;
- if (rule)
+ if (rule) {
rule->flag |= BOIDRULE_CURRENT;
+ }
DEG_relations_tag_update(bmain);
DEG_id_tag_update(&part->id, ID_RECALC_GEOMETRY | ID_RECALC_PSYS_RESET);
@@ -144,8 +148,9 @@ static int rule_move_up_exec(bContext *C, wmOperator *UNUSED(op))
BoidRule *rule;
BoidState *state;
- if (!part || part->phystype != PART_PHYS_BOIDS)
+ if (!part || part->phystype != PART_PHYS_BOIDS) {
return OPERATOR_CANCELLED;
+ }
state = boid_get_current_state(part->boids);
for (rule = state->rules.first; rule; rule = rule->next) {
@@ -180,8 +185,9 @@ static int rule_move_down_exec(bContext *C, wmOperator *UNUSED(op))
BoidRule *rule;
BoidState *state;
- if (!part || part->phystype != PART_PHYS_BOIDS)
+ if (!part || part->phystype != PART_PHYS_BOIDS) {
return OPERATOR_CANCELLED;
+ }
state = boid_get_current_state(part->boids);
for (rule = state->rules.first; rule; rule = rule->next) {
@@ -216,11 +222,13 @@ static int state_add_exec(bContext *C, wmOperator *UNUSED(op))
ParticleSettings *part = ptr.data;
BoidState *state;
- if (!part || part->phystype != PART_PHYS_BOIDS)
+ if (!part || part->phystype != PART_PHYS_BOIDS) {
return OPERATOR_CANCELLED;
+ }
- for (state = part->boids->states.first; state; state = state->next)
+ for (state = part->boids->states.first; state; state = state->next) {
state->flag &= ~BOIDSTATE_CURRENT;
+ }
state = boid_new_state(part->boids);
state->flag |= BOIDSTATE_CURRENT;
@@ -250,8 +258,9 @@ static int state_del_exec(bContext *C, wmOperator *UNUSED(op))
ParticleSettings *part = ptr.data;
BoidState *state;
- if (!part || part->phystype != PART_PHYS_BOIDS)
+ if (!part || part->phystype != PART_PHYS_BOIDS) {
return OPERATOR_CANCELLED;
+ }
for (state = part->boids->states.first; state; state = state->next) {
if (state->flag & BOIDSTATE_CURRENT) {
@@ -266,8 +275,9 @@ static int state_del_exec(bContext *C, wmOperator *UNUSED(op))
state = boid_new_state(part->boids);
BLI_addtail(&part->boids->states, state);
}
- else
+ else {
state = part->boids->states.first;
+ }
state->flag |= BOIDSTATE_CURRENT;
@@ -299,8 +309,9 @@ static int state_move_up_exec(bContext *C, wmOperator *UNUSED(op))
BoidSettings *boids;
BoidState *state;
- if (!part || part->phystype != PART_PHYS_BOIDS)
+ if (!part || part->phystype != PART_PHYS_BOIDS) {
return OPERATOR_CANCELLED;
+ }
boids = part->boids;
@@ -334,8 +345,9 @@ static int state_move_down_exec(bContext *C, wmOperator *UNUSED(op))
BoidSettings *boids;
BoidState *state;
- if (!part || part->phystype != PART_PHYS_BOIDS)
+ if (!part || part->phystype != PART_PHYS_BOIDS) {
return OPERATOR_CANCELLED;
+ }
boids = part->boids;
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index 68bbda51482..9921ca02af9 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -129,21 +129,24 @@ void PE_free_ptcache_edit(PTCacheEdit *edit)
{
POINT_P;
- if (edit == 0)
+ if (edit == 0) {
return;
+ }
if (edit->points) {
LOOP_POINTS
{
- if (point->keys)
+ if (point->keys) {
MEM_freeN(point->keys);
+ }
}
MEM_freeN(edit->points);
}
- if (edit->mirror_cache)
+ if (edit->mirror_cache) {
MEM_freeN(edit->mirror_cache);
+ }
if (edit->emitter_cosnos) {
MEM_freeN(edit->emitter_cosnos);
@@ -168,8 +171,9 @@ int PE_start_edit(PTCacheEdit *edit)
{
if (edit) {
edit->edited = 1;
- if (edit->psys)
+ if (edit->psys) {
edit->psys->flag |= PSYS_EDITED;
+ }
return 1;
}
@@ -242,8 +246,9 @@ static PTCacheEdit *pe_get_current(Depsgraph *depsgraph, Scene *scene, Object *o
ListBase pidlist;
PTCacheID *pid;
- if (pset == NULL || ob == NULL)
+ if (pset == NULL || ob == NULL) {
return NULL;
+ }
pset->scene = scene;
pset->object = ob;
@@ -273,8 +278,9 @@ static PTCacheEdit *pe_get_current(Depsgraph *depsgraph, Scene *scene, Object *o
if (psys->flag & PSYS_CURRENT) {
if (psys->part && psys->part->type == PART_HAIR) {
if (psys->flag & PSYS_HAIR_DYNAMICS && psys->pointcache->flag & PTCACHE_BAKED) {
- if (create && !psys->pointcache->edit)
+ if (create && !psys->pointcache->edit) {
PE_create_particle_edit(depsgraph, scene, ob, pid->cache, NULL);
+ }
edit = pid->cache->edit;
}
else {
@@ -287,8 +293,9 @@ static PTCacheEdit *pe_get_current(Depsgraph *depsgraph, Scene *scene, Object *o
}
}
else {
- if (create && pid->cache->flag & PTCACHE_BAKED && !pid->cache->edit)
+ if (create && pid->cache->flag & PTCACHE_BAKED && !pid->cache->edit) {
PE_create_particle_edit(depsgraph, scene, ob, pid->cache, psys);
+ }
edit = pid->cache->edit;
}
@@ -359,8 +366,9 @@ void PE_hide_keys_time(Scene *scene, PTCacheEdit *edit, float cfra)
{
LOOP_KEYS
{
- if (fabsf(cfra - *key->time) < pset->fade_frames)
+ if (fabsf(cfra - *key->time) < pset->fade_frames) {
key->flag &= ~PEK_HIDE;
+ }
else {
key->flag |= PEK_HIDE;
//key->flag &= ~PEK_SELECT;
@@ -381,8 +389,9 @@ void PE_hide_keys_time(Scene *scene, PTCacheEdit *edit, float cfra)
static int pe_x_mirror(Object *ob)
{
- if (ob->type == OB_MESH)
+ if (ob->type == OB_MESH) {
return (((Mesh *)ob->data)->editflag & ME_EDIT_MIRROR_X);
+ }
return 0;
}
@@ -505,10 +514,11 @@ static bool key_test_depth(const PEData *data, const float co[3], const int scre
float depth;
/* nothing to do */
- if (XRAY_ENABLED(v3d))
+ if (XRAY_ENABLED(v3d)) {
return true;
+ }
- /* used to calculate here but all callers have the screen_co already, so pass as arg */
+ /* used to calculate here but all callers have the screen_co already, so pass as arg */
#if 0
if (ED_view3d_project_int_global(data->vc.ar,
co,
@@ -525,16 +535,19 @@ static bool key_test_depth(const PEData *data, const float co[3], const int scre
/* we know its not clipped */
depth = vd->depths[screen_co[1] * vd->w + screen_co[0]];
}
- else
+ else {
return 0;
+ }
float win[3];
ED_view3d_project(data->vc.ar, co, win);
- if (win[2] - 0.00001f > depth)
+ if (win[2] - 0.00001f > depth) {
return 0;
- else
+ }
+ else {
return 1;
+ }
}
static bool key_inside_circle(const PEData *data, float rad, const float co[3], float *distance)
@@ -552,12 +565,14 @@ static bool key_inside_circle(const PEData *data, float rad, const float co[3],
dy = data->mval[1] - screen_co[1];
dist = sqrtf(dx * dx + dy * dy);
- if (dist > rad)
+ if (dist > rad) {
return 0;
+ }
if (key_test_depth(data, co, screen_co)) {
- if (distance)
+ if (distance) {
*distance = dist;
+ }
return 1;
}
@@ -584,18 +599,21 @@ static bool key_inside_rect(PEData *data, const float co[3])
static bool key_inside_test(PEData *data, const float co[3])
{
- if (data->mval)
+ if (data->mval) {
return key_inside_circle(data, data->rad, co, NULL);
- else
+ }
+ else {
return key_inside_rect(data, co);
+ }
}
static bool point_is_selected(PTCacheEditPoint *point)
{
KEY_K;
- if (point->flag & PEP_HIDE)
+ if (point->flag & PEP_HIDE) {
return 0;
+ }
LOOP_SELECTED_KEYS
{
@@ -641,8 +659,9 @@ static void for_mouse_hit_keys(PEData *data, ForKeyFunc func, const enum ePartic
float dist = data->rad;
/* in path select mode we have no keys */
- if (pset->selectmode == SCE_SELECT_PATH)
+ if (pset->selectmode == SCE_SELECT_PATH) {
return;
+ }
nearest_point = -1;
nearest_key = -1;
@@ -704,8 +723,9 @@ static void foreach_mouse_hit_point(PEData *data, ForHitPointFunc func, int sele
KEY_K;
/* all is selected in path mode */
- if (pset->selectmode == SCE_SELECT_PATH)
+ if (pset->selectmode == SCE_SELECT_PATH) {
selected = 0;
+ }
LOOP_VISIBLE_POINTS
{
@@ -878,8 +898,9 @@ static int count_selected_keys(Scene *scene, PTCacheEdit *edit)
else if (pset->selectmode == SCE_SELECT_END) {
if (point->totkey) {
key = point->keys + point->totkey - 1;
- if (key->flag & PEK_SELECT)
+ if (key->flag & PEK_SELECT) {
sel++;
+ }
}
}
}
@@ -906,8 +927,9 @@ static void PE_update_mirror_cache(Object *ob, ParticleSystem *psys)
psmd_eval = edit->psmd_eval;
totpart = psys->totpart;
- if (!psmd_eval->mesh_final)
+ if (!psmd_eval->mesh_final) {
return;
+ }
tree = BLI_kdtree_3d_new(totpart);
@@ -924,8 +946,9 @@ static void PE_update_mirror_cache(Object *ob, ParticleSystem *psys)
BLI_kdtree_3d_balance(tree);
/* lookup particles and set in mirror cache */
- if (!edit->mirror_cache)
+ if (!edit->mirror_cache) {
edit->mirror_cache = MEM_callocN(sizeof(int) * totpart, "PE mirror cache");
+ }
LOOP_PARTICLES
{
@@ -938,10 +961,12 @@ static void PE_update_mirror_cache(Object *ob, ParticleSystem *psys)
index = BLI_kdtree_3d_find_nearest(tree, co, &nearest);
/* this needs a custom threshold still, duplicated for editmode mirror */
- if (index != -1 && index != p && (nearest.dist <= 0.0002f))
+ if (index != -1 && index != p && (nearest.dist <= 0.0002f)) {
edit->mirror_cache[p] = index;
- else
+ }
+ else {
edit->mirror_cache[p] = -1;
+ }
}
/* make sure mirrors are in two directions */
@@ -949,8 +974,9 @@ static void PE_update_mirror_cache(Object *ob, ParticleSystem *psys)
{
if (edit->mirror_cache[p]) {
index = edit->mirror_cache[p];
- if (edit->mirror_cache[index] != p)
+ if (edit->mirror_cache[index] != p) {
edit->mirror_cache[p] = -1;
+ }
}
}
@@ -972,29 +998,35 @@ static void PE_mirror_particle(
/* find mirrored particle if needed */
if (!mpa) {
- if (!edit->mirror_cache)
+ if (!edit->mirror_cache) {
PE_update_mirror_cache(ob, psys);
+ }
- if (!edit->mirror_cache)
+ if (!edit->mirror_cache) {
return; /* something went wrong! */
+ }
mi = edit->mirror_cache[i];
- if (mi == -1)
+ if (mi == -1) {
return;
+ }
mpa = psys->particles + mi;
}
- else
+ else {
mi = mpa - psys->particles;
+ }
point = edit->points + i;
mpoint = edit->points + mi;
/* make sure they have the same amount of keys */
if (pa->totkey != mpa->totkey) {
- if (mpa->hair)
+ if (mpa->hair) {
MEM_freeN(mpa->hair);
- if (mpoint->keys)
+ }
+ if (mpoint->keys) {
MEM_freeN(mpoint->keys);
+ }
mpa->hair = MEM_dupallocN(pa->hair);
mpa->totkey = pa->totkey;
@@ -1025,16 +1057,19 @@ static void PE_mirror_particle(
mhkey->co[0] = -mhkey->co[0];
mul_m4_v3(immat, mhkey->co);
- if (key->flag & PEK_TAG)
+ if (key->flag & PEK_TAG) {
mkey->flag |= PEK_TAG;
+ }
mkey->length = key->length;
}
- if (point->flag & PEP_TAG)
+ if (point->flag & PEP_TAG) {
mpoint->flag |= PEP_TAG;
- if (point->flag & PEP_EDIT_RECALC)
+ }
+ if (point->flag & PEP_EDIT_RECALC) {
mpoint->flag |= PEP_EDIT_RECALC;
+ }
}
static void PE_apply_mirror(Object *ob, ParticleSystem *psys)
@@ -1043,20 +1078,24 @@ static void PE_apply_mirror(Object *ob, ParticleSystem *psys)
ParticleSystemModifierData *psmd_eval;
POINT_P;
- if (!psys)
+ if (!psys) {
return;
+ }
edit = psys->edit;
psmd_eval = edit->psmd_eval;
- if (!psmd_eval->mesh_final)
+ if (!psmd_eval->mesh_final) {
return;
+ }
- if (!edit->mirror_cache)
+ if (!edit->mirror_cache) {
PE_update_mirror_cache(ob, psys);
+ }
- if (!edit->mirror_cache)
+ if (!edit->mirror_cache) {
return; /* something went wrong */
+ }
/* we delay settings the PARS_EDIT_RECALC for mirrored particles
* to avoid doing mirror twice */
@@ -1065,16 +1104,19 @@ static void PE_apply_mirror(Object *ob, ParticleSystem *psys)
if (point->flag & PEP_EDIT_RECALC) {
PE_mirror_particle(ob, psmd_eval->mesh_final, psys, psys->particles + p, NULL);
- if (edit->mirror_cache[p] != -1)
+ if (edit->mirror_cache[p] != -1) {
edit->points[edit->mirror_cache[p]].flag &= ~PEP_EDIT_RECALC;
+ }
}
}
LOOP_POINTS
{
- if (point->flag & PEP_EDIT_RECALC)
- if (edit->mirror_cache[p] != -1)
+ if (point->flag & PEP_EDIT_RECALC) {
+ if (edit->mirror_cache[p] != -1) {
edit->points[edit->mirror_cache[p]].flag |= PEP_EDIT_RECALC;
+ }
+ }
}
}
@@ -1225,11 +1267,13 @@ static void PE_apply_lengths(Scene *scene, PTCacheEdit *edit)
{
ParticleEditSettings *pset = PE_settings(scene);
- if (edit == 0 || (pset->flag & PE_KEEP_LENGTHS) == 0)
+ if (edit == 0 || (pset->flag & PE_KEEP_LENGTHS) == 0) {
return;
+ }
- if (edit->psys && edit->psys->flag & PSYS_GLOBAL_HAIR)
+ if (edit->psys && edit->psys->flag & PSYS_GLOBAL_HAIR) {
return;
+ }
ApplyLengthsIterData iter_data;
iter_data.edit = edit;
@@ -1321,8 +1365,9 @@ void recalc_lengths(PTCacheEdit *edit)
POINT_P;
KEY_K;
- if (edit == 0)
+ if (edit == 0) {
return;
+ }
LOOP_EDITED_POINTS
{
@@ -1341,11 +1386,13 @@ void recalc_emitter_field(Depsgraph *UNUSED(depsgraph), Object *UNUSED(ob), Part
float *vec, *nor;
int i, totface /*, totvert*/;
- if (!mesh)
+ if (!mesh) {
return;
+ }
- if (edit->emitter_cosnos)
+ if (edit->emitter_cosnos) {
MEM_freeN(edit->emitter_cosnos);
+ }
BLI_kdtree_3d_free(edit->emitter_field);
@@ -1402,11 +1449,12 @@ static void PE_update_selection(Depsgraph *depsgraph, Scene *scene, Object *ob,
KEY_K;
/* flag all particles to be updated if not using flag */
- if (!useflag)
+ if (!useflag) {
LOOP_POINTS
{
point->flag |= PEP_EDIT_RECALC;
}
+ }
/* flush edit key flag to hair key flag to preserve selection
* on save */
@@ -1441,20 +1489,23 @@ void update_world_cos(Depsgraph *UNUSED(depsgraph), Object *ob, PTCacheEdit *edi
KEY_K;
float hairmat[4][4];
- if (psys == 0 || psys->edit == 0 || psmd_eval->mesh_final == NULL)
+ if (psys == 0 || psys->edit == 0 || psmd_eval->mesh_final == NULL) {
return;
+ }
LOOP_POINTS
{
- if (!(psys->flag & PSYS_GLOBAL_HAIR))
+ if (!(psys->flag & PSYS_GLOBAL_HAIR)) {
psys_mat_hair_to_global(
ob, psmd_eval->mesh_final, psys->part->from, psys->particles + p, hairmat);
+ }
LOOP_KEYS
{
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);
+ }
}
}
}
@@ -1466,8 +1517,9 @@ static void update_velocities(PTCacheEdit *edit)
KEY_K;
/* hair doesn't use velocities */
- if (edit->psys || !edit->points || !edit->points->keys->vel)
+ if (edit->psys || !edit->points || !edit->points->keys->vel) {
return;
+ }
frs_sec = edit->pid.flag & PTCACHE_VEL_PER_SEC ? 25.0f : 1.0f;
@@ -1478,8 +1530,9 @@ static void update_velocities(PTCacheEdit *edit)
if (k == 0) {
dfra = *(key + 1)->time - *key->time;
- if (dfra <= 0.0f)
+ if (dfra <= 0.0f) {
continue;
+ }
sub_v3_v3v3(key->vel, (key + 1)->co, key->co);
@@ -1493,8 +1546,9 @@ static void update_velocities(PTCacheEdit *edit)
else if (k == point->totkey - 1) {
dfra = *key->time - *(key - 1)->time;
- if (dfra <= 0.0f)
+ if (dfra <= 0.0f) {
continue;
+ }
sub_v3_v3v3(key->vel, key->co, (key - 1)->co);
@@ -1508,8 +1562,9 @@ static void update_velocities(PTCacheEdit *edit)
else {
dfra = *(key + 1)->time - *(key - 1)->time;
- if (dfra <= 0.0f)
+ if (dfra <= 0.0f) {
continue;
+ }
sub_v3_v3v3(key->vel, (key + 1)->co, (key - 1)->co);
}
@@ -1526,26 +1581,31 @@ void PE_update_object(Depsgraph *depsgraph, Scene *scene, Object *ob, int usefla
PTCacheEdit *edit = PE_get_current(scene, ob);
POINT_P;
- if (!edit)
+ if (!edit) {
return;
+ }
/* flag all particles to be updated if not using flag */
- if (!useflag)
+ if (!useflag) {
LOOP_POINTS
{
point->flag |= PEP_EDIT_RECALC;
}
+ }
/* do post process on particle edit keys */
pe_iterate_lengths(scene, edit);
pe_deflect_emitter(scene, ob, edit);
PE_apply_lengths(scene, edit);
- if (pe_x_mirror(ob))
+ if (pe_x_mirror(ob)) {
PE_apply_mirror(ob, edit->psys);
- if (edit->psys)
+ }
+ if (edit->psys) {
update_world_cos(depsgraph, ob, edit);
- if (pset->flag & PE_AUTO_VELOCITY)
+ }
+ if (pset->flag & PE_AUTO_VELOCITY) {
update_velocities(edit);
+ }
PE_hide_keys_time(scene, edit, CFRA);
/* regenerate path caches */
@@ -1557,8 +1617,9 @@ void PE_update_object(Depsgraph *depsgraph, Scene *scene, Object *ob, int usefla
point->flag &= ~PEP_EDIT_RECALC;
}
- if (edit->psys)
+ if (edit->psys) {
edit->psys->flag &= ~PSYS_HAIR_UPDATED;
+ }
}
/************************************************/
@@ -1573,10 +1634,12 @@ static void select_key(PEData *data, int point_index, int key_index, bool UNUSED
PTCacheEditPoint *point = edit->points + point_index;
PTCacheEditKey *key = point->keys + key_index;
- if (data->select)
+ if (data->select) {
key->flag |= PEK_SELECT;
- else
+ }
+ else {
key->flag &= ~PEK_SELECT;
+ }
point->flag |= PEP_EDIT_RECALC;
data->is_changed = true;
@@ -1607,10 +1670,12 @@ static void select_keys(PEData *data,
LOOP_KEYS
{
- if (data->select)
+ if (data->select) {
key->flag |= PEK_SELECT;
- else
+ }
+ else {
key->flag &= ~PEK_SELECT;
+ }
}
point->flag |= PEP_EDIT_RECALC;
@@ -1712,8 +1777,9 @@ static int pe_select_all_exec(bContext *C, wmOperator *op)
break;
}
- if (action == SEL_DESELECT)
+ if (action == SEL_DESELECT) {
break;
+ }
}
}
@@ -1806,8 +1872,9 @@ static void select_root(PEData *data, int point_index)
PTCacheEditPoint *point = data->edit->points + point_index;
PTCacheEditKey *key = point->keys;
- if (point->flag & PEP_HIDE)
+ if (point->flag & PEP_HIDE) {
return;
+ }
if (data->select_action != SEL_TOGGLE) {
data->is_changed = select_action_apply(point, key, data->select_action);
@@ -1874,8 +1941,9 @@ static void select_tip(PEData *data, int point_index)
key = &point->keys[point->totkey - 1];
- if (point->flag & PEP_HIDE)
+ if (point->flag & PEP_HIDE) {
return;
+ }
if (data->select_action != SEL_TOGGLE) {
data->is_changed = select_action_apply(point, key, data->select_action);
@@ -2190,8 +2258,9 @@ int PE_lasso_select(bContext *C, const int mcords[][2], const short moves, const
unit_m4(mat);
- if (!PE_start_edit(edit))
+ if (!PE_start_edit(edit)) {
return OPERATOR_CANCELLED;
+ }
/* only for depths */
PE_set_view3d_data(C, &data);
@@ -2202,9 +2271,10 @@ int PE_lasso_select(bContext *C, const int mcords[][2], const short moves, const
LOOP_VISIBLE_POINTS
{
- if (edit->psys && !(psys->flag & PSYS_GLOBAL_HAIR))
+ if (edit->psys && !(psys->flag & PSYS_GLOBAL_HAIR)) {
psys_mat_hair_to_global(
ob, psmd_eval->mesh_final, psys->part->from, psys->particles + p, mat);
+ }
if (pset->selectmode == SCE_SELECT_POINT) {
LOOP_KEYS
@@ -2375,16 +2445,19 @@ static void select_less_keys(PEData *data, int point_index)
LOOP_SELECTED_KEYS
{
if (k == 0) {
- if (((key + 1)->flag & PEK_SELECT) == 0)
+ if (((key + 1)->flag & PEK_SELECT) == 0) {
key->flag |= PEK_TAG;
+ }
}
else if (k == point->totkey - 1) {
- if (((key - 1)->flag & PEK_SELECT) == 0)
+ if (((key - 1)->flag & PEK_SELECT) == 0) {
key->flag |= PEK_TAG;
+ }
}
else {
- if ((((key - 1)->flag & (key + 1)->flag) & PEK_SELECT) == 0)
+ if ((((key - 1)->flag & (key + 1)->flag) & PEK_SELECT) == 0) {
key->flag |= PEK_TAG;
+ }
}
}
@@ -2436,20 +2509,24 @@ static void select_more_keys(PEData *data, int point_index)
LOOP_KEYS
{
- if (key->flag & PEK_SELECT)
+ if (key->flag & PEK_SELECT) {
continue;
+ }
if (k == 0) {
- if ((key + 1)->flag & PEK_SELECT)
+ if ((key + 1)->flag & PEK_SELECT) {
key->flag |= PEK_TAG;
+ }
}
else if (k == point->totkey - 1) {
- if ((key - 1)->flag & PEK_SELECT)
+ if ((key - 1)->flag & PEK_SELECT) {
key->flag |= PEK_TAG;
+ }
}
else {
- if (((key - 1)->flag | (key + 1)->flag) & PEK_SELECT)
+ if (((key - 1)->flag | (key + 1)->flag) & PEK_SELECT) {
key->flag |= PEK_TAG;
+ }
}
}
@@ -2534,22 +2611,25 @@ static void rekey_particle(PEData *data, int pa_index)
}
/* replace keys */
- if (pa->hair)
+ if (pa->hair) {
MEM_freeN(pa->hair);
+ }
pa->hair = new_keys;
point->totkey = pa->totkey = data->totrekey;
- if (point->keys)
+ if (point->keys) {
MEM_freeN(point->keys);
+ }
ekey = point->keys = MEM_callocN(pa->totkey * sizeof(PTCacheEditKey), "Hair re-key edit keys");
for (k = 0, key = pa->hair; k < pa->totkey; k++, key++, ekey++) {
ekey->co = key->co;
ekey->time = &key->time;
ekey->flag |= PEK_SELECT;
- if (!(psys->flag & PSYS_GLOBAL_HAIR))
+ if (!(psys->flag & PSYS_GLOBAL_HAIR)) {
ekey->flag |= PEK_USE_WCO;
+ }
}
pa->flag &= ~PARS_REKEY;
@@ -2605,8 +2685,9 @@ static void rekey_particle_to_time(
PTCacheEditKey *ekey;
int k;
- if (!edit || !edit->psys)
+ if (!edit || !edit->psys) {
return;
+ }
psys = edit->psys;
@@ -2629,8 +2710,9 @@ static void rekey_particle_to_time(
}
/* replace hair keys */
- if (pa->hair)
+ if (pa->hair) {
MEM_freeN(pa->hair);
+ }
pa->hair = new_keys;
/* update edit pointers */
@@ -2678,10 +2760,12 @@ static int remove_tagged_particles(Object *ob, ParticleSystem *psys, int mirror)
if (ELEM(NULL, new_pars, new_points)) {
/* allocation error! */
- if (new_pars)
+ if (new_pars) {
MEM_freeN(new_pars);
- if (new_points)
+ }
+ if (new_points) {
MEM_freeN(new_points);
+ }
return 0;
}
}
@@ -2690,10 +2774,12 @@ static int remove_tagged_particles(Object *ob, ParticleSystem *psys, int mirror)
point = edit->points;
for (i = 0; i < psys->totpart; i++, pa++, point++) {
if (point->flag & PEP_TAG) {
- if (point->keys)
+ if (point->keys) {
MEM_freeN(point->keys);
- if (pa->hair)
+ }
+ if (pa->hair) {
MEM_freeN(pa->hair);
+ }
}
else {
memcpy(npa, pa, sizeof(ParticleData));
@@ -2703,12 +2789,14 @@ static int remove_tagged_particles(Object *ob, ParticleSystem *psys, int mirror)
}
}
- if (psys->particles)
+ if (psys->particles) {
MEM_freeN(psys->particles);
+ }
psys->particles = new_pars;
- if (edit->points)
+ if (edit->points) {
MEM_freeN(edit->points);
+ }
edit->points = new_points;
if (edit->mirror_cache) {
@@ -2762,8 +2850,9 @@ static void remove_tagged_keys(Depsgraph *depsgraph, Object *ob, ParticleSystem
new_totkey--;
}
/* we can't have elements with less than two keys*/
- if (new_totkey < 2)
+ if (new_totkey < 2) {
point->flag |= PEP_TAG;
+ }
}
remove_tagged_particles(ob, psys, pe_x_mirror(ob));
@@ -2808,11 +2897,13 @@ static void remove_tagged_keys(Depsgraph *depsgraph, Object *ob, ParticleSystem
hkey++;
}
- if (pa->hair)
+ if (pa->hair) {
MEM_freeN(pa->hair);
+ }
- if (point->keys)
+ if (point->keys) {
MEM_freeN(point->keys);
+ }
pa->hair = new_hkeys;
point->keys = new_keys;
@@ -2849,12 +2940,14 @@ static void subdivide_particle(PEData *data, int pa_index)
sim.psys = edit->psys;
for (k = 0, ekey = point->keys; k < pa->totkey - 1; k++, ekey++) {
- if (ekey->flag & PEK_SELECT && (ekey + 1)->flag & PEK_SELECT)
+ if (ekey->flag & PEK_SELECT && (ekey + 1)->flag & PEK_SELECT) {
totnewkey++;
+ }
}
- if (totnewkey == 0)
+ if (totnewkey == 0) {
return;
+ }
pa->flag |= PARS_REKEY;
@@ -2886,8 +2979,9 @@ static void subdivide_particle(PEData *data, int pa_index)
nekey->co = nkey->co;
nekey->time = &nkey->time;
nekey->flag |= PEK_SELECT;
- if (!(psys->flag & PSYS_GLOBAL_HAIR))
+ if (!(psys->flag & PSYS_GLOBAL_HAIR)) {
nekey->flag |= PEK_USE_WCO;
+ }
nekey++;
nkey++;
@@ -2900,12 +2994,14 @@ static void subdivide_particle(PEData *data, int pa_index)
nekey->co = nkey->co;
nekey->time = &nkey->time;
- if (pa->hair)
+ if (pa->hair) {
MEM_freeN(pa->hair);
+ }
pa->hair = new_keys;
- if (point->keys)
+ if (point->keys) {
MEM_freeN(point->keys);
+ }
point->keys = new_ekeys;
point->totkey = pa->totkey = pa->totkey + totnewkey;
@@ -2959,8 +3055,9 @@ static int remove_doubles_exec(bContext *C, wmOperator *op)
float mat[4][4], co[3], threshold = RNA_float_get(op->ptr, "threshold");
int n, totn, removed, totremoved;
- if (psys->flag & PSYS_GLOBAL_HAIR)
+ if (psys->flag & PSYS_GLOBAL_HAIR) {
return OPERATOR_CANCELLED;
+ }
edit = psys->edit;
psmd_eval = edit->psmd_eval;
@@ -3011,8 +3108,9 @@ static int remove_doubles_exec(bContext *C, wmOperator *op)
totremoved += removed;
} while (removed);
- if (totremoved == 0)
+ if (totremoved == 0) {
return OPERATOR_CANCELLED;
+ }
BKE_reportf(op->reports, RPT_INFO, "Removed %d double particles", totremoved);
@@ -3147,9 +3245,10 @@ static void toggle_particle_cursor(bContext *C, int enable)
WM_paint_cursor_end(CTX_wm_manager(C), pset->paintcursor);
pset->paintcursor = NULL;
}
- else if (enable)
+ else if (enable) {
pset->paintcursor = WM_paint_cursor_activate(
CTX_wm_manager(C), SPACE_VIEW3D, RGN_TYPE_WINDOW, PE_poll_view3d, brush_drawcursor, NULL);
+ }
}
/*************************** delete operator **************************/
@@ -3243,12 +3342,14 @@ static void PE_mirror_x(Scene *scene, Object *ob, int tagged)
int *mirrorfaces = NULL;
int rotation, totpart, newtotpart;
- if (psys->flag & PSYS_GLOBAL_HAIR)
+ if (psys->flag & PSYS_GLOBAL_HAIR) {
return;
+ }
psmd_eval = edit->psmd_eval;
- if (!psmd_eval->mesh_final)
+ if (!psmd_eval->mesh_final) {
return;
+ }
const bool use_dm_final_indices = (psys->part->use_modifier_stack &&
!psmd_eval->mesh_final->runtime.deformed_only);
@@ -3261,8 +3362,9 @@ static void PE_mirror_x(Scene *scene, Object *ob, int tagged)
mirrorfaces = mesh_get_x_mirror_faces(
ob, NULL, use_dm_final_indices ? psmd_eval->mesh_final : NULL);
- if (!edit->mirror_cache)
+ if (!edit->mirror_cache) {
PE_update_mirror_cache(ob, psys);
+ }
totpart = psys->totpart;
newtotpart = psys->totpart;
@@ -3277,13 +3379,15 @@ static void PE_mirror_x(Scene *scene, Object *ob, int tagged)
PE_mirror_particle(ob, psmd_eval->mesh_final, psys, pa, NULL);
continue;
}
- else
+ else {
point->flag |= PEP_TAG;
+ }
}
}
- if ((point->flag & PEP_TAG) && mirrorfaces[pa->num * 2] != -1)
+ if ((point->flag & PEP_TAG) && mirrorfaces[pa->num * 2] != -1) {
newtotpart++;
+ }
}
if (newtotpart != psys->totpart) {
@@ -3320,19 +3424,23 @@ static void PE_mirror_x(Scene *scene, Object *ob, int tagged)
pa = psys->particles + p;
const int pa_num = pa->num;
- if (point->flag & PEP_HIDE)
+ if (point->flag & PEP_HIDE) {
continue;
+ }
- if (!(point->flag & PEP_TAG) || mirrorfaces[pa_num * 2] == -1)
+ if (!(point->flag & PEP_TAG) || mirrorfaces[pa_num * 2] == -1) {
continue;
+ }
/* duplicate */
*newpa = *pa;
*newpoint = *point;
- if (pa->hair)
+ if (pa->hair) {
newpa->hair = MEM_dupallocN(pa->hair);
- if (point->keys)
+ }
+ if (point->keys) {
newpoint->keys = MEM_dupallocN(point->keys);
+ }
/* rotate weights according to vertex index rotation */
rotation = mirrorfaces[pa_num * 2 + 1];
@@ -3428,8 +3536,9 @@ static void brush_comb(PEData *data,
ParticleEditSettings *pset = PE_settings(data->scene);
float cvec[3], fac;
- if (pset->flag & PE_LOCK_FIRST && key_index == 0)
+ if (pset->flag & PE_LOCK_FIRST && key_index == 0) {
return;
+ }
fac = (float)pow((double)(1.0f - mouse_distance / data->rad), (double)data->combfac);
@@ -3460,12 +3569,14 @@ static void brush_cut(PEData *data, int pa_index)
}
/* don't cut hidden */
- if (edit->points[pa_index].flag & PEP_HIDE)
+ if (edit->points[pa_index].flag & PEP_HIDE) {
return;
+ }
if (ED_view3d_project_int_global(ar, key->co, screen_co, V3D_PROJ_TEST_CLIP_NEAR) !=
- V3D_PROJ_RET_OK)
+ V3D_PROJ_RET_OK) {
return;
+ }
rad2 = data->rad * data->rad;
@@ -3616,8 +3727,9 @@ static void brush_puff(PEData *data, int point_index, float mouse_distance)
mul_v3_m4v3(kco, data->ob->imat, co);
point_index = BLI_kdtree_3d_find_nearest(edit->emitter_field, kco, NULL);
- if (point_index == -1)
+ if (point_index == -1) {
return;
+ }
copy_v3_v3(co_root, co);
copy_v3_v3(no_root, &edit->emitter_cosnos[point_index * 6 + 3]);
@@ -3632,8 +3744,9 @@ static void brush_puff(PEData *data, int point_index, float mouse_distance)
fac = (float)pow((double)(1.0f - mouse_distance / data->rad), (double)data->pufffac);
fac *= 0.025f;
- if (data->invert)
+ if (data->invert) {
fac = -fac;
+ }
}
else {
/* compute position as if hair was standing up straight.
@@ -3729,8 +3842,9 @@ static void brush_puff(PEData *data, int point_index, float mouse_distance)
}
}
- if (changed)
+ if (changed) {
point->flag |= PEP_EDIT_RECALC;
+ }
}
static void BKE_brush_weight_get(PEData *data,
@@ -3877,15 +3991,17 @@ static int particle_intersect_mesh(Depsgraph *depsgraph,
copy_v3_v3(v1, vert_cos + 3 * mface->v1);
copy_v3_v3(v2, vert_cos + 3 * mface->v2);
copy_v3_v3(v3, vert_cos + 3 * mface->v3);
- if (mface->v4)
+ if (mface->v4) {
copy_v3_v3(v4, vert_cos + 3 * mface->v4);
+ }
}
else {
copy_v3_v3(v1, mvert[mface->v1].co);
copy_v3_v3(v2, mvert[mface->v2].co);
copy_v3_v3(v3, mvert[mface->v3].co);
- if (mface->v4)
+ if (mface->v4) {
copy_v3_v3(v4, mvert[mface->v4].co);
+ }
}
if (face_minmax == 0) {
@@ -3893,16 +4009,19 @@ static int particle_intersect_mesh(Depsgraph *depsgraph,
DO_MINMAX(v1, min, max);
DO_MINMAX(v2, min, max);
DO_MINMAX(v3, min, max);
- if (mface->v4)
+ if (mface->v4) {
DO_MINMAX(v4, min, max);
- if (isect_aabb_aabb_v3(min, max, p_min, p_max) == 0)
+ }
+ if (isect_aabb_aabb_v3(min, max, p_min, p_max) == 0) {
continue;
+ }
}
else {
copy_v3_v3(min, face_minmax + 6 * i);
copy_v3_v3(max, face_minmax + 6 * i + 3);
- if (isect_aabb_aabb_v3(min, max, p_min, p_max) == 0)
+ if (isect_aabb_aabb_v3(min, max, p_min, p_max) == 0) {
continue;
+ }
}
if (radius > 0.0f) {
@@ -3933,8 +4052,9 @@ static int particle_intersect_mesh(Depsgraph *depsgraph,
min_w[1] = cur_uv[0];
min_w[2] = cur_uv[1];
min_w[3] = 0.0f;
- if (mface->v4)
+ if (mface->v4) {
intersect_dm_quad_weights(v1, v2, v3, v4, min_w);
+ }
*min_face = i;
intersect = 1;
}
@@ -4090,8 +4210,9 @@ static int brush_add(const bContext *C, PEData *data, short number)
invert_m4_m4(imat, ob->obmat);
- if (psys->flag & PSYS_GLOBAL_HAIR)
+ if (psys->flag & PSYS_GLOBAL_HAIR) {
return 0;
+ }
add_pars = MEM_callocN(number * sizeof(ParticleData), "ParticleData add");
@@ -4173,12 +4294,14 @@ static int brush_add(const bContext *C, PEData *data, short number)
memcpy(new_points, edit->points, totpart * sizeof(PTCacheEditPoint));
/* change old arrays to new ones */
- if (psys->particles)
+ if (psys->particles) {
MEM_freeN(psys->particles);
+ }
psys->particles = new_pars;
- if (edit->points)
+ if (edit->points) {
MEM_freeN(edit->points);
+ }
edit->points = new_points;
if (edit->mirror_cache) {
@@ -4225,16 +4348,18 @@ static int brush_add(const bContext *C, PEData *data, short number)
key->co = hkey->co;
key->time = &hkey->time;
- if (!(psys->flag & PSYS_GLOBAL_HAIR))
+ if (!(psys->flag & PSYS_GLOBAL_HAIR)) {
key->flag |= PEK_USE_WCO;
+ }
}
pa->size = 1.0f;
initialize_particle(&sim, pa);
reset_particle(&sim, pa, 0.0, 1.0);
point->flag |= PEP_EDIT_RECALC;
- if (pe_x_mirror(ob))
+ if (pe_x_mirror(ob)) {
point->flag |= PEP_TAG; /* signal for duplicate */
+ }
framestep = pa->lifetime / (float)(pset->totaddkey - 1);
@@ -4270,12 +4395,14 @@ static int brush_add(const bContext *C, PEData *data, short number)
}
if (totw > 0.0f) {
- for (w = 0; w < maxw; w++)
+ for (w = 0; w < maxw; w++) {
weight[w] /= totw;
+ }
}
else {
- for (w = 0; w < maxw; w++)
+ for (w = 0; w < maxw; w++) {
weight[w] = 1.0f / maxw;
+ }
}
ppa = psys->particles + ptn[0].index;
@@ -4305,8 +4432,9 @@ static int brush_add(const bContext *C, PEData *data, short number)
}
}
- if (k == 0)
+ if (k == 0) {
sub_v3_v3v3(co1, pa->state.co, key3[0].co);
+ }
add_v3_v3v3(thkey->co, key3[0].co, co1);
@@ -4327,8 +4455,9 @@ static int brush_add(const bContext *C, PEData *data, short number)
}
}
- if (tree)
+ if (tree) {
BLI_kdtree_3d_free(tree);
+ }
}
MEM_freeN(add_pars);
@@ -4408,8 +4537,9 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
float dx, dy, dmax;
int lock_root = pset->flag & PE_LOCK_FIRST;
- if (!PE_start_edit(edit))
+ if (!PE_start_edit(edit)) {
return;
+ }
RNA_float_get_array(itemptr, "mouse", mousef);
mouse[0] = mousef[0];
@@ -4428,8 +4558,9 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
mval[1] = mouse[1];
/* disable locking temporatily for disconnected hair */
- if (edit->psys && edit->psys->flag & PSYS_GLOBAL_HAIR)
+ if (edit->psys && edit->psys->flag & PSYS_GLOBAL_HAIR) {
pset->flag &= ~PE_LOCK_FIRST;
+ }
if (((pset->brushtype == PE_BRUSH_ADD) ?
(sqrtf(dx * dx + dy * dy) > pset->brush[PE_BRUSH_ADD].step) :
@@ -4458,10 +4589,12 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
data.rad = pe_brush_size_get(scene, brush);
data.combfac = (brush->strength - 0.5f) * 2.0f;
- if (data.combfac < 0.0f)
+ if (data.combfac < 0.0f) {
data.combfac = 1.0f - 9.0f * data.combfac;
- else
+ }
+ else {
data.combfac = 1.0f - data.combfac;
+ }
invert_m4_m4(ob->imat, ob->obmat);
@@ -4477,17 +4610,21 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
data.rad = pe_brush_size_get(scene, brush);
data.cutfac = brush->strength;
- if (selected)
+ if (selected) {
foreach_selected_point(&data, brush_cut);
- else
+ }
+ else {
foreach_point(&data, brush_cut);
+ }
removed = remove_tagged_particles(ob, edit->psys, pe_x_mirror(ob));
- if (pset->flag & PE_KEEP_LENGTHS)
+ if (pset->flag & PE_KEEP_LENGTHS) {
recalc_lengths(edit);
+ }
}
- else
+ else {
removed = 0;
+ }
break;
}
@@ -4497,15 +4634,18 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
data.rad = pe_brush_size_get(scene, brush);
data.growfac = brush->strength / 50.0f;
- if (brush->invert ^ flip)
+ if (brush->invert ^ flip) {
data.growfac = 1.0f - data.growfac;
- else
+ }
+ else {
data.growfac = 1.0f + data.growfac;
+ }
foreach_mouse_hit_point(&data, brush_length, selected);
- if (pset->flag & PE_KEEP_LENGTHS)
+ if (pset->flag & PE_KEEP_LENGTHS) {
recalc_lengths(edit);
+ }
break;
}
case PE_BRUSH_PUFF: {
@@ -4516,10 +4656,12 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
data.select = selected;
data.pufffac = (brush->strength - 0.5f) * 2.0f;
- if (data.pufffac < 0.0f)
+ if (data.pufffac < 0.0f) {
data.pufffac = 1.0f - 9.0f * data.pufffac;
- else
+ }
+ else {
data.pufffac = 1.0f - data.pufffac;
+ }
data.invert = (brush->invert ^ flip);
invert_m4_m4(ob->imat, ob->obmat);
@@ -4534,11 +4676,13 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
added = brush_add(C, &data, brush->count);
- if (pset->flag & PE_KEEP_LENGTHS)
+ if (pset->flag & PE_KEEP_LENGTHS) {
recalc_lengths(edit);
+ }
}
- else
+ else {
added = 0;
+ }
break;
}
case PE_BRUSH_SMOOTH: {
@@ -4575,12 +4719,14 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
break;
}
}
- if ((pset->flag & PE_KEEP_LENGTHS) == 0)
+ if ((pset->flag & PE_KEEP_LENGTHS) == 0) {
recalc_lengths(edit);
+ }
if (ELEM(pset->brushtype, PE_BRUSH_ADD, PE_BRUSH_CUT) && (added || removed)) {
- if (pset->brushtype == PE_BRUSH_ADD && pe_x_mirror(ob))
+ if (pset->brushtype == PE_BRUSH_ADD && pe_x_mirror(ob)) {
PE_mirror_x(scene, ob, 1);
+ }
update_world_cos(depsgraph, ob, edit);
psys_free_path_cache(NULL, edit);
@@ -4619,8 +4765,9 @@ static void brush_edit_exit(wmOperator *op)
static int brush_edit_exec(bContext *C, wmOperator *op)
{
- if (!brush_edit_init(C, op))
+ if (!brush_edit_init(C, op)) {
return OPERATOR_CANCELLED;
+ }
RNA_BEGIN (op->ptr, itemptr, "stroke") {
brush_edit_apply(C, op, &itemptr);
@@ -4651,8 +4798,9 @@ static void brush_edit_apply_event(bContext *C, wmOperator *op, const wmEvent *e
static int brush_edit_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- if (!brush_edit_init(C, op))
+ if (!brush_edit_init(C, op)) {
return OPERATOR_CANCELLED;
+ }
brush_edit_apply_event(C, op, event);
@@ -4738,8 +4886,9 @@ static void point_inside_bvh_cb(void *userdata,
data->bvhdata.raycast_callback(&data->bvhdata, index, ray, hit);
- if (hit->index != -1)
+ if (hit->index != -1) {
++data->num_hits;
+ }
}
/* true if the point is inside the shape mesh */
@@ -4771,8 +4920,9 @@ static void shape_cut(PEData *data, int pa_index)
int k, totkeys = 1 << pset->draw_step;
/* don't cut hidden */
- if (edit->points[pa_index].flag & PEP_HIDE)
+ if (edit->points[pa_index].flag & PEP_HIDE) {
return;
+ }
cut = false;
@@ -4833,12 +4983,14 @@ static int shape_cut_exec(bContext *C, wmOperator *UNUSED(op))
int selected = count_selected_keys(scene, edit);
int lock_root = pset->flag & PE_LOCK_FIRST;
- if (!PE_start_edit(edit))
+ if (!PE_start_edit(edit)) {
return OPERATOR_CANCELLED;
+ }
/* disable locking temporatily for disconnected hair */
- if (edit->psys && edit->psys->flag & PSYS_GLOBAL_HAIR)
+ if (edit->psys && edit->psys->flag & PSYS_GLOBAL_HAIR) {
pset->flag &= ~PE_LOCK_FIRST;
+ }
if (edit->psys && edit->pathcache) {
PEData data;
@@ -4850,10 +5002,12 @@ static int shape_cut_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_CANCELLED;
}
- if (selected)
+ if (selected) {
foreach_selected_point(&data, shape_cut);
- else
+ }
+ else {
foreach_point(&data, shape_cut);
+ }
removed = remove_tagged_particles(ob, edit->psys, pe_x_mirror(ob));
recalc_lengths(edit);
@@ -4913,19 +5067,23 @@ int PE_minmax(Scene *scene, ViewLayer *view_layer, float min[3], float max[3])
float co[3], mat[4][4];
int ok = 0;
- if (!edit)
+ if (!edit) {
return ok;
+ }
- if ((psys = edit->psys))
+ if ((psys = edit->psys)) {
psmd_eval = edit->psmd_eval;
- else
+ }
+ else {
unit_m4(mat);
+ }
LOOP_VISIBLE_POINTS
{
- if (psys)
+ if (psys) {
psys_mat_hair_to_global(
ob, psmd_eval->mesh_final, psys->part->from, psys->particles + p, mat);
+ }
LOOP_SELECTED_KEYS
{
@@ -4965,14 +5123,17 @@ void PE_create_particle_edit(
}
/* no psmd->dm happens in case particle system modifier is not enabled */
- if (!(psys && psmd && psmd_eval->mesh_final) && !cache)
+ if (!(psys && psmd && psmd_eval->mesh_final) && !cache) {
return;
+ }
- if (cache && cache->flag & PTCACHE_DISK_CACHE)
+ if (cache && cache->flag & PTCACHE_DISK_CACHE) {
return;
+ }
- if (psys == NULL && (cache && BLI_listbase_is_empty(&cache->mem_cache)))
+ if (psys == NULL && (cache && BLI_listbase_is_empty(&cache->mem_cache))) {
return;
+ }
edit = (psys) ? psys->edit : cache->edit;
@@ -5033,21 +5194,24 @@ void PE_create_particle_edit(
cache->free_edit = PE_free_ptcache_edit;
edit->psys = NULL;
- for (pm = cache->mem_cache.first; pm; pm = pm->next)
+ for (pm = cache->mem_cache.first; pm; pm = pm->next) {
totframe++;
+ }
for (pm = cache->mem_cache.first; pm; pm = pm->next) {
LOOP_POINTS
{
- if (BKE_ptcache_mem_pointers_seek(p, pm) == 0)
+ if (BKE_ptcache_mem_pointers_seek(p, pm) == 0) {
continue;
+ }
if (!point->totkey) {
key = point->keys = MEM_callocN(totframe * sizeof(PTCacheEditKey), "ParticleEditKeys");
point->flag |= PEP_EDIT_RECALC;
}
- else
+ else {
key = point->keys + point->totkey;
+ }
key->co = pm->cur[BPHYS_DATA_LOCATION];
key->vel = pm->cur[BPHYS_DATA_VELOCITY];
@@ -5071,8 +5235,9 @@ void PE_create_particle_edit(
memset(edit->nosel_col, 0x00, sizeof(edit->nosel_col));
#endif
recalc_lengths(edit);
- if (psys && !cache)
+ if (psys && !cache) {
recalc_emitter_field(depsgraph, ob, psys);
+ }
PE_update_object(depsgraph, scene, ob, 1);
}
@@ -5082,12 +5247,15 @@ static bool particle_edit_toggle_poll(bContext *C)
{
Object *ob = CTX_data_active_object(C);
- if (ob == NULL || ob->type != OB_MESH)
+ if (ob == NULL || ob->type != OB_MESH) {
return 0;
- if (!ob->data || ID_IS_LINKED(ob->data))
+ }
+ if (!ob->data || ID_IS_LINKED(ob->data)) {
return 0;
- if (CTX_data_edit_object(C))
+ }
+ if (CTX_data_edit_object(C)) {
return 0;
+ }
return (ob->particlesystem.first || modifiers_findByType(ob, eModifierType_Cloth) ||
modifiers_findByType(ob, eModifierType_Softbody));
diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c
index 214a9f22186..b03ec56c7e4 100644
--- a/source/blender/editors/physics/particle_object.c
+++ b/source/blender/editors/physics/particle_object.c
@@ -84,8 +84,9 @@ static int particle_system_add_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ED_object_context(C);
Scene *scene = CTX_data_scene(C);
- if (!scene || !ob)
+ if (!scene || !ob) {
return OPERATOR_CANCELLED;
+ }
object_add_particle_system(bmain, scene, ob, NULL);
@@ -118,8 +119,9 @@ static int particle_system_remove_exec(bContext *C, wmOperator *UNUSED(op))
ViewLayer *view_layer = CTX_data_view_layer(C);
int mode_orig;
- if (!scene || !ob)
+ if (!scene || !ob) {
return OPERATOR_CANCELLED;
+ }
mode_orig = ob->mode;
object_remove_particle_system(bmain, scene, ob);
@@ -177,15 +179,18 @@ static int new_particle_settings_exec(bContext *C, wmOperator *UNUSED(op))
psys = ptr.data;
/* add or copy particle setting */
- if (psys->part)
+ if (psys->part) {
part = BKE_particlesettings_copy(bmain, psys->part);
- else
+ }
+ else {
part = BKE_particlesettings_add(bmain, "ParticleSettings");
+ }
ob = ptr.id.data;
- if (psys->part)
+ if (psys->part) {
id_us_min(&psys->part->id);
+ }
psys->part = part;
@@ -225,12 +230,14 @@ static int new_particle_target_exec(bContext *C, wmOperator *UNUSED(op))
ParticleTarget *pt;
- if (!psys)
+ if (!psys) {
return OPERATOR_CANCELLED;
+ }
pt = psys->targets.first;
- for (; pt; pt = pt->next)
+ for (; pt; pt = pt->next) {
pt->flag &= ~PTARGET_CURRENT;
+ }
pt = MEM_callocN(sizeof(ParticleTarget), "keyed particle target");
@@ -270,8 +277,9 @@ static int remove_particle_target_exec(bContext *C, wmOperator *UNUSED(op))
ParticleTarget *pt;
- if (!psys)
+ if (!psys) {
return OPERATOR_CANCELLED;
+ }
pt = psys->targets.first;
for (; pt; pt = pt->next) {
@@ -283,8 +291,9 @@ static int remove_particle_target_exec(bContext *C, wmOperator *UNUSED(op))
}
pt = psys->targets.last;
- if (pt)
+ if (pt) {
pt->flag |= PTARGET_CURRENT;
+ }
DEG_relations_tag_update(bmain);
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
@@ -317,8 +326,9 @@ static int target_move_up_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ptr.id.data;
ParticleTarget *pt;
- if (!psys)
+ if (!psys) {
return OPERATOR_CANCELLED;
+ }
pt = psys->targets.first;
for (; pt; pt = pt->next) {
@@ -356,8 +366,9 @@ static int target_move_down_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ptr.id.data;
ParticleTarget *pt;
- if (!psys)
+ if (!psys) {
return OPERATOR_CANCELLED;
+ }
pt = psys->targets.first;
for (; pt; pt = pt->next) {
if (pt->flag & PTARGET_CURRENT && pt->next) {
@@ -392,8 +403,9 @@ static int dupliob_refresh_exec(bContext *C, wmOperator *UNUSED(op))
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
ParticleSystem *psys = ptr.data;
- if (!psys)
+ if (!psys) {
return OPERATOR_CANCELLED;
+ }
psys_check_group_weights(psys->part);
DEG_id_tag_update(&psys->part->id, ID_RECALC_GEOMETRY | ID_RECALC_PSYS_REDO);
@@ -423,8 +435,9 @@ static int dupliob_move_up_exec(bContext *C, wmOperator *UNUSED(op))
ParticleSettings *part;
ParticleDupliWeight *dw;
- if (!psys)
+ if (!psys) {
return OPERATOR_CANCELLED;
+ }
part = psys->part;
for (dw = part->instance_weights.first; dw; dw = dw->next) {
@@ -462,8 +475,9 @@ static int copy_particle_dupliob_exec(bContext *C, wmOperator *UNUSED(op))
ParticleSettings *part;
ParticleDupliWeight *dw;
- if (!psys)
+ if (!psys) {
return OPERATOR_CANCELLED;
+ }
part = psys->part;
for (dw = part->instance_weights.first; dw; dw = dw->next) {
if (dw->flag & PART_DUPLIW_CURRENT) {
@@ -502,8 +516,9 @@ static int remove_particle_dupliob_exec(bContext *C, wmOperator *UNUSED(op))
ParticleSettings *part;
ParticleDupliWeight *dw;
- if (!psys)
+ if (!psys) {
return OPERATOR_CANCELLED;
+ }
part = psys->part;
for (dw = part->instance_weights.first; dw; dw = dw->next) {
@@ -515,8 +530,9 @@ static int remove_particle_dupliob_exec(bContext *C, wmOperator *UNUSED(op))
}
dw = part->instance_weights.last;
- if (dw)
+ if (dw) {
dw->flag |= PART_DUPLIW_CURRENT;
+ }
DEG_id_tag_update(&part->id, ID_RECALC_GEOMETRY | ID_RECALC_PSYS_REDO);
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE, NULL);
@@ -547,8 +563,9 @@ static int dupliob_move_down_exec(bContext *C, wmOperator *UNUSED(op))
ParticleSettings *part;
ParticleDupliWeight *dw;
- if (!psys)
+ if (!psys) {
return OPERATOR_CANCELLED;
+ }
part = psys->part;
for (dw = part->instance_weights.first; dw; dw = dw->next) {
@@ -593,11 +610,13 @@ static void disconnect_hair(Depsgraph *depsgraph, Scene *scene, Object *ob, Part
int i, k;
float hairmat[4][4];
- if (!ob || !psys || psys->flag & PSYS_GLOBAL_HAIR)
+ if (!ob || !psys || psys->flag & PSYS_GLOBAL_HAIR) {
return;
+ }
- if (!psys->part || psys->part->type != PART_HAIR)
+ if (!psys->part || psys->part->type != PART_HAIR) {
return;
+ }
edit = psys->edit;
point = edit ? edit->points : NULL;
@@ -639,8 +658,9 @@ static int disconnect_hair_exec(bContext *C, wmOperator *op)
ParticleSystem *psys = NULL;
const bool all = RNA_boolean_get(op->ptr, "all");
- if (!ob)
+ if (!ob) {
return OPERATOR_CANCELLED;
+ }
if (all) {
for (psys = ob->particlesystem.first; psys; psys = psys->next) {
@@ -705,12 +725,15 @@ static bool remap_hair_emitter(Depsgraph *depsgraph,
float from_ob_imat[4][4], to_ob_imat[4][4];
float from_imat[4][4], to_imat[4][4];
- if (!target_psmd->mesh_final)
+ if (!target_psmd->mesh_final) {
return false;
- if (!psys->part || psys->part->type != PART_HAIR)
+ }
+ if (!psys->part || psys->part->type != PART_HAIR) {
return false;
- if (!target_psys->part || target_psys->part->type != PART_HAIR)
+ }
+ if (!target_psys->part || target_psys->part->type != PART_HAIR) {
return false;
+ }
edit_point = target_edit ? target_edit->points : NULL;
@@ -740,8 +763,9 @@ static bool remap_hair_emitter(Depsgraph *depsgraph,
mvert = mesh->mvert;
/* convert to global coordinates */
- for (i = 0; i < numverts; i++)
+ for (i = 0; i < numverts; i++) {
mul_m4_v3(to_mat, mvert[i].co);
+ }
if (mesh->totface != 0) {
mface = mesh->mface;
@@ -761,10 +785,12 @@ static bool remap_hair_emitter(Depsgraph *depsgraph,
float from_co[3];
BVHTreeNearest nearest;
- if (from_global)
+ if (from_global) {
mul_v3_m4v3(from_co, from_ob_imat, pa->hair[0].co);
- else
+ }
+ else {
mul_v3_m4v3(from_co, from_ob_imat, pa->hair[0].world_co);
+ }
mul_m4_v3(from_mat, from_co);
nearest.index = -1;
@@ -773,8 +799,9 @@ static bool remap_hair_emitter(Depsgraph *depsgraph,
BLI_bvhtree_find_nearest(bvhtree.tree, from_co, &nearest, bvhtree.nearest_callback, &bvhtree);
if (nearest.index == -1) {
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("No nearest point found for hair root!");
+ }
continue;
}
@@ -790,8 +817,9 @@ static bool remap_hair_emitter(Depsgraph *depsgraph,
copy_v3_v3(v[3], mvert[mf->v4].co);
interp_weights_poly_v3(tpa->fuv, v, 4, nearest.co);
}
- else
+ else {
interp_weights_poly_v3(tpa->fuv, v, 3, nearest.co);
+ }
tpa->foffset = 0.0f;
tpa->num = nearest.index;
@@ -815,8 +843,9 @@ static bool remap_hair_emitter(Depsgraph *depsgraph,
float hairmat[4][4], imat[4][4];
float offset[3];
- if (to_global)
+ if (to_global) {
copy_m4_m4(imat, target_ob->obmat);
+ }
else {
/* note: using target_dm here, which is in target_ob object space and has full modifiers */
psys_mat_hair_to_object(target_ob, target_mesh, target_psys->part->from, tpa, hairmat);
@@ -832,10 +861,12 @@ static bool remap_hair_emitter(Depsgraph *depsgraph,
k++, key++, tkey++, ekey++) {
float co_orig[3];
- if (from_global)
+ if (from_global) {
mul_v3_m4v3(co_orig, from_ob_imat, key->co);
- else
+ }
+ else {
mul_v3_m4v3(co_orig, from_ob_imat, key->world_co);
+ }
mul_m4_v3(from_mat, co_orig);
add_v3_v3v3(tkey->co, co_orig, offset);
@@ -851,10 +882,12 @@ static bool remap_hair_emitter(Depsgraph *depsgraph,
for (k = 0, key = pa->hair, tkey = tpa->hair; k < tpa->totkey; k++, key++, tkey++) {
float co_orig[3];
- if (from_global)
+ if (from_global) {
mul_v3_m4v3(co_orig, from_ob_imat, key->co);
- else
+ }
+ else {
mul_v3_m4v3(co_orig, from_ob_imat, key->world_co);
+ }
mul_m4_v3(from_mat, co_orig);
add_v3_v3v3(tkey->co, co_orig, offset);
@@ -879,8 +912,9 @@ static bool connect_hair(Depsgraph *depsgraph, Scene *scene, Object *ob, Particl
{
bool ok;
- if (!psys)
+ if (!psys) {
return false;
+ }
ok = remap_hair_emitter(depsgraph,
scene,
@@ -907,8 +941,9 @@ static int connect_hair_exec(bContext *C, wmOperator *op)
const bool all = RNA_boolean_get(op->ptr, "all");
bool any_connected = false;
- if (!ob)
+ if (!ob) {
return OPERATOR_CANCELLED;
+ }
if (all) {
for (psys = ob->particlesystem.first; psys; psys = psys->next) {
@@ -966,8 +1001,9 @@ static void copy_particle_edit(Depsgraph *depsgraph,
KEY_K;
POINT_P;
- if (!edit_from)
+ if (!edit_from) {
return;
+ }
edit = MEM_dupallocN(edit_from);
edit->psys = psys;
@@ -1015,10 +1051,12 @@ static void remove_particle_systems_from_object(Object *ob_to)
{
ModifierData *md, *md_next;
- if (ob_to->type != OB_MESH)
+ if (ob_to->type != OB_MESH) {
return;
- if (!ob_to->data || ID_IS_LINKED(ob_to->data))
+ }
+ if (!ob_to->data || ID_IS_LINKED(ob_to->data)) {
return;
+ }
for (md = ob_to->modifiers.first; md; md = md_next) {
md_next = md->next;
@@ -1056,10 +1094,12 @@ static bool copy_particle_systems_to_object(const bContext *C,
CustomData_MeshMasks cdmask = {0};
int i, totpsys;
- if (ob_to->type != OB_MESH)
+ if (ob_to->type != OB_MESH) {
return false;
- if (!ob_to->data || ID_IS_LINKED(ob_to->data))
+ }
+ if (!ob_to->data || ID_IS_LINKED(ob_to->data)) {
return false;
+ }
/* For remapping we need a valid DM.
* Because the modifiers are appended at the end it's safe to use
@@ -1081,8 +1121,9 @@ static bool copy_particle_systems_to_object(const bContext *C,
psys = BKE_object_copy_particlesystem(psys_from, 0);
tmp_psys[i] = psys;
- if (psys_start == NULL)
+ if (psys_start == NULL) {
psys_start = psys;
+ }
psys_emitter_customdata_mask(psys, &cdmask);
}
@@ -1181,12 +1222,14 @@ static bool copy_particle_systems_to_object(const bContext *C,
static bool copy_particle_systems_poll(bContext *C)
{
Object *ob;
- if (!ED_operator_object_active_editable(C))
+ if (!ED_operator_object_active_editable(C)) {
return false;
+ }
ob = ED_object_active_context(C);
- if (BLI_listbase_is_empty(&ob->particlesystem))
+ if (BLI_listbase_is_empty(&ob->particlesystem)) {
return false;
+ }
return true;
}
@@ -1212,13 +1255,16 @@ static int copy_particle_systems_exec(bContext *C, wmOperator *op)
remove_particle_systems_from_object(ob_to);
changed = true;
}
- if (copy_particle_systems_to_object(C, scene, ob_from, psys_from, ob_to, space, false))
+ if (copy_particle_systems_to_object(C, scene, ob_from, psys_from, ob_to, space, false)) {
changed = true;
- else
+ }
+ else {
fail++;
+ }
- if (changed)
+ if (changed) {
changed_tot++;
+ }
}
}
CTX_DATA_END;
diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c
index d90fefaa67f..1ec0aeffa17 100644
--- a/source/blender/editors/physics/physics_fluid.c
+++ b/source/blender/editors/physics/physics_fluid.c
@@ -80,8 +80,9 @@ static float get_fluid_rate(FluidsimSettings *settings)
rate = settings->animRate;
- if (rate < 0.0f)
+ if (rate < 0.0f) {
rate = 0.0f;
+ }
return rate;
}
@@ -257,8 +258,9 @@ static void set_vertex_channel(Depsgraph *depsgraph,
int framesize = (3 * fobj->numVerts) + 1;
int j;
- if (channel == NULL)
+ if (channel == NULL) {
return;
+ }
initElbeemMesh(depsgraph, scene, ob, &numVerts, &verts, &numTris, &tris, 1, modifierIndex);
@@ -281,8 +283,9 @@ static void set_vertex_channel(Depsgraph *depsgraph,
static void free_domain_channels(FluidAnimChannels *channels)
{
- if (!channels->timeAtFrame)
+ if (!channels->timeAtFrame) {
return;
+ }
MEM_freeN(channels->timeAtFrame);
channels->timeAtFrame = NULL;
MEM_freeN(channels->DomainGravity);
@@ -457,8 +460,9 @@ static void fluid_init_all_channels(bContext *C,
float active = (float)((fluidmd->fss->flag & OB_FLUIDSIM_ACTIVE) ? 1 : 0);
float rot_d[3] = {0.f, 0.f, 0.f}, old_rot[3] = {0.f, 0.f, 0.f};
- if (ELEM(fluidmd->fss->type, OB_FLUIDSIM_DOMAIN, OB_FLUIDSIM_PARTICLE))
+ if (ELEM(fluidmd->fss->type, OB_FLUIDSIM_DOMAIN, OB_FLUIDSIM_PARTICLE)) {
continue;
+ }
/* init euler rotation values and convert to elbeem format */
/* get the rotation from ob->obmat rather than ob->rot to account for parent animations */
@@ -526,8 +530,9 @@ static void export_fluid_objects(const bContext *C, ListBase *fobjects, Scene *s
elbeemMesh fsmesh;
- if (ELEM(fluidmd->fss->type, OB_FLUIDSIM_DOMAIN, OB_FLUIDSIM_PARTICLE))
+ if (ELEM(fluidmd->fss->type, OB_FLUIDSIM_DOMAIN, OB_FLUIDSIM_PARTICLE)) {
continue;
+ }
elbeemResetMesh(&fsmesh);
@@ -554,12 +559,15 @@ static void export_fluid_objects(const bContext *C, ListBase *fobjects, Scene *s
fsmesh.localInivelCoords = ((fluidmd->fss->typeFlags & OB_FSINFLOW_LOCALCOORD) ? 1 : 0);
}
- if (fluidmd->fss->typeFlags & OB_FSBND_NOSLIP)
+ if (fluidmd->fss->typeFlags & OB_FSBND_NOSLIP) {
fsmesh.obstacleType = FLUIDSIM_OBSTACLE_NOSLIP;
- else if (fluidmd->fss->typeFlags & OB_FSBND_PARTSLIP)
+ }
+ else if (fluidmd->fss->typeFlags & OB_FSBND_PARTSLIP) {
fsmesh.obstacleType = FLUIDSIM_OBSTACLE_PARTSLIP;
- else if (fluidmd->fss->typeFlags & OB_FSBND_FREESLIP)
+ }
+ else if (fluidmd->fss->typeFlags & OB_FSBND_FREESLIP) {
fsmesh.obstacleType = FLUIDSIM_OBSTACLE_FREESLIP;
+ }
fsmesh.obstaclePartslip = fluidmd->fss->partSlipValue;
fsmesh.volumeInitType = fluidmd->fss->volumeInitType;
@@ -593,16 +601,19 @@ static void export_fluid_objects(const bContext *C, ListBase *fobjects, Scene *s
fsmesh.channelTranslation = fsmesh.channelRotation = fsmesh.channelScale = NULL;
/* Override user settings, only noslip is supported here! */
- if (fsmesh.type != OB_FLUIDSIM_CONTROL)
+ if (fsmesh.type != OB_FLUIDSIM_CONTROL) {
fsmesh.obstacleType = FLUIDSIM_OBSTACLE_NOSLIP;
+ }
}
elbeemAddMesh(&fsmesh);
- if (verts)
+ if (verts) {
MEM_freeN(verts);
- if (tris)
+ }
+ if (tris) {
MEM_freeN(tris);
+ }
}
}
@@ -619,8 +630,9 @@ static int fluid_validate_scene(ReportList *reports, ViewLayer *view_layer, Obje
ob, eModifierType_Fluidsim);
/* only find objects with fluid modifiers */
- if (!fluidmdtmp || ob->type != OB_MESH)
+ if (!fluidmdtmp || ob->type != OB_MESH) {
continue;
+ }
if (fluidmdtmp->fss->type == OB_FLUIDSIM_DOMAIN) {
/* if no initial domain object given, find another potential domain */
@@ -635,16 +647,19 @@ static int fluid_validate_scene(ReportList *reports, ViewLayer *view_layer, Obje
}
/* count number of objects needed for animation channels */
- if (!ELEM(fluidmdtmp->fss->type, OB_FLUIDSIM_DOMAIN, OB_FLUIDSIM_PARTICLE))
+ if (!ELEM(fluidmdtmp->fss->type, OB_FLUIDSIM_DOMAIN, OB_FLUIDSIM_PARTICLE)) {
channelObjCount++;
+ }
/* count number of fluid input objects */
- if (ELEM(fluidmdtmp->fss->type, OB_FLUIDSIM_FLUID, OB_FLUIDSIM_INFLOW))
+ if (ELEM(fluidmdtmp->fss->type, OB_FLUIDSIM_FLUID, OB_FLUIDSIM_INFLOW)) {
fluidInputCount++;
+ }
}
- if (newdomain)
+ if (newdomain) {
fsDomain = newdomain;
+ }
if (!fsDomain) {
BKE_report(reports, RPT_ERROR, "No domain object found");
@@ -768,8 +783,9 @@ static int fluidbake_breakjob(void *customdata)
{
FluidBakeJob *fb = (FluidBakeJob *)customdata;
- if (fb->stop && *(fb->stop))
+ if (fb->stop && *(fb->stop)) {
return 1;
+ }
/* this is not nice yet, need to make the jobs list template better
* for identifying/acting upon various different jobs */
@@ -1099,19 +1115,24 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
fsset->runsimCallback = &runSimulationCallback;
fsset->runsimUserData = fb;
- if (domainSettings->typeFlags & OB_FSBND_NOSLIP)
+ if (domainSettings->typeFlags & OB_FSBND_NOSLIP) {
fsset->domainobsType = FLUIDSIM_OBSTACLE_NOSLIP;
- else if (domainSettings->typeFlags & OB_FSBND_PARTSLIP)
+ }
+ else if (domainSettings->typeFlags & OB_FSBND_PARTSLIP) {
fsset->domainobsType = FLUIDSIM_OBSTACLE_PARTSLIP;
- else if (domainSettings->typeFlags & OB_FSBND_FREESLIP)
+ }
+ else if (domainSettings->typeFlags & OB_FSBND_FREESLIP) {
fsset->domainobsType = FLUIDSIM_OBSTACLE_FREESLIP;
+ }
fsset->domainobsPartslip = domainSettings->partSlipValue;
/* use domainobsType also for surface generation flag (bit: >=64) */
- if (domainSettings->typeFlags & OB_FSSG_NOOBS)
+ if (domainSettings->typeFlags & OB_FSSG_NOOBS) {
fsset->mFsSurfGenSetting = FLUIDSIM_FSSG_NOOBS;
- else
+ }
+ else {
fsset->mFsSurfGenSetting = 0; // "normal" mode
+ }
fsset->generateVertexVectors = (domainSettings->domainNovecgen == 0);
@@ -1190,19 +1211,22 @@ static int fluidsimBake(bContext *UNUSED(C),
static int fluid_bake_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
/* only one bake job at a time */
- if (WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C), WM_JOB_TYPE_OBJECT_SIM_FLUID))
+ if (WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C), WM_JOB_TYPE_OBJECT_SIM_FLUID)) {
return OPERATOR_CANCELLED;
+ }
- if (!fluidsimBake(C, op->reports, CTX_data_active_object(C), true))
+ if (!fluidsimBake(C, op->reports, CTX_data_active_object(C), true)) {
return OPERATOR_CANCELLED;
+ }
return OPERATOR_FINISHED;
}
static int fluid_bake_exec(bContext *C, wmOperator *op)
{
- if (!fluidsimBake(C, op->reports, CTX_data_active_object(C), false))
+ if (!fluidsimBake(C, op->reports, CTX_data_active_object(C), false)) {
return OPERATOR_CANCELLED;
+ }
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/physics/rigidbody_constraint.c b/source/blender/editors/physics/rigidbody_constraint.c
index 2d2c90f9391..2c454448b9b 100644
--- a/source/blender/editors/physics/rigidbody_constraint.c
+++ b/source/blender/editors/physics/rigidbody_constraint.c
@@ -60,8 +60,9 @@ static bool ED_operator_rigidbody_con_active_poll(bContext *C)
Object *ob = CTX_data_active_object(C);
return (ob && ob->rigidbody_constraint);
}
- else
+ else {
return 0;
+ }
}
bool ED_rigidbody_constraint_add(
diff --git a/source/blender/editors/physics/rigidbody_object.c b/source/blender/editors/physics/rigidbody_object.c
index 2914127f8d8..ed6d31dfd9b 100644
--- a/source/blender/editors/physics/rigidbody_object.c
+++ b/source/blender/editors/physics/rigidbody_object.c
@@ -66,8 +66,9 @@ static bool ED_operator_rigidbody_active_poll(bContext *C)
Object *ob = ED_object_active_context(C);
return (ob && ob->rigidbody_object);
}
- else
+ else {
return 0;
+ }
}
static bool ED_operator_rigidbody_add_poll(bContext *C)
@@ -76,8 +77,9 @@ static bool ED_operator_rigidbody_add_poll(bContext *C)
Object *ob = ED_object_active_context(C);
return (ob && ob->type == OB_MESH);
}
- else
+ else {
return 0;
+ }
}
/* ----------------- */
@@ -506,8 +508,9 @@ static int rigidbody_objects_calc_mass_exec(bContext *C, wmOperator *op)
/* get density (kg/m^3) to apply */
if (material >= 0) {
/* get density from table, and store in props for later repeating */
- if (material >= NUM_RB_MATERIAL_PRESETS)
+ if (material >= NUM_RB_MATERIAL_PRESETS) {
material = 0;
+ }
density = RB_MATERIAL_DENSITY_TABLE[material].density;
RNA_float_set(op->ptr, "density", density);
diff --git a/source/blender/editors/physics/rigidbody_world.c b/source/blender/editors/physics/rigidbody_world.c
index 179a5a513f4..558a293ccbf 100644
--- a/source/blender/editors/physics/rigidbody_world.c
+++ b/source/blender/editors/physics/rigidbody_world.c
@@ -172,11 +172,13 @@ static int rigidbody_world_export_exec(bContext *C, wmOperator *op)
static int rigidbody_world_export_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (!RNA_struct_property_is_set(op->ptr, "relative_path"))
+ if (!RNA_struct_property_is_set(op->ptr, "relative_path")) {
RNA_boolean_set(op->ptr, "relative_path", (U.flag & USER_RELPATHS) != 0);
+ }
- if (RNA_struct_property_is_set(op->ptr, "filepath"))
+ if (RNA_struct_property_is_set(op->ptr, "filepath")) {
return rigidbody_world_export_exec(C, op);
+ }
// TODO: use the actual rigidbody world's name + .bullet instead of this temp crap
RNA_string_set(op->ptr, "filepath", "rigidbodyworld_export.bullet");