[Bf-blender-cvs] [10fbea8845d] master: Cleanup: style
Campbell Barton
noreply at git.blender.org
Tue Sep 25 03:28:24 CEST 2018
Commit: 10fbea8845d6994bce0ccbdad763793548ef757d
Author: Campbell Barton
Date: Tue Sep 25 11:41:29 2018 +1000
Branches: master
https://developer.blender.org/rB10fbea8845d6994bce0ccbdad763793548ef757d
Cleanup: style
===================================================================
M source/blender/blenkernel/intern/effect.c
===================================================================
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c
index 89f85530439..82bf65993a8 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -56,7 +56,7 @@
#include "PIL_time.h"
-#include "BKE_anim.h" /* needed for where_on_path */
+#include "BKE_anim.h" /* needed for where_on_path */
#include "BKE_collision.h"
#include "BKE_curve.h"
#include "BKE_displist.h"
@@ -87,8 +87,9 @@ EffectorWeights *BKE_add_effector_weights(Group *group)
EffectorWeights *weights = MEM_callocN(sizeof(EffectorWeights), "EffectorWeights");
int i;
- for (i=0; i<NUM_PFIELD_TYPES; i++)
+ for (i = 0; i < NUM_PFIELD_TYPES; i++) {
weights->weight[i] = 1.0f;
+ }
weights->global_gravity = 1.0f;
@@ -100,13 +101,13 @@ PartDeflect *object_add_collision_fields(int type)
{
PartDeflect *pd;
- pd= MEM_callocN(sizeof(PartDeflect), "PartDeflect");
+ pd = MEM_callocN(sizeof(PartDeflect), "PartDeflect");
pd->forcefield = type;
pd->pdef_sbdamp = 0.1f;
pd->pdef_sbift = 0.2f;
pd->pdef_sboft = 0.02f;
- pd->seed = ((unsigned int)(ceil(PIL_check_seconds_timer()))+1) % 128;
+ pd->seed = ((uint)(ceil(PIL_check_seconds_timer())) + 1) % 128;
pd->f_strength = 1.0f;
pd->f_damp = 1.0f;
@@ -126,7 +127,7 @@ PartDeflect *object_add_collision_fields(int type)
pd->f_flow = 1.0f;
break;
}
- pd->flag = PFIELD_DO_LOCATION|PFIELD_DO_ROTATION;
+ pd->flag = PFIELD_DO_LOCATION | PFIELD_DO_ROTATION;
return pd;
}
@@ -136,12 +137,12 @@ PartDeflect *object_add_collision_fields(int type)
/* -------------------------- Effectors ------------------ */
void free_partdeflect(PartDeflect *pd)
{
- if (!pd)
+ if (!pd) {
return;
-
- if (pd->rng)
+ }
+ if (pd->rng) {
BLI_rng_free(pd->rng);
-
+ }
MEM_freeN(pd);
}
@@ -159,15 +160,18 @@ static void add_object_to_effectors(ListBase **effectors, Scene *scene, Effector
{
EffectorCache *eff = NULL;
- if ( ob == ob_src )
+ if (ob == ob_src) {
return;
+ }
if (for_simulation) {
- if (weights->weight[ob->pd->forcefield] == 0.0f )
+ if (weights->weight[ob->pd->forcefield] == 0.0f) {
return;
+ }
- if (ob->pd->shape == PFIELD_SHAPE_POINTS && !ob->derivedFinal )
+ if (ob->pd->shape == PFIELD_SHAPE_POINTS && !ob->derivedFinal) {
return;
+ }
}
if (*effectors == NULL)
@@ -182,72 +186,70 @@ static void add_object_to_effectors(ListBase **effectors, Scene *scene, Effector
}
static void add_particles_to_effectors(ListBase **effectors, Scene *scene, EffectorWeights *weights, Object *ob, ParticleSystem *psys, ParticleSystem *psys_src, bool for_simulation)
{
- ParticleSettings *part= psys->part;
+ ParticleSettings *part = psys->part;
- if ( !psys_check_enabled(ob, psys, G.is_rendering) )
+ if (!psys_check_enabled(ob, psys, G.is_rendering)) {
return;
-
- if ( psys == psys_src && (part->flag & PART_SELF_EFFECT) == 0)
+ }
+ if (psys == psys_src && (part->flag & PART_SELF_EFFECT) == 0) {
return;
-
- if ( part->pd && part->pd->forcefield && (!for_simulation || weights->weight[part->pd->forcefield] != 0.0f)) {
- if (*effectors == NULL)
+ }
+ if (part->pd && part->pd->forcefield && (!for_simulation || weights->weight[part->pd->forcefield] != 0.0f)) {
+ if (*effectors == NULL) {
*effectors = MEM_callocN(sizeof(ListBase), "effectors list");
-
+ }
BLI_addtail(*effectors, new_effector_cache(scene, ob, psys, part->pd));
}
if (part->pd2 && part->pd2->forcefield && (!for_simulation || weights->weight[part->pd2->forcefield] != 0.0f)) {
- if (*effectors == NULL)
+ if (*effectors == NULL) {
*effectors = MEM_callocN(sizeof(ListBase), "effectors list");
-
+ }
BLI_addtail(*effectors, new_effector_cache(scene, ob, psys, part->pd2));
}
}
/* returns ListBase handle with objects taking part in the effecting */
-ListBase *pdInitEffectors(Scene *scene, Object *ob_src, ParticleSystem *psys_src,
- EffectorWeights *weights, bool for_simulation)
+ListBase *pdInitEffectors(
+ Scene *scene, Object *ob_src, ParticleSystem *psys_src,
+ EffectorWeights *weights, bool for_simulation)
{
- Base *base;
- unsigned int layer= ob_src->lay;
+ const uint layer = ob_src->lay;
ListBase *effectors = NULL;
if (weights->group) {
- GroupObject *go;
-
- for (go= weights->group->gobject.first; go; go= go->next) {
- if ( (go->ob->lay & layer) ) {
- if ( go->ob->pd && go->ob->pd->forcefield )
+ for (GroupObject *go = weights->group->gobject.first; go; go = go->next) {
+ if ((go->ob->lay & layer)) {
+ if (go->ob->pd && go->ob->pd->forcefield) {
add_object_to_effectors(&effectors, scene, weights, go->ob, ob_src, for_simulation);
+ }
- if ( go->ob->particlesystem.first ) {
- ParticleSystem *psys= go->ob->particlesystem.first;
-
- for ( ; psys; psys=psys->next )
+ if (go->ob->particlesystem.first) {
+ for (ParticleSystem *psys = go->ob->particlesystem.first; psys; psys = psys->next) {
add_particles_to_effectors(&effectors, scene, weights, go->ob, psys, psys_src, for_simulation);
+ }
}
}
}
}
else {
- for (base = scene->base.first; base; base= base->next) {
- if ( (base->lay & layer) ) {
- if ( base->object->pd && base->object->pd->forcefield )
+ for (Base *base = scene->base.first; base; base = base->next) {
+ if ((base->lay & layer)) {
+ if (base->object->pd && base->object->pd->forcefield) {
add_object_to_effectors(&effectors, scene, weights, base->object, ob_src, for_simulation);
-
- if ( base->object->particlesystem.first ) {
- ParticleSystem *psys= base->object->particlesystem.first;
-
- for ( ; psys; psys=psys->next )
+ }
+ if (base->object->particlesystem.first) {
+ for (ParticleSystem *psys = base->object->particlesystem.first; psys; psys = psys->next) {
add_particles_to_effectors(&effectors, scene, weights, base->object, psys, psys_src, for_simulation);
+ }
}
}
}
}
- if (for_simulation)
+ if (for_simulation) {
pdPrecalculateEffectors(effectors);
+ }
return effectors;
}
@@ -255,11 +257,10 @@ ListBase *pdInitEffectors(Scene *scene, Object *ob_src, ParticleSystem *psys_src
void pdEndEffectors(ListBase **effectors)
{
if (*effectors) {
- EffectorCache *eff = (*effectors)->first;
-
- for (; eff; eff=eff->next) {
- if (eff->guide_data)
+ for (EffectorCache *eff = (*effectors)->first; eff; eff = eff->next) {
+ if (eff->guide_data) {
MEM_freeN(eff->guide_data);
+ }
}
BLI_freelistN(*effectors);
@@ -270,17 +271,23 @@ void pdEndEffectors(ListBase **effectors)
static void precalculate_effector(EffectorCache *eff)
{
- unsigned int cfra = (unsigned int)(eff->scene->r.cfra >= 0 ? eff->scene->r.cfra : -eff->scene->r.cfra);
- if (!eff->pd->rng)
+ uint cfra = (uint)(eff->scene->r.cfra >= 0 ? eff->scene->r.cfra : -eff->scene->r.cfra);
+ if (!eff->pd->rng) {
eff->pd->rng = BLI_rng_new(eff->pd->seed + cfra);
- else
+ }
+ else {
BLI_rng_srandom(eff->pd->rng, eff->pd->seed + cfra);
+ }
- if (eff->pd->forcefield == PFIELD_GUIDE && eff->ob->type==OB_CURVE) {
- Curve *cu= eff->ob->data;
+ if (eff->pd->forcefield == PFIELD_GUIDE && eff->ob->type == OB_CURVE) {
+ Curve *cu = eff->ob->data;
if (cu->flag & CU_PATH) {
- if (eff->ob->curve_cache == NULL || eff->ob->curve_cache->path==NULL || eff->ob->curve_cache->path->data==NULL)
+ if ((eff->ob->curve_cache == NULL) ||
+ (eff->ob->curve_cache->path == NULL) ||
+ (eff->ob->curve_cache->path->data == NULL))
+ {
BKE_displist_make_curveTypes(eff->scene, eff->ob, 0);
+ }
if (eff->ob->curve_cache->path && eff->ob->curve_cache->path->data) {
where_on_path(eff->ob, 0.0, eff->guide_loc, eff->guide_dir, NULL, &eff->guide_radius, NULL);
@@ -290,12 +297,14 @@ static void precalculate_effector(EffectorCache *eff)
}
}
else if (eff->pd->shape == PFIELD_SHAPE_SURFACE) {
- eff->surmd = (SurfaceModifierData *)modifiers_findByType( eff->ob, eModifierType_Surface );
- if (eff->ob->type == OB_CURVE)
+ eff->surmd = (SurfaceModifierData *)modifiers_findByType(eff->ob, eModifierType_Surface);
+ if (eff->ob->type == OB_CURVE) {
eff->flag |= PE_USE_NORMAL_DATA;
+ }
}
- else if (eff->psys)
+ else if (eff->psys) {
psys_update_particle_tree(eff->psys, eff->scene->r.cfra);
+ }
/* Store object velocity */
if (eff->ob) {
@@ -311,9 +320,9 @@ static void precalculate_effector(EffectorCache *eff)
void pdPrecalculateEffectors(ListBase *effectors)
{
if (effectors) {
- EffectorCache *eff = effectors->first;
- for (; eff; eff=eff->next)
+ for (EffectorCache *eff = effectors->first; eff; eff = eff->next) {
precalculate_effector(eff);
+ }
}
}
@@ -400,14 +409,15 @@ static float eff_calc_visibility(ListBase *colliders, EffectorCache *eff, Effect
float norm[3], len = 0.0;
float visibility = 1.0, absorption = 0.0;
- if (!(eff->pd->flag & PFIELD_VISIBILITY))
+ if (!(eff->pd->flag & PFIELD_VISIBILITY)) {
return visibility;
-
- if (!colls)
+ }
+ if (!colls) {
colls = get_collider_cache(eff->scene, eff->ob, NULL);
-
- if (!colls)
+ }
+ if (!colls) {
return visibility;
+ }
negate_v3_v3(norm, efd->vec_to_point);
len = normalize_v3(norm);
@@ -416,9 +426,9 @@ static float eff_calc_visibility(ListBase *colliders, EffectorCache *eff, Effect
for (col = colls->first; col; col = col->next) {
CollisionModifierData *collmd = col->collmd;
- if (col->ob == eff->ob)
+ if (col->ob == eff->ob) {
continue;
-
+ }
if (collmd->bvhtree) {
BVHTreeRayHit hit;
@@ -430,13 +440,14 @@ static float eff_calc_visibility(ListBase *colliders, EffectorCache *eff, Effect
collmd->bvhtree, point->loc, norm, 0.0f, &hit,
eff_tri_ray_hit, NULL, raycast_flag) != -1)
{
- absorption= col->ob->pd->absorption;
+ absorption = col->ob->pd->absorption;
/* visibility is only between 0 and 1, calculated from 1-absorption */
- visibility *= CLAMPIS(1.0f-absorption, 0.0f, 1.0f);
+ visibility *= CLAMPIS(1.0f - absorption, 0.0f, 1.0f);
- if (visibility <= 0.0f)
+ if (visibility <= 0.0f) {
break;
+ }
}
}
}
@@ -450,14 +461,15 @@ static float eff_calc_visibility(Lis
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list