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>2012-03-24 10:18:31 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-03-24 10:18:31 +0400
commit69e6894b15271884623ea6f56ead06db83acbe99 (patch)
treeb68200606afaca06cf7552f6b12fc20ebd30d487 /source/blender/blenkernel
parent7b99ae0ad3017e373be2a344e30d190b70ca66b4 (diff)
style cleanup: follow style guide for formatting of if/for/while loops, and else if's
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c418
-rw-r--r--source/blender/blenkernel/intern/action.c161
-rw-r--r--source/blender/blenkernel/intern/anim.c303
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c4
-rw-r--r--source/blender/blenkernel/intern/blender.c126
-rw-r--r--source/blender/blenkernel/intern/bmfont.c15
-rw-r--r--source/blender/blenkernel/intern/boids.c292
-rw-r--r--source/blender/blenkernel/intern/booleanops_mesh.c3
-rw-r--r--source/blender/blenkernel/intern/brush.c71
-rw-r--r--source/blender/blenkernel/intern/bvhutils.c48
-rw-r--r--source/blender/blenkernel/intern/camera.c64
-rw-r--r--source/blender/blenkernel/intern/cdderivedmesh.c448
-rw-r--r--source/blender/blenkernel/intern/cloth.c158
-rw-r--r--source/blender/blenkernel/intern/collision.c102
-rw-r--r--source/blender/blenkernel/intern/colortools.c253
-rw-r--r--source/blender/blenkernel/intern/constraint.c42
-rw-r--r--source/blender/blenkernel/intern/context.c136
-rw-r--r--source/blender/blenkernel/intern/curve.c930
-rw-r--r--source/blender/blenkernel/intern/customdata.c550
-rw-r--r--source/blender/blenkernel/intern/customdata_file.c86
-rw-r--r--source/blender/blenkernel/intern/depsgraph.c658
-rw-r--r--source/blender/blenkernel/intern/displist.c319
-rw-r--r--source/blender/blenkernel/intern/dynamicpaint.c114
-rw-r--r--source/blender/blenkernel/intern/effect.c194
-rw-r--r--source/blender/blenkernel/intern/fcurve.c14
-rw-r--r--source/blender/blenkernel/intern/fluidsim.c12
-rw-r--r--source/blender/blenkernel/intern/fmodifier.c6
-rw-r--r--source/blender/blenkernel/intern/font.c141
-rw-r--r--source/blender/blenkernel/intern/group.c132
-rw-r--r--source/blender/blenkernel/intern/icons.c37
-rw-r--r--source/blender/blenkernel/intern/idprop.c61
-rw-r--r--source/blender/blenkernel/intern/image.c636
-rw-r--r--source/blender/blenkernel/intern/image_gen.c44
-rw-r--r--source/blender/blenkernel/intern/implicit.c203
-rw-r--r--source/blender/blenkernel/intern/key.c529
-rw-r--r--source/blender/blenkernel/intern/lamp.c42
-rw-r--r--source/blender/blenkernel/intern/lattice.c19
-rw-r--r--source/blender/blenkernel/intern/library.c240
-rw-r--r--source/blender/blenkernel/intern/material.c20
-rw-r--r--source/blender/blenkernel/intern/mball.c112
-rw-r--r--source/blender/blenkernel/intern/mesh.c35
-rw-r--r--source/blender/blenkernel/intern/mesh_validate.c67
-rw-r--r--source/blender/blenkernel/intern/modifier.c65
-rw-r--r--source/blender/blenkernel/intern/movieclip.c250
-rw-r--r--source/blender/blenkernel/intern/multires.c44
-rw-r--r--source/blender/blenkernel/intern/navmesh_conversion.c2
-rw-r--r--source/blender/blenkernel/intern/node.c430
-rw-r--r--source/blender/blenkernel/intern/object.c21
-rw-r--r--source/blender/blenkernel/intern/ocean.c17
-rw-r--r--source/blender/blenkernel/intern/packedFile.c79
-rw-r--r--source/blender/blenkernel/intern/paint.c10
-rw-r--r--source/blender/blenkernel/intern/particle.c1149
-rw-r--r--source/blender/blenkernel/intern/particle_system.c1006
-rw-r--r--source/blender/blenkernel/intern/pointcache.c769
-rw-r--r--source/blender/blenkernel/intern/property.c49
-rw-r--r--source/blender/blenkernel/intern/report.c38
-rw-r--r--source/blender/blenkernel/intern/sca.c164
-rw-r--r--source/blender/blenkernel/intern/screen.c106
-rw-r--r--source/blender/blenkernel/intern/seqcache.c8
-rw-r--r--source/blender/blenkernel/intern/seqeffects.c568
-rw-r--r--source/blender/blenkernel/intern/sequencer.c647
-rw-r--r--source/blender/blenkernel/intern/shrinkwrap.c103
-rw-r--r--source/blender/blenkernel/intern/sketch.c4
-rw-r--r--source/blender/blenkernel/intern/smoke.c348
-rw-r--r--source/blender/blenkernel/intern/softbody.c36
-rw-r--r--source/blender/blenkernel/intern/sound.c6
-rw-r--r--source/blender/blenkernel/intern/speaker.c24
-rw-r--r--source/blender/blenkernel/intern/subsurf_ccg.c536
-rw-r--r--source/blender/blenkernel/intern/suggestions.c12
-rw-r--r--source/blender/blenkernel/intern/text.c458
-rw-r--r--source/blender/blenkernel/intern/texture.c348
-rw-r--r--source/blender/blenkernel/intern/tracking.c642
-rw-r--r--source/blender/blenkernel/intern/world.c42
-rw-r--r--source/blender/blenkernel/intern/writeavi.c4
-rw-r--r--source/blender/blenkernel/intern/writeffmpeg.c102
-rw-r--r--source/blender/blenkernel/intern/writeframeserver.c6
76 files changed, 8193 insertions, 7745 deletions
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 48dee60d470..f05ceb81735 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -173,7 +173,7 @@ static MVert *dm_dupVertArray(DerivedMesh *dm)
MVert *tmp = MEM_callocN(sizeof(*tmp) * dm->getNumVerts(dm),
"dm_dupVertArray tmp");
- if(tmp) dm->copyVertArray(dm, tmp);
+ if (tmp) dm->copyVertArray(dm, tmp);
return tmp;
}
@@ -183,7 +183,7 @@ static MEdge *dm_dupEdgeArray(DerivedMesh *dm)
MEdge *tmp = MEM_callocN(sizeof(*tmp) * dm->getNumEdges(dm),
"dm_dupEdgeArray tmp");
- if(tmp) dm->copyEdgeArray(dm, tmp);
+ if (tmp) dm->copyEdgeArray(dm, tmp);
return tmp;
}
@@ -193,7 +193,7 @@ static MFace *dm_dupFaceArray(DerivedMesh *dm)
MFace *tmp = MEM_callocN(sizeof(*tmp) * dm->getNumTessFaces(dm),
"dm_dupFaceArray tmp");
- if(tmp) dm->copyTessFaceArray(dm, tmp);
+ if (tmp) dm->copyTessFaceArray(dm, tmp);
return tmp;
}
@@ -203,7 +203,7 @@ static MLoop *dm_dupLoopArray(DerivedMesh *dm)
MLoop *tmp = MEM_callocN(sizeof(*tmp) * dm->getNumLoops(dm),
"dm_dupLoopArray tmp");
- if(tmp) dm->copyLoopArray(dm, tmp);
+ if (tmp) dm->copyLoopArray(dm, tmp);
return tmp;
}
@@ -213,7 +213,7 @@ static MPoly *dm_dupPolyArray(DerivedMesh *dm)
MPoly *tmp = MEM_callocN(sizeof(*tmp) * dm->getNumPolys(dm),
"dm_dupPolyArray tmp");
- if(tmp) dm->copyPolyArray(dm, tmp);
+ if (tmp) dm->copyPolyArray(dm, tmp);
return tmp;
}
@@ -501,11 +501,11 @@ void DM_to_mesh(DerivedMesh *dm, Mesh *me, Object *ob)
/* not all DerivedMeshes store their verts/edges/faces in CustomData, so
* we set them here in case they are missing */
- if(!CustomData_has_layer(&tmp.vdata, CD_MVERT))
+ if (!CustomData_has_layer(&tmp.vdata, CD_MVERT))
CustomData_add_layer(&tmp.vdata, CD_MVERT, CD_ASSIGN, dm->dupVertArray(dm), totvert);
- if(!CustomData_has_layer(&tmp.edata, CD_MEDGE))
+ if (!CustomData_has_layer(&tmp.edata, CD_MEDGE))
CustomData_add_layer(&tmp.edata, CD_MEDGE, CD_ASSIGN, dm->dupEdgeArray(dm), totedge);
- if(!CustomData_has_layer(&tmp.pdata, CD_MPOLY)) {
+ if (!CustomData_has_layer(&tmp.pdata, CD_MPOLY)) {
tmp.mloop = dm->dupLoopArray(dm);
tmp.mpoly = dm->dupPolyArray(dm);
@@ -515,7 +515,7 @@ void DM_to_mesh(DerivedMesh *dm, Mesh *me, Object *ob)
/* object had got displacement layer, should copy this layer to save sculpted data */
/* NOTE: maybe some other layers should be copied? nazgul */
- if(CustomData_has_layer(&me->ldata, CD_MDISPS)) {
+ if (CustomData_has_layer(&me->ldata, CD_MDISPS)) {
if (totloop == me->totloop) {
MDisps *mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS);
CustomData_add_layer(&tmp.ldata, CD_MDISPS, CD_DUPLICATE, mdisps, totloop);
@@ -536,9 +536,9 @@ void DM_to_mesh(DerivedMesh *dm, Mesh *me, Object *ob)
/* ok, this should now use new CD shapekey data,
* which shouuld be fed through the modifier
* stack*/
- if(tmp.totvert != me->totvert && !did_shapekeys && me->key) {
+ if (tmp.totvert != me->totvert && !did_shapekeys && me->key) {
printf("YEEK! this should be recoded! Shape key loss!!!\n");
- if(tmp.key) tmp.key->id.us--;
+ if (tmp.key) tmp.key->id.us--;
tmp.key = NULL;
}
@@ -551,16 +551,16 @@ void DM_to_meshkey(DerivedMesh *dm, Mesh *me, KeyBlock *kb)
float *fp;
MVert *mvert;
- if(totvert==0 || me->totvert==0 || me->totvert!=totvert) return;
+ if (totvert==0 || me->totvert==0 || me->totvert!=totvert) return;
- if(kb->data) MEM_freeN(kb->data);
+ if (kb->data) MEM_freeN(kb->data);
kb->data= MEM_callocN(me->key->elemsize*me->totvert, "kb->data");
kb->totelem= totvert;
fp= kb->data;
mvert=dm->getVertDataArray(dm, CD_MVERT);
- for(a=0; a<kb->totelem; a++, fp+=3, mvert++) {
+ for (a=0; a<kb->totelem; a++, fp+=3, mvert++) {
copy_v3_v3(fp, mvert->co);
}
}
@@ -614,7 +614,7 @@ void *DM_get_tessface_data(DerivedMesh *dm, int index, int type)
void *DM_get_vert_data_layer(DerivedMesh *dm, int type)
{
- if(type == CD_MVERT)
+ if (type == CD_MVERT)
return dm->getVertArray(dm);
return CustomData_get_layer(&dm->vertData, type);
@@ -622,7 +622,7 @@ void *DM_get_vert_data_layer(DerivedMesh *dm, int type)
void *DM_get_edge_data_layer(DerivedMesh *dm, int type)
{
- if(type == CD_MEDGE)
+ if (type == CD_MEDGE)
return dm->getEdgeArray(dm);
return CustomData_get_layer(&dm->edgeData, type);
@@ -773,7 +773,7 @@ DerivedMesh *mesh_create_derived(Mesh *me, Object *ob, float (*vertCos)[3])
{
DerivedMesh *dm = CDDM_from_mesh(me, ob);
- if(!dm)
+ if (!dm)
return NULL;
if (vertCos)
@@ -814,7 +814,8 @@ DerivedMesh *mesh_create_derived_for_modifier(Scene *scene, Object *ob,
add_shapekey_layers(dm, me, ob);
MEM_freeN(deformedVerts);
- } else {
+ }
+ else {
DerivedMesh *tdm = mesh_create_derived(me, ob, NULL);
if (build_shapekey_layers)
@@ -822,7 +823,7 @@ DerivedMesh *mesh_create_derived_for_modifier(Scene *scene, Object *ob,
dm = mti->applyModifier(md, ob, tdm, 0, 0);
- if(tdm != dm) tdm->release(tdm);
+ if (tdm != dm) tdm->release(tdm);
}
return dm;
@@ -855,23 +856,23 @@ static void *get_orco_coords_dm(Object *ob, BMEditMesh *em, int layer, int *free
{
*free= 0;
- if(layer == CD_ORCO) {
+ if (layer == CD_ORCO) {
/* get original coordinates */
*free= 1;
- if(em)
+ if (em)
return (float(*)[3])get_editbmesh_orco_verts(em);
else
return (float(*)[3])get_mesh_orco_verts(ob);
}
- else if(layer == CD_CLOTH_ORCO) {
+ else if (layer == CD_CLOTH_ORCO) {
/* apply shape key for cloth, this should really be solved
* by a more flexible customdata system, but not simple */
- if(!em) {
+ if (!em) {
ClothModifierData *clmd = (ClothModifierData *)modifiers_findByType(ob, eModifierType_Cloth);
KeyBlock *kb= key_get_keyblock(ob_get_key(ob), clmd->sim_parms->shapekey_rest);
- if(kb->data)
+ if (kb->data)
return kb->data;
}
@@ -887,14 +888,14 @@ static DerivedMesh *create_orco_dm(Object *ob, Mesh *me, BMEditMesh *em, int lay
float (*orco)[3];
int free;
- if(em) dm= CDDM_from_BMEditMesh(em, me, FALSE, FALSE);
+ if (em) dm= CDDM_from_BMEditMesh(em, me, FALSE, FALSE);
else dm= CDDM_from_mesh(me, ob);
orco= get_orco_coords_dm(ob, em, layer, &free);
- if(orco) {
+ if (orco) {
CDDM_apply_vert_coords(dm, orco);
- if(free) MEM_freeN(orco);
+ if (free) MEM_freeN(orco);
}
CDDM_calc_normals(dm);
@@ -910,11 +911,11 @@ static void add_orco_dm(Object *ob, BMEditMesh *em, DerivedMesh *dm,
totvert= dm->getNumVerts(dm);
- if(orcodm) {
+ if (orcodm) {
orco= MEM_callocN(sizeof(float)*3*totvert, "dm orco");
free= 1;
- if(orcodm->getNumVerts(orcodm) == totvert)
+ if (orcodm->getNumVerts(orcodm) == totvert)
orcodm->getVertCos(orcodm, orco);
else
dm->getVertCos(dm, orco);
@@ -922,17 +923,17 @@ static void add_orco_dm(Object *ob, BMEditMesh *em, DerivedMesh *dm,
else
orco= get_orco_coords_dm(ob, em, layer, &free);
- if(orco) {
- if(layer == CD_ORCO)
+ if (orco) {
+ if (layer == CD_ORCO)
transform_mesh_orco_verts(ob->data, orco, totvert, 0);
- if(!(layerorco = DM_get_vert_data_layer(dm, layer))) {
+ if (!(layerorco = DM_get_vert_data_layer(dm, layer))) {
DM_add_vert_layer(dm, layer, CD_CALLOC, NULL);
layerorco = DM_get_vert_data_layer(dm, layer);
}
memcpy(layerorco, orco, sizeof(float)*3*totvert);
- if(free) MEM_freeN(orco);
+ if (free) MEM_freeN(orco);
}
}
@@ -987,7 +988,7 @@ static void weightpaint_color(unsigned char r_col[4], ColorBand *coba, const flo
{
float colf[4];
- if(coba) {
+ if (coba) {
do_colorband(coba, input, colf);
}
else {
@@ -1149,7 +1150,7 @@ void DM_update_weight_mcol(Object *ob, DerivedMesh *dm, int const draw_flag,
# else
#if 0
/* XXX We have to create a CD_PREVIEW_MCOL, else it might sigsev (after a SubSurf mod, eg)... */
- if(!dm->getTessFaceDataArray(dm, CD_PREVIEW_MCOL))
+ if (!dm->getTessFaceDataArray(dm, CD_PREVIEW_MCOL))
CustomData_add_layer(&dm->faceData, CD_PREVIEW_MCOL, CD_CALLOC, NULL, numFaces);
#endif
@@ -1161,7 +1162,7 @@ void DM_update_weight_mcol(Object *ob, DerivedMesh *dm, int const draw_flag,
float *w = weights;
/* If indices is not NULL, it means we do not have weights for all vertices,
* so we must create them (and set them to zero)... */
- if(indices) {
+ if (indices) {
w = MEM_callocN(sizeof(float)*numVerts, "Temp weight array DM_update_weight_mcol");
i = num;
while(i--)
@@ -1171,7 +1172,7 @@ void DM_update_weight_mcol(Object *ob, DerivedMesh *dm, int const draw_flag,
/* Convert float weights to colors. */
wtcol_v = calc_colors_from_weights_array(numVerts, w);
- if(indices)
+ if (indices)
MEM_freeN(w);
}
@@ -1277,7 +1278,8 @@ static void shapekey_layers_to_keyblocks(DerivedMesh *dm, Mesh *me, int actshape
for (j=0; j<dm->numVertData; j++, kbcos++, mvert++) {
copy_v3_v3(*kbcos, mvert->co);
}
- } else {
+ }
+ else {
for (j=0; j<kb->totelem; j++, cos++, kbcos++) {
copy_v3_v3(*kbcos, *cos);
}
@@ -1374,16 +1376,16 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
/* XXX Same as above... For now, only weights preview in WPaint mode. */
const int do_mod_wmcol = do_init_wmcol;
- if(mmd && !mmd->sculptlvl)
+ if (mmd && !mmd->sculptlvl)
has_multires = 0;
- if(!skipVirtualArmature) {
+ if (!skipVirtualArmature) {
firstmd = modifiers_getVirtualModifierList(ob);
}
else {
/* game engine exception */
firstmd = ob->modifiers.first;
- if(firstmd && firstmd->type == eModifierType_Armature)
+ if (firstmd && firstmd->type == eModifierType_Armature)
firstmd = firstmd->next;
}
@@ -1391,13 +1393,13 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
modifiers_clearErrors(ob);
- if(useRenderParams) required_mode = eModifierMode_Render;
+ if (useRenderParams) required_mode = eModifierMode_Render;
else required_mode = eModifierMode_Realtime;
datamasks = modifiers_calcDataMasks(scene, ob, md, dataMask, required_mode);
curr = datamasks;
- if(do_mod_wmcol || do_mod_mcol) {
+ if (do_mod_wmcol || do_mod_mcol) {
/* Find the last active modifier generating a preview, or NULL if none. */
/* XXX Currently, DPaint modifier just ignores this.
* Needs a stupid hack...
@@ -1405,33 +1407,34 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
previewmd = modifiers_getLastPreview(scene, md, required_mode);
}
- if(deform_r) *deform_r = NULL;
+ if (deform_r) *deform_r = NULL;
*final_r = NULL;
- if(useDeform) {
- if(inputVertexCos)
+ if (useDeform) {
+ if (inputVertexCos)
deformedVerts = inputVertexCos;
/* Apply all leading deforming modifiers */
- for(;md; md = md->next, curr = curr->next) {
+ for (;md; md = md->next, curr = curr->next) {
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
md->scene= scene;
- if(!modifier_isEnabled(scene, md, required_mode)) continue;
- if(useDeform < 0 && mti->dependsOnTime && mti->dependsOnTime(md)) continue;
+ if (!modifier_isEnabled(scene, md, required_mode)) continue;
+ if (useDeform < 0 && mti->dependsOnTime && mti->dependsOnTime(md)) continue;
- if(mti->type == eModifierTypeType_OnlyDeform) {
- if(!deformedVerts)
+ if (mti->type == eModifierTypeType_OnlyDeform) {
+ if (!deformedVerts)
deformedVerts = mesh_getVertexCos(me, &numVerts);
mti->deformVerts(md, ob, NULL, deformedVerts, numVerts, useRenderParams, useDeform);
- } else {
+ }
+ else {
break;
}
/* grab modifiers until index i */
- if((index >= 0) && (modifiers_indexInObject(ob, md) >= index))
+ if ((index >= 0) && (modifiers_indexInObject(ob, md) >= index))
break;
}
@@ -1445,14 +1448,15 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
if (build_shapekey_layers)
add_shapekey_layers(dm, me, ob);
- if(deformedVerts) {
+ if (deformedVerts) {
CDDM_apply_vert_coords(*deform_r, deformedVerts);
CDDM_calc_normals(*deform_r);
}
}
- } else {
+ }
+ else {
/* default behavior for meshes */
- if(inputVertexCos)
+ if (inputVertexCos)
deformedVerts = inputVertexCos;
else
deformedVerts = mesh_getVertexCos(me, &numVerts);
@@ -1466,41 +1470,41 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
orcodm = NULL;
clothorcodm = NULL;
- for(;md; md = md->next, curr = curr->next) {
+ for (;md; md = md->next, curr = curr->next) {
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
md->scene= scene;
- if(!modifier_isEnabled(scene, md, required_mode)) continue;
- if(mti->type == eModifierTypeType_OnlyDeform && !useDeform) continue;
- if((mti->flags & eModifierTypeFlag_RequiresOriginalData) && dm) {
+ if (!modifier_isEnabled(scene, md, required_mode)) continue;
+ if (mti->type == eModifierTypeType_OnlyDeform && !useDeform) continue;
+ if ((mti->flags & eModifierTypeFlag_RequiresOriginalData) && dm) {
modifier_setError(md, "%s", TIP_("Modifier requires original data, bad stack position."));
continue;
}
- if(sculpt_mode && (!has_multires || multires_applied)) {
+ if (sculpt_mode && (!has_multires || multires_applied)) {
int unsupported= 0;
- if(scene->toolsettings->sculpt->flags & SCULPT_ONLY_DEFORM)
+ if (scene->toolsettings->sculpt->flags & SCULPT_ONLY_DEFORM)
unsupported|= mti->type != eModifierTypeType_OnlyDeform;
unsupported|= md->type == eModifierType_Multires && ((MultiresModifierData*)md)->sculptlvl==0;
unsupported|= multires_applied;
- if(unsupported) {
+ if (unsupported) {
modifier_setError(md, "%s", TIP_("Not supported in sculpt mode."));
continue;
}
}
- if(needMapping && !modifier_supportsMapping(md)) continue;
- if(useDeform < 0 && mti->dependsOnTime && mti->dependsOnTime(md)) continue;
+ if (needMapping && !modifier_supportsMapping(md)) continue;
+ if (useDeform < 0 && mti->dependsOnTime && mti->dependsOnTime(md)) continue;
/* add an orco layer if needed by this modifier */
- if(mti->requiredDataMask)
+ if (mti->requiredDataMask)
mask = mti->requiredDataMask(ob, md);
else
mask = 0;
- if(dm && (mask & CD_MASK_ORCO))
+ if (dm && (mask & CD_MASK_ORCO))
add_orco_dm(ob, NULL, dm, orcodm, CD_ORCO);
/* How to apply modifier depends on (a) what we already have as
@@ -1508,10 +1512,10 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
* deformed vertices) and (b) what type the modifier is.
*/
- if(mti->type == eModifierTypeType_OnlyDeform) {
+ if (mti->type == eModifierTypeType_OnlyDeform) {
/* No existing verts to deform, need to build them. */
- if(!deformedVerts) {
- if(dm) {
+ if (!deformedVerts) {
+ if (dm) {
/* Deforming a derived mesh, read the vertex locations
* out of the mesh and deform them. Once done with this
* run of deformers verts will be written back.
@@ -1520,34 +1524,36 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
deformedVerts =
MEM_mallocN(sizeof(*deformedVerts) * numVerts, "dfmv");
dm->getVertCos(dm, deformedVerts);
- } else {
+ }
+ else {
deformedVerts = mesh_getVertexCos(me, &numVerts);
}
}
/* if this is not the last modifier in the stack then recalculate the normals
* to avoid giving bogus normals to the next modifier see: [#23673] */
- if(isPrevDeform && mti->dependsOnNormals && mti->dependsOnNormals(md)) {
+ if (isPrevDeform && mti->dependsOnNormals && mti->dependsOnNormals(md)) {
/* XXX, this covers bug #23673, but we may need normal calc for other types */
- if(dm && dm->type == DM_TYPE_CDDM) {
+ if (dm && dm->type == DM_TYPE_CDDM) {
CDDM_apply_vert_coords(dm, deformedVerts);
CDDM_calc_normals(dm);
}
}
mti->deformVerts(md, ob, dm, deformedVerts, numVerts, useRenderParams, useDeform);
- } else {
+ }
+ else {
DerivedMesh *ndm;
/* determine which data layers are needed by following modifiers */
- if(curr->next)
+ if (curr->next)
nextmask= (CustomDataMask)GET_INT_FROM_POINTER(curr->next->link);
else
nextmask= dataMask;
/* apply vertex coordinates or build a DerivedMesh as necessary */
- if(dm) {
- if(deformedVerts) {
+ if (dm) {
+ if (deformedVerts) {
DerivedMesh *tdm = CDDM_copy(dm);
dm->release(dm);
dm = tdm;
@@ -1555,18 +1561,19 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
CDDM_apply_vert_coords(dm, deformedVerts);
CDDM_calc_normals(dm);
}
- } else {
+ }
+ else {
dm = CDDM_from_mesh(me, ob);
if (build_shapekey_layers)
add_shapekey_layers(dm, me, ob);
- if(deformedVerts) {
+ if (deformedVerts) {
CDDM_apply_vert_coords(dm, deformedVerts);
CDDM_calc_normals(dm);
}
- if(do_init_wmcol)
+ if (do_init_wmcol)
DM_update_weight_mcol(ob, dm, draw_flag, NULL, 0, NULL);
/* Constructive modifiers need to have an origindex
@@ -1576,7 +1583,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
* requests it, this way Mirror, Solidify etc will keep ORIGINDEX
* data by using generic DM_copy_vert_data() functions.
*/
- if(needMapping || (nextmask & CD_MASK_ORIGINDEX)) {
+ if (needMapping || (nextmask & CD_MASK_ORIGINDEX)) {
/* calc */
DM_add_vert_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL);
DM_add_edge_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL);
@@ -1597,12 +1604,12 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
DM_set_only_copy(dm, mask | (needMapping ? CD_MASK_ORIGINDEX : 0));
/* add cloth rest shape key if need */
- if(mask & CD_MASK_CLOTH_ORCO)
+ if (mask & CD_MASK_CLOTH_ORCO)
add_orco_dm(ob, NULL, dm, clothorcodm, CD_CLOTH_ORCO);
/* add an origspace layer if needed */
- if(((CustomDataMask)GET_INT_FROM_POINTER(curr->link)) & CD_MASK_ORIGSPACE_MLOOP) {
- if(!CustomData_has_layer(&dm->loopData, CD_ORIGSPACE_MLOOP)) {
+ if (((CustomDataMask)GET_INT_FROM_POINTER(curr->link)) & CD_MASK_ORIGSPACE_MLOOP) {
+ if (!CustomData_has_layer(&dm->loopData, CD_ORIGSPACE_MLOOP)) {
DM_add_loop_layer(dm, CD_ORIGSPACE_MLOOP, CD_CALLOC, NULL);
DM_init_origspace(dm);
}
@@ -1610,14 +1617,14 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
ndm = mti->applyModifier(md, ob, dm, useRenderParams, useCache);
- if(ndm) {
+ if (ndm) {
/* if the modifier returned a new dm, release the old one */
- if(dm && dm != ndm) dm->release(dm);
+ if (dm && dm != ndm) dm->release(dm);
dm = ndm;
- if(deformedVerts) {
- if(deformedVerts != inputVertexCos)
+ if (deformedVerts) {
+ if (deformedVerts != inputVertexCos)
MEM_freeN(deformedVerts);
deformedVerts = NULL;
@@ -1625,33 +1632,33 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
}
/* create an orco derivedmesh in parallel */
- if(nextmask & CD_MASK_ORCO) {
- if(!orcodm)
+ if (nextmask & CD_MASK_ORCO) {
+ if (!orcodm)
orcodm= create_orco_dm(ob, me, NULL, CD_ORCO);
nextmask &= ~CD_MASK_ORCO;
DM_set_only_copy(orcodm, nextmask | CD_MASK_ORIGINDEX);
ndm = mti->applyModifier(md, ob, orcodm, useRenderParams, 0);
- if(ndm) {
+ if (ndm) {
/* if the modifier returned a new dm, release the old one */
- if(orcodm && orcodm != ndm) orcodm->release(orcodm);
+ if (orcodm && orcodm != ndm) orcodm->release(orcodm);
orcodm = ndm;
}
}
/* create cloth orco derivedmesh in parallel */
- if(nextmask & CD_MASK_CLOTH_ORCO) {
- if(!clothorcodm)
+ if (nextmask & CD_MASK_CLOTH_ORCO) {
+ if (!clothorcodm)
clothorcodm= create_orco_dm(ob, me, NULL, CD_CLOTH_ORCO);
nextmask &= ~CD_MASK_CLOTH_ORCO;
DM_set_only_copy(clothorcodm, nextmask | CD_MASK_ORIGINDEX);
ndm = mti->applyModifier(md, ob, clothorcodm, useRenderParams, 0);
- if(ndm) {
+ if (ndm) {
/* if the modifier returned a new dm, release the old one */
- if(clothorcodm && clothorcodm != ndm) clothorcodm->release(clothorcodm);
+ if (clothorcodm && clothorcodm != ndm) clothorcodm->release(clothorcodm);
clothorcodm = ndm;
}
}
@@ -1670,21 +1677,21 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
isPrevDeform= (mti->type == eModifierTypeType_OnlyDeform);
/* grab modifiers until index i */
- if((index >= 0) && (modifiers_indexInObject(ob, md) >= index))
+ if ((index >= 0) && (modifiers_indexInObject(ob, md) >= index))
break;
- if(sculpt_mode && md->type == eModifierType_Multires)
+ if (sculpt_mode && md->type == eModifierType_Multires)
multires_applied = 1;
}
- for(md=firstmd; md; md=md->next)
+ for (md=firstmd; md; md=md->next)
modifier_freeTemporaryData(md);
/* Yay, we are done. If we have a DerivedMesh and deformed vertices
* need to apply these back onto the DerivedMesh. If we have no
* DerivedMesh then we need to build one.
*/
- if(dm && deformedVerts) {
+ if (dm && deformedVerts) {
finaldm = CDDM_copy(dm);
dm->release(dm);
@@ -1694,46 +1701,48 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
#if 0 /* For later nice mod preview! */
/* In case we need modified weights in CD_PREVIEW_MCOL, we have to re-compute it. */
- if(do_final_wmcol)
+ if (do_final_wmcol)
DM_update_weight_mcol(ob, finaldm, draw_flag, NULL, 0, NULL);
#endif
- } else if(dm) {
+ }
+ else if (dm) {
finaldm = dm;
#if 0 /* For later nice mod preview! */
/* In case we need modified weights in CD_PREVIEW_MCOL, we have to re-compute it. */
- if(do_final_wmcol)
+ if (do_final_wmcol)
DM_update_weight_mcol(ob, finaldm, draw_flag, NULL, 0, NULL);
#endif
- } else {
+ }
+ else {
int recalc_normals= 0;
finaldm = CDDM_from_mesh(me, ob);
- if(build_shapekey_layers) {
+ if (build_shapekey_layers) {
add_shapekey_layers(finaldm, me, ob);
recalc_normals= 1;
}
- if(deformedVerts) {
+ if (deformedVerts) {
CDDM_apply_vert_coords(finaldm, deformedVerts);
recalc_normals= 1;
}
- if(recalc_normals) {
+ if (recalc_normals) {
CDDM_calc_normals(finaldm);
}
/* In this case, we should never have weight-modifying modifiers in stack... */
- if(do_init_wmcol)
+ if (do_init_wmcol)
DM_update_weight_mcol(ob, finaldm, draw_flag, NULL, 0, NULL);
}
/* add an orco layer if needed */
- if(dataMask & CD_MASK_ORCO) {
+ if (dataMask & CD_MASK_ORCO) {
add_orco_dm(ob, NULL, finaldm, orcodm, CD_ORCO);
- if(deform_r && *deform_r)
+ if (deform_r && *deform_r)
add_orco_dm(ob, NULL, *deform_r, NULL, CD_ORCO);
}
@@ -1806,12 +1815,12 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
*final_r = finaldm;
- if(orcodm)
+ if (orcodm)
orcodm->release(orcodm);
- if(clothorcodm)
+ if (clothorcodm)
clothorcodm->release(clothorcodm);
- if(deformedVerts && deformedVerts != inputVertexCos)
+ if (deformedVerts && deformedVerts != inputVertexCos)
MEM_freeN(deformedVerts);
BLI_linklist_free(datamasks, NULL);
@@ -1839,8 +1848,8 @@ int editbmesh_modifier_is_enabled(Scene *scene, ModifierData *md, DerivedMesh *d
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
int required_mode = eModifierMode_Realtime | eModifierMode_Editmode;
- if(!modifier_isEnabled(scene, md, required_mode)) return 0;
- if((mti->flags & eModifierTypeFlag_RequiresOriginalData) && dm) {
+ if (!modifier_isEnabled(scene, md, required_mode)) return 0;
+ if ((mti->flags & eModifierTypeFlag_RequiresOriginalData) && dm) {
modifier_setError(md, "%s", TIP_("Modifier requires original data, bad stack position."));
return 0;
}
@@ -1862,7 +1871,7 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
modifiers_clearErrors(ob);
- if(cage_r && cageIndex == -1) {
+ if (cage_r && cageIndex == -1) {
*cage_r = getEditDerivedBMesh(em, ob, NULL);
}
@@ -1872,18 +1881,18 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
datamasks = modifiers_calcDataMasks(scene, ob, md, dataMask, required_mode);
curr = datamasks;
- for(i = 0; md; i++, md = md->next, curr = curr->next) {
+ for (i = 0; md; i++, md = md->next, curr = curr->next) {
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
md->scene= scene;
- if(!editbmesh_modifier_is_enabled(scene, md, dm))
+ if (!editbmesh_modifier_is_enabled(scene, md, dm))
continue;
/* add an orco layer if needed by this modifier */
- if(dm && mti->requiredDataMask) {
+ if (dm && mti->requiredDataMask) {
mask = mti->requiredDataMask(ob, md);
- if(mask & CD_MASK_ORCO)
+ if (mask & CD_MASK_ORCO)
add_orco_dm(ob, em, dm, orcodm, CD_ORCO);
}
@@ -1892,10 +1901,10 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
* deformed vertices) and (b) what type the modifier is.
*/
- if(mti->type == eModifierTypeType_OnlyDeform) {
+ if (mti->type == eModifierTypeType_OnlyDeform) {
/* No existing verts to deform, need to build them. */
- if(!deformedVerts) {
- if(dm) {
+ if (!deformedVerts) {
+ if (dm) {
/* Deforming a derived mesh, read the vertex locations
* out of the mesh and deform them. Once done with this
* run of deformers verts will be written back.
@@ -1904,7 +1913,8 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
deformedVerts =
MEM_mallocN(sizeof(*deformedVerts) * numVerts, "dfmv");
dm->getVertCos(dm, deformedVerts);
- } else {
+ }
+ else {
deformedVerts = editbmesh_get_vertex_cos(em, &numVerts);
}
}
@@ -1912,28 +1922,31 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
if (mti->deformVertsEM)
mti->deformVertsEM(md, ob, em, dm, deformedVerts, numVerts);
else mti->deformVerts(md, ob, dm, deformedVerts, numVerts, 0, 0);
- } else {
+ }
+ else {
DerivedMesh *ndm;
/* apply vertex coordinates or build a DerivedMesh as necessary */
- if(dm) {
- if(deformedVerts) {
+ if (dm) {
+ if (deformedVerts) {
DerivedMesh *tdm = CDDM_copy(dm);
- if(!(cage_r && dm == *cage_r)) dm->release(dm);
+ if (!(cage_r && dm == *cage_r)) dm->release(dm);
dm = tdm;
CDDM_apply_vert_coords(dm, deformedVerts);
CDDM_calc_normals(dm);
- } else if(cage_r && dm == *cage_r) {
+ }
+ else if (cage_r && dm == *cage_r) {
/* dm may be changed by this modifier, so we need to copy it
*/
dm = CDDM_copy(dm);
}
- } else {
+ }
+ else {
dm = CDDM_from_BMEditMesh(em, ob->data, FALSE, FALSE);
- if(deformedVerts) {
+ if (deformedVerts) {
CDDM_apply_vert_coords(dm, deformedVerts);
CDDM_calc_normals(dm);
}
@@ -1941,8 +1954,8 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
/* create an orco derivedmesh in parallel */
mask= (CustomDataMask)GET_INT_FROM_POINTER(curr->link);
- if(mask & CD_MASK_ORCO) {
- if(!orcodm)
+ if (mask & CD_MASK_ORCO) {
+ if (!orcodm)
orcodm= create_orco_dm(ob, ob->data, em, CD_ORCO);
mask &= ~CD_MASK_ORCO;
@@ -1953,9 +1966,9 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
else
ndm = mti->applyModifier(md, ob, orcodm, 0, 0);
- if(ndm) {
+ if (ndm) {
/* if the modifier returned a new dm, release the old one */
- if(orcodm && orcodm != ndm) orcodm->release(orcodm);
+ if (orcodm && orcodm != ndm) orcodm->release(orcodm);
orcodm = ndm;
}
}
@@ -1965,8 +1978,8 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
DM_set_only_copy(dm, mask | CD_MASK_ORIGINDEX);
- if(mask & CD_MASK_ORIGSPACE_MLOOP) {
- if(!CustomData_has_layer(&dm->loopData, CD_ORIGSPACE_MLOOP)) {
+ if (mask & CD_MASK_ORIGSPACE_MLOOP) {
+ if (!CustomData_has_layer(&dm->loopData, CD_ORIGSPACE_MLOOP)) {
DM_add_loop_layer(dm, CD_ORIGSPACE_MLOOP, CD_CALLOC, NULL);
DM_init_origspace(dm);
}
@@ -1978,7 +1991,7 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
ndm = mti->applyModifier(md, ob, dm, 0, 0);
if (ndm) {
- if(dm && dm != ndm)
+ if (dm && dm != ndm)
dm->release(dm);
dm = ndm;
@@ -1990,13 +2003,15 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
}
}
- if(cage_r && i == cageIndex) {
- if(dm && deformedVerts) {
+ if (cage_r && i == cageIndex) {
+ if (dm && deformedVerts) {
*cage_r = CDDM_copy(dm);
CDDM_apply_vert_coords(*cage_r, deformedVerts);
- } else if(dm) {
+ }
+ else if (dm) {
*cage_r = dm;
- } else {
+ }
+ else {
*cage_r =
getEditDerivedBMesh(em, ob,
deformedVerts ? MEM_dupallocN(deformedVerts) : NULL);
@@ -2010,10 +2025,10 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
* to apply these back onto the DerivedMesh. If we have no DerivedMesh
* then we need to build one.
*/
- if(dm && deformedVerts) {
+ if (dm && deformedVerts) {
*final_r = CDDM_copy(dm);
- if(!(cage_r && dm == *cage_r)) dm->release(dm);
+ if (!(cage_r && dm == *cage_r)) dm->release(dm);
CDDM_apply_vert_coords(*final_r, deformedVerts);
CDDM_calc_normals(*final_r); /* was CDDM_calc_normals_mapping - campbell */
@@ -2051,13 +2066,13 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
/* --- */
/* add an orco layer if needed */
- if(dataMask & CD_MASK_ORCO)
+ if (dataMask & CD_MASK_ORCO)
add_orco_dm(ob, em, *final_r, orcodm, CD_ORCO);
- if(orcodm)
+ if (orcodm)
orcodm->release(orcodm);
- if(deformedVerts)
+ if (deformedVerts)
MEM_freeN(deformedVerts);
}
@@ -2088,7 +2103,7 @@ static void clear_mesh_caches(Object *ob)
ob->derivedDeform= NULL;
}
- if(ob->sculpt) {
+ if (ob->sculpt) {
object_sculpt_modifiers_changed(ob);
}
}
@@ -2113,7 +2128,7 @@ static void mesh_build_data(Scene *scene, Object *ob, CustomDataMask dataMask,
ob->derivedDeform->needsFree = 0;
ob->lastDataMask = dataMask;
- if((ob->mode & OB_MODE_SCULPT) && ob->sculpt) {
+ if ((ob->mode & OB_MODE_SCULPT) && ob->sculpt) {
/* create PBVH immediately (would be created on the fly too,
but this avoids waiting on first stroke) */
ob->sculpt->pbvh= ob->derivedFinal->getPBVH(ob, ob->derivedFinal);
@@ -2150,7 +2165,8 @@ void makeDerivedMesh(Scene *scene, Object *ob, BMEditMesh *em,
{
if (em) {
editbmesh_build_data(scene, ob, em, dataMask);
- } else {
+ }
+ else {
mesh_build_data(scene, ob, dataMask, build_shapekey_layers);
}
}
@@ -2162,7 +2178,7 @@ DerivedMesh *mesh_get_derived_final(Scene *scene, Object *ob, CustomDataMask dat
/* if there's no derived mesh or the last data mask used doesn't include
* the data we need, rebuild the derived mesh
*/
- if(!ob->derivedFinal || (dataMask & ob->lastDataMask) != dataMask)
+ if (!ob->derivedFinal || (dataMask & ob->lastDataMask) != dataMask)
mesh_build_data(scene, ob, dataMask, 0);
return ob->derivedFinal;
@@ -2173,7 +2189,7 @@ DerivedMesh *mesh_get_derived_deform(Scene *scene, Object *ob, CustomDataMask da
/* if there's no derived mesh or the last data mask used doesn't include
* the data we need, rebuild the derived mesh
*/
- if(!ob->derivedDeform || (dataMask & ob->lastDataMask) != dataMask)
+ if (!ob->derivedDeform || (dataMask & ob->lastDataMask) != dataMask)
mesh_build_data(scene, ob, dataMask, 0);
return ob->derivedDeform;
@@ -2255,7 +2271,7 @@ DerivedMesh *editbmesh_get_derived_cage_and_final(Scene *scene, Object *obedit,
/* if there's no derived mesh or the last data mask used doesn't include
* the data we need, rebuild the derived mesh
*/
- if(!em->derivedCage ||
+ if (!em->derivedCage ||
(em->lastDataMask & dataMask) != dataMask)
editbmesh_build_data(scene, obedit, em, dataMask);
@@ -2268,7 +2284,7 @@ DerivedMesh *editbmesh_get_derived_cage(Scene *scene, Object *obedit, BMEditMesh
/* if there's no derived mesh or the last data mask used doesn't include
* the data we need, rebuild the derived mesh
*/
- if(!em->derivedCage ||
+ if (!em->derivedCage ||
(em->lastDataMask & dataMask) != dataMask)
editbmesh_build_data(scene, obedit, em, dataMask);
@@ -2290,11 +2306,11 @@ static void make_vertexcosnos__mapFunc(void *userData, int index, float *co, flo
vec+= 6*index;
/* check if we've been here before (normal should not be 0) */
- if(vec[3] || vec[4] || vec[5]) return;
+ if (vec[3] || vec[4] || vec[5]) return;
copy_v3_v3(vec, co);
vec+= 3;
- if(no_f) {
+ if (no_f) {
copy_v3_v3(vec, no_f);
}
else {
@@ -2314,20 +2330,20 @@ float *mesh_get_mapped_verts_nors(Scene *scene, Object *ob)
float *vertexcosnos;
/* lets prevent crashing... */
- if(ob->type!=OB_MESH || me->totvert==0)
+ if (ob->type!=OB_MESH || me->totvert==0)
return NULL;
dm= mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH|CD_MASK_ORIGINDEX);
vertexcosnos= MEM_callocN(6*sizeof(float)*me->totvert, "vertexcosnos map");
- if(dm->foreachMappedVert) {
+ if (dm->foreachMappedVert) {
dm->foreachMappedVert(dm, make_vertexcosnos__mapFunc, vertexcosnos);
}
else {
float *fp= vertexcosnos;
int a;
- for(a=0; a< me->totvert; a++, fp+=6) {
+ for (a=0; a< me->totvert; a++, fp+=6) {
dm->getVertCo(dm, a, fp);
dm->getVertNo(dm, a, fp+3);
}
@@ -2379,7 +2395,7 @@ static void GetTextureCoordinate(const SMikkTSpaceContext * pContext, float fUV[
//assert(vert_index>=0 && vert_index<4);
SGLSLMeshToTangent * pMesh = (SGLSLMeshToTangent *) pContext->m_pUserData;
- if(pMesh->mtface!=NULL) {
+ if (pMesh->mtface!=NULL) {
float * uv = pMesh->mtface[face_num].uv[vert_index];
fUV[0]=uv[0]; fUV[1]=uv[1];
}
@@ -2395,8 +2411,8 @@ static void GetNormal(const SMikkTSpaceContext * pContext, float fNorm[], const
SGLSLMeshToTangent * pMesh = (SGLSLMeshToTangent *) pContext->m_pUserData;
const int smoothnormal = (pMesh->mface[face_num].flag & ME_SMOOTH);
- if(!smoothnormal) { // flat
- if(pMesh->precomputedFaceNormals) {
+ if (!smoothnormal) { // flat
+ if (pMesh->precomputedFaceNormals) {
copy_v3_v3(fNorm, &pMesh->precomputedFaceNormals[3*face_num]);
}
else {
@@ -2405,7 +2421,7 @@ static void GetNormal(const SMikkTSpaceContext * pContext, float fNorm[], const
float *p1= pMesh->mvert[mf->v2].co;
float *p2= pMesh->mvert[mf->v3].co;
- if(mf->v4) {
+ if (mf->v4) {
float *p3 = pMesh->mvert[mf->v4].co;
normal_quad_v3(fNorm, p0, p1, p2, p3);
}
@@ -2443,7 +2459,7 @@ void DM_add_tangent_layer(DerivedMesh *dm)
int i, j, len, mf_vi[4], totvert, totface, iCalcNewMethod;
float *nors;
- if(CustomData_get_layer_index(&dm->faceData, CD_TANGENT) != -1)
+ if (CustomData_get_layer_index(&dm->faceData, CD_TANGENT) != -1)
return;
nors = dm->getTessFaceDataArray(dm, CD_NORMAL);
@@ -2456,9 +2472,9 @@ void DM_add_tangent_layer(DerivedMesh *dm)
mface= dm->getTessFaceArray(dm);
mtface= dm->getTessFaceDataArray(dm, CD_MTFACE);
- if(!mtface) {
+ if (!mtface) {
orco= dm->getVertDataArray(dm, CD_ORCO);
- if(!orco)
+ if (!orco)
return;
}
@@ -2473,7 +2489,7 @@ void DM_add_tangent_layer(DerivedMesh *dm)
// new computation method
iCalcNewMethod = 1;
- if(iCalcNewMethod != 0) {
+ if (iCalcNewMethod != 0) {
SGLSLMeshToTangent mesh2tangent= {0};
SMikkTSpaceContext sContext= {0};
SMikkTSpaceInterface sInterface= {0};
@@ -2499,9 +2515,9 @@ void DM_add_tangent_layer(DerivedMesh *dm)
iCalcNewMethod = genTangSpaceDefault(&sContext);
}
- if(!iCalcNewMethod) {
+ if (!iCalcNewMethod) {
/* sum tangents at connected vertices */
- for(i=0, tf=mtface, mf=mface; i < totface; mf++, tf++, i++) {
+ for (i=0, tf=mtface, mf=mface; i < totface; mf++, tf++, i++) {
v1= &mvert[mf->v1];
v2= &mvert[mf->v2];
v3= &mvert[mf->v3];
@@ -2515,7 +2531,7 @@ void DM_add_tangent_layer(DerivedMesh *dm)
normal_tri_v3( fno,v3->co, v2->co, v1->co);
}
- if(mtface) {
+ if (mtface) {
uv1= tf->uv[0];
uv2= tf->uv[1];
uv3= tf->uv[2];
@@ -2526,7 +2542,7 @@ void DM_add_tangent_layer(DerivedMesh *dm)
map_to_sphere( &uv[0][0], &uv[0][1],orco[mf->v1][0], orco[mf->v1][1], orco[mf->v1][2]);
map_to_sphere( &uv[1][0], &uv[1][1],orco[mf->v2][0], orco[mf->v2][1], orco[mf->v2][2]);
map_to_sphere( &uv[2][0], &uv[2][1],orco[mf->v3][0], orco[mf->v3][1], orco[mf->v3][2]);
- if(v4)
+ if (v4)
map_to_sphere( &uv[3][0], &uv[3][1],orco[mf->v4][0], orco[mf->v4][1], orco[mf->v4][2]);
}
@@ -2535,7 +2551,7 @@ void DM_add_tangent_layer(DerivedMesh *dm)
sum_or_add_vertex_tangent(arena, &vtangents[mf->v2], tang, uv2);
sum_or_add_vertex_tangent(arena, &vtangents[mf->v3], tang, uv3);
- if(mf->v4) {
+ if (mf->v4) {
v4= &mvert[mf->v4];
tangent_from_uv(uv1, uv3, uv4, v1->co, v3->co, v4->co, fno, tang);
@@ -2546,14 +2562,14 @@ void DM_add_tangent_layer(DerivedMesh *dm)
}
/* write tangent to layer */
- for(i=0, tf=mtface, mf=mface; i < totface; mf++, tf++, i++, tangent+=4) {
+ for (i=0, tf=mtface, mf=mface; i < totface; mf++, tf++, i++, tangent+=4) {
len= (mf->v4)? 4 : 3;
- if(mtface == NULL) {
+ if (mtface == NULL) {
map_to_sphere( &uv[0][0], &uv[0][1],orco[mf->v1][0], orco[mf->v1][1], orco[mf->v1][2]);
map_to_sphere( &uv[1][0], &uv[1][1],orco[mf->v2][0], orco[mf->v2][1], orco[mf->v2][2]);
map_to_sphere( &uv[2][0], &uv[2][1],orco[mf->v3][0], orco[mf->v3][1], orco[mf->v3][2]);
- if(len==4)
+ if (len==4)
map_to_sphere( &uv[3][0], &uv[3][1],orco[mf->v4][0], orco[mf->v4][1], orco[mf->v4][2]);
}
@@ -2562,7 +2578,7 @@ void DM_add_tangent_layer(DerivedMesh *dm)
mf_vi[2]= mf->v3;
mf_vi[3]= mf->v4;
- for(j=0; j<len; j++) {
+ for (j=0; j<len; j++) {
vtang= find_vertex_tangent(vtangents[mf_vi[j]], mtface ? tf->uv[j] : uv[j]);
normalize_v3_v3(tangent[j], vtang);
((float *) tangent[j])[3]=1.0f;
@@ -2583,7 +2599,7 @@ void DM_calc_auto_bump_scale(DerivedMesh *dm)
MFace * mface = dm->getTessFaceArray(dm);
MTFace * mtface = dm->getTessFaceDataArray(dm, CD_MTFACE);
- if(mtface) {
+ if (mtface) {
double dsum = 0.0;
int nr_accumulated = 0;
int f;
@@ -2603,7 +2619,7 @@ void DM_calc_auto_bump_scale(DerivedMesh *dm)
// discard degenerate faces
is_degenerate = 0;
- if( equals_v3v3(verts[0], verts[1]) || equals_v3v3(verts[0], verts[2]) || equals_v3v3(verts[1], verts[2]) ||
+ if ( equals_v3v3(verts[0], verts[1]) || equals_v3v3(verts[0], verts[2]) || equals_v3v3(verts[1], verts[2]) ||
equals_v2v2(tex_coords[0], tex_coords[1]) || equals_v2v2(tex_coords[0], tex_coords[2]) || equals_v2v2(tex_coords[1], tex_coords[2]) )
{
is_degenerate = 1;
@@ -2632,7 +2648,7 @@ void DM_calc_auto_bump_scale(DerivedMesh *dm)
if (i == 0 ) {
is_signed = (signed_area < 0.0f) ? 1 : 0;
}
- else if((is_signed != 0) != (signed_area < 0.0f)) {
+ else if ((is_signed != 0) != (signed_area < 0.0f)) {
is_degenerate = 1;
}
@@ -2657,10 +2673,10 @@ void DM_calc_auto_bump_scale(DerivedMesh *dm)
sub_v3_v3v3(vtmp, verts[3], verts[1]);
pos_len_diag1 = dot_v3v3(vtmp, vtmp);
- if(pos_len_diag1<pos_len_diag0) {
+ if (pos_len_diag1<pos_len_diag0) {
offs=1; // alter split
}
- else if(pos_len_diag0==pos_len_diag1) { /* do UV check instead */
+ else if (pos_len_diag0==pos_len_diag1) { /* do UV check instead */
float tex_len_diag0, tex_len_diag1;
sub_v2_v2v2(vtmp, tex_coords[2], tex_coords[0]);
@@ -2733,25 +2749,25 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs,
fdata = tfdata = dm->getTessFaceDataLayout(dm);
/* calc auto bump scale if necessary */
- if(dm->auto_bump_scale<=0.0f)
+ if (dm->auto_bump_scale<=0.0f)
DM_calc_auto_bump_scale(dm);
/* add a tangent layer if necessary */
- for(b = 0; b < gattribs->totlayer; b++)
- if(gattribs->layer[b].type == CD_TANGENT)
- if(CustomData_get_layer_index(fdata, CD_TANGENT) == -1)
+ for (b = 0; b < gattribs->totlayer; b++)
+ if (gattribs->layer[b].type == CD_TANGENT)
+ if (CustomData_get_layer_index(fdata, CD_TANGENT) == -1)
DM_add_tangent_layer(dm);
- for(b = 0; b < gattribs->totlayer; b++) {
- if(gattribs->layer[b].type == CD_MTFACE) {
+ for (b = 0; b < gattribs->totlayer; b++) {
+ if (gattribs->layer[b].type == CD_MTFACE) {
/* uv coordinates */
- if(gattribs->layer[b].name[0])
+ if (gattribs->layer[b].name[0])
layer = CustomData_get_named_layer_index(tfdata, CD_MTFACE,
gattribs->layer[b].name);
else
layer = CustomData_get_active_layer_index(tfdata, CD_MTFACE);
- if(layer != -1) {
+ if (layer != -1) {
a = attribs->tottface++;
attribs->tface[a].array = tfdata->layers[layer].data;
@@ -2765,7 +2781,7 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs,
int player;
CustomData *pdata = dm->getPolyDataLayout(dm);
- if(gattribs->layer[b].name[0])
+ if (gattribs->layer[b].name[0])
player = CustomData_get_named_layer_index(pdata, CD_MTEXPOLY,
gattribs->layer[b].name);
else
@@ -2783,15 +2799,15 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs,
}
#endif
}
- else if(gattribs->layer[b].type == CD_MCOL) {
+ else if (gattribs->layer[b].type == CD_MCOL) {
/* vertex colors */
- if(gattribs->layer[b].name[0])
+ if (gattribs->layer[b].name[0])
layer = CustomData_get_named_layer_index(tfdata, CD_MCOL,
gattribs->layer[b].name);
else
layer = CustomData_get_active_layer_index(tfdata, CD_MCOL);
- if(layer != -1) {
+ if (layer != -1) {
a = attribs->totmcol++;
attribs->mcol[a].array = tfdata->layers[layer].data;
@@ -2799,11 +2815,11 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs,
attribs->mcol[a].glIndex = gattribs->layer[b].glindex;
}
}
- else if(gattribs->layer[b].type == CD_TANGENT) {
+ else if (gattribs->layer[b].type == CD_TANGENT) {
/* tangents */
layer = CustomData_get_layer_index(fdata, CD_TANGENT);
- if(layer != -1) {
+ if (layer != -1) {
attribs->tottang = 1;
attribs->tang.array = fdata->layers[layer].data;
@@ -2811,11 +2827,11 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs,
attribs->tang.glIndex = gattribs->layer[b].glindex;
}
}
- else if(gattribs->layer[b].type == CD_ORCO) {
+ else if (gattribs->layer[b].type == CD_ORCO) {
/* original coordinates */
layer = CustomData_get_layer_index(vdata, CD_ORCO);
- if(layer != -1) {
+ if (layer != -1) {
attribs->totorco = 1;
attribs->orco.array = vdata->layers[layer].data;
@@ -2836,7 +2852,7 @@ void DM_set_object_boundbox(Object *ob, DerivedMesh *dm)
dm->getMinMax(dm, min, max);
- if(!ob->bb)
+ if (!ob->bb)
ob->bb= MEM_callocN(sizeof(BoundBox), "DM-BoundBox");
boundbox_set_from_min_max(ob->bb, min, max);
@@ -2894,7 +2910,7 @@ static void navmesh_drawColored(DerivedMesh *dm)
DEBUG_VBO( "Using legacy code. drawNavMeshColored\n" );
//glShadeModel(GL_SMOOTH);
glBegin(glmode = GL_QUADS);
- for(a = 0; a < dm->numTessFaceData; a++, mface++) {
+ for (a = 0; a < dm->numTessFaceData; a++, mface++) {
int new_glmode = mface->v4?GL_QUADS:GL_TRIANGLES;
int pi = polygonIdx[a];
if (pi <= 0) {
@@ -2904,7 +2920,7 @@ static void navmesh_drawColored(DerivedMesh *dm)
navmesh_intToCol(pi, col);
}
- if(new_glmode != glmode) {
+ if (new_glmode != glmode) {
glEnd();
glBegin(glmode = new_glmode);
}
@@ -2912,7 +2928,7 @@ static void navmesh_drawColored(DerivedMesh *dm)
glVertex3fv(mvert[mface->v1].co);
glVertex3fv(mvert[mface->v2].co);
glVertex3fv(mvert[mface->v3].co);
- if(mface->v4) {
+ if (mface->v4) {
glVertex3fv(mvert[mface->v4].co);
}
}
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index dcd4a712dbb..b78a11185cc 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -415,7 +415,7 @@ bPoseChannel *get_pose_channel(const bPose *pose, const char *name)
if (ELEM(NULL, pose, name) || (name[0] == 0))
return NULL;
- if(pose->chanhash)
+ if (pose->chanhash)
return BLI_ghash_lookup(pose->chanhash, (void *)name);
return BLI_findstring(&((bPose *)pose)->chanbase, name, offsetof(bPoseChannel, name));
@@ -432,7 +432,7 @@ bPoseChannel *verify_pose_channel(bPose *pose, const char *name)
/* See if this channel exists */
chan= BLI_findstring(&pose->chanbase, name, offsetof(bPoseChannel, name));
- if(chan) {
+ if (chan) {
return chan;
}
@@ -523,7 +523,7 @@ void copy_pose (bPose **dst, bPose *src, int copycon)
pchan->mpath= NULL; /* motion paths should not get copied yet... */
}
- if(pchan->prop) {
+ if (pchan->prop) {
pchan->prop= IDP_CopyProperty(pchan->prop);
}
}
@@ -570,18 +570,18 @@ void init_pose_ikparam(bPose *pose)
void make_pose_channels_hash(bPose *pose)
{
- if(!pose->chanhash) {
+ if (!pose->chanhash) {
bPoseChannel *pchan;
pose->chanhash= BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "make_pose_chan gh");
- for(pchan=pose->chanbase.first; pchan; pchan=pchan->next)
+ for (pchan=pose->chanbase.first; pchan; pchan=pchan->next)
BLI_ghash_insert(pose->chanhash, pchan->name, pchan);
}
}
void free_pose_channels_hash(bPose *pose)
{
- if(pose->chanhash) {
+ if (pose->chanhash) {
BLI_ghash_free(pose->chanhash, NULL, NULL);
pose->chanhash= NULL;
}
@@ -656,7 +656,7 @@ static void copy_pose_channel_data(bPoseChannel *pchan, const bPoseChannel *chan
pchan->flag= chan->flag;
con= chan->constraints.first;
- for(pcon= pchan->constraints.first; pcon && con; pcon= pcon->next, con= con->next) {
+ for (pcon= pchan->constraints.first; pcon && con; pcon= pcon->next, con= con->next) {
pcon->enforce= con->enforce;
pcon->headtail= con->headtail;
}
@@ -689,13 +689,13 @@ void duplicate_pose_channel_data(bPoseChannel *pchan, const bPoseChannel *pchan_
copy_constraints(&pchan->constraints, &pchan_from->constraints, TRUE);
/* id-properties */
- if(pchan->prop) {
+ if (pchan->prop) {
/* unlikely but possible it exists */
IDP_FreeProperty(pchan->prop);
MEM_freeN(pchan->prop);
pchan->prop= NULL;
}
- if(pchan_from->prop) {
+ if (pchan_from->prop) {
pchan->prop= IDP_CopyProperty(pchan_from->prop);
}
@@ -727,19 +727,19 @@ void update_pose_constraint_flags(bPose *pose)
pchan->constflag |= PCHAN_HAS_IK;
- if(data->tar==NULL || (data->tar->type==OB_ARMATURE && data->subtarget[0]==0))
+ if (data->tar==NULL || (data->tar->type==OB_ARMATURE && data->subtarget[0]==0))
pchan->constflag |= PCHAN_HAS_TARGET;
/* negative rootbone = recalc rootbone index. used in do_versions */
- if(data->rootbone<0) {
+ if (data->rootbone<0) {
data->rootbone= 0;
- if(data->flag & CONSTRAINT_IK_TIP) parchan= pchan;
+ if (data->flag & CONSTRAINT_IK_TIP) parchan= pchan;
else parchan= pchan->parent;
- while(parchan) {
+ while (parchan) {
data->rootbone++;
- if((parchan->bone->flag & BONE_CONNECTED)==0)
+ if ((parchan->bone->flag & BONE_CONNECTED)==0)
break;
parchan= parchan->parent;
}
@@ -837,7 +837,7 @@ void pose_remove_group (Object *ob)
/* now, remove it from the pose */
BLI_freelinkN(&pose->agroups, grp);
pose->active_group--;
- if(pose->active_group < 0 || pose->agroups.first == NULL) {
+ if (pose->active_group < 0 || pose->agroups.first == NULL) {
pose->active_group= 0;
}
}
@@ -932,7 +932,7 @@ void calc_action_range(const bAction *act, float *start, float *end, short incl_
}
if (foundvert || foundmod) {
- if(min==max) max+= 1.0f;
+ if (min==max) max+= 1.0f;
*start= min;
*end= max;
}
@@ -1097,7 +1097,7 @@ void copy_pose_result(bPose *to, bPose *from)
{
bPoseChannel *pchanto, *pchanfrom;
- if(to==NULL || from==NULL) {
+ if (to==NULL || from==NULL) {
printf("pose result copy error to:%p from:%p\n", (void *)to, (void *)from); // debug temp
return;
}
@@ -1108,9 +1108,9 @@ void copy_pose_result(bPose *to, bPose *from)
}
- for(pchanfrom= from->chanbase.first; pchanfrom; pchanfrom= pchanfrom->next) {
+ for (pchanfrom= from->chanbase.first; pchanfrom; pchanfrom= pchanfrom->next) {
pchanto= get_pose_channel(to, pchanfrom->name);
- if(pchanto) {
+ if (pchanto) {
copy_m4_m4(pchanto->pose_mat, pchanfrom->pose_mat);
copy_m4_m4(pchanto->chan_mat, pchanfrom->chan_mat);
@@ -1237,15 +1237,15 @@ static void blend_pose_offset_bone(bActionStrip *strip, bPose *dst, bPose *src,
/* matching offset bones */
/* take dst offset, and put src on on that location */
- if(strip->offs_bone[0]==0)
+ if (strip->offs_bone[0]==0)
return;
/* are we also blending with matching bones? */
- if(strip->prev && strip->start>=strip->prev->start) {
+ if (strip->prev && strip->start>=strip->prev->start) {
bPoseChannel *dpchan= get_pose_channel(dst, strip->offs_bone);
- if(dpchan) {
+ if (dpchan) {
bPoseChannel *spchan= get_pose_channel(src, strip->offs_bone);
- if(spchan) {
+ if (spchan) {
float vec[3];
/* dst->ctime has the internal strip->prev action time */
@@ -1253,7 +1253,7 @@ static void blend_pose_offset_bone(bActionStrip *strip, bPose *dst, bPose *src,
float ctime= get_actionstrip_frame(strip, src->ctime, 1);
- if( ctime > strip->prev->end) {
+ if ( ctime > strip->prev->end) {
bActionChannel *achan;
/* add src to dest, minus the position of src on strip->prev->end */
@@ -1261,7 +1261,7 @@ static void blend_pose_offset_bone(bActionStrip *strip, bPose *dst, bPose *src,
ctime= get_actionstrip_frame(strip, strip->prev->end, 0);
achan= get_action_channel(strip->act, strip->offs_bone);
- if(achan && achan->ipo) {
+ if (achan && achan->ipo) {
bPoseChannel pchan;
/* Evaluates and sets the internal ipo value */
calc_ipo(achan->ipo, ctime);
@@ -1302,19 +1302,19 @@ static float stridechannel_frame(Object *ob, float sizecorr, bActionStrip *strip
bActionChannel *achan= get_action_channel(act, name);
int stride_axis= strip->stride_axis;
- if(achan && achan->ipo) {
+ if (achan && achan->ipo) {
IpoCurve *icu= NULL;
float minx=0.0f, maxx=0.0f, miny=0.0f, maxy=0.0f;
int foundvert= 0;
- if(stride_axis==0) stride_axis= AC_LOC_X;
- else if(stride_axis==1) stride_axis= AC_LOC_Y;
+ if (stride_axis==0) stride_axis= AC_LOC_X;
+ else if (stride_axis==1) stride_axis= AC_LOC_Y;
else stride_axis= AC_LOC_Z;
/* calculate the min/max */
for (icu=achan->ipo->curve.first; icu; icu=icu->next) {
- if(icu->adrcode==stride_axis) {
- if(icu->totvert>1) {
+ if (icu->adrcode==stride_axis) {
+ if (icu->totvert>1) {
foundvert= 1;
minx= icu->bezt[0].vec[1][0];
maxx= icu->bezt[icu->totvert-1].vec[1][0];
@@ -1326,7 +1326,7 @@ static float stridechannel_frame(Object *ob, float sizecorr, bActionStrip *strip
}
}
- if(foundvert && miny!=maxy) {
+ if (foundvert && miny!=maxy) {
float stridelen= sizecorr*fabs(maxy-miny), striptime;
float actiondist, pdist, pdistNewNormalized, offs;
float vec1[4], vec2[4], dir[3];
@@ -1366,10 +1366,10 @@ static float stridechannel_frame(Object *ob, float sizecorr, bActionStrip *strip
static void cyclic_offs_bone(Object *ob, bPose *pose, bActionStrip *strip, float time)
{
/* only called when strip has cyclic, so >= 1.0f works... */
- if(time >= 1.0f) {
+ if (time >= 1.0f) {
bActionChannel *achan= get_action_channel(strip->act, strip->offs_bone);
- if(achan && achan->ipo) {
+ if (achan && achan->ipo) {
IpoCurve *icu= NULL;
Bone *bone;
float min[3]={0.0f, 0.0f, 0.0f}, max[3]={0.0f, 0.0f, 0.0f};
@@ -1377,13 +1377,13 @@ static void cyclic_offs_bone(Object *ob, bPose *pose, bActionStrip *strip, float
/* calculate the min/max */
for (icu=achan->ipo->curve.first; icu; icu=icu->next) {
- if(icu->totvert>1) {
+ if (icu->totvert>1) {
- if(icu->adrcode==AC_LOC_X)
+ if (icu->adrcode==AC_LOC_X)
index= 0;
- else if(icu->adrcode==AC_LOC_Y)
+ else if (icu->adrcode==AC_LOC_Y)
index= 1;
- else if(icu->adrcode==AC_LOC_Z)
+ else if (icu->adrcode==AC_LOC_Z)
index= 2;
else
continue;
@@ -1393,11 +1393,11 @@ static void cyclic_offs_bone(Object *ob, bPose *pose, bActionStrip *strip, float
max[index]= icu->bezt[icu->totvert-1].vec[1][1];
}
}
- if(foundvert) {
+ if (foundvert) {
/* bring it into armature space */
sub_v3_v3v3(min, max, min);
bone= get_named_bone(ob->data, strip->offs_bone); /* weak */
- if(bone) {
+ if (bone) {
mul_mat3_m4_v3(bone->arm_mat, min);
/* dominant motion, cyclic_offset was cleared in rest_pose */
@@ -1405,10 +1405,11 @@ static void cyclic_offs_bone(Object *ob, bPose *pose, bActionStrip *strip, float
if (strip->flag & ACTSTRIP_CYCLIC_USEX) pose->cyclic_offset[0]= time*min[0];
if (strip->flag & ACTSTRIP_CYCLIC_USEY) pose->cyclic_offset[1]= time*min[1];
if (strip->flag & ACTSTRIP_CYCLIC_USEZ) pose->cyclic_offset[2]= time*min[2];
- } else {
- if( fabs(min[0]) >= fabs(min[1]) && fabs(min[0]) >= fabs(min[2]))
+ }
+ else {
+ if ( fabs(min[0]) >= fabs(min[1]) && fabs(min[0]) >= fabs(min[2]))
pose->cyclic_offset[0]= time*min[0];
- else if( fabs(min[1]) >= fabs(min[0]) && fabs(min[1]) >= fabs(min[2]))
+ else if ( fabs(min[1]) >= fabs(min[0]) && fabs(min[1]) >= fabs(min[2]))
pose->cyclic_offset[1]= time*min[1];
else
pose->cyclic_offset[2]= time*min[2];
@@ -1425,12 +1426,12 @@ static Object *get_parent_path(Object *ob)
{
bConstraint *con;
- if(ob->parent && ob->parent->type==OB_CURVE)
+ if (ob->parent && ob->parent->type==OB_CURVE)
return ob->parent;
for (con = ob->constraints.first; con; con=con->next) {
- if(con->type==CONSTRAINT_TYPE_FOLLOWPATH) {
- if(con->enforce>0.5f) {
+ if (con->type==CONSTRAINT_TYPE_FOLLOWPATH) {
+ if (con->enforce>0.5f) {
bFollowPathConstraint *data= con->data;
return data->tar;
}
@@ -1454,7 +1455,7 @@ static void do_nla(Scene *scene, Object *ob, int blocktype)
float scene_cfra= BKE_curframe(scene);
int doit, dostride;
- if(blocktype==ID_AR) {
+ if (blocktype==ID_AR) {
copy_pose(&tpose, ob->pose, 1);
rest_pose(ob->pose); // potentially destroying current not-keyed pose
}
@@ -1465,25 +1466,25 @@ static void do_nla(Scene *scene, Object *ob, int blocktype)
/* check on extend to left or right, when no strip is hit by 'cfra' */
for (strip=ob->nlastrips.first; strip; strip=strip->next) {
/* escape loop on a hit */
- if( scene_cfra >= strip->start && scene_cfra <= strip->end + 0.1f) /* note 0.1 comes back below */
+ if ( scene_cfra >= strip->start && scene_cfra <= strip->end + 0.1f) /* note 0.1 comes back below */
break;
- if(scene_cfra < strip->start) {
- if(stripfirst==NULL)
+ if (scene_cfra < strip->start) {
+ if (stripfirst==NULL)
stripfirst= strip;
- else if(stripfirst->start > strip->start)
+ else if (stripfirst->start > strip->start)
stripfirst= strip;
}
- else if(scene_cfra > strip->end) {
- if(striplast==NULL)
+ else if (scene_cfra > strip->end) {
+ if (striplast==NULL)
striplast= strip;
- else if(striplast->end < strip->end)
+ else if (striplast->end < strip->end)
striplast= strip;
}
}
- if(strip==NULL) { /* extend */
- if(striplast)
+ if (strip==NULL) { /* extend */
+ if (striplast)
scene_cfra= striplast->end;
- else if(stripfirst)
+ else if (stripfirst)
scene_cfra= stripfirst->start;
}
@@ -1501,7 +1502,7 @@ static void do_nla(Scene *scene, Object *ob, int blocktype)
if (striptime>=0.0) {
- if(blocktype==ID_AR)
+ if (blocktype==ID_AR)
rest_pose(tpose);
/* To handle repeat, we add 0.1 frame extra to make sure the last frame is included */
@@ -1517,20 +1518,20 @@ static void do_nla(Scene *scene, Object *ob, int blocktype)
if (cu->flag & CU_PATH) {
/* Ensure we have a valid path */
- if(cu->path==NULL || cu->path->data==NULL) makeDispListCurveTypes(scene, parent, 0);
- if(cu->path) {
+ if (cu->path==NULL || cu->path->data==NULL) makeDispListCurveTypes(scene, parent, 0);
+ if (cu->path) {
/* Find the position on the path */
ctime= bsystem_time(scene, ob, scene_cfra, 0.0);
- if(calc_ipo_spec(cu->ipo, CU_SPEED, &ctime)==0) {
+ if (calc_ipo_spec(cu->ipo, CU_SPEED, &ctime)==0) {
/* correct for actions not starting on zero */
ctime= (ctime - strip->actstart)/cu->pathlen;
CLAMP(ctime, 0.0, 1.0);
}
pdist = ctime*cu->path->totdist;
- if(tpose && strip->stridechannel[0]) {
+ if (tpose && strip->stridechannel[0]) {
striptime= stridechannel_frame(parent, ob->size[0], strip, cu->path, pdist, tpose->stride_offset);
}
else {
@@ -1545,12 +1546,12 @@ static void do_nla(Scene *scene, Object *ob, int blocktype)
frametime = (striptime * actlength) + strip->actstart;
frametime= bsystem_time(scene, ob, frametime, 0.0);
- if(blocktype==ID_AR) {
+ if (blocktype==ID_AR) {
extract_pose_from_action (tpose, strip->act, frametime);
}
- else if(blocktype==ID_OB) {
+ else if (blocktype==ID_OB) {
extract_ipochannels_from_action(&tchanbase, &ob->id, strip->act, "Object", frametime);
- if(key)
+ if (key)
extract_ipochannels_from_action(&tchanbase, &key->id, strip->act, "Shape", frametime);
}
doit=dostride= 1;
@@ -1562,25 +1563,25 @@ static void do_nla(Scene *scene, Object *ob, int blocktype)
else {
/* Mod to repeat */
- if(strip->repeat!=1.0f) {
+ if (strip->repeat!=1.0f) {
float cycle= striptime*strip->repeat;
striptime = (float)fmod (cycle, 1.0f + 0.1f/length);
cycle-= striptime;
- if(blocktype==ID_AR)
+ if (blocktype==ID_AR)
cyclic_offs_bone(ob, tpose, strip, cycle);
}
frametime = (striptime * actlength) + strip->actstart;
frametime= nla_time(scene, frametime, (float)strip->repeat);
- if(blocktype==ID_AR) {
+ if (blocktype==ID_AR) {
extract_pose_from_action (tpose, strip->act, frametime);
}
- else if(blocktype==ID_OB) {
+ else if (blocktype==ID_OB) {
extract_ipochannels_from_action(&tchanbase, &ob->id, strip->act, "Object", frametime);
- if(key)
+ if (key)
extract_ipochannels_from_action(&tchanbase, &key->id, strip->act, "Shape", frametime);
}
@@ -1593,20 +1594,20 @@ static void do_nla(Scene *scene, Object *ob, int blocktype)
/* we want the strip to hold on the exact fraction of the repeat value */
frametime = actlength * (strip->repeat-(int)strip->repeat);
- if(frametime<=0.000001f) frametime= actlength; /* rounding errors... */
+ if (frametime<=0.000001f) frametime= actlength; /* rounding errors... */
frametime= bsystem_time(scene, ob, frametime+strip->actstart, 0.0);
- if(blocktype==ID_AR)
+ if (blocktype==ID_AR)
extract_pose_from_action (tpose, strip->act, frametime);
- else if(blocktype==ID_OB) {
+ else if (blocktype==ID_OB) {
extract_ipochannels_from_action(&tchanbase, &ob->id, strip->act, "Object", frametime);
- if(key)
+ if (key)
extract_ipochannels_from_action(&tchanbase, &key->id, strip->act, "Shape", frametime);
}
/* handle cycle hold */
- if(strip->repeat!=1.0f) {
- if(blocktype==ID_AR)
+ if (strip->repeat!=1.0f) {
+ if (blocktype==ID_AR)
cyclic_offs_bone(ob, tpose, strip, strip->repeat-1.0f);
}
@@ -1627,12 +1628,12 @@ static void do_nla(Scene *scene, Object *ob, int blocktype)
else
blendfac = 1;
- if(blocktype==ID_AR) {/* Blend this pose with the accumulated pose */
+ if (blocktype==ID_AR) {/* Blend this pose with the accumulated pose */
/* offset bone, for matching cycles */
blend_pose_offset_bone (strip, ob->pose, tpose, blendfac, strip->mode);
blend_poses (ob->pose, tpose, blendfac, strip->mode);
- if(dostride)
+ if (dostride)
blend_pose_strides (ob->pose, tpose, blendfac, strip->mode);
}
else {
@@ -1644,10 +1645,10 @@ static void do_nla(Scene *scene, Object *ob, int blocktype)
}
}
- if(blocktype==ID_OB) {
+ if (blocktype==ID_OB) {
execute_ipochannels(&chanbase);
}
- else if(blocktype==ID_AR) {
+ else if (blocktype==ID_AR) {
/* apply stride offset to object */
add_v3_v3(ob->obmat[3], ob->pose->stride_offset);
}
@@ -1655,7 +1656,7 @@ static void do_nla(Scene *scene, Object *ob, int blocktype)
/* free */
if (tpose)
free_pose(tpose);
- if(chanbase.first)
+ if (chanbase.first)
BLI_freelistN(&chanbase);
}
diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c
index 48d863150bc..19c4a654f9c 100644
--- a/source/blender/blenkernel/intern/anim.c
+++ b/source/blender/blenkernel/intern/anim.c
@@ -456,7 +456,7 @@ void animviz_calc_motionpaths(Scene *scene, ListBase *targets)
*/
void free_path(Path *path)
{
- if(path->data) MEM_freeN(path->data);
+ if (path->data) MEM_freeN(path->data);
MEM_freeN(path);
}
@@ -479,29 +479,29 @@ void calc_curvepath(Object *ob)
/* in a path vertices are with equal differences: path->len = number of verts */
/* NOW WITH BEVELCURVE!!! */
- if(ob==NULL || ob->type != OB_CURVE) return;
+ if (ob==NULL || ob->type != OB_CURVE) return;
cu= ob->data;
nurbs= BKE_curve_nurbs(cu);
nu= nurbs->first;
- if(cu->path) free_path(cu->path);
+ if (cu->path) free_path(cu->path);
cu->path= NULL;
bl= cu->bev.first;
- if(bl==NULL || !bl->nr) return;
+ if (bl==NULL || !bl->nr) return;
cu->path=path= MEM_callocN(sizeof(Path), "calc_curvepath");
/* if POLY: last vertice != first vertice */
cycl= (bl->poly!= -1);
- if(cycl) tot= bl->nr;
+ if (cycl) tot= bl->nr;
else tot= bl->nr-1;
path->len= tot+1;
/* exception: vector handle paths and polygon paths should be subdivided at least a factor resolu */
- if(path->len<nu->resolu*SEGMENTSU(nu)) path->len= nu->resolu*SEGMENTSU(nu);
+ if (path->len<nu->resolu*SEGMENTSU(nu)) path->len= nu->resolu*SEGMENTSU(nu);
dist= (float *)MEM_mallocN((tot+1)*4, "calcpathdist");
@@ -509,9 +509,9 @@ void calc_curvepath(Object *ob)
bevp= bevpfirst= (BevPoint *)(bl+1);
fp= dist;
*fp= 0;
- for(a=0; a<tot; a++) {
+ for (a=0; a<tot; a++) {
fp++;
- if(cycl && a==tot-1)
+ if (cycl && a==tot-1)
sub_v3_v3v3(xyz, bevpfirst->vec, bevp->vec);
else
sub_v3_v3v3(xyz, (bevp+1)->vec, bevp->vec);
@@ -534,17 +534,17 @@ void calc_curvepath(Object *ob)
fac= 1.0f/((float)path->len-1.0f);
fac = fac * path->totdist;
- for(a=0; a<path->len; a++) {
+ for (a=0; a<path->len; a++) {
d= ((float)a)*fac;
/* we're looking for location (distance) 'd' in the array */
- while((d>= *fp) && fp<maxdist) {
+ while ((d>= *fp) && fp<maxdist) {
fp++;
- if(bevp<bevplast) bevp++;
+ if (bevp<bevplast) bevp++;
bevpn= bevp+1;
- if(bevpn>bevplast) {
- if(cycl) bevpn= bevpfirst;
+ if (bevpn>bevplast) {
+ if (cycl) bevpn= bevpfirst;
else bevpn= bevplast;
}
}
@@ -571,15 +571,15 @@ void calc_curvepath(Object *ob)
/* is this only used internally?*/
int interval_test(int min, int max, int p1, int cycl)
{
- if(cycl) {
- if(p1 < min)
+ if (cycl) {
+ if (p1 < min)
p1= ((p1 -min) % (max-min+1)) + max+1;
- else if(p1 > max)
+ else if (p1 > max)
p1= ((p1 -min) % (max-min+1)) + min;
}
else {
- if(p1 < min) p1= min;
- else if(p1 > max) p1= max;
+ if (p1 < min) p1= min;
+ else if (p1 > max) p1= max;
}
return p1;
}
@@ -603,9 +603,9 @@ int where_on_path(Object *ob, float ctime, float vec[4], float dir[3], float qua
float data[4];
int cycl=0, s0, s1, s2, s3;
- if(ob==NULL || ob->type != OB_CURVE) return 0;
+ if (ob==NULL || ob->type != OB_CURVE) return 0;
cu= ob->data;
- if(cu->path==NULL || cu->path->data==NULL) {
+ if (cu->path==NULL || cu->path->data==NULL) {
printf("no path!\n");
return 0;
}
@@ -616,7 +616,7 @@ int where_on_path(Object *ob, float ctime, float vec[4], float dir[3], float qua
bl= cu->bev.first;
if (!bl) return 0;
if (!bl->nr) return 0;
- if(bl->poly> -1) cycl= 1;
+ if (bl->poly> -1) cycl= 1;
ctime *= (path->len-1);
@@ -648,9 +648,9 @@ int where_on_path(Object *ob, float ctime, float vec[4], float dir[3], float qua
nu= cu->nurb.first;
/* make sure that first and last frame are included in the vectors here */
- if(nu->type == CU_POLY) key_curve_position_weights(1.0f-fac, data, KEY_LINEAR);
- else if(nu->type == CU_BEZIER) key_curve_position_weights(1.0f-fac, data, KEY_LINEAR);
- else if(s0==s1 || p2==p3) key_curve_position_weights(1.0f-fac, data, KEY_CARDINAL);
+ if (nu->type == CU_POLY) key_curve_position_weights(1.0f-fac, data, KEY_LINEAR);
+ else if (nu->type == CU_BEZIER) key_curve_position_weights(1.0f-fac, data, KEY_LINEAR);
+ else if (s0==s1 || p2==p3) key_curve_position_weights(1.0f-fac, data, KEY_CARDINAL);
else key_curve_position_weights(1.0f-fac, data, KEY_BSPLINE);
vec[0]= data[0]*p0->vec[0] + data[1]*p1->vec[0] + data[2]*p2->vec[0] + data[3]*p3->vec[0] ; /* X */
@@ -662,22 +662,22 @@ int where_on_path(Object *ob, float ctime, float vec[4], float dir[3], float qua
float totfac, q1[4], q2[4];
totfac= data[0]+data[3];
- if(totfac>FLT_EPSILON) interp_qt_qtqt(q1, p0->quat, p3->quat, data[3] / totfac);
+ if (totfac>FLT_EPSILON) interp_qt_qtqt(q1, p0->quat, p3->quat, data[3] / totfac);
else copy_qt_qt(q1, p1->quat);
totfac= data[1]+data[2];
- if(totfac>FLT_EPSILON) interp_qt_qtqt(q2, p1->quat, p2->quat, data[2] / totfac);
+ if (totfac>FLT_EPSILON) interp_qt_qtqt(q2, p1->quat, p2->quat, data[2] / totfac);
else copy_qt_qt(q2, p3->quat);
totfac = data[0]+data[1]+data[2]+data[3];
- if(totfac>FLT_EPSILON) interp_qt_qtqt(quat, q1, q2, (data[1]+data[2]) / totfac);
+ if (totfac>FLT_EPSILON) interp_qt_qtqt(quat, q1, q2, (data[1]+data[2]) / totfac);
else copy_qt_qt(quat, q2);
}
- if(radius)
+ if (radius)
*radius= data[0]*p0->radius + data[1]*p1->radius + data[2]*p2->radius + data[3]*p3->radius;
- if(weight)
+ if (weight)
*weight= data[0]*p0->weight + data[1]*p1->weight + data[2]*p2->weight + data[3]*p3->weight;
return 1;
@@ -710,23 +710,23 @@ static void group_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, i
GroupObject *go;
float mat[4][4], tmat[4][4];
- if(ob->dup_group==NULL) return;
+ if (ob->dup_group==NULL) return;
group= ob->dup_group;
/* simple preventing of too deep nested groups */
- if(level>MAX_DUPLI_RECUR) return;
+ if (level>MAX_DUPLI_RECUR) return;
/* handles animated groups, and */
/* we need to check update for objects that are not in scene... */
group_handle_recalc_and_update(scene, ob, group);
animated= animated || group_is_animated(ob, group);
- for(go= group->gobject.first; go; go= go->next) {
+ for (go= group->gobject.first; go; go= go->next) {
/* note, if you check on layer here, render goes wrong... it still deforms verts and uses parent imat */
- if(go->ob!=ob) {
+ if (go->ob!=ob) {
/* group dupli offset, should apply after everything else */
- if(!is_zero_v3(group->dupli_ofs)) {
+ if (!is_zero_v3(group->dupli_ofs)) {
copy_m4_m4(tmat, go->ob->obmat);
sub_v3_v3v3(tmat[3], tmat[3], group->dupli_ofs);
mult_m4_m4m4(mat, ob->obmat, tmat);
@@ -738,7 +738,7 @@ static void group_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, i
dob= new_dupli_object(lb, go->ob, mat, ob->lay, 0, OB_DUPLIGROUP, animated);
/* check the group instance and object layers match, also that the object visible flags are ok. */
- if( (dob->origlay & group->layer)==0 ||
+ if ( (dob->origlay & group->layer)==0 ||
(G.rendering==0 && dob->ob->restrictflag & OB_RESTRICT_VIEW) ||
(G.rendering && dob->ob->restrictflag & OB_RESTRICT_RENDER)
) {
@@ -748,7 +748,7 @@ static void group_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, i
dob->no_draw= 0;
}
- if(go->ob->transflag & OB_DUPLI) {
+ if (go->ob->transflag & OB_DUPLI) {
copy_m4_m4(dob->ob->obmat, dob->mat);
object_duplilist_recursive(&group->id, scene, go->ob, lb, ob->obmat, level+1, animated);
copy_m4_m4(dob->ob->obmat, dob->omat);
@@ -854,11 +854,11 @@ static void vertex_dupli__mapFunc(void *userData, int index, float *co, float *n
copy_m4_m4(obmat, vdd->obmat);
copy_v3_v3(obmat[3], vec);
- if(vdd->par->transflag & OB_DUPLIROT) {
- if(no_f) {
+ if (vdd->par->transflag & OB_DUPLIROT) {
+ if (no_f) {
vec[0]= -no_f[0]; vec[1]= -no_f[1]; vec[2]= -no_f[2];
}
- else if(no_s) {
+ else if (no_s) {
vec[0]= -no_s[0]; vec[1]= -no_s[1]; vec[2]= -no_s[2];
}
@@ -876,10 +876,10 @@ static void vertex_dupli__mapFunc(void *userData, int index, float *co, float *n
/* restore the original layer so that each dupli will have proper dob->origlay */
vdd->ob->lay = origlay;
- if(vdd->orco)
+ if (vdd->orco)
copy_v3_v3(dob->orco, vdd->orco[index]);
- if(vdd->ob->transflag & OB_DUPLI) {
+ if (vdd->ob->transflag & OB_DUPLI) {
float tmpmat[4][4];
copy_m4_m4(tmpmat, vdd->ob->obmat);
copy_m4_m4(vdd->ob->obmat, obmat); /* pretend we are really this mat */
@@ -906,16 +906,17 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl
copy_m4_m4(pmat, par->obmat);
/* simple preventing of too deep nested groups */
- if(level>MAX_DUPLI_RECUR) return;
+ if (level>MAX_DUPLI_RECUR) return;
em = me->edit_btmesh;
- if(em) {
+ if (em) {
dm= editbmesh_get_derived_cage(scene, par, em, CD_MASK_BAREMESH);
- } else
+ }
+ else
dm= mesh_get_derived_deform(scene, par, CD_MASK_BAREMESH);
- if(G.rendering) {
+ if (G.rendering) {
vdd.orco= (float(*)[3])get_mesh_orco_verts(par);
transform_mesh_orco_verts(me, vdd.orco, me->totvert, 0);
}
@@ -929,7 +930,8 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl
sce = (Scene *)id;
lay= sce->lay;
base= sce->base.first;
- } else {
+ }
+ else {
group = (Group *)id;
lay= group->layer;
go = group->gobject.first;
@@ -940,15 +942,16 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl
if (sce) {
ob_iter= base->object;
oblay = base->lay;
- } else {
+ }
+ else {
ob_iter= go->ob;
oblay = ob_iter->lay;
}
if (lay & oblay && scene->obedit!=ob_iter) {
ob=ob_iter->parent;
- while(ob) {
- if(ob==par) {
+ while (ob) {
+ if (ob==par) {
ob = ob_iter;
/* End Scene/Group object loop, below is generic */
@@ -956,7 +959,7 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl
/* par_space_mat - only used for groups so we can modify the space dupli's are in
* when par_space_mat is NULL ob->obmat can be used instead of ob__obmat
*/
- if(par_space_mat)
+ if (par_space_mat)
mult_m4_m4m4(vdd.obmat, par_space_mat, ob->obmat);
else
copy_m4_m4(vdd.obmat, ob->obmat);
@@ -971,20 +974,20 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl
copy_m4_m4(vdd.pmat, pmat);
/* mballs have a different dupli handling */
- if(ob->type!=OB_MBALL) ob->flag |= OB_DONE; /* doesnt render */
+ if (ob->type!=OB_MBALL) ob->flag |= OB_DONE; /* doesnt render */
- if(me->edit_btmesh) {
+ if (me->edit_btmesh) {
dm->foreachMappedVert(dm, vertex_dupli__mapFunc, (void*) &vdd);
}
else {
- for(a=0; a<totvert; a++) {
+ for (a=0; a<totvert; a++) {
dm->getVertCo(dm, a, vec);
dm->getVertNo(dm, a, no);
vertex_dupli__mapFunc(&vdd, a, vec, no, NULL);
}
}
- if(sce) {
+ if (sce) {
/* Set proper layer in case of scene looping,
* in case of groups the object layer will be
* changed when it's duplicated due to the
@@ -1002,7 +1005,7 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl
else go= go->next; /* group loop */
}
- if(vdd.orco)
+ if (vdd.orco)
MEM_freeN(vdd.orco);
dm->release(dm);
}
@@ -1027,12 +1030,12 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
float ob__obmat[4][4]; /* needed for groups where the object matrix needs to be modified */
/* simple preventing of too deep nested groups */
- if(level>MAX_DUPLI_RECUR) return;
+ if (level>MAX_DUPLI_RECUR) return;
copy_m4_m4(pmat, par->obmat);
em = me->edit_btmesh;
- if(em) {
+ if (em) {
dm= editbmesh_get_derived_cage(scene, par, em, CD_MASK_BAREMESH);
}
else {
@@ -1044,7 +1047,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
mloop= dm->getLoopArray(dm);
mvert= dm->getVertArray(dm);
- if(G.rendering) {
+ if (G.rendering) {
orco= (float(*)[3])get_mesh_orco_verts(par);
transform_mesh_orco_verts(me, orco, me->totvert, 0);
@@ -1060,7 +1063,8 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
sce = (Scene *)id;
lay= sce->lay;
base= sce->base.first;
- } else {
+ }
+ else {
group = (Group *)id;
lay= group->layer;
go = group->gobject.first;
@@ -1071,22 +1075,23 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
if (sce) {
ob_iter= base->object;
oblay = base->lay;
- } else {
+ }
+ else {
ob_iter= go->ob;
oblay = ob_iter->lay;
}
if (lay & oblay && scene->obedit!=ob_iter) {
ob=ob_iter->parent;
- while(ob) {
- if(ob==par) {
+ while (ob) {
+ if (ob==par) {
ob = ob_iter;
/* End Scene/Group object loop, below is generic */
/* par_space_mat - only used for groups so we can modify the space dupli's are in
* when par_space_mat is NULL ob->obmat can be used instead of ob__obmat
*/
- if(par_space_mat)
+ if (par_space_mat)
mult_m4_m4m4(ob__obmat, par_space_mat, ob->obmat);
else
copy_m4_m4(ob__obmat, ob->obmat);
@@ -1094,9 +1099,9 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
copy_m3_m4(imat, ob->parentinv);
/* mballs have a different dupli handling */
- if(ob->type!=OB_MBALL) ob->flag |= OB_DONE; /* doesnt render */
+ if (ob->type!=OB_MBALL) ob->flag |= OB_DONE; /* doesnt render */
- for(a=0, mp= mpoly; a<totface; a++, mp++) {
+ for (a=0, mp= mpoly; a<totface; a++, mp++) {
int mv1;
int mv2;
int mv3;
@@ -1140,7 +1145,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
quat_to_mat3( mat,quat);
/* scale */
- if(par->transflag & OB_DUPLIFACES_SCALE) {
+ if (par->transflag & OB_DUPLIFACES_SCALE) {
float size= mesh_calc_poly_area(mp, loopstart, mvert, NULL);
size= sqrtf(size) * par->dupfacesca;
mul_m3_fl(mat, size);
@@ -1153,17 +1158,17 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
mul_m4_m4m3(obmat, tmat, mat);
dob= new_dupli_object(lb, ob, obmat, par->lay, a, OB_DUPLIFACES, animated);
- if(G.rendering) {
+ if (G.rendering) {
w= 1.0f / (float)mp->totloop;
- if(orco) {
+ if (orco) {
int j;
for (j = 0; j < mpoly->totloop; j++) {
madd_v3_v3fl(dob->orco, orco[loopstart[j].v], w);
}
}
- if(mloopuv) {
+ if (mloopuv) {
int j;
for (j = 0; j < mpoly->totloop; j++) {
madd_v2_v2fl(dob->orco, mloopuv[loopstart[j].v].uv, w);
@@ -1171,7 +1176,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
}
}
- if(ob->transflag & OB_DUPLI) {
+ if (ob->transflag & OB_DUPLI) {
float tmpmat[4][4];
copy_m4_m4(tmpmat, ob->obmat);
copy_m4_m4(ob->obmat, obmat); /* pretend we are really this mat */
@@ -1189,7 +1194,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
else go= go->next; /* group loop */
}
- if(orco)
+ if (orco)
MEM_freeN(orco);
dm->release(dm);
@@ -1214,20 +1219,20 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
int no_draw_flag = PARS_UNEXIST;
- if(psys==NULL) return;
+ if (psys==NULL) return;
/* simple preventing of too deep nested groups */
- if(level>MAX_DUPLI_RECUR) return;
+ if (level>MAX_DUPLI_RECUR) return;
part=psys->part;
- if(part==NULL)
+ if (part==NULL)
return;
- if(!psys_check_enabled(par, psys))
+ if (!psys_check_enabled(par, psys))
return;
- if(G.rendering == 0)
+ if (G.rendering == 0)
no_draw_flag |= PARS_NO_DISP;
ctime = BKE_curframe(scene); /* NOTE: in old animsys, used parent object's timeoffset... */
@@ -1237,7 +1242,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
BLI_srandom(31415926 + psys->seed);
- if((psys->renderdata || part->draw_as==PART_DRAW_REND) && ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) {
+ if ((psys->renderdata || part->draw_as==PART_DRAW_REND) && ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) {
ParticleSimulationData sim= {NULL};
sim.scene= scene;
sim.ob= par;
@@ -1247,24 +1252,24 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
invert_m4_m4(par->imat, par->obmat);
/* first check for loops (particle system object used as dupli object) */
- if(part->ren_as == PART_DRAW_OB) {
- if(ELEM(part->dup_ob, NULL, par))
+ if (part->ren_as == PART_DRAW_OB) {
+ if (ELEM(part->dup_ob, NULL, par))
return;
}
else { /*PART_DRAW_GR */
- if(part->dup_group == NULL || part->dup_group->gobject.first == NULL)
+ if (part->dup_group == NULL || part->dup_group->gobject.first == NULL)
return;
- for(go=part->dup_group->gobject.first; go; go=go->next)
- if(go->ob == par)
+ for (go=part->dup_group->gobject.first; go; go=go->next)
+ if (go->ob == par)
return;
}
/* if we have a hair particle system, use the path cache */
- if(part->type == PART_HAIR) {
- if(psys->flag & PSYS_HAIR_DONE)
+ if (part->type == PART_HAIR) {
+ if (psys->flag & PSYS_HAIR_DONE)
hair= (totchild == 0 || psys->childcache) && psys->pathcache;
- if(!hair)
+ if (!hair)
return;
/* we use cache, update totchild according to cached data */
@@ -1277,15 +1282,15 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
psys->lattice = psys_get_lattice(&sim);
/* gather list of objects or single object */
- if(part->ren_as==PART_DRAW_GR) {
+ if (part->ren_as==PART_DRAW_GR) {
group_handle_recalc_and_update(scene, par, part->dup_group);
- if(part->draw & PART_DRAW_COUNT_GR) {
- for(dw=part->dupliweights.first; dw; dw=dw->next)
+ if (part->draw & PART_DRAW_COUNT_GR) {
+ for (dw=part->dupliweights.first; dw; dw=dw->next)
totgroup += dw->count;
}
else {
- for(go=part->dup_group->gobject.first; go; go=go->next)
+ for (go=part->dup_group->gobject.first; go; go=go->next)
totgroup++;
}
@@ -1295,11 +1300,11 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
obcopylist = MEM_callocN(totgroup*sizeof(Object), "dupgroup copy list");
- if(part->draw & PART_DRAW_COUNT_GR && totgroup) {
+ if (part->draw & PART_DRAW_COUNT_GR && totgroup) {
dw = part->dupliweights.first;
- for(a=0; a<totgroup; dw=dw->next) {
- for(b=0; b<dw->count; b++, a++) {
+ for (a=0; a<totgroup; dw=dw->next) {
+ for (b=0; b<dw->count; b++, a++) {
oblist[a] = dw->ob;
obcopylist[a] = *dw->ob;
}
@@ -1307,7 +1312,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
}
else {
go = part->dup_group->gobject.first;
- for(a=0; a<totgroup; a++, go=go->next) {
+ for (a=0; a<totgroup; a++, go=go->next) {
oblist[a] = go->ob;
obcopylist[a] = *go->ob;
}
@@ -1318,15 +1323,15 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
obcopy = *ob;
}
- if(totchild==0 || part->draw & PART_DRAW_PARENT)
+ if (totchild==0 || part->draw & PART_DRAW_PARENT)
a = 0;
else
a = totpart;
- for(pa=psys->particles,counter=0; a<totpart+totchild; a++,pa++,counter++) {
- if(a<totpart) {
+ for (pa=psys->particles,counter=0; a<totpart+totchild; a++,pa++,counter++) {
+ if (a<totpart) {
/* handle parent particle */
- if(pa->flag & no_draw_flag)
+ if (pa->flag & no_draw_flag)
continue;
/* pa_num = pa->num; */ /* UNUSED */
@@ -1343,18 +1348,18 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
}
/* some hair paths might be non-existent so they can't be used for duplication */
- if(hair &&
+ if (hair &&
((a < totpart && psys->pathcache[a]->steps < 0) ||
(a >= totpart && psys->childcache[a-totpart]->steps < 0)))
continue;
- if(part->ren_as==PART_DRAW_GR) {
+ if (part->ren_as==PART_DRAW_GR) {
/* prevent divide by zero below [#28336] */
- if(totgroup == 0)
+ if (totgroup == 0)
continue;
/* for groups, pick the object based on settings */
- if(part->draw&PART_DRAW_RAND_GR)
+ if (part->draw&PART_DRAW_RAND_GR)
b= BLI_rand() % totgroup;
else
b= a % totgroup;
@@ -1368,9 +1373,9 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
oldobmat= obcopy.obmat;
}
- if(hair) {
+ if (hair) {
/* hair we handle separate and compute transform based on hair keys */
- if(a < totpart) {
+ if (a < totpart) {
cache = psys->pathcache[a];
psys_get_dupli_path_transform(&sim, pa, NULL, cache, pamat, &scale);
}
@@ -1386,7 +1391,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
else {
/* first key */
state.time = ctime;
- if(psys_get_particle_state(&sim, a, &state, 0) == 0) {
+ if (psys_get_particle_state(&sim, a, &state, 0) == 0) {
continue;
}
else {
@@ -1398,11 +1403,11 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
}
}
- if(part->ren_as==PART_DRAW_GR && psys->part->draw & PART_DRAW_WHOLE_GR) {
- for(go= part->dup_group->gobject.first, b=0; go; go= go->next, b++) {
+ if (part->ren_as==PART_DRAW_GR && psys->part->draw & PART_DRAW_WHOLE_GR) {
+ for (go= part->dup_group->gobject.first, b=0; go; go= go->next, b++) {
/* group dupli offset, should apply after everything else */
- if(!is_zero_v3(part->dup_group->dupli_ofs)) {
+ if (!is_zero_v3(part->dup_group->dupli_ofs)) {
copy_m4_m4(tmat, oblist[b]->obmat);
sub_v3_v3v3(tmat[3], tmat[3], part->dup_group->dupli_ofs);
mult_m4_m4m4(tmat, pamat, tmat);
@@ -1412,14 +1417,14 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
}
mul_mat3_m4_fl(tmat, size*scale);
- if(par_space_mat)
+ if (par_space_mat)
mult_m4_m4m4(mat, par_space_mat, tmat);
else
copy_m4_m4(mat, tmat);
dob= new_dupli_object(lb, go->ob, mat, par->lay, counter, OB_DUPLIPARTS, animated);
copy_m4_m4(dob->omat, obcopylist[b].obmat);
- if(G.rendering)
+ if (G.rendering)
psys_get_dupli_texture(psys, part, sim.psmd, pa, cpa, dob->uv, dob->orco);
}
}
@@ -1431,7 +1436,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
obmat[3][0] = obmat[3][1] = obmat[3][2] = 0.0f;
/* particle rotation uses x-axis as the aligned axis, so pre-rotate the object accordingly */
- if((part->draw & PART_DRAW_ROTATE_OB) == 0) {
+ if ((part->draw & PART_DRAW_ROTATE_OB) == 0) {
float xvec[3], q[4];
xvec[0] = -1.f;
xvec[1] = xvec[2] = 0;
@@ -1443,7 +1448,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
/* Normal particles and cached hair live in global space so we need to
* remove the real emitter's transformation before 2nd order duplication.
*/
- if(par_space_mat && GS(id->name) != ID_GR)
+ if (par_space_mat && GS(id->name) != ID_GR)
mult_m4_m4m4(mat, psys->imat, pamat);
else
copy_m4_m4(mat, pamat);
@@ -1451,24 +1456,24 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
mult_m4_m4m4(tmat, mat, obmat);
mul_mat3_m4_fl(tmat, size*scale);
- if(par_space_mat)
+ if (par_space_mat)
mult_m4_m4m4(mat, par_space_mat, tmat);
else
copy_m4_m4(mat, tmat);
- if(part->draw & PART_DRAW_GLOBAL_OB)
+ if (part->draw & PART_DRAW_GLOBAL_OB)
add_v3_v3v3(mat[3], mat[3], vec);
dob= new_dupli_object(lb, ob, mat, ob->lay, counter, GS(id->name) == ID_GR ? OB_DUPLIGROUP : OB_DUPLIPARTS, animated);
copy_m4_m4(dob->omat, oldobmat);
- if(G.rendering)
+ if (G.rendering)
psys_get_dupli_texture(psys, part, sim.psmd, pa, cpa, dob->uv, dob->orco);
}
}
/* restore objects since they were changed in where_is_object_time */
- if(part->ren_as==PART_DRAW_GR) {
- for(a=0; a<totgroup; a++)
+ if (part->ren_as==PART_DRAW_GR) {
+ for (a=0; a<totgroup; a++)
*(oblist[a])= obcopylist[a];
}
else
@@ -1476,12 +1481,12 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
}
/* clean up */
- if(oblist)
+ if (oblist)
MEM_freeN(oblist);
- if(obcopylist)
+ if (obcopylist)
MEM_freeN(obcopylist);
- if(psys->lattice) {
+ if (psys->lattice) {
end_latt_deform(psys->lattice);
psys->lattice = NULL;
}
@@ -1492,14 +1497,14 @@ static Object *find_family_object(Object **obar, char *family, char ch)
Object *ob;
int flen;
- if( obar[(int)ch] ) return obar[(int)ch];
+ if ( obar[(int)ch] ) return obar[(int)ch];
flen= strlen(family);
ob= G.main->object.first;
- while(ob) {
- if( ob->id.name[flen+2]==ch ) {
- if( strncmp(ob->id.name+2, family, flen)==0 ) break;
+ while (ob) {
+ if ( ob->id.name[flen+2]==ch ) {
+ if ( strncmp(ob->id.name+2, family, flen)==0 ) break;
}
ob= ob->id.next;
}
@@ -1519,14 +1524,14 @@ static void font_duplilist(ListBase *lb, Scene *scene, Object *par, int level, i
int slen, a;
/* simple preventing of too deep nested groups */
- if(level>MAX_DUPLI_RECUR) return;
+ if (level>MAX_DUPLI_RECUR) return;
copy_m4_m4(pmat, par->obmat);
/* in par the family name is stored, use this to find the other objects */
chartransdata= BKE_text_to_curve(G.main, scene, par, FO_DUPLI);
- if(chartransdata==NULL) return;
+ if (chartransdata==NULL) return;
cu= par->data;
slen= strlen(cu->str);
@@ -1536,10 +1541,10 @@ static void font_duplilist(ListBase *lb, Scene *scene, Object *par, int level, i
ct= chartransdata;
- for(a=0; a<slen; a++, ct++) {
+ for (a=0; a<slen; a++, ct++) {
ob= find_family_object(obar, cu->family, cu->str[a]);
- if(ob) {
+ if (ob) {
vec[0]= fsize*(ct->xof - xof);
vec[1]= fsize*(ct->yof - yof);
vec[2]= 0.0;
@@ -1560,7 +1565,7 @@ static void font_duplilist(ListBase *lb, Scene *scene, Object *par, int level, i
static void object_duplilist_recursive(ID *id, Scene *scene, Object *ob, ListBase *duplilist, float par_space_mat[][4], int level, int animated)
{
- if((ob->transflag & OB_DUPLI)==0)
+ if ((ob->transflag & OB_DUPLI)==0)
return;
/* Should the dupli's be generated for this object? - Respect restrict flags */
@@ -1568,43 +1573,45 @@ static void object_duplilist_recursive(ID *id, Scene *scene, Object *ob, ListBas
if (ob->restrictflag & OB_RESTRICT_RENDER) {
return;
}
- } else {
+ }
+ else {
if (ob->restrictflag & OB_RESTRICT_VIEW) {
return;
}
}
- if(ob->transflag & OB_DUPLIPARTS) {
+ if (ob->transflag & OB_DUPLIPARTS) {
ParticleSystem *psys = ob->particlesystem.first;
- for(; psys; psys=psys->next)
+ for (; psys; psys=psys->next)
new_particle_duplilist(duplilist, id, scene, ob, par_space_mat, psys, level+1, animated);
}
- else if(ob->transflag & OB_DUPLIVERTS) {
- if(ob->type==OB_MESH) {
+ else if (ob->transflag & OB_DUPLIVERTS) {
+ if (ob->type==OB_MESH) {
vertex_duplilist(duplilist, id, scene, ob, par_space_mat, level+1, animated);
}
- else if(ob->type==OB_FONT) {
+ else if (ob->type==OB_FONT) {
if (GS(id->name)==ID_SCE) { /* TODO - support dupligroups */
font_duplilist(duplilist, scene, ob, level+1, animated);
}
}
}
- else if(ob->transflag & OB_DUPLIFACES) {
- if(ob->type==OB_MESH)
+ else if (ob->transflag & OB_DUPLIFACES) {
+ if (ob->type==OB_MESH)
face_duplilist(duplilist, id, scene, ob, par_space_mat, level+1, animated);
}
- else if(ob->transflag & OB_DUPLIFRAMES) {
+ else if (ob->transflag & OB_DUPLIFRAMES) {
if (GS(id->name)==ID_SCE) { /* TODO - support dupligroups */
frames_duplilist(duplilist, scene, ob, level+1, animated);
}
- } else if(ob->transflag & OB_DUPLIGROUP) {
+ }
+ else if (ob->transflag & OB_DUPLIGROUP) {
DupliObject *dob;
group_duplilist(duplilist, scene, ob, level+1, animated); /* now recursive */
if (level==0) {
- for(dob= duplilist->first; dob; dob= dob->next)
- if(dob->type == OB_DUPLIGROUP)
+ for (dob= duplilist->first; dob; dob= dob->next)
+ if (dob->type == OB_DUPLIGROUP)
copy_m4_m4(dob->ob->obmat, dob->mat);
}
}
@@ -1627,7 +1634,7 @@ void free_object_duplilist(ListBase *lb)
/* loop in reverse order, if object is instanced multiple times
* the original layer may not really be original otherwise, proper
* solution is more complicated */
- for(dob= lb->last; dob; dob= dob->prev) {
+ for (dob= lb->last; dob; dob= dob->prev) {
dob->ob->lay= dob->origlay;
copy_m4_m4(dob->ob->obmat, dob->omat);
}
@@ -1638,17 +1645,17 @@ void free_object_duplilist(ListBase *lb)
int count_duplilist(Object *ob)
{
- if(ob->transflag & OB_DUPLI) {
- if(ob->transflag & OB_DUPLIVERTS) {
- if(ob->type==OB_MESH) {
- if(ob->transflag & OB_DUPLIVERTS) {
+ if (ob->transflag & OB_DUPLI) {
+ if (ob->transflag & OB_DUPLIVERTS) {
+ if (ob->type==OB_MESH) {
+ if (ob->transflag & OB_DUPLIVERTS) {
ParticleSystem *psys = ob->particlesystem.first;
int pdup=0;
- for(; psys; psys=psys->next)
+ for (; psys; psys=psys->next)
pdup += psys->totpart;
- if(pdup==0) {
+ if (pdup==0) {
Mesh *me= ob->data;
return me->totvert;
}
@@ -1657,7 +1664,7 @@ int count_duplilist(Object *ob)
}
}
}
- else if(ob->transflag & OB_DUPLIFRAMES) {
+ else if (ob->transflag & OB_DUPLIFRAMES) {
int tot= ob->dupend - ob->dupsta;
tot/= (ob->dupon+ob->dupoff);
return tot*ob->dupon;
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index 3a08120f067..a9267be4cc4 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -1032,7 +1032,7 @@ void BKE_keyingset_free_path (KeyingSet *ks, KS_Path *ksp)
return;
/* free RNA-path info */
- if(ksp->rna_path)
+ if (ksp->rna_path)
MEM_freeN(ksp->rna_path);
/* free path itself */
@@ -1194,7 +1194,7 @@ static short animsys_write_rna_setting (PointerRNA *ptr, char *path, int array_i
/* as long as we don't do property update, we still tag datablock
* as having been updated. this flag does not cause any updates to
* be run, it's for e.g. render engines to synchronize data */
- if(new_ptr.id.data) {
+ if (new_ptr.id.data) {
ID *id= new_ptr.id.data;
id->flag |= LIB_ID_RECALC;
DAG_id_type_tag(G.main, GS(id->name));
diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c
index 1bb6841cd36..26c59129914 100644
--- a/source/blender/blenkernel/intern/blender.c
+++ b/source/blender/blenkernel/intern/blender.c
@@ -127,7 +127,7 @@ void initglobals(void)
strcpy(G.ima, "//");
- if(BLENDER_SUBVERSION)
+ if (BLENDER_SUBVERSION)
BLI_snprintf(versionstr, sizeof(versionstr), "blender.org %d.%d", BLENDER_VERSION, BLENDER_SUBVERSION);
else
BLI_snprintf(versionstr, sizeof(versionstr), "blender.org %d", BLENDER_VERSION);
@@ -174,7 +174,7 @@ static void clean_paths(Main *main)
bpath_traverse_main(main, clean_paths_visit_cb, BPATH_TRAVERSE_SKIP_MULTIFILE, NULL);
- for(scene= main->scene.first; scene; scene= scene->id.next) {
+ for (scene= main->scene.first; scene; scene= scene->id.next) {
BLI_clean(scene->r.pic);
}
}
@@ -193,21 +193,21 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath
char mode;
/* 'u' = undo save, 'n' = no UI load */
- if(bfd->main->screen.first==NULL) mode= 'u';
- else if(G.fileflags & G_FILE_NO_UI) mode= 'n';
+ if (bfd->main->screen.first==NULL) mode= 'u';
+ else if (G.fileflags & G_FILE_NO_UI) mode= 'n';
else mode= 0;
recover= (G.fileflags & G_FILE_RECOVER);
/* Only make filepaths compatible when loading for real (not undo) */
- if(mode != 'u') {
+ if (mode != 'u') {
clean_paths(bfd->main);
}
/* XXX here the complex windowmanager matching */
/* no load screens? */
- if(mode) {
+ if (mode) {
/* comes from readfile.c */
extern void lib_link_screen_restore(Main *, bScreen *, Scene *);
@@ -219,9 +219,9 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath
curscreen= CTX_wm_screen(C);
/* but use new Scene pointer */
curscene= bfd->curscene;
- if(curscene==NULL) curscene= bfd->main->scene.first;
+ if (curscene==NULL) curscene= bfd->main->scene.first;
/* and we enforce curscene to be in current screen */
- if(curscreen) curscreen->scene= curscene; /* can run in bgmode */
+ if (curscreen) curscreen->scene= curscene; /* can run in bgmode */
/* clear_global will free G.main, here we can still restore pointers */
lib_link_screen_restore(bfd->main, curscreen, curscene);
@@ -250,7 +250,7 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath
}
/* case G_FILE_NO_UI or no screens in file */
- if(mode) {
+ if (mode) {
/* leave entire context further unaltered? */
CTX_data_scene_set(C, curscene);
}
@@ -267,14 +267,14 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath
}
/* this can happen when active scene was lib-linked, and doesnt exist anymore */
- if(CTX_data_scene(C)==NULL) {
+ if (CTX_data_scene(C)==NULL) {
CTX_data_scene_set(C, bfd->main->scene.first);
CTX_wm_screen(C)->scene= CTX_data_scene(C);
curscene= CTX_data_scene(C);
}
/* special cases, override loaded flags: */
- if(G.f != bfd->globalf) {
+ if (G.f != bfd->globalf) {
const int flags_keep= (G_DEBUG | G_SWAP_EXCHANGE | G_SCRIPT_AUTOEXEC | G_SCRIPT_OVERRIDE_PREF);
bfd->globalf= (bfd->globalf & ~flags_keep) | (G.f & flags_keep);
}
@@ -291,7 +291,7 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath
if (G.main->versionfile < 250)
do_versions_ipos_to_animato(G.main);
- if(recover && bfd->filename[0] && G.relbase_valid) {
+ if (recover && bfd->filename[0] && G.relbase_valid) {
/* in case of autosave or quit.blend, use original filename instead
* use relbase_valid to make sure the file is saved, else we get <memory2> in the filename */
filepath= bfd->filename;
@@ -304,7 +304,7 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath
#endif
/* these are the same at times, should never copy to the same location */
- if(G.main->name != filepath)
+ if (G.main->name != filepath)
BLI_strncpy(G.main->name, filepath, FILE_MAX);
/* baseflags, groups, make depsgraph, etc */
@@ -317,7 +317,7 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath
static int handle_subversion_warning(Main *main, ReportList *reports)
{
- if(main->minversionfile > BLENDER_VERSION ||
+ if (main->minversionfile > BLENDER_VERSION ||
(main->minversionfile == BLENDER_VERSION &&
main->minsubversionfile > BLENDER_SUBVERSION)) {
BKE_reportf(reports, RPT_ERROR, "File written by newer Blender binary: %d.%d , expect loss of data!", main->minversionfile, main->minsubversionfile);
@@ -328,11 +328,11 @@ static int handle_subversion_warning(Main *main, ReportList *reports)
static void keymap_item_free(wmKeyMapItem *kmi)
{
- if(kmi->properties) {
+ if (kmi->properties) {
IDP_FreeProperty(kmi->properties);
MEM_freeN(kmi->properties);
}
- if(kmi->ptr)
+ if (kmi->ptr)
MEM_freeN(kmi->ptr);
}
@@ -342,19 +342,19 @@ void BKE_userdef_free(void)
wmKeyMapItem *kmi;
wmKeyMapDiffItem *kmdi;
- for(km=U.user_keymaps.first; km; km=km->next) {
- for(kmdi=km->diff_items.first; kmdi; kmdi=kmdi->next) {
- if(kmdi->add_item) {
+ for (km=U.user_keymaps.first; km; km=km->next) {
+ for (kmdi=km->diff_items.first; kmdi; kmdi=kmdi->next) {
+ if (kmdi->add_item) {
keymap_item_free(kmdi->add_item);
MEM_freeN(kmdi->add_item);
}
- if(kmdi->remove_item) {
+ if (kmdi->remove_item) {
keymap_item_free(kmdi->remove_item);
MEM_freeN(kmdi->remove_item);
}
}
- for(kmi=km->items.first; kmi; kmi=kmi->next)
+ for (kmi=km->items.first; kmi; kmi=kmi->next)
keymap_item_free(kmi);
BLI_freelistN(&km->diff_items);
@@ -373,14 +373,14 @@ int BKE_read_file(bContext *C, const char *filepath, ReportList *reports)
BlendFileData *bfd;
int retval= BKE_READ_FILE_OK;
- if(strstr(filepath, BLENDER_STARTUP_FILE)==NULL) /* don't print user-pref loading */
+ if (strstr(filepath, BLENDER_STARTUP_FILE)==NULL) /* don't print user-pref loading */
printf("read blend: %s\n", filepath);
bfd= BLO_read_from_file(filepath, reports);
if (bfd) {
- if(bfd->user) retval= BKE_READ_FILE_OK_USERPREFS;
+ if (bfd->user) retval= BKE_READ_FILE_OK_USERPREFS;
- if(0==handle_subversion_warning(bfd->main, reports)) {
+ if (0==handle_subversion_warning(bfd->main, reports)) {
free_main(bfd->main);
MEM_freeN(bfd);
bfd= NULL;
@@ -474,7 +474,7 @@ static int read_undosave(bContext *C, UndoElem *uel)
fileflags= G.fileflags;
G.fileflags |= G_FILE_NO_UI;
- if(UNDO_DISK)
+ if (UNDO_DISK)
success= (BKE_read_file(C, uel->str, NULL) != BKE_READ_FILE_FAIL);
else
success= BKE_read_file_from_memfile(C, &uel->memfile, NULL);
@@ -483,7 +483,7 @@ static int read_undosave(bContext *C, UndoElem *uel)
BLI_strncpy(G.main->name, mainstr, sizeof(G.main->name)); /* restore */
G.fileflags= fileflags;
- if(success) {
+ if (success) {
/* important not to update time here, else non keyed tranforms are lost */
DAG_on_visible_update(G.main, FALSE);
}
@@ -498,11 +498,11 @@ void BKE_write_undo(bContext *C, const char *name)
int nr /*, success */ /* UNUSED */;
UndoElem *uel;
- if( (U.uiflag & USER_GLOBALUNDO)==0) return;
- if( U.undosteps==0) return;
+ if ( (U.uiflag & USER_GLOBALUNDO)==0) return;
+ if ( U.undosteps==0) return;
/* remove all undos after (also when curundo==NULL) */
- while(undobase.last != curundo) {
+ while (undobase.last != curundo) {
uel= undobase.last;
BLI_remlink(&undobase, uel);
BLO_free_memfile(&uel->memfile);
@@ -517,13 +517,13 @@ void BKE_write_undo(bContext *C, const char *name)
/* and limit amount to the maximum */
nr= 0;
uel= undobase.last;
- while(uel) {
+ while (uel) {
nr++;
- if(nr==U.undosteps) break;
+ if (nr==U.undosteps) break;
uel= uel->prev;
}
- if(uel) {
- while(undobase.first!=uel) {
+ if (uel) {
+ while (undobase.first!=uel) {
UndoElem *first= undobase.first;
BLI_remlink(&undobase, first);
/* the merge is because of compression */
@@ -534,7 +534,7 @@ void BKE_write_undo(bContext *C, const char *name)
/* disk save version */
- if(UNDO_DISK) {
+ if (UNDO_DISK) {
static int counter= 0;
char filepath[FILE_MAX];
char numstr[32];
@@ -554,31 +554,31 @@ void BKE_write_undo(bContext *C, const char *name)
else {
MemFile *prevfile=NULL;
- if(curundo->prev) prevfile= &(curundo->prev->memfile);
+ if (curundo->prev) prevfile= &(curundo->prev->memfile);
memused= MEM_get_memory_in_use();
/* success= */ /* UNUSED */ BLO_write_file_mem(CTX_data_main(C), prevfile, &curundo->memfile, G.fileflags);
curundo->undosize= MEM_get_memory_in_use() - memused;
}
- if(U.undomemory != 0) {
+ if (U.undomemory != 0) {
/* limit to maximum memory (afterwards, we can't know in advance) */
totmem= 0;
maxmem= ((uintptr_t)U.undomemory)*1024*1024;
/* keep at least two (original + other) */
uel= undobase.last;
- while(uel && uel->prev) {
+ while (uel && uel->prev) {
totmem+= uel->undosize;
- if(totmem>maxmem) break;
+ if (totmem>maxmem) break;
uel= uel->prev;
}
- if(uel) {
- if(uel->prev && uel->prev->prev)
+ if (uel) {
+ if (uel->prev && uel->prev->prev)
uel= uel->prev;
- while(undobase.first!=uel) {
+ while (undobase.first!=uel) {
UndoElem *first= undobase.first;
BLI_remlink(&undobase, first);
/* the merge is because of compression */
@@ -593,14 +593,14 @@ void BKE_write_undo(bContext *C, const char *name)
void BKE_undo_step(bContext *C, int step)
{
- if(step==0) {
+ if (step==0) {
read_undosave(C, curundo);
}
- else if(step==1) {
+ else if (step==1) {
/* curundo should never be NULL, after restart or load file it should call undo_save */
- if(curundo==NULL || curundo->prev==NULL) ; // XXX error("No undo available");
+ if (curundo==NULL || curundo->prev==NULL) ; // XXX error("No undo available");
else {
- if(G.f & G_DEBUG) printf("undo %s\n", curundo->name);
+ if (G.f & G_DEBUG) printf("undo %s\n", curundo->name);
curundo= curundo->prev;
read_undosave(C, curundo);
}
@@ -609,11 +609,11 @@ void BKE_undo_step(bContext *C, int step)
/* curundo has to remain current situation! */
- if(curundo==NULL || curundo->next==NULL) ; // XXX error("No redo available");
+ if (curundo==NULL || curundo->next==NULL) ; // XXX error("No redo available");
else {
read_undosave(C, curundo->next);
curundo= curundo->next;
- if(G.f & G_DEBUG) printf("redo %s\n", curundo->name);
+ if (G.f & G_DEBUG) printf("redo %s\n", curundo->name);
}
}
}
@@ -623,7 +623,7 @@ void BKE_reset_undo(void)
UndoElem *uel;
uel= undobase.first;
- while(uel) {
+ while (uel) {
BLO_free_memfile(&uel->memfile);
uel= uel->next;
}
@@ -644,7 +644,7 @@ void BKE_undo_name(bContext *C, const char *name)
{
UndoElem *uel= BLI_rfindstring(&undobase, name, offsetof(UndoElem, name));
- if(uel && uel->prev) {
+ if (uel && uel->prev) {
curundo= uel->prev;
BKE_undo_step(C, 0);
}
@@ -653,7 +653,7 @@ void BKE_undo_name(bContext *C, const char *name)
/* name optional */
int BKE_undo_valid(const char *name)
{
- if(name) {
+ if (name) {
UndoElem *uel= BLI_rfindstring(&undobase, name, offsetof(UndoElem, name));
return uel && uel->prev;
}
@@ -667,10 +667,10 @@ const char *BKE_undo_get_name(int nr, int *active)
{
UndoElem *uel= BLI_findlink(&undobase, nr);
- if(active) *active= 0;
+ if (active) *active= 0;
- if(uel) {
- if(active && uel==curundo)
+ if (uel) {
+ if (active && uel==curundo)
*active= 1;
return uel->name;
}
@@ -685,7 +685,7 @@ char *BKE_undo_menu_string(void)
BLI_dynstr_append(ds, "Global Undo History %t");
- for(uel= undobase.first; uel; uel= uel->next) {
+ for (uel= undobase.first; uel; uel= uel->next) {
BLI_dynstr_append(ds, "|");
BLI_dynstr_append(ds, uel->name);
}
@@ -704,34 +704,34 @@ void BKE_undo_save_quit(void)
int file;
char str[FILE_MAX];
- if( (U.uiflag & USER_GLOBALUNDO)==0) return;
+ if ( (U.uiflag & USER_GLOBALUNDO)==0) return;
uel= curundo;
- if(uel==NULL) {
+ if (uel==NULL) {
printf("No undo buffer to save recovery file\n");
return;
}
/* no undo state to save */
- if(undobase.first==undobase.last) return;
+ if (undobase.first==undobase.last) return;
BLI_make_file_string("/", str, BLI_temporary_dir(), "quit.blend");
file = BLI_open(str,O_BINARY+O_WRONLY+O_CREAT+O_TRUNC, 0666);
- if(file == -1) {
+ if (file == -1) {
//XXX error("Unable to save %s, check you have permissions", str);
return;
}
chunk= uel->memfile.chunks.first;
- while(chunk) {
- if( write(file, chunk->buf, chunk->size) != chunk->size) break;
+ while (chunk) {
+ if ( write(file, chunk->buf, chunk->size) != chunk->size) break;
chunk= chunk->next;
}
close(file);
- if(chunk) ; //XXX error("Unable to save %s, internal error", str);
+ if (chunk) ; //XXX error("Unable to save %s, internal error", str);
else printf("Saved session recovery to %s\n", str);
}
@@ -741,9 +741,9 @@ Main *BKE_undo_get_main(Scene **scene)
Main *mainp= NULL;
BlendFileData *bfd= BLO_read_from_memfile(G.main, G.main->name, &curundo->memfile, NULL);
- if(bfd) {
+ if (bfd) {
mainp= bfd->main;
- if(scene)
+ if (scene)
*scene= bfd->curscene;
MEM_freeN(bfd);
diff --git a/source/blender/blenkernel/intern/bmfont.c b/source/blender/blenkernel/intern/bmfont.c
index 0211dcdf42c..278dbe30a95 100644
--- a/source/blender/blenkernel/intern/bmfont.c
+++ b/source/blender/blenkernel/intern/bmfont.c
@@ -163,7 +163,8 @@ void readBitmapFontVersion0(ImBuf * ibuf, unsigned char * rect, int step)
// we're going to fake alpha here:
calcAlpha(ibuf);
}
- } else {
+ }
+ else {
printf("readBitmapFontVersion0: corrupted bitmapfont\n");
}
}
@@ -183,7 +184,8 @@ void detectBitmapFont(ImBuf *ibuf)
// printf("found 8bit font !\n");
// round y size down
// do the 8 bit font stuff. (not yet)
- } else {
+ }
+ else {
// we try all 4 possible combinations
for (i = 0; i < 4; i++) {
if (rect[0] == 'B' && rect[4] == 'F' && rect[8] == 'N' && rect[12] == 'T') {
@@ -194,7 +196,8 @@ void detectBitmapFont(ImBuf *ibuf)
if (version == 0) {
readBitmapFontVersion0(ibuf, rect, 4);
- } else {
+ }
+ else {
printf("detectBitmapFont :Unsupported version %d\n", version);
}
@@ -223,10 +226,12 @@ int locateGlyph(bmFont *bmfont, unsigned short unicode)
if (bmfont->glyphs[current].unicode == unicode) {
break;
- } else if (bmfont->glyphs[current].unicode < unicode) {
+ }
+ else if (bmfont->glyphs[current].unicode < unicode) {
// have to move up
min = current;
- } else {
+ }
+ else {
// have to move down
max = current;
}
diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c
index 8fa0a46f6da..993a33ca468 100644
--- a/source/blender/blenkernel/intern/boids.c
+++ b/source/blender/blenkernel/intern/boids.c
@@ -83,15 +83,15 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val,
pd_point_from_particle(bbd->sim, pa, &pa->state, &epoint);
/* first find out goal/predator with highest priority */
- if(effectors) for(cur = effectors->first; cur; cur=cur->next) {
+ if (effectors) for(cur = effectors->first; cur; cur=cur->next) {
Object *eob = cur->ob;
PartDeflect *pd = cur->pd;
- if(gabr->ob && (rule->type != eBoidRuleType_Goal || gabr->ob != bpa->ground)) {
- if(gabr->ob == eob) {
+ if (gabr->ob && (rule->type != eBoidRuleType_Goal || gabr->ob != bpa->ground)) {
+ if (gabr->ob == eob) {
/* TODO: effectors with multiple points */
- if(get_effector_data(cur, &efd, &epoint, 0)) {
- if(cur->pd && cur->pd->forcefield == PFIELD_BOID)
+ if (get_effector_data(cur, &efd, &epoint, 0)) {
+ if (cur->pd && cur->pd->forcefield == PFIELD_BOID)
priority = mul * pd->f_strength * effector_falloff(cur, &efd, &epoint, bbd->part->effector_weights);
else
priority = 1.0;
@@ -101,21 +101,21 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val,
break;
}
}
- else if(rule->type == eBoidRuleType_Goal && eob == bpa->ground)
+ else if (rule->type == eBoidRuleType_Goal && eob == bpa->ground)
; /* skip current object */
- else if(pd->forcefield == PFIELD_BOID && mul * pd->f_strength > 0.0f && get_effector_data(cur, &cur_efd, &epoint, 0)) {
+ else if (pd->forcefield == PFIELD_BOID && mul * pd->f_strength > 0.0f && get_effector_data(cur, &cur_efd, &epoint, 0)) {
float temp = mul * pd->f_strength * effector_falloff(cur, &cur_efd, &epoint, bbd->part->effector_weights);
- if(temp == 0.0f)
+ if (temp == 0.0f)
; /* do nothing */
- else if(temp > priority) {
+ else if (temp > priority) {
priority = temp;
eff = cur;
efd = cur_efd;
len = efd.distance;
}
/* choose closest object with same priority */
- else if(temp == priority && efd.distance < len) {
+ else if (temp == priority && efd.distance < len) {
eff = cur;
efd = cur_efd;
len = efd.distance;
@@ -124,7 +124,7 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val,
}
/* if the object doesn't have effector data we have to fake it */
- if(eff == NULL && gabr->ob) {
+ if (eff == NULL && gabr->ob) {
memset(&temp_eff, 0, sizeof(EffectorCache));
temp_eff.ob = gabr->ob;
temp_eff.scene = bbd->sim->scene;
@@ -134,12 +134,12 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val,
}
/* then use that effector */
- if(priority > (rule->type==eBoidRuleType_Avoid ? gabr->fear_factor : 0.0f)) { /* with avoid, factor is "fear factor" */
+ if (priority > (rule->type==eBoidRuleType_Avoid ? gabr->fear_factor : 0.0f)) { /* with avoid, factor is "fear factor" */
Object *eob = eff->ob;
PartDeflect *pd = eff->pd;
float surface = (pd && pd->shape == PFIELD_SHAPE_SURFACE) ? 1.0f : 0.0f;
- if(gabr->options & BRULE_GOAL_AVOID_PREDICT) {
+ if (gabr->options & BRULE_GOAL_AVOID_PREDICT) {
/* estimate future location of target */
get_effector_data(eff, &efd, &epoint, 1);
@@ -149,14 +149,14 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val,
efd.distance = len_v3(efd.vec_to_point);
}
- if(rule->type == eBoidRuleType_Goal && boids->options & BOID_ALLOW_CLIMB && surface!=0.0f) {
- if(!bbd->goal_ob || bbd->goal_priority < priority) {
+ if (rule->type == eBoidRuleType_Goal && boids->options & BOID_ALLOW_CLIMB && surface!=0.0f) {
+ if (!bbd->goal_ob || bbd->goal_priority < priority) {
bbd->goal_ob = eob;
copy_v3_v3(bbd->goal_co, efd.loc);
copy_v3_v3(bbd->goal_nor, efd.nor);
}
}
- else if(rule->type == eBoidRuleType_Avoid && bpa->data.mode == eBoidMode_Climbing &&
+ else if (rule->type == eBoidRuleType_Avoid && bpa->data.mode == eBoidMode_Climbing &&
priority > 2.0f * gabr->fear_factor) {
/* detach from surface and try to fly away from danger */
negate_v3_v3(efd.vec_to_point, bpa->gravity);
@@ -168,12 +168,12 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val,
bbd->wanted_speed = val->max_speed * priority;
/* with goals factor is approach velocity factor */
- if(rule->type == eBoidRuleType_Goal && boids->landing_smoothness > 0.0f) {
+ if (rule->type == eBoidRuleType_Goal && boids->landing_smoothness > 0.0f) {
float len2 = 2.0f*len_v3(pa->prev_state.vel);
surface *= pa->size * boids->height;
- if(len2 > 0.0f && efd.distance - surface < len2) {
+ if (len2 > 0.0f && efd.distance - surface < len2) {
len2 = (efd.distance - surface)/len2;
bbd->wanted_speed *= powf(len2, boids->landing_smoothness);
}
@@ -199,7 +199,7 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues *
int ret = 0;
//check deflector objects first
- if(acbr->options & BRULE_ACOLL_WITH_DEFLECTORS && bbd->sim->colliders) {
+ if (acbr->options & BRULE_ACOLL_WITH_DEFLECTORS && bbd->sim->colliders) {
ParticleCollision col;
BVHTreeRayHit hit;
float radius = val->personal_space * pa->size, ray_dir[3];
@@ -213,23 +213,23 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues *
hit.dist = col.original_ray_length = len_v3(ray_dir);
/* find out closest deflector object */
- for(coll = bbd->sim->colliders->first; coll; coll=coll->next) {
+ for (coll = bbd->sim->colliders->first; coll; coll=coll->next) {
/* don't check with current ground object */
- if(coll->ob == bpa->ground)
+ if (coll->ob == bpa->ground)
continue;
col.current = coll->ob;
col.md = coll->collmd;
- if(col.md && col.md->bvhtree)
+ if (col.md && col.md->bvhtree)
BLI_bvhtree_ray_cast(col.md->bvhtree, col.co1, ray_dir, radius, &hit, BKE_psys_collision_neartest_cb, &col);
}
/* then avoid that object */
- if(hit.index>=0) {
+ if (hit.index>=0) {
t = hit.dist/col.original_ray_length;
/* avoid head-on collision */
- if(dot_v3v3(col.pce.nor, pa->prev_state.ave) < -0.99f) {
+ if (dot_v3v3(col.pce.nor, pa->prev_state.ave) < -0.99f) {
/* don't know why, but uneven range [0.0,1.0] */
/* works much better than even [-1.0,1.0] */
bbd->wanted_co[0] = BLI_frand();
@@ -252,7 +252,7 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues *
//check boids in own system
if (acbr->options & BRULE_ACOLL_WITH_BOIDS) {
neighbors = BLI_kdtree_range_search(bbd->sim->psys->tree, acbr->look_ahead * len_v3(pa->prev_state.vel), pa->prev_state.co, pa->prev_state.ave, &ptn);
- if(neighbors > 1) for(n=1; n<neighbors; n++) {
+ if (neighbors > 1) for(n=1; n<neighbors; n++) {
copy_v3_v3(co1, pa->prev_state.co);
copy_v3_v3(vel1, pa->prev_state.vel);
copy_v3_v3(co2, (bbd->sim->psys->particles + ptn[n].index)->prev_state.co);
@@ -265,10 +265,10 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues *
inp = dot_v3v3(vec,vec);
/* velocities not parallel */
- if(inp != 0.0f) {
+ if (inp != 0.0f) {
t = -dot_v3v3(loc, vec)/inp;
/* cpa is not too far in the future so investigate further */
- if(t > 0.0f && t < t_min) {
+ if (t > 0.0f && t < t_min) {
madd_v3_v3fl(co1, vel1, t);
madd_v3_v3fl(co2, vel2, t);
@@ -277,7 +277,7 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues *
len = normalize_v3(vec);
/* distance of cpa is close enough */
- if(len < 2.0f * val->personal_space * pa->size) {
+ if (len < 2.0f * val->personal_space * pa->size) {
t_min = t;
mul_v3_fl(vec, len_v3(vel1));
@@ -293,12 +293,12 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues *
if (ptn) { MEM_freeN(ptn); ptn=NULL; }
/* check boids in other systems */
- for(pt=bbd->sim->psys->targets.first; pt; pt=pt->next) {
+ for (pt=bbd->sim->psys->targets.first; pt; pt=pt->next) {
ParticleSystem *epsys = psys_get_target_system(bbd->sim->ob, pt);
- if(epsys) {
+ if (epsys) {
neighbors = BLI_kdtree_range_search(epsys->tree, acbr->look_ahead * len_v3(pa->prev_state.vel), pa->prev_state.co, pa->prev_state.ave, &ptn);
- if(neighbors > 0) for(n=0; n<neighbors; n++) {
+ if (neighbors > 0) for(n=0; n<neighbors; n++) {
copy_v3_v3(co1, pa->prev_state.co);
copy_v3_v3(vel1, pa->prev_state.vel);
copy_v3_v3(co2, (epsys->particles + ptn[n].index)->prev_state.co);
@@ -311,10 +311,10 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues *
inp = dot_v3v3(vec,vec);
/* velocities not parallel */
- if(inp != 0.0f) {
+ if (inp != 0.0f) {
t = -dot_v3v3(loc, vec)/inp;
/* cpa is not too far in the future so investigate further */
- if(t > 0.0f && t < t_min) {
+ if (t > 0.0f && t < t_min) {
madd_v3_v3fl(co1, vel1, t);
madd_v3_v3fl(co2, vel2, t);
@@ -323,7 +323,7 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues *
len = normalize_v3(vec);
/* distance of cpa is close enough */
- if(len < 2.0f * val->personal_space * pa->size) {
+ if (len < 2.0f * val->personal_space * pa->size) {
t_min = t;
mul_v3_fl(vec, len_v3(vel1));
@@ -341,7 +341,7 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues *
}
- if(ptn && nearest==0)
+ if (ptn && nearest==0)
MEM_freeN(ptn);
return ret;
@@ -355,7 +355,7 @@ static int rule_separate(BoidRule *UNUSED(rule), BoidBrainData *bbd, BoidValues
int neighbors = BLI_kdtree_range_search(bbd->sim->psys->tree, 2.0f * val->personal_space * pa->size, pa->prev_state.co, NULL, &ptn);
int ret = 0;
- if(neighbors > 1 && ptn[1].dist!=0.0f) {
+ if (neighbors > 1 && ptn[1].dist!=0.0f) {
sub_v3_v3v3(vec, pa->prev_state.co, bbd->sim->psys->particles[ptn[1].index].state.co);
mul_v3_fl(vec, (2.0f * val->personal_space * pa->size - ptn[1].dist) / ptn[1].dist);
add_v3_v3(bbd->wanted_co, vec);
@@ -366,13 +366,13 @@ static int rule_separate(BoidRule *UNUSED(rule), BoidBrainData *bbd, BoidValues
if (ptn) { MEM_freeN(ptn); ptn=NULL; }
/* check other boid systems */
- for(pt=bbd->sim->psys->targets.first; pt; pt=pt->next) {
+ for (pt=bbd->sim->psys->targets.first; pt; pt=pt->next) {
ParticleSystem *epsys = psys_get_target_system(bbd->sim->ob, pt);
- if(epsys) {
+ if (epsys) {
neighbors = BLI_kdtree_range_search(epsys->tree, 2.0f * val->personal_space * pa->size, pa->prev_state.co, NULL, &ptn);
- if(neighbors > 0 && ptn[0].dist < len) {
+ if (neighbors > 0 && ptn[0].dist < len) {
sub_v3_v3v3(vec, pa->prev_state.co, ptn[0].co);
mul_v3_fl(vec, (2.0f * val->personal_space * pa->size - ptn[0].dist) / ptn[1].dist);
add_v3_v3(bbd->wanted_co, vec);
@@ -394,8 +394,8 @@ static int rule_flock(BoidRule *UNUSED(rule), BoidBrainData *bbd, BoidValues *UN
int n;
int ret = 0;
- if(neighbors > 1) {
- for(n=1; n<neighbors; n++) {
+ if (neighbors > 1) {
+ for (n=1; n<neighbors; n++) {
add_v3_v3(loc, bbd->sim->psys->particles[ptn[n].index].prev_state.co);
add_v3_v3(vec, bbd->sim->psys->particles[ptn[n].index].prev_state.vel);
}
@@ -422,7 +422,7 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
int n = (flbr->queue_size <= 1) ? bbd->sim->psys->totpart : flbr->queue_size;
int i, ret = 0, p = pa - bbd->sim->psys->particles;
- if(flbr->ob) {
+ if (flbr->ob) {
float vec2[3], t;
/* first check we're not blocking the leader*/
@@ -434,10 +434,10 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
mul = dot_v3v3(vec, vec);
/* leader is not moving */
- if(mul < 0.01f) {
+ if (mul < 0.01f) {
len = len_v3(loc);
/* too close to leader */
- if(len < 2.0f * val->personal_space * pa->size) {
+ if (len < 2.0f * val->personal_space * pa->size) {
copy_v3_v3(bbd->wanted_co, loc);
bbd->wanted_speed = val->max_speed;
return 1;
@@ -447,7 +447,7 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
t = dot_v3v3(loc, vec)/mul;
/* possible blocking of leader in near future */
- if(t > 0.0f && t < 3.0f) {
+ if (t > 0.0f && t < 3.0f) {
copy_v3_v3(vec2, vec);
mul_v3_fl(vec2, t);
@@ -455,7 +455,7 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
len = len_v3(vec2);
- if(len < 2.0f * val->personal_space * pa->size) {
+ if (len < 2.0f * val->personal_space * pa->size) {
copy_v3_v3(bbd->wanted_co, vec2);
bbd->wanted_speed = val->max_speed * (3.0f - t)/3.0f;
return 1;
@@ -464,7 +464,7 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
}
/* not blocking so try to follow leader */
- if(p && flbr->options & BRULE_LEADER_IN_LINE) {
+ if (p && flbr->options & BRULE_LEADER_IN_LINE) {
copy_v3_v3(vec, bbd->sim->psys->particles[p-1].prev_state.vel);
copy_v3_v3(loc, bbd->sim->psys->particles[p-1].prev_state.co);
}
@@ -482,11 +482,11 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
ret = 1;
}
- else if(p % n) {
+ else if (p % n) {
float vec2[3], t, t_min = 3.0f;
/* first check we're not blocking any leaders */
- for(i = 0; i< bbd->sim->psys->totpart; i+=n) {
+ for (i = 0; i< bbd->sim->psys->totpart; i+=n) {
copy_v3_v3(vec, bbd->sim->psys->particles[i].prev_state.vel);
sub_v3_v3v3(loc, pa->prev_state.co, bbd->sim->psys->particles[i].prev_state.co);
@@ -494,10 +494,10 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
mul = dot_v3v3(vec, vec);
/* leader is not moving */
- if(mul < 0.01f) {
+ if (mul < 0.01f) {
len = len_v3(loc);
/* too close to leader */
- if(len < 2.0f * val->personal_space * pa->size) {
+ if (len < 2.0f * val->personal_space * pa->size) {
copy_v3_v3(bbd->wanted_co, loc);
bbd->wanted_speed = val->max_speed;
return 1;
@@ -507,7 +507,7 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
t = dot_v3v3(loc, vec)/mul;
/* possible blocking of leader in near future */
- if(t > 0.0f && t < t_min) {
+ if (t > 0.0f && t < t_min) {
copy_v3_v3(vec2, vec);
mul_v3_fl(vec2, t);
@@ -515,7 +515,7 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
len = len_v3(vec2);
- if(len < 2.0f * val->personal_space * pa->size) {
+ if (len < 2.0f * val->personal_space * pa->size) {
t_min = t;
copy_v3_v3(bbd->wanted_co, loc);
bbd->wanted_speed = val->max_speed * (3.0f - t)/3.0f;
@@ -525,10 +525,10 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
}
}
- if(ret) return 1;
+ if (ret) return 1;
/* not blocking so try to follow leader */
- if(flbr->options & BRULE_LEADER_IN_LINE) {
+ if (flbr->options & BRULE_LEADER_IN_LINE) {
copy_v3_v3(vec, bbd->sim->psys->particles[p-1].prev_state.vel);
copy_v3_v3(loc, bbd->sim->psys->particles[p-1].prev_state.co);
}
@@ -554,7 +554,7 @@ static int rule_average_speed(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
BoidRuleAverageSpeed *asbr = (BoidRuleAverageSpeed*)rule;
float vec[3] = {0.0f, 0.0f, 0.0f};
- if(asbr->wander > 0.0f) {
+ if (asbr->wander > 0.0f) {
/* abuse pa->r_ave for wandering */
bpa->wander[0] += asbr->wander * (-1.0f + 2.0f * BLI_frand());
bpa->wander[1] += asbr->wander * (-1.0f + 2.0f * BLI_frand());
@@ -573,7 +573,7 @@ static int rule_average_speed(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
add_v3_v3(bbd->wanted_co, vec);
/* leveling */
- if(asbr->level > 0.0f && psys_uses_gravity(bbd->sim)) {
+ if (asbr->level > 0.0f && psys_uses_gravity(bbd->sim)) {
project_v3_v3v3(vec, bbd->wanted_co, bbd->sim->scene->physics_settings.gravity);
mul_v3_fl(vec, asbr->level);
sub_v3_v3(bbd->wanted_co, vec);
@@ -583,14 +583,14 @@ static int rule_average_speed(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
copy_v3_v3(bbd->wanted_co, pa->prev_state.ave);
/* may happen at birth */
- if(dot_v2v2(bbd->wanted_co,bbd->wanted_co)==0.0f) {
+ if (dot_v2v2(bbd->wanted_co,bbd->wanted_co)==0.0f) {
bbd->wanted_co[0] = 2.0f*(0.5f - BLI_frand());
bbd->wanted_co[1] = 2.0f*(0.5f - BLI_frand());
bbd->wanted_co[2] = 2.0f*(0.5f - BLI_frand());
}
/* leveling */
- if(asbr->level > 0.0f && psys_uses_gravity(bbd->sim)) {
+ if (asbr->level > 0.0f && psys_uses_gravity(bbd->sim)) {
project_v3_v3v3(vec, bbd->wanted_co, bbd->sim->scene->physics_settings.gravity);
mul_v3_fl(vec, asbr->level);
sub_v3_v3(bbd->wanted_co, vec);
@@ -618,7 +618,7 @@ static int rule_fight(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti
/* calculate own group strength */
int neighbors = BLI_kdtree_range_search(bbd->sim->psys->tree, fbr->distance, pa->prev_state.co, NULL, &ptn);
- for(n=0; n<neighbors; n++) {
+ for (n=0; n<neighbors; n++) {
bpa = bbd->sim->psys->particles[ptn[n].index].boid;
health += bpa->data.health;
}
@@ -628,39 +628,39 @@ static int rule_fight(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti
if (ptn) { MEM_freeN(ptn); ptn=NULL; }
/* add other friendlies and calculate enemy strength and find closest enemy */
- for(pt=bbd->sim->psys->targets.first; pt; pt=pt->next) {
+ for (pt=bbd->sim->psys->targets.first; pt; pt=pt->next) {
ParticleSystem *epsys = psys_get_target_system(bbd->sim->ob, pt);
- if(epsys) {
+ if (epsys) {
epars = epsys->particles;
neighbors = BLI_kdtree_range_search(epsys->tree, fbr->distance, pa->prev_state.co, NULL, &ptn);
health = 0.0f;
- for(n=0; n<neighbors; n++) {
+ for (n=0; n<neighbors; n++) {
bpa = epars[ptn[n].index].boid;
health += bpa->data.health;
- if(n==0 && pt->mode==PTARGET_MODE_ENEMY && ptn[n].dist < closest_dist) {
+ if (n==0 && pt->mode==PTARGET_MODE_ENEMY && ptn[n].dist < closest_dist) {
copy_v3_v3(closest_enemy, ptn[n].co);
closest_dist = ptn[n].dist;
enemy_pa = epars + ptn[n].index;
}
}
- if(pt->mode==PTARGET_MODE_ENEMY)
+ if (pt->mode==PTARGET_MODE_ENEMY)
e_strength += epsys->part->boids->strength * health;
- else if(pt->mode==PTARGET_MODE_FRIEND)
+ else if (pt->mode==PTARGET_MODE_FRIEND)
f_strength += epsys->part->boids->strength * health;
if (ptn) { MEM_freeN(ptn); ptn=NULL; }
}
}
/* decide action if enemy presence found */
- if(e_strength > 0.0f) {
+ if (e_strength > 0.0f) {
sub_v3_v3v3(bbd->wanted_co, closest_enemy, pa->prev_state.co);
/* attack if in range */
- if(closest_dist <= bbd->part->boids->range + pa->size + enemy_pa->size) {
+ if (closest_dist <= bbd->part->boids->range + pa->size + enemy_pa->size) {
float damage = BLI_frand();
float enemy_dir[3];
@@ -670,7 +670,7 @@ static int rule_fight(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti
bbd->wanted_speed = 0.0f;
/* must face enemy to fight */
- if(dot_v3v3(pa->prev_state.ave, enemy_dir)>0.5f) {
+ if (dot_v3v3(pa->prev_state.ave, enemy_dir)>0.5f) {
bpa = enemy_pa->boid;
bpa->data.health -= bbd->part->boids->strength * bbd->timestep * ((1.0f-bbd->part->boids->accuracy)*damage + bbd->part->boids->accuracy);
}
@@ -682,9 +682,9 @@ static int rule_fight(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti
/* check if boid doesn't want to fight */
bpa = pa->boid;
- if(bpa->data.health/bbd->part->boids->health * bbd->part->boids->aggression < e_strength / f_strength) {
+ if (bpa->data.health/bbd->part->boids->health * bbd->part->boids->aggression < e_strength / f_strength) {
/* decide to flee */
- if(closest_dist < fbr->flee_distance * fbr->distance) {
+ if (closest_dist < fbr->flee_distance * fbr->distance) {
negate_v3(bbd->wanted_co);
bbd->wanted_speed = val->max_speed;
}
@@ -722,7 +722,7 @@ static void set_boid_values(BoidValues *val, BoidSettings *boids, ParticleData *
{
BoidParticle *bpa = pa->boid;
- if(ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing)) {
+ if (ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing)) {
val->max_speed = boids->land_max_speed * bpa->data.health/boids->health;
val->max_acc = boids->land_max_acc * val->max_speed;
val->max_ave = boids->land_max_ave * (float)M_PI * bpa->data.health/boids->health;
@@ -744,7 +744,7 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float grou
{
BoidParticle *bpa = pa->boid;
- if(bpa->data.mode == eBoidMode_Climbing) {
+ if (bpa->data.mode == eBoidMode_Climbing) {
SurfaceModifierData *surmd = NULL;
float x[3], v[3];
@@ -766,7 +766,7 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float grou
BVHTreeRayHit hit;
float radius = 0.0f, t, ray_dir[3];
- if(!bbd->sim->colliders)
+ if (!bbd->sim->colliders)
return NULL;
/* first try to find below boid */
@@ -778,16 +778,16 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float grou
hit.dist = col.original_ray_length = len_v3(ray_dir);
col.pce.inside = 0;
- for(coll = bbd->sim->colliders->first; coll; coll = coll->next) {
+ for (coll = bbd->sim->colliders->first; coll; coll = coll->next) {
col.current = coll->ob;
col.md = coll->collmd;
col.fac1 = col.fac2 = 0.f;
- if(col.md && col.md->bvhtree)
+ if (col.md && col.md->bvhtree)
BLI_bvhtree_ray_cast(col.md->bvhtree, col.co1, ray_dir, radius, &hit, BKE_psys_collision_neartest_cb, &col);
}
/* then use that object */
- if(hit.index>=0) {
+ if (hit.index>=0) {
t = hit.dist/col.original_ray_length;
interp_v3_v3v3(ground_co, col.co1, col.co2, t);
normalize_v3_v3(ground_nor, col.pce.nor);
@@ -803,15 +803,15 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float grou
hit.index = -1;
hit.dist = col.original_ray_length = len_v3(ray_dir);
- for(coll = bbd->sim->colliders->first; coll; coll = coll->next) {
+ for (coll = bbd->sim->colliders->first; coll; coll = coll->next) {
col.current = coll->ob;
col.md = coll->collmd;
- if(col.md && col.md->bvhtree)
+ if (col.md && col.md->bvhtree)
BLI_bvhtree_ray_cast(col.md->bvhtree, col.co1, ray_dir, radius, &hit, BKE_psys_collision_neartest_cb, &col);
}
/* then use that object */
- if(hit.index>=0) {
+ if (hit.index>=0) {
t = hit.dist/col.original_ray_length;
interp_v3_v3v3(ground_co, col.co1, col.co2, t);
normalize_v3_v3(ground_nor, col.pce.nor);
@@ -830,13 +830,13 @@ static int boid_rule_applies(ParticleData *pa, BoidSettings *UNUSED(boids), Boid
{
BoidParticle *bpa = pa->boid;
- if(rule==NULL)
+ if (rule==NULL)
return 0;
- if(ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing) && rule->flag & BOIDRULE_ON_LAND)
+ if (ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing) && rule->flag & BOIDRULE_ON_LAND)
return 1;
- if(bpa->data.mode==eBoidMode_InAir && rule->flag & BOIDRULE_IN_AIR)
+ if (bpa->data.mode==eBoidMode_InAir && rule->flag & BOIDRULE_IN_AIR)
return 1;
return 0;
@@ -845,12 +845,12 @@ void boids_precalc_rules(ParticleSettings *part, float cfra)
{
BoidState *state = part->boids->states.first;
BoidRule *rule;
- for(; state; state=state->next) {
- for(rule = state->rules.first; rule; rule=rule->next) {
- if(rule->type==eBoidRuleType_FollowLeader) {
+ for (; state; state=state->next) {
+ for (rule = state->rules.first; rule; rule=rule->next) {
+ if (rule->type==eBoidRuleType_FollowLeader) {
BoidRuleFollowLeader *flbr = (BoidRuleFollowLeader*) rule;
- if(flbr->ob && flbr->cfra != cfra) {
+ if (flbr->ob && flbr->cfra != cfra) {
/* save object locations for velocity calculations */
copy_v3_v3(flbr->oloc, flbr->loc);
copy_v3_v3(flbr->loc, flbr->ob->obmat[3]);
@@ -889,16 +889,16 @@ static float boid_goal_signed_dist(float *boid_co, float *goal_co, float *goal_n
/* wanted_co is relative to boid location */
static int apply_boid_rule(BoidBrainData *bbd, BoidRule *rule, BoidValues *val, ParticleData *pa, float fuzziness)
{
- if(rule==NULL)
+ if (rule==NULL)
return 0;
- if(boid_rule_applies(pa, bbd->part->boids, rule)==0)
+ if (boid_rule_applies(pa, bbd->part->boids, rule)==0)
return 0;
- if(boid_rules[rule->type](rule, bbd, val, pa)==0)
+ if (boid_rules[rule->type](rule, bbd, val, pa)==0)
return 0;
- if(fuzziness < 0.0f || compare_len_v3v3(bbd->wanted_co, pa->prev_state.vel, fuzziness * len_v3(pa->prev_state.vel))==0)
+ if (fuzziness < 0.0f || compare_len_v3v3(bbd->wanted_co, pa->prev_state.vel, fuzziness * len_v3(pa->prev_state.vel))==0)
return 1;
else
return 0;
@@ -908,14 +908,14 @@ static BoidState *get_boid_state(BoidSettings *boids, ParticleData *pa)
BoidState *state = boids->states.first;
BoidParticle *bpa = pa->boid;
- for(; state; state=state->next) {
- if(state->id==bpa->data.state_id)
+ for (; state; state=state->next) {
+ if (state->id==bpa->data.state_id)
return state;
}
/* for some reason particle isn't at a valid state */
state = boids->states.first;
- if(state)
+ if (state)
bpa->data.state_id = state->id;
return state;
@@ -937,7 +937,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
int rand;
//BoidCondition *cond;
- if(bpa->data.health <= 0.0f) {
+ if (bpa->data.health <= 0.0f) {
pa->alive = PARS_DYING;
pa->dietime = bbd->cfra;
return;
@@ -946,7 +946,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
//planned for near future
//cond = state->conditions.first;
//for(; cond; cond=cond->next) {
- // if(boid_condition_is_true(cond)) {
+ // if (boid_condition_is_true(cond)) {
// pa->boid->state_id = cond->state_id;
// state = get_boid_state(boids, pa);
// break; /* only first true condition is used */
@@ -965,8 +965,8 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
switch(state->ruleset_type) {
case eBoidRulesetType_Fuzzy:
{
- for(rule = state->rules.first; rule; rule = rule->next) {
- if(apply_boid_rule(bbd, rule, &val, pa, state->rule_fuzziness))
+ for (rule = state->rules.first; rule; rule = rule->next) {
+ if (apply_boid_rule(bbd, rule, &val, pa, state->rule_fuzziness))
break; /* only first nonzero rule that comes through fuzzy rule is applied */
}
break;
@@ -982,8 +982,8 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
{
float wanted_co[3] = {0.0f, 0.0f, 0.0f}, wanted_speed = 0.0f;
int n = 0;
- for(rule = state->rules.first; rule; rule=rule->next) {
- if(apply_boid_rule(bbd, rule, &val, pa, -1.0f)) {
+ for (rule = state->rules.first; rule; rule=rule->next) {
+ if (apply_boid_rule(bbd, rule, &val, pa, -1.0f)) {
add_v3_v3(wanted_co, bbd->wanted_co);
wanted_speed += bbd->wanted_speed;
n++;
@@ -991,7 +991,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
}
}
- if(n > 1) {
+ if (n > 1) {
mul_v3_fl(wanted_co, 1.0f/(float)n);
wanted_speed /= (float)n;
}
@@ -1004,11 +1004,11 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
}
/* decide on jumping & liftoff */
- if(bpa->data.mode == eBoidMode_OnLand) {
+ if (bpa->data.mode == eBoidMode_OnLand) {
/* fuzziness makes boids capable of misjudgement */
float mul = 1.0f + state->rule_fuzziness;
- if(boids->options & BOID_ALLOW_FLIGHT && bbd->wanted_co[2] > 0.0f) {
+ if (boids->options & BOID_ALLOW_FLIGHT && bbd->wanted_co[2] > 0.0f) {
float cvel[3], dir[3];
copy_v3_v3(dir, pa->prev_state.ave);
@@ -1017,15 +1017,15 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
copy_v3_v3(cvel, bbd->wanted_co);
normalize_v2(cvel);
- if(dot_v2v2(cvel, dir) > 0.95f / mul)
+ if (dot_v2v2(cvel, dir) > 0.95f / mul)
bpa->data.mode = eBoidMode_Liftoff;
}
- else if(val.jump_speed > 0.0f) {
+ else if (val.jump_speed > 0.0f) {
float jump_v[3];
int jump = 0;
/* jump to get to a location */
- if(bbd->wanted_co[2] > 0.0f) {
+ if (bbd->wanted_co[2] > 0.0f) {
float cvel[3], dir[3];
float z_v, ground_v, cur_v;
float len;
@@ -1040,7 +1040,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
/* first of all, are we going in a suitable direction? */
/* or at a suitably slow speed */
- if(dot_v2v2(cvel, dir) > 0.95f / mul || len <= state->rule_fuzziness) {
+ if (dot_v2v2(cvel, dir) > 0.95f / mul || len <= state->rule_fuzziness) {
/* try to reach goal at highest point of the parabolic path */
cur_v = len_v2(pa->prev_state.vel);
z_v = sasqrt(-2.0f * bbd->sim->scene->physics_settings.gravity[2] * bbd->wanted_co[2]);
@@ -1048,7 +1048,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
len = sasqrt((ground_v-cur_v)*(ground_v-cur_v) + z_v*z_v);
- if(len < val.jump_speed * mul || bbd->part->boids->options & BOID_ALLOW_FLIGHT) {
+ if (len < val.jump_speed * mul || bbd->part->boids->options & BOID_ALLOW_FLIGHT) {
jump = 1;
len = MIN2(len, val.jump_speed);
@@ -1065,11 +1065,11 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
}
/* jump to go faster */
- if(jump == 0 && val.jump_speed > val.max_speed && bbd->wanted_speed > val.max_speed) {
+ if (jump == 0 && val.jump_speed > val.max_speed && bbd->wanted_speed > val.max_speed) {
}
- if(jump) {
+ if (jump) {
copy_v3_v3(pa->prev_state.vel, jump_v);
bpa->data.mode = eBoidMode_Falling;
}
@@ -1098,14 +1098,14 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
/* make sure there's something in new velocity, location & rotation */
copy_particle_key(&pa->state,&pa->prev_state,0);
- if(bbd->part->flag & PART_SIZEMASS)
+ if (bbd->part->flag & PART_SIZEMASS)
pa_mass*=pa->size;
/* if boids can't fly they fall to the ground */
- if((boids->options & BOID_ALLOW_FLIGHT)==0 && ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing)==0 && psys_uses_gravity(bbd->sim))
+ if ((boids->options & BOID_ALLOW_FLIGHT)==0 && ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing)==0 && psys_uses_gravity(bbd->sim))
bpa->data.mode = eBoidMode_Falling;
- if(bpa->data.mode == eBoidMode_Falling) {
+ if (bpa->data.mode == eBoidMode_Falling) {
/* Falling boids are only effected by gravity. */
acc[2] = bbd->sim->scene->physics_settings.gravity[2];
}
@@ -1115,11 +1115,11 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
float level = landing_level + 1.0f;
float new_vel[3];
- if(bpa->data.mode == eBoidMode_Liftoff) {
+ if (bpa->data.mode == eBoidMode_Liftoff) {
bpa->data.mode = eBoidMode_InAir;
bpa->ground = boid_find_ground(bbd, pa, ground_co, ground_nor);
}
- else if(bpa->data.mode == eBoidMode_InAir && boids->options & BOID_ALLOW_LAND) {
+ else if (bpa->data.mode == eBoidMode_InAir && boids->options & BOID_ALLOW_LAND) {
/* auto-leveling & landing if close to ground */
bpa->ground = boid_find_ground(bbd, pa, ground_co, ground_nor);
@@ -1129,13 +1129,13 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
landing_level = - boids->landing_smoothness * pa->prev_state.vel[2] * pa_mass;
- if(pa->prev_state.vel[2] < 0.0f) {
- if(level < 1.0f) {
+ if (pa->prev_state.vel[2] < 0.0f) {
+ if (level < 1.0f) {
bbd->wanted_co[0] = bbd->wanted_co[1] = bbd->wanted_co[2] = 0.0f;
bbd->wanted_speed = 0.0f;
bpa->data.mode = eBoidMode_Falling;
}
- else if(level < landing_level) {
+ else if (level < landing_level) {
bbd->wanted_speed *= (level - 1.0f)/landing_level;
bbd->wanted_co[2] *= (level - 1.0f)/landing_level;
}
@@ -1146,7 +1146,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
new_speed = normalize_v3_v3(wanted_dir, bbd->wanted_co);
/* first check if we have valid direction we want to go towards */
- if(new_speed == 0.0f) {
+ if (new_speed == 0.0f) {
copy_v3_v3(new_dir, old_dir);
}
else {
@@ -1158,7 +1158,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
/* choose random direction to turn if wanted velocity */
/* is directly behind regardless of z-coordinate */
- if(dot_v2v2(old_dir2, wanted_dir2) < -0.99f) {
+ if (dot_v2v2(old_dir2, wanted_dir2) < -0.99f) {
wanted_dir[0] = 2.0f*(0.5f - BLI_frand());
wanted_dir[1] = 2.0f*(0.5f - BLI_frand());
wanted_dir[2] = 2.0f*(0.5f - BLI_frand());
@@ -1185,7 +1185,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
/* constrain speed with maximum acceleration */
old_speed = len_v3(pa->prev_state.vel);
- if(bbd->wanted_speed < old_speed)
+ if (bbd->wanted_speed < old_speed)
new_speed = MAX2(bbd->wanted_speed, old_speed - val.max_acc);
else
new_speed = MIN2(bbd->wanted_speed, old_speed + val.max_acc);
@@ -1195,7 +1195,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
mul_v3_fl(new_vel, new_speed);
/* maintain minimum flying velocity if not landing */
- if(level >= landing_level) {
+ if (level >= landing_level) {
float len2 = dot_v2v2(new_vel,new_vel);
float root;
@@ -1224,7 +1224,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
pd_point_from_particle(bbd->sim, pa, &pa->state, &epoint);
pdDoEffectors(bbd->sim->psys->effectors, bbd->sim->colliders, bbd->part->effector_weights, &epoint, force, NULL);
- if(ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing)) {
+ if (ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing)) {
float length = normalize_v3(force);
length = MAX2(0.0f, length - boids->land_stick_force);
@@ -1268,7 +1268,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
grav[2]= bbd->sim->scene->physics_settings.gravity[2] < 0.0f ? -1.0f : 0.0f;
/* don't take forward acceleration into account (better banking) */
- if(dot_v3v3(bpa->data.acc, pa->state.vel) > 0.0f) {
+ if (dot_v3v3(bpa->data.acc, pa->state.vel) > 0.0f) {
project_v3_v3v3(dvec, bpa->data.acc, pa->state.vel);
sub_v3_v3v3(dvec, bpa->data.acc, dvec);
}
@@ -1281,21 +1281,21 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
normalize_v3(bpa->gravity);
/* stick boid on goal when close enough */
- if(bbd->goal_ob && boid_goal_signed_dist(pa->state.co, bbd->goal_co, bbd->goal_nor) <= pa->size * boids->height) {
+ if (bbd->goal_ob && boid_goal_signed_dist(pa->state.co, bbd->goal_co, bbd->goal_nor) <= pa->size * boids->height) {
bpa->data.mode = eBoidMode_Climbing;
bpa->ground = bbd->goal_ob;
boid_find_ground(bbd, pa, ground_co, ground_nor);
boid_climb(boids, pa, ground_co, ground_nor);
}
- else if(pa->state.co[2] <= ground_co[2] + pa->size * boids->height) {
+ else if (pa->state.co[2] <= ground_co[2] + pa->size * boids->height) {
/* land boid when below ground */
- if(boids->options & BOID_ALLOW_LAND) {
+ if (boids->options & BOID_ALLOW_LAND) {
pa->state.co[2] = ground_co[2] + pa->size * boids->height;
pa->state.vel[2] = 0.0f;
bpa->data.mode = eBoidMode_OnLand;
}
/* fly above ground */
- else if(bpa->ground) {
+ else if (bpa->ground) {
pa->state.co[2] = ground_co[2] + pa->size * boids->height;
pa->state.vel[2] = 0.0f;
}
@@ -1315,22 +1315,22 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
madd_v3_v3fl(bpa->gravity, grav, dtime);
normalize_v3(bpa->gravity);
- if(boids->options & BOID_ALLOW_LAND) {
+ if (boids->options & BOID_ALLOW_LAND) {
/* stick boid on goal when close enough */
- if(bbd->goal_ob && boid_goal_signed_dist(pa->state.co, bbd->goal_co, bbd->goal_nor) <= pa->size * boids->height) {
+ if (bbd->goal_ob && boid_goal_signed_dist(pa->state.co, bbd->goal_co, bbd->goal_nor) <= pa->size * boids->height) {
bpa->data.mode = eBoidMode_Climbing;
bpa->ground = bbd->goal_ob;
boid_find_ground(bbd, pa, ground_co, ground_nor);
boid_climb(boids, pa, ground_co, ground_nor);
}
/* land boid when really near ground */
- else if(pa->state.co[2] <= ground_co[2] + 1.01f * pa->size * boids->height) {
+ else if (pa->state.co[2] <= ground_co[2] + 1.01f * pa->size * boids->height) {
pa->state.co[2] = ground_co[2] + pa->size * boids->height;
pa->state.vel[2] = 0.0f;
bpa->data.mode = eBoidMode_OnLand;
}
/* if we're falling, can fly and want to go upwards lets fly */
- else if(boids->options & BOID_ALLOW_FLIGHT && bbd->wanted_co[2] > 0.0f)
+ else if (boids->options & BOID_ALLOW_FLIGHT && bbd->wanted_co[2] > 0.0f)
bpa->data.mode = eBoidMode_InAir;
}
else
@@ -1359,14 +1359,14 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
case eBoidMode_OnLand:
{
/* stick boid on goal when close enough */
- if(bbd->goal_ob && boid_goal_signed_dist(pa->state.co, bbd->goal_co, bbd->goal_nor) <= pa->size * boids->height) {
+ if (bbd->goal_ob && boid_goal_signed_dist(pa->state.co, bbd->goal_co, bbd->goal_nor) <= pa->size * boids->height) {
bpa->data.mode = eBoidMode_Climbing;
bpa->ground = bbd->goal_ob;
boid_find_ground(bbd, pa, ground_co, ground_nor);
boid_climb(boids, pa, ground_co, ground_nor);
}
/* ground is too far away so boid falls */
- else if(pa->state.co[2]-ground_co[2] > 1.1f * pa->size * boids->height)
+ else if (pa->state.co[2]-ground_co[2] > 1.1f * pa->size * boids->height)
bpa->data.mode = eBoidMode_Falling;
else {
/* constrain to surface */
@@ -1374,7 +1374,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
pa->state.vel[2] = 0.0f;
}
- if(boids->banking > 0.0f) {
+ if (boids->banking > 0.0f) {
float grav[3];
/* Don't take gravity's strength in to account, */
/* otherwise amount of banking is hard to control. */
@@ -1398,18 +1398,18 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
/* save direction to state.ave unless the boid is falling */
/* (boids can't effect their direction when falling) */
- if(bpa->data.mode!=eBoidMode_Falling && len_v3(pa->state.vel) > 0.1f*pa->size) {
+ if (bpa->data.mode!=eBoidMode_Falling && len_v3(pa->state.vel) > 0.1f*pa->size) {
copy_v3_v3(pa->state.ave, pa->state.vel);
pa->state.ave[2] *= bbd->part->boids->pitch;
normalize_v3(pa->state.ave);
}
/* apply damping */
- if(ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing))
+ if (ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing))
mul_v3_fl(pa->state.vel, 1.0f - 0.2f*bbd->part->dampfac);
/* calculate rotation matrix based on forward & down vectors */
- if(bpa->data.mode == eBoidMode_InAir) {
+ if (bpa->data.mode == eBoidMode_InAir) {
copy_v3_v3(mat[0], pa->state.ave);
project_v3_v3v3(dvec, bpa->gravity, pa->state.ave);
@@ -1434,7 +1434,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
BoidRule *boid_new_rule(int type)
{
BoidRule *rule = NULL;
- if(type <= 0)
+ if (type <= 0)
return NULL;
switch(type) {
@@ -1501,7 +1501,7 @@ BoidState *boid_new_state(BoidSettings *boids)
BoidState *state = MEM_callocN(sizeof(BoidState), "BoidState");
state->id = boids->last_state_id++;
- if(state->id)
+ if (state->id)
BLI_snprintf(state->name, sizeof(state->name), "State %i", state->id);
else
strcpy(state->name, "State");
@@ -1527,10 +1527,10 @@ BoidState *boid_duplicate_state(BoidSettings *boids, BoidState *state)
}
void boid_free_settings(BoidSettings *boids)
{
- if(boids) {
+ if (boids) {
BoidState *state = boids->states.first;
- for(; state; state=state->next) {
+ for (; state; state=state->next) {
BLI_freelistN(&state->rules);
BLI_freelistN(&state->conditions);
BLI_freelistN(&state->actions);
@@ -1545,7 +1545,7 @@ BoidSettings *boid_copy_settings(BoidSettings *boids)
{
BoidSettings *nboids = NULL;
- if(boids) {
+ if (boids) {
BoidState *state;
BoidState *nstate;
@@ -1555,7 +1555,7 @@ BoidSettings *boid_copy_settings(BoidSettings *boids)
state = boids->states.first;
nstate = nboids->states.first;
- for(; state; state=state->next, nstate=nstate->next) {
+ for (; state; state=state->next, nstate=nstate->next) {
BLI_duplicatelist(&nstate->rules, &state->rules);
BLI_duplicatelist(&nstate->conditions, &state->conditions);
BLI_duplicatelist(&nstate->actions, &state->actions);
@@ -1568,8 +1568,8 @@ BoidState *boid_get_current_state(BoidSettings *boids)
{
BoidState *state = boids->states.first;
- for(; state; state=state->next) {
- if(state->flag & BOIDSTATE_CURRENT)
+ for (; state; state=state->next) {
+ if (state->flag & BOIDSTATE_CURRENT)
break;
}
diff --git a/source/blender/blenkernel/intern/booleanops_mesh.c b/source/blender/blenkernel/intern/booleanops_mesh.c
index ea626df5018..31c90d54d14 100644
--- a/source/blender/blenkernel/intern/booleanops_mesh.c
+++ b/source/blender/blenkernel/intern/booleanops_mesh.c
@@ -208,7 +208,8 @@ CSG_PerformOp(
mesh2->m_vertex_iterator,
InterpFaceVertexData
);
- } else {
+ }
+ else {
success =
CSG_PerformBooleanOperation(
bool_op,
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index c178bf6f0a7..e7ba09d3959 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -197,23 +197,23 @@ void make_local_brush(Brush *brush)
Scene *scene;
int is_local= FALSE, is_lib= FALSE;
- if(brush->id.lib==NULL) return;
+ if (brush->id.lib==NULL) return;
- if(brush->clone.image) {
+ if (brush->clone.image) {
/* special case: ima always local immediately. Clone image should only
* have one user anyway. */
id_clear_lib_data(bmain, &brush->clone.image->id);
extern_local_brush(brush);
}
- for(scene= bmain->scene.first; scene && ELEM(0, is_lib, is_local); scene=scene->id.next) {
- if(paint_brush(&scene->toolsettings->imapaint.paint)==brush) {
- if(scene->id.lib) is_lib= TRUE;
+ for (scene= bmain->scene.first; scene && ELEM(0, is_lib, is_local); scene=scene->id.next) {
+ if (paint_brush(&scene->toolsettings->imapaint.paint)==brush) {
+ if (scene->id.lib) is_lib= TRUE;
else is_local= TRUE;
}
}
- if(is_local && is_lib == FALSE) {
+ if (is_local && is_lib == FALSE) {
id_clear_lib_data(bmain, &brush->id);
extern_local_brush(brush);
@@ -223,7 +223,7 @@ void make_local_brush(Brush *brush)
brush->id.us++;
}
}
- else if(is_local && is_lib) {
+ else if (is_local && is_lib) {
Brush *brush_new= copy_brush(brush);
brush_new->id.us= 1; /* only keep fake user */
brush_new->id.flag |= LIB_FAKEUSER;
@@ -231,9 +231,9 @@ void make_local_brush(Brush *brush)
/* Remap paths of new ID using old library as base. */
BKE_id_lib_local_paths(bmain, brush->id.lib, &brush_new->id);
- for(scene= bmain->scene.first; scene; scene=scene->id.next) {
- if(paint_brush(&scene->toolsettings->imapaint.paint)==brush) {
- if(scene->id.lib==NULL) {
+ for (scene= bmain->scene.first; scene; scene=scene->id.next) {
+ if (paint_brush(&scene->toolsettings->imapaint.paint)==brush) {
+ if (scene->id.lib==NULL) {
paint_brush_set(&scene->toolsettings->imapaint.paint, brush_new);
}
}
@@ -248,13 +248,13 @@ void brush_debug_print_state(Brush *br)
brush_set_defaults(&def);
#define BR_TEST(field, t) \
- if(br->field != def.field) \
+ if (br->field != def.field) \
printf("br->" #field " = %" #t ";\n", br->field)
#define BR_TEST_FLAG(_f) \
- if((br->flag & _f) && !(def.flag & _f)) \
+ if ((br->flag & _f) && !(def.flag & _f)) \
printf("br->flag |= " #_f ";\n"); \
- else if(!(br->flag & _f) && (def.flag & _f)) \
+ else if (!(br->flag & _f) && (def.flag & _f)) \
printf("br->flag &= ~" #_f ";\n")
@@ -412,7 +412,7 @@ void brush_curve_preset(Brush *b, /*CurveMappingPreset*/int preset)
{
CurveMap *cm = NULL;
- if(!b->curve)
+ if (!b->curve)
b->curve = curvemapping_add(1, 0, 0, 1, 1);
cm = b->curve->cm;
@@ -430,12 +430,12 @@ int brush_texture_set_nr(Brush *brush, int nr)
id= (ID *)brush->mtex.tex;
idtest= (ID*)BLI_findlink(&G.main->tex, nr-1);
- if(idtest==NULL) { /* new tex */
- if(id) idtest= (ID *)copy_texture((Tex *)id);
+ if (idtest==NULL) { /* new tex */
+ if (id) idtest= (ID *)copy_texture((Tex *)id);
else idtest= (ID *)add_texture("Tex");
idtest->us--;
}
- if(idtest!=id) {
+ if (idtest!=id) {
brush_texture_delete(brush);
brush->mtex.tex= (Tex*)idtest;
@@ -449,7 +449,7 @@ int brush_texture_set_nr(Brush *brush, int nr)
int brush_texture_delete(Brush *brush)
{
- if(brush->mtex.tex)
+ if (brush->mtex.tex)
brush->mtex.tex->id.us--;
return 1;
@@ -457,10 +457,10 @@ int brush_texture_delete(Brush *brush)
int brush_clone_image_set_nr(Brush *brush, int nr)
{
- if(brush && nr > 0) {
+ if (brush && nr > 0) {
Image *ima= (Image*)BLI_findlink(&G.main->image, nr-1);
- if(ima) {
+ if (ima) {
brush_clone_image_delete(brush);
brush->clone.image= ima;
id_us_plus(&ima->id);
@@ -717,7 +717,7 @@ void brush_scale_unprojected_radius(float *unprojected_radius,
{
float scale = new_brush_size;
/* avoid division by zero */
- if(old_brush_size != 0)
+ if (old_brush_size != 0)
scale /= (float)old_brush_size;
(*unprojected_radius) *= scale;
}
@@ -729,7 +729,7 @@ void brush_scale_size(int *brush_size,
{
float scale = new_unprojected_radius;
/* avoid division by zero */
- if(old_unprojected_radius != 0)
+ if (old_unprojected_radius != 0)
scale /= new_unprojected_radius;
(*brush_size)= (int)((float)(*brush_size) * scale);
}
@@ -1077,7 +1077,7 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, const float pos[2
int totpaintops= 0;
if (pressure == 0.0f) {
- if(painter->lastpressure) // XXX - hack, operator misses
+ if (painter->lastpressure) // XXX - hack, operator misses
pressure= painter->lastpressure;
else
pressure = 1.0f; /* zero pressure == not using tablet */
@@ -1172,7 +1172,8 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, const float pos[2
painter->accumdistance -= spacing;
startdistance -= spacing;
}
- } else {
+ }
+ else {
brush_jitter_pos(scene, brush, pos, finalpos);
if (painter->cache.enabled)
@@ -1230,19 +1231,19 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, const float pos[2
/* Uses the brush curve control to find a strength value between 0 and 1 */
float brush_curve_strength_clamp(Brush *br, float p, const float len)
{
- if(p >= len) return 0;
+ if (p >= len) return 0;
else p= p/len;
p= curvemapping_evaluateF(br->curve, 0, p);
- if(p < 0.0f) p= 0.0f;
- else if(p > 1.0f) p= 1.0f;
+ if (p < 0.0f) p= 0.0f;
+ else if (p > 1.0f) p= 1.0f;
return p;
}
/* same as above but can return negative values if the curve enables
* used for sculpt only */
float brush_curve_strength(Brush *br, float p, const float len)
{
- if(p >= len)
+ if (p >= len)
p= 1.0f;
else
p= p/len;
@@ -1259,7 +1260,7 @@ unsigned int *brush_gen_texture_cache(Brush *br, int half_side)
int hasrgb, ix, iy;
int side = half_side * 2;
- if(mtex->tex) {
+ if (mtex->tex) {
float x, y, step = 2.0 / side, co[3];
texcache = MEM_callocN(sizeof(int) * side * side, "Brush texture cache");
@@ -1280,7 +1281,7 @@ unsigned int *brush_gen_texture_cache(Brush *br, int half_side)
* intensity, so calculate one (formula from do_material_tex).
* if the texture didn't give an RGB value, copy the intensity across
*/
- if(hasrgb & TEX_RGB)
+ if (hasrgb & TEX_RGB)
texres.tin = (0.35f * texres.tr + 0.45f *
texres.tg + 0.2f * texres.tb);
@@ -1309,17 +1310,17 @@ struct ImBuf *brush_gen_radial_control_imbuf(Brush *br)
im->rect_float = MEM_callocN(sizeof(float) * side * side, "radial control rect");
im->x = im->y = side;
- for(i=0; i<side; ++i) {
- for(j=0; j<side; ++j) {
+ for (i=0; i<side; ++i) {
+ for (j=0; j<side; ++j) {
float magn= sqrt(pow(i - half, 2) + pow(j - half, 2));
im->rect_float[i*side + j]= brush_curve_strength_clamp(br, magn, half);
}
}
/* Modulate curve with texture */
- if(texcache) {
- for(i=0; i<side; ++i) {
- for(j=0; j<side; ++j) {
+ if (texcache) {
+ for (i=0; i<side; ++i) {
+ for (j=0; j<side; ++j) {
const int col= texcache[i*side+j];
im->rect_float[i*side+j]*= (((char*)&col)[0]+((char*)&col)[1]+((char*)&col)[2])/3.0f/255.0f;
}
diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c
index 90cdb7bb130..d7c7a9a569b 100644
--- a/source/blender/blenkernel/intern/bvhutils.c
+++ b/source/blender/blenkernel/intern/bvhutils.c
@@ -51,7 +51,7 @@ float bvhtree_ray_tri_intersection(const BVHTreeRay *ray, const float UNUSED(m_d
{
float dist;
- if(isect_ray_tri_epsilon_v3(ray->origin, ray->direction, v0, v1, v2, &dist, NULL, FLT_EPSILON))
+ if (isect_ray_tri_epsilon_v3(ray->origin, ray->direction, v0, v1, v2, &dist, NULL, FLT_EPSILON))
return dist;
return FLT_MAX;
@@ -121,7 +121,7 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f
lv = 1;
}
else {
- if(fabsf(A00) > FLT_EPSILON)
+ if (fabsf(A00) > FLT_EPSILON)
S = -B0/A00;
else
S = 0.0f;
@@ -142,7 +142,7 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f
lv = 2;
}
else {
- if(fabsf(A11) > FLT_EPSILON)
+ if (fabsf(A11) > FLT_EPSILON)
T = -B1 / A11;
else
T = 0.0f;
@@ -164,7 +164,7 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f
lv = 2;
}
else {
- if(fabsf(A11) > FLT_EPSILON)
+ if (fabsf(A11) > FLT_EPSILON)
T = -B1 / A11;
else
T = 0.0;
@@ -197,7 +197,7 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f
else { /* Region 0 */
// Minimum at interior lv
float invDet;
- if(fabsf(Det) > FLT_EPSILON)
+ if (fabsf(Det) > FLT_EPSILON)
invDet = 1.0f / Det;
else
invDet = 0.0f;
@@ -223,7 +223,7 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f
lv = 1;
}
else {
- if(fabsf(denom) > FLT_EPSILON)
+ if (fabsf(denom) > FLT_EPSILON)
S = numer / denom;
else
S = 0.0f;
@@ -246,7 +246,7 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f
lv = 0;
}
else {
- if(fabsf(A11) > FLT_EPSILON)
+ if (fabsf(A11) > FLT_EPSILON)
T = -B1 / A11;
else
T = 0.0f;
@@ -268,7 +268,7 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f
lv = 2;
}
else {
- if(fabsf(denom) > FLT_EPSILON)
+ if (fabsf(denom) > FLT_EPSILON)
T = numer / denom;
else
T = 0.0f;
@@ -291,7 +291,7 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f
lv = 0;
}
else {
- if(fabsf(A00) > FLT_EPSILON)
+ if (fabsf(A00) > FLT_EPSILON)
S = -B0 / A00;
else
S = 0.0f;
@@ -317,7 +317,7 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f
lv = 1;
}
else {
- if(fabsf(denom) > FLT_EPSILON)
+ if (fabsf(denom) > FLT_EPSILON)
S = numer / denom;
else
S = 0.0f;
@@ -390,7 +390,7 @@ static void mesh_faces_nearest_point(void *userdata, int index, const float co[3
t2 = t3;
t3 = NULL;
- } while(t2);
+ } while (t2);
}
// Callback to bvh tree raycast. The tree must bust have been built using bvhtree_from_mesh_faces.
@@ -411,7 +411,7 @@ static void mesh_faces_spherecast(void *userdata, int index, const BVHTreeRay *r
do
{
float dist;
- if(data->sphere_radius == 0.0f)
+ if (data->sphere_radius == 0.0f)
dist = bvhtree_ray_tri_intersection(ray, hit->dist, t0, t1, t2);
else
dist = sphereray_tri_intersection(ray, data->sphere_radius, hit->dist, t0, t1, t2);
@@ -428,7 +428,7 @@ static void mesh_faces_spherecast(void *userdata, int index, const BVHTreeRay *r
t2 = t3;
t3 = NULL;
- } while(t2);
+ } while (t2);
}
// Callback to bvh tree nearest point. The tree must bust have been built using bvhtree_from_mesh_edges.
@@ -465,7 +465,7 @@ BVHTree* bvhtree_from_mesh_verts(BVHTreeFromMesh *data, DerivedMesh *mesh, float
BVHTree *tree = bvhcache_find(&mesh->bvhCache, BVHTREE_FROM_VERTICES);
//Not in cache
- if(tree == NULL) {
+ if (tree == NULL) {
int i;
int numVerts= mesh->getNumVerts(mesh);
MVert *vert = mesh->getVertDataArray(mesh, CD_MVERT);
@@ -530,12 +530,12 @@ BVHTree* bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *mesh, float
* if not caller should use DM_ensure_tessface() */
BLI_assert(!(numFaces == 0 && mesh->getNumPolys(mesh) != 0));
- if(numFaces != 0) {
+ if (numFaces != 0) {
/* Create a bvh-tree of the given target */
tree = BLI_bvhtree_new(numFaces, epsilon, tree_type, axis);
if (tree != NULL) {
BMEditMesh *em= data->em_evil;
- if(em) {
+ if (em) {
/* data->em_evil is only set for snapping, and only for the mesh of the object
* which is currently open in edit mode. When set, the bvhtree should not contain
* faces that will interfere with snapping (e.g. faces that are hidden/selected
@@ -598,12 +598,12 @@ BVHTree* bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *mesh, float
MFace *face = mesh->getTessFaceDataArray(mesh, CD_MFACE);
if (vert != NULL && face != NULL) {
- for(i = 0; i < numFaces; i++) {
+ for (i = 0; i < numFaces; i++) {
float co[4][3];
copy_v3_v3(co[0], vert[ face[i].v1 ].co);
copy_v3_v3(co[1], vert[ face[i].v2 ].co);
copy_v3_v3(co[2], vert[ face[i].v3 ].co);
- if(face[i].v4)
+ if (face[i].v4)
copy_v3_v3(co[3], vert[ face[i].v4 ].co);
BLI_bvhtree_insert(tree, i, co[0], face[i].v4 ? 4 : 3);
@@ -627,7 +627,7 @@ BVHTree* bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *mesh, float
memset(data, 0, sizeof(*data));
data->tree = tree;
- if(data->tree) {
+ if (data->tree) {
data->cached = TRUE;
data->nearest_callback = mesh_faces_nearest_point;
@@ -649,7 +649,7 @@ BVHTree* bvhtree_from_mesh_edges(BVHTreeFromMesh *data, DerivedMesh *mesh, float
BVHTree *tree = bvhcache_find(&mesh->bvhCache, BVHTREE_FROM_EDGES);
//Not in cache
- if(tree == NULL)
+ if (tree == NULL)
{
int i;
int numEdges= mesh->getNumEdges(mesh);
@@ -685,7 +685,7 @@ BVHTree* bvhtree_from_mesh_edges(BVHTreeFromMesh *data, DerivedMesh *mesh, float
memset(data, 0, sizeof(*data));
data->tree = tree;
- if(data->tree) {
+ if (data->tree) {
data->cached = TRUE;
data->nearest_callback = mesh_edges_nearest_point;
@@ -704,8 +704,8 @@ BVHTree* bvhtree_from_mesh_edges(BVHTreeFromMesh *data, DerivedMesh *mesh, float
// Frees data allocated by a call to bvhtree_from_mesh_*.
void free_bvhtree_from_mesh(struct BVHTreeFromMesh *data)
{
- if(data->tree) {
- if(!data->cached)
+ if (data->tree) {
+ if (!data->cached)
BLI_bvhtree_free(data->tree);
memset( data, 0, sizeof(*data) );
@@ -726,7 +726,7 @@ static void bvhcacheitem_set_if_match(void *_cached, void *_search)
BVHCacheItem * cached = (BVHCacheItem *)_cached;
BVHCacheItem * search = (BVHCacheItem *)_search;
- if(search->type == cached->type) {
+ if (search->type == cached->type) {
search->tree = cached->tree;
}
}
diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c
index a6651e25a5f..12801228950 100644
--- a/source/blender/blenkernel/intern/camera.c
+++ b/source/blender/blenkernel/intern/camera.c
@@ -91,23 +91,23 @@ void make_local_camera(Camera *cam)
* - mixed: make copy
*/
- if(cam->id.lib==NULL) return;
- if(cam->id.us==1) {
+ if (cam->id.lib==NULL) return;
+ if (cam->id.us==1) {
id_clear_lib_data(bmain, &cam->id);
return;
}
- for(ob= bmain->object.first; ob && ELEM(0, is_lib, is_local); ob= ob->id.next) {
- if(ob->data==cam) {
- if(ob->id.lib) is_lib= TRUE;
+ for (ob= bmain->object.first; ob && ELEM(0, is_lib, is_local); ob= ob->id.next) {
+ if (ob->data==cam) {
+ if (ob->id.lib) is_lib= TRUE;
else is_local= TRUE;
}
}
- if(is_local && is_lib == FALSE) {
+ if (is_local && is_lib == FALSE) {
id_clear_lib_data(bmain, &cam->id);
}
- else if(is_local && is_lib) {
+ else if (is_local && is_lib) {
Camera *cam_new= copy_camera(cam);
cam_new->id.us= 0;
@@ -115,9 +115,9 @@ void make_local_camera(Camera *cam)
/* Remap paths of new ID using old library as base. */
BKE_id_lib_local_paths(bmain, cam->id.lib, &cam_new->id);
- for(ob= bmain->object.first; ob; ob= ob->id.next) {
- if(ob->data == cam) {
- if(ob->id.lib==NULL) {
+ for (ob= bmain->object.first; ob; ob= ob->id.next) {
+ if (ob->data == cam) {
+ if (ob->id.lib==NULL) {
ob->data= cam_new;
cam_new->id.us++;
cam->id.us--;
@@ -138,10 +138,10 @@ void object_camera_mode(RenderData *rd, Object *cam_ob)
{
rd->mode &= ~(R_ORTHO|R_PANORAMA);
- if(cam_ob && cam_ob->type==OB_CAMERA) {
+ if (cam_ob && cam_ob->type==OB_CAMERA) {
Camera *cam= cam_ob->data;
- if(cam->type == CAM_ORTHO) rd->mode |= R_ORTHO;
- if(cam->flag & CAM_PANORAMA) rd->mode |= R_PANORAMA;
+ if (cam->type == CAM_ORTHO) rd->mode |= R_ORTHO;
+ if (cam->flag & CAM_PANORAMA) rd->mode |= R_PANORAMA;
}
}
@@ -168,7 +168,7 @@ float object_camera_dof_distance(Object *ob)
float camera_sensor_size(int sensor_fit, float sensor_x, float sensor_y)
{
/* sensor size used to fit to. for auto, sensor_x is both x and y. */
- if(sensor_fit == CAMERA_SENSOR_FIT_VERT)
+ if (sensor_fit == CAMERA_SENSOR_FIT_VERT)
return sensor_y;
return sensor_x;
@@ -176,8 +176,8 @@ float camera_sensor_size(int sensor_fit, float sensor_x, float sensor_y)
int camera_sensor_fit(int sensor_fit, float sizex, float sizey)
{
- if(sensor_fit == CAMERA_SENSOR_FIT_AUTO) {
- if(sizex >= sizey)
+ if (sensor_fit == CAMERA_SENSOR_FIT_AUTO) {
+ if (sizex >= sizey)
return CAMERA_SENSOR_FIT_HOR;
else
return CAMERA_SENSOR_FIT_VERT;
@@ -202,14 +202,14 @@ void camera_params_init(CameraParams *params)
void camera_params_from_object(CameraParams *params, Object *ob)
{
- if(!ob)
+ if (!ob)
return;
- if(ob->type==OB_CAMERA) {
+ if (ob->type==OB_CAMERA) {
/* camera object */
Camera *cam= ob->data;
- if(cam->type == CAM_ORTHO)
+ if (cam->type == CAM_ORTHO)
params->is_ortho= TRUE;
params->lens= cam->lens;
params->ortho_scale= cam->ortho_scale;
@@ -224,14 +224,14 @@ void camera_params_from_object(CameraParams *params, Object *ob)
params->clipsta= cam->clipsta;
params->clipend= cam->clipend;
}
- else if(ob->type==OB_LAMP) {
+ else if (ob->type==OB_LAMP) {
/* lamp object */
Lamp *la= ob->data;
float fac= cosf((float)M_PI*la->spotsize/360.0f);
float phi= acos(fac);
params->lens= 16.0f*fac/sinf(phi);
- if(params->lens==0.0f)
+ if (params->lens==0.0f)
params->lens= 35.0f;
params->clipsta= la->clipsta;
@@ -246,7 +246,7 @@ void camera_params_from_view3d(CameraParams *params, View3D *v3d, RegionView3D *
params->clipsta= v3d->near;
params->clipend= v3d->far;
- if(rv3d->persp==RV3D_CAMOB) {
+ if (rv3d->persp==RV3D_CAMOB) {
/* camera view */
camera_params_from_object(params, v3d->camera);
@@ -260,7 +260,7 @@ void camera_params_from_view3d(CameraParams *params, View3D *v3d, RegionView3D *
params->zoom= 1.0f/params->zoom;
}
- else if(rv3d->persp==RV3D_ORTHO) {
+ else if (rv3d->persp==RV3D_ORTHO) {
/* orthographic view */
params->clipend *= 0.5f; // otherwise too extreme low zbuffer quality
params->clipsta= - params->clipend;
@@ -283,10 +283,10 @@ void camera_params_compute_viewplane(CameraParams *params, int winx, int winy, f
/* fields rendering */
params->ycor= yasp/xasp;
- if(params->use_fields)
+ if (params->use_fields)
params->ycor *= 2.0f;
- if(params->is_ortho) {
+ if (params->is_ortho) {
/* orthographic camera */
/* scale == 1.0 means exact 1 to 1 mapping */
pixsize= params->ortho_scale;
@@ -300,7 +300,7 @@ void camera_params_compute_viewplane(CameraParams *params, int winx, int winy, f
/* determine sensor fit */
sensor_fit = camera_sensor_fit(params->sensor_fit, xasp*winx, yasp*winy);
- if(sensor_fit==CAMERA_SENSOR_FIT_HOR)
+ if (sensor_fit==CAMERA_SENSOR_FIT_HOR)
viewfac= winx;
else
viewfac= params->ycor * winy;
@@ -327,8 +327,8 @@ void camera_params_compute_viewplane(CameraParams *params, int winx, int winy, f
viewplane.ymax += dy;
/* fields offset */
- if(params->field_second) {
- if(params->field_odd) {
+ if (params->field_second) {
+ if (params->field_odd) {
viewplane.ymin-= 0.5f * params->ycor;
viewplane.ymax-= 0.5f * params->ycor;
}
@@ -356,7 +356,7 @@ void camera_params_compute_matrix(CameraParams *params)
rctf viewplane= params->viewplane;
/* compute projection matrix */
- if(params->is_ortho)
+ if (params->is_ortho)
orthographic_m4(params->winmat, viewplane.xmin, viewplane.xmax,
viewplane.ymin, viewplane.ymax, params->clipsta, params->clipend);
else
@@ -378,7 +378,7 @@ void camera_view_frame_ex(Scene *scene, Camera *camera, float drawsize, const sh
float aspy= (float) scene->r.ysch*scene->r.yasp;
int sensor_fit= camera_sensor_fit(camera->sensor_fit, aspx, aspy);
- if(sensor_fit==CAMERA_SENSOR_FIT_HOR) {
+ if (sensor_fit==CAMERA_SENSOR_FIT_HOR) {
r_asp[0]= 1.0;
r_asp[1]= aspy / aspx;
}
@@ -392,7 +392,7 @@ void camera_view_frame_ex(Scene *scene, Camera *camera, float drawsize, const sh
r_asp[1]= 1.0f;
}
- if(camera->type==CAM_ORTHO) {
+ if (camera->type==CAM_ORTHO) {
facx= 0.5f * camera->ortho_scale * r_asp[0] * scale[0];
facy= 0.5f * camera->ortho_scale * r_asp[1] * scale[1];
r_shift[0]= camera->shiftx * camera->ortho_scale * scale[0];
@@ -408,7 +408,7 @@ void camera_view_frame_ex(Scene *scene, Camera *camera, float drawsize, const sh
*r_drawsize= drawsize / ((scale[0] + scale[1] + scale[2]) / 3.0f);
- if(do_clip) {
+ if (do_clip) {
/* fixed depth, variable size (avoids exceeding clipping range) */
depth = -(camera->clipsta + 0.1f);
fac = depth / (camera->lens/(-half_sensor) * scale[2]);
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index 7b0baf6556a..e3be9c4c236 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -198,7 +198,7 @@ static void cdDM_getVertCos(DerivedMesh *dm, float (*cos_r)[3])
MVert *mv = CDDM_get_verts(dm);
int i;
- for(i = 0; i < dm->numVertData; i++, mv++)
+ for (i = 0; i < dm->numVertData; i++, mv++)
copy_v3_v3(cos_r[i], mv->co);
}
@@ -212,7 +212,7 @@ static const MeshElemMap *cdDM_getPolyMap(Object *ob, DerivedMesh *dm)
{
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
- if(!cddm->pmap && ob->type == OB_MESH) {
+ if (!cddm->pmap && ob->type == OB_MESH) {
Mesh *me= ob->data;
create_vert_poly_map(&cddm->pmap, &cddm->pmap_mem,
@@ -239,7 +239,7 @@ static int can_pbvh_draw(Object *ob, DerivedMesh *dm)
* final DM to give final result to user */
deformed|= ob->sculpt->kb && (ob->shapeflag&OB_SHAPE_LOCK) == 0;
- if(deformed)
+ if (deformed)
return 0;
return cddm->mvert == me->mvert || ob->sculpt->kb;
@@ -249,14 +249,14 @@ static struct PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm)
{
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
- if(!ob) {
+ if (!ob) {
cddm->pbvh= NULL;
return NULL;
}
- if(!ob->sculpt)
+ if (!ob->sculpt)
return NULL;
- if(ob->sculpt->pbvh) {
+ if (ob->sculpt->pbvh) {
cddm->pbvh= ob->sculpt->pbvh;
cddm->pbvh_draw = can_pbvh_draw(ob, dm);
}
@@ -264,7 +264,7 @@ static struct PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm)
/* always build pbvh from original mesh, and only use it for drawing if
* this derivedmesh is just original mesh. it's the multires subsurf dm
* that this is actually for, to support a pbvh on a modified mesh */
- if(!cddm->pbvh && ob->type == OB_MESH) {
+ if (!cddm->pbvh && ob->type == OB_MESH) {
SculptSession *ss= ob->sculpt;
Mesh *me= ob->data;
cddm->pbvh = BLI_pbvh_new();
@@ -275,7 +275,7 @@ static struct PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm)
BLI_pbvh_build_mesh(cddm->pbvh, me->mface, me->mvert,
me->totface, me->totvert);
- if(ss->modifiers_active && ob->derivedDeform) {
+ if (ss->modifiers_active && ob->derivedDeform) {
DerivedMesh *deformdm= ob->derivedDeform;
float (*vertCos)[3];
int totvert;
@@ -298,7 +298,7 @@ static void cdDM_update_normals_from_pbvh(DerivedMesh *dm)
CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
float (*face_nors)[3];
- if(!cddm->pbvh || !cddm->pbvh_draw || !dm->numTessFaceData)
+ if (!cddm->pbvh || !cddm->pbvh_draw || !dm->numTessFaceData)
return;
face_nors = CustomData_get_layer(&dm->faceData, CD_NORMAL);
@@ -312,16 +312,16 @@ static void cdDM_drawVerts(DerivedMesh *dm)
MVert *mv = cddm->mvert;
int i;
- if( GPU_buffer_legacy(dm) ) {
+ if ( GPU_buffer_legacy(dm) ) {
glBegin(GL_POINTS);
- for(i = 0; i < dm->numVertData; i++, mv++)
+ for (i = 0; i < dm->numVertData; i++, mv++)
glVertex3fv(mv->co);
glEnd();
}
else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */
GPU_vertex_setup(dm);
- if( !GPU_buffer_legacy(dm) ) {
- if(dm->drawObject->tot_triangle_point)
+ if ( !GPU_buffer_legacy(dm) ) {
+ if (dm->drawObject->tot_triangle_point)
glDrawArrays(GL_POINTS,0, dm->drawObject->tot_triangle_point);
else
glDrawArrays(GL_POINTS,0, dm->drawObject->tot_loose_point);
@@ -337,21 +337,22 @@ static void cdDM_drawUVEdges(DerivedMesh *dm)
MTFace *tf = DM_get_tessface_data_layer(dm, CD_MTFACE);
int i;
- if(mf) {
- if( GPU_buffer_legacy(dm) ) {
+ if (mf) {
+ if ( GPU_buffer_legacy(dm) ) {
glBegin(GL_LINES);
- for(i = 0; i < dm->numTessFaceData; i++, mf++, tf++) {
- if(!(mf->flag&ME_HIDE)) {
+ for (i = 0; i < dm->numTessFaceData; i++, mf++, tf++) {
+ if (!(mf->flag&ME_HIDE)) {
glVertex2fv(tf->uv[0]);
glVertex2fv(tf->uv[1]);
glVertex2fv(tf->uv[1]);
glVertex2fv(tf->uv[2]);
- if(!mf->v4) {
+ if (!mf->v4) {
glVertex2fv(tf->uv[2]);
glVertex2fv(tf->uv[0]);
- } else {
+ }
+ else {
glVertex2fv(tf->uv[2]);
glVertex2fv(tf->uv[3]);
@@ -369,21 +370,21 @@ static void cdDM_drawUVEdges(DerivedMesh *dm)
int curpos = 0;
GPU_uvedge_setup(dm);
- if( !GPU_buffer_legacy(dm) ) {
- for(i = 0; i < dm->numTessFaceData; i++, mf++) {
- if(!(mf->flag&ME_HIDE)) {
+ if ( !GPU_buffer_legacy(dm) ) {
+ for (i = 0; i < dm->numTessFaceData; i++, mf++) {
+ if (!(mf->flag&ME_HIDE)) {
draw = 1;
}
else {
draw = 0;
}
- if( prevdraw != draw ) {
- if( prevdraw > 0 && (curpos-prevstart) > 0) {
+ if ( prevdraw != draw ) {
+ if ( prevdraw > 0 && (curpos-prevstart) > 0) {
glDrawArrays(GL_LINES,prevstart,curpos-prevstart);
}
prevstart = curpos;
}
- if( mf->v4 ) {
+ if ( mf->v4 ) {
curpos += 8;
}
else {
@@ -391,7 +392,7 @@ static void cdDM_drawUVEdges(DerivedMesh *dm)
}
prevdraw = draw;
}
- if( prevdraw > 0 && (curpos-prevstart) > 0 ) {
+ if ( prevdraw > 0 && (curpos-prevstart) > 0 ) {
glDrawArrays(GL_LINES,prevstart,curpos-prevstart);
}
}
@@ -407,11 +408,11 @@ static void cdDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdges
MEdge *medge = cddm->medge;
int i;
- if( GPU_buffer_legacy(dm) ) {
+ if ( GPU_buffer_legacy(dm) ) {
DEBUG_VBO( "Using legacy code. cdDM_drawEdges\n" );
glBegin(GL_LINES);
- for(i = 0; i < dm->numEdgeData; i++, medge++) {
- if((drawAllEdges || (medge->flag&ME_EDGEDRAW))
+ for (i = 0; i < dm->numEdgeData; i++, medge++) {
+ if ((drawAllEdges || (medge->flag&ME_EDGEDRAW))
&& (drawLooseEdges || !(medge->flag&ME_LOOSEEDGE))) {
glVertex3fv(mvert[medge->v1].co);
glVertex3fv(mvert[medge->v2].co);
@@ -425,24 +426,24 @@ static void cdDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdges
int draw = 1;
GPU_edge_setup(dm);
- if( !GPU_buffer_legacy(dm) ) {
- for(i = 0; i < dm->numEdgeData; i++, medge++) {
- if((drawAllEdges || (medge->flag&ME_EDGEDRAW))
+ if ( !GPU_buffer_legacy(dm) ) {
+ for (i = 0; i < dm->numEdgeData; i++, medge++) {
+ if ((drawAllEdges || (medge->flag&ME_EDGEDRAW))
&& (drawLooseEdges || !(medge->flag&ME_LOOSEEDGE))) {
draw = 1;
}
else {
draw = 0;
}
- if( prevdraw != draw ) {
- if( prevdraw > 0 && (i-prevstart) > 0 ) {
+ if ( prevdraw != draw ) {
+ if ( prevdraw > 0 && (i-prevstart) > 0 ) {
GPU_buffer_draw_elements(dm->drawObject->edges, GL_LINES, prevstart * 2, (i - prevstart) * 2);
}
prevstart = i;
}
prevdraw = draw;
}
- if( prevdraw > 0 && (i-prevstart) > 0 ) {
+ if ( prevdraw > 0 && (i-prevstart) > 0 ) {
GPU_buffer_draw_elements(dm->drawObject->edges, GL_LINES, prevstart * 2, (i-prevstart) * 2);
}
}
@@ -457,11 +458,11 @@ static void cdDM_drawLooseEdges(DerivedMesh *dm)
MEdge *medge = cddm->medge;
int i;
- if( GPU_buffer_legacy(dm) ) {
+ if ( GPU_buffer_legacy(dm) ) {
DEBUG_VBO( "Using legacy code. cdDM_drawLooseEdges\n" );
glBegin(GL_LINES);
- for(i = 0; i < dm->numEdgeData; i++, medge++) {
- if(medge->flag&ME_LOOSEEDGE) {
+ for (i = 0; i < dm->numEdgeData; i++, medge++) {
+ if (medge->flag&ME_LOOSEEDGE) {
glVertex3fv(mvert[medge->v1].co);
glVertex3fv(mvert[medge->v2].co);
}
@@ -474,23 +475,23 @@ static void cdDM_drawLooseEdges(DerivedMesh *dm)
int draw = 1;
GPU_edge_setup(dm);
- if( !GPU_buffer_legacy(dm) ) {
- for(i = 0; i < dm->numEdgeData; i++, medge++) {
- if(medge->flag&ME_LOOSEEDGE) {
+ if ( !GPU_buffer_legacy(dm) ) {
+ for (i = 0; i < dm->numEdgeData; i++, medge++) {
+ if (medge->flag&ME_LOOSEEDGE) {
draw = 1;
}
else {
draw = 0;
}
- if( prevdraw != draw ) {
- if( prevdraw > 0 && (i-prevstart) > 0) {
+ if ( prevdraw != draw ) {
+ if ( prevdraw > 0 && (i-prevstart) > 0) {
GPU_buffer_draw_elements(dm->drawObject->edges, GL_LINES, prevstart * 2, (i - prevstart) * 2);
}
prevstart = i;
}
prevdraw = draw;
}
- if( prevdraw > 0 && (i-prevstart) > 0 ) {
+ if ( prevdraw > 0 && (i-prevstart) > 0 ) {
GPU_buffer_draw_elements(dm->drawObject->edges, GL_LINES, prevstart * 2, (i - prevstart) * 2);
}
}
@@ -509,15 +510,15 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm,
int a, glmode = -1, shademodel = -1, matnr = -1, drawCurrentMat = 1;
#define PASSVERT(index) { \
- if(shademodel == GL_SMOOTH) { \
+ if (shademodel == GL_SMOOTH) { \
short *no = mvert[index].no; \
glNormal3sv(no); \
} \
glVertex3fv(mvert[index].co); \
}
- if(cddm->pbvh && cddm->pbvh_draw) {
- if(dm->numTessFaceData) {
+ if (cddm->pbvh && cddm->pbvh_draw) {
+ if (dm->numTessFaceData) {
float (*face_nors)[3] = CustomData_get_layer(&dm->faceData, CD_NORMAL);
BLI_pbvh_draw(cddm->pbvh, partial_redraw_planes, face_nors, setMaterial);
@@ -527,17 +528,17 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm,
return;
}
- if( GPU_buffer_legacy(dm) ) {
+ if ( GPU_buffer_legacy(dm) ) {
DEBUG_VBO( "Using legacy code. cdDM_drawFacesSolid\n" );
glBegin(glmode = GL_QUADS);
- for(a = 0; a < dm->numTessFaceData; a++, mface++) {
+ for (a = 0; a < dm->numTessFaceData; a++, mface++) {
int new_glmode, new_matnr, new_shademodel;
new_glmode = mface->v4?GL_QUADS:GL_TRIANGLES;
new_matnr = mface->mat_nr + 1;
new_shademodel = (mface->flag & ME_SMOOTH)?GL_SMOOTH:GL_FLAT;
- if(new_glmode != glmode || new_matnr != matnr
+ if (new_glmode != glmode || new_matnr != matnr
|| new_shademodel != shademodel) {
glEnd();
@@ -547,17 +548,18 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm,
glBegin(glmode = new_glmode);
}
- if(drawCurrentMat) {
- if(shademodel == GL_FLAT) {
+ if (drawCurrentMat) {
+ if (shademodel == GL_FLAT) {
if (nors) {
glNormal3fv(nors);
}
else {
/* TODO make this better (cache facenormals as layer?) */
float nor[3];
- if(mface->v4) {
+ if (mface->v4) {
normal_quad_v3( nor,mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co, mvert[mface->v4].co);
- } else {
+ }
+ else {
normal_tri_v3( nor,mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co);
}
glNormal3fv(nor);
@@ -567,22 +569,22 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm,
PASSVERT(mface->v1);
PASSVERT(mface->v2);
PASSVERT(mface->v3);
- if(mface->v4) {
+ if (mface->v4) {
PASSVERT(mface->v4);
}
}
- if(nors) nors += 3;
+ if (nors) nors += 3;
}
glEnd();
}
else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */
GPU_vertex_setup( dm );
GPU_normal_setup( dm );
- if( !GPU_buffer_legacy(dm) ) {
+ if ( !GPU_buffer_legacy(dm) ) {
glShadeModel(GL_SMOOTH);
- for( a = 0; a < dm->drawObject->totmaterial; a++ ) {
- if( setMaterial(dm->drawObject->materials[a].mat_nr+1, NULL) )
+ for ( a = 0; a < dm->drawObject->totmaterial; a++ ) {
+ if ( setMaterial(dm->drawObject->materials[a].mat_nr+1, NULL) )
glDrawArrays(GL_TRIANGLES, dm->drawObject->materials[a].start,
dm->drawObject->materials[a].totpoint);
}
@@ -609,46 +611,47 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
int i, j, orig, *index = DM_get_tessface_data_layer(dm, CD_ORIGINDEX);
int startFace = 0 /*, lastFlag = 0xdeadbeef */ /* UNUSED */;
MCol *mcol = dm->getTessFaceDataArray(dm, CD_PREVIEW_MCOL);
- if(!mcol)
+ if (!mcol)
mcol = dm->getTessFaceDataArray(dm, CD_MCOL);
cdDM_update_normals_from_pbvh(dm);
- if( GPU_buffer_legacy(dm) ) {
+ if ( GPU_buffer_legacy(dm) ) {
DEBUG_VBO( "Using legacy code. cdDM_drawFacesTex_common\n" );
- for(i = 0; i < dm->numTessFaceData; i++, mf++) {
+ for (i = 0; i < dm->numTessFaceData; i++, mf++) {
MVert *mvert;
DMDrawOption draw_option;
unsigned char *cp = NULL;
- if(drawParams) {
+ if (drawParams) {
draw_option = drawParams(tf? &tf[i]: NULL, (mcol != NULL), mf->mat_nr);
}
else {
- if(index) {
+ if (index) {
orig = *index++;
- if(orig == ORIGINDEX_NONE) { if(nors) nors += 3; continue; }
- if(drawParamsMapped) draw_option = drawParamsMapped(userData, orig);
+ if (orig == ORIGINDEX_NONE) { if(nors) nors += 3; continue; }
+ if (drawParamsMapped) draw_option = drawParamsMapped(userData, orig);
else { if(nors) nors += 3; continue; }
}
else
- if(drawParamsMapped) draw_option = drawParamsMapped(userData, i);
+ if (drawParamsMapped) draw_option = drawParamsMapped(userData, i);
else { if(nors) nors += 3; continue; }
}
- if(draw_option != DM_DRAW_OPTION_SKIP) {
+ if (draw_option != DM_DRAW_OPTION_SKIP) {
if (draw_option != DM_DRAW_OPTION_NO_MCOL && mcol)
cp= (unsigned char*) &mcol[i*4];
- if(!(mf->flag&ME_SMOOTH)) {
+ if (!(mf->flag&ME_SMOOTH)) {
if (nors) {
glNormal3fv(nors);
}
else {
float nor[3];
- if(mf->v4) {
+ if (mf->v4) {
normal_quad_v3( nor,mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co, mv[mf->v4].co);
- } else {
+ }
+ else {
normal_tri_v3( nor,mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co);
}
glNormal3fv(nor);
@@ -656,55 +659,57 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
}
glBegin(mf->v4?GL_QUADS:GL_TRIANGLES);
- if(tf) glTexCoord2fv(tf[i].uv[0]);
- if(cp) glColor3ub(cp[3], cp[2], cp[1]);
+ if (tf) glTexCoord2fv(tf[i].uv[0]);
+ if (cp) glColor3ub(cp[3], cp[2], cp[1]);
mvert = &mv[mf->v1];
- if(mf->flag&ME_SMOOTH) glNormal3sv(mvert->no);
+ if (mf->flag&ME_SMOOTH) glNormal3sv(mvert->no);
glVertex3fv(mvert->co);
- if(tf) glTexCoord2fv(tf[i].uv[1]);
- if(cp) glColor3ub(cp[7], cp[6], cp[5]);
+ if (tf) glTexCoord2fv(tf[i].uv[1]);
+ if (cp) glColor3ub(cp[7], cp[6], cp[5]);
mvert = &mv[mf->v2];
- if(mf->flag&ME_SMOOTH) glNormal3sv(mvert->no);
+ if (mf->flag&ME_SMOOTH) glNormal3sv(mvert->no);
glVertex3fv(mvert->co);
- if(tf) glTexCoord2fv(tf[i].uv[2]);
- if(cp) glColor3ub(cp[11], cp[10], cp[9]);
+ if (tf) glTexCoord2fv(tf[i].uv[2]);
+ if (cp) glColor3ub(cp[11], cp[10], cp[9]);
mvert = &mv[mf->v3];
- if(mf->flag&ME_SMOOTH) glNormal3sv(mvert->no);
+ if (mf->flag&ME_SMOOTH) glNormal3sv(mvert->no);
glVertex3fv(mvert->co);
- if(mf->v4) {
- if(tf) glTexCoord2fv(tf[i].uv[3]);
- if(cp) glColor3ub(cp[15], cp[14], cp[13]);
+ if (mf->v4) {
+ if (tf) glTexCoord2fv(tf[i].uv[3]);
+ if (cp) glColor3ub(cp[15], cp[14], cp[13]);
mvert = &mv[mf->v4];
- if(mf->flag&ME_SMOOTH) glNormal3sv(mvert->no);
+ if (mf->flag&ME_SMOOTH) glNormal3sv(mvert->no);
glVertex3fv(mvert->co);
}
glEnd();
}
- if(nors) nors += 3;
+ if (nors) nors += 3;
}
- } else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */
+ }
+ else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */
MCol *col = realcol;
- if(!col)
+ if (!col)
col = mcol;
GPU_vertex_setup( dm );
GPU_normal_setup( dm );
GPU_uv_setup( dm );
- if( col != NULL ) {
+ if ( col != NULL ) {
/*if( realcol && dm->drawObject->colType == CD_TEXTURE_MCOL ) {
col = 0;
- } else if( mcol && dm->drawObject->colType == CD_MCOL ) {
+ }
+ else if ( mcol && dm->drawObject->colType == CD_MCOL ) {
col = 0;
}
- if( col != 0 ) {*/
+ if ( col != 0 ) {*/
unsigned char *colors = MEM_mallocN(dm->getNumTessFaces(dm)*4*3*sizeof(unsigned char), "cdDM_drawFacesTex_common");
- for( i=0; i < dm->getNumTessFaces(dm); i++ ) {
- for( j=0; j < 4; j++ ) {
+ for ( i=0; i < dm->getNumTessFaces(dm); i++ ) {
+ for ( j=0; j < 4; j++ ) {
/* bgr -> rgb is intentional (and stupid), but how its stored internally */
colors[i*12+j*3] = col[i*4+j].b;
colors[i*12+j*3+1] = col[i*4+j].g;
@@ -713,58 +718,58 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
}
GPU_color3_upload(dm,colors);
MEM_freeN(colors);
- if(realcol)
+ if (realcol)
dm->drawObject->colType = CD_TEXTURE_MCOL;
- else if(mcol)
+ else if (mcol)
dm->drawObject->colType = CD_MCOL;
//}
GPU_color_setup( dm );
}
- if( !GPU_buffer_legacy(dm) ) {
+ if ( !GPU_buffer_legacy(dm) ) {
int tottri = dm->drawObject->tot_triangle_point/3;
int next_actualFace= dm->drawObject->triangle_to_mface[0];
glShadeModel( GL_SMOOTH );
/* lastFlag = 0; */ /* UNUSED */
- for(i = 0; i < tottri; i++) {
+ for (i = 0; i < tottri; i++) {
int actualFace = next_actualFace;
DMDrawOption draw_option = DM_DRAW_OPTION_NORMAL;
int flush = 0;
- if(i != tottri-1)
+ if (i != tottri-1)
next_actualFace= dm->drawObject->triangle_to_mface[i+1];
- if(drawParams) {
+ if (drawParams) {
draw_option = drawParams(tf? &tf[actualFace]: NULL, (mcol != NULL), mf[actualFace].mat_nr);
}
else {
- if(index) {
+ if (index) {
orig = index[actualFace];
- if(orig == ORIGINDEX_NONE) continue;
- if(drawParamsMapped)
+ if (orig == ORIGINDEX_NONE) continue;
+ if (drawParamsMapped)
draw_option = drawParamsMapped(userData, orig);
}
else
- if(drawParamsMapped)
+ if (drawParamsMapped)
draw_option = drawParamsMapped(userData, actualFace);
}
/* flush buffer if current triangle isn't drawable or it's last triangle */
flush= (draw_option == DM_DRAW_OPTION_SKIP) || (i == tottri - 1);
- if(!flush && compareDrawOptions) {
+ if (!flush && compareDrawOptions) {
/* also compare draw options and flush buffer if they're different
* need for face selection highlight in edit mode */
flush|= compareDrawOptions(userData, actualFace, next_actualFace) == 0;
}
- if(flush) {
+ if (flush) {
int first= startFace*3;
/* Add one to the length if we're drawing at the end of the array */
int count= (i-startFace+(draw_option != DM_DRAW_OPTION_SKIP ? 1 : 0))*3;
- if(count) {
+ if (count) {
if (col)
GPU_color_switch(1);
else
@@ -806,32 +811,32 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm,
int i, orig, *index = DM_get_tessface_data_layer(dm, CD_ORIGINDEX);
mc = DM_get_tessface_data_layer(dm, CD_ID_MCOL);
- if(!mc)
+ if (!mc)
mc = DM_get_tessface_data_layer(dm, CD_PREVIEW_MCOL);
- if(!mc)
+ if (!mc)
mc = DM_get_tessface_data_layer(dm, CD_MCOL);
cdDM_update_normals_from_pbvh(dm);
/* back-buffer always uses legacy since VBO's would need the
* color array temporarily overwritten for drawing, then reset. */
- if( GPU_buffer_legacy(dm) || G.f & G_BACKBUFSEL) {
+ if ( GPU_buffer_legacy(dm) || G.f & G_BACKBUFSEL) {
DEBUG_VBO( "Using legacy code. cdDM_drawMappedFaces\n" );
- for(i = 0; i < dm->numTessFaceData; i++, mf++) {
+ for (i = 0; i < dm->numTessFaceData; i++, mf++) {
int drawSmooth = (flag & DM_DRAW_ALWAYS_SMOOTH) ? 1 : (mf->flag & ME_SMOOTH);
DMDrawOption draw_option= DM_DRAW_OPTION_NORMAL;
orig= (index==NULL) ? i : *index++;
- if(orig == ORIGINDEX_NONE)
+ if (orig == ORIGINDEX_NONE)
draw_option= setMaterial(mf->mat_nr + 1, NULL);
else if (setDrawOptions != NULL)
draw_option= setDrawOptions(userData, orig);
- if(draw_option != DM_DRAW_OPTION_SKIP) {
+ if (draw_option != DM_DRAW_OPTION_SKIP) {
unsigned char *cp = NULL;
- if(useColors && mc)
+ if (useColors && mc)
cp = (unsigned char *)&mc[i * 4];
/* no need to set shading mode to flat because
@@ -845,36 +850,38 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm,
}
else {
float nor[3];
- if(mf->v4) {
+ if (mf->v4) {
normal_quad_v3( nor,mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co, mv[mf->v4].co);
- } else {
+ }
+ else {
normal_tri_v3( nor,mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co);
}
glNormal3fv(nor);
}
- if(cp) glColor3ub(cp[3], cp[2], cp[1]);
+ if (cp) glColor3ub(cp[3], cp[2], cp[1]);
glVertex3fv(mv[mf->v1].co);
- if(cp) glColor3ub(cp[7], cp[6], cp[5]);
+ if (cp) glColor3ub(cp[7], cp[6], cp[5]);
glVertex3fv(mv[mf->v2].co);
- if(cp) glColor3ub(cp[11], cp[10], cp[9]);
+ if (cp) glColor3ub(cp[11], cp[10], cp[9]);
glVertex3fv(mv[mf->v3].co);
- if(mf->v4) {
- if(cp) glColor3ub(cp[15], cp[14], cp[13]);
+ if (mf->v4) {
+ if (cp) glColor3ub(cp[15], cp[14], cp[13]);
glVertex3fv(mv[mf->v4].co);
}
- } else {
- if(cp) glColor3ub(cp[3], cp[2], cp[1]);
+ }
+ else {
+ if (cp) glColor3ub(cp[3], cp[2], cp[1]);
glNormal3sv(mv[mf->v1].no);
glVertex3fv(mv[mf->v1].co);
- if(cp) glColor3ub(cp[7], cp[6], cp[5]);
+ if (cp) glColor3ub(cp[7], cp[6], cp[5]);
glNormal3sv(mv[mf->v2].no);
glVertex3fv(mv[mf->v2].co);
- if(cp) glColor3ub(cp[11], cp[10], cp[9]);
+ if (cp) glColor3ub(cp[11], cp[10], cp[9]);
glNormal3sv(mv[mf->v3].no);
glVertex3fv(mv[mf->v3].co);
- if(mf->v4) {
- if(cp) glColor3ub(cp[15], cp[14], cp[13]);
+ if (mf->v4) {
+ if (cp) glColor3ub(cp[15], cp[14], cp[13]);
glNormal3sv(mv[mf->v4].no);
glVertex3fv(mv[mf->v4].co);
}
@@ -890,16 +897,16 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm,
int prevstart = 0;
GPU_vertex_setup(dm);
GPU_normal_setup(dm);
- if( useColors && mc )
+ if ( useColors && mc )
GPU_color_setup(dm);
- if( !GPU_buffer_legacy(dm) ) {
+ if ( !GPU_buffer_legacy(dm) ) {
int tottri = dm->drawObject->tot_triangle_point/3;
glShadeModel(GL_SMOOTH);
- if(tottri == 0) {
+ if (tottri == 0) {
/* avoid buffer problems in following code */
}
- if(setDrawOptions == NULL) {
+ if (setDrawOptions == NULL) {
/* just draw the entire face array */
glDrawArrays(GL_TRIANGLES, 0, (tottri) * 3);
}
@@ -907,7 +914,7 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm,
/* we need to check if the next material changes */
int next_actualFace= dm->drawObject->triangle_to_mface[0];
- for( i = 0; i < tottri; i++ ) {
+ for ( i = 0; i < tottri; i++ ) {
//int actualFace = dm->drawObject->triangle_to_mface[i];
int actualFace = next_actualFace;
MFace *mface= mf + actualFace;
@@ -915,12 +922,12 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm,
DMDrawOption draw_option = DM_DRAW_OPTION_NORMAL;
int flush = 0;
- if(i != tottri-1)
+ if (i != tottri-1)
next_actualFace= dm->drawObject->triangle_to_mface[i+1];
orig= (index==NULL) ? actualFace : index[actualFace];
- if(orig == ORIGINDEX_NONE)
+ if (orig == ORIGINDEX_NONE)
draw_option= setMaterial(mface->mat_nr + 1, NULL);
else if (setDrawOptions != NULL)
draw_option= setDrawOptions(userData, orig);
@@ -935,16 +942,16 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm,
/* ... or when material setting is dissferent */
flush|= mf[actualFace].mat_nr != mf[next_actualFace].mat_nr;
- if(!flush && compareDrawOptions) {
+ if (!flush && compareDrawOptions) {
flush|= compareDrawOptions(userData, actualFace, next_actualFace) == 0;
}
- if(flush) {
+ if (flush) {
int first= prevstart*3;
/* Add one to the length if we're drawing at the end of the array */
int count= (i-prevstart+(draw_option != DM_DRAW_OPTION_SKIP ? 1 : 0))*3;
- if(count)
+ if (count)
glDrawArrays(GL_TRIANGLES, first, count);
prevstart = i + 1;
@@ -971,25 +978,25 @@ static void cddm_draw_attrib_vertex(DMVertexAttribs *attribs, MVert *mvert, int
int b;
/* orco texture coordinates */
- if(attribs->totorco) {
- if(attribs->orco.glTexco)
+ if (attribs->totorco) {
+ if (attribs->orco.glTexco)
glTexCoord3fv(attribs->orco.array[index]);
else
glVertexAttrib3fvARB(attribs->orco.glIndex, attribs->orco.array[index]);
}
/* uv texture coordinates */
- for(b = 0; b < attribs->tottface; b++) {
+ for (b = 0; b < attribs->tottface; b++) {
MTFace *tf = &attribs->tface[b].array[a];
- if(attribs->tface[b].glTexco)
+ if (attribs->tface[b].glTexco)
glTexCoord2fv(tf->uv[vert]);
else
glVertexAttrib2fvARB(attribs->tface[b].glIndex, tf->uv[vert]);
}
/* vertex colors */
- for(b = 0; b < attribs->totmcol; b++) {
+ for (b = 0; b < attribs->totmcol; b++) {
MCol *cp = &attribs->mcol[b].array[a*4 + vert];
GLubyte col[4];
col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a;
@@ -997,13 +1004,13 @@ static void cddm_draw_attrib_vertex(DMVertexAttribs *attribs, MVert *mvert, int
}
/* tangent for normal mapping */
- if(attribs->tottang) {
+ if (attribs->tottang) {
float *tang = attribs->tang.array[a*4 + vert];
glVertexAttrib4fvARB(attribs->tang.glIndex, tang);
}
/* vertex normal */
- if(smoothnormal)
+ if (smoothnormal)
glNormal3sv(mvert[index].no);
/* vertex coordinate */
@@ -1032,52 +1039,53 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm,
glShadeModel(GL_SMOOTH);
- if( GPU_buffer_legacy(dm) || setDrawOptions != NULL ) {
+ if ( GPU_buffer_legacy(dm) || setDrawOptions != NULL ) {
DEBUG_VBO( "Using legacy code. cdDM_drawMappedFacesGLSL\n" );
memset(&attribs, 0, sizeof(attribs));
glBegin(GL_QUADS);
- for(a = 0; a < dm->numTessFaceData; a++, mface++) {
+ for (a = 0; a < dm->numTessFaceData; a++, mface++) {
const int smoothnormal = (mface->flag & ME_SMOOTH);
new_matnr = mface->mat_nr + 1;
- if(new_matnr != matnr) {
+ if (new_matnr != matnr) {
glEnd();
dodraw = setMaterial(matnr = new_matnr, &gattribs);
- if(dodraw)
+ if (dodraw)
DM_vertex_attributes_from_gpu(dm, &gattribs, &attribs);
glBegin(GL_QUADS);
}
- if(!dodraw) {
+ if (!dodraw) {
continue;
}
- else if(setDrawOptions) {
+ else if (setDrawOptions) {
orig = (index)? index[a]: a;
- if(orig == ORIGINDEX_NONE) {
+ if (orig == ORIGINDEX_NONE) {
/* since the material is set by setMaterial(), faces with no
* origin can be assumed to be generated by a modifier */
/* continue */
}
- else if(setDrawOptions(userData, orig) == DM_DRAW_OPTION_SKIP)
+ else if (setDrawOptions(userData, orig) == DM_DRAW_OPTION_SKIP)
continue;
}
- if(!smoothnormal) {
- if(nors) {
+ if (!smoothnormal) {
+ if (nors) {
glNormal3fv(nors[a]);
}
else {
/* TODO ideally a normal layer should always be available */
float nor[3];
- if(mface->v4) {
+ if (mface->v4) {
normal_quad_v3( nor,mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co, mvert[mface->v4].co);
- } else {
+ }
+ else {
normal_tri_v3( nor,mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co);
}
glNormal3fv(nor);
@@ -1088,7 +1096,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm,
cddm_draw_attrib_vertex(&attribs, mvert, a, mface->v2, 1, smoothnormal);
cddm_draw_attrib_vertex(&attribs, mvert, a, mface->v3, 2, smoothnormal);
- if(mface->v4)
+ if (mface->v4)
cddm_draw_attrib_vertex(&attribs, mvert, a, mface->v4, 3, smoothnormal);
else
cddm_draw_attrib_vertex(&attribs, mvert, a, mface->v3, 2, smoothnormal);
@@ -1109,21 +1117,21 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm,
GPU_vertex_setup(dm);
GPU_normal_setup(dm);
- if( !GPU_buffer_legacy(dm) ) {
- for( i = 0; i < dm->drawObject->tot_triangle_point/3; i++ ) {
+ if ( !GPU_buffer_legacy(dm) ) {
+ for ( i = 0; i < dm->drawObject->tot_triangle_point/3; i++ ) {
a = dm->drawObject->triangle_to_mface[i];
mface = mf + a;
new_matnr = mface->mat_nr + 1;
- if(new_matnr != matnr ) {
+ if (new_matnr != matnr ) {
numfaces = curface - start;
- if( numfaces > 0 ) {
+ if ( numfaces > 0 ) {
- if( dodraw ) {
+ if ( dodraw ) {
- if( numdata != 0 ) {
+ if ( numdata != 0 ) {
GPU_buffer_unlock(buffer);
@@ -1132,7 +1140,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm,
glDrawArrays(GL_TRIANGLES,start*3,numfaces*3);
- if( numdata != 0 ) {
+ if ( numdata != 0 ) {
GPU_buffer_free(buffer);
@@ -1145,43 +1153,43 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm,
start = curface;
/* prevdraw = dodraw; */ /* UNUSED */
dodraw = setMaterial(matnr = new_matnr, &gattribs);
- if(dodraw) {
+ if (dodraw) {
DM_vertex_attributes_from_gpu(dm, &gattribs, &attribs);
- if(attribs.totorco) {
+ if (attribs.totorco) {
datatypes[numdata].index = attribs.orco.glIndex;
datatypes[numdata].size = 3;
datatypes[numdata].type = GL_FLOAT;
numdata++;
}
- for(b = 0; b < attribs.tottface; b++) {
+ for (b = 0; b < attribs.tottface; b++) {
datatypes[numdata].index = attribs.tface[b].glIndex;
datatypes[numdata].size = 2;
datatypes[numdata].type = GL_FLOAT;
numdata++;
}
- for(b = 0; b < attribs.totmcol; b++) {
+ for (b = 0; b < attribs.totmcol; b++) {
datatypes[numdata].index = attribs.mcol[b].glIndex;
datatypes[numdata].size = 4;
datatypes[numdata].type = GL_UNSIGNED_BYTE;
numdata++;
}
- if(attribs.tottang) {
+ if (attribs.tottang) {
datatypes[numdata].index = attribs.tang.glIndex;
datatypes[numdata].size = 4;
datatypes[numdata].type = GL_FLOAT;
numdata++;
}
- if( numdata != 0 ) {
+ if ( numdata != 0 ) {
elementsize = GPU_attrib_element_size( datatypes, numdata );
buffer = GPU_buffer_alloc( elementsize*dm->drawObject->tot_triangle_point);
- if( buffer == NULL ) {
+ if ( buffer == NULL ) {
GPU_buffer_unbind();
dm->drawObject->legacy = 1;
return;
}
varray = GPU_buffer_lock_stream(buffer);
- if( varray == NULL ) {
+ if ( varray == NULL ) {
GPU_buffer_unbind();
GPU_buffer_free(buffer);
dm->drawObject->legacy = 1;
@@ -1197,15 +1205,15 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm,
}
}
- if(dodraw && numdata != 0 ) {
+ if (dodraw && numdata != 0 ) {
offset = 0;
- if(attribs.totorco) {
+ if (attribs.totorco) {
copy_v3_v3((float *)&varray[elementsize*curface*3],(float *)attribs.orco.array[mface->v1]);
copy_v3_v3((float *)&varray[elementsize*curface*3+elementsize],(float *)attribs.orco.array[mface->v2]);
copy_v3_v3((float *)&varray[elementsize*curface*3+elementsize*2],(float *)attribs.orco.array[mface->v3]);
offset += sizeof(float)*3;
}
- for(b = 0; b < attribs.tottface; b++) {
+ for (b = 0; b < attribs.tottface; b++) {
MTFace *tf = &attribs.tface[b].array[a];
copy_v2_v2((float *)&varray[elementsize*curface*3+offset],tf->uv[0]);
copy_v2_v2((float *)&varray[elementsize*curface*3+offset+elementsize],tf->uv[1]);
@@ -1213,7 +1221,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm,
copy_v2_v2((float *)&varray[elementsize*curface*3+offset+elementsize*2],tf->uv[2]);
offset += sizeof(float)*2;
}
- for(b = 0; b < attribs.totmcol; b++) {
+ for (b = 0; b < attribs.totmcol; b++) {
MCol *cp = &attribs.mcol[b].array[a*4 + 0];
GLubyte col[4];
col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a;
@@ -1226,7 +1234,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm,
copy_v4_v4_char((char *)&varray[elementsize*curface*3+offset+elementsize*2], (char *)col);
offset += sizeof(unsigned char)*4;
}
- if(attribs.tottang) {
+ if (attribs.tottang) {
float *tang = attribs.tang.array[a*4 + 0];
copy_v4_v4((float *)&varray[elementsize*curface*3+offset], tang);
tang = attribs.tang.array[a*4 + 1];
@@ -1238,23 +1246,23 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm,
(void)offset;
}
curface++;
- if(mface->v4) {
- if(dodraw && numdata != 0 ) {
+ if (mface->v4) {
+ if (dodraw && numdata != 0 ) {
offset = 0;
- if(attribs.totorco) {
+ if (attribs.totorco) {
copy_v3_v3((float *)&varray[elementsize*curface*3],(float *)attribs.orco.array[mface->v3]);
copy_v3_v3((float *)&varray[elementsize*curface*3+elementsize],(float *)attribs.orco.array[mface->v4]);
copy_v3_v3((float *)&varray[elementsize*curface*3+elementsize*2],(float *)attribs.orco.array[mface->v1]);
offset += sizeof(float)*3;
}
- for(b = 0; b < attribs.tottface; b++) {
+ for (b = 0; b < attribs.tottface; b++) {
MTFace *tf = &attribs.tface[b].array[a];
copy_v2_v2((float *)&varray[elementsize*curface*3+offset],tf->uv[2]);
copy_v2_v2((float *)&varray[elementsize*curface*3+offset+elementsize],tf->uv[3]);
copy_v2_v2((float *)&varray[elementsize*curface*3+offset+elementsize*2],tf->uv[0]);
offset += sizeof(float)*2;
}
- for(b = 0; b < attribs.totmcol; b++) {
+ for (b = 0; b < attribs.totmcol; b++) {
MCol *cp = &attribs.mcol[b].array[a*4 + 2];
GLubyte col[4];
col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a;
@@ -1267,7 +1275,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm,
copy_v4_v4_char((char *)&varray[elementsize*curface*3+offset+elementsize*2], (char *)col);
offset += sizeof(unsigned char)*4;
}
- if(attribs.tottang) {
+ if (attribs.tottang) {
float *tang = attribs.tang.array[a*4 + 2];
copy_v4_v4((float *)&varray[elementsize*curface*3+offset], tang);
tang = attribs.tang.array[a*4 + 3];
@@ -1283,9 +1291,9 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm,
}
}
numfaces = curface - start;
- if( numfaces > 0 ) {
- if( dodraw ) {
- if( numdata != 0 ) {
+ if ( numfaces > 0 ) {
+ if ( dodraw ) {
+ if ( numdata != 0 ) {
GPU_buffer_unlock(buffer);
GPU_interleaved_attrib_setup(buffer,datatypes,numdata);
}
@@ -1328,13 +1336,13 @@ static void cdDM_drawMappedFacesMat(DerivedMesh *dm,
glBegin(GL_QUADS);
- for(a = 0; a < dm->numTessFaceData; a++, mf++) {
+ for (a = 0; a < dm->numTessFaceData; a++, mf++) {
const int smoothnormal = (mf->flag & ME_SMOOTH);
/* material */
new_matnr = mf->mat_nr + 1;
- if(new_matnr != matnr) {
+ if (new_matnr != matnr) {
glEnd();
setMaterial(userData, matnr = new_matnr, &gattribs);
@@ -1344,23 +1352,23 @@ static void cdDM_drawMappedFacesMat(DerivedMesh *dm,
}
/* skipping faces */
- if(setFace) {
+ if (setFace) {
orig = (index)? index[a]: a;
- if(orig != ORIGINDEX_NONE && !setFace(userData, orig))
+ if (orig != ORIGINDEX_NONE && !setFace(userData, orig))
continue;
}
/* smooth normal */
- if(!smoothnormal) {
- if(nors) {
+ if (!smoothnormal) {
+ if (nors) {
glNormal3fv(nors[a]);
}
else {
/* TODO ideally a normal layer should always be available */
float nor[3];
- if(mf->v4)
+ if (mf->v4)
normal_quad_v3( nor,mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co, mvert[mf->v4].co);
else
normal_tri_v3( nor,mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co);
@@ -1374,7 +1382,7 @@ static void cdDM_drawMappedFacesMat(DerivedMesh *dm,
cddm_draw_attrib_vertex(&attribs, mvert, a, mf->v2, 1, smoothnormal);
cddm_draw_attrib_vertex(&attribs, mvert, a, mf->v3, 2, smoothnormal);
- if(mf->v4)
+ if (mf->v4)
cddm_draw_attrib_vertex(&attribs, mvert, a, mf->v4, 3, smoothnormal);
else
cddm_draw_attrib_vertex(&attribs, mvert, a, mf->v3, 2, smoothnormal);
@@ -1392,15 +1400,15 @@ static void cdDM_drawMappedEdges(DerivedMesh *dm, DMSetDrawOptions setDrawOption
int i, orig, *index = DM_get_edge_data_layer(dm, CD_ORIGINDEX);
glBegin(GL_LINES);
- for(i = 0; i < dm->numEdgeData; i++, edge++) {
- if(index) {
+ for (i = 0; i < dm->numEdgeData; i++, edge++) {
+ if (index) {
orig = *index++;
- if(setDrawOptions && orig == ORIGINDEX_NONE) continue;
+ if (setDrawOptions && orig == ORIGINDEX_NONE) continue;
}
else
orig = i;
- if(!setDrawOptions || (setDrawOptions(userData, orig) != DM_DRAW_OPTION_SKIP)) {
+ if (!setDrawOptions || (setDrawOptions(userData, orig) != DM_DRAW_OPTION_SKIP)) {
glVertex3fv(vert[edge->v1].co);
glVertex3fv(vert[edge->v2].co);
}
@@ -1417,10 +1425,10 @@ static void cdDM_foreachMappedVert(
MVert *mv = CDDM_get_verts(dm);
int i, orig, *index = DM_get_vert_data_layer(dm, CD_ORIGINDEX);
- for(i = 0; i < dm->numVertData; i++, mv++) {
- if(index) {
+ for (i = 0; i < dm->numVertData; i++, mv++) {
+ if (index) {
orig = *index++;
- if(orig == ORIGINDEX_NONE) continue;
+ if (orig == ORIGINDEX_NONE) continue;
func(userData, orig, mv->co, NULL, mv->no);
}
else
@@ -1439,10 +1447,10 @@ static void cdDM_foreachMappedEdge(
MEdge *med = cddm->medge;
int i, orig, *index = DM_get_edge_data_layer(dm, CD_ORIGINDEX);
- for(i = 0; i < dm->numEdgeData; i++, med++) {
+ for (i = 0; i < dm->numEdgeData; i++, med++) {
if (index) {
orig = *index++;
- if(orig == ORIGINDEX_NONE) continue;
+ if (orig == ORIGINDEX_NONE) continue;
func(userData, orig, mv[med->v1].co, mv[med->v2].co);
}
else
@@ -1464,13 +1472,13 @@ static void cdDM_foreachMappedFaceCenter(
index = CustomData_get_layer(&dm->polyData, CD_ORIGINDEX);
mf = cddm->mpoly;
- for(i = 0; i < dm->numPolyData; i++, mf++) {
+ for (i = 0; i < dm->numPolyData; i++, mf++) {
float cent[3];
float no[3];
if (index) {
orig = *index++;
- if(orig == ORIGINDEX_NONE) continue;
+ if (orig == ORIGINDEX_NONE) continue;
}
else
orig = i;
@@ -1486,7 +1494,8 @@ static void cdDM_foreachMappedFaceCenter(
if (j > 3) {
normal_quad_v3(no, mv[ml->v].co, mv[(ml+1)->v].co,
mv[(ml+2)->v].co, mv[(ml+3)->v].co);
- } else {
+ }
+ else {
normal_tri_v3(no, mv[ml->v].co, mv[(ml+1)->v].co, mv[(ml+2)->v].co);
}
@@ -1523,8 +1532,8 @@ void CDDM_recalc_tessellation(DerivedMesh *dm)
static void cdDM_free_internal(CDDerivedMesh *cddm)
{
- if(cddm->pmap) MEM_freeN(cddm->pmap);
- if(cddm->pmap_mem) MEM_freeN(cddm->pmap_mem);
+ if (cddm->pmap) MEM_freeN(cddm->pmap);
+ if (cddm->pmap_mem) MEM_freeN(cddm->pmap_mem);
}
static void cdDM_release(DerivedMesh *dm)
@@ -1882,7 +1891,7 @@ DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *UNUSED(me), int use_mdis
polyindex = dm->getTessFaceDataArray(dm, CD_POLYINDEX);
index = dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
- for(i = 0; i < dm->numTessFaceData; i++, index++, polyindex++) {
+ for (i = 0; i < dm->numTessFaceData; i++, index++, polyindex++) {
MFace *mf = &mface[i];
BMLoop **l = em->looptris[i];
efa = l[0]->f;
@@ -2020,13 +2029,13 @@ DerivedMesh *CDDM_from_template(DerivedMesh *source,
CustomData_add_layer(&dm->loopData, CD_MLOOP, CD_CALLOC, NULL, numLoops);
CustomData_add_layer(&dm->polyData, CD_MPOLY, CD_CALLOC, NULL, numPolys);
- if(!CustomData_get_layer(&dm->vertData, CD_ORIGINDEX))
+ if (!CustomData_get_layer(&dm->vertData, CD_ORIGINDEX))
CustomData_add_layer(&dm->vertData, CD_ORIGINDEX, CD_CALLOC, NULL, numVerts);
- if(!CustomData_get_layer(&dm->edgeData, CD_ORIGINDEX))
+ if (!CustomData_get_layer(&dm->edgeData, CD_ORIGINDEX))
CustomData_add_layer(&dm->edgeData, CD_ORIGINDEX, CD_CALLOC, NULL, numEdges);
- if(!CustomData_get_layer(&dm->faceData, CD_ORIGINDEX))
+ if (!CustomData_get_layer(&dm->faceData, CD_ORIGINDEX))
CustomData_add_layer(&dm->faceData, CD_ORIGINDEX, CD_CALLOC, NULL, numTessFaces);
- if(!CustomData_get_layer(&dm->faceData, CD_POLYINDEX))
+ if (!CustomData_get_layer(&dm->faceData, CD_POLYINDEX))
CustomData_add_layer(&dm->faceData, CD_POLYINDEX, CD_CALLOC, NULL, numTessFaces);
cddm->mvert = CustomData_get_layer(&dm->vertData, CD_MVERT);
@@ -2048,7 +2057,7 @@ void CDDM_apply_vert_coords(DerivedMesh *dm, float (*vertCoords)[3])
vert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MVERT, dm->numVertData);
cddm->mvert = vert;
- for(i = 0; i < dm->numVertData; ++i, ++vert)
+ for (i = 0; i < dm->numVertData; ++i, ++vert)
copy_v3_v3(vert->co, vertCoords[i]);
}
@@ -2062,7 +2071,7 @@ void CDDM_apply_vert_normals(DerivedMesh *dm, short (*vertNormals)[3])
vert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MVERT, dm->numVertData);
cddm->mvert = vert;
- for(i = 0; i < dm->numVertData; ++i, ++vert)
+ for (i = 0; i < dm->numVertData; ++i, ++vert)
copy_v3_v3_short(vert->no, vertNormals[i]);
}
@@ -2071,7 +2080,7 @@ void CDDM_calc_normals_mapping_ex(DerivedMesh *dm, const short only_face_normals
CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
float (*face_nors)[3] = NULL;
- if(dm->numVertData == 0) return;
+ if (dm->numVertData == 0) return;
/* now we skip calculating vertex normals for referenced layer,
* no need to duplicate verts.
@@ -2125,7 +2134,7 @@ void CDDM_calc_normals(DerivedMesh *dm)
CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
float (*poly_nors)[3];
- if(dm->numVertData == 0) return;
+ if (dm->numVertData == 0) return;
/* we don't want to overwrite any referenced layers */
cddm->mvert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MVERT, dm->numVertData);
@@ -2145,7 +2154,7 @@ void CDDM_calc_normals_tessface(DerivedMesh *dm)
CDDerivedMesh *cddm = (CDDerivedMesh*)dm;
float (*face_nors)[3];
- if(dm->numVertData == 0) return;
+ if (dm->numVertData == 0) return;
/* we don't want to overwrite any referenced layers */
cddm->mvert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MVERT, dm->numVertData);
@@ -2367,7 +2376,8 @@ void CDDM_calc_edges_tessface(DerivedMesh *dm)
BLI_edgehash_insert(eh, mf->v3, mf->v4, NULL);
if (!BLI_edgehash_haskey(eh, mf->v4, mf->v1))
BLI_edgehash_insert(eh, mf->v4, mf->v1, NULL);
- } else {
+ }
+ else {
if (!BLI_edgehash_haskey(eh, mf->v3, mf->v1))
BLI_edgehash_insert(eh, mf->v3, mf->v1, NULL);
}
@@ -2383,7 +2393,7 @@ void CDDM_calc_edges_tessface(DerivedMesh *dm)
ehi = BLI_edgehashIterator_new(eh);
med = CustomData_get_layer(&edgeData, CD_MEDGE);
index = CustomData_get_layer(&edgeData, CD_ORIGINDEX);
- for(i = 0; !BLI_edgehashIterator_isDone(ehi);
+ for (i = 0; !BLI_edgehashIterator_isDone(ehi);
BLI_edgehashIterator_step(ehi), ++i, ++med, ++index) {
BLI_edgehashIterator_getKey(ehi, &med->v1, &med->v2);
@@ -2446,7 +2456,7 @@ void CDDM_calc_edges(DerivedMesh *dm)
ehi = BLI_edgehashIterator_new(eh);
med = CustomData_get_layer(&edgeData, CD_MEDGE);
index = CustomData_get_layer(&edgeData, CD_ORIGINDEX);
- for(i = 0; !BLI_edgehashIterator_isDone(ehi);
+ for (i = 0; !BLI_edgehashIterator_isDone(ehi);
BLI_edgehashIterator_step(ehi), ++i, ++med, ++index) {
BLI_edgehashIterator_getKey(ehi, &med->v1, &med->v2);
j = GET_INT_FROM_POINTER(BLI_edgehashIterator_getValue(ehi));
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index 3fb8a3501d0..0dd7687f998 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -158,10 +158,10 @@ void cloth_init ( ClothModifierData *clmd )
clmd->sim_parms->goalfrict = 0.0f;
clmd->sim_parms->velocity_smooth = 0.0f;
- if(!clmd->sim_parms->effector_weights)
+ if (!clmd->sim_parms->effector_weights)
clmd->sim_parms->effector_weights = BKE_add_effector_weights(NULL);
- if(clmd->point_cache)
+ if (clmd->point_cache)
clmd->point_cache->step = 1;
}
@@ -173,25 +173,25 @@ static BVHTree *bvhselftree_build_from_cloth (ClothModifierData *clmd, float eps
ClothVertex *verts;
float co[12];
- if(!clmd)
+ if (!clmd)
return NULL;
cloth = clmd->clothObject;
- if(!cloth)
+ if (!cloth)
return NULL;
verts = cloth->verts;
// in the moment, return zero if no faces there
- if(!cloth->numverts)
+ if (!cloth->numverts)
return NULL;
// create quadtree with k=26
bvhtree = BLI_bvhtree_new(cloth->numverts, epsilon, 4, 6);
// fill tree
- for(i = 0; i < cloth->numverts; i++, verts++)
+ for (i = 0; i < cloth->numverts; i++, verts++)
{
copy_v3_v3(&co[0*3], verts->xold);
@@ -213,32 +213,32 @@ static BVHTree *bvhtree_build_from_cloth (ClothModifierData *clmd, float epsilon
MFace *mfaces;
float co[12];
- if(!clmd)
+ if (!clmd)
return NULL;
cloth = clmd->clothObject;
- if(!cloth)
+ if (!cloth)
return NULL;
verts = cloth->verts;
mfaces = cloth->mfaces;
// in the moment, return zero if no faces there
- if(!cloth->numfaces)
+ if (!cloth->numfaces)
return NULL;
// create quadtree with k=26
bvhtree = BLI_bvhtree_new(cloth->numfaces, epsilon, 4, 26);
// fill tree
- for(i = 0; i < cloth->numfaces; i++, mfaces++)
+ for (i = 0; i < cloth->numfaces; i++, mfaces++)
{
copy_v3_v3(&co[0*3], verts[mfaces->v1].xold);
copy_v3_v3(&co[1*3], verts[mfaces->v2].xold);
copy_v3_v3(&co[2*3], verts[mfaces->v3].xold);
- if(mfaces->v4)
+ if (mfaces->v4)
copy_v3_v3(&co[3*3], verts[mfaces->v4].xold);
BLI_bvhtree_insert(bvhtree, i, co, (mfaces->v4 ? 4 : 3));
@@ -260,32 +260,32 @@ void bvhtree_update_from_cloth(ClothModifierData *clmd, int moving)
float co[12], co_moving[12];
int ret = 0;
- if(!bvhtree)
+ if (!bvhtree)
return;
mfaces = cloth->mfaces;
// update vertex position in bvh tree
- if(verts && mfaces)
+ if (verts && mfaces)
{
- for(i = 0; i < cloth->numfaces; i++, mfaces++)
+ for (i = 0; i < cloth->numfaces; i++, mfaces++)
{
copy_v3_v3(&co[0*3], verts[mfaces->v1].txold);
copy_v3_v3(&co[1*3], verts[mfaces->v2].txold);
copy_v3_v3(&co[2*3], verts[mfaces->v3].txold);
- if(mfaces->v4)
+ if (mfaces->v4)
copy_v3_v3(&co[3*3], verts[mfaces->v4].txold);
// copy new locations into array
- if(moving)
+ if (moving)
{
// update moving positions
copy_v3_v3(&co_moving[0*3], verts[mfaces->v1].tx);
copy_v3_v3(&co_moving[1*3], verts[mfaces->v2].tx);
copy_v3_v3(&co_moving[2*3], verts[mfaces->v3].tx);
- if(mfaces->v4)
+ if (mfaces->v4)
copy_v3_v3(&co_moving[3*3], verts[mfaces->v4].tx);
ret = BLI_bvhtree_update_node(bvhtree, i, co, co_moving, (mfaces->v4 ? 4 : 3));
@@ -295,7 +295,7 @@ void bvhtree_update_from_cloth(ClothModifierData *clmd, int moving)
}
// check if tree is already full
- if(!ret)
+ if (!ret)
break;
}
@@ -313,20 +313,20 @@ void bvhselftree_update_from_cloth(ClothModifierData *clmd, int moving)
float co[12], co_moving[12];
int ret = 0;
- if(!bvhtree)
+ if (!bvhtree)
return;
mfaces = cloth->mfaces;
// update vertex position in bvh tree
- if(verts && mfaces)
+ if (verts && mfaces)
{
- for(i = 0; i < cloth->numverts; i++, verts++)
+ for (i = 0; i < cloth->numverts; i++, verts++)
{
copy_v3_v3(&co[0*3], verts->txold);
// copy new locations into array
- if(moving)
+ if (moving)
{
// update moving positions
copy_v3_v3(&co_moving[0*3], verts->tx);
@@ -338,7 +338,7 @@ void bvhselftree_update_from_cloth(ClothModifierData *clmd, int moving)
}
// check if tree is already full
- if(!ret)
+ if (!ret)
break;
}
@@ -353,7 +353,7 @@ void cloth_clear_cache(Object *ob, ClothModifierData *clmd, float framenr)
BKE_ptcache_id_from_cloth(&pid, ob, clmd);
// don't do anything as long as we're in editmode!
- if(pid.cache->edit && ob->mode & OB_MODE_PARTICLE_EDIT)
+ if (pid.cache->edit && ob->mode & OB_MODE_PARTICLE_EDIT)
return;
BKE_ptcache_id_clear(&pid, PTCACHE_CLEAR_AFTER, framenr);
@@ -366,13 +366,13 @@ static int do_init_cloth(Object *ob, ClothModifierData *clmd, DerivedMesh *resul
cache= clmd->point_cache;
/* initialize simulation data if it didn't exist already */
- if(clmd->clothObject == NULL) {
- if(!cloth_from_object(ob, clmd, result, framenr, 1)) {
+ if (clmd->clothObject == NULL) {
+ if (!cloth_from_object(ob, clmd, result, framenr, 1)) {
BKE_ptcache_invalidate(cache);
return 0;
}
- if(clmd->clothObject == NULL) {
+ if (clmd->clothObject == NULL) {
BKE_ptcache_invalidate(cache);
return 0;
}
@@ -400,7 +400,7 @@ static int do_step_cloth(Object *ob, ClothModifierData *clmd, DerivedMesh *resul
mvert = result->getVertArray(result);
/* force any pinned verts to their constrained location. */
- for(i = 0; i < clmd->clothObject->numverts; i++, verts++) {
+ for (i = 0; i < clmd->clothObject->numverts; i++, verts++) {
/* save the previous position. */
copy_v3_v3(verts->xold, verts->xconst);
copy_v3_v3(verts->txold, verts->x);
@@ -415,7 +415,7 @@ static int do_step_cloth(Object *ob, ClothModifierData *clmd, DerivedMesh *resul
tstart();
/* call the solver. */
- if(solvers [clmd->sim_parms->solver_type].solver)
+ if (solvers [clmd->sim_parms->solver_type].solver)
ret = solvers[clmd->sim_parms->solver_type].solver(ob, framenr, clmd, effectors);
tend();
@@ -446,7 +446,7 @@ void clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, Derived
BKE_ptcache_id_time(&pid, scene, framenr, &startframe, &endframe, &timescale);
clmd->sim_parms->timescale= timescale;
- if(clmd->sim_parms->reset
+ if (clmd->sim_parms->reset
|| (framenr == (startframe - clmd->sim_parms->preroll) && clmd->sim_parms->preroll != 0)
|| (clmd->clothObject && dm->getNumVerts(dm) != clmd->clothObject->numverts))
{
@@ -463,11 +463,11 @@ void clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, Derived
clmd->sim_parms->dt = clmd->sim_parms->timescale / clmd->sim_parms->stepsPerFrame;
/* handle continuous simulation with the play button */
- if(BKE_ptcache_get_continue_physics() || ((clmd->sim_parms->preroll > 0) && (framenr > startframe - clmd->sim_parms->preroll) && (framenr < startframe))) {
+ if (BKE_ptcache_get_continue_physics() || ((clmd->sim_parms->preroll > 0) && (framenr > startframe - clmd->sim_parms->preroll) && (framenr < startframe))) {
BKE_ptcache_invalidate(cache);
/* do simulation */
- if(!do_init_cloth(ob, clmd, dm, framenr))
+ if (!do_init_cloth(ob, clmd, dm, framenr))
return;
do_step_cloth(ob, clmd, dm, framenr);
@@ -479,19 +479,19 @@ void clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, Derived
}
/* simulation is only active during a specific period */
- if(framenr < startframe) {
+ if (framenr < startframe) {
BKE_ptcache_invalidate(cache);
return;
}
- else if(framenr > endframe) {
+ else if (framenr > endframe) {
framenr= endframe;
}
/* initialize simulation data if it didn't exist already */
- if(!do_init_cloth(ob, clmd, dm, framenr))
+ if (!do_init_cloth(ob, clmd, dm, framenr))
return;
- if((framenr == startframe) && (clmd->sim_parms->preroll == 0)) {
+ if ((framenr == startframe) && (clmd->sim_parms->preroll == 0)) {
BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
do_init_cloth(ob, clmd, dm, framenr);
BKE_ptcache_validate(cache, framenr);
@@ -503,33 +503,33 @@ void clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, Derived
/* try to read from cache */
cache_result = BKE_ptcache_read(&pid, (float)framenr+scene->r.subframe);
- if(cache_result == PTCACHE_READ_EXACT || cache_result == PTCACHE_READ_INTERPOLATED) {
+ if (cache_result == PTCACHE_READ_EXACT || cache_result == PTCACHE_READ_INTERPOLATED) {
implicit_set_positions(clmd);
cloth_to_object (ob, clmd, vertexCos);
BKE_ptcache_validate(cache, framenr);
- if(cache_result == PTCACHE_READ_INTERPOLATED && cache->flag & PTCACHE_REDO_NEEDED)
+ if (cache_result == PTCACHE_READ_INTERPOLATED && cache->flag & PTCACHE_REDO_NEEDED)
BKE_ptcache_write(&pid, framenr);
clmd->clothObject->last_frame= framenr;
return;
}
- else if(cache_result==PTCACHE_READ_OLD) {
+ else if (cache_result==PTCACHE_READ_OLD) {
implicit_set_positions(clmd);
}
- else if( /*ob->id.lib ||*/ (cache->flag & PTCACHE_BAKED)) { /* 2.4x disabled lib, but this can be used in some cases, testing further - campbell */
+ else if ( /*ob->id.lib ||*/ (cache->flag & PTCACHE_BAKED)) { /* 2.4x disabled lib, but this can be used in some cases, testing further - campbell */
/* if baked and nothing in cache, do nothing */
BKE_ptcache_invalidate(cache);
return;
}
- if(framenr!=clmd->clothObject->last_frame+1)
+ if (framenr!=clmd->clothObject->last_frame+1)
return;
/* if on second frame, write cache for first frame */
- if(cache->simframe == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact==0))
+ if (cache->simframe == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact==0))
BKE_ptcache_write(&pid, startframe);
clmd->sim_parms->timescale *= framenr - cache->simframe;
@@ -537,7 +537,7 @@ void clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, Derived
/* do simulation */
BKE_ptcache_validate(cache, framenr);
- if(!do_step_cloth(ob, clmd, dm, framenr)) {
+ if (!do_step_cloth(ob, clmd, dm, framenr)) {
BKE_ptcache_invalidate(cache);
}
else
@@ -577,7 +577,7 @@ void cloth_free_modifier(ClothModifierData *clmd )
if ( cloth->springs != NULL )
{
LinkNode *search = cloth->springs;
- while(search)
+ while (search)
{
ClothSpring *spring = search->link;
@@ -603,12 +603,12 @@ void cloth_free_modifier(ClothModifierData *clmd )
if ( cloth->mfaces )
MEM_freeN ( cloth->mfaces );
- if(cloth->edgehash)
+ if (cloth->edgehash)
BLI_edgehash_free ( cloth->edgehash, NULL );
/*
- if(clmd->clothObject->facemarks)
+ if (clmd->clothObject->facemarks)
MEM_freeN(clmd->clothObject->facemarks);
*/
MEM_freeN ( cloth );
@@ -620,7 +620,7 @@ void cloth_free_modifier(ClothModifierData *clmd )
void cloth_free_modifier_extern ( ClothModifierData *clmd )
{
Cloth *cloth = NULL;
- if(G.rt > 0)
+ if (G.rt > 0)
printf("cloth_free_modifier_extern\n");
if ( !clmd )
@@ -630,7 +630,7 @@ void cloth_free_modifier_extern ( ClothModifierData *clmd )
if ( cloth )
{
- if(G.rt > 0)
+ if (G.rt > 0)
printf("cloth_free_modifier_extern in\n");
// If our solver provides a free function, call it
@@ -650,7 +650,7 @@ void cloth_free_modifier_extern ( ClothModifierData *clmd )
if ( cloth->springs != NULL )
{
LinkNode *search = cloth->springs;
- while(search)
+ while (search)
{
ClothSpring *spring = search->link;
@@ -676,12 +676,12 @@ void cloth_free_modifier_extern ( ClothModifierData *clmd )
if ( cloth->mfaces )
MEM_freeN ( cloth->mfaces );
- if(cloth->edgehash)
+ if (cloth->edgehash)
BLI_edgehash_free ( cloth->edgehash, NULL );
/*
- if(clmd->clothObject->facemarks)
+ if (clmd->clothObject->facemarks)
MEM_freeN(clmd->clothObject->facemarks);
*/
MEM_freeN ( cloth );
@@ -777,20 +777,20 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm )
if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SCALING )
{
- if( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_struct-1))
+ if ( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_struct-1))
{
verts->struct_stiff = dvert->dw [j].weight;
verts->shear_stiff = dvert->dw [j].weight;
}
- if( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_bend-1))
+ if ( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_bend-1))
{
verts->bend_stiff = dvert->dw [j].weight;
}
}
/*
// for later
- if( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_weight-1))
+ if ( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_weight-1))
{
verts->mass = dvert->dw [j].weight;
}
@@ -815,7 +815,7 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d
if ( clmd->clothObject != NULL )
{
cloth_free_modifier ( clmd );
- if(G.rt > 0)
+ if (G.rt > 0)
printf("cloth_free_modifier cloth_from_object\n");
}
@@ -843,7 +843,7 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d
clmd->clothObject->springs = NULL;
clmd->clothObject->numsprings = -1;
- if( clmd->sim_parms->shapekey_rest )
+ if ( clmd->sim_parms->shapekey_rest )
shapekey_rest = dm->getVertDataArray ( dm, CD_CLOTH_ORCO );
mvert = dm->getVertArray ( dm );
@@ -853,13 +853,13 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d
// set initial values
for ( i = 0; i < dm->getNumVerts(dm); i++, verts++ )
{
- if(first)
+ if (first)
{
copy_v3_v3( verts->x, mvert[i].co );
mul_m4_v3( ob->obmat, verts->x );
- if( shapekey_rest ) {
+ if ( shapekey_rest ) {
verts->xrest= shapekey_rest[i];
mul_m4_v3( ob->obmat, verts->xrest );
}
@@ -901,7 +901,7 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d
for ( i = 0; i < dm->getNumVerts(dm); i++)
{
- if((!(cloth->verts[i].flags & CLOTH_VERT_FLAG_PINNED)) && (cloth->verts[i].goal > ALMOST_ZERO))
+ if ((!(cloth->verts[i].flags & CLOTH_VERT_FLAG_PINNED)) && (cloth->verts[i].goal > ALMOST_ZERO))
{
cloth_add_spring (clmd, i, i, 0.0, CLOTH_SPRING_TYPE_GOAL);
}
@@ -912,12 +912,12 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d
solvers [clmd->sim_parms->solver_type].init ( ob, clmd );
}
- if(!first)
+ if (!first)
implicit_set_positions(clmd);
clmd->clothObject->bvhtree = bvhtree_build_from_cloth ( clmd, MAX2(clmd->coll_parms->epsilon, clmd->coll_parms->distance_repel) );
- for(i = 0; i < dm->getNumVerts(dm); i++)
+ for (i = 0; i < dm->getNumVerts(dm); i++)
{
maxdist = MAX2(maxdist, clmd->coll_parms->selfepsilon* ( cloth->verts[i].avg_spring_len*2.0f));
}
@@ -977,13 +977,13 @@ int cloth_add_spring ( ClothModifierData *clmd, unsigned int indexA, unsigned in
Cloth *cloth = clmd->clothObject;
ClothSpring *spring = NULL;
- if(cloth)
+ if (cloth)
{
// TODO: look if this spring is already there
spring = ( ClothSpring * ) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" );
- if(!spring)
+ if (!spring)
return 0;
spring->ij = indexA;
@@ -1009,7 +1009,7 @@ static void cloth_free_errorsprings(Cloth *cloth, EdgeHash *UNUSED(edgehash), Li
if ( cloth->springs != NULL )
{
LinkNode *search = cloth->springs;
- while(search)
+ while (search)
{
ClothSpring *spring = search->link;
@@ -1021,7 +1021,7 @@ static void cloth_free_errorsprings(Cloth *cloth, EdgeHash *UNUSED(edgehash), Li
cloth->springs = NULL;
}
- if(edgelist)
+ if (edgelist)
{
for ( i = 0; i < cloth->numverts; i++ )
{
@@ -1031,7 +1031,7 @@ static void cloth_free_errorsprings(Cloth *cloth, EdgeHash *UNUSED(edgehash), Li
MEM_freeN ( edgelist );
}
- if(cloth->edgehash)
+ if (cloth->edgehash)
BLI_edgehash_free ( cloth->edgehash, NULL );
}
@@ -1059,7 +1059,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
edgelist = MEM_callocN ( sizeof ( LinkNode * ) * numverts, "cloth_edgelist_alloc" );
- if(!edgelist)
+ if (!edgelist)
return 0;
for ( i = 0; i < numverts; i++ )
@@ -1101,10 +1101,10 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
}
}
- if(struct_springs > 0)
+ if (struct_springs > 0)
clmd->sim_parms->avg_spring_len /= struct_springs;
- for(i = 0; i < numverts; i++)
+ for (i = 0; i < numverts; i++)
{
cloth->verts[i].avg_spring_len = cloth->verts[i].avg_spring_len * 0.49f / ((float)cloth->verts[i].spring_count);
}
@@ -1118,7 +1118,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
spring = ( ClothSpring *) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" );
- if(!spring)
+ if (!spring)
{
cloth_free_errorsprings(cloth, edgehash, edgelist);
return 0;
@@ -1140,7 +1140,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
// if ( mface[i].v4 ) --> Quad face
spring = ( ClothSpring * ) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" );
- if(!spring)
+ if (!spring)
{
cloth_free_errorsprings(cloth, edgehash, edgelist);
return 0;
@@ -1159,7 +1159,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
BLI_linklist_prepend ( &cloth->springs, spring );
}
- if(numfaces) {
+ if (numfaces) {
// bending springs
search2 = cloth->springs;
for ( i = struct_springs; i < struct_springs+shear_springs; i++ )
@@ -1181,7 +1181,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
{
spring = ( ClothSpring * ) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" );
- if(!spring)
+ if (!spring)
{
cloth_free_errorsprings(cloth, edgehash, edgelist);
return 0;
@@ -1202,7 +1202,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
search2 = search2->next;
}
}
- else if(struct_springs > 2) {
+ else if (struct_springs > 2) {
/* bending springs for hair strands */
/* The current algorightm only goes through the edges in order of the mesh edges list */
/* and makes springs between the outer vert of edges sharing a vertice. This works just */
@@ -1212,15 +1212,15 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
/* of the strands. -jahka */
search = cloth->springs;
search2 = search->next;
- while(search && search2)
+ while (search && search2)
{
tspring = search->link;
tspring2 = search2->link;
- if(tspring->ij == tspring2->kl) {
+ if (tspring->ij == tspring2->kl) {
spring = ( ClothSpring * ) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" );
- if(!spring)
+ if (!spring)
{
cloth_free_errorsprings(cloth, edgehash, edgelist);
return 0;
@@ -1247,7 +1247,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
for ( i = 0; i < numfaces; i++ ) // edge springs
{
- if(mface[i].v4)
+ if (mface[i].v4)
{
BLI_edgehash_insert ( edgehash, MIN2(mface[i].v1, mface[i].v3), MAX2(mface[i].v3, mface[i].v1), NULL );
@@ -1270,7 +1270,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
cloth->edgehash = edgehash;
- if(G.rt>0)
+ if (G.rt>0)
printf("avg_len: %f\n",clmd->sim_parms->avg_spring_len);
return 1;
diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c
index 93e6fa678f3..f6a6ef068d6 100644
--- a/source/blender/blenkernel/intern/collision.c
+++ b/source/blender/blenkernel/intern/collision.c
@@ -174,7 +174,7 @@ Collision modifier code end
* copied from SOLVE_CUBIC.C --> GSL
*/
-#define mySWAP(a,b) do { double tmp = b ; b = a ; a = tmp ; } while(0)
+#define mySWAP(a,b) do { double tmp = b ; b = a ; a = tmp ; } while (0)
#if 0 /* UNUSED */
static int
gsl_poly_solve_cubic (double a, double b, double c,
@@ -1021,7 +1021,8 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM
result = 1;
}
- } else {
+ }
+ else {
w1 = collpair->bary[0]; w2 = collpair->bary[1]; w3 = collpair->bary[2];
// Calculate relative "velocity".
@@ -1353,7 +1354,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, BVHTree
collpair->flag = COLLISION_USE_COLLFACE;
collpair++;
- } else if (ret && j >= 3) { /*coll vert versus cloth face*/
+ }
+ else if (ret && j >= 3) { /*coll vert versus cloth face*/
collpair->ap1 = ap1; collpair->ap2 = ap2; collpair->ap3 = ap3;
collpair->collp = collp;
@@ -1547,7 +1549,7 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2,
sub_v3_v3v3 ( relativeVelocity, v2, v1 );
- if(sqrt(dot_v3v3(relativeVelocity, relativeVelocity)) >= distance)
+ if (sqrt(dot_v3v3(relativeVelocity, relativeVelocity)) >= distance)
{
// check for collision in the future
collpair->flag |= COLLISION_IN_FUTURE;
@@ -1789,9 +1791,9 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float
CLAMP(*out_a1, 0.0, 1.0);
calculateEENormal(np11, np12, np21, np22, out_normal);
- if(*out_a1 > .5)
+ if (*out_a1 > .5)
{
- if(*out_a2 > .5)
+ if (*out_a2 > .5)
{
sub_v3_v3v3(temp, np12, np22);
}
@@ -1802,7 +1804,7 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float
}
else
{
- if(*out_a2 > .5)
+ if (*out_a2 > .5)
{
sub_v3_v3v3(temp, np11, np22);
}
@@ -1920,11 +1922,11 @@ static int cloth_collision_moving_edges ( ClothModifierData *clmd, CollisionModi
cloth1 = clmd->clothObject;
verts1 = cloth1->verts;
- for(i = 0; i < 9; i++)
+ for (i = 0; i < 9; i++)
{
// 9 edge - edge possibilities
- if(i == 0) // cloth edge: 1-2; coll edge: 1-2
+ if (i == 0) // cloth edge: 1-2; coll edge: 1-2
{
edgecollpair.p11 = collpair->ap1;
edgecollpair.p12 = collpair->ap2;
@@ -1932,7 +1934,7 @@ static int cloth_collision_moving_edges ( ClothModifierData *clmd, CollisionModi
edgecollpair.p21 = collpair->bp1;
edgecollpair.p22 = collpair->bp2;
}
- else if(i == 1) // cloth edge: 1-2; coll edge: 2-3
+ else if (i == 1) // cloth edge: 1-2; coll edge: 2-3
{
edgecollpair.p11 = collpair->ap1;
edgecollpair.p12 = collpair->ap2;
@@ -1940,7 +1942,7 @@ static int cloth_collision_moving_edges ( ClothModifierData *clmd, CollisionModi
edgecollpair.p21 = collpair->bp2;
edgecollpair.p22 = collpair->bp3;
}
- else if(i == 2) // cloth edge: 1-2; coll edge: 1-3
+ else if (i == 2) // cloth edge: 1-2; coll edge: 1-3
{
edgecollpair.p11 = collpair->ap1;
edgecollpair.p12 = collpair->ap2;
@@ -1948,7 +1950,7 @@ static int cloth_collision_moving_edges ( ClothModifierData *clmd, CollisionModi
edgecollpair.p21 = collpair->bp1;
edgecollpair.p22 = collpair->bp3;
}
- else if(i == 3) // cloth edge: 2-3; coll edge: 1-2
+ else if (i == 3) // cloth edge: 2-3; coll edge: 1-2
{
edgecollpair.p11 = collpair->ap2;
edgecollpair.p12 = collpair->ap3;
@@ -1956,7 +1958,7 @@ static int cloth_collision_moving_edges ( ClothModifierData *clmd, CollisionModi
edgecollpair.p21 = collpair->bp1;
edgecollpair.p22 = collpair->bp2;
}
- else if(i == 4) // cloth edge: 2-3; coll edge: 2-3
+ else if (i == 4) // cloth edge: 2-3; coll edge: 2-3
{
edgecollpair.p11 = collpair->ap2;
edgecollpair.p12 = collpair->ap3;
@@ -1964,7 +1966,7 @@ static int cloth_collision_moving_edges ( ClothModifierData *clmd, CollisionModi
edgecollpair.p21 = collpair->bp2;
edgecollpair.p22 = collpair->bp3;
}
- else if(i == 5) // cloth edge: 2-3; coll edge: 1-3
+ else if (i == 5) // cloth edge: 2-3; coll edge: 1-3
{
edgecollpair.p11 = collpair->ap2;
edgecollpair.p12 = collpair->ap3;
@@ -1972,7 +1974,7 @@ static int cloth_collision_moving_edges ( ClothModifierData *clmd, CollisionModi
edgecollpair.p21 = collpair->bp1;
edgecollpair.p22 = collpair->bp3;
}
- else if(i ==6) // cloth edge: 1-3; coll edge: 1-2
+ else if (i ==6) // cloth edge: 1-3; coll edge: 1-2
{
edgecollpair.p11 = collpair->ap1;
edgecollpair.p12 = collpair->ap3;
@@ -1980,7 +1982,7 @@ static int cloth_collision_moving_edges ( ClothModifierData *clmd, CollisionModi
edgecollpair.p21 = collpair->bp1;
edgecollpair.p22 = collpair->bp2;
}
- else if(i ==7) // cloth edge: 1-3; coll edge: 2-3
+ else if (i ==7) // cloth edge: 1-3; coll edge: 2-3
{
edgecollpair.p11 = collpair->ap1;
edgecollpair.p12 = collpair->ap3;
@@ -1988,7 +1990,7 @@ static int cloth_collision_moving_edges ( ClothModifierData *clmd, CollisionModi
edgecollpair.p21 = collpair->bp2;
edgecollpair.p22 = collpair->bp3;
}
- else if(i == 8) // cloth edge: 1-3; coll edge: 1-3
+ else if (i == 8) // cloth edge: 1-3; coll edge: 1-3
{
edgecollpair.p11 = collpair->ap1;
edgecollpair.p12 = collpair->ap3;
@@ -1997,9 +1999,9 @@ static int cloth_collision_moving_edges ( ClothModifierData *clmd, CollisionModi
edgecollpair.p22 = collpair->bp3;
}
/*
- if((edgecollpair.p11 == 3) && (edgecollpair.p12 == 16))
+ if ((edgecollpair.p11 == 3) && (edgecollpair.p12 == 16))
printf("Ahier!\n");
- if((edgecollpair.p11 == 16) && (edgecollpair.p12 == 3))
+ if ((edgecollpair.p11 == 16) && (edgecollpair.p12 == 3))
printf("Ahier!\n");
*/
@@ -2017,9 +2019,9 @@ static int cloth_collision_moving_edges ( ClothModifierData *clmd, CollisionModi
numsolutions = cloth_get_collision_time ( x1, v1, x2, v2, x3, v3, solution );
- if((edgecollpair.p11 == 3 && edgecollpair.p12==16)|| (edgecollpair.p11==16 && edgecollpair.p12==3))
+ if ((edgecollpair.p11 == 3 && edgecollpair.p12==16)|| (edgecollpair.p11==16 && edgecollpair.p12==3))
{
- if(edgecollpair.p21==6 || edgecollpair.p22 == 6)
+ if (edgecollpair.p21==6 || edgecollpair.p22 == 6)
{
printf("dist: %f, sol[k]: %f, sol2[k]: %f\n", distance, solution[k], solution2[k]);
printf("a1: %f, a2: %f, b1: %f, b2: %f\n", x1[0], x2[0], x3[0], v1[0]);
@@ -2071,7 +2073,7 @@ static int cloth_collision_moving_edges ( ClothModifierData *clmd, CollisionModi
out_normalVelocity = dot_v3v3(vrel_1_to_2, out_normal);
/*
// this correction results in wrong normals sometimes?
- if(out_normalVelocity < 0.0)
+ if (out_normalVelocity < 0.0)
{
out_normalVelocity*= -1.0;
negate_v3(out_normal);
@@ -2135,16 +2137,16 @@ static void add_collision_object(Object ***objs, unsigned int *numobj, unsigned
{
CollisionModifierData *cmd= NULL;
- if(ob == self)
+ if (ob == self)
return;
/* only get objects with collision modifier */
- if(((modifier_type == eModifierType_Collision) && ob->pd && ob->pd->deflect) || (modifier_type != eModifierType_Collision))
+ if (((modifier_type == eModifierType_Collision) && ob->pd && ob->pd->deflect) || (modifier_type != eModifierType_Collision))
cmd= (CollisionModifierData *)modifiers_findByType(ob, modifier_type);
- if(cmd) {
+ if (cmd) {
/* extend array */
- if(*numobj >= *maxobj) {
+ if (*numobj >= *maxobj) {
*maxobj *= 2;
*objs= MEM_reallocN(*objs, sizeof(Object*)*(*maxobj));
}
@@ -2154,12 +2156,12 @@ static void add_collision_object(Object ***objs, unsigned int *numobj, unsigned
}
/* objects in dupli groups, one level only for now */
- if(ob->dup_group && level == 0) {
+ if (ob->dup_group && level == 0) {
GroupObject *go;
Group *group= ob->dup_group;
/* add objects */
- for(go= group->gobject.first; go; go= go->next)
+ for (go= group->gobject.first; go; go= go->next)
add_collision_object(objs, numobj, maxobj, go->ob, self, level+1, modifier_type);
}
}
@@ -2176,16 +2178,16 @@ Object **get_collisionobjects(Scene *scene, Object *self, Group *group, unsigned
objs= MEM_callocN(sizeof(Object *)*maxobj, "CollisionObjectsArray");
/* gather all collision objects */
- if(group) {
+ if (group) {
/* use specified group */
- for(go= group->gobject.first; go; go= go->next)
+ for (go= group->gobject.first; go; go= go->next)
add_collision_object(&objs, &numobj, &maxobj, go->ob, self, 0, modifier_type);
}
else {
Scene *sce_iter;
/* add objects in same layer in scene */
- for(SETLOOPER(scene, sce_iter, base)) {
- if(base->lay & self->lay)
+ for (SETLOOPER(scene, sce_iter, base)) {
+ if (base->lay & self->lay)
add_collision_object(&objs, &numobj, &maxobj, base->object, self, 0, modifier_type);
}
@@ -2201,14 +2203,14 @@ static void add_collider_cache_object(ListBase **objs, Object *ob, Object *self,
CollisionModifierData *cmd= NULL;
ColliderCache *col;
- if(ob == self)
+ if (ob == self)
return;
- if(ob->pd && ob->pd->deflect)
+ if (ob->pd && ob->pd->deflect)
cmd =(CollisionModifierData *)modifiers_findByType(ob, eModifierType_Collision);
- if(cmd && cmd->bvhtree) {
- if(*objs == NULL)
+ if (cmd && cmd->bvhtree) {
+ if (*objs == NULL)
*objs = MEM_callocN(sizeof(ListBase), "ColliderCache array");
col = MEM_callocN(sizeof(ColliderCache), "ColliderCache");
@@ -2220,12 +2222,12 @@ static void add_collider_cache_object(ListBase **objs, Object *ob, Object *self,
}
/* objects in dupli groups, one level only for now */
- if(ob->dup_group && level == 0) {
+ if (ob->dup_group && level == 0) {
GroupObject *go;
Group *group= ob->dup_group;
/* add objects */
- for(go= group->gobject.first; go; go= go->next)
+ for (go= group->gobject.first; go; go= go->next)
add_collider_cache_object(objs, go->ob, self, level+1);
}
}
@@ -2236,8 +2238,8 @@ ListBase *get_collider_cache(Scene *scene, Object *self, Group *group)
ListBase *objs= NULL;
/* add object in same layer in scene */
- if(group) {
- for(go= group->gobject.first; go; go= go->next)
+ if (group) {
+ for (go= group->gobject.first; go; go= go->next)
add_collider_cache_object(&objs, go->ob, self, 0);
}
else {
@@ -2245,8 +2247,8 @@ ListBase *get_collider_cache(Scene *scene, Object *self, Group *group)
Base *base;
/* add objects in same layer in scene */
- for(SETLOOPER(scene, sce_iter, base)) {
- if(!self || (base->lay & self->lay))
+ for (SETLOOPER(scene, sce_iter, base)) {
+ if (!self || (base->lay & self->lay))
add_collider_cache_object(&objs, base->object, self, 0);
}
@@ -2257,7 +2259,7 @@ ListBase *get_collider_cache(Scene *scene, Object *self, Group *group)
void free_collider_cache(ListBase **colliders)
{
- if(*colliders) {
+ if (*colliders) {
BLI_freelistN(*colliders);
MEM_freeN(*colliders);
*colliders = NULL;
@@ -2387,7 +2389,7 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl
collobjs = get_collisionobjects(clmd->scene, ob, clmd->coll_parms->group, &numcollobj, eModifierType_Collision);
- if(!collobjs)
+ if (!collobjs)
return 0;
do
@@ -2400,14 +2402,14 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl
collisions_index = MEM_callocN(sizeof(CollPair *) *numcollobj , "CollPair");
// check all collision objects
- for(i = 0; i < numcollobj; i++)
+ for (i = 0; i < numcollobj; i++)
{
Object *collob= collobjs[i];
CollisionModifierData *collmd = (CollisionModifierData*)modifiers_findByType(collob, eModifierType_Collision);
BVHTreeOverlap *overlap = NULL;
unsigned int result = 0;
- if(!collmd->bvhtree)
+ if (!collmd->bvhtree)
continue;
/* move object to position (step) in time */
@@ -2418,7 +2420,7 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl
overlap = BLI_bvhtree_overlap ( cloth_bvh, collmd->bvhtree, &result );
// go to next object if no overlap is there
- if( result && overlap ) {
+ if ( result && overlap ) {
/* check if collisions really happen (costly near check) */
cloth_bvh_objcollisions_nearcheck ( clmd, collmd, &collisions[i],
&collisions_index[i], result, overlap, dt/(float)clmd->coll_parms->loop_count);
@@ -2433,7 +2435,7 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl
}
rounds++;
- for(i = 0; i < numcollobj; i++)
+ for (i = 0; i < numcollobj; i++)
{
if ( collisions[i] ) MEM_freeN ( collisions[i] );
}
@@ -2467,7 +2469,7 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl
////////////////////////////////////////////////////////////
if ( clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_SELF )
{
- for(l = 0; l < (unsigned int)clmd->coll_parms->self_loop_count; l++)
+ for (l = 0; l < (unsigned int)clmd->coll_parms->self_loop_count; l++)
{
// TODO: add coll quality rounds again
BVHTreeOverlap *overlap = NULL;
@@ -2573,7 +2575,7 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl
}
while ( ret2 && ( clmd->coll_parms->loop_count>rounds ) );
- if(collobjs)
+ if (collobjs)
MEM_freeN(collobjs);
return 1|MIN2 ( ret, 1 );
diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c
index 4f288594dc9..8ec3ad567a2 100644
--- a/source/blender/blenkernel/intern/colortools.c
+++ b/source/blender/blenkernel/intern/colortools.c
@@ -64,7 +64,7 @@ CurveMapping *curvemapping_add(int tot, float minx, float miny, float maxx, floa
cumap= MEM_callocN(sizeof(CurveMapping), "new curvemap");
cumap->flag= CUMA_DO_CLIP;
- if(tot==4) cumap->cur= 3; /* rhms, hack for 'col' curve? */
+ if (tot==4) cumap->cur= 3; /* rhms, hack for 'col' curve? */
clipminx = MIN2(minx, maxx);
clipminy = MIN2(miny, maxy);
@@ -77,7 +77,7 @@ CurveMapping *curvemapping_add(int tot, float minx, float miny, float maxx, floa
cumap->white[0]= cumap->white[1]= cumap->white[2]= 1.0f;
cumap->bwmul[0]= cumap->bwmul[1]= cumap->bwmul[2]= 1.0f;
- for(a=0; a<tot; a++) {
+ for (a=0; a<tot; a++) {
cumap->cm[a].flag= CUMA_EXTEND_EXTRAPOLATE;
cumap->cm[a].totpoint= 2;
cumap->cm[a].curve= MEM_callocN(2*sizeof(CurveMapPoint), "curve points");
@@ -97,11 +97,11 @@ void curvemapping_free(CurveMapping *cumap)
{
int a;
- if(cumap) {
- for(a=0; a<CM_TOT; a++) {
- if(cumap->cm[a].curve) MEM_freeN(cumap->cm[a].curve);
- if(cumap->cm[a].table) MEM_freeN(cumap->cm[a].table);
- if(cumap->cm[a].premultable) MEM_freeN(cumap->cm[a].premultable);
+ if (cumap) {
+ for (a=0; a<CM_TOT; a++) {
+ if (cumap->cm[a].curve) MEM_freeN(cumap->cm[a].curve);
+ if (cumap->cm[a].table) MEM_freeN(cumap->cm[a].table);
+ if (cumap->cm[a].premultable) MEM_freeN(cumap->cm[a].premultable);
}
MEM_freeN(cumap);
}
@@ -111,14 +111,14 @@ CurveMapping *curvemapping_copy(CurveMapping *cumap)
{
int a;
- if(cumap) {
+ if (cumap) {
CurveMapping *cumapn= MEM_dupallocN(cumap);
- for(a=0; a<CM_TOT; a++) {
- if(cumap->cm[a].curve)
+ for (a=0; a<CM_TOT; a++) {
+ if (cumap->cm[a].curve)
cumapn->cm[a].curve= MEM_dupallocN(cumap->cm[a].curve);
- if(cumap->cm[a].table)
+ if (cumap->cm[a].table)
cumapn->cm[a].table= MEM_dupallocN(cumap->cm[a].table);
- if(cumap->cm[a].premultable)
+ if (cumap->cm[a].premultable)
cumapn->cm[a].premultable= MEM_dupallocN(cumap->cm[a].premultable);
}
return cumapn;
@@ -130,13 +130,13 @@ void curvemapping_set_black_white(CurveMapping *cumap, const float black[3], con
{
int a;
- if(white)
+ if (white)
copy_v3_v3(cumap->white, white);
- if(black)
+ if (black)
copy_v3_v3(cumap->black, black);
- for(a=0; a<3; a++) {
- if(cumap->white[a]==cumap->black[a])
+ for (a=0; a<3; a++) {
+ if (cumap->white[a]==cumap->black[a])
cumap->bwmul[a]= 0.0f;
else
cumap->bwmul[a]= 1.0f/(cumap->white[a] - cumap->black[a]);
@@ -154,8 +154,8 @@ void curvemap_remove(CurveMap *cuma, int flag)
/* well, lets keep the two outer points! */
cmp[0]= cuma->curve[0];
- for(a=1, b=1; a<cuma->totpoint-1; a++) {
- if(!(cuma->curve[a].flag & flag)) {
+ for (a=1, b=1; a<cuma->totpoint-1; a++) {
+ if (!(cuma->curve[a].flag & flag)) {
cmp[b]= cuma->curve[a];
b++;
}
@@ -175,8 +175,8 @@ void curvemap_insert(CurveMap *cuma, float x, float y)
/* insert fragments of the old one and the new point to the new curve */
cuma->totpoint++;
- for(a=0, b=0; a<cuma->totpoint; a++) {
- if((x < cuma->curve[a].x) && !foundloc) {
+ for (a=0, b=0; a<cuma->totpoint; a++) {
+ if ((x < cuma->curve[a].x) && !foundloc) {
cmp[a].x= x;
cmp[a].y= y;
cmp[a].flag= CUMA_SELECT;
@@ -199,7 +199,7 @@ void curvemap_insert(CurveMap *cuma, float x, float y)
void curvemap_reset(CurveMap *cuma, rctf *clipr, int preset, int slope)
{
- if(cuma->curve)
+ if (cuma->curve)
MEM_freeN(cuma->curve);
switch(preset) {
@@ -295,7 +295,7 @@ void curvemap_reset(CurveMap *cuma, rctf *clipr, int preset, int slope)
cuma->curve = newpoints;
}
- if(cuma->table) {
+ if (cuma->table) {
MEM_freeN(cuma->table);
cuma->table= NULL;
}
@@ -306,9 +306,9 @@ void curvemap_sethandle(CurveMap *cuma, int type)
{
int a;
- for(a=0; a<cuma->totpoint; a++) {
- if(cuma->curve[a].flag & CUMA_SELECT) {
- if(type) cuma->curve[a].flag |= CUMA_VECTOR;
+ for (a=0; a<cuma->totpoint; a++) {
+ if (cuma->curve[a].flag & CUMA_SELECT) {
+ if (type) cuma->curve[a].flag |= CUMA_VECTOR;
else cuma->curve[a].flag &= ~CUMA_VECTOR;
}
}
@@ -323,13 +323,13 @@ static void calchandle_curvemap(BezTriple *bezt, BezTriple *prev, BezTriple *nex
float len,len_a, len_b;
float dvec_a[2], dvec_b[2];
- if(bezt->h1==0 && bezt->h2==0) {
+ if (bezt->h1==0 && bezt->h2==0) {
return;
}
p2= bezt->vec[1];
- if(prev==NULL) {
+ if (prev==NULL) {
p3= next->vec[1];
pt[0]= 2.0f*p2[0] - p3[0];
pt[1]= 2.0f*p2[1] - p3[1];
@@ -339,7 +339,7 @@ static void calchandle_curvemap(BezTriple *bezt, BezTriple *prev, BezTriple *nex
p1= prev->vec[1];
}
- if(next==NULL) {
+ if (next==NULL) {
p1= prev->vec[1];
pt[0]= 2.0f*p2[0] - p1[0];
pt[1]= 2.0f*p2[1] - p1[1];
@@ -355,32 +355,32 @@ static void calchandle_curvemap(BezTriple *bezt, BezTriple *prev, BezTriple *nex
len_a= len_v2(dvec_a);
len_b= len_v2(dvec_b);
- if(len_a==0.0f) len_a=1.0f;
- if(len_b==0.0f) len_b=1.0f;
+ if (len_a==0.0f) len_a=1.0f;
+ if (len_b==0.0f) len_b=1.0f;
- if(bezt->h1==HD_AUTO || bezt->h2==HD_AUTO) { /* auto */
+ if (bezt->h1==HD_AUTO || bezt->h2==HD_AUTO) { /* auto */
float tvec[2];
tvec[0]= dvec_b[0]/len_b + dvec_a[0]/len_a;
tvec[1]= dvec_b[1]/len_b + dvec_a[1]/len_a;
len= len_v2(tvec) * 2.5614f;
- if(len!=0.0f) {
+ if (len!=0.0f) {
- if(bezt->h1==HD_AUTO) {
+ if (bezt->h1==HD_AUTO) {
len_a/=len;
madd_v2_v2v2fl(p2-3, p2, tvec, -len_a);
}
- if(bezt->h2==HD_AUTO) {
+ if (bezt->h2==HD_AUTO) {
len_b/=len;
madd_v2_v2v2fl(p2+3, p2, tvec, len_b);
}
}
}
- if(bezt->h1==HD_VECT) { /* vector */
+ if (bezt->h1==HD_VECT) { /* vector */
madd_v2_v2v2fl(p2-3, p2, dvec_a, -1.0f/3.0f);
}
- if(bezt->h2==HD_VECT) {
+ if (bezt->h2==HD_VECT) {
madd_v2_v2v2fl(p2+3, p2, dvec_b, 1.0f/3.0f);
}
}
@@ -389,25 +389,25 @@ static void calchandle_curvemap(BezTriple *bezt, BezTriple *prev, BezTriple *nex
* X is presumed to be outside first or last */
static float curvemap_calc_extend(CurveMap *cuma, float x, const float first[2], const float last[2])
{
- if(x <= first[0]) {
- if((cuma->flag & CUMA_EXTEND_EXTRAPOLATE)==0) {
+ if (x <= first[0]) {
+ if ((cuma->flag & CUMA_EXTEND_EXTRAPOLATE)==0) {
/* no extrapolate */
return first[1];
}
else {
- if(cuma->ext_in[0]==0.0f)
+ if (cuma->ext_in[0]==0.0f)
return first[1] + cuma->ext_in[1]*10000.0f;
else
return first[1] + cuma->ext_in[1]*(x - first[0])/cuma->ext_in[0];
}
}
- else if(x >= last[0]) {
- if((cuma->flag & CUMA_EXTEND_EXTRAPOLATE)==0) {
+ else if (x >= last[0]) {
+ if ((cuma->flag & CUMA_EXTEND_EXTRAPOLATE)==0) {
/* no extrapolate */
return last[1];
}
else {
- if(cuma->ext_out[0]==0.0f)
+ if (cuma->ext_out[0]==0.0f)
return last[1] - cuma->ext_out[1]*10000.0f;
else
return last[1] + cuma->ext_out[1]*(x - last[0])/cuma->ext_out[0];
@@ -424,7 +424,7 @@ static void curvemap_make_table(CurveMap *cuma, rctf *clipr)
float *fp, *allpoints, *lastpoint, curf, range;
int a, totpoint;
- if(cuma->curve==NULL) return;
+ if (cuma->curve==NULL) return;
/* default rect also is table range */
cuma->mintable= clipr->xmin;
@@ -433,21 +433,21 @@ static void curvemap_make_table(CurveMap *cuma, rctf *clipr)
/* hrmf... we now rely on blender ipo beziers, these are more advanced */
bezt= MEM_callocN(cuma->totpoint*sizeof(BezTriple), "beztarr");
- for(a=0; a<cuma->totpoint; a++) {
+ for (a=0; a<cuma->totpoint; a++) {
cuma->mintable= MIN2(cuma->mintable, cmp[a].x);
cuma->maxtable= MAX2(cuma->maxtable, cmp[a].x);
bezt[a].vec[1][0]= cmp[a].x;
bezt[a].vec[1][1]= cmp[a].y;
- if(cmp[a].flag & CUMA_VECTOR)
+ if (cmp[a].flag & CUMA_VECTOR)
bezt[a].h1= bezt[a].h2= HD_VECT;
else
bezt[a].h1= bezt[a].h2= HD_AUTO;
}
- for(a=0; a<cuma->totpoint; a++) {
- if(a==0)
+ for (a=0; a<cuma->totpoint; a++) {
+ if (a==0)
calchandle_curvemap(bezt, NULL, bezt+1, 0);
- else if(a==cuma->totpoint-1)
+ else if (a==cuma->totpoint-1)
calchandle_curvemap(bezt+a, bezt+a-1, NULL, 0);
else
calchandle_curvemap(bezt+a, bezt+a-1, bezt+a+1, 0);
@@ -455,37 +455,37 @@ static void curvemap_make_table(CurveMap *cuma, rctf *clipr)
/* first and last handle need correction, instead of pointing to center of next/prev,
* we let it point to the closest handle */
- if(cuma->totpoint>2) {
+ if (cuma->totpoint>2) {
float hlen, nlen, vec[3];
- if(bezt[0].h2==HD_AUTO) {
+ if (bezt[0].h2==HD_AUTO) {
hlen= len_v3v3(bezt[0].vec[1], bezt[0].vec[2]); /* original handle length */
/* clip handle point */
copy_v3_v3(vec, bezt[1].vec[0]);
- if(vec[0] < bezt[0].vec[1][0])
+ if (vec[0] < bezt[0].vec[1][0])
vec[0]= bezt[0].vec[1][0];
sub_v3_v3(vec, bezt[0].vec[1]);
nlen= len_v3(vec);
- if(nlen>FLT_EPSILON) {
+ if (nlen>FLT_EPSILON) {
mul_v3_fl(vec, hlen/nlen);
add_v3_v3v3(bezt[0].vec[2], vec, bezt[0].vec[1]);
sub_v3_v3v3(bezt[0].vec[0], bezt[0].vec[1], vec);
}
}
a= cuma->totpoint-1;
- if(bezt[a].h2==HD_AUTO) {
+ if (bezt[a].h2==HD_AUTO) {
hlen= len_v3v3(bezt[a].vec[1], bezt[a].vec[0]); /* original handle length */
/* clip handle point */
copy_v3_v3(vec, bezt[a-1].vec[2]);
- if(vec[0] > bezt[a].vec[1][0])
+ if (vec[0] > bezt[a].vec[1][0])
vec[0]= bezt[a].vec[1][0];
sub_v3_v3(vec, bezt[a].vec[1]);
nlen= len_v3(vec);
- if(nlen>FLT_EPSILON) {
+ if (nlen>FLT_EPSILON) {
mul_v3_fl(vec, hlen/nlen);
add_v3_v3v3(bezt[a].vec[0], vec, bezt[a].vec[1]);
sub_v3_v3v3(bezt[a].vec[2], bezt[a].vec[1], vec);
@@ -493,12 +493,12 @@ static void curvemap_make_table(CurveMap *cuma, rctf *clipr)
}
}
/* make the bezier curve */
- if(cuma->table)
+ if (cuma->table)
MEM_freeN(cuma->table);
totpoint= (cuma->totpoint-1)*CM_RESOL;
fp= allpoints= MEM_callocN(totpoint*2*sizeof(float), "table");
- for(a=0; a<cuma->totpoint-1; a++, fp += 2*CM_RESOL) {
+ for (a=0; a<cuma->totpoint-1; a++, fp += 2*CM_RESOL) {
correct_bezpart(bezt[a].vec[1], bezt[a].vec[2], bezt[a+1].vec[0], bezt[a+1].vec[1]);
forward_diff_bezier(bezt[a].vec[1][0], bezt[a].vec[2][0], bezt[a+1].vec[0][0], bezt[a+1].vec[1][0], fp, CM_RESOL-1, 2*sizeof(float));
forward_diff_bezier(bezt[a].vec[1][1], bezt[a].vec[2][1], bezt[a+1].vec[0][1], bezt[a+1].vec[1][1], fp+1, CM_RESOL-1, 2*sizeof(float));
@@ -529,20 +529,20 @@ static void curvemap_make_table(CurveMap *cuma, rctf *clipr)
lastpoint= allpoints + 2*(totpoint-1);
cmp= MEM_callocN((CM_TABLE+1)*sizeof(CurveMapPoint), "dist table");
- for(a=0; a<=CM_TABLE; a++) {
+ for (a=0; a<=CM_TABLE; a++) {
curf= cuma->mintable + range*(float)a;
cmp[a].x= curf;
/* get the first x coordinate larger than curf */
- while(curf >= fp[0] && fp!=lastpoint) {
+ while (curf >= fp[0] && fp!=lastpoint) {
fp+=2;
}
- if(fp==allpoints || (curf >= fp[0] && fp==lastpoint))
+ if (fp==allpoints || (curf >= fp[0] && fp==lastpoint))
cmp[a].y= curvemap_calc_extend(cuma, curf, allpoints, lastpoint);
else {
float fac1= fp[0] - fp[-2];
float fac2= fp[0] - curf;
- if(fac1 > FLT_EPSILON)
+ if (fac1 > FLT_EPSILON)
fac1= fac2/fac1;
else
fac1= 0.0f;
@@ -560,9 +560,9 @@ void curvemapping_premultiply(CurveMapping *cumap, int restore)
{
int a;
- if(restore) {
- if(cumap->flag & CUMA_PREMULLED) {
- for(a=0; a<3; a++) {
+ if (restore) {
+ if (cumap->flag & CUMA_PREMULLED) {
+ for (a=0; a<3; a++) {
MEM_freeN(cumap->cm[a].table);
cumap->cm[a].table= cumap->cm[a].premultable;
cumap->cm[a].premultable= NULL;
@@ -572,23 +572,23 @@ void curvemapping_premultiply(CurveMapping *cumap, int restore)
}
}
else {
- if((cumap->flag & CUMA_PREMULLED)==0) {
+ if ((cumap->flag & CUMA_PREMULLED)==0) {
/* verify and copy */
- for(a=0; a<3; a++) {
- if(cumap->cm[a].table==NULL)
+ for (a=0; a<3; a++) {
+ if (cumap->cm[a].table==NULL)
curvemap_make_table(cumap->cm+a, &cumap->clipr);
cumap->cm[a].premultable= cumap->cm[a].table;
cumap->cm[a].table= MEM_mallocN((CM_TABLE+1)*sizeof(CurveMapPoint), "premul table");
memcpy(cumap->cm[a].table, cumap->cm[a].premultable, (CM_TABLE+1)*sizeof(CurveMapPoint));
}
- if(cumap->cm[3].table==NULL)
+ if (cumap->cm[3].table==NULL)
curvemap_make_table(cumap->cm+3, &cumap->clipr);
/* premul */
- for(a=0; a<3; a++) {
+ for (a=0; a<3; a++) {
int b;
- for(b=0; b<=CM_TABLE; b++) {
+ for (b=0; b<=CM_TABLE; b++) {
cumap->cm[a].table[b].y= curvemap_evaluateF(cumap->cm+3, cumap->cm[a].table[b].y);
}
}
@@ -602,8 +602,8 @@ static int sort_curvepoints(const void *a1, const void *a2)
{
const struct CurveMapPoint *x1=a1, *x2=a2;
- if( x1->x > x2->x ) return 1;
- else if( x1->x < x2->x) return -1;
+ if ( x1->x > x2->x ) return 1;
+ else if ( x1->x < x2->x) return -1;
return 0;
}
@@ -622,21 +622,21 @@ void curvemapping_changed(CurveMapping *cumap, int rem_doubles)
cumap->changed_timestamp++;
/* clamp with clip */
- if(cumap->flag & CUMA_DO_CLIP) {
- for(a=0; a<cuma->totpoint; a++) {
- if(cmp[a].flag & CUMA_SELECT) {
- if(cmp[a].x < clipr->xmin)
+ if (cumap->flag & CUMA_DO_CLIP) {
+ for (a=0; a<cuma->totpoint; a++) {
+ if (cmp[a].flag & CUMA_SELECT) {
+ if (cmp[a].x < clipr->xmin)
dx= MIN2(dx, cmp[a].x - clipr->xmin);
- else if(cmp[a].x > clipr->xmax)
+ else if (cmp[a].x > clipr->xmax)
dx= MAX2(dx, cmp[a].x - clipr->xmax);
- if(cmp[a].y < clipr->ymin)
+ if (cmp[a].y < clipr->ymin)
dy= MIN2(dy, cmp[a].y - clipr->ymin);
- else if(cmp[a].y > clipr->ymax)
+ else if (cmp[a].y > clipr->ymax)
dy= MAX2(dy, cmp[a].y - clipr->ymax);
}
}
- for(a=0; a<cuma->totpoint; a++) {
- if(cmp[a].flag & CUMA_SELECT) {
+ for (a=0; a<cuma->totpoint; a++) {
+ if (cmp[a].flag & CUMA_SELECT) {
cmp[a].x -= dx;
cmp[a].y -= dy;
}
@@ -647,25 +647,25 @@ void curvemapping_changed(CurveMapping *cumap, int rem_doubles)
qsort(cmp, cuma->totpoint, sizeof(CurveMapPoint), sort_curvepoints);
/* remove doubles, threshold set on 1% of default range */
- if(rem_doubles && cuma->totpoint>2) {
- for(a=0; a<cuma->totpoint-1; a++) {
+ if (rem_doubles && cuma->totpoint>2) {
+ for (a=0; a<cuma->totpoint-1; a++) {
dx= cmp[a].x - cmp[a+1].x;
dy= cmp[a].y - cmp[a+1].y;
- if( sqrtf(dx*dx + dy*dy) < thresh ) {
- if(a==0) {
+ if ( sqrtf(dx*dx + dy*dy) < thresh ) {
+ if (a==0) {
cmp[a+1].flag|= 2;
- if(cmp[a+1].flag & CUMA_SELECT)
+ if (cmp[a+1].flag & CUMA_SELECT)
cmp[a].flag |= CUMA_SELECT;
}
else {
cmp[a].flag|= 2;
- if(cmp[a].flag & CUMA_SELECT)
+ if (cmp[a].flag & CUMA_SELECT)
cmp[a+1].flag |= CUMA_SELECT;
}
break; /* we assume 1 deletion per edit is ok */
}
}
- if(a != cuma->totpoint-1)
+ if (a != cuma->totpoint-1)
curvemap_remove(cuma, 2);
}
curvemap_make_table(cuma, clipr);
@@ -682,11 +682,11 @@ float curvemap_evaluateF(CurveMap *cuma, float value)
i= (int)fi;
/* fi is table float index and should check against table range i.e. [0.0 CM_TABLE] */
- if(fi<0.0f || fi>CM_TABLE)
+ if (fi<0.0f || fi>CM_TABLE)
return curvemap_calc_extend(cuma, value, &cuma->table[0].x, &cuma->table[CM_TABLE].x);
else {
- if(i<0) return cuma->table[0].y;
- if(i>=CM_TABLE) return cuma->table[CM_TABLE].y;
+ if (i<0) return cuma->table[0].y;
+ if (i>=CM_TABLE) return cuma->table[CM_TABLE].y;
fi= fi-(float)i;
return (1.0f-fi)*cuma->table[i].y + (fi)*cuma->table[i+1].y;
@@ -699,9 +699,9 @@ float curvemapping_evaluateF(CurveMapping *cumap, int cur, float value)
CurveMap *cuma= cumap->cm+cur;
/* allocate or bail out */
- if(cuma->table==NULL) {
+ if (cuma->table==NULL) {
curvemap_make_table(cuma, &cumap->clipr);
- if(cuma->table==NULL)
+ if (cuma->table==NULL)
return 1.0f-value;
}
return curvemap_evaluateF(cuma, value);
@@ -750,11 +750,11 @@ void curvemapping_do_ibuf(CurveMapping *cumap, ImBuf *ibuf)
int stride= 4;
float *pix_out;
- if(ibuf==NULL)
+ if (ibuf==NULL)
return;
- if(ibuf->rect_float==NULL)
+ if (ibuf->rect_float==NULL)
IMB_float_from_rect(ibuf);
- else if(ibuf->rect==NULL)
+ else if (ibuf->rect==NULL)
imb_addrectImBuf(ibuf);
if (!ibuf->rect || !ibuf->rect_float)
@@ -769,11 +769,11 @@ void curvemapping_do_ibuf(CurveMapping *cumap, ImBuf *ibuf)
pix_in= ibuf->rect_float;
pix_out= tmpbuf->rect_float;
- if(ibuf->channels)
+ if (ibuf->channels)
stride= ibuf->channels;
- for(pixel= ibuf->x*ibuf->y; pixel>0; pixel--, pix_in+=stride, pix_out+=stride) {
- if(stride<3) {
+ for (pixel= ibuf->x*ibuf->y; pixel>0; pixel--, pix_in+=stride, pix_out+=stride) {
+ if (stride<3) {
col[0]= curvemap_evaluateF(cumap->cm, *pix_in);
pix_out[1]= pix_out[2]= pix_out[3]= pix_out[0]= col[0];
@@ -783,7 +783,7 @@ void curvemapping_do_ibuf(CurveMapping *cumap, ImBuf *ibuf)
pix_out[0]= col[0];
pix_out[1]= col[1];
pix_out[2]= col[2];
- if(stride>3)
+ if (stride>3)
pix_out[3]= pix_in[3];
else
pix_out[3]= 1.f;
@@ -801,21 +801,21 @@ int curvemapping_RGBA_does_something(CurveMapping *cumap)
{
int a;
- if(cumap->black[0]!=0.0f) return 1;
- if(cumap->black[1]!=0.0f) return 1;
- if(cumap->black[2]!=0.0f) return 1;
- if(cumap->white[0]!=1.0f) return 1;
- if(cumap->white[1]!=1.0f) return 1;
- if(cumap->white[2]!=1.0f) return 1;
+ if (cumap->black[0]!=0.0f) return 1;
+ if (cumap->black[1]!=0.0f) return 1;
+ if (cumap->black[2]!=0.0f) return 1;
+ if (cumap->white[0]!=1.0f) return 1;
+ if (cumap->white[1]!=1.0f) return 1;
+ if (cumap->white[2]!=1.0f) return 1;
- for(a=0; a<CM_TOT; a++) {
- if(cumap->cm[a].curve) {
- if(cumap->cm[a].totpoint!=2) return 1;
+ for (a=0; a<CM_TOT; a++) {
+ if (cumap->cm[a].curve) {
+ if (cumap->cm[a].totpoint!=2) return 1;
- if(cumap->cm[a].curve[0].x != 0.0f) return 1;
- if(cumap->cm[a].curve[0].y != 0.0f) return 1;
- if(cumap->cm[a].curve[1].x != 1.0f) return 1;
- if(cumap->cm[a].curve[1].y != 1.0f) return 1;
+ if (cumap->cm[a].curve[0].x != 0.0f) return 1;
+ if (cumap->cm[a].curve[0].y != 0.0f) return 1;
+ if (cumap->cm[a].curve[1].x != 1.0f) return 1;
+ if (cumap->cm[a].curve[1].y != 1.0f) return 1;
}
}
return 0;
@@ -825,10 +825,10 @@ void curvemapping_initialize(CurveMapping *cumap)
{
int a;
- if(cumap==NULL) return;
+ if (cumap==NULL) return;
- for(a=0; a<CM_TOT; a++) {
- if(cumap->cm[a].table==NULL)
+ for (a=0; a<CM_TOT; a++) {
+ if (cumap->cm[a].table==NULL)
curvemap_make_table(cumap->cm+a, &cumap->clipr);
}
}
@@ -841,14 +841,14 @@ void curvemapping_table_RGBA(CurveMapping *cumap, float **array, int *size)
*array = MEM_callocN(sizeof(float)*(*size)*4, "CurveMapping");
curvemapping_initialize(cumap);
- for(a=0; a<*size; a++) {
- if(cumap->cm[0].table)
+ for (a=0; a<*size; a++) {
+ if (cumap->cm[0].table)
(*array)[a*4+0]= cumap->cm[0].table[a].y;
- if(cumap->cm[1].table)
+ if (cumap->cm[1].table)
(*array)[a*4+1]= cumap->cm[1].table[a].y;
- if(cumap->cm[2].table)
+ if (cumap->cm[2].table)
(*array)[a*4+2]= cumap->cm[2].table[a].y;
- if(cumap->cm[3].table)
+ if (cumap->cm[3].table)
(*array)[a*4+3]= cumap->cm[3].table[a].y;
}
}
@@ -986,8 +986,11 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management)
for (y = 0; y < ibuf->y; y++) {
if (savedlines<scopes->sample_lines && y>=((savedlines)*ibuf->y)/(scopes->sample_lines+1)) {
- saveline=1;
- } else saveline=0;
+ saveline = 1;
+ }
+ else {
+ saveline = 0;
+ }
for (x = 0; x < ibuf->x; x++) {
if (is_float) {
@@ -1005,7 +1008,7 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management)
luma = rgb_to_luma(rgb);
/* check for min max */
- if(ycc_mode == -1 ) {
+ if (ycc_mode == -1 ) {
for (c=0; c<3; c++) {
if (rgb[c] < scopes->minmax[c][0]) scopes->minmax[c][0] = rgb[c];
if (rgb[c] > scopes->minmax[c][1]) scopes->minmax[c][1] = rgb[c];
@@ -1026,7 +1029,7 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management)
bin_lum[ get_bin_float(luma) ] += 1;
/* save sample if needed */
- if(saveline) {
+ if (saveline) {
const float fx = (float)x / (float)ibuf->x;
const int idx = 2*(ibuf->x*savedlines+x);
save_sample_line(scopes, idx, fx, rgb, ycc);
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index dbc1335ebcd..449376a3960 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -490,7 +490,7 @@ static void contarget_get_mesh_mat (Object *ob, const char *substring, float mat
copy_v3_v3(plane, tmat[1]);
cross_v3_v3v3(mat[0], normal, plane);
- if(len_v3(mat[0]) < 1e-3f) {
+ if (len_v3(mat[0]) < 1e-3f) {
copy_v3_v3(plane, tmat[0]);
cross_v3_v3v3(mat[0], normal, plane);
}
@@ -820,7 +820,7 @@ static void childof_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta
float parmat[4][4];
/* simple matrix parenting */
- if(data->flag == CHILDOF_ALL) {
+ if (data->flag == CHILDOF_ALL) {
/* multiply target (parent matrix) by offset (parent inverse) to get
* the effect of the parent that will be exherted on the owner
@@ -3449,7 +3449,7 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr
{
bShrinkwrapConstraint *scon = (bShrinkwrapConstraint *) con->data;
- if( VALID_CONS_TARGET(ct) && (ct->tar->type == OB_MESH) )
+ if ( VALID_CONS_TARGET(ct) && (ct->tar->type == OB_MESH) )
{
int fail = FALSE;
float co[3] = {0.0f, 0.0f, 0.0f};
@@ -3471,7 +3471,7 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr
unit_m4(ct->matrix);
- if(target != NULL)
+ if (target != NULL)
{
space_transform_from_matrixs(&transform, cob->matrix, ct->tar->obmat);
@@ -3480,12 +3480,12 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr
case MOD_SHRINKWRAP_NEAREST_SURFACE:
case MOD_SHRINKWRAP_NEAREST_VERTEX:
- if(scon->shrinkType == MOD_SHRINKWRAP_NEAREST_VERTEX)
+ if (scon->shrinkType == MOD_SHRINKWRAP_NEAREST_VERTEX)
bvhtree_from_mesh_verts(&treeData, target, 0.0, 2, 6);
else
bvhtree_from_mesh_faces(&treeData, target, 0.0, 2, 6);
- if(treeData.tree == NULL)
+ if (treeData.tree == NULL)
{
fail = TRUE;
break;
@@ -3496,16 +3496,16 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr
BLI_bvhtree_find_nearest(treeData.tree, co, &nearest, treeData.nearest_callback, &treeData);
dist = len_v3v3(co, nearest.co);
- if(dist != 0.0f) {
+ if (dist != 0.0f) {
interp_v3_v3v3(co, co, nearest.co, (dist - scon->dist)/dist); /* linear interpolation */
}
space_transform_invert(&transform, co);
break;
case MOD_SHRINKWRAP_PROJECT:
- if(scon->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_X_AXIS) no[0] = 1.0f;
- if(scon->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_Y_AXIS) no[1] = 1.0f;
- if(scon->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_Z_AXIS) no[2] = 1.0f;
+ if (scon->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_X_AXIS) no[0] = 1.0f;
+ if (scon->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_Y_AXIS) no[1] = 1.0f;
+ if (scon->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_Z_AXIS) no[2] = 1.0f;
if (dot_v3v3(no, no) < FLT_EPSILON) {
fail = TRUE;
@@ -3516,13 +3516,13 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr
bvhtree_from_mesh_faces(&treeData, target, scon->dist, 4, 6);
- if(treeData.tree == NULL)
+ if (treeData.tree == NULL)
{
fail = TRUE;
break;
}
- if(normal_projection_project_vertex(0, co, no, &transform, treeData.tree, &hit, treeData.raycast_callback, &treeData) == FALSE)
+ if (normal_projection_project_vertex(0, co, no, &transform, treeData.tree, &hit, treeData.raycast_callback, &treeData) == FALSE)
{
fail = TRUE;
break;
@@ -3892,7 +3892,7 @@ static void pivotcon_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *t
/* correct the pivot by the rotation axis otherwise the pivot translates when it shouldnt */
mat3_to_axis_angle(axis, &angle, rotMat);
- if(angle) {
+ if (angle) {
float dvec[3];
sub_v3_v3v3(vec, pivot, cob->matrix[3]);
project_v3_v3v3(dvec, vec, axis);
@@ -3962,12 +3962,12 @@ static void followtrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase
tracking= &clip->tracking;
- if(data->object[0])
+ if (data->object[0])
tracking_object= BKE_tracking_named_object(tracking, data->object);
else
tracking_object= BKE_tracking_get_camera_object(tracking);
- if(!tracking_object)
+ if (!tracking_object)
return;
track= BKE_tracking_named_track(tracking, tracking_object, data->track);
@@ -3981,7 +3981,7 @@ static void followtrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase
copy_m4_m4(obmat, cob->matrix);
- if((tracking_object->flag&TRACKING_OBJECT_CAMERA)==0) {
+ if ((tracking_object->flag&TRACKING_OBJECT_CAMERA)==0) {
float imat[4][4];
copy_m4_m4(mat, camob->obmat);
@@ -4068,7 +4068,7 @@ static void followtrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase
copy_v3_v3(cob->matrix[3], disp);
}
- if(data->depth_ob && data->depth_ob->derivedFinal) {
+ if (data->depth_ob && data->depth_ob->derivedFinal) {
Object *depth_ob= data->depth_ob;
BVHTreeFromMesh treeData= NULL_BVHTreeFromMesh;
BVHTreeRayHit hit;
@@ -4089,7 +4089,7 @@ static void followtrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase
result= BLI_bvhtree_ray_cast(treeData.tree, ray_start, ray_nor, 0.0f, &hit, treeData.raycast_callback, &treeData);
- if(result != -1) {
+ if (result != -1) {
mul_v3_m4v3(cob->matrix[3], depth_ob->obmat, hit.co);
}
@@ -4199,7 +4199,7 @@ static void objectsolver_evaluate (bConstraint *con, bConstraintOb *cob, ListBas
if (data->flag & OBJECTSOLVER_ACTIVECLIP)
clip= scene->clip;
- if(!camob || !clip)
+ if (!camob || !clip)
return;
if (clip) {
@@ -4208,7 +4208,7 @@ static void objectsolver_evaluate (bConstraint *con, bConstraintOb *cob, ListBas
object= BKE_tracking_named_object(tracking, data->object);
- if(object) {
+ if (object) {
float mat[4][4], obmat[4][4], imat[4][4], cammat[4][4], camimat[4][4], parmat[4][4];
where_is_object_mat(scene, camob, cammat);
@@ -4720,7 +4720,7 @@ void get_constraint_target_matrix (struct Scene *scene, bConstraint *con, int n,
/* only calculate the target matrix on the first target */
ct= (bConstraintTarget *)targets.first;
- while(ct && n-- > 0)
+ while (ct && n-- > 0)
ct= ct->next;
if (ct) {
diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c
index 05c56fa8101..9f3f3a7aeb1 100644
--- a/source/blender/blenkernel/intern/context.c
+++ b/source/blender/blenkernel/intern/context.c
@@ -120,8 +120,8 @@ bContextStore *CTX_store_add(ListBase *contexts, const char *name, PointerRNA *p
* we have to copy the context to ensure */
ctx= contexts->last;
- if(!ctx || ctx->used) {
- if(ctx) {
+ if (!ctx || ctx->used) {
+ if (ctx) {
lastctx= ctx;
ctx= MEM_dupallocN(lastctx);
BLI_duplicatelist(&ctx->entries, &lastctx->entries);
@@ -166,7 +166,7 @@ void CTX_store_free_list(ListBase *contexts)
{
bContextStore *ctx;
- while((ctx= contexts->first)) {
+ while ((ctx= contexts->first)) {
BLI_remlink(contexts, ctx);
CTX_store_free(ctx);
}
@@ -243,127 +243,127 @@ struct ReportList *CTX_wm_reports(const bContext *C)
View3D *CTX_wm_view3d(const bContext *C)
{
- if(C->wm.area && C->wm.area->spacetype==SPACE_VIEW3D)
+ if (C->wm.area && C->wm.area->spacetype==SPACE_VIEW3D)
return C->wm.area->spacedata.first;
return NULL;
}
RegionView3D *CTX_wm_region_view3d(const bContext *C)
{
- if(C->wm.area && C->wm.area->spacetype==SPACE_VIEW3D)
- if(C->wm.region)
+ if (C->wm.area && C->wm.area->spacetype==SPACE_VIEW3D)
+ if (C->wm.region)
return C->wm.region->regiondata;
return NULL;
}
struct SpaceText *CTX_wm_space_text(const bContext *C)
{
- if(C->wm.area && C->wm.area->spacetype==SPACE_TEXT)
+ if (C->wm.area && C->wm.area->spacetype==SPACE_TEXT)
return C->wm.area->spacedata.first;
return NULL;
}
struct SpaceConsole *CTX_wm_space_console(const bContext *C)
{
- if(C->wm.area && C->wm.area->spacetype==SPACE_CONSOLE)
+ if (C->wm.area && C->wm.area->spacetype==SPACE_CONSOLE)
return C->wm.area->spacedata.first;
return NULL;
}
struct SpaceImage *CTX_wm_space_image(const bContext *C)
{
- if(C->wm.area && C->wm.area->spacetype==SPACE_IMAGE)
+ if (C->wm.area && C->wm.area->spacetype==SPACE_IMAGE)
return C->wm.area->spacedata.first;
return NULL;
}
struct SpaceButs *CTX_wm_space_buts(const bContext *C)
{
- if(C->wm.area && C->wm.area->spacetype==SPACE_BUTS)
+ if (C->wm.area && C->wm.area->spacetype==SPACE_BUTS)
return C->wm.area->spacedata.first;
return NULL;
}
struct SpaceFile *CTX_wm_space_file(const bContext *C)
{
- if(C->wm.area && C->wm.area->spacetype==SPACE_FILE)
+ if (C->wm.area && C->wm.area->spacetype==SPACE_FILE)
return C->wm.area->spacedata.first;
return NULL;
}
struct SpaceSeq *CTX_wm_space_seq(const bContext *C)
{
- if(C->wm.area && C->wm.area->spacetype==SPACE_SEQ)
+ if (C->wm.area && C->wm.area->spacetype==SPACE_SEQ)
return C->wm.area->spacedata.first;
return NULL;
}
struct SpaceOops *CTX_wm_space_outliner(const bContext *C)
{
- if(C->wm.area && C->wm.area->spacetype==SPACE_OUTLINER)
+ if (C->wm.area && C->wm.area->spacetype==SPACE_OUTLINER)
return C->wm.area->spacedata.first;
return NULL;
}
struct SpaceNla *CTX_wm_space_nla(const bContext *C)
{
- if(C->wm.area && C->wm.area->spacetype==SPACE_NLA)
+ if (C->wm.area && C->wm.area->spacetype==SPACE_NLA)
return C->wm.area->spacedata.first;
return NULL;
}
struct SpaceTime *CTX_wm_space_time(const bContext *C)
{
- if(C->wm.area && C->wm.area->spacetype==SPACE_TIME)
+ if (C->wm.area && C->wm.area->spacetype==SPACE_TIME)
return C->wm.area->spacedata.first;
return NULL;
}
struct SpaceNode *CTX_wm_space_node(const bContext *C)
{
- if(C->wm.area && C->wm.area->spacetype==SPACE_NODE)
+ if (C->wm.area && C->wm.area->spacetype==SPACE_NODE)
return C->wm.area->spacedata.first;
return NULL;
}
struct SpaceLogic *CTX_wm_space_logic(const bContext *C)
{
- if(C->wm.area && C->wm.area->spacetype==SPACE_LOGIC)
+ if (C->wm.area && C->wm.area->spacetype==SPACE_LOGIC)
return C->wm.area->spacedata.first;
return NULL;
}
struct SpaceIpo *CTX_wm_space_graph(const bContext *C)
{
- if(C->wm.area && C->wm.area->spacetype==SPACE_IPO)
+ if (C->wm.area && C->wm.area->spacetype==SPACE_IPO)
return C->wm.area->spacedata.first;
return NULL;
}
struct SpaceAction *CTX_wm_space_action(const bContext *C)
{
- if(C->wm.area && C->wm.area->spacetype==SPACE_ACTION)
+ if (C->wm.area && C->wm.area->spacetype==SPACE_ACTION)
return C->wm.area->spacedata.first;
return NULL;
}
struct SpaceInfo *CTX_wm_space_info(const bContext *C)
{
- if(C->wm.area && C->wm.area->spacetype==SPACE_INFO)
+ if (C->wm.area && C->wm.area->spacetype==SPACE_INFO)
return C->wm.area->spacedata.first;
return NULL;
}
struct SpaceUserPref *CTX_wm_space_userpref(const bContext *C)
{
- if(C->wm.area && C->wm.area->spacetype==SPACE_USERPREF)
+ if (C->wm.area && C->wm.area->spacetype==SPACE_USERPREF)
return C->wm.area->spacedata.first;
return NULL;
}
struct SpaceClip *CTX_wm_space_clip(const bContext *C)
{
- if(C->wm.area && C->wm.area->spacetype==SPACE_CLIP)
+ if (C->wm.area && C->wm.area->spacetype==SPACE_CLIP)
return C->wm.area->spacedata.first;
return NULL;
}
@@ -381,7 +381,7 @@ void CTX_wm_window_set(bContext *C, wmWindow *win)
{
C->wm.window= win;
C->wm.screen= (win)? win->screen: NULL;
- if(C->wm.screen)
+ if (C->wm.screen)
C->data.scene= C->wm.screen->scene;
C->wm.area= NULL;
C->wm.region= NULL;
@@ -390,7 +390,7 @@ void CTX_wm_window_set(bContext *C, wmWindow *win)
void CTX_wm_screen_set(bContext *C, bScreen *screen)
{
C->wm.screen= screen;
- if(C->wm.screen)
+ if (C->wm.screen)
C->data.scene= C->wm.screen->scene;
C->wm.area= NULL;
C->wm.region= NULL;
@@ -438,7 +438,7 @@ static int ctx_data_get(bContext *C, const char *member, bContextDataResult *res
memset(result, 0, sizeof(bContextDataResult));
#ifdef WITH_PYTHON
- if(CTX_py_dict_get(C)) {
+ if (CTX_py_dict_get(C)) {
return BPY_context_member_get(C, member, result);
// if (BPY_context_member_get(C, member, result))
// return 1;
@@ -453,38 +453,38 @@ static int ctx_data_get(bContext *C, const char *member, bContextDataResult *res
* Values in order of importance
* (0, -1, 1) - Where 1 is highest priority
* */
- if(done!=1 && recursion < 1 && C->wm.store) {
+ if (done!=1 && recursion < 1 && C->wm.store) {
bContextStoreEntry *entry;
C->data.recursion= 1;
entry= BLI_rfindstring(&C->wm.store->entries, member, offsetof(bContextStoreEntry, name));
- if(entry) {
+ if (entry) {
result->ptr= entry->ptr;
done= 1;
}
}
- if(done!=1 && recursion < 2 && C->wm.region) {
+ if (done!=1 && recursion < 2 && C->wm.region) {
C->data.recursion= 2;
- if(C->wm.region->type && C->wm.region->type->context) {
+ if (C->wm.region->type && C->wm.region->type->context) {
ret = C->wm.region->type->context(C, member, result);
- if(ret) done= -(-ret | -done);
+ if (ret) done= -(-ret | -done);
}
}
- if(done!=1 && recursion < 3 && C->wm.area) {
+ if (done!=1 && recursion < 3 && C->wm.area) {
C->data.recursion= 3;
- if(C->wm.area->type && C->wm.area->type->context) {
+ if (C->wm.area->type && C->wm.area->type->context) {
ret = C->wm.area->type->context(C, member, result);
- if(ret) done= -(-ret | -done);
+ if (ret) done= -(-ret | -done);
}
}
- if(done!=1 && recursion < 4 && C->wm.screen) {
+ if (done!=1 && recursion < 4 && C->wm.screen) {
bContextDataCallback cb= C->wm.screen->context;
C->data.recursion= 4;
- if(cb) {
+ if (cb) {
ret = cb(C, member, result);
- if(ret) done= -(-ret | -done);
+ if (ret) done= -(-ret | -done);
}
}
@@ -497,7 +497,7 @@ static void *ctx_data_pointer_get(const bContext *C, const char *member)
{
bContextDataResult result;
- if(C && ctx_data_get((bContext*)C, member, &result)==1)
+ if (C && ctx_data_get((bContext*)C, member, &result)==1)
return result.ptr.data;
return NULL;
@@ -512,7 +512,7 @@ static int ctx_data_pointer_verify(const bContext *C, const char *member, void *
*pointer= NULL;
return 1;
}
- else if(ctx_data_get((bContext*)C, member, &result)==1) {
+ else if (ctx_data_get((bContext*)C, member, &result)==1) {
*pointer= result.ptr.data;
return 1;
}
@@ -526,7 +526,7 @@ static int ctx_data_collection_get(const bContext *C, const char *member, ListBa
{
bContextDataResult result;
- if(ctx_data_get((bContext*)C, member, &result)==1) {
+ if (ctx_data_get((bContext*)C, member, &result)==1) {
*list= result.list;
return 1;
}
@@ -541,7 +541,7 @@ PointerRNA CTX_data_pointer_get(const bContext *C, const char *member)
{
bContextDataResult result;
- if(ctx_data_get((bContext*)C, member, &result)==1)
+ if (ctx_data_get((bContext*)C, member, &result)==1)
return result.ptr;
else
return PointerRNA_NULL;
@@ -551,7 +551,7 @@ PointerRNA CTX_data_pointer_get_type(const bContext *C, const char *member, Stru
{
PointerRNA ptr = CTX_data_pointer_get(C, member);
- if(ptr.data && RNA_struct_is_a(ptr.type, type))
+ if (ptr.data && RNA_struct_is_a(ptr.type, type))
return ptr;
return PointerRNA_NULL;
@@ -561,7 +561,7 @@ ListBase CTX_data_collection_get(const bContext *C, const char *member)
{
bContextDataResult result;
- if(ctx_data_get((bContext*)C, member, &result)==1) {
+ if (ctx_data_get((bContext*)C, member, &result)==1) {
return result.list;
}
else {
@@ -576,7 +576,7 @@ int CTX_data_get(const bContext *C, const char *member, PointerRNA *r_ptr, ListB
bContextDataResult result;
int ret= ctx_data_get((bContext*)C, member, &result);
- if(ret==1) {
+ if (ret==1) {
*r_ptr= result.ptr;
*r_lb= result.list;
*r_type= result.type;
@@ -594,10 +594,10 @@ static void data_dir_add(ListBase *lb, const char *member)
{
LinkData *link;
- if(strcmp(member, "scene") == 0) /* exception */
+ if (strcmp(member, "scene") == 0) /* exception */
return;
- if(BLI_findstring(lb, member, offsetof(LinkData, data)))
+ if (BLI_findstring(lb, member, offsetof(LinkData, data)))
return;
link= MEM_callocN(sizeof(LinkData), "LinkData");
@@ -613,35 +613,35 @@ ListBase CTX_data_dir_get(const bContext *C)
memset(&lb, 0, sizeof(lb));
- if(C->wm.store) {
+ if (C->wm.store) {
bContextStoreEntry *entry;
- for(entry=C->wm.store->entries.first; entry; entry=entry->next)
+ for (entry=C->wm.store->entries.first; entry; entry=entry->next)
data_dir_add(&lb, entry->name);
}
- if(C->wm.region && C->wm.region->type && C->wm.region->type->context) {
+ if (C->wm.region && C->wm.region->type && C->wm.region->type->context) {
memset(&result, 0, sizeof(result));
C->wm.region->type->context(C, "", &result);
- if(result.dir)
- for(a=0; result.dir[a]; a++)
+ if (result.dir)
+ for (a=0; result.dir[a]; a++)
data_dir_add(&lb, result.dir[a]);
}
- if(C->wm.area && C->wm.area->type && C->wm.area->type->context) {
+ if (C->wm.area && C->wm.area->type && C->wm.area->type->context) {
memset(&result, 0, sizeof(result));
C->wm.area->type->context(C, "", &result);
- if(result.dir)
- for(a=0; result.dir[a]; a++)
+ if (result.dir)
+ for (a=0; result.dir[a]; a++)
data_dir_add(&lb, result.dir[a]);
}
- if(C->wm.screen && C->wm.screen->context) {
+ if (C->wm.screen && C->wm.screen->context) {
bContextDataCallback cb= C->wm.screen->context;
memset(&result, 0, sizeof(result));
cb(C, "", &result);
- if(result.dir)
- for(a=0; result.dir[a]; a++)
+ if (result.dir)
+ for (a=0; result.dir[a]; a++)
data_dir_add(&lb, result.dir[a]);
}
@@ -692,7 +692,7 @@ int ctx_data_list_count(const bContext *C, int (*func)(const bContext*, ListBase
{
ListBase list;
- if(func(C, &list)) {
+ if (func(C, &list)) {
int tot= BLI_countlist(&list);
BLI_freelistN(&list);
return tot;
@@ -722,7 +722,7 @@ Main *CTX_data_main(const bContext *C)
{
Main *bmain;
- if(ctx_data_pointer_verify(C, "blend_data", (void*)&bmain))
+ if (ctx_data_pointer_verify(C, "blend_data", (void*)&bmain))
return bmain;
else
return C->data.main;
@@ -737,7 +737,7 @@ Scene *CTX_data_scene(const bContext *C)
{
Scene *scene;
- if(ctx_data_pointer_verify(C, "scene", (void*)&scene))
+ if (ctx_data_pointer_verify(C, "scene", (void*)&scene))
return scene;
else
return C->data.scene;
@@ -747,7 +747,7 @@ int CTX_data_mode_enum(const bContext *C)
{
Object *obedit= CTX_data_edit_object(C);
- if(obedit) {
+ if (obedit) {
switch(obedit->type) {
case OB_MESH:
return CTX_MODE_EDIT_MESH;
@@ -768,13 +768,13 @@ int CTX_data_mode_enum(const bContext *C)
else {
Object *ob = CTX_data_active_object(C);
- if(ob) {
- if(ob->mode & OB_MODE_POSE) return CTX_MODE_POSE;
- else if(ob->mode & OB_MODE_SCULPT) return CTX_MODE_SCULPT;
- else if(ob->mode & OB_MODE_WEIGHT_PAINT) return CTX_MODE_PAINT_WEIGHT;
- else if(ob->mode & OB_MODE_VERTEX_PAINT) return CTX_MODE_PAINT_VERTEX;
- else if(ob->mode & OB_MODE_TEXTURE_PAINT) return CTX_MODE_PAINT_TEXTURE;
- else if(ob->mode & OB_MODE_PARTICLE_EDIT) return CTX_MODE_PARTICLE;
+ if (ob) {
+ if (ob->mode & OB_MODE_POSE) return CTX_MODE_POSE;
+ else if (ob->mode & OB_MODE_SCULPT) return CTX_MODE_SCULPT;
+ else if (ob->mode & OB_MODE_WEIGHT_PAINT) return CTX_MODE_PAINT_WEIGHT;
+ else if (ob->mode & OB_MODE_VERTEX_PAINT) return CTX_MODE_PAINT_VERTEX;
+ else if (ob->mode & OB_MODE_TEXTURE_PAINT) return CTX_MODE_PAINT_TEXTURE;
+ else if (ob->mode & OB_MODE_PARTICLE_EDIT) return CTX_MODE_PARTICLE;
}
}
@@ -815,7 +815,7 @@ ToolSettings *CTX_data_tool_settings(const bContext *C)
{
Scene *scene = CTX_data_scene(C);
- if(scene)
+ if (scene)
return scene->toolsettings;
else
return NULL;
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index 1b6b95b4c85..c84db44a674 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -74,38 +74,38 @@ void unlink_curve(Curve *cu)
{
int a;
- for(a=0; a<cu->totcol; a++) {
- if(cu->mat[a]) cu->mat[a]->id.us--;
+ for (a=0; a<cu->totcol; a++) {
+ if (cu->mat[a]) cu->mat[a]->id.us--;
cu->mat[a]= NULL;
}
- if(cu->vfont) cu->vfont->id.us--;
+ if (cu->vfont) cu->vfont->id.us--;
cu->vfont= NULL;
- if(cu->vfontb) cu->vfontb->id.us--;
+ if (cu->vfontb) cu->vfontb->id.us--;
cu->vfontb= NULL;
- if(cu->vfonti) cu->vfonti->id.us--;
+ if (cu->vfonti) cu->vfonti->id.us--;
cu->vfonti= NULL;
- if(cu->vfontbi) cu->vfontbi->id.us--;
+ if (cu->vfontbi) cu->vfontbi->id.us--;
cu->vfontbi= NULL;
- if(cu->key) cu->key->id.us--;
+ if (cu->key) cu->key->id.us--;
cu->key= NULL;
}
/* frees editcurve entirely */
void BKE_free_editfont(Curve *cu)
{
- if(cu->editfont) {
+ if (cu->editfont) {
EditFont *ef= cu->editfont;
- if(ef->oldstr) MEM_freeN(ef->oldstr);
- if(ef->oldstrinfo) MEM_freeN(ef->oldstrinfo);
- if(ef->textbuf) MEM_freeN(ef->textbuf);
- if(ef->textbufinfo) MEM_freeN(ef->textbufinfo);
- if(ef->copybuf) MEM_freeN(ef->copybuf);
- if(ef->copybufinfo) MEM_freeN(ef->copybufinfo);
+ if (ef->oldstr) MEM_freeN(ef->oldstr);
+ if (ef->oldstrinfo) MEM_freeN(ef->oldstrinfo);
+ if (ef->textbuf) MEM_freeN(ef->textbuf);
+ if (ef->textbufinfo) MEM_freeN(ef->textbufinfo);
+ if (ef->copybuf) MEM_freeN(ef->copybuf);
+ if (ef->copybufinfo) MEM_freeN(ef->copybufinfo);
MEM_freeN(ef);
cu->editfont= NULL;
@@ -123,7 +123,7 @@ void free_curve_editNurb_keyIndex(EditNurb *editnurb)
void free_curve_editNurb (Curve *cu)
{
- if(cu->editnurb) {
+ if (cu->editnurb) {
freeNurblist(&cu->editnurb->nurbs);
free_curve_editNurb_keyIndex(cu->editnurb);
MEM_freeN(cu->editnurb);
@@ -143,12 +143,12 @@ void free_curve(Curve *cu)
unlink_curve(cu);
BKE_free_animdata((ID *)cu);
- if(cu->mat) MEM_freeN(cu->mat);
- if(cu->str) MEM_freeN(cu->str);
- if(cu->strinfo) MEM_freeN(cu->strinfo);
- if(cu->bb) MEM_freeN(cu->bb);
- if(cu->path) free_path(cu->path);
- if(cu->tb) MEM_freeN(cu->tb);
+ if (cu->mat) MEM_freeN(cu->mat);
+ if (cu->str) MEM_freeN(cu->str);
+ if (cu->strinfo) MEM_freeN(cu->strinfo);
+ if (cu->bb) MEM_freeN(cu->bb);
+ if (cu->path) free_path(cu->path);
+ if (cu->tb) MEM_freeN(cu->tb);
}
Curve *add_curve(const char *name, int type)
@@ -172,7 +172,7 @@ Curve *add_curve(const char *name, int type)
cu->bb= unit_boundbox();
- if(type==OB_FONT) {
+ if (type==OB_FONT) {
cu->vfont= cu->vfontb= cu->vfonti= cu->vfontbi= get_builtin_font();
cu->vfont->id.us+=4;
cu->str= MEM_mallocN(12, "str");
@@ -197,7 +197,7 @@ Curve *copy_curve(Curve *cu)
duplicateNurblist( &(cun->nurb), &(cu->nurb));
cun->mat= MEM_dupallocN(cu->mat);
- for(a=0; a<cun->totcol; a++) {
+ for (a=0; a<cun->totcol; a++) {
id_us_plus((ID *)cun->mat[a]);
}
@@ -207,7 +207,7 @@ Curve *copy_curve(Curve *cu)
cun->bb= MEM_dupallocN(cu->bb);
cun->key= copy_key(cu->key);
- if(cun->key) cun->key->from= (ID *)cun;
+ if (cun->key) cun->key->from= (ID *)cun;
cun->disp.first= cun->disp.last= NULL;
cun->bev.first= cun->bev.last= NULL;
@@ -219,7 +219,7 @@ Curve *copy_curve(Curve *cu)
#if 0 // XXX old animation system
/* single user ipo too */
- if(cun->ipo) cun->ipo= copy_ipo(cun->ipo);
+ if (cun->ipo) cun->ipo= copy_ipo(cun->ipo);
#endif // XXX old animation system
id_us_plus((ID *)cun->vfont);
@@ -237,7 +237,7 @@ static void extern_local_curve(Curve *cu)
id_lib_extern((ID *)cu->vfonti);
id_lib_extern((ID *)cu->vfontbi);
- if(cu->mat) {
+ if (cu->mat) {
extern_local_matarar(cu->mat, cu->totcol);
}
}
@@ -253,34 +253,34 @@ void make_local_curve(Curve *cu)
* - mixed: do a copy
*/
- if(cu->id.lib==NULL) return;
+ if (cu->id.lib==NULL) return;
- if(cu->id.us==1) {
+ if (cu->id.us==1) {
id_clear_lib_data(bmain, &cu->id);
extern_local_curve(cu);
return;
}
- for(ob= bmain->object.first; ob && ELEM(0, is_lib, is_local); ob= ob->id.next) {
- if(ob->data == cu) {
- if(ob->id.lib) is_lib= TRUE;
+ for (ob= bmain->object.first; ob && ELEM(0, is_lib, is_local); ob= ob->id.next) {
+ if (ob->data == cu) {
+ if (ob->id.lib) is_lib= TRUE;
else is_local= TRUE;
}
}
- if(is_local && is_lib == FALSE) {
+ if (is_local && is_lib == FALSE) {
id_clear_lib_data(bmain, &cu->id);
extern_local_curve(cu);
}
- else if(is_local && is_lib) {
+ else if (is_local && is_lib) {
Curve *cu_new= copy_curve(cu);
cu_new->id.us= 0;
BKE_id_lib_local_paths(bmain, cu->id.lib, &cu_new->id);
- for(ob= bmain->object.first; ob; ob= ob->id.next) {
- if(ob->data==cu) {
- if(ob->id.lib==NULL) {
+ for (ob= bmain->object.first; ob; ob= ob->id.next) {
+ if (ob->data==cu) {
+ if (ob->id.lib==NULL) {
ob->data= cu_new;
cu_new->id.us++;
cu->id.us--;
@@ -305,15 +305,15 @@ short curve_type(Curve *cu)
Nurb *nu;
int type= cu->type;
- if(cu->vfont) {
+ if (cu->vfont) {
return OB_FONT;
}
- if(!cu->type) {
+ if (!cu->type) {
type= OB_CURVE;
for (nu= cu->nurb.first; nu; nu= nu->next) {
- if(nu->pntsv>1) {
+ if (nu->pntsv>1) {
type= OB_SURF;
}
}
@@ -327,18 +327,18 @@ void update_curve_dimension(Curve *cu)
ListBase *nurbs= BKE_curve_nurbs(cu);
Nurb *nu= nurbs->first;
- if(cu->flag&CU_3D) {
- for( ; nu; nu= nu->next) {
+ if (cu->flag&CU_3D) {
+ for ( ; nu; nu= nu->next) {
nu->flag &= ~CU_2D;
}
}
else {
- for( ; nu; nu= nu->next) {
+ for ( ; nu; nu= nu->next) {
nu->flag |= CU_2D;
test2DNurb(nu);
/* since the handles are moved they need to be auto-located again */
- if(nu->type == CU_BEZIER)
+ if (nu->type == CU_BEZIER)
calchandlesNurb(nu);
}
}
@@ -348,7 +348,7 @@ void test_curve_type(Object *ob)
{
ob->type= curve_type(ob->data);
- if(ob->type==OB_CURVE)
+ if (ob->type==OB_CURVE)
update_curve_dimension((Curve *)ob->data);
}
@@ -359,33 +359,33 @@ void tex_space_curve(Curve *cu)
float *fp, min[3], max[3];
int tot, doit= 0;
- if(cu->bb==NULL) cu->bb= MEM_callocN(sizeof(BoundBox), "boundbox");
+ if (cu->bb==NULL) cu->bb= MEM_callocN(sizeof(BoundBox), "boundbox");
bb= cu->bb;
INIT_MINMAX(min, max);
dl= cu->disp.first;
- while(dl) {
+ while (dl) {
tot = ELEM(dl->type, DL_INDEX3, DL_INDEX4) ? dl->nr : dl->nr * dl->parts;
- if(tot) doit= 1;
+ if (tot) doit= 1;
fp= dl->verts;
- while(tot--) {
+ while (tot--) {
DO_MINMAX(fp, min, max);
fp += 3;
}
dl= dl->next;
}
- if(!doit) {
+ if (!doit) {
min[0] = min[1] = min[2] = -1.0f;
max[0] = max[1] = max[2] = 1.0f;
}
boundbox_set_from_min_max(bb, min, max);
- if(cu->texflag & CU_AUTOSPACE) {
+ if (cu->texflag & CU_AUTOSPACE) {
mid_v3_v3v3(cu->loc, min, max);
cu->size[0]= (max[0]-min[0])/2.0f;
cu->size[1]= (max[1]-min[1])/2.0f;
@@ -393,17 +393,17 @@ void tex_space_curve(Curve *cu)
zero_v3(cu->rot);
- if(cu->size[0]==0.0f) cu->size[0]= 1.0f;
- else if(cu->size[0]>0.0f && cu->size[0]<0.00001f) cu->size[0]= 0.00001f;
- else if(cu->size[0]<0.0f && cu->size[0]> -0.00001f) cu->size[0]= -0.00001f;
+ if (cu->size[0]==0.0f) cu->size[0]= 1.0f;
+ else if (cu->size[0]>0.0f && cu->size[0]<0.00001f) cu->size[0]= 0.00001f;
+ else if (cu->size[0]<0.0f && cu->size[0]> -0.00001f) cu->size[0]= -0.00001f;
- if(cu->size[1]==0.0f) cu->size[1]= 1.0f;
- else if(cu->size[1]>0.0f && cu->size[1]<0.00001f) cu->size[1]= 0.00001f;
- else if(cu->size[1]<0.0f && cu->size[1]> -0.00001f) cu->size[1]= -0.00001f;
+ if (cu->size[1]==0.0f) cu->size[1]= 1.0f;
+ else if (cu->size[1]>0.0f && cu->size[1]<0.00001f) cu->size[1]= 0.00001f;
+ else if (cu->size[1]<0.0f && cu->size[1]> -0.00001f) cu->size[1]= -0.00001f;
- if(cu->size[2]==0.0f) cu->size[2]= 1.0f;
- else if(cu->size[2]>0.0f && cu->size[2]<0.00001f) cu->size[2]= 0.00001f;
- else if(cu->size[2]<0.0f && cu->size[2]> -0.00001f) cu->size[2]= -0.00001f;
+ if (cu->size[2]==0.0f) cu->size[2]= 1.0f;
+ else if (cu->size[2]>0.0f && cu->size[2]<0.00001f) cu->size[2]= 0.00001f;
+ else if (cu->size[2]<0.0f && cu->size[2]> -0.00001f) cu->size[2]= -0.00001f;
}
}
@@ -414,9 +414,9 @@ int count_curveverts(ListBase *nurb)
int tot=0;
nu= nurb->first;
- while(nu) {
- if(nu->bezt) tot+= 3*nu->pntsu;
- else if(nu->bp) tot+= nu->pntsu*nu->pntsv;
+ while (nu) {
+ if (nu->bezt) tot+= 3*nu->pntsu;
+ else if (nu->bp) tot+= nu->pntsu*nu->pntsv;
nu= nu->next;
}
@@ -429,9 +429,9 @@ int count_curveverts_without_handles(ListBase *nurb)
int tot=0;
nu= nurb->first;
- while(nu) {
- if(nu->bezt) tot+= nu->pntsu;
- else if(nu->bp) tot+= nu->pntsu*nu->pntsv;
+ while (nu) {
+ if (nu->bezt) tot+= nu->pntsu;
+ else if (nu->bp) tot+= nu->pntsu*nu->pntsv;
nu= nu->next;
}
@@ -443,15 +443,15 @@ int count_curveverts_without_handles(ListBase *nurb)
void freeNurb(Nurb *nu)
{
- if(nu==NULL) return;
+ if (nu==NULL) return;
- if(nu->bezt) MEM_freeN(nu->bezt);
+ if (nu->bezt) MEM_freeN(nu->bezt);
nu->bezt= NULL;
- if(nu->bp) MEM_freeN(nu->bp);
+ if (nu->bp) MEM_freeN(nu->bp);
nu->bp= NULL;
- if(nu->knotsu) MEM_freeN(nu->knotsu);
+ if (nu->knotsu) MEM_freeN(nu->knotsu);
nu->knotsu= NULL;
- if(nu->knotsv) MEM_freeN(nu->knotsv);
+ if (nu->knotsv) MEM_freeN(nu->knotsv);
nu->knotsv= NULL;
/* if(nu->trim.first) freeNurblist(&(nu->trim)); */
@@ -464,10 +464,10 @@ void freeNurblist(ListBase *lb)
{
Nurb *nu, *next;
- if(lb==NULL) return;
+ if (lb==NULL) return;
nu= lb->first;
- while(nu) {
+ while (nu) {
next= nu->next;
freeNurb(nu);
nu= next;
@@ -481,10 +481,10 @@ Nurb *duplicateNurb(Nurb *nu)
int len;
newnu= (Nurb*)MEM_mallocN(sizeof(Nurb),"duplicateNurb");
- if(newnu==NULL) return NULL;
+ if (newnu==NULL) return NULL;
memcpy(newnu, nu, sizeof(Nurb));
- if(nu->bezt) {
+ if (nu->bezt) {
newnu->bezt=
(BezTriple*)MEM_mallocN((nu->pntsu)* sizeof(BezTriple),"duplicateNurb2");
memcpy(newnu->bezt, nu->bezt, nu->pntsu*sizeof(BezTriple));
@@ -497,16 +497,16 @@ Nurb *duplicateNurb(Nurb *nu)
newnu->knotsu= newnu->knotsv= NULL;
- if(nu->knotsu) {
+ if (nu->knotsu) {
len= KNOTSU(nu);
- if(len) {
+ if (len) {
newnu->knotsu= MEM_mallocN(len*sizeof(float), "duplicateNurb4");
memcpy(newnu->knotsu, nu->knotsu, sizeof(float)*len);
}
}
- if(nu->pntsv>1 && nu->knotsv) {
+ if (nu->pntsv>1 && nu->knotsv) {
len= KNOTSV(nu);
- if(len) {
+ if (len) {
newnu->knotsv= MEM_mallocN(len*sizeof(float), "duplicateNurb5");
memcpy(newnu->knotsv, nu->knotsv, sizeof(float)*len);
}
@@ -522,7 +522,7 @@ void duplicateNurblist(ListBase *lb1, ListBase *lb2)
freeNurblist(lb1);
nu= lb2->first;
- while(nu) {
+ while (nu) {
nun= duplicateNurb(nu);
BLI_addtail(lb1, nun);
@@ -536,13 +536,13 @@ void test2DNurb(Nurb *nu)
BPoint *bp;
int a;
- if((nu->flag & CU_2D)==0)
+ if ((nu->flag & CU_2D)==0)
return;
- if(nu->type == CU_BEZIER) {
+ if (nu->type == CU_BEZIER) {
a= nu->pntsu;
bezt= nu->bezt;
- while(a--) {
+ while (a--) {
bezt->vec[0][2]= 0.0;
bezt->vec[1][2]= 0.0;
bezt->vec[2][2]= 0.0;
@@ -552,7 +552,7 @@ void test2DNurb(Nurb *nu)
else {
a= nu->pntsu*nu->pntsv;
bp= nu->bp;
- while(a--) {
+ while (a--) {
bp->vec[2]= 0.0;
bp++;
}
@@ -565,10 +565,10 @@ void minmaxNurb(Nurb *nu, float *min, float *max)
BPoint *bp;
int a;
- if(nu->type == CU_BEZIER) {
+ if (nu->type == CU_BEZIER) {
a= nu->pntsu;
bezt= nu->bezt;
- while(a--) {
+ while (a--) {
DO_MINMAX(bezt->vec[0], min, max);
DO_MINMAX(bezt->vec[1], min, max);
DO_MINMAX(bezt->vec[2], min, max);
@@ -578,7 +578,7 @@ void minmaxNurb(Nurb *nu, float *min, float *max)
else {
a= nu->pntsu*nu->pntsv;
bp= nu->bp;
- while(a--) {
+ while (a--) {
DO_MINMAX(bp->vec, min, max);
bp++;
}
@@ -592,14 +592,14 @@ void addNurbPoints(Nurb *nu, int number)
int i;
nu->bp= (BPoint *)MEM_mallocN((nu->pntsu + number) * sizeof(BPoint), "rna_Curve_spline_points_add");
- if(tmp) {
+ if (tmp) {
memmove(nu->bp, tmp, nu->pntsu * sizeof(BPoint));
MEM_freeN(tmp);
}
memset(nu->bp + nu->pntsu, 0, number * sizeof(BPoint));
- for(i=0, tmp= nu->bp + nu->pntsu; i < number; i++, tmp++) {
+ for (i=0, tmp= nu->bp + nu->pntsu; i < number; i++, tmp++) {
tmp->radius= 1.0f;
}
@@ -612,14 +612,14 @@ void addNurbPointsBezier(Nurb *nu, int number)
int i;
nu->bezt= (BezTriple *)MEM_mallocN((nu->pntsu + number) * sizeof(BezTriple), "rna_Curve_spline_points_add");
- if(tmp) {
+ if (tmp) {
memmove(nu->bezt, tmp, nu->pntsu * sizeof(BezTriple));
MEM_freeN(tmp);
}
memset(nu->bezt + nu->pntsu, 0, number * sizeof(BezTriple));
- for(i=0, tmp= nu->bezt + nu->pntsu; i < number; i++, tmp++) {
+ for (i=0, tmp= nu->bezt + nu->pntsu; i < number; i++, tmp++) {
tmp->radius= 1.0f;
}
@@ -639,25 +639,25 @@ static void calcknots(float *knots, const short pnts, const short order, const s
switch(flag & (CU_NURB_ENDPOINT|CU_NURB_BEZIER)) {
case CU_NURB_ENDPOINT:
k= 0.0;
- for(a=1; a <= pnts_order; a++) {
+ for (a=1; a <= pnts_order; a++) {
knots[a-1]= k;
- if(a >= order && a <= pnts) k+= 1.0f;
+ if (a >= order && a <= pnts) k+= 1.0f;
}
break;
case CU_NURB_BEZIER:
/* Warning, the order MUST be 2 or 4,
* if this is not enforced, the displist will be corrupt */
- if(order==4) {
+ if (order==4) {
k= 0.34;
- for(a=0; a < pnts_order; a++) {
+ for (a=0; a < pnts_order; a++) {
knots[a]= floorf(k);
k+= (1.0f/3.0f);
}
}
- else if(order==3) {
+ else if (order==3) {
k= 0.6f;
- for(a=0; a < pnts_order; a++) {
- if(a >= order && a <= pnts) k+= 0.5f;
+ for (a=0; a < pnts_order; a++) {
+ if (a >= order && a <= pnts) k+= 0.5f;
knots[a]= floorf(k);
}
}
@@ -666,7 +666,7 @@ static void calcknots(float *knots, const short pnts, const short order, const s
}
break;
default:
- for(a=0; a < pnts_order; a++) {
+ for (a=0; a < pnts_order; a++) {
knots[a]= (float)a;
}
break;
@@ -678,22 +678,22 @@ static void makecyclicknots(float *knots, short pnts, short order)
{
int a, b, order2, c;
- if(knots==NULL) return;
+ if (knots==NULL) return;
order2=order-1;
/* do first long rows (order -1), remove identical knots at endpoints */
- if(order>2) {
+ if (order>2) {
b= pnts+order2;
- for(a=1; a<order2; a++) {
- if(knots[b]!= knots[b-a]) break;
+ for (a=1; a<order2; a++) {
+ if (knots[b]!= knots[b-a]) break;
}
- if(a==order2) knots[pnts+order-2]+= 1.0f;
+ if (a==order2) knots[pnts+order-2]+= 1.0f;
}
b= order;
c=pnts + order + order2;
- for(a=pnts+order2; a<c; a++) {
+ for (a=pnts+order2; a<c; a++) {
knots[a]= knots[a-1]+ (knots[b]-knots[b-1]);
b--;
}
@@ -703,28 +703,31 @@ static void makecyclicknots(float *knots, short pnts, short order)
static void makeknots(Nurb *nu, short uv)
{
- if(nu->type == CU_NURBS) {
- if(uv == 1) {
- if(nu->knotsu) MEM_freeN(nu->knotsu);
- if(check_valid_nurb_u(nu)) {
+ if (nu->type == CU_NURBS) {
+ if (uv == 1) {
+ if (nu->knotsu) MEM_freeN(nu->knotsu);
+ if (check_valid_nurb_u(nu)) {
nu->knotsu= MEM_callocN(4+sizeof(float)*KNOTSU(nu), "makeknots");
- if(nu->flagu & CU_NURB_CYCLIC) {
+ if (nu->flagu & CU_NURB_CYCLIC) {
calcknots(nu->knotsu, nu->pntsu, nu->orderu, 0); /* cyclic should be uniform */
makecyclicknots(nu->knotsu, nu->pntsu, nu->orderu);
- } else {
+ }
+ else {
calcknots(nu->knotsu, nu->pntsu, nu->orderu, nu->flagu);
}
}
else nu->knotsu= NULL;
- } else if(uv == 2) {
- if(nu->knotsv) MEM_freeN(nu->knotsv);
- if(check_valid_nurb_v(nu)) {
+ }
+ else if (uv == 2) {
+ if (nu->knotsv) MEM_freeN(nu->knotsv);
+ if (check_valid_nurb_v(nu)) {
nu->knotsv= MEM_callocN(4+sizeof(float)*KNOTSV(nu), "makeknots");
- if(nu->flagv & CU_NURB_CYCLIC) {
+ if (nu->flagv & CU_NURB_CYCLIC) {
calcknots(nu->knotsv, nu->pntsv, nu->orderv, 0); /* cyclic should be uniform */
makecyclicknots(nu->knotsv, nu->pntsv, nu->orderv);
- } else {
+ }
+ else {
calcknots(nu->knotsv, nu->pntsv, nu->orderv, nu->flagv);
}
}
@@ -752,19 +755,19 @@ static void basisNurb(float t, short order, short pnts, float *knots, float *bas
opp2 = orderpluspnts-1;
/* this is for float inaccuracy */
- if(t < knots[0]) t= knots[0];
- else if(t > knots[opp2]) t= knots[opp2];
+ if (t < knots[0]) t= knots[0];
+ else if (t > knots[opp2]) t= knots[opp2];
/* this part is order '1' */
o2 = order + 1;
- for(i=0;i<opp2;i++) {
- if(knots[i]!=knots[i+1] && t>= knots[i] && t<=knots[i+1]) {
+ for (i=0;i<opp2;i++) {
+ if (knots[i]!=knots[i+1] && t>= knots[i] && t<=knots[i+1]) {
basis[i]= 1.0;
i1= i-o2;
- if(i1<0) i1= 0;
+ if (i1<0) i1= 0;
i2= i;
i++;
- while(i<opp2) {
+ while (i<opp2) {
basis[i]= 0.0;
i++;
}
@@ -775,17 +778,17 @@ static void basisNurb(float t, short order, short pnts, float *knots, float *bas
basis[i]= 0.0;
/* this is order 2,3,... */
- for(j=2; j<=order; j++) {
+ for (j=2; j<=order; j++) {
- if(i2+j>= orderpluspnts) i2= opp2-j;
+ if (i2+j>= orderpluspnts) i2= opp2-j;
- for(i= i1; i<=i2; i++) {
- if(basis[i]!=0.0f)
+ for (i= i1; i<=i2; i++) {
+ if (basis[i]!=0.0f)
d= ((t-knots[i])*basis[i]) / (knots[i+j-1]-knots[i]);
else
d= 0.0f;
- if(basis[i+1] != 0.0f)
+ if (basis[i+1] != 0.0f)
e= ((knots[i+j]-t)*basis[i+1]) / (knots[i+j]-knots[i+1]);
else
e= 0.0;
@@ -797,10 +800,10 @@ static void basisNurb(float t, short order, short pnts, float *knots, float *bas
*start= 1000;
*end= 0;
- for(i=i1; i<=i2; i++) {
- if(basis[i] > 0.0f) {
+ for (i=i1; i<=i2; i++) {
+ if (basis[i] > 0.0f) {
*end= i;
- if(*start==1000) *start= i;
+ if (*start==1000) *start= i;
}
}
}
@@ -817,21 +820,21 @@ void makeNurbfaces(Nurb *nu, float *coord_array, int rowstride, int resolu, int
int totu = nu->pntsu*resolu, totv = nu->pntsv*resolv;
- if(nu->knotsu==NULL || nu->knotsv==NULL) return;
- if(nu->orderu>nu->pntsu) return;
- if(nu->orderv>nu->pntsv) return;
- if(coord_array==NULL) return;
+ if (nu->knotsu==NULL || nu->knotsv==NULL) return;
+ if (nu->orderu>nu->pntsu) return;
+ if (nu->orderv>nu->pntsv) return;
+ if (coord_array==NULL) return;
/* allocate and initialize */
len = totu * totv;
- if(len==0) return;
+ if (len==0) return;
sum= (float *)MEM_callocN(sizeof(float)*len, "makeNurbfaces1");
len= totu*totv;
- if(len==0) {
+ if (len==0) {
MEM_freeN(sum);
return;
}
@@ -839,8 +842,8 @@ void makeNurbfaces(Nurb *nu, float *coord_array, int rowstride, int resolu, int
bp= nu->bp;
i= nu->pntsu*nu->pntsv;
ratcomp=0;
- while(i--) {
- if(bp->vec[3] != 1.0f) {
+ while (i--) {
+ if (bp->vec[3] != 1.0f) {
ratcomp= 1;
break;
}
@@ -849,7 +852,7 @@ void makeNurbfaces(Nurb *nu, float *coord_array, int rowstride, int resolu, int
fp= nu->knotsu;
ustart= fp[nu->orderu-1];
- if(nu->flagu & CU_NURB_CYCLIC) uend= fp[nu->pntsu+nu->orderu-1];
+ if (nu->flagu & CU_NURB_CYCLIC) uend= fp[nu->pntsu+nu->orderu-1];
else uend= fp[nu->pntsu];
ustep= (uend-ustart)/((nu->flagu & CU_NURB_CYCLIC) ? totu : totu - 1);
@@ -858,7 +861,7 @@ void makeNurbfaces(Nurb *nu, float *coord_array, int rowstride, int resolu, int
fp= nu->knotsv;
vstart= fp[nu->orderv-1];
- if(nu->flagv & CU_NURB_CYCLIC) vend= fp[nu->pntsv+nu->orderv-1];
+ if (nu->flagv & CU_NURB_CYCLIC) vend= fp[nu->pntsv+nu->orderv-1];
else vend= fp[nu->pntsv];
vstep= (vend-vstart)/((nu->flagv & CU_NURB_CYCLIC) ? totv : totv - 1);
@@ -868,29 +871,29 @@ void makeNurbfaces(Nurb *nu, float *coord_array, int rowstride, int resolu, int
jend= (int *)MEM_mallocN(sizeof(float)*totv, "makeNurbfaces5");
/* precalculation of basisv and jstart,jend */
- if(nu->flagv & CU_NURB_CYCLIC) cycl= nu->orderv-1;
+ if (nu->flagv & CU_NURB_CYCLIC) cycl= nu->orderv-1;
else cycl= 0;
v= vstart;
basis= basisv;
curv= totv;
- while(curv--) {
+ while (curv--) {
basisNurb(v, nu->orderv, (short)(nu->pntsv+cycl), nu->knotsv, basis, jstart+curv, jend+curv);
basis+= KNOTSV(nu);
v+= vstep;
}
- if(nu->flagu & CU_NURB_CYCLIC) cycl= nu->orderu-1;
+ if (nu->flagu & CU_NURB_CYCLIC) cycl= nu->orderu-1;
else cycl= 0;
in= coord_array;
u= ustart;
curu= totu;
- while(curu--) {
+ while (curu--) {
basisNurb(u, nu->orderu, (short)(nu->pntsu+cycl), nu->knotsu, basisu, &istart, &iend);
basis= basisv;
curv= totv;
- while(curv--) {
+ while (curv--) {
jsta= jstart[curv];
jen= jend[curv];
@@ -899,21 +902,21 @@ void makeNurbfaces(Nurb *nu, float *coord_array, int rowstride, int resolu, int
sumdiv= 0.0;
fp= sum;
- for(j= jsta; j<=jen; j++) {
+ for (j= jsta; j<=jen; j++) {
- if(j>=nu->pntsv) jofs= (j - nu->pntsv);
+ if (j>=nu->pntsv) jofs= (j - nu->pntsv);
else jofs= j;
bp= nu->bp+ nu->pntsu*jofs+istart-1;
- for(i= istart; i<=iend; i++, fp++) {
+ for (i= istart; i<=iend; i++, fp++) {
- if(i>= nu->pntsu) {
+ if (i>= nu->pntsu) {
iofs= i- nu->pntsu;
bp= nu->bp+ nu->pntsu*jofs+iofs;
}
else bp++;
- if(ratcomp) {
+ if (ratcomp) {
*fp= basisu[i]*basis[j]*bp->vec[3];
sumdiv+= *fp;
}
@@ -921,10 +924,10 @@ void makeNurbfaces(Nurb *nu, float *coord_array, int rowstride, int resolu, int
}
}
- if(ratcomp) {
+ if (ratcomp) {
fp= sum;
- for(j= jsta; j<=jen; j++) {
- for(i= istart; i<=iend; i++, fp++) {
+ for (j= jsta; j<=jen; j++) {
+ for (i= istart; i<=iend; i++, fp++) {
*fp/= sumdiv;
}
}
@@ -932,21 +935,21 @@ void makeNurbfaces(Nurb *nu, float *coord_array, int rowstride, int resolu, int
/* one! (1.0) real point now */
fp= sum;
- for(j= jsta; j<=jen; j++) {
+ for (j= jsta; j<=jen; j++) {
- if(j>=nu->pntsv) jofs= (j - nu->pntsv);
+ if (j>=nu->pntsv) jofs= (j - nu->pntsv);
else jofs= j;
bp= nu->bp+ nu->pntsu*jofs+istart-1;
- for(i= istart; i<=iend; i++, fp++) {
+ for (i= istart; i<=iend; i++, fp++) {
- if(i>= nu->pntsu) {
+ if (i>= nu->pntsu) {
iofs= i- nu->pntsu;
bp= nu->bp+ nu->pntsu*jofs+iofs;
}
else bp++;
- if(*fp != 0.0f) {
+ if (*fp != 0.0f) {
in[0]+= (*fp) * bp->vec[0];
in[1]+= (*fp) * bp->vec[1];
in[2]+= (*fp) * bp->vec[2];
@@ -979,53 +982,53 @@ void makeNurbcurve(Nurb *nu, float *coord_array, float *tilt_array, float *radiu
float *coord_fp= coord_array, *tilt_fp= tilt_array, *radius_fp= radius_array, *weight_fp= weight_array;
int i, len, istart, iend, cycl;
- if(nu->knotsu==NULL) return;
- if(nu->orderu>nu->pntsu) return;
- if(coord_array==NULL) return;
+ if (nu->knotsu==NULL) return;
+ if (nu->orderu>nu->pntsu) return;
+ if (coord_array==NULL) return;
/* allocate and initialize */
len= nu->pntsu;
- if(len==0) return;
+ if (len==0) return;
sum= (float *)MEM_callocN(sizeof(float)*len, "makeNurbcurve1");
resolu= (resolu*SEGMENTSU(nu));
- if(resolu==0) {
+ if (resolu==0) {
MEM_freeN(sum);
return;
}
fp= nu->knotsu;
ustart= fp[nu->orderu-1];
- if(nu->flagu & CU_NURB_CYCLIC) uend= fp[nu->pntsu+nu->orderu-1];
+ if (nu->flagu & CU_NURB_CYCLIC) uend= fp[nu->pntsu+nu->orderu-1];
else uend= fp[nu->pntsu];
ustep= (uend-ustart)/(resolu - ((nu->flagu & CU_NURB_CYCLIC) ? 0 : 1));
basisu= (float *)MEM_mallocN(sizeof(float)*KNOTSU(nu), "makeNurbcurve3");
- if(nu->flagu & CU_NURB_CYCLIC) cycl= nu->orderu-1;
+ if (nu->flagu & CU_NURB_CYCLIC) cycl= nu->orderu-1;
else cycl= 0;
u= ustart;
- while(resolu--) {
+ while (resolu--) {
basisNurb(u, nu->orderu, (short)(nu->pntsu+cycl), nu->knotsu, basisu, &istart, &iend);
/* calc sum */
sumdiv= 0.0;
fp= sum;
bp= nu->bp+ istart-1;
- for(i= istart; i<=iend; i++, fp++) {
+ for (i= istart; i<=iend; i++, fp++) {
- if(i>=nu->pntsu) bp= nu->bp+(i - nu->pntsu);
+ if (i>=nu->pntsu) bp= nu->bp+(i - nu->pntsu);
else bp++;
*fp= basisu[i]*bp->vec[3];
sumdiv+= *fp;
}
- if(sumdiv != 0.0f) if(sumdiv < 0.999f || sumdiv > 1.001f) {
+ if (sumdiv != 0.0f) if(sumdiv < 0.999f || sumdiv > 1.001f) {
/* is normalizing needed? */
fp= sum;
- for(i= istart; i<=iend; i++, fp++) {
+ for (i= istart; i<=iend; i++, fp++) {
*fp/= sumdiv;
}
}
@@ -1033,12 +1036,12 @@ void makeNurbcurve(Nurb *nu, float *coord_array, float *tilt_array, float *radiu
/* one! (1.0) real point */
fp= sum;
bp= nu->bp+ istart-1;
- for(i= istart; i<=iend; i++, fp++) {
+ for (i= istart; i<=iend; i++, fp++) {
- if(i>=nu->pntsu) bp= nu->bp+(i - nu->pntsu);
+ if (i>=nu->pntsu) bp= nu->bp+(i - nu->pntsu);
else bp++;
- if(*fp != 0.0f) {
+ if (*fp != 0.0f) {
coord_fp[0]+= (*fp) * bp->vec[0];
coord_fp[1]+= (*fp) * bp->vec[1];
@@ -1089,7 +1092,7 @@ void forward_diff_bezier(float q0, float q1, float q2, float q3, float *p, int i
q2= 2*rt2+6*rt3;
q3= 6*rt3;
- for(a=0; a<=it; a++) {
+ for (a=0; a<=it; a++) {
*p= q0;
p = (float *)(((char *)p)+stride);
q0+= q1;
@@ -1105,11 +1108,11 @@ static void forward_diff_bezier_cotangent(float *p0, float *p1, float *p2, float
*
* This could also be optimized like forward_diff_bezier */
int a;
- for(a=0; a<=it; a++) {
+ for (a=0; a<=it; a++) {
float t = (float)a / (float)it;
int i;
- for(i=0; i<3; i++) {
+ for (i=0; i<3; i++) {
p[i]= (-6*t + 6)*p0[i] + (18*t - 12)*p1[i] + (-18*t + 6)*p2[i] + (6*t)*p3[i];
}
normalize_v3(p);
@@ -1132,7 +1135,7 @@ float *make_orco_surf(Object *ob)
/* first calculate the size of the datablock */
nu= cu->nurb.first;
- while(nu) {
+ while (nu) {
/* as we want to avoid the seam in a cyclic nurbs
* texture wrapping, reserve extra orco data space to save these extra needed
* vertex based UV coordinates for the meridian vertices.
@@ -1149,7 +1152,7 @@ float *make_orco_surf(Object *ob)
sizev = nu->pntsv*resolv;
if (nu->flagu & CU_NURB_CYCLIC) sizeu++;
if (nu->flagv & CU_NURB_CYCLIC) sizev++;
- if(nu->pntsv>1) tot+= sizeu * sizev;
+ if (nu->pntsv>1) tot+= sizeu * sizev;
nu= nu->next;
}
@@ -1157,24 +1160,24 @@ float *make_orco_surf(Object *ob)
fp= coord_array= MEM_callocN(3*sizeof(float)*tot, "make_orco");
nu= cu->nurb.first;
- while(nu) {
+ while (nu) {
resolu= cu->resolu_ren ? cu->resolu_ren : nu->resolu;
resolv= cu->resolv_ren ? cu->resolv_ren : nu->resolv;
- if(nu->pntsv>1) {
+ if (nu->pntsv>1) {
sizeu = nu->pntsu*resolu;
sizev = nu->pntsv*resolv;
if (nu->flagu & CU_NURB_CYCLIC) sizeu++;
if (nu->flagv & CU_NURB_CYCLIC) sizev++;
- if(cu->flag & CU_UV_ORCO) {
- for(b=0; b< sizeu; b++) {
- for(a=0; a< sizev; a++) {
+ if (cu->flag & CU_UV_ORCO) {
+ for (b=0; b< sizeu; b++) {
+ for (a=0; a< sizev; a++) {
- if(sizev <2) fp[0]= 0.0f;
+ if (sizev <2) fp[0]= 0.0f;
else fp[0]= -1.0f + 2.0f*((float)a)/(sizev - 1);
- if(sizeu <2) fp[1]= 0.0f;
+ if (sizeu <2) fp[1]= 0.0f;
else fp[1]= -1.0f + 2.0f*((float)b)/(sizeu - 1);
fp[2]= 0.0;
@@ -1189,12 +1192,12 @@ float *make_orco_surf(Object *ob)
makeNurbfaces(nu, tdata, 0, resolu, resolv);
- for(b=0; b<sizeu; b++) {
+ for (b=0; b<sizeu; b++) {
int use_b= b;
if (b==sizeu-1 && (nu->flagu & CU_NURB_CYCLIC))
use_b= 0;
- for(a=0; a<sizev; a++) {
+ for (a=0; a<sizev; a++) {
int use_a= a;
if (a==sizev-1 && (nu->flagv & CU_NURB_CYCLIC))
use_a= 0;
@@ -1235,7 +1238,8 @@ float *make_orco_curve(Scene *scene, Object *ob)
for (dl=disp.first; dl; dl=dl->next) {
if (dl->type==DL_INDEX3) {
numVerts += dl->nr;
- } else if (dl->type==DL_SURF) {
+ }
+ else if (dl->type==DL_SURF) {
/* convertblender.c uses the Surface code for creating renderfaces when cyclic U only (closed circle beveling) */
if (dl->flag & DL_CYCL_U) {
if (dl->flag & DL_CYCL_V)
@@ -1256,7 +1260,8 @@ float *make_orco_curve(Scene *scene, Object *ob)
fp[0]= 2.0f*u/(dl->nr-1) - 1.0f;
fp[1]= 0.0;
fp[2]= 0.0;
- } else {
+ }
+ else {
copy_v3_v3(fp, &dl->verts[u*3]);
fp[0]= (fp[0]-cu->loc[0])/cu->size[0];
@@ -1264,7 +1269,8 @@ float *make_orco_curve(Scene *scene, Object *ob)
fp[2]= (fp[2]-cu->loc[2])/cu->size[2];
}
}
- } else if (dl->type==DL_SURF) {
+ }
+ else if (dl->type==DL_SURF) {
int sizeu= dl->nr, sizev= dl->parts;
/* exception as handled in convertblender.c too */
@@ -1280,7 +1286,8 @@ float *make_orco_curve(Scene *scene, Object *ob)
fp[0]= 2.0f*u/(sizev - 1) - 1.0f;
fp[1]= 2.0f*v/(sizeu - 1) - 1.0f;
fp[2]= 0.0;
- } else {
+ }
+ else {
float *vert;
int realv= v % dl->nr;
int realu= u % dl->parts;
@@ -1316,13 +1323,13 @@ void makebevelcurve(Scene *scene, Object *ob, ListBase *disp, int forRender)
disp->first = disp->last = NULL;
/* if a font object is being edited, then do nothing */
-// XXX if( ob == obedit && ob->type == OB_FONT ) return;
+// XXX if ( ob == obedit && ob->type == OB_FONT ) return;
- if(cu->bevobj) {
+ if (cu->bevobj) {
if (cu->bevobj->type!=OB_CURVE) return;
bevcu= cu->bevobj->data;
- if(bevcu->ext1==0.0f && bevcu->ext2==0.0f) {
+ if (bevcu->ext1==0.0f && bevcu->ext2==0.0f) {
ListBase bevdisp= {NULL, NULL};
facx= cu->bevobj->size[0];
facy= cu->bevobj->size[1];
@@ -1330,27 +1337,28 @@ void makebevelcurve(Scene *scene, Object *ob, ListBase *disp, int forRender)
if (forRender) {
makeDispListCurveTypes_forRender(scene, cu->bevobj, &bevdisp, NULL, 0);
dl= bevdisp.first;
- } else {
+ }
+ else {
dl= cu->bevobj->disp.first;
- if(dl==NULL) {
+ if (dl==NULL) {
makeDispListCurveTypes(scene, cu->bevobj, 0);
dl= cu->bevobj->disp.first;
}
}
- while(dl) {
+ while (dl) {
if ELEM(dl->type, DL_POLY, DL_SEGM) {
dlnew= MEM_mallocN(sizeof(DispList), "makebevelcurve1");
*dlnew= *dl;
dlnew->verts= MEM_mallocN(3*sizeof(float)*dl->parts*dl->nr, "makebevelcurve1");
memcpy(dlnew->verts, dl->verts, 3*sizeof(float)*dl->parts*dl->nr);
- if(dlnew->type==DL_SEGM) dlnew->flag |= (DL_FRONT_CURVE|DL_BACK_CURVE);
+ if (dlnew->type==DL_SEGM) dlnew->flag |= (DL_FRONT_CURVE|DL_BACK_CURVE);
BLI_addtail(disp, dlnew);
fp= dlnew->verts;
nr= dlnew->parts*dlnew->nr;
- while(nr--) {
+ while (nr--) {
fp[2]= fp[1]*facy;
fp[1]= -fp[0]*facx;
fp[0]= 0.0;
@@ -1363,10 +1371,10 @@ void makebevelcurve(Scene *scene, Object *ob, ListBase *disp, int forRender)
freedisplist(&bevdisp);
}
}
- else if(cu->ext1==0.0f && cu->ext2==0.0f) {
+ else if (cu->ext1==0.0f && cu->ext2==0.0f) {
;
}
- else if(cu->ext2==0.0f) {
+ else if (cu->ext2==0.0f) {
dl= MEM_callocN(sizeof(DispList), "makebevelcurve2");
dl->verts= MEM_mallocN(2*3*sizeof(float), "makebevelcurve2");
BLI_addtail(disp, dl);
@@ -1381,7 +1389,7 @@ void makebevelcurve(Scene *scene, Object *ob, ListBase *disp, int forRender)
fp[3]= fp[4]= 0.0;
fp[5]= cu->ext1;
}
- else if( (cu->flag & (CU_FRONT|CU_BACK))==0 && cu->ext1==0.0f) { // we make a full round bevel in that case
+ else if ( (cu->flag & (CU_FRONT|CU_BACK))==0 && cu->ext1==0.0f) { // we make a full round bevel in that case
nr= 4+ 2*cu->bevresol;
@@ -1398,7 +1406,7 @@ void makebevelcurve(Scene *scene, Object *ob, ListBase *disp, int forRender)
dangle= (2.0f*(float)M_PI/(nr));
angle= -(nr-1)*dangle;
- for(a=0; a<nr; a++) {
+ for (a=0; a<nr; a++) {
fp[0]= 0.0;
fp[1]= (cosf(angle)*(cu->ext2));
fp[2]= (sinf(angle)*(cu->ext2)) - cu->ext1;
@@ -1412,9 +1420,9 @@ void makebevelcurve(Scene *scene, Object *ob, ListBase *disp, int forRender)
/* bevel now in three parts, for proper vertex normals */
/* part 1, back */
- if((cu->flag & CU_BACK) || !(cu->flag & CU_FRONT)) {
+ if ((cu->flag & CU_BACK) || !(cu->flag & CU_FRONT)) {
dnr= nr= 2+ cu->bevresol;
- if( (cu->flag & (CU_FRONT|CU_BACK))==0)
+ if ( (cu->flag & (CU_FRONT|CU_BACK))==0)
nr= 3+ 2*cu->bevresol;
dl= MEM_callocN(sizeof(DispList), "makebevelcurve p1");
@@ -1430,7 +1438,7 @@ void makebevelcurve(Scene *scene, Object *ob, ListBase *disp, int forRender)
dangle= (0.5*M_PI/(dnr-1));
angle= -(nr-1)*dangle;
- for(a=0; a<nr; a++) {
+ for (a=0; a<nr; a++) {
fp[0]= 0.0;
fp[1]= (float)(cosf(angle)*(cu->ext2));
fp[2]= (float)(sinf(angle)*(cu->ext2)) - cu->ext1;
@@ -1440,7 +1448,7 @@ void makebevelcurve(Scene *scene, Object *ob, ListBase *disp, int forRender)
}
/* part 2, sidefaces */
- if(cu->ext1!=0.0f) {
+ if (cu->ext1!=0.0f) {
nr= 2;
dl= MEM_callocN(sizeof(DispList), "makebevelcurve p2");
@@ -1456,7 +1464,7 @@ void makebevelcurve(Scene *scene, Object *ob, ListBase *disp, int forRender)
fp[4]= cu->ext2;
fp[5]= cu->ext1;
- if( (cu->flag & (CU_FRONT|CU_BACK))==0) {
+ if ( (cu->flag & (CU_FRONT|CU_BACK))==0) {
dl= MEM_dupallocN(dl);
dl->verts= MEM_dupallocN(dl->verts);
BLI_addtail(disp, dl);
@@ -1470,9 +1478,9 @@ void makebevelcurve(Scene *scene, Object *ob, ListBase *disp, int forRender)
}
/* part 3, front */
- if((cu->flag & CU_FRONT) || !(cu->flag & CU_BACK)) {
+ if ((cu->flag & CU_FRONT) || !(cu->flag & CU_BACK)) {
dnr= nr= 2+ cu->bevresol;
- if( (cu->flag & (CU_FRONT|CU_BACK))==0)
+ if ( (cu->flag & (CU_FRONT|CU_BACK))==0)
nr= 3+ 2*cu->bevresol;
dl= MEM_callocN(sizeof(DispList), "makebevelcurve p3");
@@ -1488,7 +1496,7 @@ void makebevelcurve(Scene *scene, Object *ob, ListBase *disp, int forRender)
angle= 0.0;
dangle= (0.5*M_PI/(dnr-1));
- for(a=0; a<nr; a++) {
+ for (a=0; a<nr; a++) {
fp[0]= 0.0;
fp[1]= (float)(cosf(angle)*(cu->ext2));
fp[2]= (float)(sinf(angle)*(cu->ext2)) + cu->ext1;
@@ -1512,23 +1520,24 @@ static int cu_isectLL(const float v1[3], const float v2[3], const float v3[3], c
float deler;
deler= (v1[cox]-v2[cox])*(v3[coy]-v4[coy])-(v3[cox]-v4[cox])*(v1[coy]-v2[coy]);
- if(deler==0.0f) return -1;
+ if (deler==0.0f) return -1;
*labda= (v1[coy]-v3[coy])*(v3[cox]-v4[cox])-(v1[cox]-v3[cox])*(v3[coy]-v4[coy]);
*labda= -(*labda/deler);
deler= v3[coy]-v4[coy];
- if(deler==0) {
+ if (deler==0) {
deler=v3[cox]-v4[cox];
*mu= -(*labda*(v2[cox]-v1[cox])+v1[cox]-v3[cox])/deler;
- } else {
+ }
+ else {
*mu= -(*labda*(v2[coy]-v1[coy])+v1[coy]-v3[coy])/deler;
}
vec[cox]= *labda*(v2[cox]-v1[cox])+v1[cox];
vec[coy]= *labda*(v2[coy]-v1[coy])+v1[coy];
- if(*labda>=0.0f && *labda<=1.0f && *mu>=0.0f && *mu<=1.0f) {
- if(*labda==0.0f || *labda==1.0f || *mu==0.0f || *mu==1.0f) return 1;
+ if (*labda>=0.0f && *labda<=1.0f && *mu>=0.0f && *mu<=1.0f) {
+ if (*labda==0.0f || *labda==1.0f || *mu==0.0f || *mu==1.0f) return 1;
return 2;
}
return 0;
@@ -1559,22 +1568,22 @@ static short bevelinside(BevList *bl1,BevList *bl2)
nr= bl1->nr;
prevbevp= bevp+(nr-1);
- while(nr--) {
+ while (nr--) {
min= prevbevp->vec[1];
max= bevp->vec[1];
- if(max<min) {
+ if (max<min) {
min= max;
max= prevbevp->vec[1];
}
- if(min!=max) {
- if(min<=hvec1[1] && max>=hvec1[1]) {
+ if (min!=max) {
+ if (min<=hvec1[1] && max>=hvec1[1]) {
/* there's a transition, calc intersection point */
mode= cu_isectLL(prevbevp->vec, bevp->vec, hvec1, hvec2, 0, 1, &lab, &mu, vec);
/* if lab==0.0 or lab==1.0 then the edge intersects exactly a transition
* only allow for one situation: we choose lab= 1.0
*/
- if(mode >= 0 && lab != 0.0f) {
- if(vec[0]<hvec1[0]) links++;
+ if (mode >= 0 && lab != 0.0f) {
+ if (vec[0]<hvec1[0]) links++;
else rechts++;
}
}
@@ -1583,7 +1592,7 @@ static short bevelinside(BevList *bl1,BevList *bl2)
bevp++;
}
- if( (links & 1) && (rechts & 1) ) return 1;
+ if ( (links & 1) && (rechts & 1) ) return 1;
return 0;
}
@@ -1598,8 +1607,8 @@ static int vergxcobev(const void *a1, const void *a2)
{
const struct bevelsort *x1=a1,*x2=a2;
- if( x1->left > x2->left ) return 1;
- else if( x1->left < x2->left) return -1;
+ if ( x1->left > x2->left ) return 1;
+ else if ( x1->left < x2->left) return -1;
return 0;
}
@@ -1611,8 +1620,8 @@ static void calc_bevel_sin_cos(float x1, float y1, float x2, float y2, float *si
t01= (float)sqrt(x1*x1+y1*y1);
t02= (float)sqrt(x2*x2+y2*y2);
- if(t01==0.0f) t01= 1.0f;
- if(t02==0.0f) t02= 1.0f;
+ if (t01==0.0f) t01= 1.0f;
+ if (t02==0.0f) t02= 1.0f;
x1/=t01;
y1/=t01;
@@ -1620,18 +1629,19 @@ static void calc_bevel_sin_cos(float x1, float y1, float x2, float y2, float *si
y2/=t02;
t02= x1*x2+y1*y2;
- if(fabs(t02)>=1.0) t02= .5*M_PI;
+ if (fabs(t02)>=1.0) t02= .5*M_PI;
else t02= (saacos(t02))/2.0f;
t02= (float)sin(t02);
- if(t02==0.0f) t02= 1.0f;
+ if (t02==0.0f) t02= 1.0f;
x3= x1-x2;
y3= y1-y2;
- if(x3==0 && y3==0) {
+ if (x3==0 && y3==0) {
x3= y1;
y3= -x1;
- } else {
+ }
+ else {
t01= (float)sqrt(x3*x3+y3*y3);
x3/=t01;
y3/=t01;
@@ -1648,21 +1658,21 @@ static void alfa_bezpart(BezTriple *prevbezt, BezTriple *bezt, Nurb *nu, float *
float fac, dfac, t[4];
int a;
- if(tilt_array==NULL && radius_array==NULL)
+ if (tilt_array==NULL && radius_array==NULL)
return;
last= nu->bezt+(nu->pntsu-1);
/* returns a point */
- if(prevbezt==nu->bezt) {
- if(nu->flagu & CU_NURB_CYCLIC) pprev= last;
+ if (prevbezt==nu->bezt) {
+ if (nu->flagu & CU_NURB_CYCLIC) pprev= last;
else pprev= prevbezt;
}
else pprev= prevbezt-1;
/* next point */
- if(bezt==last) {
- if(nu->flagu & CU_NURB_CYCLIC) next= nu->bezt;
+ if (bezt==last) {
+ if (nu->flagu & CU_NURB_CYCLIC) next= nu->bezt;
else next= bezt;
}
else next= bezt+1;
@@ -1670,11 +1680,12 @@ static void alfa_bezpart(BezTriple *prevbezt, BezTriple *bezt, Nurb *nu, float *
fac= 0.0;
dfac= 1.0f/(float)resolu;
- for(a=0; a<resolu; a++, fac+= dfac) {
+ for (a=0; a<resolu; a++, fac+= dfac) {
if (tilt_array) {
if (nu->tilt_interp==KEY_CU_EASE) { /* May as well support for tilt also 2.47 ease interp */
*tilt_array = prevbezt->alfa + (bezt->alfa - prevbezt->alfa)*(3.0f*fac*fac - 2.0f*fac*fac*fac);
- } else {
+ }
+ else {
key_curve_position_weights(fac, t, nu->tilt_interp);
*tilt_array= t[0]*pprev->alfa + t[1]*prevbezt->alfa + t[2]*bezt->alfa + t[3]*next->alfa;
}
@@ -1688,7 +1699,8 @@ static void alfa_bezpart(BezTriple *prevbezt, BezTriple *bezt, Nurb *nu, float *
* Note! - this only takes the 2 points into account,
* giving much more localized results to changes in radius, sometimes you want that */
*radius_array = prevbezt->radius + (bezt->radius - prevbezt->radius)*(3.0f*fac*fac - 2.0f*fac*fac*fac);
- } else {
+ }
+ else {
/* reuse interpolation from tilt if we can */
if (tilt_array==NULL || nu->tilt_interp != nu->radius_interp) {
@@ -1700,7 +1712,7 @@ static void alfa_bezpart(BezTriple *prevbezt, BezTriple *bezt, Nurb *nu, float *
radius_array = (float *)(((char *)radius_array) + stride);
}
- if(weight_array) {
+ if (weight_array) {
/* basic interpolation for now, could copy tilt interp too */
*weight_array = prevbezt->weight + (bezt->weight - prevbezt->weight)*(3.0f*fac*fac - 2.0f*fac*fac*fac);
@@ -1741,7 +1753,7 @@ static void bevel_list_calc_bisect(BevList *bl)
bevp0= bevp1-1;
nr= bl->nr;
- while(nr--) {
+ while (nr--) {
/* totally simple */
bisect_v3_v3v3v3(bevp1->dir, bevp0->vec, bevp1->vec, bevp2->vec);
@@ -1760,8 +1772,8 @@ static void bevel_list_flip_tangents(BevList *bl)
bevp0= bevp1-1;
nr= bl->nr;
- while(nr--) {
- if(RAD2DEGF(angle_v2v2(bevp0->tan, bevp1->tan)) > 90.0f)
+ while (nr--) {
+ if (RAD2DEGF(angle_v2v2(bevp0->tan, bevp1->tan)) > 90.0f)
negate_v3(bevp1->tan);
bevp0= bevp1;
@@ -1780,7 +1792,7 @@ static void bevel_list_apply_tilt(BevList *bl)
bevp1= bevp2+(bl->nr-1);
nr= bl->nr;
- while(nr--) {
+ while (nr--) {
axis_angle_to_quat(q, bevp1->dir, bevp1->alfa);
mul_qt_qtqt(bevp1->quat, q, bevp1->quat);
normalize_qt(bevp1->quat);
@@ -1799,7 +1811,7 @@ static void bevel_list_smooth(BevList *bl, int smooth_iter)
float bevp0_quat[4];
int a;
- for(a=0; a < smooth_iter; a++) {
+ for (a=0; a < smooth_iter; a++) {
bevp2= (BevPoint *)(bl+1);
bevp1= bevp2+(bl->nr-1);
@@ -1807,7 +1819,7 @@ static void bevel_list_smooth(BevList *bl, int smooth_iter)
nr= bl->nr;
- if(bl->poly== -1) { /* check its not cyclic */
+ if (bl->poly== -1) { /* check its not cyclic */
/* skip the first point */
/* bevp0= bevp1; */
bevp1= bevp2;
@@ -1823,7 +1835,7 @@ static void bevel_list_smooth(BevList *bl, int smooth_iter)
copy_qt_qt(bevp0_quat, bevp0->quat);
- while(nr--) {
+ while (nr--) {
/* interpolate quats */
float zaxis[3] = {0,0,1}, cross[3], q2[4];
interp_qt_qtqt(q, bevp0_quat, bevp2->quat, 0.5);
@@ -1857,7 +1869,7 @@ static void make_bevel_list_3D_zup(BevList *bl)
bevp0= bevp1-1;
nr= bl->nr;
- while(nr--) {
+ while (nr--) {
/* totally simple */
bisect_v3_v3v3v3(bevp1->dir, bevp0->vec, bevp1->vec, bevp2->vec);
vec_to_quat( bevp1->quat,bevp1->dir, 5, 1);
@@ -1881,15 +1893,15 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl)
bevp0= bevp1-1;
nr= bl->nr;
- while(nr--) {
+ while (nr--) {
- if(nr+4 > bl->nr) { /* first time and second time, otherwise first point adjusts last */
+ if (nr+4 > bl->nr) { /* first time and second time, otherwise first point adjusts last */
vec_to_quat( bevp1->quat,bevp1->dir, 5, 1);
}
else {
float angle= angle_normalized_v3v3(bevp0->dir, bevp1->dir);
- if(angle > 0.0f) { /* otherwise we can keep as is */
+ if (angle > 0.0f) { /* otherwise we can keep as is */
float cross_tmp[3];
cross_v3_v3v3(cross_tmp, bevp0->dir, bevp1->dir);
axis_angle_to_quat(q, cross_tmp, angle);
@@ -1905,7 +1917,7 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl)
bevp2++;
}
- if(bl->poly != -1) { /* check for cyclic */
+ if (bl->poly != -1) { /* check for cyclic */
/* Need to correct for the start/end points not matching
* do this by calculating the tilt angle difference, then apply
@@ -1949,7 +1961,7 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl)
/* flip rotation if needs be */
cross_v3_v3v3(cross_tmp, vec_1, vec_2);
normalize_v3(cross_tmp);
- if(angle_normalized_v3v3(bevp_first->dir, cross_tmp) < DEG2RADF(90.0f))
+ if (angle_normalized_v3v3(bevp_first->dir, cross_tmp) < DEG2RADF(90.0f))
angle = -angle;
bevp2= (BevPoint *)(bl+1);
@@ -1957,7 +1969,7 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl)
bevp0= bevp1-1;
nr= bl->nr;
- while(nr--) {
+ while (nr--) {
ang_fac= angle * (1.0f-((float)nr/bl->nr)); /* also works */
axis_angle_to_quat(q, bevp1->dir, ang_fac);
@@ -1978,7 +1990,7 @@ static void make_bevel_list_3D_tangent(BevList *bl)
float bevp0_tan[3], cross_tmp[3];
bevel_list_calc_bisect(bl);
- if(bl->poly== -1) /* check its not cyclic */
+ if (bl->poly== -1) /* check its not cyclic */
bevel_list_cyclic_fix_3D(bl); // XXX - run this now so tangents will be right before doing the flipping
bevel_list_flip_tangents(bl);
@@ -1988,7 +2000,7 @@ static void make_bevel_list_3D_tangent(BevList *bl)
bevp0= bevp1-1;
nr= bl->nr;
- while(nr--) {
+ while (nr--) {
cross_v3_v3v3(cross_tmp, bevp1->tan, bevp1->dir);
cross_v3_v3v3(bevp1->tan, cross_tmp, bevp1->dir);
@@ -2008,7 +2020,7 @@ static void make_bevel_list_3D_tangent(BevList *bl)
copy_v3_v3(bevp0_tan, bevp0->tan);
nr= bl->nr;
- while(nr--) {
+ while (nr--) {
/* make perpendicular, modify tan in place, is ok */
float cross_tmp[3];
@@ -2037,10 +2049,10 @@ static void make_bevel_list_3D(BevList *bl, int smooth_iter, int twist_mode)
make_bevel_list_3D_zup(bl);
}
- if(bl->poly== -1) /* check its not cyclic */
+ if (bl->poly== -1) /* check its not cyclic */
bevel_list_cyclic_fix_3D(bl);
- if(smooth_iter)
+ if (smooth_iter)
bevel_list_smooth(bl, smooth_iter);
bevel_list_apply_tilt(bl);
@@ -2099,12 +2111,15 @@ void makeBevelList(Object *ob)
/* STEP 1: MAKE POLYS */
BLI_freelistN(&(cu->bev));
- if(cu->editnurb && ob->type!=OB_FONT) {
+ if (cu->editnurb && ob->type!=OB_FONT) {
ListBase *nurbs= curve_editnurbs(cu);
- nu= nurbs->first;
- } else nu= cu->nurb.first;
+ nu = nurbs->first;
+ }
+ else {
+ nu = cu->nurb.first;
+ }
- while(nu) {
+ while (nu) {
/* check if we will calculate tilt data */
do_tilt = CU_DO_TILT(cu, nu);
@@ -2113,29 +2128,30 @@ void makeBevelList(Object *ob)
/* check we are a single point? also check we are not a surface and that the orderu is sane,
* enforced in the UI but can go wrong possibly */
- if(!check_valid_nurb_u(nu)) {
+ if (!check_valid_nurb_u(nu)) {
bl= MEM_callocN(sizeof(BevList)+1*sizeof(BevPoint), "makeBevelList1");
BLI_addtail(&(cu->bev), bl);
bl->nr= 0;
- } else {
- if(G.rendering && cu->resolu_ren!=0)
+ }
+ else {
+ if (G.rendering && cu->resolu_ren!=0)
resolu= cu->resolu_ren;
else
resolu= nu->resolu;
- if(nu->type == CU_POLY) {
+ if (nu->type == CU_POLY) {
len= nu->pntsu;
bl= MEM_callocN(sizeof(BevList)+len*sizeof(BevPoint), "makeBevelList2");
BLI_addtail(&(cu->bev), bl);
- if(nu->flagu & CU_NURB_CYCLIC) bl->poly= 0;
+ if (nu->flagu & CU_NURB_CYCLIC) bl->poly= 0;
else bl->poly= -1;
bl->nr= len;
bl->dupe_nr= 0;
bevp= (BevPoint *)(bl+1);
bp= nu->bp;
- while(len--) {
+ while (len--) {
copy_v3_v3(bevp->vec, bp->vec);
bevp->alfa= bp->alfa;
bevp->radius= bp->radius;
@@ -2145,19 +2161,19 @@ void makeBevelList(Object *ob)
bp++;
}
}
- else if(nu->type == CU_BEZIER) {
+ else if (nu->type == CU_BEZIER) {
len= resolu*(nu->pntsu+ (nu->flagu & CU_NURB_CYCLIC) -1)+1; /* in case last point is not cyclic */
bl= MEM_callocN(sizeof(BevList)+len*sizeof(BevPoint), "makeBevelBPoints");
BLI_addtail(&(cu->bev), bl);
- if(nu->flagu & CU_NURB_CYCLIC) bl->poly= 0;
+ if (nu->flagu & CU_NURB_CYCLIC) bl->poly= 0;
else bl->poly= -1;
bevp= (BevPoint *)(bl+1);
a= nu->pntsu-1;
bezt= nu->bezt;
- if(nu->flagu & CU_NURB_CYCLIC) {
+ if (nu->flagu & CU_NURB_CYCLIC) {
a++;
prevbezt= nu->bezt+(nu->pntsu-1);
}
@@ -2166,8 +2182,8 @@ void makeBevelList(Object *ob)
bezt++;
}
- while(a--) {
- if(prevbezt->h2==HD_VECT && bezt->h1==HD_VECT) {
+ while (a--) {
+ if (prevbezt->h2==HD_VECT && bezt->h1==HD_VECT) {
copy_v3_v3(bevp->vec, prevbezt->vec[1]);
bevp->alfa= prevbezt->alfa;
@@ -2184,7 +2200,7 @@ void makeBevelList(Object *ob)
int j;
/* BevPoint must stay aligned to 4 so sizeof(BevPoint)/sizeof(float) works */
- for(j=0; j<3; j++) {
+ for (j=0; j<3; j++) {
forward_diff_bezier( prevbezt->vec[1][j], prevbezt->vec[2][j],
bezt->vec[0][j], bezt->vec[1][j],
&(bevp->vec[j]), resolu, sizeof(BevPoint));
@@ -2198,7 +2214,7 @@ void makeBevelList(Object *ob)
resolu, sizeof(BevPoint));
- if(cu->twist_mode==CU_TWIST_TANGENT) {
+ if (cu->twist_mode==CU_TWIST_TANGENT) {
forward_diff_bezier_cotangent(
prevbezt->vec[1], prevbezt->vec[2],
bezt->vec[0], bezt->vec[1],
@@ -2206,12 +2222,12 @@ void makeBevelList(Object *ob)
}
/* indicate with handlecodes double points */
- if(prevbezt->h1==prevbezt->h2) {
- if(prevbezt->h1==0 || prevbezt->h1==HD_VECT) bevp->split_tag= TRUE;
+ if (prevbezt->h1==prevbezt->h2) {
+ if (prevbezt->h1==0 || prevbezt->h1==HD_VECT) bevp->split_tag= TRUE;
}
else {
- if(prevbezt->h1==0 || prevbezt->h1==HD_VECT) bevp->split_tag= TRUE;
- else if(prevbezt->h2==0 || prevbezt->h2==HD_VECT) bevp->split_tag= TRUE;
+ if (prevbezt->h1==0 || prevbezt->h1==HD_VECT) bevp->split_tag= TRUE;
+ else if (prevbezt->h2==0 || prevbezt->h2==HD_VECT) bevp->split_tag= TRUE;
}
bl->nr+= resolu;
bevp+= resolu;
@@ -2220,7 +2236,7 @@ void makeBevelList(Object *ob)
bezt++;
}
- if((nu->flagu & CU_NURB_CYCLIC)==0) { /* not cyclic: endpoint */
+ if ((nu->flagu & CU_NURB_CYCLIC)==0) { /* not cyclic: endpoint */
copy_v3_v3(bevp->vec, prevbezt->vec[1]);
bevp->alfa= prevbezt->alfa;
bevp->radius= prevbezt->radius;
@@ -2228,15 +2244,15 @@ void makeBevelList(Object *ob)
bl->nr++;
}
}
- else if(nu->type == CU_NURBS) {
- if(nu->pntsv==1) {
+ else if (nu->type == CU_NURBS) {
+ if (nu->pntsv==1) {
len= (resolu*SEGMENTSU(nu));
bl= MEM_callocN(sizeof(BevList)+len*sizeof(BevPoint), "makeBevelList3");
BLI_addtail(&(cu->bev), bl);
bl->nr= len;
bl->dupe_nr= 0;
- if(nu->flagu & CU_NURB_CYCLIC) bl->poly= 0;
+ if (nu->flagu & CU_NURB_CYCLIC) bl->poly= 0;
else bl->poly= -1;
bevp= (BevPoint *)(bl+1);
@@ -2253,16 +2269,16 @@ void makeBevelList(Object *ob)
/* STEP 2: DOUBLE POINTS AND AUTOMATIC RESOLUTION, REDUCE DATABLOCKS */
bl= cu->bev.first;
- while(bl) {
+ while (bl) {
if (bl->nr) { /* null bevel items come from single points */
nr= bl->nr;
bevp1= (BevPoint *)(bl+1);
bevp0= bevp1+(nr-1);
nr--;
- while(nr--) {
- if( fabs(bevp0->vec[0]-bevp1->vec[0])<0.00001 ) {
- if( fabs(bevp0->vec[1]-bevp1->vec[1])<0.00001 ) {
- if( fabs(bevp0->vec[2]-bevp1->vec[2])<0.00001 ) {
+ while (nr--) {
+ if ( fabs(bevp0->vec[0]-bevp1->vec[0])<0.00001 ) {
+ if ( fabs(bevp0->vec[1]-bevp1->vec[1])<0.00001 ) {
+ if ( fabs(bevp0->vec[2]-bevp1->vec[2])<0.00001 ) {
bevp0->dupe_tag= TRUE;
bl->dupe_nr++;
}
@@ -2275,9 +2291,9 @@ void makeBevelList(Object *ob)
bl= bl->next;
}
bl= cu->bev.first;
- while(bl) {
+ while (bl) {
blnext= bl->next;
- if(bl->nr && bl->dupe_nr) {
+ if (bl->nr && bl->dupe_nr) {
nr= bl->nr- bl->dupe_nr+1; /* +1 because vectorbezier sets flag too */
blnew= MEM_mallocN(sizeof(BevList)+nr*sizeof(BevPoint), "makeBevelList4");
memcpy(blnew, bl, sizeof(BevList));
@@ -2287,8 +2303,8 @@ void makeBevelList(Object *ob)
bevp0= (BevPoint *)(bl+1);
bevp1= (BevPoint *)(blnew+1);
nr= bl->nr;
- while(nr--) {
- if(bevp0->dupe_tag==0) {
+ while (nr--) {
+ if (bevp0->dupe_tag==0) {
memcpy(bevp1, bevp0, sizeof(BevPoint));
bevp1++;
blnew->nr++;
@@ -2304,8 +2320,8 @@ void makeBevelList(Object *ob)
/* STEP 3: POLYS COUNT AND AUTOHOLE */
bl= cu->bev.first;
poly= 0;
- while(bl) {
- if(bl->nr && bl->poly>=0) {
+ while (bl) {
+ if (bl->nr && bl->poly>=0) {
poly++;
bl->poly= poly;
bl->hole= 0;
@@ -2315,17 +2331,17 @@ void makeBevelList(Object *ob)
/* find extreme left points, also test (turning) direction */
- if(poly>0) {
+ if (poly>0) {
sd= sortdata= MEM_mallocN(sizeof(struct bevelsort)*poly, "makeBevelList5");
bl= cu->bev.first;
- while(bl) {
- if(bl->poly>0) {
+ while (bl) {
+ if (bl->poly>0) {
min= 300000.0;
bevp= (BevPoint *)(bl+1);
nr= bl->nr;
- while(nr--) {
- if(min>bevp->vec[0]) {
+ while (nr--) {
+ if (min>bevp->vec[0]) {
min= bevp->vec[0];
bevp1= bevp;
}
@@ -2335,15 +2351,15 @@ void makeBevelList(Object *ob)
sd->left= min;
bevp= (BevPoint *)(bl+1);
- if(bevp1== bevp) bevp0= bevp+ (bl->nr-1);
+ if (bevp1== bevp) bevp0= bevp+ (bl->nr-1);
else bevp0= bevp1-1;
bevp= bevp+ (bl->nr-1);
- if(bevp1== bevp) bevp2= (BevPoint *)(bl+1);
+ if (bevp1== bevp) bevp2= (BevPoint *)(bl+1);
else bevp2= bevp1+1;
inp= (bevp1->vec[0]- bevp0->vec[0]) * (bevp0->vec[1]- bevp2->vec[1]) + (bevp0->vec[1]- bevp1->vec[1]) * (bevp0->vec[0]- bevp2->vec[0]);
- if(inp > 0.0f) sd->dir= 1;
+ if (inp > 0.0f) sd->dir= 1;
else sd->dir= 0;
sd++;
@@ -2354,11 +2370,11 @@ void makeBevelList(Object *ob)
qsort(sortdata,poly,sizeof(struct bevelsort), vergxcobev);
sd= sortdata+1;
- for(a=1; a<poly; a++, sd++) {
+ for (a=1; a<poly; a++, sd++) {
bl= sd->bl; /* is bl a hole? */
sd1= sortdata+ (a-1);
- for(b=a-1; b>=0; b--, sd1--) { /* all polys to the left */
- if(bevelinside(sd1->bl, bl)) {
+ for (b=a-1; b>=0; b--, sd1--) { /* all polys to the left */
+ if (bevelinside(sd1->bl, bl)) {
bl->hole= 1- sd1->bl->hole;
break;
}
@@ -2366,15 +2382,15 @@ void makeBevelList(Object *ob)
}
/* turning direction */
- if((cu->flag & CU_3D)==0) {
+ if ((cu->flag & CU_3D)==0) {
sd= sortdata;
- for(a=0; a<poly; a++, sd++) {
- if(sd->bl->hole==sd->dir) {
+ for (a=0; a<poly; a++, sd++) {
+ if (sd->bl->hole==sd->dir) {
bl= sd->bl;
bevp1= (BevPoint *)(bl+1);
bevp2= bevp1+ (bl->nr-1);
nr= bl->nr/2;
- while(nr--) {
+ while (nr--) {
SWAP(BevPoint, *bevp1, *bevp2);
bevp1++;
bevp2--;
@@ -2386,16 +2402,16 @@ void makeBevelList(Object *ob)
}
/* STEP 4: 2D-COSINES or 3D ORIENTATION */
- if((cu->flag & CU_3D)==0) {
+ if ((cu->flag & CU_3D)==0) {
/* note: bevp->dir and bevp->quat are not needed for beveling but are
* used when making a path from a 2D curve, therefor they need to be set - Campbell */
bl= cu->bev.first;
- while(bl) {
+ while (bl) {
- if(bl->nr < 2) {
+ if (bl->nr < 2) {
/* do nothing */
}
- else if(bl->nr==2) { /* 2 pnt, treat separate */
+ else if (bl->nr==2) { /* 2 pnt, treat separate */
bevp2= (BevPoint *)(bl+1);
bevp1= bevp2+1;
@@ -2415,7 +2431,7 @@ void makeBevelList(Object *ob)
bevp0= bevp1-1;
nr= bl->nr;
- while(nr--) {
+ while (nr--) {
x1= bevp1->vec[0]- bevp0->vec[0];
x2= bevp1->vec[0]- bevp2->vec[0];
y1= bevp1->vec[1]- bevp0->vec[1];
@@ -2435,7 +2451,7 @@ void makeBevelList(Object *ob)
}
/* correct non-cyclic cases */
- if(bl->poly== -1) {
+ if (bl->poly== -1) {
bevp= (BevPoint *)(bl+1);
bevp1= bevp+1;
bevp->sina= bevp1->sina;
@@ -2455,12 +2471,12 @@ void makeBevelList(Object *ob)
}
else { /* 3D Curves */
bl= cu->bev.first;
- while(bl) {
+ while (bl) {
- if(bl->nr < 2) {
+ if (bl->nr < 2) {
/* do nothing */
}
- else if(bl->nr==2) { /* 2 pnt, treat separate */
+ else if (bl->nr==2) { /* 2 pnt, treat separate */
make_bevel_list_segment_3D(bl);
}
else {
@@ -2486,13 +2502,13 @@ static void calchandleNurb_intern(BezTriple *bezt, BezTriple *prev, BezTriple *n
float len, len_a, len_b;
const float eps= 1e-5;
- if(bezt->h1==0 && bezt->h2==0) {
+ if (bezt->h1==0 && bezt->h2==0) {
return;
}
p2= bezt->vec[1];
- if(prev==NULL) {
+ if (prev==NULL) {
p3= next->vec[1];
pt[0]= 2.0f*p2[0] - p3[0];
pt[1]= 2.0f*p2[1] - p3[1];
@@ -2503,7 +2519,7 @@ static void calchandleNurb_intern(BezTriple *bezt, BezTriple *prev, BezTriple *n
p1= prev->vec[1];
}
- if(next==NULL) {
+ if (next==NULL) {
pt[0]= 2.0f*p2[0] - p1[0];
pt[1]= 2.0f*p2[1] - p1[1];
pt[2]= 2.0f*p2[2] - p1[2];
@@ -2525,42 +2541,42 @@ static void calchandleNurb_intern(BezTriple *bezt, BezTriple *prev, BezTriple *n
len_b= len_v3(dvec_b);
}
- if(len_a==0.0f) len_a=1.0f;
- if(len_b==0.0f) len_b=1.0f;
+ if (len_a==0.0f) len_a=1.0f;
+ if (len_b==0.0f) len_b=1.0f;
- if(ELEM(bezt->h1,HD_AUTO,HD_AUTO_ANIM) || ELEM(bezt->h2,HD_AUTO,HD_AUTO_ANIM)) { /* auto */
+ if (ELEM(bezt->h1,HD_AUTO,HD_AUTO_ANIM) || ELEM(bezt->h2,HD_AUTO,HD_AUTO_ANIM)) { /* auto */
float tvec[3];
tvec[0]= dvec_b[0]/len_b + dvec_a[0]/len_a;
tvec[1]= dvec_b[1]/len_b + dvec_a[1]/len_a;
tvec[2]= dvec_b[2]/len_b + dvec_a[2]/len_a;
len= len_v3(tvec) * 2.5614f;
- if(len!=0.0f) {
+ if (len!=0.0f) {
int leftviolate=0, rightviolate=0; /* for mode==2 */
- if(len_a>5.0f*len_b) len_a= 5.0f*len_b;
- if(len_b>5.0f*len_a) len_b= 5.0f*len_a;
+ if (len_a>5.0f*len_b) len_a= 5.0f*len_b;
+ if (len_b>5.0f*len_a) len_b= 5.0f*len_a;
- if(ELEM(bezt->h1,HD_AUTO,HD_AUTO_ANIM)) {
+ if (ELEM(bezt->h1,HD_AUTO,HD_AUTO_ANIM)) {
len_a/=len;
madd_v3_v3v3fl(p2-3, p2, tvec, -len_a);
- if((bezt->h1==HD_AUTO_ANIM) && next && prev) { /* keep horizontal if extrema */
+ if ((bezt->h1==HD_AUTO_ANIM) && next && prev) { /* keep horizontal if extrema */
float ydiff1= prev->vec[1][1] - bezt->vec[1][1];
float ydiff2= next->vec[1][1] - bezt->vec[1][1];
- if( (ydiff1 <= 0.0f && ydiff2 <= 0.0f) || (ydiff1 >= 0.0f && ydiff2 >= 0.0f) ) {
+ if ( (ydiff1 <= 0.0f && ydiff2 <= 0.0f) || (ydiff1 >= 0.0f && ydiff2 >= 0.0f) ) {
bezt->vec[0][1]= bezt->vec[1][1];
}
else { /* handles should not be beyond y coord of two others */
- if(ydiff1 <= 0.0f) {
- if(prev->vec[1][1] > bezt->vec[0][1]) {
+ if (ydiff1 <= 0.0f) {
+ if (prev->vec[1][1] > bezt->vec[0][1]) {
bezt->vec[0][1]= prev->vec[1][1];
leftviolate= 1;
}
}
else {
- if(prev->vec[1][1] < bezt->vec[0][1]) {
+ if (prev->vec[1][1] < bezt->vec[0][1]) {
bezt->vec[0][1]= prev->vec[1][1];
leftviolate= 1;
}
@@ -2568,25 +2584,25 @@ static void calchandleNurb_intern(BezTriple *bezt, BezTriple *prev, BezTriple *n
}
}
}
- if(ELEM(bezt->h2,HD_AUTO,HD_AUTO_ANIM)) {
+ if (ELEM(bezt->h2,HD_AUTO,HD_AUTO_ANIM)) {
len_b/=len;
madd_v3_v3v3fl(p2+3, p2, tvec, len_b);
- if((bezt->h2==HD_AUTO_ANIM) && next && prev) { /* keep horizontal if extrema */
+ if ((bezt->h2==HD_AUTO_ANIM) && next && prev) { /* keep horizontal if extrema */
float ydiff1= prev->vec[1][1] - bezt->vec[1][1];
float ydiff2= next->vec[1][1] - bezt->vec[1][1];
- if( (ydiff1 <= 0.0f && ydiff2 <= 0.0f) || (ydiff1 >= 0.0f && ydiff2 >= 0.0f) ) {
+ if ( (ydiff1 <= 0.0f && ydiff2 <= 0.0f) || (ydiff1 >= 0.0f && ydiff2 >= 0.0f) ) {
bezt->vec[2][1]= bezt->vec[1][1];
}
else { /* andles should not be beyond y coord of two others */
- if(ydiff1 <= 0.0f) {
- if(next->vec[1][1] < bezt->vec[2][1]) {
+ if (ydiff1 <= 0.0f) {
+ if (next->vec[1][1] < bezt->vec[2][1]) {
bezt->vec[2][1]= next->vec[1][1];
rightviolate= 1;
}
}
else {
- if(next->vec[1][1] > bezt->vec[2][1]) {
+ if (next->vec[1][1] > bezt->vec[2][1]) {
bezt->vec[2][1]= next->vec[1][1];
rightviolate= 1;
}
@@ -2594,7 +2610,7 @@ static void calchandleNurb_intern(BezTriple *bezt, BezTriple *prev, BezTriple *n
}
}
}
- if(leftviolate || rightviolate) { /* align left handle */
+ if (leftviolate || rightviolate) { /* align left handle */
float h1[3], h2[3];
float dot;
@@ -2606,7 +2622,7 @@ static void calchandleNurb_intern(BezTriple *bezt, BezTriple *prev, BezTriple *n
dot= dot_v3v3(h1, h2);
- if(leftviolate) {
+ if (leftviolate) {
mul_v3_fl(h1, dot * len_b);
sub_v3_v3v3(p2+3, p2, h1);
}
@@ -2619,14 +2635,14 @@ static void calchandleNurb_intern(BezTriple *bezt, BezTriple *prev, BezTriple *n
}
}
- if(bezt->h1==HD_VECT) { /* vector */
+ if (bezt->h1==HD_VECT) { /* vector */
madd_v3_v3v3fl(p2-3, p2, dvec_a, -1.0f/3.0f);
}
- if(bezt->h2==HD_VECT) {
+ if (bezt->h2==HD_VECT) {
madd_v3_v3v3fl(p2+3, p2, dvec_b, 1.0f/3.0f);
}
- if(skip_align) {
+ if (skip_align) {
/* handles need to be updated during animation and applying stuff like hooks,
* but in such situatios it's quite difficult to distinguish in which order
* align handles should be aligned so skip them for now */
@@ -2635,20 +2651,20 @@ static void calchandleNurb_intern(BezTriple *bezt, BezTriple *prev, BezTriple *n
len_b= len_v3v3(p2, p2+3);
len_a= len_v3v3(p2, p2-3);
- if(len_a==0.0f) len_a= 1.0f;
- if(len_b==0.0f) len_b= 1.0f;
+ if (len_a==0.0f) len_a= 1.0f;
+ if (len_b==0.0f) len_b= 1.0f;
- if(bezt->f1 & SELECT) { /* order of calculation */
- if(bezt->h2==HD_ALIGN) { /* aligned */
- if(len_a>eps) {
+ if (bezt->f1 & SELECT) { /* order of calculation */
+ if (bezt->h2==HD_ALIGN) { /* aligned */
+ if (len_a>eps) {
len= len_b/len_a;
p2[3]= p2[0]+len*(p2[0] - p2[-3]);
p2[4]= p2[1]+len*(p2[1] - p2[-2]);
p2[5]= p2[2]+len*(p2[2] - p2[-1]);
}
}
- if(bezt->h1==HD_ALIGN) {
- if(len_b>eps) {
+ if (bezt->h1==HD_ALIGN) {
+ if (len_b>eps) {
len= len_a/len_b;
p2[-3]= p2[0]+len*(p2[0] - p2[3]);
p2[-2]= p2[1]+len*(p2[1] - p2[4]);
@@ -2657,16 +2673,16 @@ static void calchandleNurb_intern(BezTriple *bezt, BezTriple *prev, BezTriple *n
}
}
else {
- if(bezt->h1==HD_ALIGN) {
- if(len_b>eps) {
+ if (bezt->h1==HD_ALIGN) {
+ if (len_b>eps) {
len= len_a/len_b;
p2[-3]= p2[0]+len*(p2[0] - p2[3]);
p2[-2]= p2[1]+len*(p2[1] - p2[4]);
p2[-1]= p2[2]+len*(p2[2] - p2[5]);
}
}
- if(bezt->h2==HD_ALIGN) { /* aligned */
- if(len_a>eps) {
+ if (bezt->h2==HD_ALIGN) { /* aligned */
+ if (len_a>eps) {
len= len_b/len_a;
p2[3]= p2[0]+len*(p2[0] - p2[-3]);
p2[4]= p2[1]+len*(p2[1] - p2[-2]);
@@ -2681,20 +2697,20 @@ static void calchandlesNurb_intern(Nurb *nu, int skip_align)
BezTriple *bezt, *prev, *next;
short a;
- if(nu->type != CU_BEZIER) return;
- if(nu->pntsu<2) return;
+ if (nu->type != CU_BEZIER) return;
+ if (nu->pntsu<2) return;
a= nu->pntsu;
bezt= nu->bezt;
- if(nu->flagu & CU_NURB_CYCLIC) prev= bezt+(a-1);
+ if (nu->flagu & CU_NURB_CYCLIC) prev= bezt+(a-1);
else prev= NULL;
next= bezt+1;
- while(a--) {
+ while (a--) {
calchandleNurb_intern(bezt, prev, next, 0, skip_align);
prev= bezt;
- if(a==1) {
- if(nu->flagu & CU_NURB_CYCLIC) next= nu->bezt;
+ if (a==1) {
+ if (nu->flagu & CU_NURB_CYCLIC) next= nu->bezt;
else next= NULL;
}
else next++;
@@ -2726,29 +2742,29 @@ void testhandlesNurb(Nurb *nu)
BezTriple *bezt;
short flag, a;
- if(nu->type != CU_BEZIER) return;
+ if (nu->type != CU_BEZIER) return;
bezt= nu->bezt;
a= nu->pntsu;
- while(a--) {
+ while (a--) {
flag= 0;
- if(bezt->f1 & SELECT) flag++;
- if(bezt->f2 & SELECT) flag += 2;
- if(bezt->f3 & SELECT) flag += 4;
+ if (bezt->f1 & SELECT) flag++;
+ if (bezt->f2 & SELECT) flag += 2;
+ if (bezt->f3 & SELECT) flag += 4;
- if( !(flag==0 || flag==7) ) {
- if(ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM)) { /* auto */
+ if ( !(flag==0 || flag==7) ) {
+ if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM)) { /* auto */
bezt->h1= HD_ALIGN;
}
- if(ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM)) { /* auto */
+ if (ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM)) { /* auto */
bezt->h2= HD_ALIGN;
}
- if(bezt->h1==HD_VECT) { /* vector */
- if(flag < 4) bezt->h1= 0;
+ if (bezt->h1==HD_VECT) { /* vector */
+ if (flag < 4) bezt->h1= 0;
}
- if(bezt->h2==HD_VECT) { /* vector */
- if( flag > 3) bezt->h2= 0;
+ if (bezt->h2==HD_VECT) { /* vector */
+ if ( flag > 3) bezt->h2= 0;
}
}
bezt++;
@@ -2764,61 +2780,61 @@ void autocalchandlesNurb(Nurb *nu, int flag)
BezTriple *bezt2, *bezt1, *bezt0;
int i, align, leftsmall, rightsmall;
- if(nu==NULL || nu->bezt==NULL) return;
+ if (nu==NULL || nu->bezt==NULL) return;
bezt2 = nu->bezt;
bezt1 = bezt2 + (nu->pntsu-1);
bezt0 = bezt1 - 1;
i = nu->pntsu;
- while(i--) {
+ while (i--) {
align= leftsmall= rightsmall= 0;
/* left handle: */
- if(flag==0 || (bezt1->f1 & flag) ) {
+ if (flag==0 || (bezt1->f1 & flag) ) {
bezt1->h1= 0;
/* distance too short: vectorhandle */
- if( len_v3v3( bezt1->vec[1], bezt0->vec[1] ) < 0.0001f) {
+ if ( len_v3v3( bezt1->vec[1], bezt0->vec[1] ) < 0.0001f) {
bezt1->h1= HD_VECT;
leftsmall= 1;
}
else {
/* aligned handle? */
- if(dist_to_line_v2(bezt1->vec[1], bezt1->vec[0], bezt1->vec[2]) < 0.0001f) {
+ if (dist_to_line_v2(bezt1->vec[1], bezt1->vec[0], bezt1->vec[2]) < 0.0001f) {
align= 1;
bezt1->h1= HD_ALIGN;
}
/* or vector handle? */
- if(dist_to_line_v2(bezt1->vec[0], bezt1->vec[1], bezt0->vec[1]) < 0.0001f)
+ if (dist_to_line_v2(bezt1->vec[0], bezt1->vec[1], bezt0->vec[1]) < 0.0001f)
bezt1->h1= HD_VECT;
}
}
/* right handle: */
- if(flag==0 || (bezt1->f3 & flag) ) {
+ if (flag==0 || (bezt1->f3 & flag) ) {
bezt1->h2= 0;
/* distance too short: vectorhandle */
- if( len_v3v3( bezt1->vec[1], bezt2->vec[1] ) < 0.0001f) {
+ if ( len_v3v3( bezt1->vec[1], bezt2->vec[1] ) < 0.0001f) {
bezt1->h2= HD_VECT;
rightsmall= 1;
}
else {
/* aligned handle? */
- if(align) bezt1->h2= HD_ALIGN;
+ if (align) bezt1->h2= HD_ALIGN;
/* or vector handle? */
- if(dist_to_line_v2(bezt1->vec[2], bezt1->vec[1], bezt2->vec[1]) < 0.0001f)
+ if (dist_to_line_v2(bezt1->vec[2], bezt1->vec[1], bezt2->vec[1]) < 0.0001f)
bezt1->h2= HD_VECT;
}
}
- if(leftsmall && bezt1->h2==HD_ALIGN) bezt1->h2= 0;
- if(rightsmall && bezt1->h1==HD_ALIGN) bezt1->h1= 0;
+ if (leftsmall && bezt1->h2==HD_ALIGN) bezt1->h2= 0;
+ if (rightsmall && bezt1->h1==HD_ALIGN) bezt1->h1= 0;
/* undesired combination: */
- if(bezt1->h1==HD_ALIGN && bezt1->h2==HD_VECT) bezt1->h1= 0;
- if(bezt1->h2==HD_ALIGN && bezt1->h1==HD_VECT) bezt1->h2= 0;
+ if (bezt1->h1==HD_ALIGN && bezt1->h2==HD_VECT) bezt1->h1= 0;
+ if (bezt1->h2==HD_ALIGN && bezt1->h1==HD_VECT) bezt1->h2= 0;
bezt0= bezt1;
bezt1= bezt2;
@@ -2833,7 +2849,7 @@ void autocalchandlesNurb_all(ListBase *editnurb, int flag)
Nurb *nu;
nu= editnurb->first;
- while(nu) {
+ while (nu) {
autocalchandlesNurb(nu, flag);
nu= nu->next;
}
@@ -2851,17 +2867,17 @@ void sethandlesNurb(ListBase *editnurb, short code)
BezTriple *bezt;
short a, ok=0;
- if(code==1 || code==2) {
+ if (code==1 || code==2) {
nu= editnurb->first;
- while(nu) {
- if(nu->type == CU_BEZIER) {
+ while (nu) {
+ if (nu->type == CU_BEZIER) {
bezt= nu->bezt;
a= nu->pntsu;
- while(a--) {
- if((bezt->f1 & SELECT) || (bezt->f3 & SELECT)) {
- if(bezt->f1 & SELECT) bezt->h1= code;
- if(bezt->f3 & SELECT) bezt->h2= code;
- if(bezt->h1!=bezt->h2) {
+ while (a--) {
+ if ((bezt->f1 & SELECT) || (bezt->f3 & SELECT)) {
+ if (bezt->f1 & SELECT) bezt->h1= code;
+ if (bezt->f3 & SELECT) bezt->h2= code;
+ if (bezt->h1!=bezt->h2) {
if ELEM(bezt->h1, HD_ALIGN, HD_AUTO) bezt->h1= HD_FREE;
if ELEM(bezt->h2, HD_ALIGN, HD_AUTO) bezt->h2= HD_FREE;
}
@@ -2879,34 +2895,36 @@ void sethandlesNurb(ListBase *editnurb, short code)
nu= editnurb->first;
if (code == 5) {
ok = HD_ALIGN;
- } else if (code == 6) {
+ }
+ else if (code == 6) {
ok = HD_FREE;
- } else {
+ }
+ else {
/* Toggle */
- while(nu) {
- if(nu->type == CU_BEZIER) {
+ while (nu) {
+ if (nu->type == CU_BEZIER) {
bezt= nu->bezt;
a= nu->pntsu;
- while(a--) {
- if((bezt->f1 & SELECT) && bezt->h1) ok= 1;
- if((bezt->f3 & SELECT) && bezt->h2) ok= 1;
- if(ok) break;
+ while (a--) {
+ if ((bezt->f1 & SELECT) && bezt->h1) ok= 1;
+ if ((bezt->f3 & SELECT) && bezt->h2) ok= 1;
+ if (ok) break;
bezt++;
}
}
nu= nu->next;
}
- if(ok) ok= HD_FREE;
+ if (ok) ok= HD_FREE;
else ok= HD_ALIGN;
}
nu= editnurb->first;
- while(nu) {
- if(nu->type == CU_BEZIER) {
+ while (nu) {
+ if (nu->type == CU_BEZIER) {
bezt= nu->bezt;
a= nu->pntsu;
- while(a--) {
- if(bezt->f1 & SELECT) bezt->h1= ok;
- if(bezt->f3 & SELECT) bezt->h2= ok;
+ while (a--) {
+ if (bezt->f1 & SELECT) bezt->h1= ok;
+ if (bezt->f3 & SELECT) bezt->h2= ok;
bezt++;
}
@@ -2920,9 +2938,9 @@ void sethandlesNurb(ListBase *editnurb, short code)
static void swapdata(void *adr1, void *adr2, int len)
{
- if(len<=0) return;
+ if (len<=0) return;
- if(len<65) {
+ if (len<65) {
char adr[64];
memcpy(adr, adr1, len);
@@ -2947,24 +2965,24 @@ void switchdirectionNurb(Nurb *nu)
float *fp1, *fp2, *tempf;
int a, b;
- if(nu->pntsu==1 && nu->pntsv==1) return;
+ if (nu->pntsu==1 && nu->pntsv==1) return;
- if(nu->type == CU_BEZIER) {
+ if (nu->type == CU_BEZIER) {
a= nu->pntsu;
bezt1= nu->bezt;
bezt2= bezt1+(a-1);
- if(a & 1) a+= 1; /* if odd, also swap middle content */
+ if (a & 1) a+= 1; /* if odd, also swap middle content */
a/= 2;
- while(a>0) {
- if(bezt1!=bezt2) SWAP(BezTriple, *bezt1, *bezt2);
+ while (a>0) {
+ if (bezt1!=bezt2) SWAP(BezTriple, *bezt1, *bezt2);
swapdata(bezt1->vec[0], bezt1->vec[2], 12);
- if(bezt1!=bezt2) swapdata(bezt2->vec[0], bezt2->vec[2], 12);
+ if (bezt1!=bezt2) swapdata(bezt2->vec[0], bezt2->vec[2], 12);
SWAP(char, bezt1->h1, bezt1->h2);
SWAP(short, bezt1->f1, bezt1->f3);
- if(bezt1!=bezt2) {
+ if (bezt1!=bezt2) {
SWAP(char, bezt2->h1, bezt2->h2);
SWAP(short, bezt2->f1, bezt2->f3);
bezt1->alfa= -bezt1->alfa;
@@ -2975,12 +2993,12 @@ void switchdirectionNurb(Nurb *nu)
bezt2--;
}
}
- else if(nu->pntsv==1) {
+ else if (nu->pntsv==1) {
a= nu->pntsu;
bp1= nu->bp;
bp2= bp1+(a-1);
a/= 2;
- while(bp1!=bp2 && a>0) {
+ while (bp1!=bp2 && a>0) {
SWAP(BPoint, *bp1, *bp2);
a--;
bp1->alfa= -bp1->alfa;
@@ -2988,15 +3006,15 @@ void switchdirectionNurb(Nurb *nu)
bp1++;
bp2--;
}
- if(nu->type == CU_NURBS) {
+ if (nu->type == CU_NURBS) {
/* no knots for too short paths */
- if(nu->knotsu) {
+ if (nu->knotsu) {
/* inverse knots */
a= KNOTSU(nu);
fp1= nu->knotsu;
fp2= fp1+(a-1);
a/= 2;
- while(fp1!=fp2 && a>0) {
+ while (fp1!=fp2 && a>0) {
SWAP(float, *fp1, *fp2);
a--;
fp1++;
@@ -3006,7 +3024,7 @@ void switchdirectionNurb(Nurb *nu)
a= KNOTSU(nu);
fp1= nu->knotsu;
fp2=tempf= MEM_mallocN(sizeof(float)*a, "switchdirect");
- while(a--) {
+ while (a--) {
fp2[0]= fabs(fp1[1]-fp1[0]);
fp1++;
fp2++;
@@ -3017,7 +3035,7 @@ void switchdirectionNurb(Nurb *nu)
fp2= tempf;
fp1[0]= 0.0;
fp1++;
- while(a--) {
+ while (a--) {
fp1[0]= fp1[-1]+fp2[0];
fp1++;
fp2++;
@@ -3028,14 +3046,14 @@ void switchdirectionNurb(Nurb *nu)
}
else {
- for(b=0; b<nu->pntsv; b++) {
+ for (b=0; b<nu->pntsv; b++) {
bp1= nu->bp+b*nu->pntsu;
a= nu->pntsu;
bp2= bp1+(a-1);
a/= 2;
- while(bp1!=bp2 && a>0) {
+ while (bp1!=bp2 && a>0) {
SWAP(BPoint, *bp1, *bp2);
a--;
bp1++;
@@ -3062,7 +3080,8 @@ float (*curve_getVertexCos(Curve *UNUSED(cu), ListBase *lb, int *numVerts_r))[3]
copy_v3_v3(co, bezt->vec[1]); co+=3;
copy_v3_v3(co, bezt->vec[2]); co+=3;
}
- } else {
+ }
+ else {
BPoint *bp = nu->bp;
for (i=0; i<nu->pntsu*nu->pntsv; i++,bp++) {
@@ -3089,7 +3108,8 @@ void curve_applyVertexCos(Curve *UNUSED(cu), ListBase *lb, float (*vertexCos)[3]
copy_v3_v3(bezt->vec[1], co); co+=3;
copy_v3_v3(bezt->vec[2], co); co+=3;
}
- } else {
+ }
+ else {
BPoint *bp = nu->bp;
for (i=0; i<nu->pntsu*nu->pntsv; i++,bp++) {
@@ -3122,7 +3142,7 @@ float (*curve_getKeyVertexCos(Curve *UNUSED(cu), ListBase *lb, float *key))[3]
else {
BPoint *bp = nu->bp;
- for(i=0; i<nu->pntsu*nu->pntsv; i++,bp++) {
+ for (i=0; i<nu->pntsu*nu->pntsv; i++,bp++) {
copy_v3_v3(co, key); co+=3; key+=3;
key++; /* skip tilt */
}
@@ -3137,11 +3157,11 @@ void curve_applyKeyVertexTilts(Curve *UNUSED(cu), ListBase *lb, float *key)
Nurb *nu;
int i;
- for(nu=lb->first; nu; nu=nu->next) {
- if(nu->type == CU_BEZIER) {
+ for (nu=lb->first; nu; nu=nu->next) {
+ if (nu->type == CU_BEZIER) {
BezTriple *bezt = nu->bezt;
- for(i=0; i<nu->pntsu; i++,bezt++) {
+ for (i=0; i<nu->pntsu; i++,bezt++) {
key+=3*3;
bezt->alfa= *key;
key+=3;
@@ -3150,7 +3170,7 @@ void curve_applyKeyVertexTilts(Curve *UNUSED(cu), ListBase *lb, float *key)
else {
BPoint *bp = nu->bp;
- for(i=0; i<nu->pntsu*nu->pntsv; i++,bp++) {
+ for (i=0; i<nu->pntsu*nu->pntsv; i++,bp++) {
key+=3;
bp->alfa= *key;
key++;
@@ -3169,7 +3189,8 @@ int check_valid_nurb_u( struct Nurb *nu )
if (((nu->flag & CU_NURB_CYCLIC)==0) && (nu->flagu & CU_NURB_BEZIER)) { /* Bezier U Endpoints */
if (nu->orderu==4) {
if (nu->pntsu < 5) return 0; /* bezier with 4 orderu needs 5 points */
- } else if (nu->orderu != 3) return 0; /* order must be 3 or 4 */
+ }
+ else if (nu->orderu != 3) return 0; /* order must be 3 or 4 */
}
return 1;
}
@@ -3183,7 +3204,8 @@ int check_valid_nurb_v( struct Nurb *nu)
if (((nu->flag & CU_NURB_CYCLIC)==0) && (nu->flagv & CU_NURB_BEZIER)) { /* Bezier V Endpoints */
if (nu->orderv==4) {
if (nu->pntsv < 5) return 0; /* bezier with 4 orderu needs 5 points */
- } else if (nu->orderv != 3) return 0; /* order must be 3 or 4 */
+ }
+ else if (nu->orderv != 3) return 0; /* order must be 3 or 4 */
}
return 1;
}
@@ -3191,11 +3213,11 @@ int check_valid_nurb_v( struct Nurb *nu)
int clamp_nurb_order_u( struct Nurb *nu )
{
int change = 0;
- if(nu->pntsu<nu->orderu) {
+ if (nu->pntsu<nu->orderu) {
nu->orderu= nu->pntsu;
change= 1;
}
- if(((nu->flagu & CU_NURB_CYCLIC)==0) && (nu->flagu & CU_NURB_BEZIER)) {
+ if (((nu->flagu & CU_NURB_CYCLIC)==0) && (nu->flagu & CU_NURB_BEZIER)) {
CLAMP(nu->orderu, 3,4);
change= 1;
}
@@ -3205,11 +3227,11 @@ int clamp_nurb_order_u( struct Nurb *nu )
int clamp_nurb_order_v( struct Nurb *nu)
{
int change = 0;
- if(nu->pntsv<nu->orderv) {
+ if (nu->pntsv<nu->orderv) {
nu->orderv= nu->pntsv;
change= 1;
}
- if(((nu->flagv & CU_NURB_CYCLIC)==0) && (nu->flagv & CU_NURB_BEZIER)) {
+ if (((nu->flagv & CU_NURB_CYCLIC)==0) && (nu->flagv & CU_NURB_BEZIER)) {
CLAMP(nu->orderv, 3,4);
change= 1;
}
@@ -3233,7 +3255,7 @@ int minmax_curve(Curve *cu, float min[3], float max[3])
ListBase *nurb_lb= BKE_curve_nurbs(cu);
Nurb *nu;
- for(nu= nurb_lb->first; nu; nu= nu->next)
+ for (nu= nurb_lb->first; nu; nu= nu->next)
minmaxNurb(nu, min, max);
return (nurb_lb->first != NULL);
@@ -3247,14 +3269,14 @@ int curve_center_median(Curve *cu, float cent[3])
zero_v3(cent);
- for(nu= nurb_lb->first; nu; nu= nu->next) {
+ for (nu= nurb_lb->first; nu; nu= nu->next) {
int i;
- if(nu->type == CU_BEZIER) {
+ if (nu->type == CU_BEZIER) {
BezTriple *bezt;
i= nu->pntsu;
total += i * 3;
- for(bezt= nu->bezt; i--; bezt++) {
+ for (bezt= nu->bezt; i--; bezt++) {
add_v3_v3(cent, bezt->vec[0]);
add_v3_v3(cent, bezt->vec[1]);
add_v3_v3(cent, bezt->vec[2]);
@@ -3264,7 +3286,7 @@ int curve_center_median(Curve *cu, float cent[3])
BPoint *bp;
i= nu->pntsu*nu->pntsv;
total += i;
- for(bp= nu->bp; i--; bp++) {
+ for (bp= nu->bp; i--; bp++) {
add_v3_v3(cent, bp->vec);
}
}
@@ -3279,7 +3301,7 @@ int curve_center_bounds(Curve *cu, float cent[3])
{
float min[3], max[3];
INIT_MINMAX(min, max);
- if(minmax_curve(cu, min, max)) {
+ if (minmax_curve(cu, min, max)) {
mid_v3_v3v3(cent, min, max);
return 1;
}
@@ -3293,13 +3315,13 @@ void curve_translate(Curve *cu, float offset[3], int do_keys)
Nurb *nu;
int i;
- for(nu= nurb_lb->first; nu; nu= nu->next) {
+ for (nu= nurb_lb->first; nu; nu= nu->next) {
BezTriple *bezt;
BPoint *bp;
- if(nu->type == CU_BEZIER) {
+ if (nu->type == CU_BEZIER) {
i= nu->pntsu;
- for(bezt= nu->bezt; i--; bezt++) {
+ for (bezt= nu->bezt; i--; bezt++) {
add_v3_v3(bezt->vec[0], offset);
add_v3_v3(bezt->vec[1], offset);
add_v3_v3(bezt->vec[2], offset);
@@ -3307,7 +3329,7 @@ void curve_translate(Curve *cu, float offset[3], int do_keys)
}
else {
i= nu->pntsu*nu->pntsv;
- for(bp= nu->bp; i--; bp++) {
+ for (bp= nu->bp; i--; bp++) {
add_v3_v3(bp->vec, offset);
}
}
@@ -3328,10 +3350,10 @@ void curve_delete_material_index(Curve *cu, int index)
{
const int curvetype= curve_type(cu);
- if(curvetype == OB_FONT) {
+ if (curvetype == OB_FONT) {
struct CharInfo *info= cu->strinfo;
int i;
- for(i= cu->len-1; i >= 0; i--, info++) {
+ for (i= cu->len-1; i >= 0; i--, info++) {
if (info->mat_nr && info->mat_nr>=index) {
info->mat_nr--;
}
@@ -3341,7 +3363,7 @@ void curve_delete_material_index(Curve *cu, int index)
Nurb *nu;
for (nu= cu->nurb.first; nu; nu= nu->next) {
- if(nu->mat_nr && nu->mat_nr>=index) {
+ if (nu->mat_nr && nu->mat_nr>=index) {
nu->mat_nr--;
if (curvetype == OB_CURVE) nu->charidx--;
}
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index 3ce11f178f6..a48f2550b48 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -130,10 +130,10 @@ static void layerCopy_mdeformvert(const void *source, void *dest,
memcpy(dest, source, count * size);
- for(i = 0; i < count; ++i) {
+ for (i = 0; i < count; ++i) {
MDeformVert *dvert = (MDeformVert *)((char *)dest + i * size);
- if(dvert->totweight) {
+ if (dvert->totweight) {
MDeformWeight *dw = MEM_callocN(dvert->totweight * sizeof(*dw),
"layerCopy_mdeformvert dw");
@@ -149,10 +149,10 @@ static void layerFree_mdeformvert(void *data, int count, int size)
{
int i;
- for(i = 0; i < count; ++i) {
+ for (i = 0; i < count; ++i) {
MDeformVert *dvert = (MDeformVert *)((char *)data + i * size);
- if(dvert->dw) {
+ if (dvert->dw) {
MEM_freeN(dvert->dw);
dvert->dw = NULL;
dvert->totweight = 0;
@@ -166,7 +166,7 @@ static void layerCopy_bmesh_elem_py_ptr(const void *UNUSED(source), void *dest,
{
int i, size = sizeof(void *);
- for(i = 0; i < count; ++i) {
+ for (i = 0; i < count; ++i) {
void **ptr = (void **)((char *)dest + i * size);
*ptr = NULL;
}
@@ -185,7 +185,7 @@ static void layerFree_bmesh_elem_py_ptr(void *data, int count, int size)
int i;
- for(i = 0; i < count; ++i) {
+ for (i = 0; i < count; ++i) {
void **ptr = (void *)((char *)data + i * size);
if (*ptr) {
bpy_bm_generic_invalidate(*ptr);
@@ -207,28 +207,28 @@ static void layerInterp_mdeformvert(void **sources, float *weights,
LinkNode *node;
int i, j, totweight;
- if(count <= 0) return;
+ if (count <= 0) return;
/* build a list of unique def_nrs for dest */
totweight = 0;
- for(i = 0; i < count; ++i) {
+ for (i = 0; i < count; ++i) {
MDeformVert *source = sources[i];
float interp_weight = weights ? weights[i] : 1.0f;
- for(j = 0; j < source->totweight; ++j) {
+ for (j = 0; j < source->totweight; ++j) {
MDeformWeight *dw = &source->dw[j];
- for(node = dest_dw; node; node = node->next) {
+ for (node = dest_dw; node; node = node->next) {
MDeformWeight *tmp_dw = (MDeformWeight *)node->link;
- if(tmp_dw->def_nr == dw->def_nr) {
+ if (tmp_dw->def_nr == dw->def_nr) {
tmp_dw->weight += dw->weight * interp_weight;
break;
}
}
/* if this def_nr is not in the list, add it */
- if(!node) {
+ if (!node) {
MDeformWeight *tmp_dw = MEM_callocN(sizeof(*tmp_dw),
"layerInterp_mdeformvert tmp_dw");
tmp_dw->def_nr = dw->def_nr;
@@ -240,14 +240,14 @@ static void layerInterp_mdeformvert(void **sources, float *weights,
}
/* now we know how many unique deform weights there are, so realloc */
- if(dvert->dw) MEM_freeN(dvert->dw);
+ if (dvert->dw) MEM_freeN(dvert->dw);
- if(totweight) {
+ if (totweight) {
dvert->dw = MEM_callocN(sizeof(*dvert->dw) * totweight,
"layerInterp_mdeformvert dvert->dw");
dvert->totweight = totweight;
- for(i = 0, node = dest_dw; node; node = node->next, ++i)
+ for (i = 0, node = dest_dw; node; node = node->next, ++i)
dvert->dw[i] = *((MDeformWeight *)node->link);
}
else
@@ -265,7 +265,7 @@ static void layerInterp_msticky(void **sources, float *weights,
int i;
co[0] = co[1] = 0.0f;
- for(i = 0; i < count; i++) {
+ for (i = 0; i < count; i++) {
w = weights ? weights[i] : 1.0f;
mst = (MSticky*)sources[i];
@@ -283,7 +283,7 @@ static void layerCopy_tface(const void *source, void *dest, int count)
MTFace *dest_tf = (MTFace*)dest;
int i;
- for(i = 0; i < count; ++i)
+ for (i = 0; i < count; ++i)
dest_tf[i] = source_tf[i];
}
@@ -295,16 +295,16 @@ static void layerInterp_tface(void **sources, float *weights,
float uv[4][2] = {{0.0f}};
float *sub_weight;
- if(count <= 0) return;
+ if (count <= 0) return;
sub_weight = sub_weights;
- for(i = 0; i < count; ++i) {
+ for (i = 0; i < count; ++i) {
float weight = weights ? weights[i] : 1;
MTFace *src = sources[i];
- for(j = 0; j < 4; ++j) {
- if(sub_weights) {
- for(k = 0; k < 4; ++k, ++sub_weight) {
+ for (j = 0; j < 4; ++j) {
+ if (sub_weights) {
+ for (k = 0; k < 4; ++k, ++sub_weight) {
madd_v2_v2fl(uv[j], src->uv[k], (*sub_weight) * weight);
}
}
@@ -330,18 +330,18 @@ static void layerSwap_tface(void *data, const int *corner_indices)
char flag = tf->flag & ~(TF_SEL1 | TF_SEL2 | TF_SEL3 | TF_SEL4);
int j;
- for(j = 0; j < 4; ++j) {
+ for (j = 0; j < 4; ++j) {
const int source_index = corner_indices[j];
copy_v2_v2(uv[j], tf->uv[source_index]);
// swap pinning flags around
- if(tf->unwrap & pin_flags[source_index]) {
+ if (tf->unwrap & pin_flags[source_index]) {
unwrap |= pin_flags[j];
}
// swap selection flags around
- if(tf->flag & sel_flags[source_index]) {
+ if (tf->flag & sel_flags[source_index]) {
flag |= sel_flags[j];
}
}
@@ -358,7 +358,7 @@ static void layerDefault_tface(void *data, int count)
MTFace *tf = (MTFace*)data;
int i;
- for(i = 0; i < count; i++)
+ for (i = 0; i < count; i++)
tf[i] = default_tf;
}
@@ -386,7 +386,7 @@ static void layerCopy_origspace_face(const void *source, void *dest, int count)
OrigSpaceFace *dest_tf = (OrigSpaceFace*)dest;
int i;
- for(i = 0; i < count; ++i)
+ for (i = 0; i < count; ++i)
dest_tf[i] = source_tf[i];
}
@@ -398,19 +398,20 @@ static void layerInterp_origspace_face(void **sources, float *weights,
float uv[4][2] = {{0.0f}};
float *sub_weight;
- if(count <= 0) return;
+ if (count <= 0) return;
sub_weight = sub_weights;
- for(i = 0; i < count; ++i) {
+ for (i = 0; i < count; ++i) {
float weight = weights ? weights[i] : 1;
OrigSpaceFace *src = sources[i];
- for(j = 0; j < 4; ++j) {
- if(sub_weights) {
- for(k = 0; k < 4; ++k, ++sub_weight) {
+ for (j = 0; j < 4; ++j) {
+ if (sub_weights) {
+ for (k = 0; k < 4; ++k, ++sub_weight) {
madd_v2_v2fl(uv[j], src->uv[k], (*sub_weight) * weight);
}
- } else {
+ }
+ else {
madd_v2_v2fl(uv[j], src->uv[j], weight);
}
}
@@ -428,7 +429,7 @@ static void layerSwap_origspace_face(void *data, const int *corner_indices)
float uv[4][2];
int j;
- for(j = 0; j < 4; ++j) {
+ for (j = 0; j < 4; ++j) {
copy_v2_v2(uv[j], osf->uv[corner_indices[j]]);
}
memcpy(osf->uv, uv, sizeof(osf->uv));
@@ -440,7 +441,7 @@ static void layerDefault_origspace_face(void *data, int count)
OrigSpaceFace *osf = (OrigSpaceFace*)data;
int i;
- for(i = 0; i < count; i++)
+ for (i = 0; i < count; i++)
osf[i] = default_osf;
}
@@ -450,12 +451,12 @@ static void layerSwap_mdisps(void *data, const int *ci)
float (*d)[3] = NULL;
int corners, cornersize, S;
- if(s->disps) {
+ if (s->disps) {
int nverts= (ci[1] == 3) ? 4 : 3; /* silly way to know vertex count of face */
corners= multires_mdisp_corners(s);
cornersize= s->totdisp/corners;
- if(corners!=nverts) {
+ if (corners!=nverts) {
/* happens when face changed vertex count in edit mode
* if it happened, just forgot displacement */
@@ -467,7 +468,7 @@ static void layerSwap_mdisps(void *data, const int *ci)
d= MEM_callocN(sizeof(float) * 3 * s->totdisp, "mdisps swap");
- for(S = 0; S < corners; S++)
+ for (S = 0; S < corners; S++)
memcpy(d + cornersize*S, s->disps + cornersize*ci[S], cornersize*3*sizeof(float));
MEM_freeN(s->disps);
@@ -481,8 +482,8 @@ static void layerCopy_mdisps(const void *source, void *dest, int count)
const MDisps *s = source;
MDisps *d = dest;
- for(i = 0; i < count; ++i) {
- if(s[i].disps) {
+ for (i = 0; i < count; ++i) {
+ if (s[i].disps) {
d[i].disps = MEM_dupallocN(s[i].disps);
d[i].hidden = MEM_dupallocN(s[i].hidden);
d[i].totdisp = s[i].totdisp;
@@ -503,10 +504,10 @@ static void layerFree_mdisps(void *data, int count, int UNUSED(size))
int i;
MDisps *d = data;
- for(i = 0; i < count; ++i) {
- if(d[i].disps)
+ for (i = 0; i < count; ++i) {
+ if (d[i].disps)
MEM_freeN(d[i].disps);
- if(d[i].hidden)
+ if (d[i].hidden)
MEM_freeN(d[i].hidden);
d[i].disps = NULL;
d[i].hidden = NULL;
@@ -520,11 +521,11 @@ static int layerRead_mdisps(CDataFile *cdf, void *data, int count)
MDisps *d = data;
int i;
- for(i = 0; i < count; ++i) {
- if(!d[i].disps)
+ for (i = 0; i < count; ++i) {
+ if (!d[i].disps)
d[i].disps = MEM_callocN(sizeof(float)*3*d[i].totdisp, "mdisps read");
- if(!cdf_read_data(cdf, d[i].totdisp*3*sizeof(float), d[i].disps)) {
+ if (!cdf_read_data(cdf, d[i].totdisp*3*sizeof(float), d[i].disps)) {
printf("failed to read multires displacement %d/%d %d\n", i, count, d[i].totdisp);
return 0;
}
@@ -538,8 +539,8 @@ static int layerWrite_mdisps(CDataFile *cdf, void *data, int count)
MDisps *d = data;
int i;
- for(i = 0; i < count; ++i) {
- if(!cdf_write_data(cdf, d[i].totdisp*3*sizeof(float), d[i].disps)) {
+ for (i = 0; i < count; ++i) {
+ if (!cdf_write_data(cdf, d[i].totdisp*3*sizeof(float), d[i].disps)) {
printf("failed to write multires displacement %d/%d %d\n", i, count, d[i].totdisp);
return 0;
}
@@ -554,7 +555,7 @@ static size_t layerFilesize_mdisps(CDataFile *UNUSED(cdf), void *data, int count
size_t size = 0;
int i;
- for(i = 0; i < count; ++i)
+ for (i = 0; i < count; ++i)
size += d[i].totdisp*3*sizeof(float);
return size;
@@ -640,7 +641,7 @@ static void layerDefault_mloopcol(void *data, int count)
MLoopCol default_mloopcol = {255,255,255,255};
MLoopCol *mlcol = (MLoopCol*)data;
int i;
- for(i = 0; i < count; i++)
+ for (i = 0; i < count; i++)
mlcol[i] = default_mloopcol;
}
@@ -744,7 +745,7 @@ static void layerInterp_mloopuv(void **sources, float *weights,
if (sub_weights) {
const float *sub_weight = sub_weights;
- for(i = 0; i < count; i++) {
+ for (i = 0; i < count; i++) {
float weight = weights ? weights[i] : 1.0f;
MLoopUV *src = sources[i];
madd_v2_v2fl(uv, src->uv, (*sub_weight) * weight);
@@ -752,7 +753,7 @@ static void layerInterp_mloopuv(void **sources, float *weights,
}
}
else {
- for(i = 0; i < count; i++) {
+ for (i = 0; i < count; i++) {
float weight = weights ? weights[i] : 1;
MLoopUV *src = sources[i];
madd_v2_v2fl(uv, src->uv, weight);
@@ -814,7 +815,7 @@ static void layerInterp_mloop_origspace(void **sources, float *weights,
if (sub_weights) {
const float *sub_weight = sub_weights;
- for(i = 0; i < count; i++) {
+ for (i = 0; i < count; i++) {
float weight = weights ? weights[i] : 1.0f;
OrigSpaceLoop *src = sources[i];
madd_v2_v2fl(uv, src->uv, (*sub_weight) * weight);
@@ -822,7 +823,7 @@ static void layerInterp_mloop_origspace(void **sources, float *weights,
}
}
else {
- for(i = 0; i < count; i++) {
+ for (i = 0; i < count; i++) {
float weight = weights ? weights[i] : 1;
OrigSpaceLoop *src = sources[i];
madd_v2_v2fl(uv, src->uv, weight);
@@ -845,23 +846,24 @@ static void layerInterp_mcol(void **sources, float *weights,
float *sub_weight;
- if(count <= 0) return;
+ if (count <= 0) return;
sub_weight = sub_weights;
- for(i = 0; i < count; ++i) {
+ for (i = 0; i < count; ++i) {
float weight = weights ? weights[i] : 1;
- for(j = 0; j < 4; ++j) {
- if(sub_weights) {
+ for (j = 0; j < 4; ++j) {
+ if (sub_weights) {
MCol *src = sources[i];
- for(k = 0; k < 4; ++k, ++sub_weight, ++src) {
+ for (k = 0; k < 4; ++k, ++sub_weight, ++src) {
const float w= (*sub_weight) * weight;
col[j].a += src->a * w;
col[j].r += src->r * w;
col[j].g += src->g * w;
col[j].b += src->b * w;
}
- } else {
+ }
+ else {
MCol *src = sources[i];
col[j].a += src[j].a * weight;
col[j].r += src[j].r * weight;
@@ -871,7 +873,7 @@ static void layerInterp_mcol(void **sources, float *weights,
}
}
- for(j = 0; j < 4; ++j) {
+ for (j = 0; j < 4; ++j) {
/* Subdivide smooth or fractal can cause problems without clamping
* although weights should also not cause this situation */
@@ -893,7 +895,7 @@ static void layerSwap_mcol(void *data, const int *corner_indices)
MCol col[4];
int j;
- for(j = 0; j < 4; ++j)
+ for (j = 0; j < 4; ++j)
col[j] = mcol[corner_indices[j]];
memcpy(mcol, col, sizeof(col));
@@ -905,7 +907,7 @@ static void layerDefault_mcol(void *data, int count)
MCol *mcol = (MCol*)data;
int i;
- for(i = 0; i < 4*count; i++) {
+ for (i = 0; i < 4*count; i++) {
mcol[i] = default_mcol;
}
}
@@ -917,17 +919,17 @@ static void layerInterp_bweight(void **sources, float *weights,
float **in = (float **)sources;
int i;
- if(count <= 0) return;
+ if (count <= 0) return;
*f = 0.0f;
if (weights) {
- for(i = 0; i < count; ++i) {
+ for (i = 0; i < count; ++i) {
*f += *in[i] * weights[i];
}
}
else {
- for(i = 0; i < count; ++i) {
+ for (i = 0; i < count; ++i) {
*f += *in[i];
}
}
@@ -940,17 +942,17 @@ static void layerInterp_shapekey(void **sources, float *weights,
float **in = (float **)sources;
int i;
- if(count <= 0) return;
+ if (count <= 0) return;
zero_v3(co);
if (weights) {
- for(i = 0; i < count; ++i) {
+ for (i = 0; i < count; ++i) {
madd_v3_v3fl(co, in[i], weights[i]);
}
}
else {
- for(i = 0; i < count; ++i) {
+ for (i = 0; i < count; ++i) {
add_v3_v3(co, in[i]);
}
}
@@ -1104,14 +1106,14 @@ const CustomDataMask CD_MASK_FACECORNERS =
static const LayerTypeInfo *layerType_getInfo(int type)
{
- if(type < 0 || type >= CD_NUMTYPES) return NULL;
+ if (type < 0 || type >= CD_NUMTYPES) return NULL;
return &LAYERTYPEINFO[type];
}
static const char *layerType_getName(int type)
{
- if(type < 0 || type >= CD_NUMTYPES) return NULL;
+ if (type < 0 || type >= CD_NUMTYPES) return NULL;
return LAYERTYPENAMES[type];
}
@@ -1149,7 +1151,7 @@ void CustomData_merge(const struct CustomData *source, struct CustomData *dest,
void *data;
int i, type, number = 0, lasttype = -1, lastactive = 0, lastrender = 0, lastclone = 0, lastmask = 0, lastflag = 0;
- for(i = 0; i < source->totlayer; ++i) {
+ for (i = 0; i < source->totlayer; ++i) {
layer = &source->layers[i];
/*typeInfo = layerType_getInfo(layer->type);*/ /*UNUSED*/
@@ -1167,9 +1169,9 @@ void CustomData_merge(const struct CustomData *source, struct CustomData *dest,
else
number++;
- if(lastflag & CD_FLAG_NOCOPY) continue;
- else if(!(mask & CD_TYPE_AS_MASK(type))) continue;
- else if(number < CustomData_number_of_layers(dest, type)) continue;
+ if (lastflag & CD_FLAG_NOCOPY) continue;
+ else if (!(mask & CD_TYPE_AS_MASK(type))) continue;
+ else if (number < CustomData_number_of_layers(dest, type)) continue;
switch (alloctype) {
case CD_ASSIGN:
@@ -1182,14 +1184,14 @@ void CustomData_merge(const struct CustomData *source, struct CustomData *dest,
break;
}
- if((alloctype == CD_ASSIGN) && (lastflag & CD_FLAG_NOFREE))
+ if ((alloctype == CD_ASSIGN) && (lastflag & CD_FLAG_NOFREE))
newlayer = customData_add_layer__internal(dest, type, CD_REFERENCE,
data, totelem, layer->name);
else
newlayer = customData_add_layer__internal(dest, type, alloctype,
data, totelem, layer->name);
- if(newlayer) {
+ if (newlayer) {
newlayer->uid = layer->uid;
newlayer->active = lastactive;
@@ -1208,7 +1210,7 @@ void CustomData_copy(const struct CustomData *source, struct CustomData *dest,
{
memset(dest, 0, sizeof(*dest));
- if(source->external)
+ if (source->external)
dest->external= MEM_dupallocN(source->external);
CustomData_merge(source, dest, mask, alloctype, totelem);
@@ -1218,20 +1220,20 @@ static void customData_free_layer__internal(CustomDataLayer *layer, int totelem)
{
const LayerTypeInfo *typeInfo;
- if(!(layer->flag & CD_FLAG_NOFREE) && layer->data) {
+ if (!(layer->flag & CD_FLAG_NOFREE) && layer->data) {
typeInfo = layerType_getInfo(layer->type);
- if(typeInfo->free)
+ if (typeInfo->free)
typeInfo->free(layer->data, totelem, typeInfo->size);
- if(layer->data)
+ if (layer->data)
MEM_freeN(layer->data);
}
}
static void CustomData_external_free(CustomData *data)
{
- if(data->external) {
+ if (data->external) {
MEM_freeN(data->external);
data->external= NULL;
}
@@ -1241,10 +1243,10 @@ void CustomData_free(CustomData *data, int totelem)
{
int i;
- for(i = 0; i < data->totlayer; ++i)
+ for (i = 0; i < data->totlayer; ++i)
customData_free_layer__internal(&data->layers[i], totelem);
- if(data->layers)
+ if (data->layers)
MEM_freeN(data->layers);
CustomData_external_free(data);
@@ -1257,7 +1259,7 @@ static void customData_update_offsets(CustomData *data)
const LayerTypeInfo *typeInfo;
int i, offset = 0;
- for(i = 0; i < data->totlayer; ++i) {
+ for (i = 0; i < data->totlayer; ++i) {
typeInfo = layerType_getInfo(data->layers[i].type);
data->layers[i].offset = offset;
@@ -1272,8 +1274,8 @@ int CustomData_get_layer_index(const CustomData *data, int type)
{
int i;
- for(i=0; i < data->totlayer; ++i)
- if(data->layers[i].type == type)
+ for (i=0; i < data->totlayer; ++i)
+ if (data->layers[i].type == type)
return i;
return -1;
@@ -1294,8 +1296,8 @@ int CustomData_get_named_layer_index(const CustomData *data, int type, const cha
{
int i;
- for(i=0; i < data->totlayer; ++i)
- if(data->layers[i].type == type && strcmp(data->layers[i].name, name)==0)
+ for (i=0; i < data->totlayer; ++i)
+ if (data->layers[i].type == type && strcmp(data->layers[i].name, name)==0)
return i;
return -1;
@@ -1317,8 +1319,8 @@ int CustomData_get_render_layer_index(const CustomData *data, int type)
{
int i;
- for(i=0; i < data->totlayer; ++i)
- if(data->layers[i].type == type)
+ for (i=0; i < data->totlayer; ++i)
+ if (data->layers[i].type == type)
return i + data->layers[i].active_rnd;
return -1;
@@ -1328,8 +1330,8 @@ int CustomData_get_clone_layer_index(const CustomData *data, int type)
{
int i;
- for(i=0; i < data->totlayer; ++i)
- if(data->layers[i].type == type)
+ for (i=0; i < data->totlayer; ++i)
+ if (data->layers[i].type == type)
return i + data->layers[i].active_clone;
return -1;
@@ -1339,8 +1341,8 @@ int CustomData_get_stencil_layer_index(const CustomData *data, int type)
{
int i;
- for(i=0; i < data->totlayer; ++i)
- if(data->layers[i].type == type)
+ for (i=0; i < data->totlayer; ++i)
+ if (data->layers[i].type == type)
return i + data->layers[i].active_mask;
return -1;
@@ -1350,8 +1352,8 @@ int CustomData_get_active_layer(const CustomData *data, int type)
{
int i;
- for(i=0; i < data->totlayer; ++i)
- if(data->layers[i].type == type)
+ for (i=0; i < data->totlayer; ++i)
+ if (data->layers[i].type == type)
return data->layers[i].active;
return -1;
@@ -1361,8 +1363,8 @@ int CustomData_get_render_layer(const CustomData *data, int type)
{
int i;
- for(i=0; i < data->totlayer; ++i)
- if(data->layers[i].type == type)
+ for (i=0; i < data->totlayer; ++i)
+ if (data->layers[i].type == type)
return data->layers[i].active_rnd;
return -1;
@@ -1372,8 +1374,8 @@ int CustomData_get_clone_layer(const CustomData *data, int type)
{
int i;
- for(i=0; i < data->totlayer; ++i)
- if(data->layers[i].type == type)
+ for (i=0; i < data->totlayer; ++i)
+ if (data->layers[i].type == type)
return data->layers[i].active_clone;
return -1;
@@ -1383,8 +1385,8 @@ int CustomData_get_stencil_layer(const CustomData *data, int type)
{
int i;
- for(i=0; i < data->totlayer; ++i)
- if(data->layers[i].type == type)
+ for (i=0; i < data->totlayer; ++i)
+ if (data->layers[i].type == type)
return data->layers[i].active_mask;
return -1;
@@ -1394,8 +1396,8 @@ void CustomData_set_layer_active(CustomData *data, int type, int n)
{
int i;
- for(i=0; i < data->totlayer; ++i)
- if(data->layers[i].type == type)
+ for (i=0; i < data->totlayer; ++i)
+ if (data->layers[i].type == type)
data->layers[i].active = n;
}
@@ -1403,8 +1405,8 @@ void CustomData_set_layer_render(CustomData *data, int type, int n)
{
int i;
- for(i=0; i < data->totlayer; ++i)
- if(data->layers[i].type == type)
+ for (i=0; i < data->totlayer; ++i)
+ if (data->layers[i].type == type)
data->layers[i].active_rnd = n;
}
@@ -1412,8 +1414,8 @@ void CustomData_set_layer_clone(CustomData *data, int type, int n)
{
int i;
- for(i=0; i < data->totlayer; ++i)
- if(data->layers[i].type == type)
+ for (i=0; i < data->totlayer; ++i)
+ if (data->layers[i].type == type)
data->layers[i].active_clone = n;
}
@@ -1421,8 +1423,8 @@ void CustomData_set_layer_stencil(CustomData *data, int type, int n)
{
int i;
- for(i=0; i < data->totlayer; ++i)
- if(data->layers[i].type == type)
+ for (i=0; i < data->totlayer; ++i)
+ if (data->layers[i].type == type)
data->layers[i].active_mask = n;
}
@@ -1431,8 +1433,8 @@ void CustomData_set_layer_active_index(CustomData *data, int type, int n)
{
int i;
- for(i=0; i < data->totlayer; ++i)
- if(data->layers[i].type == type)
+ for (i=0; i < data->totlayer; ++i)
+ if (data->layers[i].type == type)
data->layers[i].active = n-i;
}
@@ -1440,8 +1442,8 @@ void CustomData_set_layer_render_index(CustomData *data, int type, int n)
{
int i;
- for(i=0; i < data->totlayer; ++i)
- if(data->layers[i].type == type)
+ for (i=0; i < data->totlayer; ++i)
+ if (data->layers[i].type == type)
data->layers[i].active_rnd = n-i;
}
@@ -1449,8 +1451,8 @@ void CustomData_set_layer_clone_index(CustomData *data, int type, int n)
{
int i;
- for(i=0; i < data->totlayer; ++i)
- if(data->layers[i].type == type)
+ for (i=0; i < data->totlayer; ++i)
+ if (data->layers[i].type == type)
data->layers[i].active_clone = n-i;
}
@@ -1458,8 +1460,8 @@ void CustomData_set_layer_stencil_index(CustomData *data, int type, int n)
{
int i;
- for(i=0; i < data->totlayer; ++i)
- if(data->layers[i].type == type)
+ for (i=0; i < data->totlayer; ++i)
+ if (data->layers[i].type == type)
data->layers[i].active_mask = n-i;
}
@@ -1467,8 +1469,8 @@ void CustomData_set_layer_flag(struct CustomData *data, int type, int flag)
{
int i;
- for(i=0; i < data->totlayer; ++i)
- if(data->layers[i].type == type)
+ for (i=0; i < data->totlayer; ++i)
+ if (data->layers[i].type == type)
data->layers[i].flag |= flag;
}
@@ -1476,7 +1478,7 @@ static int customData_resize(CustomData *data, int amount)
{
CustomDataLayer *tmp = MEM_callocN(sizeof(*tmp)*(data->maxlayer + amount),
"CustomData->layers");
- if(!tmp) return 0;
+ if (!tmp) return 0;
data->maxlayer += amount;
if (data->layers) {
@@ -1505,31 +1507,31 @@ static CustomDataLayer *customData_add_layer__internal(CustomData *data,
if (!typeInfo->defaultname && CustomData_has_layer(data, type))
return &data->layers[CustomData_get_layer_index(data, type)];
- if((alloctype == CD_ASSIGN) || (alloctype == CD_REFERENCE)) {
+ if ((alloctype == CD_ASSIGN) || (alloctype == CD_REFERENCE)) {
newlayerdata = layerdata;
}
else if (size > 0) {
newlayerdata = MEM_callocN(size, layerType_getName(type));
- if(!newlayerdata)
+ if (!newlayerdata)
return NULL;
}
if (alloctype == CD_DUPLICATE && layerdata) {
- if(typeInfo->copy)
+ if (typeInfo->copy)
typeInfo->copy(layerdata, newlayerdata, totelem);
else
memcpy(newlayerdata, layerdata, size);
}
else if (alloctype == CD_DEFAULT) {
- if(typeInfo->set_default)
+ if (typeInfo->set_default)
typeInfo->set_default((char*)newlayerdata, totelem);
}
else if (alloctype == CD_REFERENCE)
flag |= CD_FLAG_NOFREE;
- if(index >= data->maxlayer) {
- if(!customData_resize(data, CUSTOMDATA_GROW)) {
- if(newlayerdata != layerdata)
+ if (index >= data->maxlayer) {
+ if (!customData_resize(data, CUSTOMDATA_GROW)) {
+ if (newlayerdata != layerdata)
MEM_freeN(newlayerdata);
return NULL;
}
@@ -1538,26 +1540,27 @@ static CustomDataLayer *customData_add_layer__internal(CustomData *data,
data->totlayer++;
/* keep layers ordered by type */
- for( ; index > 0 && data->layers[index - 1].type > type; --index)
+ for ( ; index > 0 && data->layers[index - 1].type > type; --index)
data->layers[index] = data->layers[index - 1];
data->layers[index].type = type;
data->layers[index].flag = flag;
data->layers[index].data = newlayerdata;
- if(name || (name=typeInfo->defaultname)) {
+ if (name || (name=typeInfo->defaultname)) {
BLI_strncpy(data->layers[index].name, name, sizeof(data->layers[index].name));
CustomData_set_layer_unique_name(data, index);
}
else
data->layers[index].name[0] = '\0';
- if(index > 0 && data->layers[index-1].type == type) {
+ if (index > 0 && data->layers[index-1].type == type) {
data->layers[index].active = data->layers[index-1].active;
data->layers[index].active_rnd = data->layers[index-1].active_rnd;
data->layers[index].active_clone = data->layers[index-1].active_clone;
data->layers[index].active_mask = data->layers[index-1].active_mask;
- } else {
+ }
+ else {
data->layers[index].active = 0;
data->layers[index].active_rnd = 0;
data->layers[index].active_clone = 0;
@@ -1579,7 +1582,7 @@ void *CustomData_add_layer(CustomData *data, int type, int alloctype,
totelem, typeInfo->defaultname);
CustomData_update_typemap(data);
- if(layer)
+ if (layer)
return layer->data;
return NULL;
@@ -1595,7 +1598,7 @@ void *CustomData_add_layer_named(CustomData *data, int type, int alloctype,
totelem, name);
CustomData_update_typemap(data);
- if(layer)
+ if (layer)
return layer->data;
return NULL;
@@ -1661,8 +1664,8 @@ int CustomData_number_of_layers(const CustomData *data, int type)
{
int i, number = 0;
- for(i = 0; i < data->totlayer; i++)
- if(data->layers[i].type == type)
+ for (i = 0; i < data->totlayer; i++)
+ if (data->layers[i].type == type)
number++;
return number;
@@ -1675,7 +1678,7 @@ void *CustomData_duplicate_referenced_layer(struct CustomData *data, const int t
/* get the layer index of the first layer of type */
layer_index = CustomData_get_active_layer_index(data, type);
- if(layer_index < 0) return NULL;
+ if (layer_index < 0) return NULL;
layer = &data->layers[layer_index];
@@ -1686,7 +1689,7 @@ void *CustomData_duplicate_referenced_layer(struct CustomData *data, const int t
*/
const LayerTypeInfo *typeInfo = layerType_getInfo(layer->type);
- if(typeInfo->copy) {
+ if (typeInfo->copy) {
char *dest_data = MEM_mallocN(typeInfo->size * totelem, "CD duplicate ref layer");
typeInfo->copy(layer->data, dest_data, totelem);
layer->data = dest_data;
@@ -1708,7 +1711,7 @@ void *CustomData_duplicate_referenced_layer_named(struct CustomData *data,
/* get the layer index of the desired layer */
layer_index = CustomData_get_named_layer_index(data, type, name);
- if(layer_index < 0) return NULL;
+ if (layer_index < 0) return NULL;
layer = &data->layers[layer_index];
@@ -1719,7 +1722,7 @@ void *CustomData_duplicate_referenced_layer_named(struct CustomData *data,
*/
const LayerTypeInfo *typeInfo = layerType_getInfo(layer->type);
- if(typeInfo->copy) {
+ if (typeInfo->copy) {
char *dest_data = MEM_mallocN(typeInfo->size * totelem, "CD duplicate ref layer");
typeInfo->copy(layer->data, dest_data, totelem);
layer->data = dest_data;
@@ -1740,7 +1743,7 @@ int CustomData_is_referenced_layer(struct CustomData *data, int type)
/* get the layer index of the first layer of type */
layer_index = CustomData_get_active_layer_index(data, type);
- if(layer_index < 0) return 0;
+ if (layer_index < 0) return 0;
layer = &data->layers[layer_index];
@@ -1752,7 +1755,7 @@ void CustomData_free_temporary(CustomData *data, int totelem)
CustomDataLayer *layer;
int i, j;
- for(i = 0, j = 0; i < data->totlayer; ++i) {
+ for (i = 0, j = 0; i < data->totlayer; ++i) {
layer = &data->layers[i];
if (i != j)
@@ -1766,7 +1769,7 @@ void CustomData_free_temporary(CustomData *data, int totelem)
data->totlayer = j;
- if(data->totlayer <= data->maxlayer-CUSTOMDATA_GROW)
+ if (data->totlayer <= data->maxlayer-CUSTOMDATA_GROW)
customData_resize(data, -CUSTOMDATA_GROW);
customData_update_offsets(data);
@@ -1777,8 +1780,8 @@ void CustomData_set_only_copy(const struct CustomData *data,
{
int i;
- for(i = 0; i < data->totlayer; ++i)
- if(!(mask & CD_TYPE_AS_MASK(data->layers[i].type)))
+ for (i = 0; i < data->totlayer; ++i)
+ if (!(mask & CD_TYPE_AS_MASK(data->layers[i].type)))
data->layers[i].flag |= CD_FLAG_NOCOPY;
}
@@ -1802,20 +1805,20 @@ void CustomData_copy_data(const CustomData *source, CustomData *dest,
/* copies a layer at a time */
dest_i = 0;
- for(src_i = 0; src_i < source->totlayer; ++src_i) {
+ for (src_i = 0; src_i < source->totlayer; ++src_i) {
/* find the first dest layer with type >= the source type
* (this should work because layers are ordered by type)
*/
- while(dest_i < dest->totlayer
+ while (dest_i < dest->totlayer
&& dest->layers[dest_i].type < source->layers[src_i].type)
++dest_i;
/* if there are no more dest layers, we're done */
- if(dest_i >= dest->totlayer) return;
+ if (dest_i >= dest->totlayer) return;
/* if we found a matching layer, copy the data */
- if(dest->layers[dest_i].type == source->layers[src_i].type) {
+ if (dest->layers[dest_i].type == source->layers[src_i].type) {
char *src_data = source->layers[src_i].data;
char *dest_data = dest->layers[dest_i].data;
@@ -1833,7 +1836,7 @@ void CustomData_copy_data(const CustomData *source, CustomData *dest,
continue;
}
- if(typeInfo->copy)
+ if (typeInfo->copy)
typeInfo->copy(src_data + src_offset,
dest_data + dest_offset,
count);
@@ -1856,11 +1859,11 @@ void CustomData_free_elem(CustomData *data, int index, int count)
int i;
const LayerTypeInfo *typeInfo;
- for(i = 0; i < data->totlayer; ++i) {
- if(!(data->layers[i].flag & CD_FLAG_NOFREE)) {
+ for (i = 0; i < data->totlayer; ++i) {
+ if (!(data->layers[i].flag & CD_FLAG_NOFREE)) {
typeInfo = layerType_getInfo(data->layers[i].type);
- if(typeInfo->free) {
+ if (typeInfo->free) {
int offset = typeInfo->size * index;
typeInfo->free((char *)data->layers[i].data + offset,
@@ -1885,31 +1888,31 @@ void CustomData_interp(const CustomData *source, CustomData *dest,
/* slow fallback in case we're interpolating a ridiculous number of
* elements
*/
- if(count > SOURCE_BUF_SIZE)
+ if (count > SOURCE_BUF_SIZE)
sources = MEM_callocN(sizeof(*sources) * count,
"CustomData_interp sources");
/* interpolates a layer at a time */
dest_i = 0;
- for(src_i = 0; src_i < source->totlayer; ++src_i) {
+ for (src_i = 0; src_i < source->totlayer; ++src_i) {
const LayerTypeInfo *typeInfo= layerType_getInfo(source->layers[src_i].type);
- if(!typeInfo->interp) continue;
+ if (!typeInfo->interp) continue;
/* find the first dest layer with type >= the source type
* (this should work because layers are ordered by type)
*/
- while(dest_i < dest->totlayer
+ while (dest_i < dest->totlayer
&& dest->layers[dest_i].type < source->layers[src_i].type)
++dest_i;
/* if there are no more dest layers, we're done */
- if(dest_i >= dest->totlayer) return;
+ if (dest_i >= dest->totlayer) return;
/* if we found a matching layer, copy the data */
- if(dest->layers[dest_i].type == source->layers[src_i].type) {
+ if (dest->layers[dest_i].type == source->layers[src_i].type) {
void *src_data = source->layers[src_i].data;
- for(j = 0; j < count; ++j)
+ for (j = 0; j < count; ++j)
sources[j] = (char *)src_data
+ typeInfo->size * src_indices[j];
@@ -1926,7 +1929,7 @@ void CustomData_interp(const CustomData *source, CustomData *dest,
}
}
- if(count > SOURCE_BUF_SIZE) MEM_freeN(sources);
+ if (count > SOURCE_BUF_SIZE) MEM_freeN(sources);
}
void CustomData_swap(struct CustomData *data, int index, const int *corner_indices)
@@ -1934,10 +1937,10 @@ void CustomData_swap(struct CustomData *data, int index, const int *corner_indic
const LayerTypeInfo *typeInfo;
int i;
- for(i = 0; i < data->totlayer; ++i) {
+ for (i = 0; i < data->totlayer; ++i) {
typeInfo = layerType_getInfo(data->layers[i].type);
- if(typeInfo->swap) {
+ if (typeInfo->swap) {
int offset = typeInfo->size * index;
typeInfo->swap((char *)data->layers[i].data + offset, corner_indices);
@@ -1952,7 +1955,7 @@ void *CustomData_get(const CustomData *data, int index, int type)
/* get the layer index of the active layer of type */
layer_index = CustomData_get_active_layer_index(data, type);
- if(layer_index < 0) return NULL;
+ if (layer_index < 0) return NULL;
/* get the offset of the desired element */
offset = layerType_getInfo(type)->size * index;
@@ -1967,7 +1970,7 @@ void *CustomData_get_n(const CustomData *data, int type, int index, int n)
/* get the layer index of the first layer of type */
layer_index = data->typemap[type];
- if(layer_index < 0) return NULL;
+ if (layer_index < 0) return NULL;
offset = layerType_getInfo(type)->size * index;
return (char *)data->layers[layer_index+n].data + offset;
@@ -1977,7 +1980,7 @@ void *CustomData_get_layer(const CustomData *data, int type)
{
/* get the layer index of the active layer of type */
int layer_index = CustomData_get_active_layer_index(data, type);
- if(layer_index < 0) return NULL;
+ if (layer_index < 0) return NULL;
return data->layers[layer_index].data;
}
@@ -1986,7 +1989,7 @@ void *CustomData_get_layer_n(const CustomData *data, int type, int n)
{
/* get the layer index of the active layer of type */
int layer_index = CustomData_get_layer_index_n(data, type, n);
- if(layer_index < 0) return NULL;
+ if (layer_index < 0) return NULL;
return data->layers[layer_index].data;
}
@@ -1995,7 +1998,7 @@ void *CustomData_get_layer_named(const struct CustomData *data, int type,
const char *name)
{
int layer_index = CustomData_get_named_layer_index(data, type, name);
- if(layer_index < 0) return NULL;
+ if (layer_index < 0) return NULL;
return data->layers[layer_index].data;
}
@@ -2006,7 +2009,7 @@ int CustomData_set_layer_name(const CustomData *data, int type, int n, const cha
/* get the layer index of the first layer of type */
int layer_index = CustomData_get_layer_index_n(data, type, n);
- if(layer_index < 0) return 0;
+ if (layer_index < 0) return 0;
if (!name) return 0;
strcpy(data->layers[layer_index].name, name);
@@ -2019,7 +2022,7 @@ void *CustomData_set_layer(const CustomData *data, int type, void *ptr)
/* get the layer index of the first layer of type */
int layer_index = CustomData_get_active_layer_index(data, type);
- if(layer_index < 0) return NULL;
+ if (layer_index < 0) return NULL;
data->layers[layer_index].data = ptr;
@@ -2030,7 +2033,7 @@ void *CustomData_set_layer_n(const struct CustomData *data, int type, int n, voi
{
/* get the layer index of the first layer of type */
int layer_index = CustomData_get_layer_index_n(data, type, n);
- if(layer_index < 0) return NULL;
+ if (layer_index < 0) return NULL;
data->layers[layer_index].data = ptr;
@@ -2042,9 +2045,9 @@ void CustomData_set(const CustomData *data, int index, int type, void *source)
void *dest = CustomData_get(data, index, type);
const LayerTypeInfo *typeInfo = layerType_getInfo(type);
- if(!dest) return;
+ if (!dest) return;
- if(typeInfo->copy)
+ if (typeInfo->copy)
typeInfo->copy(source, dest, 1);
else
memcpy(dest, source, typeInfo->size);
@@ -2056,8 +2059,8 @@ void CustomData_to_bmeshpoly(CustomData *fdata, CustomData *pdata, CustomData *l
int totloop, int totpoly)
{
int i;
- for(i=0; i < fdata->totlayer; i++) {
- if(fdata->layers[i].type == CD_MTFACE) {
+ for (i=0; i < fdata->totlayer; i++) {
+ if (fdata->layers[i].type == CD_MTFACE) {
CustomData_add_layer_named(pdata, CD_MTEXPOLY, CD_CALLOC, NULL, totpoly, fdata->layers[i].name);
CustomData_add_layer_named(ldata, CD_MLOOPUV, CD_CALLOC, NULL, totloop, fdata->layers[i].name);
}
@@ -2073,12 +2076,12 @@ void CustomData_to_bmeshpoly(CustomData *fdata, CustomData *pdata, CustomData *l
void CustomData_from_bmeshpoly(CustomData *fdata, CustomData *pdata, CustomData *ldata, int total)
{
int i;
- for(i=0; i < pdata->totlayer; i++) {
+ for (i=0; i < pdata->totlayer; i++) {
if (pdata->layers[i].type == CD_MTEXPOLY) {
CustomData_add_layer_named(fdata, CD_MTFACE, CD_CALLOC, NULL, total, pdata->layers[i].name);
}
}
- for(i=0; i < ldata->totlayer; i++) {
+ for (i=0; i < ldata->totlayer; i++) {
if (ldata->layers[i].type == CD_MLOOPCOL) {
CustomData_add_layer_named(fdata, CD_MCOL, CD_CALLOC, NULL, total, ldata->layers[i].name);
}
@@ -2185,7 +2188,8 @@ void CustomData_bmesh_merge(CustomData *source, CustomData *dest,
CustomData_bmesh_free_block(&destold, &h->data);
h->data = tmp;
}
- } else {
+ }
+ else {
BMFace *f;
BMLoop *l;
BMIter liter;
@@ -2208,12 +2212,12 @@ void CustomData_bmesh_free_block(CustomData *data, void **block)
const LayerTypeInfo *typeInfo;
int i;
- if(!*block) return;
- for(i = 0; i < data->totlayer; ++i) {
- if(!(data->layers[i].flag & CD_FLAG_NOFREE)) {
+ if (!*block) return;
+ for (i = 0; i < data->totlayer; ++i) {
+ if (!(data->layers[i].flag & CD_FLAG_NOFREE)) {
typeInfo = layerType_getInfo(data->layers[i].type);
- if(typeInfo->free) {
+ if (typeInfo->free) {
int offset = data->layers[i].offset;
typeInfo->free((char*)*block + offset, 1, typeInfo->size);
}
@@ -2249,27 +2253,27 @@ void CustomData_bmesh_copy_data(const CustomData *source, CustomData *dest,
/* copies a layer at a time */
dest_i = 0;
- for(src_i = 0; src_i < source->totlayer; ++src_i) {
+ for (src_i = 0; src_i < source->totlayer; ++src_i) {
/* find the first dest layer with type >= the source type
* (this should work because layers are ordered by type)
*/
- while(dest_i < dest->totlayer
+ while (dest_i < dest->totlayer
&& dest->layers[dest_i].type < source->layers[src_i].type)
++dest_i;
/* if there are no more dest layers, we're done */
- if(dest_i >= dest->totlayer) return;
+ if (dest_i >= dest->totlayer) return;
/* if we found a matching layer, copy the data */
- if(dest->layers[dest_i].type == source->layers[src_i].type &&
+ if (dest->layers[dest_i].type == source->layers[src_i].type &&
strcmp(dest->layers[dest_i].name, source->layers[src_i].name) == 0) {
char *src_data = (char*)src_block + source->layers[src_i].offset;
char *dest_data = (char*)*dest_block + dest->layers[dest_i].offset;
typeInfo = layerType_getInfo(source->layers[src_i].type);
- if(typeInfo->copy)
+ if (typeInfo->copy)
typeInfo->copy(src_data, dest_data, 1);
else
memcpy(dest_data, src_data, typeInfo->size);
@@ -2290,7 +2294,7 @@ void *CustomData_bmesh_get(const CustomData *data, void *block, int type)
/* get the layer index of the first layer of type */
layer_index = CustomData_get_active_layer_index(data, type);
- if(layer_index < 0) return NULL;
+ if (layer_index < 0) return NULL;
return (char *)block + data->layers[layer_index].offset;
}
@@ -2301,7 +2305,7 @@ void *CustomData_bmesh_get_n(const CustomData *data, void *block, int type, int
/* get the layer index of the first layer of type */
layer_index = CustomData_get_layer_index(data, type);
- if(layer_index < 0) return NULL;
+ if (layer_index < 0) return NULL;
return (char *)block + data->layers[layer_index+n].offset;
}
@@ -2309,7 +2313,7 @@ void *CustomData_bmesh_get_n(const CustomData *data, void *block, int type, int
/*gets from the layer at physical index n, note: doesn't check type.*/
void *CustomData_bmesh_get_layer_n(const CustomData *data, void *block, int n)
{
- if(n < 0 || n >= data->totlayer) return NULL;
+ if (n < 0 || n >= data->totlayer) return NULL;
return (char *)block + data->layers[n].offset;
}
@@ -2330,9 +2334,9 @@ void CustomData_data_copy_value(int type, void *source, void *dest)
{
const LayerTypeInfo *typeInfo = layerType_getInfo(type);
- if(!dest) return;
+ if (!dest) return;
- if(typeInfo->copyvalue)
+ if (typeInfo->copyvalue)
typeInfo->copyvalue(source, dest);
else
memcpy(dest, source, typeInfo->size);
@@ -2387,9 +2391,9 @@ void CustomData_bmesh_set(const CustomData *data, void *block, int type, void *s
void *dest = CustomData_bmesh_get(data, block, type);
const LayerTypeInfo *typeInfo = layerType_getInfo(type);
- if(!dest) return;
+ if (!dest) return;
- if(typeInfo->copy)
+ if (typeInfo->copy)
typeInfo->copy(source, dest, 1);
else
memcpy(dest, source, typeInfo->size);
@@ -2400,9 +2404,9 @@ void CustomData_bmesh_set_n(CustomData *data, void *block, int type, int n, void
void *dest = CustomData_bmesh_get_n(data, block, type, n);
const LayerTypeInfo *typeInfo = layerType_getInfo(type);
- if(!dest) return;
+ if (!dest) return;
- if(typeInfo->copy)
+ if (typeInfo->copy)
typeInfo->copy(source, dest, 1);
else
memcpy(dest, source, typeInfo->size);
@@ -2413,9 +2417,9 @@ void CustomData_bmesh_set_layer_n(CustomData *data, void *block, int n, void *so
void *dest = CustomData_bmesh_get_layer_n(data, block, n);
const LayerTypeInfo *typeInfo = layerType_getInfo(data->layers[n].type);
- if(!dest) return;
+ if (!dest) return;
- if(typeInfo->copy)
+ if (typeInfo->copy)
typeInfo->copy(source, dest, 1);
else
memcpy(dest, source, typeInfo->size);
@@ -2431,16 +2435,16 @@ void CustomData_bmesh_interp(CustomData *data, void **src_blocks, float *weights
/* slow fallback in case we're interpolating a ridiculous number of
* elements
*/
- if(count > SOURCE_BUF_SIZE)
+ if (count > SOURCE_BUF_SIZE)
sources = MEM_callocN(sizeof(*sources) * count,
"CustomData_interp sources");
/* interpolates a layer at a time */
- for(i = 0; i < data->totlayer; ++i) {
+ for (i = 0; i < data->totlayer; ++i) {
CustomDataLayer *layer = &data->layers[i];
const LayerTypeInfo *typeInfo = layerType_getInfo(layer->type);
- if(typeInfo->interp) {
- for(j = 0; j < count; ++j)
+ if (typeInfo->interp) {
+ for (j = 0; j < count; ++j)
sources[j] = (char *)src_blocks[j] + layer->offset;
typeInfo->interp(sources, weights, sub_weights, count,
@@ -2448,7 +2452,7 @@ void CustomData_bmesh_interp(CustomData *data, void **src_blocks, float *weights
}
}
- if(count > SOURCE_BUF_SIZE) MEM_freeN(sources);
+ if (count > SOURCE_BUF_SIZE) MEM_freeN(sources);
}
void CustomData_bmesh_set_default(CustomData *data, void **block)
@@ -2459,12 +2463,12 @@ void CustomData_bmesh_set_default(CustomData *data, void **block)
if (!*block)
CustomData_bmesh_alloc_block(data, block);
- for(i = 0; i < data->totlayer; ++i) {
+ for (i = 0; i < data->totlayer; ++i) {
int offset = data->layers[i].offset;
typeInfo = layerType_getInfo(data->layers[i].type);
- if(typeInfo->set_default)
+ if (typeInfo->set_default)
typeInfo->set_default((char*)*block + offset, 1);
else memset((char*)*block + offset, 0, typeInfo->size);
}
@@ -2481,20 +2485,20 @@ void CustomData_to_bmesh_block(const CustomData *source, CustomData *dest,
/* copies a layer at a time */
dest_i = 0;
- for(src_i = 0; src_i < source->totlayer; ++src_i) {
+ for (src_i = 0; src_i < source->totlayer; ++src_i) {
/* find the first dest layer with type >= the source type
* (this should work because layers are ordered by type)
*/
- while(dest_i < dest->totlayer
+ while (dest_i < dest->totlayer
&& dest->layers[dest_i].type < source->layers[src_i].type)
++dest_i;
/* if there are no more dest layers, we're done */
- if(dest_i >= dest->totlayer) return;
+ if (dest_i >= dest->totlayer) return;
/* if we found a matching layer, copy the data */
- if(dest->layers[dest_i].type == source->layers[src_i].type) {
+ if (dest->layers[dest_i].type == source->layers[src_i].type) {
int offset = dest->layers[dest_i].offset;
char *src_data = source->layers[src_i].data;
char *dest_data = (char*)*dest_block + offset;
@@ -2502,7 +2506,7 @@ void CustomData_to_bmesh_block(const CustomData *source, CustomData *dest,
typeInfo = layerType_getInfo(dest->layers[dest_i].type);
src_offset = src_index * typeInfo->size;
- if(typeInfo->copy)
+ if (typeInfo->copy)
typeInfo->copy(src_data + src_offset, dest_data, 1);
else
memcpy(dest_data, src_data + src_offset, typeInfo->size);
@@ -2524,20 +2528,20 @@ void CustomData_from_bmesh_block(const CustomData *source, CustomData *dest,
/* copies a layer at a time */
dest_i = 0;
- for(src_i = 0; src_i < source->totlayer; ++src_i) {
+ for (src_i = 0; src_i < source->totlayer; ++src_i) {
/* find the first dest layer with type >= the source type
* (this should work because layers are ordered by type)
*/
- while(dest_i < dest->totlayer
+ while (dest_i < dest->totlayer
&& dest->layers[dest_i].type < source->layers[src_i].type)
++dest_i;
/* if there are no more dest layers, we're done */
- if(dest_i >= dest->totlayer) return;
+ if (dest_i >= dest->totlayer) return;
/* if we found a matching layer, copy the data */
- if(dest->layers[dest_i].type == source->layers[src_i].type) {
+ if (dest->layers[dest_i].type == source->layers[src_i].type) {
int offset = source->layers[src_i].offset;
char *src_data = (char*)src_block + offset;
char *dest_data = dest->layers[dest_i].data;
@@ -2545,7 +2549,7 @@ void CustomData_from_bmesh_block(const CustomData *source, CustomData *dest,
typeInfo = layerType_getInfo(dest->layers[dest_i].type);
dest_offset = dest_index * typeInfo->size;
- if(typeInfo->copy)
+ if (typeInfo->copy)
typeInfo->copy(src_data, dest_data + dest_offset, 1);
else
memcpy(dest_data + dest_offset, src_data, typeInfo->size);
@@ -2582,7 +2586,7 @@ const char *CustomData_layertype_name(int type)
static int CustomData_is_property_layer(int type)
{
- if((type == CD_PROP_FLT) || (type == CD_PROP_INT) || (type == CD_PROP_STR))
+ if ((type == CD_PROP_FLT) || (type == CD_PROP_INT) || (type == CD_PROP_STR))
return 1;
return 0;
}
@@ -2591,17 +2595,17 @@ static int cd_layer_find_dupe(CustomData *data, const char *name, int type, int
{
int i;
/* see if there is a duplicate */
- for(i=0; i<data->totlayer; i++) {
- if(i != index) {
+ for (i=0; i<data->totlayer; i++) {
+ if (i != index) {
CustomDataLayer *layer= &data->layers[i];
- if(CustomData_is_property_layer(type)) {
- if(CustomData_is_property_layer(layer->type) && strcmp(layer->name, name)==0) {
+ if (CustomData_is_property_layer(type)) {
+ if (CustomData_is_property_layer(layer->type) && strcmp(layer->name, name)==0) {
return 1;
}
}
- else{
- if(i!=index && layer->type==type && strcmp(layer->name, name)==0) {
+ else {
+ if (i!=index && layer->type==type && strcmp(layer->name, name)==0) {
return 1;
}
}
@@ -2638,10 +2642,10 @@ void CustomData_validate_layer_name(const CustomData *data, int type, char *name
int index = -1;
/* if a layer name was given, try to find that layer */
- if(name[0])
+ if (name[0])
index = CustomData_get_named_layer_index(data, type, name);
- if(index < 0) {
+ if (index < 0) {
/* either no layer was specified, or the layer we want has been
* deleted, so assign the active layer to name
*/
@@ -2692,13 +2696,13 @@ void CustomData_external_reload(CustomData *data, ID *UNUSED(id), CustomDataMask
const LayerTypeInfo *typeInfo;
int i;
- for(i=0; i<data->totlayer; i++) {
+ for (i=0; i<data->totlayer; i++) {
layer = &data->layers[i];
typeInfo = layerType_getInfo(layer->type);
- if(!(mask & CD_TYPE_AS_MASK(layer->type)));
- else if((layer->flag & CD_FLAG_EXTERNAL) && (layer->flag & CD_FLAG_IN_MEMORY)) {
- if(typeInfo->free)
+ if (!(mask & CD_TYPE_AS_MASK(layer->type)));
+ else if ((layer->flag & CD_FLAG_EXTERNAL) && (layer->flag & CD_FLAG_IN_MEMORY)) {
+ if (typeInfo->free)
typeInfo->free(layer->data, totelem, typeInfo->size);
layer->flag &= ~CD_FLAG_IN_MEMORY;
}
@@ -2715,42 +2719,42 @@ void CustomData_external_read(CustomData *data, ID *id, CustomDataMask mask, int
const LayerTypeInfo *typeInfo;
int i, update = 0;
- if(!external)
+ if (!external)
return;
- for(i=0; i<data->totlayer; i++) {
+ for (i=0; i<data->totlayer; i++) {
layer = &data->layers[i];
typeInfo = layerType_getInfo(layer->type);
- if(!(mask & CD_TYPE_AS_MASK(layer->type)));
- else if(layer->flag & CD_FLAG_IN_MEMORY);
- else if((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->read)
+ if (!(mask & CD_TYPE_AS_MASK(layer->type)));
+ else if (layer->flag & CD_FLAG_IN_MEMORY);
+ else if ((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->read)
update= 1;
}
- if(!update)
+ if (!update)
return;
customdata_external_filename(filename, id, external);
cdf= cdf_create(CDF_TYPE_MESH);
- if(!cdf_read_open(cdf, filename)) {
+ if (!cdf_read_open(cdf, filename)) {
fprintf(stderr, "Failed to read %s layer from %s.\n", layerType_getName(layer->type), filename);
return;
}
- for(i=0; i<data->totlayer; i++) {
+ for (i=0; i<data->totlayer; i++) {
layer = &data->layers[i];
typeInfo = layerType_getInfo(layer->type);
- if(!(mask & CD_TYPE_AS_MASK(layer->type)));
- else if(layer->flag & CD_FLAG_IN_MEMORY);
- else if((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->read) {
+ if (!(mask & CD_TYPE_AS_MASK(layer->type)));
+ else if (layer->flag & CD_FLAG_IN_MEMORY);
+ else if ((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->read) {
blay= cdf_layer_find(cdf, layer->type, layer->name);
- if(blay) {
- if(cdf_read_layer(cdf, blay)) {
- if(typeInfo->read(cdf, layer->data, totelem));
+ if (blay) {
+ if (cdf_read_layer(cdf, blay)) {
+ if (typeInfo->read(cdf, layer->data, totelem));
else break;
layer->flag |= CD_FLAG_IN_MEMORY;
}
@@ -2774,20 +2778,20 @@ void CustomData_external_write(CustomData *data, ID *id, CustomDataMask mask, in
int i, update = 0;
char filename[FILE_MAX];
- if(!external)
+ if (!external)
return;
/* test if there is anything to write */
- for(i=0; i<data->totlayer; i++) {
+ for (i=0; i<data->totlayer; i++) {
layer = &data->layers[i];
typeInfo = layerType_getInfo(layer->type);
- if(!(mask & CD_TYPE_AS_MASK(layer->type)));
- else if((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->write)
+ if (!(mask & CD_TYPE_AS_MASK(layer->type)));
+ else if ((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->write)
update= 1;
}
- if(!update)
+ if (!update)
return;
/* make sure data is read before we try to write */
@@ -2796,12 +2800,12 @@ void CustomData_external_write(CustomData *data, ID *id, CustomDataMask mask, in
cdf= cdf_create(CDF_TYPE_MESH);
- for(i=0; i<data->totlayer; i++) {
+ for (i=0; i<data->totlayer; i++) {
layer = &data->layers[i];
typeInfo = layerType_getInfo(layer->type);
- if((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->filesize) {
- if(layer->flag & CD_FLAG_IN_MEMORY) {
+ if ((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->filesize) {
+ if (layer->flag & CD_FLAG_IN_MEMORY) {
cdf_layer_add(cdf, layer->type, layer->name,
typeInfo->filesize(cdf, layer->data, totelem));
}
@@ -2812,20 +2816,20 @@ void CustomData_external_write(CustomData *data, ID *id, CustomDataMask mask, in
}
}
- if(!cdf_write_open(cdf, filename)) {
+ if (!cdf_write_open(cdf, filename)) {
fprintf(stderr, "Failed to open %s for writing.\n", filename);
return;
}
- for(i=0; i<data->totlayer; i++) {
+ for (i=0; i<data->totlayer; i++) {
layer = &data->layers[i];
typeInfo = layerType_getInfo(layer->type);
- if((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->write) {
+ if ((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->write) {
blay= cdf_layer_find(cdf, layer->type, layer->name);
- if(cdf_write_layer(cdf, blay)) {
- if(typeInfo->write(cdf, layer->data, totelem));
+ if (cdf_write_layer(cdf, blay)) {
+ if (typeInfo->write(cdf, layer->data, totelem));
else break;
}
else
@@ -2833,19 +2837,19 @@ void CustomData_external_write(CustomData *data, ID *id, CustomDataMask mask, in
}
}
- if(i != data->totlayer) {
+ if (i != data->totlayer) {
fprintf(stderr, "Failed to write data to %s.\n", filename);
cdf_free(cdf);
return;
}
- for(i=0; i<data->totlayer; i++) {
+ for (i=0; i<data->totlayer; i++) {
layer = &data->layers[i];
typeInfo = layerType_getInfo(layer->type);
- if((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->write) {
- if(free) {
- if(typeInfo->free)
+ if ((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->write) {
+ if (free) {
+ if (typeInfo->free)
typeInfo->free(layer->data, totelem, typeInfo->size);
layer->flag &= ~CD_FLAG_IN_MEMORY;
}
@@ -2863,14 +2867,14 @@ void CustomData_external_add(CustomData *data, ID *UNUSED(id), int type, int UNU
int layer_index;
layer_index = CustomData_get_active_layer_index(data, type);
- if(layer_index < 0) return;
+ if (layer_index < 0) return;
layer = &data->layers[layer_index];
- if(layer->flag & CD_FLAG_EXTERNAL)
+ if (layer->flag & CD_FLAG_EXTERNAL)
return;
- if(!external) {
+ if (!external) {
external= MEM_callocN(sizeof(CustomDataExternal), "CustomDataExternal");
data->external= external;
}
@@ -2887,26 +2891,26 @@ void CustomData_external_remove(CustomData *data, ID *id, int type, int totelem)
int layer_index; // i, remove_file;
layer_index = CustomData_get_active_layer_index(data, type);
- if(layer_index < 0) return;
+ if (layer_index < 0) return;
layer = &data->layers[layer_index];
- if(!external)
+ if (!external)
return;
- if(layer->flag & CD_FLAG_EXTERNAL) {
- if(!(layer->flag & CD_FLAG_IN_MEMORY))
+ if (layer->flag & CD_FLAG_EXTERNAL) {
+ if (!(layer->flag & CD_FLAG_IN_MEMORY))
CustomData_external_read(data, id, CD_TYPE_AS_MASK(layer->type), totelem);
layer->flag &= ~CD_FLAG_EXTERNAL;
#if 0
remove_file= 1;
- for(i=0; i<data->totlayer; i++)
- if(data->layers[i].flag & CD_FLAG_EXTERNAL)
+ for (i=0; i<data->totlayer; i++)
+ if (data->layers[i].flag & CD_FLAG_EXTERNAL)
remove_file= 0;
- if(remove_file) {
+ if (remove_file) {
customdata_external_filename(filename, id, external);
cdf_remove(filename);
CustomData_external_free(data);
@@ -2921,7 +2925,7 @@ int CustomData_external_test(CustomData *data, int type)
int layer_index;
layer_index = CustomData_get_active_layer_index(data, type);
- if(layer_index < 0) return 0;
+ if (layer_index < 0) return 0;
layer = &data->layers[layer_index];
return (layer->flag & CD_FLAG_EXTERNAL);
@@ -2933,7 +2937,7 @@ void CustomData_external_remove_object(CustomData *data, ID *id)
CustomDataExternal *external= data->external;
char filename[FILE_MAX];
- if(!external)
+ if (!external)
return;
customdata_external_filename(filename, id, external);
diff --git a/source/blender/blenkernel/intern/customdata_file.c b/source/blender/blenkernel/intern/customdata_file.c
index a89307399d9..6d0dabede47 100644
--- a/source/blender/blenkernel/intern/customdata_file.c
+++ b/source/blender/blenkernel/intern/customdata_file.c
@@ -103,7 +103,7 @@ struct CDataFile {
static int cdf_endian(void)
{
- if(ENDIAN_ORDER == L_ENDIAN)
+ if (ENDIAN_ORDER == L_ENDIAN)
return CDF_ENDIAN_LITTLE;
else
return CDF_ENDIAN_BIG;
@@ -112,7 +112,7 @@ static int cdf_endian(void)
#if 0
static int cdf_data_type_size(int datatype)
{
- if(datatype == CDF_DATA_FLOAT)
+ if (datatype == CDF_DATA_FLOAT)
return sizeof(float);
return 0;
@@ -133,7 +133,7 @@ void cdf_free(CDataFile *cdf)
cdf_read_close(cdf);
cdf_write_close(cdf);
- if(cdf->layer)
+ if (cdf->layer)
MEM_freeN(cdf->layer);
MEM_freeN(cdf);
@@ -153,38 +153,38 @@ static int cdf_read_header(CDataFile *cdf)
header= &cdf->header;
- if(!fread(header, sizeof(CDataFileHeader), 1, cdf->readf))
+ if (!fread(header, sizeof(CDataFileHeader), 1, cdf->readf))
return 0;
- if(memcmp(header->ID, "BCDF", sizeof(header->ID)) != 0)
+ if (memcmp(header->ID, "BCDF", sizeof(header->ID)) != 0)
return 0;
- if(header->version > CDF_VERSION)
+ if (header->version > CDF_VERSION)
return 0;
cdf->switchendian= header->endian != cdf_endian();
header->endian= cdf_endian();
- if(cdf->switchendian) {
+ if (cdf->switchendian) {
SWITCH_INT(header->type);
SWITCH_INT(header->totlayer);
SWITCH_INT(header->structbytes);
}
- if(!ELEM(header->type, CDF_TYPE_IMAGE, CDF_TYPE_MESH))
+ if (!ELEM(header->type, CDF_TYPE_IMAGE, CDF_TYPE_MESH))
return 0;
offset += header->structbytes;
header->structbytes= sizeof(CDataFileHeader);
- if(fseek(f, offset, SEEK_SET) != 0)
+ if (fseek(f, offset, SEEK_SET) != 0)
return 0;
- if(header->type == CDF_TYPE_IMAGE) {
+ if (header->type == CDF_TYPE_IMAGE) {
image= &cdf->btype.image;
- if(!fread(image, sizeof(CDataFileImageHeader), 1, f))
+ if (!fread(image, sizeof(CDataFileImageHeader), 1, f))
return 0;
- if(cdf->switchendian) {
+ if (cdf->switchendian) {
SWITCH_INT(image->width);
SWITCH_INT(image->height);
SWITCH_INT(image->tile_size);
@@ -194,44 +194,44 @@ static int cdf_read_header(CDataFile *cdf)
offset += image->structbytes;
image->structbytes= sizeof(CDataFileImageHeader);
}
- else if(header->type == CDF_TYPE_MESH) {
+ else if (header->type == CDF_TYPE_MESH) {
mesh= &cdf->btype.mesh;
- if(!fread(mesh, sizeof(CDataFileMeshHeader), 1, f))
+ if (!fread(mesh, sizeof(CDataFileMeshHeader), 1, f))
return 0;
- if(cdf->switchendian)
+ if (cdf->switchendian)
SWITCH_INT(mesh->structbytes);
offset += mesh->structbytes;
mesh->structbytes= sizeof(CDataFileMeshHeader);
}
- if(fseek(f, offset, SEEK_SET) != 0)
+ if (fseek(f, offset, SEEK_SET) != 0)
return 0;
cdf->layer= MEM_callocN(sizeof(CDataFileLayer)*header->totlayer, "CDataFileLayer");
cdf->totlayer= header->totlayer;
- for(a=0; a<header->totlayer; a++) {
+ for (a=0; a<header->totlayer; a++) {
layer= &cdf->layer[a];
- if(!fread(layer, sizeof(CDataFileLayer), 1, f))
+ if (!fread(layer, sizeof(CDataFileLayer), 1, f))
return 0;
- if(cdf->switchendian) {
+ if (cdf->switchendian) {
SWITCH_INT(layer->type);
SWITCH_INT(layer->datatype);
SWITCH_INT64(layer->datasize);
SWITCH_INT(layer->structbytes);
}
- if(layer->datatype != CDF_DATA_FLOAT)
+ if (layer->datatype != CDF_DATA_FLOAT)
return 0;
offset += layer->structbytes;
layer->structbytes= sizeof(CDataFileLayer);
- if(fseek(f, offset, SEEK_SET) != 0)
+ if (fseek(f, offset, SEEK_SET) != 0)
return 0;
}
@@ -251,24 +251,24 @@ static int cdf_write_header(CDataFile *cdf)
header= &cdf->header;
- if(!fwrite(header, sizeof(CDataFileHeader), 1, f))
+ if (!fwrite(header, sizeof(CDataFileHeader), 1, f))
return 0;
- if(header->type == CDF_TYPE_IMAGE) {
+ if (header->type == CDF_TYPE_IMAGE) {
image= &cdf->btype.image;
- if(!fwrite(image, sizeof(CDataFileImageHeader), 1, f))
+ if (!fwrite(image, sizeof(CDataFileImageHeader), 1, f))
return 0;
}
- else if(header->type == CDF_TYPE_MESH) {
+ else if (header->type == CDF_TYPE_MESH) {
mesh= &cdf->btype.mesh;
- if(!fwrite(mesh, sizeof(CDataFileMeshHeader), 1, f))
+ if (!fwrite(mesh, sizeof(CDataFileMeshHeader), 1, f))
return 0;
}
- for(a=0; a<header->totlayer; a++) {
+ for (a=0; a<header->totlayer; a++) {
layer= &cdf->layer[a];
- if(!fwrite(layer, sizeof(CDataFileLayer), 1, f))
+ if (!fwrite(layer, sizeof(CDataFileLayer), 1, f))
return 0;
}
@@ -280,17 +280,17 @@ int cdf_read_open(CDataFile *cdf, const char *filename)
FILE *f;
f= BLI_fopen(filename, "rb");
- if(!f)
+ if (!f)
return 0;
cdf->readf= f;
- if(!cdf_read_header(cdf)) {
+ if (!cdf_read_header(cdf)) {
cdf_read_close(cdf);
return 0;
}
- if(cdf->header.type != cdf->type) {
+ if (cdf->header.type != cdf->type) {
cdf_read_close(cdf);
return 0;
}
@@ -305,8 +305,8 @@ int cdf_read_layer(CDataFile *cdf, CDataFileLayer *blay)
/* seek to right location in file */
offset= cdf->dataoffset;
- for(a=0; a<cdf->totlayer; a++) {
- if(&cdf->layer[a] == blay)
+ for (a=0; a<cdf->totlayer; a++) {
+ if (&cdf->layer[a] == blay)
break;
else
offset += cdf->layer[a].datasize;
@@ -321,11 +321,11 @@ int cdf_read_data(CDataFile *cdf, unsigned int size, void *data)
unsigned int a;
/* read data */
- if(!fread(data, size, 1, cdf->readf))
+ if (!fread(data, size, 1, cdf->readf))
return 0;
/* switch endian if necessary */
- if(cdf->switchendian) {
+ if (cdf->switchendian) {
fdata= data;
for (a=0; a<size/sizeof(float); a++) {
@@ -338,7 +338,7 @@ int cdf_read_data(CDataFile *cdf, unsigned int size, void *data)
void cdf_read_close(CDataFile *cdf)
{
- if(cdf->readf) {
+ if (cdf->readf) {
fclose(cdf->readf);
cdf->readf= NULL;
}
@@ -352,7 +352,7 @@ int cdf_write_open(CDataFile *cdf, const char *filename)
FILE *f;
f= BLI_fopen(filename, "wb");
- if(!f)
+ if (!f)
return 0;
cdf->writef= f;
@@ -369,13 +369,13 @@ int cdf_write_open(CDataFile *cdf, const char *filename)
header->type= cdf->type;
header->totlayer= cdf->totlayer;
- if(cdf->type == CDF_TYPE_IMAGE) {
+ if (cdf->type == CDF_TYPE_IMAGE) {
/* fill image header */
image= &cdf->btype.image;
image->structbytes= sizeof(CDataFileImageHeader);
image->tile_size= CDF_TILE_SIZE;
}
- else if(cdf->type == CDF_TYPE_MESH) {
+ else if (cdf->type == CDF_TYPE_MESH) {
/* fill mesh header */
mesh= &cdf->btype.mesh;
mesh->structbytes= sizeof(CDataFileMeshHeader);
@@ -394,7 +394,7 @@ int cdf_write_layer(CDataFile *UNUSED(cdf), CDataFileLayer *UNUSED(blay))
int cdf_write_data(CDataFile *cdf, unsigned int size, void *data)
{
/* write data */
- if(!fwrite(data, size, 1, cdf->writef))
+ if (!fwrite(data, size, 1, cdf->writef))
return 0;
return 1;
@@ -402,7 +402,7 @@ int cdf_write_data(CDataFile *cdf, unsigned int size, void *data)
void cdf_write_close(CDataFile *cdf)
{
- if(cdf->writef) {
+ if (cdf->writef) {
fclose(cdf->writef);
cdf->writef= NULL;
}
@@ -420,10 +420,10 @@ CDataFileLayer *cdf_layer_find(CDataFile *cdf, int type, const char *name)
CDataFileLayer *layer;
int a;
- for(a=0; a<cdf->totlayer; a++) {
+ for (a=0; a<cdf->totlayer; a++) {
layer= &cdf->layer[a];
- if(layer->type == type && strcmp(layer->name, name) == 0)
+ if (layer->type == type && strcmp(layer->name, name) == 0)
return layer;
}
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c
index c178a4ef6ea..35824d895db 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -169,7 +169,8 @@ void push_queue(DagNodeQueue *queue, DagNode *node)
queue->freenodes->first = NULL;
}
queue->freenodes->count--;
- } else { /* alllocating more */
+ }
+ else { /* alllocating more */
elem = MEM_mallocN(sizeof(DagNodeQueueElem),"DAG queue elem1");
elem->node = NULL;
elem->next = NULL;
@@ -213,7 +214,8 @@ void push_stack(DagNodeQueue *queue, DagNode *node)
queue->freenodes->first = NULL;
}
queue->freenodes->count--;
- } else { /* alllocating more */
+ }
+ else { /* alllocating more */
elem = MEM_mallocN(sizeof(DagNodeQueueElem),"DAG queue elem1");
elem->node = NULL;
elem->next = NULL;
@@ -263,7 +265,8 @@ DagNode * pop_queue(DagNodeQueue *queue)
elem->next = NULL;
queue->freenodes->count++;
return node;
- } else {
+ }
+ else {
fprintf(stderr,"return null \n");
return NULL;
}
@@ -346,10 +349,10 @@ static void dag_add_collision_field_relation(DagForest *dag, Scene *scene, Objec
// would be nice to have a list of colliders here
// so for now walk all objects in scene check 'same layer rule'
- for(base = scene->base.first; base; base= base->next) {
- if((base->lay & ob->lay) && base->object->pd) {
+ for (base = scene->base.first; base; base= base->next) {
+ if ((base->lay & ob->lay) && base->object->pd) {
Object *ob1= base->object;
- if((ob1->pd->deflect || ob1->pd->forcefield) && (ob1 != ob)) {
+ if ((ob1->pd->deflect || ob1->pd->forcefield) && (ob1 != ob)) {
node2 = dag_get_node(dag, ob1);
dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Field Collision");
}
@@ -400,10 +403,10 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
if (ct->subtarget[0]) {
dag_add_relation(dag,node3,node, DAG_RL_OB_DATA|DAG_RL_DATA_DATA, cti->name);
- if(ct->tar->type == OB_MESH)
+ if (ct->tar->type == OB_MESH)
node3->customdata_mask |= CD_MASK_MDEFORMVERT;
}
- else if(ELEM3(con->type, CONSTRAINT_TYPE_FOLLOWPATH, CONSTRAINT_TYPE_CLAMPTO, CONSTRAINT_TYPE_SPLINEIK))
+ else if (ELEM3(con->type, CONSTRAINT_TYPE_FOLLOWPATH, CONSTRAINT_TYPE_CLAMPTO, CONSTRAINT_TYPE_SPLINEIK))
dag_add_relation(dag,node3,node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, cti->name);
else
dag_add_relation(dag,node3,node, DAG_RL_OB_DATA, cti->name);
@@ -421,14 +424,14 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
/* driver dependencies, nla modifiers */
#if 0 // XXX old animation system
- if(ob->nlastrips.first) {
+ if (ob->nlastrips.first) {
bActionStrip *strip;
bActionChannel *chan;
- for(strip= ob->nlastrips.first; strip; strip= strip->next) {
- if(strip->modifiers.first) {
+ for (strip= ob->nlastrips.first; strip; strip= strip->next) {
+ if (strip->modifiers.first) {
bActionModifier *amod;
- for(amod= strip->modifiers.first; amod; amod= amod->next) {
- if(amod->ob) {
+ for (amod= strip->modifiers.first; amod; amod= amod->next) {
+ if (amod->ob) {
node2 = dag_get_node(dag, amod->ob);
dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "NLA Strip Modifier");
}
@@ -447,7 +450,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
if (ob->modifiers.first) {
ModifierData *md;
- for(md=ob->modifiers.first; md; md=md->next) {
+ for (md=ob->modifiers.first; md; md=md->next) {
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
if (mti->updateDepgraph) mti->updateDepgraph(md, dag, scene, ob, node);
@@ -468,11 +471,11 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
dag_add_relation(dag,node2,node,DAG_RL_DATA_OB|DAG_RL_OB_OB, "Bone Parent");
break;
default:
- if(ob->parent->type==OB_LATTICE)
+ if (ob->parent->type==OB_LATTICE)
dag_add_relation(dag,node2,node,DAG_RL_DATA_DATA|DAG_RL_OB_OB, "Lattice Parent");
- else if(ob->parent->type==OB_CURVE) {
+ else if (ob->parent->type==OB_CURVE) {
Curve *cu= ob->parent->data;
- if(cu->flag & CU_PATH)
+ if (cu->flag & CU_PATH)
dag_add_relation(dag,node2,node,DAG_RL_DATA_OB|DAG_RL_OB_OB, "Curve Parent");
else
dag_add_relation(dag,node2,node,DAG_RL_OB_OB, "Curve Parent");
@@ -481,7 +484,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
dag_add_relation(dag,node2,node,DAG_RL_OB_OB, "Parent");
}
/* exception case: parent is duplivert */
- if(ob->type==OB_MBALL && (ob->parent->transflag & OB_DUPLIVERTS)) {
+ if (ob->type==OB_MBALL && (ob->parent->transflag & OB_DUPLIVERTS)) {
dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_OB, "Duplivert");
}
@@ -494,10 +497,10 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
}
if (ob->transflag & OB_DUPLI) {
- if((ob->transflag & OB_DUPLIGROUP) && ob->dup_group) {
+ if ((ob->transflag & OB_DUPLIGROUP) && ob->dup_group) {
GroupObject *go;
- for(go= ob->dup_group->gobject.first; go; go= go->next) {
- if(go->ob) {
+ for (go= ob->dup_group->gobject.first; go; go= go->next) {
+ if (go->ob) {
node2 = dag_get_node(dag, go->ob);
/* node2 changes node1, this keeps animations updated in groups?? not logical? */
dag_add_relation(dag, node2, node, DAG_RL_OB_OB, "Dupligroup");
@@ -508,7 +511,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
/* softbody collision */
if ((ob->type==OB_MESH) || (ob->type==OB_CURVE) || (ob->type==OB_LATTICE)) {
- if(modifiers_isSoftbodyEnabled(ob) || modifiers_isClothEnabled(ob) || ob->particlesystem.first)
+ if (modifiers_isSoftbodyEnabled(ob) || modifiers_isClothEnabled(ob) || ob->particlesystem.first)
dag_add_collision_field_relation(dag, scene, ob, node); /* TODO: use effectorweight->group */
}
@@ -535,7 +538,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
{
Object *mom= find_basis_mball(scene, ob);
- if(mom!=ob) {
+ if (mom!=ob) {
node2 = dag_get_node(dag, mom);
dag_add_relation(dag,node,node2,DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Metaball"); // mom depends on children!
}
@@ -546,16 +549,16 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
{
Curve *cu= ob->data;
- if(cu->bevobj) {
+ if (cu->bevobj) {
node2 = dag_get_node(dag, cu->bevobj);
dag_add_relation(dag,node2,node,DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Curve Bevel");
}
- if(cu->taperobj) {
+ if (cu->taperobj) {
node2 = dag_get_node(dag, cu->taperobj);
dag_add_relation(dag,node2,node,DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Curve Taper");
}
- if(ob->type == OB_FONT) {
- if(cu->textoncurve) {
+ if (ob->type == OB_FONT) {
+ if (cu->textoncurve) {
node2 = dag_get_node(dag, cu->textoncurve);
dag_add_relation(dag,node2,node,DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Texture On Curve");
}
@@ -566,10 +569,10 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
/* particles */
psys= ob->particlesystem.first;
- if(psys) {
+ if (psys) {
GroupObject *go;
- for(; psys; psys=psys->next) {
+ for (; psys; psys=psys->next) {
BoidRule *rule = NULL;
BoidState *state = NULL;
ParticleSettings *part= psys->part;
@@ -578,32 +581,32 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
dag_add_relation(dag, node, node, DAG_RL_OB_DATA, "Particle-Object Relation");
- if(!psys_check_enabled(ob, psys))
+ if (!psys_check_enabled(ob, psys))
continue;
- if(ELEM(part->phystype,PART_PHYS_KEYED,PART_PHYS_BOIDS)) {
+ if (ELEM(part->phystype,PART_PHYS_KEYED,PART_PHYS_BOIDS)) {
ParticleTarget *pt = psys->targets.first;
- for(; pt; pt=pt->next) {
- if(pt->ob && BLI_findlink(&pt->ob->particlesystem, pt->psys-1)) {
+ for (; pt; pt=pt->next) {
+ if (pt->ob && BLI_findlink(&pt->ob->particlesystem, pt->psys-1)) {
node2 = dag_get_node(dag, pt->ob);
dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Particle Targets");
}
}
}
- if(part->ren_as == PART_DRAW_OB && part->dup_ob) {
+ if (part->ren_as == PART_DRAW_OB && part->dup_ob) {
node2 = dag_get_node(dag, part->dup_ob);
/* note that this relation actually runs in the wrong direction, the problem
* is that dupli system all have this (due to parenting), and the render
* engine instancing assumes particular ordering of objects in list */
dag_add_relation(dag, node, node2, DAG_RL_OB_OB, "Particle Object Visualisation");
- if(part->dup_ob->type == OB_MBALL)
+ if (part->dup_ob->type == OB_MBALL)
dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA, "Particle Object Visualisation");
}
- if(part->ren_as == PART_DRAW_GR && part->dup_group) {
- for(go=part->dup_group->gobject.first; go; go=go->next) {
+ if (part->ren_as == PART_DRAW_GR && part->dup_group) {
+ for (go=part->dup_group->gobject.first; go; go=go->next) {
node2 = dag_get_node(dag, go->ob);
dag_add_relation(dag, node2, node, DAG_RL_OB_OB, "Particle Group Visualisation");
}
@@ -611,8 +614,8 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
effectors = pdInitEffectors(scene, ob, psys, part->effector_weights);
- if(effectors) for(eff = effectors->first; eff; eff=eff->next) {
- if(eff->psys) {
+ if (effectors) for(eff = effectors->first; eff; eff=eff->next) {
+ if (eff->psys) {
node2 = dag_get_node(dag, eff->ob);
dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Particle Field");
}
@@ -620,16 +623,16 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
pdEndEffectors(&effectors);
- if(part->boids) {
- for(state = part->boids->states.first; state; state=state->next) {
- for(rule = state->rules.first; rule; rule=rule->next) {
+ if (part->boids) {
+ for (state = part->boids->states.first; state; state=state->next) {
+ for (rule = state->rules.first; rule; rule=rule->next) {
Object *ruleob = NULL;
- if(rule->type==eBoidRuleType_Avoid)
+ if (rule->type==eBoidRuleType_Avoid)
ruleob = ((BoidRuleGoalAvoid*)rule)->ob;
- else if(rule->type==eBoidRuleType_FollowLeader)
+ else if (rule->type==eBoidRuleType_FollowLeader)
ruleob = ((BoidRuleFollowLeader*)rule)->ob;
- if(ruleob) {
+ if (ruleob) {
node2 = dag_get_node(dag, ruleob);
dag_add_relation(dag, node2, node, DAG_RL_OB_DATA, "Boid Rule");
}
@@ -645,28 +648,28 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
- if(!cti)
+ if (!cti)
continue;
/* special case for camera tracking -- it doesn't use targets to define relations */
- if(ELEM3(cti->type, CONSTRAINT_TYPE_FOLLOWTRACK, CONSTRAINT_TYPE_CAMERASOLVER, CONSTRAINT_TYPE_OBJECTSOLVER)) {
+ if (ELEM3(cti->type, CONSTRAINT_TYPE_FOLLOWTRACK, CONSTRAINT_TYPE_CAMERASOLVER, CONSTRAINT_TYPE_OBJECTSOLVER)) {
int depends_on_camera= 0;
- if(cti->type==CONSTRAINT_TYPE_FOLLOWTRACK) {
+ if (cti->type==CONSTRAINT_TYPE_FOLLOWTRACK) {
bFollowTrackConstraint *data= (bFollowTrackConstraint *)con->data;
- if((data->clip || data->flag&FOLLOWTRACK_ACTIVECLIP) && data->track[0])
+ if ((data->clip || data->flag&FOLLOWTRACK_ACTIVECLIP) && data->track[0])
depends_on_camera= 1;
- if(data->depth_ob) {
+ if (data->depth_ob) {
node2 = dag_get_node(dag, data->depth_ob);
dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, cti->name);
}
}
- else if(cti->type==CONSTRAINT_TYPE_OBJECTSOLVER)
+ else if (cti->type==CONSTRAINT_TYPE_OBJECTSOLVER)
depends_on_camera= 1;
- if(depends_on_camera && scene->camera) {
+ if (depends_on_camera && scene->camera) {
node2 = dag_get_node(dag, scene->camera);
dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, cti->name);
}
@@ -733,22 +736,22 @@ struct DagForest *build_dag(Main *bmain, Scene *sce, short mask)
scenenode = dag_add_node(dag, sce);
/* add current scene objects */
- for(base = sce->base.first; base; base= base->next) {
+ for (base = sce->base.first; base; base= base->next) {
ob= base->object;
build_dag_object(dag, scenenode, sce, ob, mask);
- if(ob->proxy)
+ if (ob->proxy)
build_dag_object(dag, scenenode, sce, ob->proxy, mask);
/* handled in next loop */
- if(ob->dup_group)
+ if (ob->dup_group)
ob->dup_group->id.flag |= LIB_DOIT;
}
/* add groups used in current scene objects */
- for(group= bmain->group.first; group; group= group->id.next) {
- if(group->id.flag & LIB_DOIT) {
- for(go= group->gobject.first; go; go= go->next) {
+ for (group= bmain->group.first; group; group= group->id.next) {
+ if (group->id.flag & LIB_DOIT) {
+ for (go= group->gobject.first; go; go= go->next) {
build_dag_object(dag, scenenode, sce, go->ob, mask);
}
group->id.flag &= ~LIB_DOIT;
@@ -760,10 +763,10 @@ struct DagForest *build_dag(Main *bmain, Scene *sce, short mask)
* the relation type has to be synced. One of the parents can change, and should give same event to child */
/* nodes were callocced, so we can use node->color for temporal storage */
- for(node = sce->theDag->DagNode.first; node; node= node->next) {
- if(node->type==ID_OB) {
- for(itA = node->child; itA; itA= itA->next) {
- if(itA->node->type==ID_OB) {
+ for (node = sce->theDag->DagNode.first; node; node= node->next) {
+ if (node->type==ID_OB) {
+ for (itA = node->child; itA; itA= itA->next) {
+ if (itA->node->type==ID_OB) {
itA->node->color |= itA->type;
}
}
@@ -773,10 +776,10 @@ struct DagForest *build_dag(Main *bmain, Scene *sce, short mask)
}
}
/* now set relations equal, so that when only one parent changes, the correct recalcs are found */
- for(node = sce->theDag->DagNode.first; node; node= node->next) {
- if(node->type==ID_OB) {
- for(itA = node->child; itA; itA= itA->next) {
- if(itA->node->type==ID_OB) {
+ for (node = sce->theDag->DagNode.first; node; node= node->next) {
+ if (node->type==ID_OB) {
+ for (itA = node->child; itA; itA= itA->next) {
+ if (itA->node->type==ID_OB) {
itA->type |= itA->node->color;
}
}
@@ -827,7 +830,7 @@ void free_forest(DagForest *Dag)
DagNode * dag_find_node (DagForest *forest,void * fob)
{
- if(forest->nodeHash)
+ if (forest->nodeHash)
return BLI_ghash_lookup(forest->nodeHash, fob);
return NULL;
@@ -846,18 +849,19 @@ DagNode * dag_add_node (DagForest *forest, void * fob)
node->ob = fob;
node->color = DAG_WHITE;
- if(ugly_hack_sorry) node->type = GS(((ID *) fob)->name); // sorry, done for pose sorting
+ if (ugly_hack_sorry) node->type = GS(((ID *) fob)->name); // sorry, done for pose sorting
if (forest->numNodes) {
((DagNode *) forest->DagNode.last)->next = node;
forest->DagNode.last = node;
forest->numNodes++;
- } else {
+ }
+ else {
forest->DagNode.last = node;
forest->DagNode.first = node;
forest->numNodes = 1;
}
- if(!forest->nodeHash)
+ if (!forest->nodeHash)
forest->nodeHash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "dag_add_node gh");
BLI_ghash_insert(forest->nodeHash, fob, node);
}
@@ -890,7 +894,8 @@ DagNode * dag_get_sub_node (DagForest *forest,void * fob)
prev->next = mainchild->next;
MEM_freeN(mainchild);
break;
- } else {
+ }
+ else {
((DagNode *) forest->DagNode.first)->child = mainchild->next;
MEM_freeN(mainchild);
break;
@@ -954,9 +959,9 @@ void dag_add_relation(DagForest *forest, DagNode *fob1, DagNode *fob2, short rel
static const char *dag_node_name(DagNode *node)
{
- if(node->ob == NULL)
+ if (node->ob == NULL)
return "null";
- else if(ugly_hack_sorry)
+ else if (ugly_hack_sorry)
return ((ID*)(node->ob))->name+2;
else
return ((bPoseChannel*)(node->ob))->name;
@@ -968,7 +973,7 @@ static void dag_node_print_dependencies(DagNode *node)
printf("%s depends on:\n", dag_node_name(node));
- for(itA= node->parent; itA; itA= itA->next)
+ for (itA= node->parent; itA; itA= itA->next)
printf(" %s through %s\n", dag_node_name(itA->node), itA->name);
printf("\n");
}
@@ -977,16 +982,16 @@ static int dag_node_print_dependency_recurs(DagNode *node, DagNode *endnode)
{
DagAdjList *itA;
- if(node->color == DAG_BLACK)
+ if (node->color == DAG_BLACK)
return 0;
node->color= DAG_BLACK;
- if(node == endnode)
+ if (node == endnode)
return 1;
- for(itA= node->parent; itA; itA= itA->next) {
- if(dag_node_print_dependency_recurs(itA->node, endnode)) {
+ for (itA= node->parent; itA; itA= itA->next) {
+ if (dag_node_print_dependency_recurs(itA->node, endnode)) {
printf(" %s depends on %s through %s.\n", dag_node_name(node), dag_node_name(itA->node), itA->name);
return 1;
}
@@ -999,7 +1004,7 @@ static void dag_node_print_dependency_cycle(DagForest *dag, DagNode *startnode,
{
DagNode *node;
- for(node = dag->DagNode.first; node; node= node->next)
+ for (node = dag->DagNode.first; node; node= node->next)
node->color= DAG_WHITE;
printf(" %s depends on %s through %s.\n", dag_node_name(endnode), dag_node_name(startnode), name);
@@ -1015,8 +1020,8 @@ static int dag_node_recurs_level(DagNode *node, int level)
node->color= DAG_BLACK; /* done */
newlevel= ++level;
- for(itA= node->parent; itA; itA= itA->next) {
- if(itA->node->color==DAG_WHITE) {
+ for (itA= node->parent; itA; itA= itA->next) {
+ if (itA->node->color==DAG_WHITE) {
itA->node->ancestor_count= dag_node_recurs_level(itA->node, level);
newlevel= MAX2(newlevel, level+itA->node->ancestor_count);
}
@@ -1033,25 +1038,25 @@ static void dag_check_cycle(DagForest *dag)
DagAdjList *itA;
/* debugging print */
- if(dag_print_dependencies)
- for(node = dag->DagNode.first; node; node= node->next)
+ if (dag_print_dependencies)
+ for (node = dag->DagNode.first; node; node= node->next)
dag_node_print_dependencies(node);
/* tag nodes unchecked */
- for(node = dag->DagNode.first; node; node= node->next)
+ for (node = dag->DagNode.first; node; node= node->next)
node->color= DAG_WHITE;
- for(node = dag->DagNode.first; node; node= node->next) {
- if(node->color==DAG_WHITE) {
+ for (node = dag->DagNode.first; node; node= node->next) {
+ if (node->color==DAG_WHITE) {
node->ancestor_count= dag_node_recurs_level(node, 0);
}
}
/* check relations, and print errors */
- for(node = dag->DagNode.first; node; node= node->next) {
- for(itA= node->parent; itA; itA= itA->next) {
- if(itA->node->ancestor_count > node->ancestor_count) {
- if(node->ob && itA->node->ob) {
+ for (node = dag->DagNode.first; node; node= node->next) {
+ for (itA= node->parent; itA; itA= itA->next) {
+ if (itA->node->ancestor_count > node->ancestor_count) {
+ if (node->ob && itA->node->ob) {
printf("Dependency cycle detected:\n");
dag_node_print_dependency_cycle(dag, itA->node, node, itA->name);
}
@@ -1060,7 +1065,7 @@ static void dag_check_cycle(DagForest *dag)
}
/* parent relations are only needed for cycle checking, so free now */
- for(node = dag->DagNode.first; node; node= node->next) {
+ for (node = dag->DagNode.first; node; node= node->next) {
while (node->parent) {
itA = node->parent->next;
MEM_freeN(node->parent);
@@ -1119,7 +1124,7 @@ void graph_bfs(void)
* dagnode.first is always the root (scene)
*/
node = MainDag->DagNode.first;
- while(node) {
+ while (node) {
node->color = DAG_WHITE;
node->BFS_dist = 9999;
node->k = 0;
@@ -1131,13 +1136,13 @@ void graph_bfs(void)
node->color = DAG_GRAY;
node->BFS_dist = 1;
push_queue(nqueue,node);
- while(nqueue->count) {
+ while (nqueue->count) {
node = pop_queue(nqueue);
minheight = pos[node->BFS_dist];
itA = node->child;
- while(itA != NULL) {
- if(itA->node->color == DAG_WHITE) {
+ while (itA != NULL) {
+ if (itA->node->color == DAG_WHITE) {
itA->node->color = DAG_GRAY;
itA->node->BFS_dist = node->BFS_dist + 1;
itA->node->k = (float) minheight;
@@ -1154,7 +1159,8 @@ void graph_bfs(void)
if (pos[node->BFS_dist] > node->k ) {
pos[node->BFS_dist] += 1;
node->k = (float) pos[node->BFS_dist];
- } else {
+ }
+ else {
pos[node->BFS_dist] = (int) node->k +1;
}
set_node_xy(node, node->BFS_dist*DEPSX*2, pos[node->BFS_dist]*DEPSY*2);
@@ -1188,7 +1194,7 @@ int pre_and_post_source_BFS(DagForest *dag, short mask, DagNode *source, graph_a
*/
node = dag->DagNode.first;
nqueue = queue_create(DAGQUEUEALLOC);
- while(node) {
+ while (node) {
node->color = DAG_WHITE;
node->BFS_dist = 9999;
node = node->next;
@@ -1200,12 +1206,12 @@ int pre_and_post_source_BFS(DagForest *dag, short mask, DagNode *source, graph_a
node->BFS_dist = 1;
pre_func(node->ob,data);
- while(nqueue->count) {
+ while (nqueue->count) {
node = pop_queue(nqueue);
itA = node->child;
- while(itA != NULL) {
- if((itA->node->color == DAG_WHITE) && (itA->type & mask)) {
+ while (itA != NULL) {
+ if ((itA->node->color == DAG_WHITE) && (itA->type & mask)) {
itA->node->color = DAG_GRAY;
itA->node->BFS_dist = node->BFS_dist + 1;
push_queue(nqueue,itA->node);
@@ -1253,7 +1259,7 @@ DagNodeQueue * graph_dfs(void)
* dagnode.first is always the root (scene)
*/
node = MainDag->DagNode.first;
- while(node) {
+ while (node) {
node->color = DAG_WHITE;
node->DFS_dist = 9999;
node->DFS_dvtm = node->DFS_fntm = 9999;
@@ -1273,7 +1279,7 @@ DagNodeQueue * graph_dfs(void)
time++;
push_stack(nqueue,node);
- while(nqueue->count) {
+ while (nqueue->count) {
//graph_print_queue(nqueue);
skip = 0;
@@ -1282,8 +1288,8 @@ DagNodeQueue * graph_dfs(void)
minheight = pos[node->DFS_dist];
itA = node->child;
- while(itA != NULL) {
- if(itA->node->color == DAG_WHITE) {
+ while (itA != NULL) {
+ if (itA->node->color == DAG_WHITE) {
itA->node->DFS_dvtm = time;
itA->node->color = DAG_GRAY;
@@ -1293,11 +1299,13 @@ DagNodeQueue * graph_dfs(void)
push_stack(nqueue,itA->node);
skip = 1;
break;
- } else {
+ }
+ else {
if (itA->node->color == DAG_GRAY) { // back edge
fprintf(stderr,"dfs back edge :%15s %15s \n",((ID *) node->ob)->name, ((ID *) itA->node->ob)->name);
/* is_cycle = 1; */ /* UNUSED */
- } else if (itA->node->color == DAG_BLACK) {
+ }
+ else if (itA->node->color == DAG_BLACK) {
;
/* already processed node but we may want later to change distance either to shorter to longer.
* DFS_dist is the first encounter
@@ -1313,7 +1321,8 @@ DagNodeQueue * graph_dfs(void)
itA->node->DFS_dvtm,
itA->node->DFS_fntm);
*/
- } else
+ }
+ else
fprintf(stderr,"dfs unknown edge \n");
}
itA = itA->next;
@@ -1330,7 +1339,8 @@ DagNodeQueue * graph_dfs(void)
if (pos[node->DFS_dist] > node->k ) {
pos[node->DFS_dist] += 1;
node->k = (float) pos[node->DFS_dist];
- } else {
+ }
+ else {
pos[node->DFS_dist] = (int) node->k +1;
}
set_node_xy(node, node->DFS_dist*DEPSX*2, pos[node->DFS_dist]*DEPSY*2);
@@ -1376,7 +1386,7 @@ int pre_and_post_source_DFS(DagForest *dag, short mask, DagNode *source, graph_a
* dagnode.first is always the root (scene)
*/
node = dag->DagNode.first;
- while(node) {
+ while (node) {
node->color = DAG_WHITE;
node->DFS_dist = 9999;
node->DFS_dvtm = node->DFS_fntm = 9999;
@@ -1396,13 +1406,13 @@ int pre_and_post_source_DFS(DagForest *dag, short mask, DagNode *source, graph_a
push_stack(nqueue,node);
pre_func(node->ob,data);
- while(nqueue->count) {
+ while (nqueue->count) {
skip = 0;
node = get_top_node_queue(nqueue);
itA = node->child;
- while(itA != NULL) {
- if((itA->node->color == DAG_WHITE) && (itA->type & mask) ) {
+ while (itA != NULL) {
+ if ((itA->node->color == DAG_WHITE) && (itA->type & mask) ) {
itA->node->DFS_dvtm = time;
itA->node->color = DAG_GRAY;
@@ -1413,7 +1423,8 @@ int pre_and_post_source_DFS(DagForest *dag, short mask, DagNode *source, graph_a
skip = 1;
break;
- } else {
+ }
+ else {
if (itA->node->color == DAG_GRAY) {// back edge
retval = 1;
}
@@ -1449,20 +1460,21 @@ struct DagNodeQueue *get_obparents(struct DagForest *dag, void *ob)
DagAdjList *itA;
node = dag_find_node(dag,ob);
- if(node==NULL) {
+ if (node==NULL) {
return NULL;
}
else if (node->ancestor_count == 1) { // simple case
nqueue = queue_create(1);
push_queue(nqueue,node);
- } else { // need to go over the whole dag for adj list
+ }
+ else { /* need to go over the whole dag for adj list */
nqueue = queue_create(node->ancestor_count);
node1 = dag->DagNode.first;
do {
if (node1->DFS_fntm > node->DFS_fntm) { // a parent is finished after child. must check adj list
itA = node->child;
- while(itA != NULL) {
+ while (itA != NULL) {
if ((itA->node == node) && (itA->type == DAG_RL_DATA)) {
push_queue(nqueue,node);
}
@@ -1490,7 +1502,7 @@ struct DagNodeQueue *get_first_ancestors(struct DagForest *dag, void *ob)
do {
if (node1->DFS_fntm > node->DFS_fntm) {
itA = node->child;
- while(itA != NULL) {
+ while (itA != NULL) {
if (itA->node == node) {
push_queue(nqueue,node);
}
@@ -1517,7 +1529,7 @@ struct DagNodeQueue *get_all_childs(struct DagForest *dag, void *ob)
retqueue = queue_create(dag->numNodes); // was MainDag... why? (ton)
node = dag->DagNode.first;
- while(node) {
+ while (node) {
node->color = DAG_WHITE;
node = node->next;
}
@@ -1525,20 +1537,20 @@ struct DagNodeQueue *get_all_childs(struct DagForest *dag, void *ob)
time = 1;
node = dag_find_node(dag, ob); // could be done in loop above (ton)
- if(node) { // can be null for newly added objects
+ if (node) { // can be null for newly added objects
node->color = DAG_GRAY;
time++;
push_stack(nqueue,node);
- while(nqueue->count) {
+ while (nqueue->count) {
skip = 0;
node = get_top_node_queue(nqueue);
itA = node->child;
- while(itA != NULL) {
- if(itA->node->color == DAG_WHITE) {
+ while (itA != NULL) {
+ if (itA->node->color == DAG_WHITE) {
itA->node->DFS_dvtm = time;
itA->node->color = DAG_GRAY;
@@ -1572,8 +1584,8 @@ short are_obs_related(struct DagForest *dag, void *ob1, void *ob2)
node = dag_find_node(dag, ob1);
itA = node->child;
- while(itA != NULL) {
- if(itA->node->ob == ob2) {
+ while (itA != NULL) {
+ if (itA->node->ob == ob2) {
return itA->node->type;
}
itA = itA->next;
@@ -1600,7 +1612,7 @@ void graph_print_queue(DagNodeQueue *nqueue)
DagNodeQueueElem *queueElem;
queueElem = nqueue->first;
- while(queueElem) {
+ while (queueElem) {
fprintf(stderr,"** %s %i %i-%i ",((ID *) queueElem->node->ob)->name,queueElem->node->color,queueElem->node->DFS_dvtm,queueElem->node->DFS_fntm);
queueElem = queueElem->next;
}
@@ -1614,7 +1626,7 @@ void graph_print_queue_dist(DagNodeQueue *nqueue)
queueElem = nqueue->first;
count = 0;
- while(queueElem) {
+ while (queueElem) {
fprintf(stderr,"** %25s %2.2i-%2.2i ",((ID *) queueElem->node->ob)->name,queueElem->node->DFS_dvtm,queueElem->node->DFS_fntm);
while (count < queueElem->node->DFS_dvtm-1) { fputc(' ',stderr); count++;}
fputc('|',stderr);
@@ -1633,7 +1645,7 @@ void graph_print_adj_list(void)
DagAdjList *itA;
node = (getMainDag())->DagNode.first;
- while(node) {
+ while (node) {
fprintf(stderr,"node : %s col: %i",((ID *) node->ob)->name, node->color);
itA = node->child;
while (itA) {
@@ -1661,13 +1673,13 @@ void DAG_editors_update_cb(void (*id_func)(Main *bmain, ID *id), void (*scene_fu
static void dag_editors_id_update(Main *bmain, ID *id)
{
- if(EditorsUpdateIDCb)
+ if (EditorsUpdateIDCb)
EditorsUpdateIDCb(bmain, id);
}
static void dag_editors_scene_update(Main *bmain, Scene *scene, int updated)
{
- if(EditorsUpdateSceneCb)
+ if (EditorsUpdateSceneCb)
EditorsUpdateSceneCb(bmain, scene, updated);
}
@@ -1680,29 +1692,29 @@ static void scene_sort_groups(Main *bmain, Scene *sce)
Object *ob;
/* test; are group objects all in this scene? */
- for(ob= bmain->object.first; ob; ob= ob->id.next) {
+ for (ob= bmain->object.first; ob; ob= ob->id.next) {
ob->id.flag &= ~LIB_DOIT;
ob->id.newid= NULL; /* newid abuse for GroupObject */
}
- for(base = sce->base.first; base; base= base->next)
+ for (base = sce->base.first; base; base= base->next)
base->object->id.flag |= LIB_DOIT;
- for(group= bmain->group.first; group; group= group->id.next) {
- for(go= group->gobject.first; go; go= go->next) {
- if((go->ob->id.flag & LIB_DOIT)==0)
+ for (group= bmain->group.first; group; group= group->id.next) {
+ for (go= group->gobject.first; go; go= go->next) {
+ if ((go->ob->id.flag & LIB_DOIT)==0)
break;
}
/* this group is entirely in this scene */
- if(go==NULL) {
+ if (go==NULL) {
ListBase listb= {NULL, NULL};
- for(go= group->gobject.first; go; go= go->next)
+ for (go= group->gobject.first; go; go= go->next)
go->ob->id.newid= (ID *)go;
/* in order of sorted bases we reinsert group objects */
- for(base = sce->base.first; base; base= base->next) {
+ for (base = sce->base.first; base; base= base->next) {
- if(base->object->id.newid) {
+ if (base->object->id.newid) {
go= (GroupObject *)base->object->id.newid;
base->object->id.newid= NULL;
BLI_remlink( &group->gobject, go);
@@ -1734,7 +1746,7 @@ void DAG_scene_sort(Main *bmain, Scene *sce)
nqueue = queue_create(DAGQUEUEALLOC);
- for(node = sce->theDag->DagNode.first; node; node= node->next) {
+ for (node = sce->theDag->DagNode.first; node; node= node->next) {
node->color = DAG_WHITE;
}
@@ -1745,14 +1757,14 @@ void DAG_scene_sort(Main *bmain, Scene *sce)
time++;
push_stack(nqueue,rootnode);
- while(nqueue->count) {
+ while (nqueue->count) {
skip = 0;
node = get_top_node_queue(nqueue);
itA = node->child;
- while(itA != NULL) {
- if(itA->node->color == DAG_WHITE) {
+ while (itA != NULL) {
+ if (itA->node->color == DAG_WHITE) {
itA->node->DFS_dvtm = time;
itA->node->color = DAG_GRAY;
@@ -1775,7 +1787,7 @@ void DAG_scene_sort(Main *bmain, Scene *sce)
base = sce->base.first;
while (base && base->object != node->ob)
base = base->next;
- if(base) {
+ if (base) {
BLI_remlink(&sce->base,base);
BLI_addhead(&tempbase,base);
}
@@ -1799,9 +1811,9 @@ void DAG_scene_sort(Main *bmain, Scene *sce)
/* all groups with objects in this scene gets resorted too */
scene_sort_groups(bmain, sce);
- if(G.f & G_DEBUG) {
+ if (G.f & G_DEBUG) {
printf("\nordered\n");
- for(base = sce->base.first; base; base= base->next) {
+ for (base = sce->base.first; base; base= base->next) {
printf(" %s\n", base->object->id.name);
}
}
@@ -1833,51 +1845,51 @@ static void flush_update_node(DagNode *node, unsigned int layer, int curtime)
node->lasttime= curtime;
ob= node->ob;
- if(ob && (ob->recalc & OB_RECALC_ALL)) {
+ if (ob && (ob->recalc & OB_RECALC_ALL)) {
all_layer= node->scelay;
/* got an object node that changes, now check relations */
- for(itA = node->child; itA; itA= itA->next) {
+ for (itA = node->child; itA; itA= itA->next) {
all_layer |= itA->lay;
/* the relationship is visible */
- if((itA->lay & layer)) { // XXX || (itA->node->ob == obedit)
- if(itA->node->type==ID_OB) {
+ if ((itA->lay & layer)) { // XXX || (itA->node->ob == obedit)
+ if (itA->node->type==ID_OB) {
obc= itA->node->ob;
oldflag= obc->recalc;
/* got a ob->obc relation, now check if flag needs flush */
- if(ob->recalc & OB_RECALC_OB) {
- if(itA->type & DAG_RL_OB_OB) {
+ if (ob->recalc & OB_RECALC_OB) {
+ if (itA->type & DAG_RL_OB_OB) {
//printf("ob %s changes ob %s\n", ob->id.name, obc->id.name);
obc->recalc |= OB_RECALC_OB;
lib_id_recalc_tag(bmain, &obc->id);
}
- if(itA->type & DAG_RL_OB_DATA) {
+ if (itA->type & DAG_RL_OB_DATA) {
//printf("ob %s changes obdata %s\n", ob->id.name, obc->id.name);
obc->recalc |= OB_RECALC_DATA;
lib_id_recalc_data_tag(bmain, &obc->id);
}
}
- if(ob->recalc & OB_RECALC_DATA) {
- if(itA->type & DAG_RL_DATA_OB) {
+ if (ob->recalc & OB_RECALC_DATA) {
+ if (itA->type & DAG_RL_DATA_OB) {
//printf("obdata %s changes ob %s\n", ob->id.name, obc->id.name);
obc->recalc |= OB_RECALC_OB;
lib_id_recalc_tag(bmain, &obc->id);
}
- if(itA->type & DAG_RL_DATA_DATA) {
+ if (itA->type & DAG_RL_DATA_DATA) {
//printf("obdata %s changes obdata %s\n", ob->id.name, obc->id.name);
obc->recalc |= OB_RECALC_DATA;
lib_id_recalc_data_tag(bmain, &obc->id);
}
}
- if(oldflag!=obc->recalc) changed= 1;
+ if (oldflag!=obc->recalc) changed= 1;
}
}
}
/* even nicer, we can clear recalc flags... */
- if((all_layer & layer)==0) { // XXX && (ob != obedit)) {
+ if ((all_layer & layer)==0) { // XXX && (ob != obedit)) {
/* but existing displaylists or derivedmesh should be freed */
- if(ob->recalc & OB_RECALC_DATA)
+ if (ob->recalc & OB_RECALC_DATA)
object_free_display(ob);
ob->recalc &= ~OB_RECALC_ALL;
@@ -1887,15 +1899,15 @@ static void flush_update_node(DagNode *node, unsigned int layer, int curtime)
/* check case where child changes and parent forcing obdata to change */
/* should be done regardless if this ob has recalc set */
/* could merge this in with loop above...? (ton) */
- for(itA = node->child; itA; itA= itA->next) {
+ for (itA = node->child; itA; itA= itA->next) {
/* the relationship is visible */
- if((itA->lay & layer)) { // XXX || (itA->node->ob == obedit)
- if(itA->node->type==ID_OB) {
+ if ((itA->lay & layer)) { // XXX || (itA->node->ob == obedit)
+ if (itA->node->type==ID_OB) {
obc= itA->node->ob;
/* child moves */
- if((obc->recalc & OB_RECALC_ALL)==OB_RECALC_OB) {
+ if ((obc->recalc & OB_RECALC_ALL)==OB_RECALC_OB) {
/* parent has deforming info */
- if(itA->type & (DAG_RL_OB_DATA|DAG_RL_DATA_DATA)) {
+ if (itA->type & (DAG_RL_OB_DATA|DAG_RL_DATA_DATA)) {
// printf("parent %s changes ob %s\n", ob->id.name, obc->id.name);
obc->recalc |= OB_RECALC_DATA;
lib_id_recalc_data_tag(bmain, &obc->id);
@@ -1906,8 +1918,8 @@ static void flush_update_node(DagNode *node, unsigned int layer, int curtime)
}
/* we only go deeper if node not checked or something changed */
- for(itA = node->child; itA; itA= itA->next) {
- if(changed || itA->node->lasttime!=curtime)
+ for (itA = node->child; itA; itA= itA->next) {
+ if (changed || itA->node->lasttime!=curtime)
flush_update_node(itA->node, layer, curtime);
}
@@ -1921,9 +1933,9 @@ static unsigned int flush_layer_node(Scene *sce, DagNode *node, int curtime)
node->lasttime= curtime;
node->lay= node->scelay;
- for(itA = node->child; itA; itA= itA->next) {
- if(itA->node->type==ID_OB) {
- if(itA->node->lasttime!=curtime) {
+ for (itA = node->child; itA; itA= itA->next) {
+ if (itA->node->type==ID_OB) {
+ if (itA->node->lasttime!=curtime) {
itA->lay= flush_layer_node(sce, itA->node, curtime); // lay is only set once for each relation
}
else itA->lay= itA->node->lay;
@@ -1944,13 +1956,13 @@ static void flush_pointcache_reset(Scene *scene, DagNode *node, int curtime, int
node->lasttime= curtime;
- for(itA = node->child; itA; itA= itA->next) {
- if(itA->node->type==ID_OB) {
- if(itA->node->lasttime!=curtime) {
+ for (itA = node->child; itA; itA= itA->next) {
+ if (itA->node->type==ID_OB) {
+ if (itA->node->lasttime!=curtime) {
ob= (Object*)(itA->node->ob);
- if(reset || (ob->recalc & OB_RECALC_ALL)) {
- if(BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_DEPSGRAPH)) {
+ if (reset || (ob->recalc & OB_RECALC_ALL)) {
+ if (BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_DEPSGRAPH)) {
ob->recalc |= OB_RECALC_DATA;
lib_id_recalc_data_tag(bmain, &ob->id);
}
@@ -1974,14 +1986,14 @@ static void dag_scene_flush_layers(Scene *sce, int lay)
firstnode= sce->theDag->DagNode.first; // always scene node
- for(itA = firstnode->child; itA; itA= itA->next)
+ for (itA = firstnode->child; itA; itA= itA->next)
itA->lay= 0;
sce->theDag->time++; // so we know which nodes were accessed
lasttime= sce->theDag->time;
/* update layer flags in nodes */
- for(base= sce->base.first; base; base= base->next) {
+ for (base= sce->base.first; base; base= base->next) {
node= dag_get_node(sce->theDag, base->object);
node->scelay= base->object->lay;
}
@@ -1990,7 +2002,7 @@ static void dag_scene_flush_layers(Scene *sce, int lay)
* they ared still used for rendering or setting the camera view
*
* XXX, this wont work for local view / unlocked camera's */
- if(sce->camera) {
+ if (sce->camera) {
node= dag_get_node(sce->theDag, sce->camera);
node->scelay |= lay;
}
@@ -1999,8 +2011,8 @@ static void dag_scene_flush_layers(Scene *sce, int lay)
{
TimeMarker *m;
- for(m= sce->markers.first; m; m= m->next) {
- if(m->camera) {
+ for (m= sce->markers.first; m; m= m->next) {
+ if (m->camera) {
node= dag_get_node(sce->theDag, m->camera);
node->scelay |= lay;
}
@@ -2009,27 +2021,27 @@ static void dag_scene_flush_layers(Scene *sce, int lay)
#endif
/* flush layer nodes to dependencies */
- for(itA = firstnode->child; itA; itA= itA->next)
- if(itA->node->lasttime!=lasttime && itA->node->type==ID_OB)
+ for (itA = firstnode->child; itA; itA= itA->next)
+ if (itA->node->lasttime!=lasttime && itA->node->type==ID_OB)
flush_layer_node(sce, itA->node, lasttime);
}
static void dag_tag_renderlayers(Scene *sce, unsigned int lay)
{
- if(sce->nodetree) {
+ if (sce->nodetree) {
bNode *node;
Base *base;
unsigned int lay_changed= 0;
- for(base= sce->base.first; base; base= base->next)
- if(base->lay & lay)
- if(base->object->recalc)
+ for (base= sce->base.first; base; base= base->next)
+ if (base->lay & lay)
+ if (base->object->recalc)
lay_changed |= base->lay;
- for(node= sce->nodetree->nodes.first; node; node= node->next) {
- if(node->id==(ID *)sce) {
+ for (node= sce->nodetree->nodes.first; node; node= node->next) {
+ if (node->id==(ID *)sce) {
SceneRenderLayer *srl= BLI_findlink(&sce->r.layers, node->custom1);
- if(srl && (srl->lay & lay_changed))
+ if (srl && (srl->lay & lay_changed))
nodeUpdate(sce->nodetree, node);
}
}
@@ -2044,7 +2056,7 @@ void DAG_scene_flush_update(Main *bmain, Scene *sce, unsigned int lay, const sho
Object *ob;
int lasttime;
- if(sce->theDag==NULL) {
+ if (sce->theDag==NULL) {
printf("DAG zero... not allowed to happen!\n");
DAG_scene_sort(bmain, sce);
}
@@ -2057,20 +2069,20 @@ void DAG_scene_flush_update(Main *bmain, Scene *sce, unsigned int lay, const sho
/* then we use the relationships + layer info to flush update events */
sce->theDag->time++; // so we know which nodes were accessed
lasttime= sce->theDag->time;
- for(itA = firstnode->child; itA; itA= itA->next)
- if(itA->node->lasttime!=lasttime && itA->node->type==ID_OB)
+ for (itA = firstnode->child; itA; itA= itA->next)
+ if (itA->node->lasttime!=lasttime && itA->node->type==ID_OB)
flush_update_node(itA->node, lay, lasttime);
/* if update is not due to time change, do pointcache clears */
- if(!time) {
+ if (!time) {
sce->theDag->time++; // so we know which nodes were accessed
lasttime= sce->theDag->time;
- for(itA = firstnode->child; itA; itA= itA->next) {
- if(itA->node->lasttime!=lasttime && itA->node->type==ID_OB) {
+ for (itA = firstnode->child; itA; itA= itA->next) {
+ if (itA->node->lasttime!=lasttime && itA->node->type==ID_OB) {
ob= (Object*)(itA->node->ob);
- if(ob->recalc & OB_RECALC_ALL) {
- if(BKE_ptcache_object_reset(sce, ob, PTCACHE_RESET_DEPSGRAPH)) {
+ if (ob->recalc & OB_RECALC_ALL) {
+ if (BKE_ptcache_object_reset(sce, ob, PTCACHE_RESET_DEPSGRAPH)) {
ob->recalc |= OB_RECALC_DATA;
lib_id_recalc_data_tag(bmain, &ob->id);
}
@@ -2130,7 +2142,7 @@ static short animdata_use_time(AnimData *adt)
{
NlaTrack *nlt;
- if(adt==NULL) return 0;
+ if (adt==NULL) return 0;
/* check action - only if assigned, and it has anim curves */
if (adt->action && adt->action->curves.first)
@@ -2164,7 +2176,7 @@ static short animdata_use_time(AnimData *adt)
static void dag_object_time_update_flags(Object *ob)
{
- if(ob->constraints.first) {
+ if (ob->constraints.first) {
bConstraint *con;
for (con = ob->constraints.first; con; con=con->next) {
bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
@@ -2173,7 +2185,7 @@ static void dag_object_time_update_flags(Object *ob)
if (cti) {
/* special case for camera tracking -- it doesn't use targets to define relations */
- if(ELEM3(cti->type, CONSTRAINT_TYPE_FOLLOWTRACK, CONSTRAINT_TYPE_CAMERASOLVER, CONSTRAINT_TYPE_OBJECTSOLVER)) {
+ if (ELEM3(cti->type, CONSTRAINT_TYPE_FOLLOWTRACK, CONSTRAINT_TYPE_CAMERASOLVER, CONSTRAINT_TYPE_OBJECTSOLVER)) {
ob->recalc |= OB_RECALC_OB;
}
else if (cti->get_constraint_targets) {
@@ -2194,33 +2206,33 @@ static void dag_object_time_update_flags(Object *ob)
}
}
- if(ob->parent) {
+ if (ob->parent) {
/* motion path or bone child */
- if(ob->parent->type==OB_CURVE || ob->parent->type==OB_ARMATURE) ob->recalc |= OB_RECALC_OB;
+ if (ob->parent->type==OB_CURVE || ob->parent->type==OB_ARMATURE) ob->recalc |= OB_RECALC_OB;
}
#if 0 // XXX old animation system
- if(ob->nlastrips.first) {
- if(ob->dup_group) {
+ if (ob->nlastrips.first) {
+ if (ob->dup_group) {
bActionStrip *strip;
/* this case is for groups with nla, whilst nla target has no action or nla */
- for(strip= ob->nlastrips.first; strip; strip= strip->next) {
- if(strip->object)
+ for (strip= ob->nlastrips.first; strip; strip= strip->next) {
+ if (strip->object)
strip->object->recalc |= OB_RECALC_ALL;
}
}
}
#endif // XXX old animation system
- if(animdata_use_time(ob->adt)) {
+ if (animdata_use_time(ob->adt)) {
ob->recalc |= OB_RECALC_OB;
ob->adt->recalc |= ADT_RECALC_ANIM;
}
- if((ob->adt) && (ob->type==OB_ARMATURE)) ob->recalc |= OB_RECALC_DATA;
+ if ((ob->adt) && (ob->type==OB_ARMATURE)) ob->recalc |= OB_RECALC_DATA;
- if(object_modifiers_use_time(ob)) ob->recalc |= OB_RECALC_DATA;
- if((ob->pose) && (ob->pose->flag & POSE_CONSTRAINTS_TIMEDEPEND)) ob->recalc |= OB_RECALC_DATA;
+ if (object_modifiers_use_time(ob)) ob->recalc |= OB_RECALC_DATA;
+ if ((ob->pose) && (ob->pose->flag & POSE_CONSTRAINTS_TIMEDEPEND)) ob->recalc |= OB_RECALC_DATA;
{
AnimData *adt= BKE_animdata_from_id((ID *)ob->data);
@@ -2231,51 +2243,51 @@ static void dag_object_time_update_flags(Object *ob)
switch(ob->type) {
case OB_MESH:
me= ob->data;
- if(me->key) {
- if(!(ob->shapeflag & OB_SHAPE_LOCK)) {
+ if (me->key) {
+ if (!(ob->shapeflag & OB_SHAPE_LOCK)) {
ob->recalc |= OB_RECALC_DATA;
}
}
- if(ob->particlesystem.first)
+ if (ob->particlesystem.first)
ob->recalc |= OB_RECALC_DATA;
break;
case OB_CURVE:
case OB_SURF:
cu= ob->data;
- if(cu->key) {
- if(!(ob->shapeflag & OB_SHAPE_LOCK)) {
+ if (cu->key) {
+ if (!(ob->shapeflag & OB_SHAPE_LOCK)) {
ob->recalc |= OB_RECALC_DATA;
}
}
break;
case OB_FONT:
cu= ob->data;
- if(cu->nurb.first==NULL && cu->str && cu->vfont)
+ if (cu->nurb.first==NULL && cu->str && cu->vfont)
ob->recalc |= OB_RECALC_DATA;
break;
case OB_LATTICE:
lt= ob->data;
- if(lt->key) {
- if(!(ob->shapeflag & OB_SHAPE_LOCK)) {
+ if (lt->key) {
+ if (!(ob->shapeflag & OB_SHAPE_LOCK)) {
ob->recalc |= OB_RECALC_DATA;
}
}
break;
case OB_MBALL:
- if(ob->transflag & OB_DUPLI) ob->recalc |= OB_RECALC_DATA;
+ if (ob->transflag & OB_DUPLI) ob->recalc |= OB_RECALC_DATA;
break;
}
- if(animdata_use_time(adt)) {
+ if (animdata_use_time(adt)) {
ob->recalc |= OB_RECALC_DATA;
adt->recalc |= ADT_RECALC_ANIM;
}
- if(ob->particlesystem.first) {
+ if (ob->particlesystem.first) {
ParticleSystem *psys= ob->particlesystem.first;
- for(; psys; psys=psys->next) {
- if(psys_check_enabled(ob, psys)) {
+ for (; psys; psys=psys->next) {
+ if (psys_check_enabled(ob, psys)) {
ob->recalc |= OB_RECALC_DATA;
break;
}
@@ -2283,9 +2295,9 @@ static void dag_object_time_update_flags(Object *ob)
}
}
- if(ob->recalc & OB_RECALC_OB)
+ if (ob->recalc & OB_RECALC_OB)
lib_id_recalc_tag(G.main, &ob->id);
- if(ob->recalc & OB_RECALC_DATA)
+ if (ob->recalc & OB_RECALC_DATA)
lib_id_recalc_data_tag(G.main, &ob->id);
}
@@ -2300,51 +2312,51 @@ void DAG_scene_update_flags(Main *bmain, Scene *scene, unsigned int lay, const s
Scene *sce_iter;
/* set ob flags where animated systems are */
- for(SETLOOPER(scene, sce_iter, base)) {
+ for (SETLOOPER(scene, sce_iter, base)) {
ob= base->object;
- if(do_time) {
+ if (do_time) {
/* now if DagNode were part of base, the node->lay could be checked... */
/* we do all now, since the scene_flush checks layers and clears recalc flags even */
dag_object_time_update_flags(ob);
}
/* handled in next loop */
- if(ob->dup_group)
+ if (ob->dup_group)
ob->dup_group->id.flag |= LIB_DOIT;
}
- if(do_time) {
+ if (do_time) {
/* we do groups each once */
- for(group= bmain->group.first; group; group= group->id.next) {
- if(group->id.flag & LIB_DOIT) {
- for(go= group->gobject.first; go; go= go->next) {
+ for (group= bmain->group.first; group; group= group->id.next) {
+ if (group->id.flag & LIB_DOIT) {
+ for (go= group->gobject.first; go; go= go->next) {
dag_object_time_update_flags(go->ob);
}
}
}
}
- for(sce_iter= scene; sce_iter; sce_iter= sce_iter->set)
+ for (sce_iter= scene; sce_iter; sce_iter= sce_iter->set)
DAG_scene_flush_update(bmain, sce_iter, lay, 1);
- if(do_time) {
+ if (do_time) {
/* test: set time flag, to disable baked systems to update */
- for(SETLOOPER(scene, sce_iter, base)) {
+ for (SETLOOPER(scene, sce_iter, base)) {
ob= base->object;
- if(ob->recalc)
+ if (ob->recalc)
ob->recalc |= OB_RECALC_TIME;
}
/* hrmf... an exception to look at once, for invisible camera object we do it over */
- if(scene->camera)
+ if (scene->camera)
dag_object_time_update_flags(scene->camera);
}
/* and store the info in groupobject */
- for(group= bmain->group.first; group; group= group->id.next) {
- if(group->id.flag & LIB_DOIT) {
- for(go= group->gobject.first; go; go= go->next) {
+ for (group= bmain->group.first; group; group= group->id.next) {
+ if (group->id.flag & LIB_DOIT) {
+ for (go= group->gobject.first; go; go= go->next) {
go->recalc= go->ob->recalc;
// printf("ob %s recalc %d\n", go->ob->id.name, go->recalc);
}
@@ -2365,11 +2377,11 @@ static void dag_current_scene_layers(Main *bmain, Scene **sce, unsigned int *lay
*sce= NULL;
*lay= 0;
- if((wm= bmain->wm.first)) {
+ if ((wm= bmain->wm.first)) {
/* if we have a windowmanager, look into windows */
- for(win=wm->windows.first; win; win=win->next) {
- if(win->screen) {
- if(!*sce) *sce= win->screen->scene;
+ for (win=wm->windows.first; win; win=win->next) {
+ if (win->screen) {
+ if (!*sce) *sce= win->screen->scene;
*lay |= BKE_screen_visible_layers(win->screen, win->screen->scene);
}
}
@@ -2377,7 +2389,7 @@ static void dag_current_scene_layers(Main *bmain, Scene **sce, unsigned int *lay
else {
/* if not, use the first sce */
*sce= bmain->scene.first;
- if(*sce) *lay= (*sce)->lay;
+ if (*sce) *lay= (*sce)->lay;
/* XXX for background mode, we should get the scene
* from somewhere, for the -S option, but it's in
@@ -2392,7 +2404,7 @@ void DAG_ids_flush_update(Main *bmain, int time)
dag_current_scene_layers(bmain, &sce, &lay);
- if(sce)
+ if (sce)
DAG_scene_flush_update(bmain, sce, lay, time);
}
@@ -2408,7 +2420,7 @@ void DAG_on_visible_update(Main *bmain, const short do_time)
dag_current_scene_layers(bmain, &scene, &lay);
- if(scene && scene->theDag) {
+ if (scene && scene->theDag) {
Scene *sce_iter;
/* derivedmeshes and displists are not saved to file so need to be
* remade, tag them so they get remade in the scene update loop,
@@ -2416,25 +2428,25 @@ void DAG_on_visible_update(Main *bmain, const short do_time)
* require updates, so we skip those */
dag_scene_flush_layers(scene, lay);
- for(SETLOOPER(scene, sce_iter, base)) {
+ for (SETLOOPER(scene, sce_iter, base)) {
ob= base->object;
node= (sce_iter->theDag)? dag_get_node(sce_iter->theDag, ob): NULL;
oblay= (node)? node->lay: ob->lay;
- if((oblay & lay) & ~scene->lay_updated) {
- if(ELEM6(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL, OB_LATTICE))
+ if ((oblay & lay) & ~scene->lay_updated) {
+ if (ELEM6(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL, OB_LATTICE))
ob->recalc |= OB_RECALC_DATA;
- if(ob->dup_group)
+ if (ob->dup_group)
ob->dup_group->id.flag |= LIB_DOIT;
}
}
- for(group= bmain->group.first; group; group= group->id.next) {
- if(group->id.flag & LIB_DOIT) {
- for(go= group->gobject.first; go; go= go->next) {
- if(ELEM6(go->ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL, OB_LATTICE))
+ for (group= bmain->group.first; group; group= group->id.next) {
+ if (group->id.flag & LIB_DOIT) {
+ for (go= group->gobject.first; go; go= go->next) {
+ if (ELEM6(go->ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL, OB_LATTICE))
go->ob->recalc |= OB_RECALC_DATA;
- if(go->ob->proxy_from)
+ if (go->ob->proxy_from)
go->ob->recalc |= OB_RECALC_OB;
}
@@ -2455,7 +2467,7 @@ static void dag_id_flush_update__isDependentTexture(void *userData, Object *UNUS
{
struct { ID *id; int is_dependent; } *data = userData;
- if(*idpoin && GS((*idpoin)->name)==ID_TE) {
+ if (*idpoin && GS((*idpoin)->name)==ID_TE) {
if (data->id == (*idpoin))
data->is_dependent = 1;
}
@@ -2471,16 +2483,16 @@ static void dag_id_flush_update(Scene *sce, ID *id)
* due to only objects and not other datablocks being in the depsgraph */
/* set flags & pointcache for object */
- if(GS(id->name) == ID_OB) {
+ if (GS(id->name) == ID_OB) {
ob= (Object*)id;
BKE_ptcache_object_reset(sce, ob, PTCACHE_RESET_DEPSGRAPH);
- if(ob->recalc & OB_RECALC_DATA) {
+ if (ob->recalc & OB_RECALC_DATA) {
/* all users of this ob->data should be checked */
id= ob->data;
/* no point in trying in this cases */
- if(id && id->us <= 1) {
+ if (id && id->us <= 1) {
dag_editors_id_update(bmain, id);
id= NULL;
}
@@ -2488,12 +2500,12 @@ static void dag_id_flush_update(Scene *sce, ID *id)
}
/* set flags & pointcache for object data */
- if(id) {
+ if (id) {
idtype= GS(id->name);
- if(ELEM8(idtype, ID_ME, ID_CU, ID_MB, ID_LA, ID_LT, ID_CA, ID_AR, ID_SPK)) {
- for(obt=bmain->object.first; obt; obt= obt->id.next) {
- if(!(ob && obt == ob) && obt->data == id) {
+ if (ELEM8(idtype, ID_ME, ID_CU, ID_MB, ID_LA, ID_LT, ID_CA, ID_AR, ID_SPK)) {
+ for (obt=bmain->object.first; obt; obt= obt->id.next) {
+ if (!(ob && obt == ob) && obt->data == id) {
obt->recalc |= OB_RECALC_DATA;
lib_id_recalc_data_tag(bmain, &obt->id);
BKE_ptcache_object_reset(sce, obt, PTCACHE_RESET_DEPSGRAPH);
@@ -2502,8 +2514,8 @@ static void dag_id_flush_update(Scene *sce, ID *id)
}
/* set flags based on textures - can influence depgraph via modifiers */
- if(idtype == ID_TE) {
- for(obt=bmain->object.first; obt; obt= obt->id.next) {
+ if (idtype == ID_TE) {
+ for (obt=bmain->object.first; obt; obt= obt->id.next) {
struct { ID *id; int is_dependent; } data;
data.id= id;
data.is_dependent= 0;
@@ -2515,21 +2527,21 @@ static void dag_id_flush_update(Scene *sce, ID *id)
}
/* particle settings can use the texture as well */
- if(obt->particlesystem.first) {
+ if (obt->particlesystem.first) {
ParticleSystem *psys = obt->particlesystem.first;
MTex **mtexp, *mtex;
int a;
- for(; psys; psys=psys->next) {
+ for (; psys; psys=psys->next) {
mtexp = psys->part->mtex;
- for(a=0; a<MAX_MTEX; a++, mtexp++) {
+ for (a=0; a<MAX_MTEX; a++, mtexp++) {
mtex = *mtexp;
- if(mtex && mtex->tex == (Tex*)id) {
+ if (mtex && mtex->tex == (Tex*)id) {
obt->recalc |= OB_RECALC_DATA;
lib_id_recalc_data_tag(bmain, &obt->id);
- if(mtex->mapto & PAMAP_INIT)
+ if (mtex->mapto & PAMAP_INIT)
psys->recalc |= PSYS_RECALC_RESET;
- if(mtex->mapto & PAMAP_CHILD)
+ if (mtex->mapto & PAMAP_CHILD)
psys->recalc |= PSYS_RECALC_CHILD;
BKE_ptcache_object_reset(sce, obt, PTCACHE_RESET_DEPSGRAPH);
@@ -2541,10 +2553,10 @@ static void dag_id_flush_update(Scene *sce, ID *id)
}
/* set flags based on ShapeKey */
- if(idtype == ID_KE) {
- for(obt=bmain->object.first; obt; obt= obt->id.next) {
+ if (idtype == ID_KE) {
+ for (obt=bmain->object.first; obt; obt= obt->id.next) {
Key *key= ob_get_key(obt);
- if(!(ob && obt == ob) && ((ID *)key == id)) {
+ if (!(ob && obt == ob) && ((ID *)key == id)) {
obt->flag |= (OB_RECALC_OB|OB_RECALC_DATA);
lib_id_recalc_tag(bmain, &obt->id);
lib_id_recalc_data_tag(bmain, &obt->id);
@@ -2554,20 +2566,20 @@ static void dag_id_flush_update(Scene *sce, ID *id)
}
/* set flags based on particle settings */
- if(idtype == ID_PA) {
+ if (idtype == ID_PA) {
ParticleSystem *psys;
- for(obt=bmain->object.first; obt; obt= obt->id.next)
- for(psys=obt->particlesystem.first; psys; psys=psys->next)
- if(&psys->part->id == id)
+ for (obt=bmain->object.first; obt; obt= obt->id.next)
+ for (psys=obt->particlesystem.first; psys; psys=psys->next)
+ if (&psys->part->id == id)
BKE_ptcache_object_reset(sce, obt, PTCACHE_RESET_DEPSGRAPH);
}
- if(idtype == ID_MC) {
- for(obt=bmain->object.first; obt; obt= obt->id.next) {
+ if (idtype == ID_MC) {
+ for (obt=bmain->object.first; obt; obt= obt->id.next) {
bConstraint *con;
for (con = obt->constraints.first; con; con=con->next) {
bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
- if(ELEM3(cti->type, CONSTRAINT_TYPE_FOLLOWTRACK, CONSTRAINT_TYPE_CAMERASOLVER,
+ if (ELEM3(cti->type, CONSTRAINT_TYPE_FOLLOWTRACK, CONSTRAINT_TYPE_CAMERASOLVER,
CONSTRAINT_TYPE_OBJECTSOLVER))
{
obt->recalc |= OB_RECALC_OB;
@@ -2576,11 +2588,11 @@ static void dag_id_flush_update(Scene *sce, ID *id)
}
}
- if(sce->nodetree) {
+ if (sce->nodetree) {
bNode *node;
- for(node= sce->nodetree->nodes.first; node; node= node->next) {
- if(node->id==id) {
+ for (node= sce->nodetree->nodes.first; node; node= node->next) {
+ if (node->id==id) {
nodeUpdate(sce->nodetree, node);
}
}
@@ -2590,10 +2602,10 @@ static void dag_id_flush_update(Scene *sce, ID *id)
/* camera's matrix is used to orient reconstructed stuff,
* so it should happen tracking-related constraints recalculation
* when camera is changing (sergey) */
- if(sce->camera && &sce->camera->id == id) {
+ if (sce->camera && &sce->camera->id == id) {
MovieClip *clip = object_get_movieclip(sce, sce->camera, 1);
- if(clip)
+ if (clip)
dag_id_flush_update(sce, &clip->id);
}
@@ -2611,21 +2623,21 @@ void DAG_ids_flush_tagged(Main *bmain)
dag_current_scene_layers(bmain, &sce, &lay);
- if(!sce || !sce->theDag)
+ if (!sce || !sce->theDag)
return;
/* loop over all ID types */
a = set_listbasepointers(bmain, lbarray);
- while(a--) {
+ while (a--) {
ListBase *lb = lbarray[a];
ID *id = lb->first;
/* we tag based on first ID type character to avoid
* looping over all ID's in case there are no tags */
- if(id && bmain->id_tag_update[id->name[0]]) {
- for(; id; id=id->next) {
- if(id->flag & (LIB_ID_RECALC|LIB_ID_RECALC_DATA)) {
+ if (id && bmain->id_tag_update[id->name[0]]) {
+ for (; id; id=id->next) {
+ if (id->flag & (LIB_ID_RECALC|LIB_ID_RECALC_DATA)) {
dag_id_flush_update(sce, id);
do_flush = 1;
}
@@ -2634,7 +2646,7 @@ void DAG_ids_flush_tagged(Main *bmain)
}
/* flush changes to other objects */
- if(do_flush)
+ if (do_flush)
DAG_scene_flush_update(bmain, sce, lay, 0);
}
@@ -2646,13 +2658,13 @@ void DAG_ids_check_recalc(Main *bmain, Scene *scene, int time)
/* loop over all ID types */
a = set_listbasepointers(bmain, lbarray);
- while(a--) {
+ while (a--) {
ListBase *lb = lbarray[a];
ID *id = lb->first;
/* we tag based on first ID type character to avoid
* looping over all ID's in case there are no tags */
- if(id && bmain->id_tag_update[id->name[0]]) {
+ if (id && bmain->id_tag_update[id->name[0]]) {
updated= 1;
break;
}
@@ -2669,15 +2681,15 @@ void DAG_ids_clear_recalc(Main *bmain)
/* loop over all ID types */
a = set_listbasepointers(bmain, lbarray);
- while(a--) {
+ while (a--) {
ListBase *lb = lbarray[a];
ID *id = lb->first;
/* we tag based on first ID type character to avoid
* looping over all ID's in case there are no tags */
- if(id && bmain->id_tag_update[id->name[0]]) {
- for(; id; id=id->next)
- if(id->flag & (LIB_ID_RECALC|LIB_ID_RECALC_DATA))
+ if (id && bmain->id_tag_update[id->name[0]]) {
+ for (; id; id=id->next)
+ if (id->flag & (LIB_ID_RECALC|LIB_ID_RECALC_DATA))
id->flag &= ~(LIB_ID_RECALC|LIB_ID_RECALC_DATA);
}
}
@@ -2689,34 +2701,34 @@ void DAG_id_tag_update(ID *id, short flag)
{
Main *bmain= G.main;
- if(id==NULL) return;
+ if (id==NULL) return;
/* tag ID for update */
- if(flag) {
- if(flag & OB_RECALC_OB)
+ if (flag) {
+ if (flag & OB_RECALC_OB)
lib_id_recalc_tag(bmain, id);
- if(flag & (OB_RECALC_DATA|PSYS_RECALC))
+ if (flag & (OB_RECALC_DATA|PSYS_RECALC))
lib_id_recalc_data_tag(bmain, id);
}
else
lib_id_recalc_tag(bmain, id);
/* flag is for objects and particle systems */
- if(flag) {
+ if (flag) {
Object *ob;
ParticleSystem *psys;
short idtype = GS(id->name);
- if(idtype == ID_OB) {
+ if (idtype == ID_OB) {
/* only quick tag */
ob = (Object*)id;
ob->recalc |= (flag & OB_RECALC_ALL);
}
- else if(idtype == ID_PA) {
+ else if (idtype == ID_PA) {
/* this is weak still, should be done delayed as well */
- for(ob=bmain->object.first; ob; ob=ob->id.next) {
- for(psys=ob->particlesystem.first; psys; psys=psys->next) {
- if(&psys->part->id == id) {
+ for (ob=bmain->object.first; ob; ob=ob->id.next) {
+ for (psys=ob->particlesystem.first; psys; psys=psys->next) {
+ if (&psys->part->id == id) {
ob->recalc |= (flag & OB_RECALC_ALL);
psys->recalc |= (flag & PSYS_RECALC);
lib_id_recalc_tag(bmain, &ob->id);
@@ -2752,20 +2764,20 @@ static int parent_check_node(DagNode *node, int curtime)
node->lasttime= curtime;
- if(node->color==DAG_GRAY)
+ if (node->color==DAG_GRAY)
return DAG_GRAY;
- for(itA = node->child; itA; itA= itA->next) {
- if(itA->node->type==ID_OB) {
+ for (itA = node->child; itA; itA= itA->next) {
+ if (itA->node->type==ID_OB) {
- if(itA->node->color==DAG_GRAY)
+ if (itA->node->color==DAG_GRAY)
return DAG_GRAY;
/* descend if not done */
- if(itA->node->lasttime!=curtime) {
+ if (itA->node->lasttime!=curtime) {
itA->node->color= parent_check_node(itA->node, curtime);
- if(itA->node->color==DAG_GRAY)
+ if (itA->node->color==DAG_GRAY)
return DAG_GRAY;
}
}
@@ -2798,12 +2810,12 @@ void DAG_pose_sort(Object *ob)
rootnode = dag_add_node(dag, NULL); // node->ob becomes NULL
/* we add the hierarchy and the constraints */
- for(pchan = pose->chanbase.first; pchan; pchan= pchan->next) {
+ for (pchan = pose->chanbase.first; pchan; pchan= pchan->next) {
int addtoroot = 1;
node = dag_get_node(dag, pchan);
- if(pchan->parent) {
+ if (pchan->parent) {
node2 = dag_get_node(dag, pchan->parent);
dag_add_relation(dag, node2, node, 0, "Parent Relation");
addtoroot = 0;
@@ -2829,7 +2841,7 @@ void DAG_pose_sort(Object *ob)
int segcount= 0;
/* exclude tip from chain? */
- if(!(data->flag & CONSTRAINT_IK_TIP))
+ if (!(data->flag & CONSTRAINT_IK_TIP))
parchan= pchan->parent;
else
parchan= pchan;
@@ -2865,20 +2877,20 @@ void DAG_pose_sort(Object *ob)
nqueue = queue_create(DAGQUEUEALLOC);
/* tag nodes unchecked */
- for(node = dag->DagNode.first; node; node= node->next)
+ for (node = dag->DagNode.first; node; node= node->next)
node->color = DAG_WHITE;
rootnode->color = DAG_GRAY;
push_stack(nqueue, rootnode);
- while(nqueue->count) {
+ while (nqueue->count) {
skip = 0;
node = get_top_node_queue(nqueue);
itA = node->child;
- while(itA != NULL) {
- if(itA->node->color == DAG_WHITE) {
+ while (itA != NULL) {
+ if (itA->node->color == DAG_WHITE) {
itA->node->color = DAG_GRAY;
push_stack(nqueue,itA->node);
skip = 1;
@@ -2902,7 +2914,7 @@ void DAG_pose_sort(Object *ob)
}
// temporal correction for circular dependancies
- while(pose->chanbase.first) {
+ while (pose->chanbase.first) {
pchan= pose->chanbase.first;
BLI_remlink(&pose->chanbase, pchan);
BLI_addhead(&tempbase, pchan);
@@ -2914,7 +2926,7 @@ void DAG_pose_sort(Object *ob)
queue_delete(nqueue);
// printf("\nordered\n");
-// for(pchan = pose->chanbase.first; pchan; pchan= pchan->next) {
+// for (pchan = pose->chanbase.first; pchan; pchan= pchan->next) {
// printf(" %s\n", pchan->name);
// }
@@ -2931,7 +2943,7 @@ void DAG_print_dependencies(Main *bmain, Scene *scene, Object *ob)
/* utility for debugging dependencies */
dag_print_dependencies= 1;
- if(ob && (ob->mode & OB_MODE_POSE)) {
+ if (ob && (ob->mode & OB_MODE_POSE)) {
printf("\nDEPENDENCY RELATIONS for %s\n\n", ob->id.name+2);
DAG_pose_sort(ob);
}
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index 7142dc38da3..7a34df85bdc 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -66,13 +66,13 @@ static void boundbox_displist(Object *ob);
void free_disp_elem(DispList *dl)
{
- if(dl) {
- if(dl->verts) MEM_freeN(dl->verts);
- if(dl->nors) MEM_freeN(dl->nors);
- if(dl->index) MEM_freeN(dl->index);
- if(dl->col1) MEM_freeN(dl->col1);
- if(dl->col2) MEM_freeN(dl->col2);
- if(dl->bevelSplitFlag) MEM_freeN(dl->bevelSplitFlag);
+ if (dl) {
+ if (dl->verts) MEM_freeN(dl->verts);
+ if (dl->nors) MEM_freeN(dl->nors);
+ if (dl->index) MEM_freeN(dl->index);
+ if (dl->col1) MEM_freeN(dl->col1);
+ if (dl->col2) MEM_freeN(dl->col2);
+ if (dl->bevelSplitFlag) MEM_freeN(dl->bevelSplitFlag);
MEM_freeN(dl);
}
}
@@ -82,7 +82,7 @@ void freedisplist(ListBase *lb)
DispList *dl;
dl= lb->first;
- while(dl) {
+ while (dl) {
BLI_remlink(lb, dl);
free_disp_elem(dl);
dl= lb->first;
@@ -94,8 +94,8 @@ DispList *find_displist_create(ListBase *lb, int type)
DispList *dl;
dl= lb->first;
- while(dl) {
- if(dl->type==type) return dl;
+ while (dl) {
+ if (dl->type==type) return dl;
dl= dl->next;
}
@@ -111,8 +111,8 @@ DispList *find_displist(ListBase *lb, int type)
DispList *dl;
dl= lb->first;
- while(dl) {
- if(dl->type==type) return dl;
+ while (dl) {
+ if (dl->type==type) return dl;
dl= dl->next;
}
@@ -122,7 +122,7 @@ DispList *find_displist(ListBase *lb, int type)
int displist_has_faces(ListBase *lb)
{
DispList *dl;
- for(dl= lb->first; dl; dl= dl->next) {
+ for (dl= lb->first; dl; dl= dl->next) {
if ELEM3(dl->type, DL_INDEX3, DL_INDEX4, DL_SURF)
return 1;
}
@@ -136,7 +136,7 @@ void copy_displist(ListBase *lbn, ListBase *lb)
freedisplist(lbn);
dl= lb->first;
- while(dl) {
+ while (dl) {
dln= MEM_dupallocN(dl);
BLI_addtail(lbn, dln);
@@ -146,7 +146,7 @@ void copy_displist(ListBase *lbn, ListBase *lb)
dln->col1= MEM_dupallocN(dl->col1);
dln->col2= MEM_dupallocN(dl->col2);
- if(dl->bevelSplitFlag)
+ if (dl->bevelSplitFlag)
dln->bevelSplitFlag= MEM_dupallocN(dl->bevelSplitFlag);
dl= dl->next;
@@ -164,22 +164,22 @@ void addnormalsDispList(ListBase *lb)
dl= lb->first;
- while(dl) {
- if(dl->type==DL_INDEX3) {
- if(dl->nors==NULL) {
+ while (dl) {
+ if (dl->type==DL_INDEX3) {
+ if (dl->nors==NULL) {
dl->nors= MEM_callocN(sizeof(float)*3, "dlnors");
- if(dl->verts[2] < 0.0f) dl->nors[2]= -1.0f;
+ if (dl->verts[2] < 0.0f) dl->nors[2]= -1.0f;
else dl->nors[2]= 1.0f;
}
}
- else if(dl->type==DL_SURF) {
- if(dl->nors==NULL) {
+ else if (dl->type==DL_SURF) {
+ if (dl->nors==NULL) {
dl->nors= MEM_callocN(sizeof(float)*3*dl->nr*dl->parts, "dlnors");
vdata= dl->verts;
ndata= dl->nors;
- for(a=0; a<dl->parts; a++) {
+ for (a=0; a<dl->parts; a++) {
if (surfindex_displist(dl, a, &b, &p1, &p2, &p3, &p4)==0)
break;
@@ -193,7 +193,7 @@ void addnormalsDispList(ListBase *lb)
v4= vdata+ 3*p4;
n4= ndata+ 3*p4;
- for(; b<dl->nr; b++) {
+ for (; b<dl->nr; b++) {
normal_quad_v3( nor,v1, v3, v4, v2);
@@ -210,7 +210,7 @@ void addnormalsDispList(ListBase *lb)
}
a= dl->parts*dl->nr;
v1= ndata;
- while(a--) {
+ while (a--) {
normalize_v3(v1);
v1+= 3;
}
@@ -225,7 +225,7 @@ void count_displist(ListBase *lb, int *totvert, int *totface)
DispList *dl;
dl= lb->first;
- while(dl) {
+ while (dl) {
switch(dl->type) {
case DL_SURF:
@@ -248,17 +248,18 @@ void count_displist(ListBase *lb, int *totvert, int *totface)
int surfindex_displist(DispList *dl, int a, int *b, int *p1, int *p2, int *p3, int *p4)
{
- if((dl->flag & DL_CYCL_V)==0 && a==(dl->parts)-1) {
+ if ((dl->flag & DL_CYCL_V)==0 && a==(dl->parts)-1) {
return 0;
}
- if(dl->flag & DL_CYCL_U) {
+ if (dl->flag & DL_CYCL_U) {
(*p1)= dl->nr*a;
(*p2)= (*p1)+ dl->nr-1;
(*p3)= (*p1)+ dl->nr;
(*p4)= (*p2)+ dl->nr;
(*b)= 0;
- } else {
+ }
+ else {
(*p2)= dl->nr*a;
(*p1)= (*p2)+1;
(*p4)= (*p2)+ dl->nr;
@@ -266,7 +267,7 @@ int surfindex_displist(DispList *dl, int a, int *b, int *p1, int *p2, int *p3, i
(*b)= 1;
}
- if( (dl->flag & DL_CYCL_V) && a==dl->parts-1) {
+ if ( (dl->flag & DL_CYCL_V) && a==dl->parts-1) {
(*p3)-= dl->nr*dl->parts;
(*p4)-= dl->nr*dl->parts;
}
@@ -286,31 +287,31 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, i
int a, len, resolu;
nu= nubase->first;
- while(nu) {
- if(nu->hide==0) {
+ while (nu) {
+ if (nu->hide==0) {
- if(forRender && cu->resolu_ren!=0)
+ if (forRender && cu->resolu_ren!=0)
resolu= cu->resolu_ren;
else
resolu= nu->resolu;
- if(!check_valid_nurb_u(nu));
- else if(nu->type == CU_BEZIER) {
+ if (!check_valid_nurb_u(nu));
+ else if (nu->type == CU_BEZIER) {
/* count */
len= 0;
a= nu->pntsu-1;
- if(nu->flagu & CU_NURB_CYCLIC) a++;
+ if (nu->flagu & CU_NURB_CYCLIC) a++;
prevbezt= nu->bezt;
bezt= prevbezt+1;
- while(a--) {
- if(a==0 && (nu->flagu & CU_NURB_CYCLIC)) bezt= nu->bezt;
+ while (a--) {
+ if (a==0 && (nu->flagu & CU_NURB_CYCLIC)) bezt= nu->bezt;
- if(prevbezt->h2==HD_VECT && bezt->h1==HD_VECT) len++;
+ if (prevbezt->h2==HD_VECT && bezt->h1==HD_VECT) len++;
else len+= resolu;
- if(a==0 && (nu->flagu & CU_NURB_CYCLIC)==0) len++;
+ if (a==0 && (nu->flagu & CU_NURB_CYCLIC)==0) len++;
prevbezt= bezt;
bezt++;
@@ -327,7 +328,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, i
data= dl->verts;
- if(nu->flagu & CU_NURB_CYCLIC) {
+ if (nu->flagu & CU_NURB_CYCLIC) {
dl->type= DL_POLY;
a= nu->pntsu;
}
@@ -339,16 +340,16 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, i
prevbezt= nu->bezt;
bezt= prevbezt+1;
- while(a--) {
- if(a==0 && dl->type== DL_POLY) bezt= nu->bezt;
+ while (a--) {
+ if (a==0 && dl->type== DL_POLY) bezt= nu->bezt;
- if(prevbezt->h2==HD_VECT && bezt->h1==HD_VECT) {
+ if (prevbezt->h2==HD_VECT && bezt->h1==HD_VECT) {
copy_v3_v3(data, prevbezt->vec[1]);
data+= 3;
}
else {
int j;
- for(j=0; j<3; j++) {
+ for (j=0; j<3; j++) {
forward_diff_bezier( prevbezt->vec[1][j],
prevbezt->vec[2][j],
bezt->vec[0][j],
@@ -359,7 +360,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, i
data+= 3*resolu;
}
- if(a==0 && dl->type==DL_SEGM) {
+ if (a==0 && dl->type==DL_SEGM) {
copy_v3_v3(data, bezt->vec[1]);
}
@@ -367,7 +368,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, i
bezt++;
}
}
- else if(nu->type == CU_NURBS) {
+ else if (nu->type == CU_NURBS) {
len= (resolu*SEGMENTSU(nu));
dl= MEM_callocN(sizeof(DispList), "makeDispListsurf");
@@ -380,11 +381,11 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, i
dl->charidx = nu->charidx;
data= dl->verts;
- if(nu->flagu & CU_NURB_CYCLIC) dl->type= DL_POLY;
+ if (nu->flagu & CU_NURB_CYCLIC) dl->type= DL_POLY;
else dl->type= DL_SEGM;
makeNurbcurve(nu, data, NULL, NULL, NULL, resolu, 3*sizeof(float));
}
- else if(nu->type == CU_POLY) {
+ else if (nu->type == CU_POLY) {
len= nu->pntsu;
dl= MEM_callocN(sizeof(DispList), "makeDispListpoly");
dl->verts= MEM_callocN(len*3*sizeof(float), "dlverts");
@@ -395,12 +396,12 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, i
dl->charidx = nu->charidx;
data= dl->verts;
- if(nu->flagu & CU_NURB_CYCLIC) dl->type= DL_POLY;
+ if (nu->flagu & CU_NURB_CYCLIC) dl->type= DL_POLY;
else dl->type= DL_SEGM;
a= len;
bp= nu->bp;
- while(a--) {
+ while (a--) {
copy_v3_v3(data, bp->vec);
bp++;
data+= 3;
@@ -421,10 +422,10 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal)
int colnr=0, charidx=0, cont=1, tot, a, *index, nextcol= 0;
intptr_t totvert;
- if(dispbase==NULL) return;
- if(dispbase->first==NULL) return;
+ if (dispbase==NULL) return;
+ if (dispbase->first==NULL) return;
- while(cont) {
+ while (cont) {
cont= 0;
totvert= 0;
nextcol= 0;
@@ -432,34 +433,35 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal)
BLI_begin_edgefill();
dl= dispbase->first;
- while(dl) {
+ while (dl) {
- if(dl->type==DL_POLY) {
- if(charidx<dl->charidx) cont= 1;
- else if(charidx==dl->charidx) { /* character with needed index */
- if(colnr==dl->col) {
+ if (dl->type==DL_POLY) {
+ if (charidx<dl->charidx) cont= 1;
+ else if (charidx==dl->charidx) { /* character with needed index */
+ if (colnr==dl->col) {
/* make editverts and edges */
f1= dl->verts;
a= dl->nr;
eve= v1= NULL;
- while(a--) {
+ while (a--) {
vlast= eve;
eve= BLI_addfillvert(f1);
totvert++;
- if(vlast==NULL) v1= eve;
+ if (vlast==NULL) v1= eve;
else {
BLI_addfilledge(vlast, eve);
}
f1+=3;
}
- if(eve!=NULL && v1!=NULL) {
+ if (eve!=NULL && v1!=NULL) {
BLI_addfilledge(eve, v1);
}
- } else if (colnr<dl->col) {
+ }
+ else if (colnr<dl->col) {
/* got poly with next material at current char */
cont= 1;
nextcol= 1;
@@ -469,8 +471,8 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal)
dl= dl->next;
}
- if(totvert && (tot= BLI_edgefill(0))) { // XXX (obedit && obedit->actcol)?(obedit->actcol-1):0)) {
- if(tot) {
+ if (totvert && (tot= BLI_edgefill(0))) { // XXX (obedit && obedit->actcol)?(obedit->actcol-1):0)) {
+ if (tot) {
dlnew= MEM_callocN(sizeof(DispList), "filldisplist");
dlnew->type= DL_INDEX3;
dlnew->col= colnr;
@@ -484,7 +486,7 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal)
f1= dlnew->verts;
totvert= 0;
eve= fillvertbase.first;
- while(eve) {
+ while (eve) {
copy_v3_v3(f1, eve->co);
f1+= 3;
@@ -498,12 +500,12 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal)
/* index data */
efa= fillfacebase.first;
index= dlnew->index;
- while(efa) {
+ while (efa) {
index[0]= (intptr_t)efa->v1->tmp.l;
index[1]= (intptr_t)efa->v2->tmp.l;
index[2]= (intptr_t)efa->v3->tmp.l;
- if(flipnormal)
+ if (flipnormal)
SWAP(int, index[0], index[2]);
index+= 3;
@@ -516,10 +518,11 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal)
}
BLI_end_edgefill();
- if(nextcol) {
+ if (nextcol) {
/* stay at current char but fill polys with next material */
colnr++;
- } else {
+ }
+ else {
/* switch to next char and start filling from first material */
charidx++;
colnr= 0;
@@ -540,10 +543,10 @@ static void bevels_to_filledpoly(Curve *cu, ListBase *dispbase)
front.first= front.last= back.first= back.last= NULL;
dl= dispbase->first;
- while(dl) {
- if(dl->type==DL_SURF) {
- if( (dl->flag & DL_CYCL_V) && (dl->flag & DL_CYCL_U)==0 ) {
- if( (cu->flag & CU_BACK) && (dl->flag & DL_BACK_CURVE) ) {
+ while (dl) {
+ if (dl->type==DL_SURF) {
+ if ( (dl->flag & DL_CYCL_V) && (dl->flag & DL_CYCL_U)==0 ) {
+ if ( (cu->flag & CU_BACK) && (dl->flag & DL_BACK_CURVE) ) {
dlnew= MEM_callocN(sizeof(DispList), "filldisp");
BLI_addtail(&front, dlnew);
dlnew->verts= fp1= MEM_mallocN(sizeof(float)*3*dl->parts, "filldisp1");
@@ -557,13 +560,13 @@ static void bevels_to_filledpoly(Curve *cu, ListBase *dispbase)
dpoly= 3*dl->nr;
a= dl->parts;
- while(a--) {
+ while (a--) {
copy_v3_v3(fp1, fp);
fp1+= 3;
fp+= dpoly;
}
}
- if( (cu->flag & CU_FRONT) && (dl->flag & DL_FRONT_CURVE) ) {
+ if ( (cu->flag & CU_FRONT) && (dl->flag & DL_FRONT_CURVE) ) {
dlnew= MEM_callocN(sizeof(DispList), "filldisp");
BLI_addtail(&back, dlnew);
dlnew->verts= fp1= MEM_mallocN(sizeof(float)*3*dl->parts, "filldisp1");
@@ -577,7 +580,7 @@ static void bevels_to_filledpoly(Curve *cu, ListBase *dispbase)
dpoly= 3*dl->nr;
a= dl->parts;
- while(a--) {
+ while (a--) {
copy_v3_v3(fp1, fp);
fp1+= 3;
fp+= dpoly;
@@ -600,9 +603,9 @@ static void bevels_to_filledpoly(Curve *cu, ListBase *dispbase)
static void curve_to_filledpoly(Curve *cu, ListBase *UNUSED(nurb), ListBase *dispbase)
{
- if(cu->flag & CU_3D) return;
+ if (cu->flag & CU_3D) return;
- if(dispbase->first && ((DispList*) dispbase->first)->type==DL_SURF) {
+ if (dispbase->first && ((DispList*) dispbase->first)->type==DL_SURF) {
bevels_to_filledpoly(cu, dispbase);
}
else {
@@ -619,14 +622,14 @@ float calc_taper(Scene *scene, Object *taperobj, int cur, int tot)
{
DispList *dl;
- if(taperobj==NULL || taperobj->type!=OB_CURVE) return 1.0;
+ if (taperobj==NULL || taperobj->type!=OB_CURVE) return 1.0;
dl= taperobj->disp.first;
- if(dl==NULL) {
+ if (dl==NULL) {
makeDispListCurveTypes(scene, taperobj, 0);
dl= taperobj->disp.first;
}
- if(dl) {
+ if (dl) {
float fac= ((float)cur)/(float)(tot-1);
float minx, dx, *fp;
int a;
@@ -634,16 +637,16 @@ float calc_taper(Scene *scene, Object *taperobj, int cur, int tot)
/* horizontal size */
minx= dl->verts[0];
dx= dl->verts[3*(dl->nr-1)] - minx;
- if(dx > 0.0f) {
+ if (dx > 0.0f) {
fp= dl->verts;
- for(a=0; a<dl->nr; a++, fp+=3) {
- if( (fp[0]-minx)/dx >= fac) {
+ for (a=0; a<dl->nr; a++, fp+=3) {
+ if ( (fp[0]-minx)/dx >= fac) {
/* interpolate with prev */
- if(a>0) {
+ if (a>0) {
float fac1= (fp[-3]-minx)/dx;
float fac2= (fp[0]-minx)/dx;
- if(fac1!=fac2)
+ if (fac1!=fac2)
return fp[1]*(fac1-fac)/(fac1-fac2) + fp[-2]*(fac-fac2)/(fac1-fac2);
}
return fp[1];
@@ -658,16 +661,16 @@ float calc_taper(Scene *scene, Object *taperobj, int cur, int tot)
void makeDispListMBall(Scene *scene, Object *ob)
{
- if(!ob || ob->type!=OB_MBALL) return;
+ if (!ob || ob->type!=OB_MBALL) return;
// XXX: mball stuff uses plenty of global variables
// while this is unchanged updating during render is unsafe
- if(G.rendering) return;
+ if (G.rendering) return;
freedisplist(&(ob->disp));
- if(ob->type==OB_MBALL) {
- if(ob==find_basis_mball(scene, ob)) {
+ if (ob->type==OB_MBALL) {
+ if (ob==find_basis_mball(scene, ob)) {
metaball_polygonize(scene, ob, &ob->disp);
tex_space_mball(ob);
@@ -692,10 +695,10 @@ static ModifierData *curve_get_tessellate_point(Scene *scene, Object *ob, int fo
ModifierData *pretessellatePoint;
int required_mode;
- if(forRender) required_mode = eModifierMode_Render;
+ if (forRender) required_mode = eModifierMode_Render;
else required_mode = eModifierMode_Realtime;
- if(editmode) required_mode |= eModifierMode_Editmode;
+ if (editmode) required_mode |= eModifierMode_Editmode;
pretessellatePoint = NULL;
for (; md; md=md->next) {
@@ -711,7 +714,8 @@ static ModifierData *curve_get_tessellate_point(Scene *scene, Object *ob, int fo
* (some of them even can't be applied on tessellated curve), set flag
* for incformation button in modifier's header */
md->mode |= eModifierMode_ApplyOnSpline;
- } else if(md->mode&eModifierMode_ApplyOnSpline) {
+ }
+ else if (md->mode&eModifierMode_ApplyOnSpline) {
pretessellatePoint = md;
}
}
@@ -732,17 +736,17 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, fl
float *keyVerts= NULL;
int required_mode;
- if(forRender) required_mode = eModifierMode_Render;
+ if (forRender) required_mode = eModifierMode_Render;
else required_mode = eModifierMode_Realtime;
pretessellatePoint = curve_get_tessellate_point(scene, ob, forRender, editmode);
- if(editmode) required_mode |= eModifierMode_Editmode;
+ if (editmode) required_mode |= eModifierMode_Editmode;
- if(cu->editnurb==NULL) {
+ if (cu->editnurb==NULL) {
keyVerts= do_ob_key(scene, ob);
- if(keyVerts) {
+ if (keyVerts) {
/* split coords from key data, the latter also includes
* tilts, which is passed through in the modifier stack.
* this is also the reason curves do not use a virtual
@@ -780,7 +784,7 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, fl
if (keyVerts) /* these are not passed through modifier stack */
curve_applyKeyVertexTilts(cu, nurb, keyVerts);
- if(keyVerts)
+ if (keyVerts)
MEM_freeN(keyVerts);
*originalVerts_r = originalVerts;
@@ -835,12 +839,12 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba
float (*vertCos)[3] = NULL;
int useCache = !forRender;
- if(forRender) required_mode = eModifierMode_Render;
+ if (forRender) required_mode = eModifierMode_Render;
else required_mode = eModifierMode_Realtime;
pretessellatePoint = curve_get_tessellate_point(scene, ob, forRender, editmode);
- if(editmode) required_mode |= eModifierMode_Editmode;
+ if (editmode) required_mode |= eModifierMode_Editmode;
if (pretessellatePoint) {
md = pretessellatePoint->next;
@@ -868,14 +872,16 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba
}
mti->deformVerts(md, ob, dm, vertCos, totvert, forRender, editmode);
- } else {
+ }
+ else {
if (!vertCos) {
vertCos= displist_get_allverts(dispbase, &totvert);
}
mti->deformVerts(md, ob, NULL, vertCos, totvert, forRender, editmode);
}
- } else {
+ }
+ else {
if (!derivedFinal) {
/* makeDisplistCurveTypes could be used for beveling, where derived mesh */
/* is totally unnecessary, so we could stop modifiers applying */
@@ -892,7 +898,8 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba
CDDM_apply_vert_coords(dm, vertCos);
CDDM_calc_normals_mapping(dm);
}
- } else {
+ }
+ else {
if (vertCos) {
displist_apply_allverts(dispbase, vertCos);
}
@@ -933,7 +940,8 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba
CDDM_apply_vert_coords(dm, vertCos);
CDDM_calc_normals_mapping(dm);
MEM_freeN(vertCos);
- } else {
+ }
+ else {
displist_apply_allverts(dispbase, vertCos);
MEM_freeN(vertCos);
vertCos= NULL;
@@ -961,12 +969,12 @@ static void displist_surf_indices(DispList *dl)
index=dl->index= MEM_mallocN( 4*sizeof(int)*(dl->parts+1)*(dl->nr+1), "index array nurbs");
- for(a=0; a<dl->parts; a++) {
+ for (a=0; a<dl->parts; a++) {
if (surfindex_displist(dl, a, &b, &p1, &p2, &p3, &p4)==0)
break;
- for(; b<dl->nr; b++, index+=4) {
+ for (; b<dl->nr; b++, index+=4) {
index[0]= p1;
index[1]= p2;
index[2]= p4;
@@ -1004,10 +1012,10 @@ static void add_orco_dm(Scene *scene, Object *ob, DerivedMesh *dm, DerivedMesh *
totvert= dm->getNumVerts(dm);
- if(orcodm) {
+ if (orcodm) {
orco= MEM_callocN(sizeof(float)*3*totvert, "dm orco");
- if(orcodm->getNumVerts(orcodm) == totvert)
+ if (orcodm->getNumVerts(orcodm) == totvert)
orcodm->getVertCos(orcodm, orco);
else
dm->getVertCos(dm, orco);
@@ -1016,14 +1024,14 @@ static void add_orco_dm(Scene *scene, Object *ob, DerivedMesh *dm, DerivedMesh *
orco= (float(*)[3])make_orco_curve(scene, ob);
}
- for(a=0; a<totvert; a++) {
+ for (a=0; a<totvert; a++) {
float *co = orco[a];
co[0] = (co[0]-cu->loc[0])/cu->size[0];
co[1] = (co[1]-cu->loc[1])/cu->size[1];
co[2] = (co[2]-cu->loc[2])/cu->size[2];
}
- if((layerorco = DM_get_vert_data_layer(dm, CD_ORCO))) {
+ if ((layerorco = DM_get_vert_data_layer(dm, CD_ORCO))) {
memcpy(layerorco, orco, sizeof(float)*totvert);
MEM_freeN(orco);
}
@@ -1043,12 +1051,12 @@ static void curve_calc_orcodm(Scene *scene, Object *ob, DerivedMesh *derivedFina
int editmode = (!forRender && cu->editnurb);
DerivedMesh *ndm, *orcodm= NULL;
- if(forRender) required_mode = eModifierMode_Render;
+ if (forRender) required_mode = eModifierMode_Render;
else required_mode = eModifierMode_Realtime;
pretessellatePoint = curve_get_tessellate_point(scene, ob, forRender, editmode);
- if(editmode) required_mode |= eModifierMode_Editmode;
+ if (editmode) required_mode |= eModifierMode_Editmode;
if (pretessellatePoint) {
md = pretessellatePoint->next;
@@ -1063,14 +1071,14 @@ static void curve_calc_orcodm(Scene *scene, Object *ob, DerivedMesh *derivedFina
if (mti->isDisabled && mti->isDisabled(md, forRender)) continue;
if (mti->type!=eModifierTypeType_Constructive) continue;
- if(!orcodm)
+ if (!orcodm)
orcodm= create_orco_dm(scene, ob);
ndm = mti->applyModifier(md, ob, orcodm, forRender, 0);
- if(ndm) {
+ if (ndm) {
/* if the modifier returned a new dm, release the old one */
- if(orcodm && orcodm != ndm) {
+ if (orcodm && orcodm != ndm) {
orcodm->release(orcodm);
}
orcodm = ndm;
@@ -1080,7 +1088,7 @@ static void curve_calc_orcodm(Scene *scene, Object *ob, DerivedMesh *derivedFina
/* add an orco layer if needed */
add_orco_dm(scene, ob, derivedFinal, orcodm);
- if(orcodm)
+ if (orcodm)
orcodm->release(orcodm);
}
@@ -1097,24 +1105,24 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase,
float (*originalVerts)[3];
float (*deformedVerts)[3];
- if(!forRender && cu->editnurb)
+ if (!forRender && cu->editnurb)
nubase= curve_editnurbs(cu);
else
nubase= &cu->nurb;
- if(!forOrco)
+ if (!forOrco)
curve_calc_modifiers_pre(scene, ob, forRender, &originalVerts, &deformedVerts, &numVerts);
for (nu=nubase->first; nu; nu=nu->next) {
- if(forRender || nu->hide==0) {
+ if (forRender || nu->hide==0) {
int resolu= nu->resolu, resolv= nu->resolv;
- if(forRender) {
- if(cu->resolu_ren) resolu= cu->resolu_ren;
- if(cu->resolv_ren) resolv= cu->resolv_ren;
+ if (forRender) {
+ if (cu->resolu_ren) resolu= cu->resolu_ren;
+ if (cu->resolv_ren) resolv= cu->resolv_ren;
}
- if(nu->pntsv==1) {
+ if (nu->pntsv==1) {
len= SEGMENTSU(nu)*resolu;
dl= MEM_callocN(sizeof(DispList), "makeDispListsurf");
@@ -1131,7 +1139,7 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase,
dl->rt= nu->flag & ~CU_2D;
data= dl->verts;
- if(nu->flagu & CU_NURB_CYCLIC) dl->type= DL_POLY;
+ if (nu->flagu & CU_NURB_CYCLIC) dl->type= DL_POLY;
else dl->type= DL_SEGM;
makeNurbcurve(nu, data, NULL, NULL, NULL, resolu, 3*sizeof(float));
@@ -1155,8 +1163,8 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase,
dl->parts= (nu->pntsu*resolu); /* in reverse, because makeNurbfaces works that way */
dl->nr= (nu->pntsv*resolv);
- if(nu->flagv & CU_NURB_CYCLIC) dl->flag|= DL_CYCL_U; /* reverse too! */
- if(nu->flagu & CU_NURB_CYCLIC) dl->flag|= DL_CYCL_V;
+ if (nu->flagv & CU_NURB_CYCLIC) dl->flag|= DL_CYCL_U; /* reverse too! */
+ if (nu->flagu & CU_NURB_CYCLIC) dl->flag|= DL_CYCL_V;
makeNurbfaces(nu, data, 0, resolu, resolv);
@@ -1175,7 +1183,7 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase,
tex_space_curve(cu);
}
- if(!forOrco)
+ if (!forOrco)
curve_calc_modifiers_post(scene, ob, dispbase, derivedFinal,
forRender, originalVerts, deformedVerts);
}
@@ -1187,7 +1195,7 @@ static void rotateBevelPiece(Curve *cu, BevPoint *bevp, DispList *dlb, float wid
fp = dlb->verts;
for (b = 0; b<dlb->nr; b++,fp += 3,data += 3) {
- if(cu->flag & CU_3D) {
+ if (cu->flag & CU_3D) {
float vec[3];
vec[0] = fp[1]+widfac;
@@ -1240,9 +1248,9 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
Curve *cu = ob->data;
/* we do allow duplis... this is only displist on curve level */
- if(!ELEM3(ob->type, OB_SURF, OB_CURVE, OB_FONT)) return;
+ if (!ELEM3(ob->type, OB_SURF, OB_CURVE, OB_FONT)) return;
- if(ob->type==OB_SURF) {
+ if (ob->type==OB_SURF) {
makeDispListSurf(scene, ob, dispbase, derivedFinal, forRender, forOrco);
}
else if (ELEM(ob->type, OB_CURVE, OB_FONT)) {
@@ -1256,12 +1264,12 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
BLI_freelistN(&(cu->bev));
- if(cu->path) free_path(cu->path);
+ if (cu->path) free_path(cu->path);
cu->path= NULL;
- if(ob->type==OB_FONT) BKE_text_to_curve(G.main, scene, ob, 0);
+ if (ob->type==OB_FONT) BKE_text_to_curve(G.main, scene, ob, 0);
- if(!forOrco) curve_calc_modifiers_pre(scene, ob, forRender, &originalVerts, &deformedVerts, &numVerts);
+ if (!forOrco) curve_calc_modifiers_pre(scene, ob, forRender, &originalVerts, &deformedVerts, &numVerts);
makeBevelList(ob);
@@ -1271,7 +1279,8 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
/* no bevel or extrude, and no width correction? */
if (!dlbev.first && cu->width==1.0f) {
curve_to_displist(cu, nubase, dispbase, forRender);
- } else {
+ }
+ else {
float widfac= cu->width - 1.0f;
BevList *bl= cu->bev.first;
Nurb *nu= nubase->first;
@@ -1285,15 +1294,15 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
if (bl->nr) { /* blank bevel lists can happen */
/* exception handling; curve without bevel or extrude, with width correction */
- if(dlbev.first==NULL) {
+ if (dlbev.first==NULL) {
dl= MEM_callocN(sizeof(DispList), "makeDispListbev");
dl->verts= MEM_callocN(3*sizeof(float)*bl->nr, "dlverts");
BLI_addtail(dispbase, dl);
- if(bl->poly!= -1) dl->type= DL_POLY;
+ if (bl->poly!= -1) dl->type= DL_POLY;
else dl->type= DL_SEGM;
- if(dl->type==DL_SEGM) dl->flag = (DL_FRONT_CURVE|DL_BACK_CURVE);
+ if (dl->type==DL_SEGM) dl->flag = (DL_FRONT_CURVE|DL_BACK_CURVE);
dl->parts= 1;
dl->nr= bl->nr;
@@ -1307,7 +1316,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
a= dl->nr;
bevp= (BevPoint *)(bl+1);
data= dl->verts;
- while(a--) {
+ while (a--) {
data[0]= bevp->vec[0]+widfac*bevp->sina;
data[1]= bevp->vec[1]+widfac*bevp->cosa;
data[2]= bevp->vec[2];
@@ -1329,8 +1338,8 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
dl->type= DL_SURF;
dl->flag= dlb->flag & (DL_FRONT_CURVE|DL_BACK_CURVE);
- if(dlb->type==DL_POLY) dl->flag |= DL_CYCL_U;
- if(bl->poly>=0) dl->flag |= DL_CYCL_V;
+ if (dlb->type==DL_POLY) dl->flag |= DL_CYCL_U;
+ if (bl->poly>=0) dl->flag |= DL_CYCL_V;
dl->parts= bl->nr;
dl->nr= dlb->nr;
@@ -1345,12 +1354,13 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
/* for each point of poly make a bevel piece */
bevp= (BevPoint *)(bl+1);
- for(a=0; a<bl->nr; a++,bevp++) {
+ for (a=0; a<bl->nr; a++,bevp++) {
float fac=1.0;
if (cu->taperobj==NULL) {
if ( (cu->bevobj!=NULL) || !((cu->flag & CU_FRONT) || (cu->flag & CU_BACK)) )
fac = bevp->radius;
- } else {
+ }
+ else {
fac = calc_taper(scene, cu->taperobj, a, bl->nr);
}
@@ -1373,7 +1383,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
displist_surf_indices(dl);
}
- if(bottom_capbase.first) {
+ if (bottom_capbase.first) {
filldisplist(&bottom_capbase, dispbase, 1);
filldisplist(&top_capbase, dispbase, 0);
freedisplist(&bottom_capbase);
@@ -1390,7 +1400,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
curve_to_filledpoly(cu, nubase, dispbase);
}
- if(cu->flag & CU_PATH) calc_curvepath(ob);
+ if (cu->flag & CU_PATH) calc_curvepath(ob);
/* make copy of 'undeformed" displist for texture space calculation
* actually, it's not totally undeformed -- pre-tessellation modifiers are
@@ -1401,7 +1411,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
tex_space_curve(cu);
}
- if(!forOrco) curve_calc_modifiers_post(scene, ob, dispbase, derivedFinal, forRender, originalVerts, deformedVerts);
+ if (!forOrco) curve_calc_modifiers_post(scene, ob, dispbase, derivedFinal, forRender, originalVerts, deformedVerts);
if (cu->flag & CU_DEFORM_FILL && !ob->derivedFinal) {
curve_to_filledpoly(cu, nubase, dispbase);
@@ -1417,7 +1427,7 @@ void makeDispListCurveTypes(Scene *scene, Object *ob, int forOrco)
/* The same check for duplis as in do_makeDispListCurveTypes.
* Happens when curve used for constraint/bevel was converted to mesh.
* check there is still needed for render displist and orco displists. */
- if(!ELEM3(ob->type, OB_SURF, OB_CURVE, OB_FONT)) return;
+ if (!ELEM3(ob->type, OB_SURF, OB_CURVE, OB_FONT)) return;
freedisplist(&(ob->disp));
dispbase= &(ob->disp);
@@ -1430,7 +1440,8 @@ void makeDispListCurveTypes(Scene *scene, Object *ob, int forOrco)
if (ob->derivedFinal) {
DM_set_object_boundbox (ob, ob->derivedFinal);
- } else {
+ }
+ else {
boundbox_displist (ob);
/* if there is no derivedMesh, object's boundbox is unneeded */
@@ -1466,7 +1477,7 @@ float *makeOrcoDispList(Scene *scene, Object *ob, DerivedMesh *derivedFinal, int
orco= derivedFinal->getVertDataArray(derivedFinal, CD_ORCO);
- if(orco) {
+ if (orco) {
orco= MEM_dupallocN(orco);
}
@@ -1484,21 +1495,21 @@ static void boundbox_displist(Object *ob)
INIT_MINMAX(min, max);
- if(ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
+ if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
Curve *cu= ob->data;
int doit= 0;
- if(cu->bb==NULL) cu->bb= MEM_callocN(sizeof(BoundBox), "boundbox");
+ if (cu->bb==NULL) cu->bb= MEM_callocN(sizeof(BoundBox), "boundbox");
bb= cu->bb;
dl= ob->disp.first;
while (dl) {
- if(dl->type==DL_INDEX3) tot= dl->nr;
+ if (dl->type==DL_INDEX3) tot= dl->nr;
else tot= dl->nr*dl->parts;
vert= dl->verts;
- for(a=0; a<tot; a++, vert+=3) {
+ for (a=0; a<tot; a++, vert+=3) {
doit= 1;
DO_MINMAX(vert, min, max);
}
@@ -1506,7 +1517,7 @@ static void boundbox_displist(Object *ob)
dl= dl->next;
}
- if(!doit) {
+ if (!doit) {
/* there's no geometry in displist, use zero-sized boundbox */
zero_v3(min);
zero_v3(max);
@@ -1514,7 +1525,7 @@ static void boundbox_displist(Object *ob)
}
- if(bb) {
+ if (bb) {
boundbox_set_from_min_max(bb, min, max);
}
}
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c
index 2e13890dbd5..70b55356e6a 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -246,8 +246,8 @@ struct DynamicPaintSurface *get_activeSurface(DynamicPaintCanvasSettings *canvas
DynamicPaintSurface *surface = canvas->surfaces.first;
int i;
- for(i=0; surface; surface=surface->next) {
- if(i == canvas->active_sur)
+ for (i=0; surface; surface=surface->next) {
+ if (i == canvas->active_sur)
return surface;
i++;
}
@@ -260,7 +260,7 @@ void dynamicPaint_resetPreview(DynamicPaintCanvasSettings *canvas)
DynamicPaintSurface *surface = canvas->surfaces.first;
int done=0;
- for(; surface; surface=surface->next) {
+ for (; surface; surface=surface->next) {
if (!done && dynamicPaint_surfaceHasColorPreview(surface)) {
surface->flags |= MOD_DPAINT_PREVIEW;
done=1;
@@ -274,7 +274,7 @@ void dynamicPaint_resetPreview(DynamicPaintCanvasSettings *canvas)
static void dynamicPaint_setPreview(DynamicPaintSurface *t_surface)
{
DynamicPaintSurface *surface = t_surface->canvas->surfaces.first;
- for(; surface; surface=surface->next) {
+ for (; surface; surface=surface->next) {
if (surface == t_surface)
surface->flags |= MOD_DPAINT_PREVIEW;
else
@@ -310,7 +310,7 @@ static int surface_duplicateOutputExists(void *arg, const char *name)
DynamicPaintSurface *t_surface = (DynamicPaintSurface*)arg;
DynamicPaintSurface *surface = t_surface->canvas->surfaces.first;
- for(; surface; surface=surface->next) {
+ for (; surface; surface=surface->next) {
if (surface!=t_surface && surface->type==t_surface->type &&
surface->format==t_surface->format) {
if (surface->output_name[0]!='\0' && !BLI_path_cmp(name, surface->output_name)) return 1;
@@ -336,7 +336,7 @@ static int surface_duplicateNameExists(void *arg, const char *name)
DynamicPaintSurface *t_surface = (DynamicPaintSurface*)arg;
DynamicPaintSurface *surface = t_surface->canvas->surfaces.first;
- for(; surface; surface=surface->next) {
+ for (; surface; surface=surface->next) {
if (surface!=t_surface && !strcmp(name, surface->name)) return 1;
}
return 0;
@@ -455,8 +455,8 @@ static void object_cacheIgnoreClear(Object *ob, int state)
PTCacheID *pid;
BKE_ptcache_ids_from_object(&pidlist, ob, NULL, 0);
- for(pid=pidlist.first; pid; pid=pid->next) {
- if(pid->cache) {
+ for (pid=pidlist.first; pid; pid=pid->next) {
+ if (pid->cache) {
if (state)
pid->cache->flag |= PTCACHE_IGNORE_CLEAR;
else
@@ -506,7 +506,7 @@ static int subframe_updateObject(Scene *scene, Object *ob, int flags, float fram
}
}
/* for curve following objects, parented curve has to be updated too */
- if(ob->type==OB_CURVE) {
+ if (ob->type==OB_CURVE) {
Curve *cu= ob->data;
BKE_animsys_evaluate_animdata(scene, &cu->id, cu->adt, frame, ADT_RECALC_ANIM);
}
@@ -542,7 +542,7 @@ static int surface_getBrushFlags(DynamicPaintSurface *surface, Scene *scene)
int flags = 0;
- if(surface->brush_group)
+ if (surface->brush_group)
go = surface->brush_group->gobject.first;
else
base = scene->base.first;
@@ -552,26 +552,26 @@ static int surface_getBrushFlags(DynamicPaintSurface *surface, Scene *scene)
brushObj = NULL;
/* select object */
- if(surface->brush_group) {
- if(go->ob) brushObj = go->ob;
+ if (surface->brush_group) {
+ if (go->ob) brushObj = go->ob;
}
else
brushObj = base->object;
- if(!brushObj)
+ if (!brushObj)
{
- if(surface->brush_group) go = go->next;
+ if (surface->brush_group) go = go->next;
else base= base->next;
continue;
}
- if(surface->brush_group)
+ if (surface->brush_group)
go = go->next;
else
base= base->next;
md = modifiers_findByType(brushObj, eModifierType_DynamicPaint);
- if(md && md->mode & (eModifierMode_Realtime | eModifierMode_Render))
+ if (md && md->mode & (eModifierMode_Realtime | eModifierMode_Render))
{
DynamicPaintModifierData *pmd2 = (DynamicPaintModifierData *)md;
@@ -832,15 +832,15 @@ static void surfaceGenerateGrid(struct DynamicPaintSurface *surface)
/* Free brush data */
void dynamicPaint_freeBrush(struct DynamicPaintModifierData *pmd)
{
- if(pmd->brush) {
- if(pmd->brush->dm)
+ if (pmd->brush) {
+ if (pmd->brush->dm)
pmd->brush->dm->release(pmd->brush->dm);
pmd->brush->dm = NULL;
- if(pmd->brush->paint_ramp)
+ if (pmd->brush->paint_ramp)
MEM_freeN(pmd->brush->paint_ramp);
pmd->brush->paint_ramp = NULL;
- if(pmd->brush->vel_ramp)
+ if (pmd->brush->vel_ramp)
MEM_freeN(pmd->brush->vel_ramp);
pmd->brush->vel_ramp = NULL;
@@ -922,7 +922,7 @@ void dynamicPaint_freeSurface(DynamicPaintSurface *surface)
BKE_ptcache_free_list(&(surface->ptcaches));
surface->pointcache = NULL;
- if(surface->effector_weights)
+ if (surface->effector_weights)
MEM_freeN(surface->effector_weights);
surface->effector_weights = NULL;
@@ -934,7 +934,7 @@ void dynamicPaint_freeSurface(DynamicPaintSurface *surface)
/* Free canvas data */
void dynamicPaint_freeCanvas(DynamicPaintModifierData *pmd)
{
- if(pmd->canvas) {
+ if (pmd->canvas) {
/* Free surface data */
DynamicPaintSurface *surface = pmd->canvas->surfaces.first;
DynamicPaintSurface *next_surface = NULL;
@@ -958,7 +958,7 @@ void dynamicPaint_freeCanvas(DynamicPaintModifierData *pmd)
/* Free whole dp modifier */
void dynamicPaint_Modifier_free(struct DynamicPaintModifierData *pmd)
{
- if(pmd) {
+ if (pmd) {
dynamicPaint_freeCanvas(pmd);
dynamicPaint_freeBrush(pmd);
}
@@ -1047,10 +1047,10 @@ struct DynamicPaintSurface *dynamicPaint_createNewSurface(DynamicPaintCanvasSett
*/
int dynamicPaint_createType(struct DynamicPaintModifierData *pmd, int type, struct Scene *scene)
{
- if(pmd) {
- if(type == MOD_DYNAMICPAINT_TYPE_CANVAS) {
+ if (pmd) {
+ if (type == MOD_DYNAMICPAINT_TYPE_CANVAS) {
DynamicPaintCanvasSettings *canvas;
- if(pmd->canvas)
+ if (pmd->canvas)
dynamicPaint_freeCanvas(pmd);
canvas = pmd->canvas = MEM_callocN(sizeof(DynamicPaintCanvasSettings), "DynamicPaint Canvas");
@@ -1064,9 +1064,9 @@ int dynamicPaint_createType(struct DynamicPaintModifierData *pmd, int type, stru
return 0;
}
- else if(type == MOD_DYNAMICPAINT_TYPE_BRUSH) {
+ else if (type == MOD_DYNAMICPAINT_TYPE_BRUSH) {
DynamicPaintBrushSettings *brush;
- if(pmd->brush)
+ if (pmd->brush)
dynamicPaint_freeBrush(pmd);
brush = pmd->brush = MEM_callocN(sizeof(DynamicPaintBrushSettings), "DynamicPaint Paint");
@@ -1148,8 +1148,8 @@ void dynamicPaint_Modifier_copy(struct DynamicPaintModifierData *pmd, struct Dyn
/* Copy data */
if (tpmd->canvas) {
tpmd->canvas->pmd = tpmd;
-
- } else if (tpmd->brush) {
+ }
+ else if (tpmd->brush) {
DynamicPaintBrushSettings *brush = pmd->brush, *t_brush = tpmd->brush;
t_brush->pmd = tpmd;
@@ -1574,7 +1574,7 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData
{
DerivedMesh *result = CDDM_copy(dm);
- if(pmd->canvas && !(pmd->canvas->flags & MOD_DPAINT_BAKING)) {
+ if (pmd->canvas && !(pmd->canvas->flags & MOD_DPAINT_BAKING)) {
DynamicPaintSurface *surface = pmd->canvas->surfaces.first;
int update_normals = 0;
@@ -1615,7 +1615,7 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData
#if 0
/* XXX We have to create a CD_PREVIEW_MCOL, else it might sigsev
* (after a SubSurf mod, eg)... */
- if(!result->getTessFaceDataArray(result, CD_PREVIEW_MCOL)) {
+ if (!result->getTessFaceDataArray(result, CD_PREVIEW_MCOL)) {
int numFaces = result->getNumTessFaces(result);
CustomData_add_layer(&result->faceData, CD_PREVIEW_MCOL, CD_CALLOC, NULL, numFaces);
}
@@ -1730,7 +1730,7 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData
NULL, sData->total_points, surface->output_name);
if (defgrp_index >= 0 && dvert) {
int i;
- for(i=0; i<sData->total_points; i++) {
+ for (i=0; i<sData->total_points; i++) {
MDeformVert *dv= &dvert[i];
MDeformWeight *def_weight = defvert_find_index(dv, defgrp_index);
@@ -1804,7 +1804,7 @@ void canvas_copyDerivedMesh(DynamicPaintCanvasSettings *canvas, DerivedMesh *dm)
*/
static void dynamicPaint_frameUpdate(DynamicPaintModifierData *pmd, Scene *scene, Object *ob, DerivedMesh *dm)
{
- if(pmd->canvas) {
+ if (pmd->canvas) {
DynamicPaintCanvasSettings *canvas = pmd->canvas;
DynamicPaintSurface *surface = canvas->surfaces.first;
@@ -1843,7 +1843,7 @@ static void dynamicPaint_frameUpdate(DynamicPaintModifierData *pmd, Scene *scene
BKE_ptcache_id_time(&pid, scene, (float)scene->r.cfra, NULL, NULL, NULL);
/* reset non-baked cache at first frame */
- if((int)scene->r.cfra == surface->start_frame && !(cache->flag & PTCACHE_BAKED))
+ if ((int)scene->r.cfra == surface->start_frame && !(cache->flag & PTCACHE_BAKED))
{
cache->flag |= PTCACHE_REDO_NEEDED;
BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
@@ -1851,7 +1851,7 @@ static void dynamicPaint_frameUpdate(DynamicPaintModifierData *pmd, Scene *scene
}
/* try to read from cache */
- if(BKE_ptcache_read(&pid, (float)scene->r.cfra)) {
+ if (BKE_ptcache_read(&pid, (float)scene->r.cfra)) {
BKE_ptcache_validate(cache, (int)scene->r.cfra);
}
/* if read failed and we're on surface range do recalculate */
@@ -2499,7 +2499,7 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface)
sData->total_points = active_points;
sData->format_data = f_data;
- for(index = 0; index < (w*h); index++) {
+ for (index = 0; index < (w*h); index++) {
if (tempPoints[index].face_index != -1) {
memcpy(&f_data->uv_p[cursor], &tempPoints[index], sizeof(PaintUVPoint));
memcpy(&f_data->barycentricWeights[cursor*aa_samples], &tempWeights[index*aa_samples], sizeof(Vec3f)*aa_samples);
@@ -2760,7 +2760,7 @@ static void mesh_faces_spherecast_dp(void *userdata, int index, const BVHTreeRay
{
float dist = bvhtree_ray_tri_intersection(ray, hit->dist, t0, t1, t2);
- if(dist >= 0 && dist < hit->dist)
+ if (dist >= 0 && dist < hit->dist)
{
hit->index = index;
hit->dist = dist;
@@ -2772,7 +2772,7 @@ static void mesh_faces_spherecast_dp(void *userdata, int index, const BVHTreeRay
t3 = NULL;
quad = 1;
- } while(t2);
+ } while (t2);
}
/* A modified callback to bvh tree nearest point. The tree must bust have been built using bvhtree_from_mesh_faces.
@@ -2800,7 +2800,7 @@ static void mesh_faces_nearest_point_dp(void *userdata, int index, const float *
int vertex, edge;
dist = nearest_point_in_tri_surface(t0, t1, t2, co, &vertex, &edge, nearest_tmp);
- if(dist < nearest->dist)
+ if (dist < nearest->dist)
{
nearest->index = index;
nearest->dist = dist;
@@ -2813,7 +2813,7 @@ static void mesh_faces_nearest_point_dp(void *userdata, int index, const float *
t3 = NULL;
quad = 1;
- } while(t2);
+ } while (t2);
}
@@ -3187,7 +3187,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
}
/* check bounding box collision */
- if(grid && meshBrush_boundsIntersect(&grid->grid_bounds, &mesh_bb, brush, brush_radius))
+ if (grid && meshBrush_boundsIntersect(&grid->grid_bounds, &mesh_bb, brush, brush_radius))
/* Build a bvh tree from transformed vertices */
if (bvhtree_from_mesh_faces(&treeData, dm, 0.0f, 4, 8))
{
@@ -3264,7 +3264,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
/* Check volume collision */
if (brush->collision == MOD_DPAINT_COL_VOLUME || brush->collision == MOD_DPAINT_COL_VOLDIST)
- if(BLI_bvhtree_ray_cast(treeData.tree, ray_start, ray_dir, 0.0f, &hit, mesh_faces_spherecast_dp, &treeData) != -1)
+ if (BLI_bvhtree_ray_cast(treeData.tree, ray_start, ray_dir, 0.0f, &hit, mesh_faces_spherecast_dp, &treeData) != -1)
{
/* We hit a triangle, now check if collision point normal is facing the point */
@@ -3291,7 +3291,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
BLI_bvhtree_ray_cast(treeData.tree, ray_start, ray_dir, 0.0f, &hit, mesh_faces_spherecast_dp, &treeData);
- if(hit.index != -1) {
+ if (hit.index != -1) {
/* Add factor on supersample filter */
volume_factor = 1.0f;
hit_found = HIT_VOLUME;
@@ -3343,7 +3343,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
hit.dist = brush_radius;
/* Do a face normal directional raycast, and use that distance */
- if(BLI_bvhtree_ray_cast(treeData.tree, ray_start, proj_ray, 0.0f, &hit, mesh_faces_spherecast_dp, &treeData) != -1)
+ if (BLI_bvhtree_ray_cast(treeData.tree, ray_start, proj_ray, 0.0f, &hit, mesh_faces_spherecast_dp, &treeData) != -1)
{
proxDist = hit.dist;
madd_v3_v3v3fl(hitCo, ray_start, proj_ray, hit.dist); /* Calculate final hit coordinates */
@@ -3556,12 +3556,12 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface,
tree= BLI_kdtree_new(psys->totpart);
/* loop through particles and insert valid ones to the tree */
- for(p=0, pa=psys->particles; p<psys->totpart; p++, pa++) {
+ for (p=0, pa=psys->particles; p<psys->totpart; p++, pa++) {
/* Proceed only if particle is active */
- if(pa->alive == PARS_UNBORN && (part->flag & PART_UNBORN)==0) continue;
- else if(pa->alive == PARS_DEAD && (part->flag & PART_DIED)==0) continue;
- else if(pa->flag & PARS_UNEXIST) continue;
+ if (pa->alive == PARS_UNBORN && (part->flag & PART_UNBORN)==0) continue;
+ else if (pa->alive == PARS_DEAD && (part->flag & PART_DIED)==0) continue;
+ else if (pa->flag & PARS_UNEXIST) continue;
/* for debug purposes check if any NAN particle proceeds
* For some reason they get past activity check, this should rule most of them out */
@@ -3668,7 +3668,7 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface,
particles = BLI_kdtree_range_search(tree, max_range, bData->realCoord[bData->s_pos[index]].v, NULL, &nearest);
/* Find particle that produces highest influence */
- for(n=0; n<particles; n++) {
+ for (n=0; n<particles; n++) {
ParticleData *pa = psys->particles + nearest[n].index;
float s_range;
@@ -4792,7 +4792,7 @@ static int dynamicPaint_doStep(Scene *scene, Object *ob, DynamicPaintSurface *su
float scene_subframe = scene->r.subframe;
/* either from group or from all objects */
- if(surface->brush_group)
+ if (surface->brush_group)
go = surface->brush_group->gobject.first;
else
base = scene->base.first;
@@ -4801,28 +4801,28 @@ static int dynamicPaint_doStep(Scene *scene, Object *ob, DynamicPaintSurface *su
{
brushObj = NULL;
/* select object */
- if(surface->brush_group) {
- if(go->ob) brushObj = go->ob;
+ if (surface->brush_group) {
+ if (go->ob) brushObj = go->ob;
}
else
brushObj = base->object;
- if(!brushObj) {
+ if (!brushObj) {
/* skip item */
- if(surface->brush_group) go = go->next;
+ if (surface->brush_group) go = go->next;
else base= base->next;
continue;
}
/* next item */
- if(surface->brush_group)
+ if (surface->brush_group)
go = go->next;
else
base= base->next;
/* check if target has an active dp modifier */
md = modifiers_findByType(brushObj, eModifierType_DynamicPaint);
- if(md && md->mode & (eModifierMode_Realtime | eModifierMode_Render))
+ if (md && md->mode & (eModifierMode_Realtime | eModifierMode_Render))
{
DynamicPaintModifierData *pmd2 = (DynamicPaintModifierData *)md;
/* make sure we're dealing with a brush */
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c
index f3abc20fab7..ff3eea8736d 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -105,7 +105,7 @@ 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;
@@ -157,13 +157,13 @@ typedef struct VeNoCo {
/* -------------------------- Effectors ------------------ */
void free_partdeflect(PartDeflect *pd)
{
- if(!pd)
+ if (!pd)
return;
- if(pd->tex)
+ if (pd->tex)
pd->tex->id.us--;
- if(pd->rng)
+ if (pd->rng)
rng_free(pd->rng);
MEM_freeN(pd);
@@ -172,34 +172,34 @@ void free_partdeflect(PartDeflect *pd)
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)
+ if (!eff->pd->rng)
eff->pd->rng = rng_new(eff->pd->seed + cfra);
else
rng_srandom(eff->pd->rng, eff->pd->seed + cfra);
- if(eff->pd->forcefield == PFIELD_GUIDE && eff->ob->type==OB_CURVE) {
+ if (eff->pd->forcefield == PFIELD_GUIDE && eff->ob->type==OB_CURVE) {
Curve *cu= eff->ob->data;
- if(cu->flag & CU_PATH) {
- if(cu->path==NULL || cu->path->data==NULL)
+ if (cu->flag & CU_PATH) {
+ if (cu->path==NULL || cu->path->data==NULL)
makeDispListCurveTypes(eff->scene, eff->ob, 0);
- if(cu->path && cu->path->data) {
+ if (cu->path && cu->path->data) {
where_on_path(eff->ob, 0.0, eff->guide_loc, eff->guide_dir, NULL, &eff->guide_radius, NULL);
mul_m4_v3(eff->ob->obmat, eff->guide_loc);
mul_mat3_m4_v3(eff->ob->obmat, eff->guide_dir);
}
}
}
- else if(eff->pd->shape == PFIELD_SHAPE_SURFACE) {
+ else if (eff->pd->shape == PFIELD_SHAPE_SURFACE) {
eff->surmd = (SurfaceModifierData *)modifiers_findByType ( eff->ob, eModifierType_Surface );
- if(eff->ob->type == OB_CURVE)
+ 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) {
+ if (eff->ob) {
float old_vel[3];
where_is_object_time(eff->scene, eff->ob, cfra - 1.0f);
@@ -225,13 +225,13 @@ static void add_object_to_effectors(ListBase **effectors, Scene *scene, Effector
{
EffectorCache *eff = NULL;
- if( ob == ob_src || weights->weight[ob->pd->forcefield] == 0.0f )
+ if ( ob == ob_src || weights->weight[ob->pd->forcefield] == 0.0f )
return;
if (ob->pd->shape == PFIELD_SHAPE_POINTS && !ob->derivedFinal )
return;
- if(*effectors == NULL)
+ if (*effectors == NULL)
*effectors = MEM_callocN(sizeof(ListBase), "effectors list");
eff = new_effector_cache(scene, ob, NULL, ob->pd);
@@ -245,21 +245,21 @@ static void add_particles_to_effectors(ListBase **effectors, Scene *scene, Effec
{
ParticleSettings *part= psys->part;
- if( !psys_check_enabled(ob, psys) )
+ if ( !psys_check_enabled(ob, psys) )
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 && weights->weight[part->pd->forcefield] != 0.0f) {
- if(*effectors == NULL)
+ if ( part->pd && part->pd->forcefield && 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 && 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));
@@ -273,33 +273,33 @@ ListBase *pdInitEffectors(Scene *scene, Object *ob_src, ParticleSystem *psys_src
unsigned int layer= ob_src->lay;
ListBase *effectors = NULL;
- if(weights->group) {
+ 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 (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);
- if( go->ob->particlesystem.first ) {
+ if ( go->ob->particlesystem.first ) {
ParticleSystem *psys= go->ob->particlesystem.first;
- for( ; psys; psys=psys->next )
+ for ( ; psys; psys=psys->next )
add_particles_to_effectors(&effectors, scene, weights, go->ob, psys, psys_src);
}
}
}
}
else {
- for(base = scene->base.first; base; base= base->next) {
- if( (base->lay & layer) ) {
- if( base->object->pd && base->object->pd->forcefield )
+ for (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);
- if( base->object->particlesystem.first ) {
+ if ( base->object->particlesystem.first ) {
ParticleSystem *psys= base->object->particlesystem.first;
- for( ; psys; psys=psys->next )
+ for ( ; psys; psys=psys->next )
add_particles_to_effectors(&effectors, scene, weights, base->object, psys, psys_src);
}
}
@@ -310,11 +310,11 @@ ListBase *pdInitEffectors(Scene *scene, Object *ob_src, ParticleSystem *psys_src
void pdEndEffectors(ListBase **effectors)
{
- if(*effectors) {
+ if (*effectors) {
EffectorCache *eff = (*effectors)->first;
- for(; eff; eff=eff->next) {
- if(eff->guide_data)
+ for (; eff; eff=eff->next) {
+ if (eff->guide_data)
MEM_freeN(eff->guide_data);
}
@@ -334,10 +334,10 @@ void pd_point_from_particle(ParticleSimulationData *sim, ParticleData *pa, Parti
point->size = pa->size;
point->charge = 0.0f;
- if(part->pd && part->pd->forcefield == PFIELD_CHARGE)
+ if (part->pd && part->pd->forcefield == PFIELD_CHARGE)
point->charge += part->pd->f_strength;
- if(part->pd2 && part->pd2->forcefield == PFIELD_CHARGE)
+ if (part->pd2 && part->pd2->forcefield == PFIELD_CHARGE)
point->charge += part->pd2->f_strength;
point->vel_to_sec = 1.0f;
@@ -345,7 +345,7 @@ void pd_point_from_particle(ParticleSimulationData *sim, ParticleData *pa, Parti
point->flag = 0;
- if(sim->psys->part->flag & PART_ROT_DYN) {
+ if (sim->psys->part->flag & PART_ROT_DYN) {
point->ave = state->ave;
point->rot = state->rot;
}
@@ -406,24 +406,24 @@ 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);
// check all collision objects
- for(col = colls->first; col; col = col->next)
+ 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) {
@@ -439,13 +439,13 @@ static float eff_calc_visibility(ListBase *colliders, EffectorCache *eff, Effect
// visibility is only between 0 and 1, calculated from 1-absorption
visibility *= CLAMPIS(1.0f-absorption, 0.0f, 1.0f);
- if(visibility <= 0.0f)
+ if (visibility <= 0.0f)
break;
}
}
}
- if(!colliders)
+ if (!colliders)
free_collider_cache(&colls);
return visibility;
@@ -472,13 +472,13 @@ static float wind_func(struct RNG *rng, float strength)
static float falloff_func(float fac, int usemin, float mindist, int usemax, float maxdist, float power)
{
/* first quick checks */
- if(usemax && fac > maxdist)
+ if (usemax && fac > maxdist)
return 0.0f;
- if(usemin && fac < mindist)
+ if (usemin && fac < mindist)
return 1.0f;
- if(!usemin)
+ if (!usemin)
mindist = 0.0;
return pow((double)(1.0f+fac-mindist), (double)(-power));
@@ -502,9 +502,9 @@ float effector_falloff(EffectorCache *eff, EffectorData *efd, EffectedPoint *UNU
fac = dot_v3v3(efd->nor, efd->vec_to_point2);
- if(eff->pd->zdir == PFIELD_Z_POS && fac < 0.0f)
+ if (eff->pd->zdir == PFIELD_Z_POS && fac < 0.0f)
falloff=0.0f;
- else if(eff->pd->zdir == PFIELD_Z_NEG && fac > 0.0f)
+ else if (eff->pd->zdir == PFIELD_Z_NEG && fac > 0.0f)
falloff=0.0f;
else switch(eff->pd->falloff) {
case PFIELD_FALL_SPHERE:
@@ -513,7 +513,7 @@ float effector_falloff(EffectorCache *eff, EffectorData *efd, EffectedPoint *UNU
case PFIELD_FALL_TUBE:
falloff*= falloff_func_dist(eff->pd, ABS(fac));
- if(falloff == 0.0f)
+ if (falloff == 0.0f)
break;
madd_v3_v3v3fl(temp, efd->vec_to_point, efd->nor, -fac);
@@ -522,7 +522,7 @@ float effector_falloff(EffectorCache *eff, EffectorData *efd, EffectedPoint *UNU
break;
case PFIELD_FALL_CONE:
falloff*= falloff_func_dist(eff->pd, ABS(fac));
- if(falloff == 0.0f)
+ if (falloff == 0.0f)
break;
r_fac= RAD2DEGF(saacos(fac/len_v3(efd->vec_to_point)));
@@ -543,20 +543,20 @@ int closest_point_on_surface(SurfaceModifierData *surmd, const float co[3], floa
BLI_bvhtree_find_nearest(surmd->bvhtree->tree, co, &nearest, surmd->bvhtree->nearest_callback, surmd->bvhtree);
- if(nearest.index != -1) {
+ if (nearest.index != -1) {
copy_v3_v3(surface_co, nearest.co);
- if(surface_nor) {
+ if (surface_nor) {
copy_v3_v3(surface_nor, nearest.no);
}
- if(surface_vel) {
+ if (surface_vel) {
MFace *mface = CDDM_get_tessface(surmd->dm, nearest.index);
copy_v3_v3(surface_vel, surmd->v[mface->v1].co);
add_v3_v3(surface_vel, surmd->v[mface->v2].co);
add_v3_v3(surface_vel, surmd->v[mface->v3].co);
- if(mface->v4)
+ if (mface->v4)
add_v3_v3(surface_vel, surmd->v[mface->v4].co);
mul_v3_fl(surface_vel, mface->v4 ? 0.25f : 0.333f);
@@ -571,7 +571,7 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin
float cfra = eff->scene->r.cfra;
int ret = 0;
- if(eff->pd && eff->pd->shape==PFIELD_SHAPE_SURFACE && eff->surmd) {
+ if (eff->pd && eff->pd->shape==PFIELD_SHAPE_SURFACE && eff->surmd) {
/* closest point in the object surface is an effector */
float vec[3];
@@ -584,9 +584,9 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin
efd->size = 0.0f;
}
- else if(eff->pd && eff->pd->shape==PFIELD_SHAPE_POINTS) {
+ else if (eff->pd && eff->pd->shape==PFIELD_SHAPE_POINTS) {
- if(eff->ob->derivedFinal) {
+ if (eff->ob->derivedFinal) {
DerivedMesh *dm = eff->ob->derivedFinal;
dm->getVertCo(dm, *efd->index, efd->loc);
@@ -603,12 +603,12 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin
ret = 1;
}
}
- else if(eff->psys) {
+ else if (eff->psys) {
ParticleData *pa = eff->psys->particles + *efd->index;
ParticleKey state;
/* exclude the particle itself for self effecting particles */
- if(eff->psys == point->psys && *efd->index == point->index) {
+ if (eff->psys == point->psys && *efd->index == point->index) {
/* pass */
}
else {
@@ -623,7 +623,7 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin
/* TODO */
//if(eff->pd->forcefiled == PFIELD_HARMONIC && ret==0) {
- // if(pa->dietime < eff->psys->cfra)
+ // if (pa->dietime < eff->psys->cfra)
// eff->flag |= PE_VELOCITY_TO_IMPULSE;
//}
@@ -634,7 +634,7 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin
efd->nor[1] = efd->nor[2] = 0.f;
mul_qt_v3(state.rot, efd->nor);
- if(real_velocity)
+ if (real_velocity)
copy_v3_v3(efd->vel, state.vel);
efd->size = pa->size;
@@ -648,13 +648,13 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin
/* use z-axis as normal*/
normalize_v3_v3(efd->nor, ob->obmat[2]);
- if(eff->pd && eff->pd->shape == PFIELD_SHAPE_PLANE) {
+ if (eff->pd && eff->pd->shape == PFIELD_SHAPE_PLANE) {
float temp[3], translate[3];
sub_v3_v3v3(temp, point->loc, ob->obmat[3]);
project_v3_v3v3(translate, temp, efd->nor);
/* for vortex the shape chooses between old / new force */
- if(eff->pd->forcefield == PFIELD_VORTEX)
+ if (eff->pd->forcefield == PFIELD_VORTEX)
add_v3_v3v3(efd->loc, ob->obmat[3], translate);
else /* normally efd->loc is closest point on effector xy-plane */
sub_v3_v3v3(efd->loc, point->loc, translate);
@@ -663,7 +663,7 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin
copy_v3_v3(efd->loc, ob->obmat[3]);
}
- if(real_velocity)
+ if (real_velocity)
copy_v3_v3(efd->vel, eff->velocity);
*eff->ob = obcopy;
@@ -673,15 +673,15 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin
ret = 1;
}
- if(ret) {
+ if (ret) {
sub_v3_v3v3(efd->vec_to_point, point->loc, efd->loc);
efd->distance = len_v3(efd->vec_to_point);
/* rest length for harmonic effector, will have to see later if this could be extended to other effectors */
- if(eff->pd && eff->pd->forcefield == PFIELD_HARMONIC && eff->pd->f_size)
+ if (eff->pd && eff->pd->forcefield == PFIELD_HARMONIC && eff->pd->f_size)
mul_v3_fl(efd->vec_to_point, (efd->distance-eff->pd->f_size)/efd->distance);
- if(eff->flag & PE_USE_NORMAL_DATA) {
+ if (eff->flag & PE_USE_NORMAL_DATA) {
copy_v3_v3(efd->vec_to_point2, efd->vec_to_point);
copy_v3_v3(efd->nor2, efd->nor);
}
@@ -696,24 +696,24 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin
}
static void get_effector_tot(EffectorCache *eff, EffectorData *efd, EffectedPoint *point, int *tot, int *p, int *step)
{
- if(eff->pd->shape == PFIELD_SHAPE_POINTS) {
+ if (eff->pd->shape == PFIELD_SHAPE_POINTS) {
efd->index = p;
*p = 0;
*tot = eff->ob->derivedFinal ? eff->ob->derivedFinal->numVertData : 1;
- if(*tot && eff->pd->forcefield == PFIELD_HARMONIC && point->index >= 0) {
+ if (*tot && eff->pd->forcefield == PFIELD_HARMONIC && point->index >= 0) {
*p = point->index % *tot;
*tot = *p+1;
}
}
- else if(eff->psys) {
+ else if (eff->psys) {
efd->index = p;
*p = 0;
*tot = eff->psys->totpart;
- if(eff->pd->forcefield == PFIELD_CHARGE) {
+ if (eff->pd->forcefield == PFIELD_CHARGE) {
/* Only the charge of the effected particle is used for
* interaction, not fall-offs. If the fall-offs aren't the
* same this will be unphysical, but for animation this
@@ -722,13 +722,13 @@ static void get_effector_tot(EffectorCache *eff, EffectorData *efd, EffectedPoin
*/
efd->charge = eff->pd->f_strength;
}
- else if(eff->pd->forcefield == PFIELD_HARMONIC && (eff->pd->flag & PFIELD_MULTIPLE_SPRINGS)==0) {
+ else if (eff->pd->forcefield == PFIELD_HARMONIC && (eff->pd->flag & PFIELD_MULTIPLE_SPRINGS)==0) {
/* every particle is mapped to only one harmonic effector particle */
*p= point->index % eff->psys->totpart;
*tot= *p + 1;
}
- if(eff->psys->part->effector_amount) {
+ if (eff->psys->part->effector_amount) {
int totpart = eff->psys->totpart;
int amount = eff->psys->part->effector_amount;
@@ -748,7 +748,7 @@ static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedP
int hasrgb;
short mode = eff->pd->tex_mode;
- if(!eff->pd->tex)
+ if (!eff->pd->tex)
return;
result[0].nor = result[1].nor = result[2].nor = result[3].nor = NULL;
@@ -757,18 +757,18 @@ static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedP
copy_v3_v3(tex_co,point->loc);
- if(eff->pd->flag & PFIELD_TEX_2D) {
+ if (eff->pd->flag & PFIELD_TEX_2D) {
float fac=-dot_v3v3(tex_co, efd->nor);
madd_v3_v3fl(tex_co, efd->nor, fac);
}
- if(eff->pd->flag & PFIELD_TEX_OBJECT) {
+ if (eff->pd->flag & PFIELD_TEX_OBJECT) {
mul_m4_v3(eff->ob->imat, tex_co);
}
hasrgb = multitex_ext(eff->pd->tex, tex_co, NULL,NULL, 0, result);
- if(hasrgb && mode==PFIELD_TEX_RGB) {
+ if (hasrgb && mode==PFIELD_TEX_RGB) {
force[0] = (0.5f - result->tr) * strength;
force[1] = (0.5f - result->tg) * strength;
force[2] = (0.5f - result->tb) * strength;
@@ -787,7 +787,7 @@ static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedP
tex_co[2] += nabla;
multitex_ext(eff->pd->tex, tex_co, NULL, NULL, 0, result+3);
- if(mode == PFIELD_TEX_GRAD || !hasrgb) { /* if we don't have rgb fall back to grad */
+ if (mode == PFIELD_TEX_GRAD || !hasrgb) { /* if we don't have rgb fall back to grad */
force[0] = (result[0].tin - result[1].tin) * strength;
force[1] = (result[0].tin - result[2].tin) * strength;
force[2] = (result[0].tin - result[3].tin) * strength;
@@ -808,7 +808,7 @@ static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedP
}
}
- if(eff->pd->flag & PFIELD_TEX_2D) {
+ if (eff->pd->flag & PFIELD_TEX_2D) {
float fac = -dot_v3v3(force, efd->nor);
madd_v3_v3fl(force, efd->nor, fac);
}
@@ -826,10 +826,10 @@ static void do_physical_effector(EffectorCache *eff, EffectorData *efd, Effected
float damp = pd->f_damp;
float noise_factor = pd->f_noise;
- if(noise_factor > 0.0f) {
+ if (noise_factor > 0.0f) {
strength += wind_func(rng, noise_factor);
- if(ELEM(pd->forcefield, PFIELD_HARMONIC, PFIELD_DRAG))
+ if (ELEM(pd->forcefield, PFIELD_HARMONIC, PFIELD_DRAG))
damp += wind_func(rng, noise_factor);
}
@@ -846,7 +846,7 @@ static void do_physical_effector(EffectorCache *eff, EffectorData *efd, Effected
break;
case PFIELD_VORTEX:
/* old vortex force */
- if(pd->shape == PFIELD_SHAPE_POINT) {
+ if (pd->shape == PFIELD_SHAPE_POINT) {
cross_v3_v3v3(force, efd->nor, efd->vec_to_point);
normalize_v3(force);
mul_v3_fl(force, strength * efd->distance * efd->falloff);
@@ -864,7 +864,7 @@ static void do_physical_effector(EffectorCache *eff, EffectorData *efd, Effected
}
break;
case PFIELD_MAGNET:
- if(eff->pd->shape == PFIELD_SHAPE_POINT)
+ if (eff->pd->shape == PFIELD_SHAPE_POINT)
/* magnetic field of a moving charge */
cross_v3_v3v3(temp, efd->nor, efd->vec_to_point);
else
@@ -898,7 +898,7 @@ static void do_physical_effector(EffectorCache *eff, EffectorData *efd, Effected
/* Boid field is handled completely in boids code. */
return;
case PFIELD_TURBULENCE:
- if(pd->flag & PFIELD_GLOBAL_CO) {
+ if (pd->flag & PFIELD_GLOBAL_CO) {
copy_v3_v3(temp, point->loc);
}
else {
@@ -920,20 +920,20 @@ static void do_physical_effector(EffectorCache *eff, EffectorData *efd, Effected
break;
}
- if(pd->flag & PFIELD_DO_LOCATION) {
+ if (pd->flag & PFIELD_DO_LOCATION) {
madd_v3_v3fl(total_force, force, 1.0f/point->vel_to_sec);
- if(ELEM(pd->forcefield, PFIELD_HARMONIC, PFIELD_DRAG)==0 && pd->f_flow != 0.0f) {
+ if (ELEM(pd->forcefield, PFIELD_HARMONIC, PFIELD_DRAG)==0 && pd->f_flow != 0.0f) {
madd_v3_v3fl(total_force, point->vel, -pd->f_flow * efd->falloff);
}
}
- if(pd->flag & PFIELD_DO_ROTATION && point->ave && point->rot) {
+ if (pd->flag & PFIELD_DO_ROTATION && point->ave && point->rot) {
float xvec[3] = {1.0f, 0.0f, 0.0f};
float dave[3];
mul_qt_v3(point->rot, xvec);
cross_v3_v3v3(dave, xvec, force);
- if(pd->f_flow != 0.0f) {
+ if (pd->f_flow != 0.0f) {
madd_v3_v3fl(dave, point->ave, -pd->f_flow * efd->falloff);
}
add_v3_v3(point->ave, dave);
@@ -975,21 +975,21 @@ void pdDoEffectors(ListBase *effectors, ListBase *colliders, EffectorWeights *we
/* Cycle through collected objects, get total of (1/(gravity_strength * dist^gravity_power)) */
/* Check for min distance here? (yes would be cool to add that, ton) */
- if(effectors) for(eff = effectors->first; eff; eff=eff->next) {
+ if (effectors) for(eff = effectors->first; eff; eff=eff->next) {
/* object effectors were fully checked to be OK to evaluate! */
get_effector_tot(eff, &efd, point, &tot, &p, &step);
- for(; p<tot; p+=step) {
- if(get_effector_data(eff, &efd, point, 0)) {
+ for (; p<tot; p+=step) {
+ if (get_effector_data(eff, &efd, point, 0)) {
efd.falloff= effector_falloff(eff, &efd, point, weights);
- if(efd.falloff > 0.0f)
+ if (efd.falloff > 0.0f)
efd.falloff *= eff_calc_visibility(colliders, eff, &efd, point);
- if(efd.falloff <= 0.0f)
+ if (efd.falloff <= 0.0f)
; /* don't do anything */
- else if(eff->pd->forcefield == PFIELD_TEXTURE)
+ else if (eff->pd->forcefield == PFIELD_TEXTURE)
do_texture_effector(eff, &efd, point, force);
else {
float temp1[3]={0,0,0}, temp2[3];
@@ -998,13 +998,13 @@ void pdDoEffectors(ListBase *effectors, ListBase *colliders, EffectorWeights *we
do_physical_effector(eff, &efd, point, force);
// for softbody backward compatibility
- if(point->flag & PE_WIND_AS_SPEED && impulse) {
+ if (point->flag & PE_WIND_AS_SPEED && impulse) {
sub_v3_v3v3(temp2, force, temp1);
sub_v3_v3v3(impulse, impulse, temp2);
}
}
}
- else if(eff->flag & PE_VELOCITY_TO_IMPULSE && impulse) {
+ else if (eff->flag & PE_VELOCITY_TO_IMPULSE && impulse) {
/* special case for harmonic effector */
add_v3_v3v3(impulse, impulse, efd.vel);
}
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index 65bf9f0219e..97e59df3353 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -183,7 +183,7 @@ FCurve *id_data_find_fcurve(ID *id, void *data, StructRNA *type, const char *pro
PropertyRNA *prop;
char *path;
- if(driven)
+ if (driven)
*driven = FALSE;
/* only use the current action ??? */
@@ -204,7 +204,7 @@ FCurve *id_data_find_fcurve(ID *id, void *data, StructRNA *type, const char *pro
/* if not animated, check if driven */
if ((fcu == NULL) && (adt->drivers.first)) {
fcu= list_find_fcurve(&adt->drivers, path, index);
- if(fcu && driven)
+ if (fcu && driven)
*driven = TRUE;
fcu = NULL;
}
@@ -845,8 +845,8 @@ void testhandles_fcurve (FCurve *fcu, const short use_handle)
* of beztriple control-points (labelled 0,1,2)
*/
if (bezt->f2 & SELECT) flag |= (1<<1); // == 2
- if(use_handle == FALSE) {
- if(flag & 2) {
+ if (use_handle == FALSE) {
+ if (flag & 2) {
flag |= (1<<0) | (1<<2);
}
}
@@ -1020,7 +1020,7 @@ static float dtar_get_prop_val (ChannelDriver *driver, DriverTarget *dtar)
/* get property to read from, and get value as appropriate */
if (RNA_path_resolve_full(&id_ptr, dtar->rna_path, &ptr, &prop, &index)) {
- if(RNA_property_array_check(prop)) {
+ if (RNA_property_array_check(prop)) {
/* array */
if (index < RNA_property_array_length(&ptr, prop)) {
switch (RNA_property_type(prop)) {
@@ -1418,7 +1418,7 @@ void driver_free_variable (ChannelDriver *driver, DriverVar *dvar)
#ifdef WITH_PYTHON
/* since driver variables are cached, the expression needs re-compiling too */
- if(driver->type==DRIVER_TYPE_PYTHON)
+ if (driver->type==DRIVER_TYPE_PYTHON)
driver->flag |= DRIVER_FLAG_RENAMEVAR;
#endif
}
@@ -1981,7 +1981,7 @@ static float fcurve_eval_keyframes (FCurve *fcu, BezTriple *bezts, float evaltim
/* evaltime occurs somewhere in the middle of the curve */
for (a=0; prevbezt && bezt && (a < fcu->totvert-1); a++, prevbezt=bezt, bezt++) {
/* use if the key is directly on the frame, rare cases this is needed else we get 0.0 instead. */
- if(fabsf(bezt->vec[1][0] - evaltime) < SMALL_NUMBER) {
+ if (fabsf(bezt->vec[1][0] - evaltime) < SMALL_NUMBER) {
cvalue= bezt->vec[1][1];
}
/* evaltime occurs within the interval defined by these two keyframes */
diff --git a/source/blender/blenkernel/intern/fluidsim.c b/source/blender/blenkernel/intern/fluidsim.c
index 587fe75031f..d3d0952f3f8 100644
--- a/source/blender/blenkernel/intern/fluidsim.c
+++ b/source/blender/blenkernel/intern/fluidsim.c
@@ -91,20 +91,20 @@ void initElbeemMesh(struct Scene *scene, struct Object *ob,
*numVertices = totvert;
verts = MEM_callocN( totvert*3*sizeof(float), "elbeemmesh_vertices");
- for(i=0; i<totvert; i++) {
+ for (i=0; i<totvert; i++) {
copy_v3_v3(&verts[i*3], mvert[i].co);
- if(useGlobalCoords) { mul_m4_v3(ob->obmat, &verts[i*3]); }
+ if (useGlobalCoords) { mul_m4_v3(ob->obmat, &verts[i*3]); }
}
*vertices = verts;
- for(i=0; i<totface; i++) {
+ for (i=0; i<totface; i++) {
countTris++;
- if(mface[i].v4) { countTris++; }
+ if (mface[i].v4) { countTris++; }
}
*numTriangles = countTris;
tris = MEM_callocN( countTris*3*sizeof(int), "elbeemmesh_triangles");
countTris = 0;
- for(i=0; i<totface; i++) {
+ for (i=0; i<totface; i++) {
int face[4];
face[0] = mface[i].v1;
face[1] = mface[i].v2;
@@ -115,7 +115,7 @@ void initElbeemMesh(struct Scene *scene, struct Object *ob,
tris[countTris*3+1] = face[1];
tris[countTris*3+2] = face[2];
countTris++;
- if(face[3]) {
+ if (face[3]) {
tris[countTris*3+0] = face[0];
tris[countTris*3+1] = face[2];
tris[countTris*3+2] = face[3];
diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c
index e6538e1500a..bc587449853 100644
--- a/source/blender/blenkernel/intern/fmodifier.c
+++ b/source/blender/blenkernel/intern/fmodifier.c
@@ -627,7 +627,7 @@ static float fcm_cycles_time (FCurve *fcu, FModifier *fcm, float UNUSED(cvalue),
/* check if 'cyclic extrapolation', and thus calculate y-offset for this cycle */
if (mode == FCM_EXTRAPOLATE_CYCLIC_OFFSET) {
- if(side < 0)
+ if (side < 0)
cycyofs = (float)floor((evaltime - ofs) / cycdx);
else
cycyofs = (float)ceil((evaltime - ofs) / cycdx);
@@ -635,10 +635,10 @@ static float fcm_cycles_time (FCurve *fcu, FModifier *fcm, float UNUSED(cvalue),
}
/* special case for cycle start/end */
- if(cyct == 0.0f) {
+ if (cyct == 0.0f) {
evaltime = (side == 1 ? lastkey[0] : prevkey[0]);
- if((mode == FCM_EXTRAPOLATE_MIRROR) && ((int)cycle % 2))
+ if ((mode == FCM_EXTRAPOLATE_MIRROR) && ((int)cycle % 2))
evaltime = (side == 1 ? prevkey[0] : lastkey[0]);
}
/* calculate where in the cycle we are (overwrite evaltime to reflect this) */
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c
index 4cf47906b64..b2759f18e9b 100644
--- a/source/blender/blenkernel/intern/font.c
+++ b/source/blender/blenkernel/intern/font.c
@@ -68,7 +68,7 @@ void free_vfont(struct VFont *vf)
if (vf == NULL) return;
if (vf->data) {
- while(vf->data->characters.first)
+ while (vf->data->characters.first)
{
VChar *che = vf->data->characters.first;
@@ -106,7 +106,8 @@ static PackedFile *get_builtin_packedfile(void)
printf("Internal error, builtin font not loaded\n");
return NULL;
- } else {
+ }
+ else {
void *mem= MEM_mallocN(builtin_font_size, "vfd_builtin");
memcpy(mem, builtin_font_data, builtin_font_size);
@@ -119,8 +120,8 @@ void free_ttfont(void)
{
struct TmpFont *tf;
- for(tf= ttfdata.first; tf; tf= tf->next) {
- if(tf->pf) freePackedFile(tf->pf); /* NULL when the font file can't be found on disk */
+ for (tf= ttfdata.first; tf; tf= tf->next) {
+ if (tf->pf) freePackedFile(tf->pf); /* NULL when the font file can't be found on disk */
tf->pf= NULL;
tf->vfont= NULL;
}
@@ -131,13 +132,13 @@ struct TmpFont *vfont_find_tmpfont(VFont *vfont)
{
struct TmpFont *tmpfnt = NULL;
- if(vfont==NULL) return NULL;
+ if (vfont==NULL) return NULL;
// Try finding the font from font list
tmpfnt = ttfdata.first;
- while(tmpfnt)
+ while (tmpfnt)
{
- if(tmpfnt->vfont == vfont)
+ if (tmpfnt->vfont == vfont)
break;
tmpfnt = tmpfnt->next;
}
@@ -149,7 +150,7 @@ static VFontData *vfont_get_data(Main *bmain, VFont *vfont)
struct TmpFont *tmpfnt = NULL;
PackedFile *tpf;
- if(vfont==NULL) return NULL;
+ if (vfont==NULL) return NULL;
// Try finding the font from font list
tmpfnt = vfont_find_tmpfont(vfont);
@@ -160,12 +161,13 @@ static VFontData *vfont_get_data(Main *bmain, VFont *vfont)
if (strcmp(vfont->name, FO_BUILTIN_NAME)==0) {
pf= get_builtin_packedfile();
- } else {
+ }
+ else {
if (vfont->packedfile) {
pf= vfont->packedfile;
// We need to copy a tmp font to memory unless it is already there
- if(!tmpfnt) {
+ if (!tmpfnt) {
tpf= MEM_callocN(sizeof(*tpf), "PackedFile");
tpf->data= MEM_mallocN(pf->size, "packFile");
tpf->size= pf->size;
@@ -191,7 +193,7 @@ static VFontData *vfont_get_data(Main *bmain, VFont *vfont)
BLI_addtail(&ttfdata, tmpfnt);
}
}
- if(!pf) {
+ if (!pf) {
printf("Font file doesn't exist: %s\n", vfont->name);
strcpy(vfont->name, FO_BUILTIN_NAME);
@@ -224,7 +226,8 @@ VFont *load_vfont(Main *bmain, const char *name)
pf= get_builtin_packedfile();
is_builtin= 1;
- } else {
+ }
+ else {
char dir[FILE_MAXDIR];
BLI_strncpy(dir, name, sizeof(dir));
@@ -304,8 +307,8 @@ static VChar *find_vfont_char(VFontData *vfd, intptr_t character)
{
VChar *che= NULL;
- for(che = vfd->characters.first; che; che = che->next) {
- if(che->index == character)
+ for (che = vfd->characters.first; che; che = che->next) {
+ if (che->index == character)
break;
}
return che; /* NULL if not found */
@@ -390,11 +393,11 @@ static void buildchar(Main *bmain, Curve *cu, unsigned long character, CharInfo
che= find_vfont_char(vfd, character);
// Select the glyph data
- if(che)
+ if (che)
nu1 = che->nurbsbase.first;
// Create the character
- while(nu1)
+ while (nu1)
{
bezt1 = nu1->bezt;
if (bezt1) {
@@ -434,7 +437,7 @@ static void buildchar(Main *bmain, Curve *cu, unsigned long character, CharInfo
bezt2++;
}
}
- if(rot != 0.0f) {
+ if (rot != 0.0f) {
bezt2= nu2->bezt;
for (i=nu2->pntsu; i > 0; i--) {
fp= bezt2->vec[0];
@@ -454,7 +457,7 @@ static void buildchar(Main *bmain, Curve *cu, unsigned long character, CharInfo
}
bezt2 = nu2->bezt;
- if(info->flag & CU_CHINFO_SMALLCAPS_CHECK) {
+ if (info->flag & CU_CHINFO_SMALLCAPS_CHECK) {
const float sca= cu->smallcaps_scale;
for (i= nu2->pntsu; i > 0; i--) {
fp= bezt2->vec[0];
@@ -509,10 +512,10 @@ int BKE_font_getselection(Object *ob, int *start, int *end)
static float char_width(Curve *cu, VChar *che, CharInfo *info)
{
// The character wasn't found, propably ascii = 0, then the width shall be 0 as well
- if(che == NULL) {
+ if (che == NULL) {
return 0.0f;
}
- else if(info->flag & CU_CHINFO_SMALLCAPS_CHECK) {
+ else if (info->flag & CU_CHINFO_SMALLCAPS_CHECK) {
return che->width * cu->smallcaps_scale;
}
else {
@@ -541,14 +544,14 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m
/* renark: do calculations including the trailing '\0' of a string
* because the cursor can be at that location */
- if(ob->type!=OB_FONT) return NULL;
+ if (ob->type!=OB_FONT) return NULL;
// Set font data
cu= (Curve *) ob->data;
vfont= cu->vfont;
- if(cu->str == NULL) return NULL;
- if(vfont == NULL) return NULL;
+ if (cu->str == NULL) return NULL;
+ if (vfont == NULL) return NULL;
// Create unicode string
utf8len = BLI_strlen_utf8(cu->str);
@@ -575,8 +578,8 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m
vfd= vfont_get_data(bmain, vfont);
/* The VFont Data can not be found */
- if(!vfd) {
- if(mem)
+ if (!vfd) {
+ if (mem)
MEM_freeN(mem);
return NULL;
}
@@ -615,9 +618,9 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m
// Characters in the list
info = &(custrinfo[i]);
ascii = mem[i];
- if(info->flag & CU_CHINFO_SMALLCAPS) {
+ if (info->flag & CU_CHINFO_SMALLCAPS) {
ascii = towupper(ascii);
- if(mem[i] != ascii) {
+ if (mem[i] != ascii) {
mem[i]= ascii;
info->flag |= CU_CHINFO_SMALLCAPS_CHECK;
}
@@ -625,7 +628,7 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m
vfont = which_vfont(cu, info);
- if(vfont==NULL) break;
+ if (vfont==NULL) break;
che= find_vfont_char(vfd, ascii);
@@ -634,7 +637,7 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m
* But if the font is FO_BUILTIN_NAME then do not try loading since
* whole font is in the memory already
*/
- if(che == NULL && strcmp(vfont->name, FO_BUILTIN_NAME)) {
+ if (che == NULL && strcmp(vfont->name, FO_BUILTIN_NAME)) {
BLI_vfontchar_from_freetypefont(vfont, ascii);
}
@@ -643,7 +646,7 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m
/* No VFont found */
if (vfont==NULL) {
- if(mem)
+ if (mem)
MEM_freeN(mem);
MEM_freeN(chartransdata);
return NULL;
@@ -656,7 +659,7 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m
/* VFont Data for VFont couldn't be found */
if (!vfd) {
- if(mem)
+ if (mem)
MEM_freeN(mem);
MEM_freeN(chartransdata);
return NULL;
@@ -665,7 +668,7 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m
twidth = char_width(cu, che, info);
// Calculate positions
- if((tb->w != 0.0f) && (ct->dobreak==0) && ((xof-(tb->x/cu->fsize)+twidth)*cu->fsize) > tb->w + cu->xof*cu->fsize) {
+ if ((tb->w != 0.0f) && (ct->dobreak==0) && ((xof-(tb->x/cu->fsize)+twidth)*cu->fsize) > tb->w + cu->xof*cu->fsize) {
// fprintf(stderr, "linewidth exceeded: %c%c%c...\n", mem[i], mem[i+1], mem[i+2]);
for (j=i; j && (mem[j] != '\n') && (mem[j] != '\r') && (chartransdata[j].dobreak==0); j--) {
if (mem[j]==' ' || mem[j]=='-') {
@@ -691,7 +694,7 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m
}
}
}
- if(ascii== '\n' || ascii== '\r' || ascii==0 || ct->dobreak) {
+ if (ascii== '\n' || ascii== '\r' || ascii==0 || ct->dobreak) {
ct->xof= xof;
ct->yof= yof;
ct->linenr= lnr;
@@ -716,7 +719,7 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m
/* XXX, has been unused for years, need to check if this is useful, r4613 r5282 - campbell */
#if 0
- if(ascii == '\n' || ascii == '\r')
+ if (ascii == '\n' || ascii == '\r')
xof = cu->xof;
else
xof= cu->xof + (tb->x/cu->fsize);
@@ -727,7 +730,7 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m
cnr= 0;
wsnr= 0;
}
- else if(ascii==9) { /* TAB */
+ else if (ascii==9) { /* TAB */
float tabfac;
ct->xof= xof;
@@ -777,7 +780,7 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m
tmp = mem;
for (i= 0; i<=slen; i++, tmp++, ct++) {
ascii = *tmp;
- if(ascii== '\n' || ascii== '\r' || ct->dobreak) cu->lines++;
+ if (ascii== '\n' || ascii== '\r' || ct->dobreak) cu->lines++;
}
// linedata is now: width of line
@@ -785,25 +788,27 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m
// linedata3 is now: maxlen of that line
// linedata4 is now: number of whitespaces of line
- if(cu->spacemode!=CU_LEFT) {
+ if (cu->spacemode!=CU_LEFT) {
ct= chartransdata;
- if(cu->spacemode==CU_RIGHT) {
- for(i=0;i<lnr;i++) linedata[i]= linedata3[i]-linedata[i];
+ if (cu->spacemode==CU_RIGHT) {
+ for (i=0;i<lnr;i++) linedata[i]= linedata3[i]-linedata[i];
for (i=0; i<=slen; i++) {
ct->xof+= linedata[ct->linenr];
ct++;
}
- } else if(cu->spacemode==CU_MIDDLE) {
- for(i=0;i<lnr;i++) linedata[i]= (linedata3[i]-linedata[i])/2;
+ }
+ else if (cu->spacemode==CU_MIDDLE) {
+ for (i=0;i<lnr;i++) linedata[i]= (linedata3[i]-linedata[i])/2;
for (i=0; i<=slen; i++) {
ct->xof+= linedata[ct->linenr];
ct++;
}
- } else if((cu->spacemode==CU_FLUSH) &&
+ }
+ else if ((cu->spacemode==CU_FLUSH) &&
(cu->tb[0].w != 0.0f)) {
- for(i=0;i<lnr;i++)
- if(linedata2[i]>1)
+ for (i=0;i<lnr;i++)
+ if (linedata2[i]>1)
linedata[i]= (linedata3[i]-linedata[i])/(linedata2[i]-1);
for (i=0; i<=slen; i++) {
for (j=i; (!ELEM3(mem[j], '\0', '\n', '\r')) && (chartransdata[j].dobreak == 0) && (j < slen); j++) {
@@ -816,7 +821,7 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m
ct++;
}
}
- else if((cu->spacemode==CU_JUSTIFY) && (cu->tb[0].w != 0.0f)) {
+ else if ((cu->spacemode==CU_JUSTIFY) && (cu->tb[0].w != 0.0f)) {
float curofs= 0.0f;
for (i=0; i<=slen; i++) {
for (j=i; (mem[j]) && (mem[j]!='\n') &&
@@ -834,14 +839,14 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m
/* TEXT ON CURVE */
/* Note: Only OB_CURVE objects could have a path */
- if(cu->textoncurve && cu->textoncurve->type==OB_CURVE) {
+ if (cu->textoncurve && cu->textoncurve->type==OB_CURVE) {
Curve *cucu= cu->textoncurve->data;
int oldflag= cucu->flag;
cucu->flag |= (CU_PATH+CU_FOLLOW);
- if(cucu->path==NULL) makeDispListCurveTypes(scene, cu->textoncurve, 0);
- if(cucu->path) {
+ if (cucu->path==NULL) makeDispListCurveTypes(scene, cu->textoncurve, 0);
+ if (cucu->path) {
float distfac, imat[4][4], imat3[3][3], cmat[3][3];
float minx, maxx, miny, maxy;
float timeofs, sizefac;
@@ -857,10 +862,10 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m
maxx=maxy= -1.0e20f;
ct= chartransdata;
for (i=0; i<=slen; i++, ct++) {
- if(minx>ct->xof) minx= ct->xof;
- if(maxx<ct->xof) maxx= ct->xof;
- if(miny>ct->yof) miny= ct->yof;
- if(maxy<ct->yof) maxy= ct->yof;
+ if (minx>ct->xof) minx= ct->xof;
+ if (maxx<ct->xof) maxx= ct->xof;
+ if (miny>ct->yof) miny= ct->yof;
+ if (maxy<ct->yof) maxy= ct->yof;
}
/* we put the x-coordinaat exact at the curve, the y is rotated */
@@ -869,17 +874,17 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m
distfac= sizefac*cucu->path->totdist/(maxx-minx);
timeofs= 0.0f;
- if(distfac > 1.0f) {
+ if (distfac > 1.0f) {
/* path longer than text: spacemode involves */
distfac= 1.0f/distfac;
- if(cu->spacemode==CU_RIGHT) {
+ if (cu->spacemode==CU_RIGHT) {
timeofs= 1.0f-distfac;
}
- else if(cu->spacemode==CU_MIDDLE) {
+ else if (cu->spacemode==CU_MIDDLE) {
timeofs= (1.0f-distfac)/2.0f;
}
- else if(cu->spacemode==CU_FLUSH) distfac= 1.0f;
+ else if (cu->spacemode==CU_FLUSH) distfac= 1.0f;
}
else distfac= 1.0;
@@ -937,13 +942,13 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m
}
}
- if(mode==FO_CURSUP || mode==FO_CURSDOWN || mode==FO_PAGEUP || mode==FO_PAGEDOWN) {
+ if (mode==FO_CURSUP || mode==FO_CURSDOWN || mode==FO_PAGEUP || mode==FO_PAGEDOWN) {
/* 2: curs up
* 3: curs down */
ct= chartransdata+cu->pos;
- if((mode==FO_CURSUP || mode==FO_PAGEUP) && ct->linenr==0);
- else if((mode==FO_CURSDOWN || mode==FO_PAGEDOWN) && ct->linenr==lnr);
+ if ((mode==FO_CURSUP || mode==FO_PAGEUP) && ct->linenr==0);
+ else if ((mode==FO_CURSDOWN || mode==FO_PAGEDOWN) && ct->linenr==lnr);
else {
switch(mode) {
case FO_CURSUP: lnr= ct->linenr-1; break;
@@ -956,11 +961,11 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m
cu->pos= 0;
ct= chartransdata;
for (i= 0; i<slen; i++) {
- if(ct->linenr==lnr) {
- if(ct->charnr==cnr) break;
- if( (ct+1)->charnr==0) break;
+ if (ct->linenr==lnr) {
+ if (ct->charnr==cnr) break;
+ if ( (ct+1)->charnr==0) break;
}
- else if(ct->linenr>lnr) break;
+ else if (ct->linenr>lnr) break;
cu->pos++;
ct++;
}
@@ -968,7 +973,7 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m
}
/* cursor first */
- if(cu->editfont) {
+ if (cu->editfont) {
float si, co;
ct= chartransdata+cu->pos;
@@ -1002,7 +1007,7 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m
return NULL;
}
- if(mode == FO_EDIT) {
+ if (mode == FO_EDIT) {
/* make nurbdata */
freeNurblist(&cu->nurb);
@@ -1016,7 +1021,7 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m
info->mat_nr = 0;
}
// We do not want to see any character for \n or \r
- if(cha != '\n' && cha != '\r')
+ if (cha != '\n' && cha != '\r')
buildchar(bmain, cu, cha, info, ct->xof, ct->yof, ct->rot, i);
if ((info->flag & CU_CHINFO_UNDERLINE) && (cu->textoncurve == NULL) && (cha != '\n') && (cha != '\r')) {
@@ -1067,12 +1072,12 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m
}
}
- if(mode==FO_DUPLI) {
+ if (mode==FO_DUPLI) {
MEM_freeN(mem);
return chartransdata;
}
- if(mem)
+ if (mem)
MEM_freeN(mem);
MEM_freeN(chartransdata);
diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c
index 2b8db5d5940..b20a59ed6f8 100644
--- a/source/blender/blenkernel/intern/group.c
+++ b/source/blender/blenkernel/intern/group.c
@@ -66,7 +66,7 @@ void free_group_objects(Group *group)
/* don't free group itself */
GroupObject *go;
- while(group->gobject.first) {
+ while (group->gobject.first) {
go= group->gobject.first;
BLI_remlink(&group->gobject, go);
free_group_object(go);
@@ -82,52 +82,52 @@ void unlink_group(Group *group)
SceneRenderLayer *srl;
ParticleSystem *psys;
- for(ma= bmain->mat.first; ma; ma= ma->id.next) {
- if(ma->group==group)
+ for (ma= bmain->mat.first; ma; ma= ma->id.next) {
+ if (ma->group==group)
ma->group= NULL;
}
- for(ma= bmain->mat.first; ma; ma= ma->id.next) {
- if(ma->group==group)
+ for (ma= bmain->mat.first; ma; ma= ma->id.next) {
+ if (ma->group==group)
ma->group= NULL;
}
for (sce= bmain->scene.first; sce; sce= sce->id.next) {
Base *base= sce->base.first;
/* ensure objects are not in this group */
- for(; base; base= base->next) {
- if(rem_from_group(group, base->object, sce, base) && find_group(base->object, NULL)==NULL) {
+ for (; base; base= base->next) {
+ if (rem_from_group(group, base->object, sce, base) && find_group(base->object, NULL)==NULL) {
base->object->flag &= ~OB_FROMGROUP;
base->flag &= ~OB_FROMGROUP;
}
}
- for(srl= sce->r.layers.first; srl; srl= srl->next) {
+ for (srl= sce->r.layers.first; srl; srl= srl->next) {
if (srl->light_override==group)
srl->light_override= NULL;
}
}
- for(ob= bmain->object.first; ob; ob= ob->id.next) {
+ for (ob= bmain->object.first; ob; ob= ob->id.next) {
- if(ob->dup_group==group) {
+ if (ob->dup_group==group) {
ob->dup_group= NULL;
#if 0 /* XXX OLD ANIMSYS, NLASTRIPS ARE NO LONGER USED */
{
bActionStrip *strip;
/* duplicator strips use a group object, we remove it */
- for(strip= ob->nlastrips.first; strip; strip= strip->next) {
- if(strip->object)
+ for (strip= ob->nlastrips.first; strip; strip= strip->next) {
+ if (strip->object)
strip->object= NULL;
}
}
#endif
}
- for(psys=ob->particlesystem.first; psys; psys=psys->next) {
- if(psys->part->dup_group==group)
+ for (psys=ob->particlesystem.first; psys; psys=psys->next) {
+ if (psys->part->dup_group==group)
psys->part->dup_group= NULL;
#if 0 /* not used anymore, only keps for readfile.c, no need to account for this */
- if(psys->part->eff_group==group)
+ if (psys->part->eff_group==group)
psys->part->eff_group= NULL;
#endif
}
@@ -162,11 +162,11 @@ static int add_to_group_internal(Group *group, Object *ob)
{
GroupObject *go;
- if(group==NULL || ob==NULL) return 0;
+ if (group==NULL || ob==NULL) return 0;
/* check if the object has been added already */
- for(go= group->gobject.first; go; go= go->next) {
- if(go->ob==ob) return 0;
+ for (go= group->gobject.first; go; go= go->next) {
+ if (go->ob==ob) return 0;
}
go= MEM_callocN(sizeof(GroupObject), "groupobject");
@@ -179,15 +179,15 @@ static int add_to_group_internal(Group *group, Object *ob)
int add_to_group(Group *group, Object *object, Scene *scene, Base *base)
{
- if(add_to_group_internal(group, object)) {
- if((object->flag & OB_FROMGROUP)==0) {
+ if (add_to_group_internal(group, object)) {
+ if ((object->flag & OB_FROMGROUP)==0) {
- if(scene && base==NULL)
+ if (scene && base==NULL)
base= object_in_scene(object, scene);
object->flag |= OB_FROMGROUP;
- if(base)
+ if (base)
base->flag |= OB_FROMGROUP;
}
return 1;
@@ -202,12 +202,12 @@ static int rem_from_group_internal(Group *group, Object *ob)
{
GroupObject *go, *gon;
int removed = 0;
- if(group==NULL) return 0;
+ if (group==NULL) return 0;
go= group->gobject.first;
- while(go) {
+ while (go) {
gon= go->next;
- if(go->ob==ob) {
+ if (go->ob==ob) {
BLI_remlink(&group->gobject, go);
free_group_object(go);
removed = 1;
@@ -220,15 +220,15 @@ static int rem_from_group_internal(Group *group, Object *ob)
int rem_from_group(Group *group, Object *object, Scene *scene, Base *base)
{
- if(rem_from_group_internal(group, object)) {
+ if (rem_from_group_internal(group, object)) {
/* object can be NULL */
- if(object && find_group(object, NULL) == NULL) {
- if(scene && base==NULL)
+ if (object && find_group(object, NULL) == NULL) {
+ if (scene && base==NULL)
base= object_in_scene(object, scene);
object->flag &= ~OB_FROMGROUP;
- if(base)
+ if (base)
base->flag &= ~OB_FROMGROUP;
}
return 1;
@@ -242,10 +242,10 @@ int object_in_group(Object *ob, Group *group)
{
GroupObject *go;
- if(group==NULL || ob==NULL) return 0;
+ if (group==NULL || ob==NULL) return 0;
- for(go= group->gobject.first; go; go= go->next) {
- if(go->ob==ob)
+ for (go= group->gobject.first; go; go= go->next) {
+ if (go->ob==ob)
return 1;
}
return 0;
@@ -258,8 +258,8 @@ Group *find_group(Object *ob, Group *group)
else
group= G.main->group.first;
- while(group) {
- if(object_in_group(ob, group))
+ while (group) {
+ if (object_in_group(ob, group))
return group;
group= group->id.next;
}
@@ -270,10 +270,10 @@ void group_tag_recalc(Group *group)
{
GroupObject *go;
- if(group==NULL) return;
+ if (group==NULL) return;
- for(go= group->gobject.first; go; go= go->next) {
- if(go->ob)
+ for (go= group->gobject.first; go; go= go->next) {
+ if (go->ob)
go->ob->recalc= go->recalc;
}
}
@@ -283,12 +283,12 @@ int group_is_animated(Object *UNUSED(parent), Group *group)
GroupObject *go;
#if 0 /* XXX OLD ANIMSYS, NLASTRIPS ARE NO LONGER USED */
- if(parent->nlastrips.first)
+ if (parent->nlastrips.first)
return 1;
#endif
- for(go= group->gobject.first; go; go= go->next)
- if(go->ob && go->ob->proxy)
+ for (go= group->gobject.first; go; go= go->next)
+ if (go->ob && go->ob->proxy)
return 1;
return 0;
@@ -304,11 +304,11 @@ static void group_replaces_nla(Object *parent, Object *target, char mode)
static int done= 0;
bActionStrip *strip, *nstrip;
- if(mode=='s') {
+ if (mode=='s') {
- for(strip= parent->nlastrips.first; strip; strip= strip->next) {
- if(strip->object==target) {
- if(done==0) {
+ for (strip= parent->nlastrips.first; strip; strip= strip->next) {
+ if (strip->object==target) {
+ if (done==0) {
/* clear nla & action from object */
nlastrips= target->nlastrips;
target->nlastrips.first= target->nlastrips.last= NULL;
@@ -322,8 +322,8 @@ static void group_replaces_nla(Object *parent, Object *target, char mode)
}
}
}
- else if(mode=='e') {
- if(done) {
+ else if (mode=='e') {
+ if (done) {
BLI_freelistN(&target->nlastrips);
target->nlastrips= nlastrips;
target->action= action;
@@ -350,15 +350,15 @@ void group_handle_recalc_and_update(Scene *scene, Object *UNUSED(parent), Group
* but when its enabled at some point it will need to be changed so as not to update so much - campbell */
/* if animated group... */
- if(parent->nlastrips.first) {
+ if (parent->nlastrips.first) {
int cfrao;
/* switch to local time */
cfrao= scene->r.cfra;
/* we need a DAG per group... */
- for(go= group->gobject.first; go; go= go->next) {
- if(go->ob && go->recalc) {
+ for (go= group->gobject.first; go; go= go->next) {
+ if (go->ob && go->recalc) {
go->ob->recalc= go->recalc;
group_replaces_nla(parent, go->ob, 's');
@@ -377,9 +377,9 @@ void group_handle_recalc_and_update(Scene *scene, Object *UNUSED(parent), Group
#endif
{
/* only do existing tags, as set by regular depsgraph */
- for(go= group->gobject.first; go; go= go->next) {
- if(go->ob) {
- if(go->ob->recalc) {
+ for (go= group->gobject.first; go; go= go->next) {
+ if (go->ob) {
+ if (go->ob->recalc) {
object_handle_update(scene, go->ob);
}
}
@@ -392,17 +392,17 @@ Object *group_get_member_with_action(Group *group, bAction *act)
{
GroupObject *go;
- if(group==NULL || act==NULL) return NULL;
+ if (group==NULL || act==NULL) return NULL;
- for(go= group->gobject.first; go; go= go->next) {
- if(go->ob) {
- if(go->ob->action==act)
+ for (go= group->gobject.first; go; go= go->next) {
+ if (go->ob) {
+ if (go->ob->action==act)
return go->ob;
- if(go->ob->nlastrips.first) {
+ if (go->ob->nlastrips.first) {
bActionStrip *strip;
- for(strip= go->ob->nlastrips.first; strip; strip= strip->next) {
- if(strip->act==act)
+ for (strip= go->ob->nlastrips.first; strip; strip= strip->next) {
+ if (strip->act==act)
return go->ob;
}
}
@@ -419,18 +419,18 @@ void group_relink_nla_objects(Object *ob)
GroupObject *go;
bActionStrip *strip;
- if(ob==NULL || ob->dup_group==NULL) return;
+ if (ob==NULL || ob->dup_group==NULL) return;
group= ob->dup_group;
- for(strip= ob->nlastrips.first; strip; strip= strip->next) {
- if(strip->object) {
- for(go= group->gobject.first; go; go= go->next) {
- if(go->ob) {
- if(strcmp(go->ob->id.name, strip->object->id.name)==0)
+ for (strip= ob->nlastrips.first; strip; strip= strip->next) {
+ if (strip->object) {
+ for (go= group->gobject.first; go; go= go->next) {
+ if (go->ob) {
+ if (strcmp(go->ob->id.name, strip->object->id.name)==0)
break;
}
}
- if(go)
+ if (go)
strip->object= go->ob;
else
strip->object= NULL;
diff --git a/source/blender/blenkernel/intern/icons.c b/source/blender/blenkernel/intern/icons.c
index f06ac5b7c10..edde21ed7c8 100644
--- a/source/blender/blenkernel/intern/icons.c
+++ b/source/blender/blenkernel/intern/icons.c
@@ -110,7 +110,7 @@ void BKE_icons_init(int first_dyn_id)
void BKE_icons_free(void)
{
- if(gIcons)
+ if (gIcons)
BLI_ghash_free(gIcons, NULL, icon_free);
gIcons = NULL;
}
@@ -147,7 +147,7 @@ void BKE_previewimg_freefunc(void *link)
void BKE_previewimg_free(PreviewImage **prv)
{
- if(prv && (*prv)) {
+ if (prv && (*prv)) {
BKE_previewimg_freefunc(*prv);
*prv = NULL;
}
@@ -163,7 +163,8 @@ struct PreviewImage* BKE_previewimg_copy(PreviewImage *prv)
for (i=0; i < NUM_ICON_SIZES; ++i) {
if (prv->rect[i]) {
prv_img->rect[i] = MEM_dupallocN(prv->rect[i]);
- } else {
+ }
+ else {
prv_img->rect[i] = NULL;
}
}
@@ -176,19 +177,24 @@ void BKE_previewimg_free_id(ID *id)
if (GS(id->name) == ID_MA) {
Material *mat = (Material*)id;
BKE_previewimg_free(&mat->preview);
- } else if (GS(id->name) == ID_TE) {
+ }
+ else if (GS(id->name) == ID_TE) {
Tex *tex = (Tex*)id;
BKE_previewimg_free(&tex->preview);
- } else if (GS(id->name) == ID_WO) {
+ }
+ else if (GS(id->name) == ID_WO) {
World *wo = (World*)id;
BKE_previewimg_free(&wo->preview);
- } else if (GS(id->name) == ID_LA) {
+ }
+ else if (GS(id->name) == ID_LA) {
Lamp *la = (Lamp*)id;
BKE_previewimg_free(&la->preview);
- } else if (GS(id->name) == ID_IM) {
+ }
+ else if (GS(id->name) == ID_IM) {
Image *img = (Image*)id;
BKE_previewimg_free(&img->preview);
- } else if (GS(id->name) == ID_BR) {
+ }
+ else if (GS(id->name) == ID_BR) {
Brush *br = (Brush*)id;
BKE_previewimg_free(&br->preview);
}
@@ -202,23 +208,28 @@ PreviewImage* BKE_previewimg_get(ID *id)
Material *mat = (Material*)id;
if (!mat->preview) mat->preview = BKE_previewimg_create();
prv_img = mat->preview;
- } else if (GS(id->name) == ID_TE) {
+ }
+ else if (GS(id->name) == ID_TE) {
Tex *tex = (Tex*)id;
if (!tex->preview) tex->preview = BKE_previewimg_create();
prv_img = tex->preview;
- } else if (GS(id->name) == ID_WO) {
+ }
+ else if (GS(id->name) == ID_WO) {
World *wo = (World*)id;
if (!wo->preview) wo->preview = BKE_previewimg_create();
prv_img = wo->preview;
- } else if (GS(id->name) == ID_LA) {
+ }
+ else if (GS(id->name) == ID_LA) {
Lamp *la = (Lamp*)id;
if (!la->preview) la->preview = BKE_previewimg_create();
prv_img = la->preview;
- } else if (GS(id->name) == ID_IM) {
+ }
+ else if (GS(id->name) == ID_IM) {
Image *img = (Image*)id;
if (!img->preview) img->preview = BKE_previewimg_create();
prv_img = img->preview;
- } else if (GS(id->name) == ID_BR) {
+ }
+ else if (GS(id->name) == ID_BR) {
Brush *br = (Brush*)id;
if (!br->preview) br->preview = BKE_previewimg_create();
prv_img = br->preview;
diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c
index ee79c2fed35..1fee5cfa359 100644
--- a/source/blender/blenkernel/intern/idprop.c
+++ b/source/blender/blenkernel/intern/idprop.c
@@ -103,7 +103,7 @@ void IDP_FreeIDPArray(IDProperty *prop)
for (i=0; i<prop->len; i++)
IDP_FreeProperty(GETPROP(prop, i));
- if(prop->data.pointer)
+ if (prop->data.pointer)
MEM_freeN(prop->data.pointer);
}
@@ -139,7 +139,7 @@ void IDP_ResizeIDPArray(IDProperty *prop, int newlen)
if (newlen <= prop->totallen && prop->totallen - newlen < 200) {
int i;
- for(i=newlen; i<prop->len; i++)
+ for (i=newlen; i<prop->len; i++)
IDP_FreeProperty(GETPROP(prop, i));
prop->len = newlen;
@@ -170,7 +170,7 @@ void IDP_ResizeIDPArray(IDProperty *prop, int newlen)
memcpy(newarr, prop->data.pointer, newlen*sizeof(IDProperty));
}
- if(prop->data.pointer)
+ if (prop->data.pointer)
MEM_freeN(prop->data.pointer);
prop->data.pointer = newarr;
prop->len = newlen;
@@ -180,16 +180,16 @@ void IDP_ResizeIDPArray(IDProperty *prop, int newlen)
/* ----------- Numerical Array Type ----------- */
static void idp_resize_group_array(IDProperty *prop, int newlen, void *newarr)
{
- if(prop->subtype != IDP_GROUP)
+ if (prop->subtype != IDP_GROUP)
return;
- if(newlen >= prop->len) {
+ if (newlen >= prop->len) {
/* bigger */
IDProperty **array= newarr;
IDPropertyTemplate val;
int a;
- for(a=prop->len; a<newlen; a++) {
+ for (a=prop->len; a<newlen; a++) {
val.i = 0; /* silence MSVC warning about uninitialized var when debugging */
array[a]= IDP_New(IDP_GROUP, &val, "IDP_ResizeArray group");
}
@@ -199,7 +199,7 @@ static void idp_resize_group_array(IDProperty *prop, int newlen, void *newarr)
IDProperty **array= prop->data.pointer;
int a;
- for(a=newlen; a<prop->len; a++) {
+ for (a=newlen; a<prop->len; a++) {
IDP_FreeProperty(array[a]);
MEM_freeN(array[a]);
}
@@ -277,11 +277,11 @@ static IDProperty *IDP_CopyArray(IDProperty *prop)
if (prop->data.pointer) {
newp->data.pointer = MEM_dupallocN(prop->data.pointer);
- if(prop->type == IDP_GROUP) {
+ if (prop->type == IDP_GROUP) {
IDProperty **array= newp->data.pointer;
int a;
- for(a=0; a<prop->len; a++)
+ for (a=0; a<prop->len; a++)
array[a]= IDP_CopyProperty(array[a]);
}
}
@@ -316,7 +316,7 @@ IDProperty *IDP_NewString(const char *st, const char *name, int maxlen)
else {
int stlen = strlen(st);
- if(maxlen > 0 && maxlen < stlen)
+ if (maxlen > 0 && maxlen < stlen)
stlen = maxlen;
stlen++; /* null terminator '\0' */
@@ -349,7 +349,7 @@ void IDP_AssignString(IDProperty *prop, const char *st, int maxlen)
{
int stlen = strlen(st);
- if(maxlen > 0 && maxlen < stlen)
+ if (maxlen > 0 && maxlen < stlen)
stlen= maxlen;
if (prop->subtype == IDP_STRING_SUB_BYTE) {
@@ -387,7 +387,7 @@ void IDP_ConcatString(IDProperty *str1, IDProperty *append)
void IDP_FreeString(IDProperty *prop)
{
- if(prop->data.pointer)
+ if (prop->data.pointer)
MEM_freeN(prop->data.pointer);
}
@@ -619,52 +619,52 @@ IDProperty *IDP_GetProperties(ID *id, int create_if_needed)
int IDP_EqualsProperties(IDProperty *prop1, IDProperty *prop2)
{
- if(prop1 == NULL && prop2 == NULL)
+ if (prop1 == NULL && prop2 == NULL)
return 1;
- else if(prop1 == NULL || prop2 == NULL)
+ else if (prop1 == NULL || prop2 == NULL)
return 0;
- else if(prop1->type != prop2->type)
+ else if (prop1->type != prop2->type)
return 0;
- if(prop1->type == IDP_INT)
+ if (prop1->type == IDP_INT)
return (IDP_Int(prop1) == IDP_Int(prop2));
- else if(prop1->type == IDP_FLOAT)
+ else if (prop1->type == IDP_FLOAT)
return (IDP_Float(prop1) == IDP_Float(prop2));
- else if(prop1->type == IDP_DOUBLE)
+ else if (prop1->type == IDP_DOUBLE)
return (IDP_Double(prop1) == IDP_Double(prop2));
- else if(prop1->type == IDP_STRING)
+ else if (prop1->type == IDP_STRING)
return ((prop1->len == prop2->len) && strncmp(IDP_String(prop1), IDP_String(prop2), prop1->len) == 0);
- else if(prop1->type == IDP_ARRAY) {
- if(prop1->len == prop2->len && prop1->subtype == prop2->subtype)
+ else if (prop1->type == IDP_ARRAY) {
+ if (prop1->len == prop2->len && prop1->subtype == prop2->subtype)
return memcmp(IDP_Array(prop1), IDP_Array(prop2), idp_size_table[(int)prop1->subtype]*prop1->len);
else
return 0;
}
- else if(prop1->type == IDP_GROUP) {
+ else if (prop1->type == IDP_GROUP) {
IDProperty *link1, *link2;
- if(BLI_countlist(&prop1->data.group) != BLI_countlist(&prop2->data.group))
+ if (BLI_countlist(&prop1->data.group) != BLI_countlist(&prop2->data.group))
return 0;
- for(link1=prop1->data.group.first; link1; link1=link1->next) {
+ for (link1=prop1->data.group.first; link1; link1=link1->next) {
link2= IDP_GetPropertyFromGroup(prop2, link1->name);
- if(!IDP_EqualsProperties(link1, link2))
+ if (!IDP_EqualsProperties(link1, link2))
return 0;
}
return 1;
}
- else if(prop1->type == IDP_IDPARRAY) {
+ else if (prop1->type == IDP_IDPARRAY) {
IDProperty *array1= IDP_IDPArray(prop1);
IDProperty *array2= IDP_IDPArray(prop2);
int i;
- if(prop1->len != prop2->len)
+ if (prop1->len != prop2->len)
return 0;
- for(i=0; i<prop1->len; i++)
- if(!IDP_EqualsProperties(&array1[i], &array2[i]))
+ for (i=0; i<prop1->len; i++)
+ if (!IDP_EqualsProperties(&array1[i], &array2[i]))
return 0;
}
@@ -703,7 +703,8 @@ IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *n
prop->data.pointer = MEM_callocN(idp_size_table[val->array.type]*val->array.len, "id property array");
prop->len = prop->totallen = val->array.len;
break;
- } else {
+ }
+ else {
return NULL;
}
}
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 053ebf654f0..b696e10986a 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -160,8 +160,8 @@ static void de_interlace_st(struct ImBuf *ibuf) /* standard fields */
void image_de_interlace(Image *ima, int odd)
{
ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL);
- if(ibuf) {
- if(odd)
+ if (ibuf) {
+ if (odd)
de_interlace_st(ibuf);
else
de_interlace_ng(ibuf);
@@ -174,7 +174,7 @@ static void image_free_buffers(Image *ima)
{
ImBuf *ibuf;
- while((ibuf = ima->ibufs.first)) {
+ while ((ibuf = ima->ibufs.first)) {
BLI_remlink(&ima->ibufs, ibuf);
if (ibuf->userdata) {
@@ -184,10 +184,10 @@ static void image_free_buffers(Image *ima)
IMB_freeImBuf(ibuf);
}
- if(ima->anim) IMB_free_anim(ima->anim);
+ if (ima->anim) IMB_free_anim(ima->anim);
ima->anim= NULL;
- if(ima->rr) {
+ if (ima->rr) {
RE_FreeRenderResult(ima->rr);
ima->rr= NULL;
}
@@ -212,8 +212,8 @@ void free_image(Image *ima)
BKE_previewimg_free(&ima->preview);
- for(a=0; a<IMA_MAX_RENDER_SLOT; a++) {
- if(ima->renders[a]) {
+ for (a=0; a<IMA_MAX_RENDER_SLOT; a++) {
+ if (ima->renders[a]) {
RE_FreeRenderResult(ima->renders[a]);
ima->renders[a]= NULL;
}
@@ -226,7 +226,7 @@ static Image *image_alloc(const char *name, short source, short type)
Image *ima;
ima= alloc_libblock(&G.main->image, ID_IM, name);
- if(ima) {
+ if (ima) {
ima->ok= IMA_OK;
ima->xrep= ima->yrep= 1;
@@ -246,14 +246,14 @@ static ImBuf *image_get_ibuf(Image *ima, int index, int frame)
/* this function is intended to be thread safe. with IMA_NO_INDEX this
* should be OK, but when iterating over the list this is more tricky
* */
- if(index==IMA_NO_INDEX)
+ if (index==IMA_NO_INDEX)
return ima->ibufs.first;
else {
ImBuf *ibuf;
index= IMA_MAKE_INDEX(frame, index);
- for(ibuf= ima->ibufs.first; ibuf; ibuf= ibuf->next)
- if(ibuf->index==index)
+ for (ibuf= ima->ibufs.first; ibuf; ibuf= ibuf->next)
+ if (ibuf->index==index)
return ibuf;
return NULL;
@@ -263,7 +263,7 @@ static ImBuf *image_get_ibuf(Image *ima, int index, int frame)
/* no ima->ibuf anymore, but listbase */
static void image_remove_ibuf(Image *ima, ImBuf *ibuf)
{
- if(ibuf) {
+ if (ibuf) {
BLI_remlink(&ima->ibufs, ibuf);
IMB_freeImBuf(ibuf);
}
@@ -273,19 +273,19 @@ static void image_remove_ibuf(Image *ima, ImBuf *ibuf)
/* no ima->ibuf anymore, but listbase */
static void image_assign_ibuf(Image *ima, ImBuf *ibuf, int index, int frame)
{
- if(ibuf) {
+ if (ibuf) {
ImBuf *link;
- if(index!=IMA_NO_INDEX)
+ if (index!=IMA_NO_INDEX)
index= IMA_MAKE_INDEX(frame, index);
/* insert based on index */
- for(link= ima->ibufs.first; link; link= link->next)
- if(link->index>=index)
+ for (link= ima->ibufs.first; link; link= link->next)
+ if (link->index>=index)
break;
ibuf->index= index;
- if(ima->flag & IMA_CM_PREDIVIDE)
+ if (ima->flag & IMA_CM_PREDIVIDE)
ibuf->flags |= IB_cm_predivide;
else
ibuf->flags &= ~IB_cm_predivide;
@@ -294,7 +294,7 @@ static void image_assign_ibuf(Image *ima, ImBuf *ibuf, int index, int frame)
BLI_insertlinkbefore(&ima->ibufs, link, ibuf);
/* now we don't want copies? */
- if(link && ibuf->index==link->index)
+ if (link && ibuf->index==link->index)
image_remove_ibuf(ima, link);
}
}
@@ -340,42 +340,42 @@ void make_local_image(struct Image *ima)
* - mixed: make copy
*/
- if(ima->id.lib==NULL) return;
+ if (ima->id.lib==NULL) return;
/* Can't take short cut here: must check meshes at least because of bogus
* texface ID refs. - z0r */
#if 0
- if(ima->id.us==1) {
+ if (ima->id.us==1) {
id_clear_lib_data(bmain, &ima->id);
extern_local_image(ima);
return;
}
#endif
- for(tex= bmain->tex.first; tex; tex= tex->id.next) {
- if(tex->ima == ima) {
- if(tex->id.lib) is_lib= TRUE;
+ for (tex= bmain->tex.first; tex; tex= tex->id.next) {
+ if (tex->ima == ima) {
+ if (tex->id.lib) is_lib= TRUE;
else is_local= TRUE;
}
}
- for(brush= bmain->brush.first; brush; brush= brush->id.next) {
- if(brush->clone.image == ima) {
- if(brush->id.lib) is_lib= TRUE;
+ for (brush= bmain->brush.first; brush; brush= brush->id.next) {
+ if (brush->clone.image == ima) {
+ if (brush->id.lib) is_lib= TRUE;
else is_local= TRUE;
}
}
- for(me= bmain->mesh.first; me; me= me->id.next) {
- if(me->mtface) {
+ for (me= bmain->mesh.first; me; me= me->id.next) {
+ if (me->mtface) {
MTFace *tface;
int a, i;
- for(i=0; i<me->fdata.totlayer; i++) {
- if(me->fdata.layers[i].type == CD_MTFACE) {
+ for (i=0; i<me->fdata.totlayer; i++) {
+ if (me->fdata.layers[i].type == CD_MTFACE) {
tface= (MTFace*)me->fdata.layers[i].data;
- for(a=0; a<me->totface; a++, tface++) {
- if(tface->tpage == ima) {
- if(me->id.lib) is_lib= TRUE;
+ for (a=0; a<me->totface; a++, tface++) {
+ if (tface->tpage == ima) {
+ if (me->id.lib) is_lib= TRUE;
else is_local= TRUE;
}
}
@@ -383,17 +383,17 @@ void make_local_image(struct Image *ima)
}
}
- if(me->mtpoly) {
+ if (me->mtpoly) {
MTexPoly *mtpoly;
int a, i;
- for(i=0; i<me->pdata.totlayer; i++) {
- if(me->pdata.layers[i].type == CD_MTEXPOLY) {
+ for (i=0; i<me->pdata.totlayer; i++) {
+ if (me->pdata.layers[i].type == CD_MTEXPOLY) {
mtpoly= (MTexPoly*)me->pdata.layers[i].data;
- for(a=0; a<me->totpoly; a++, mtpoly++) {
- if(mtpoly->tpage == ima) {
- if(me->id.lib) is_lib= TRUE;
+ for (a=0; a<me->totpoly; a++, mtpoly++) {
+ if (mtpoly->tpage == ima) {
+ if (me->id.lib) is_lib= TRUE;
else is_local= TRUE;
}
}
@@ -403,11 +403,11 @@ void make_local_image(struct Image *ima)
}
- if(is_local && is_lib == FALSE) {
+ if (is_local && is_lib == FALSE) {
id_clear_lib_data(bmain, &ima->id);
extern_local_image(ima);
}
- else if(is_local && is_lib) {
+ else if (is_local && is_lib) {
Image *ima_new= copy_image(ima);
ima_new->id.us= 0;
@@ -416,9 +416,9 @@ void make_local_image(struct Image *ima)
BKE_id_lib_local_paths(bmain, ima->id.lib, &ima_new->id);
tex= bmain->tex.first;
- while(tex) {
- if(tex->id.lib==NULL) {
- if(tex->ima==ima) {
+ while (tex) {
+ if (tex->id.lib==NULL) {
+ if (tex->ima==ima) {
tex->ima = ima_new;
ima_new->id.us++;
ima->id.us--;
@@ -427,9 +427,9 @@ void make_local_image(struct Image *ima)
tex= tex->id.next;
}
brush= bmain->brush.first;
- while(brush) {
- if(brush->id.lib==NULL) {
- if(brush->clone.image==ima) {
+ while (brush) {
+ if (brush->id.lib==NULL) {
+ if (brush->clone.image==ima) {
brush->clone.image = ima_new;
ima_new->id.us++;
ima->id.us--;
@@ -441,19 +441,19 @@ void make_local_image(struct Image *ima)
* user count *unless* there are no other users. See
* readfile.c:lib_link_mtface. */
me= bmain->mesh.first;
- while(me) {
- if(me->mtface) {
+ while (me) {
+ if (me->mtface) {
MTFace *tface;
int a, i;
- for(i=0; i<me->fdata.totlayer; i++) {
- if(me->fdata.layers[i].type == CD_MTFACE) {
+ for (i=0; i<me->fdata.totlayer; i++) {
+ if (me->fdata.layers[i].type == CD_MTFACE) {
tface= (MTFace*)me->fdata.layers[i].data;
- for(a=0; a<me->totface; a++, tface++) {
- if(tface->tpage == ima) {
+ for (a=0; a<me->totface; a++, tface++) {
+ if (tface->tpage == ima) {
tface->tpage = ima_new;
- if(ima_new->id.us == 0) {
+ if (ima_new->id.us == 0) {
tface->tpage->id.us= 1;
}
id_lib_extern((ID*)ima_new);
@@ -463,18 +463,18 @@ void make_local_image(struct Image *ima)
}
}
- if(me->mtpoly) {
+ if (me->mtpoly) {
MTexPoly *mtpoly;
int a, i;
- for(i=0; i<me->pdata.totlayer; i++) {
- if(me->pdata.layers[i].type == CD_MTEXPOLY) {
+ for (i=0; i<me->pdata.totlayer; i++) {
+ if (me->pdata.layers[i].type == CD_MTEXPOLY) {
mtpoly= (MTexPoly*)me->pdata.layers[i].data;
- for(a=0; a<me->totpoly; a++, mtpoly++) {
- if(mtpoly->tpage == ima) {
+ for (a=0; a<me->totpoly; a++, mtpoly++) {
+ if (mtpoly->tpage == ima) {
mtpoly->tpage = ima_new;
- if(ima_new->id.us == 0) {
+ if (ima_new->id.us == 0) {
mtpoly->tpage->id.us= 1;
}
id_lib_extern((ID*)ima_new);
@@ -494,9 +494,9 @@ void BKE_image_merge(Image *dest, Image *source)
ImBuf *ibuf;
/* sanity check */
- if(dest && source && dest!=source) {
+ if (dest && source && dest!=source) {
- while((ibuf= source->ibufs.first)) {
+ while ((ibuf= source->ibufs.first)) {
BLI_remlink(&source->ibufs, ibuf);
image_assign_ibuf(dest, ibuf, IMA_INDEX_PASS(ibuf->index), IMA_INDEX_FRAME(ibuf->index));
}
@@ -522,20 +522,20 @@ Image *BKE_add_image_file(const char *name)
/* exists? */
file= BLI_open(str, O_BINARY|O_RDONLY, 0);
- if(file== -1) return NULL;
+ if (file== -1) return NULL;
close(file);
/* first search an identical image */
- for(ima= G.main->image.first; ima; ima= ima->id.next) {
- if(ima->source!=IMA_SRC_VIEWER && ima->source!=IMA_SRC_GENERATED) {
+ for (ima= G.main->image.first; ima; ima= ima->id.next) {
+ if (ima->source!=IMA_SRC_VIEWER && ima->source!=IMA_SRC_GENERATED) {
BLI_strncpy(strtest, ima->name, sizeof(ima->name));
BLI_path_abs(strtest, G.main->name);
if (BLI_path_cmp(strtest, str)==0) {
- if(ima->anim==NULL || ima->id.us==0) {
+ if (ima->anim==NULL || ima->id.us==0) {
BLI_strncpy(ima->name, name, sizeof(ima->name)); /* for stringcode */
ima->id.us++; /* officially should not, it doesn't link here! */
- if(ima->ok==0)
+ if (ima->ok==0)
ima->ok= IMA_OK;
/* RETURN! */
return ima;
@@ -554,7 +554,7 @@ Image *BKE_add_image_file(const char *name)
ima= image_alloc(libname, IMA_SRC_FILE, IMA_TYPE_IMAGE);
BLI_strncpy(ima->name, name, sizeof(ima->name));
- if(BLI_testextensie_array(name, imb_ext_movie))
+ if (BLI_testextensie_array(name, imb_ext_movie))
ima->source= IMA_SRC_MOVIE;
return ima;
@@ -638,7 +638,7 @@ void BKE_image_memorypack(Image *ima)
{
ImBuf *ibuf= image_get_ibuf(ima, IMA_NO_INDEX, 0);
- if(ibuf==NULL)
+ if (ibuf==NULL)
return;
if (ima->packedfile) {
freePackedFile(ima->packedfile);
@@ -649,7 +649,7 @@ void BKE_image_memorypack(Image *ima)
ibuf->planes= R_IMF_PLANES_RGBA;
IMB_saveiff(ibuf, ibuf->name, IB_rect | IB_mem);
- if(ibuf->encodedbuffer==NULL) {
+ if (ibuf->encodedbuffer==NULL) {
printf("memory save for pack error\n");
}
else {
@@ -662,7 +662,7 @@ void BKE_image_memorypack(Image *ima)
ibuf->encodedsize= 0;
ibuf->userflags &= ~IB_BITMAPDIRTY;
- if(ima->source==IMA_SRC_GENERATED) {
+ if (ima->source==IMA_SRC_GENERATED) {
ima->source= IMA_SRC_FILE;
ima->type= IMA_TYPE_IMAGE;
}
@@ -682,8 +682,8 @@ static void tag_all_images_time()
int ctime = (int)PIL_check_seconds_timer();
ima= G.main->image.first;
- while(ima) {
- if(ima->bindcode || ima->repbind || ima->ibufs.first) {
+ while (ima) {
+ if (ima->bindcode || ima->repbind || ima->ibufs.first) {
ima->lastused = ctime;
}
}
@@ -710,11 +710,11 @@ void free_old_images(void)
lasttime = ctime;
ima= G.main->image.first;
- while(ima) {
- if((ima->flag & IMA_NOCOLLECT)==0 && ctime - ima->lastused > U.textimeout) {
+ while (ima) {
+ if ((ima->flag & IMA_NOCOLLECT)==0 && ctime - ima->lastused > U.textimeout) {
/* If it's in GL memory, deallocate and set time tag to current time
* This gives textures a "second chance" to be used before dying. */
- if(ima->bindcode || ima->repbind) {
+ if (ima->bindcode || ima->repbind) {
GPU_free_image(ima);
ima->lastused = ctime;
}
@@ -736,18 +736,18 @@ static uintptr_t image_mem_size(Image *ima)
size= 0;
/* viewers have memory depending on other rules, has no valid rect pointer */
- if(ima->source==IMA_SRC_VIEWER)
+ if (ima->source==IMA_SRC_VIEWER)
return 0;
- for(ibuf= ima->ibufs.first; ibuf; ibuf= ibuf->next) {
- if(ibuf->rect) size += MEM_allocN_len(ibuf->rect);
- else if(ibuf->rect_float) size += MEM_allocN_len(ibuf->rect_float);
+ for (ibuf= ima->ibufs.first; ibuf; ibuf= ibuf->next) {
+ if (ibuf->rect) size += MEM_allocN_len(ibuf->rect);
+ else if (ibuf->rect_float) size += MEM_allocN_len(ibuf->rect_float);
- for(level=0; level<IB_MIPMAP_LEVELS; level++) {
+ for (level=0; level<IB_MIPMAP_LEVELS; level++) {
ibufm= ibuf->mipmap[level];
- if(ibufm) {
- if(ibufm->rect) size += MEM_allocN_len(ibufm->rect);
- else if(ibufm->rect_float) size += MEM_allocN_len(ibufm->rect_float);
+ if (ibufm) {
+ if (ibufm->rect) size += MEM_allocN_len(ibufm->rect);
+ else if (ibufm->rect_float) size += MEM_allocN_len(ibufm->rect_float);
}
}
}
@@ -760,15 +760,15 @@ void BKE_image_print_memlist(void)
Image *ima;
uintptr_t size, totsize= 0;
- for(ima= G.main->image.first; ima; ima= ima->id.next)
+ for (ima= G.main->image.first; ima; ima= ima->id.next)
totsize += image_mem_size(ima);
printf("\ntotal image memory len: %.3f MB\n", (double)totsize/(double)(1024*1024));
- for(ima= G.main->image.first; ima; ima= ima->id.next) {
+ for (ima= G.main->image.first; ima; ima= ima->id.next) {
size= image_mem_size(ima);
- if(size)
+ if (size)
printf("%s len: %.3f MB\n", ima->id.name+2, (double)size/(double)(1024*1024));
}
}
@@ -779,30 +779,30 @@ void BKE_image_free_all_textures(void)
Image *ima;
/* unsigned int totsize= 0; */
- for(ima= G.main->image.first; ima; ima= ima->id.next)
+ for (ima= G.main->image.first; ima; ima= ima->id.next)
ima->id.flag &= ~LIB_DOIT;
- for(tex= G.main->tex.first; tex; tex= tex->id.next)
- if(tex->ima)
+ for (tex= G.main->tex.first; tex; tex= tex->id.next)
+ if (tex->ima)
tex->ima->id.flag |= LIB_DOIT;
- for(ima= G.main->image.first; ima; ima= ima->id.next) {
- if(ima->ibufs.first && (ima->id.flag & LIB_DOIT)) {
+ for (ima= G.main->image.first; ima; ima= ima->id.next) {
+ if (ima->ibufs.first && (ima->id.flag & LIB_DOIT)) {
ImBuf *ibuf;
- for(ibuf= ima->ibufs.first; ibuf; ibuf= ibuf->next) {
+ for (ibuf= ima->ibufs.first; ibuf; ibuf= ibuf->next) {
/* escape when image is painted on */
- if(ibuf->userflags & IB_BITMAPDIRTY)
+ if (ibuf->userflags & IB_BITMAPDIRTY)
break;
#if 0
- if(ibuf->mipmap[0])
+ if (ibuf->mipmap[0])
totsize+= 1.33*ibuf->x*ibuf->y*4;
else
totsize+= ibuf->x*ibuf->y*4;
#endif
}
- if(ibuf==NULL)
+ if (ibuf==NULL)
image_free_buffers(ima);
}
}
@@ -814,13 +814,13 @@ void BKE_image_free_anim_ibufs(Image *ima, int except_frame)
{
ImBuf *ibuf, *nbuf;
- for(ibuf= ima->ibufs.first; ibuf; ibuf= nbuf) {
+ for (ibuf= ima->ibufs.first; ibuf; ibuf= nbuf) {
nbuf= ibuf->next;
- if(ibuf->userflags & IB_BITMAPDIRTY)
+ if (ibuf->userflags & IB_BITMAPDIRTY)
continue;
- if(ibuf->index==IMA_NO_INDEX)
+ if (ibuf->index==IMA_NO_INDEX)
continue;
- if(except_frame!=IMA_INDEX_FRAME(ibuf->index)) {
+ if (except_frame!=IMA_INDEX_FRAME(ibuf->index)) {
BLI_remlink(&ima->ibufs, ibuf);
if (ibuf->userdata) {
@@ -836,8 +836,8 @@ void BKE_image_all_free_anim_ibufs(int cfra)
{
Image *ima;
- for(ima= G.main->image.first; ima; ima= ima->id.next)
- if(ELEM(ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE))
+ for (ima= G.main->image.first; ima; ima= ima->id.next)
+ if (ELEM(ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE))
BKE_image_free_anim_ibufs(ima, cfra);
}
@@ -846,11 +846,11 @@ void BKE_image_all_free_anim_ibufs(int cfra)
int BKE_imtype_to_ftype(const char imtype)
{
- if(imtype==R_IMF_IMTYPE_TARGA)
+ if (imtype==R_IMF_IMTYPE_TARGA)
return TGA;
- else if(imtype==R_IMF_IMTYPE_RAWTGA)
+ else if (imtype==R_IMF_IMTYPE_RAWTGA)
return RAWTGA;
- else if(imtype== R_IMF_IMTYPE_IRIS)
+ else if (imtype== R_IMF_IMTYPE_IRIS)
return IMAGIC;
#ifdef WITH_HDR
else if (imtype==R_IMF_IMTYPE_RADHDR)
@@ -877,7 +877,7 @@ int BKE_imtype_to_ftype(const char imtype)
return DPX;
#endif
#ifdef WITH_OPENJPEG
- else if(imtype==R_IMF_IMTYPE_JP2)
+ else if (imtype==R_IMF_IMTYPE_JP2)
return JP2;
#endif
else
@@ -886,9 +886,9 @@ int BKE_imtype_to_ftype(const char imtype)
char BKE_ftype_to_imtype(const int ftype)
{
- if(ftype==0)
+ if (ftype==0)
return R_IMF_IMTYPE_TARGA;
- else if(ftype == IMAGIC)
+ else if (ftype == IMAGIC)
return R_IMF_IMTYPE_IRIS;
#ifdef WITH_HDR
else if (ftype & RADHDR)
@@ -916,10 +916,10 @@ char BKE_ftype_to_imtype(const int ftype)
#endif
else if (ftype & TGA)
return R_IMF_IMTYPE_TARGA;
- else if(ftype & RAWTGA)
+ else if (ftype & RAWTGA)
return R_IMF_IMTYPE_RAWTGA;
#ifdef WITH_OPENJPEG
- else if(ftype & JP2)
+ else if (ftype & JP2)
return R_IMF_IMTYPE_JP2;
#endif
else
@@ -1076,79 +1076,79 @@ int BKE_add_image_extension(char *string, const char imtype)
{
const char *extension= NULL;
- if(imtype== R_IMF_IMTYPE_IRIS) {
- if(!BLI_testextensie(string, ".rgb"))
+ if (imtype== R_IMF_IMTYPE_IRIS) {
+ if (!BLI_testextensie(string, ".rgb"))
extension= ".rgb";
}
- else if(imtype==R_IMF_IMTYPE_IRIZ) {
- if(!BLI_testextensie(string, ".rgb"))
+ else if (imtype==R_IMF_IMTYPE_IRIZ) {
+ if (!BLI_testextensie(string, ".rgb"))
extension= ".rgb";
}
#ifdef WITH_HDR
- else if(imtype==R_IMF_IMTYPE_RADHDR) {
- if(!BLI_testextensie(string, ".hdr"))
+ else if (imtype==R_IMF_IMTYPE_RADHDR) {
+ if (!BLI_testextensie(string, ".hdr"))
extension= ".hdr";
}
#endif
else if (ELEM5(imtype, R_IMF_IMTYPE_PNG, R_IMF_IMTYPE_FFMPEG, R_IMF_IMTYPE_H264, R_IMF_IMTYPE_THEORA, R_IMF_IMTYPE_XVID)) {
- if(!BLI_testextensie(string, ".png"))
+ if (!BLI_testextensie(string, ".png"))
extension= ".png";
}
#ifdef WITH_DDS
- else if(imtype==R_IMF_IMTYPE_DDS) {
- if(!BLI_testextensie(string, ".dds"))
+ else if (imtype==R_IMF_IMTYPE_DDS) {
+ if (!BLI_testextensie(string, ".dds"))
extension= ".dds";
}
#endif
- else if(imtype==R_IMF_IMTYPE_RAWTGA) {
- if(!BLI_testextensie(string, ".tga"))
+ else if (imtype==R_IMF_IMTYPE_RAWTGA) {
+ if (!BLI_testextensie(string, ".tga"))
extension= ".tga";
}
- else if(imtype==R_IMF_IMTYPE_BMP) {
- if(!BLI_testextensie(string, ".bmp"))
+ else if (imtype==R_IMF_IMTYPE_BMP) {
+ if (!BLI_testextensie(string, ".bmp"))
extension= ".bmp";
}
#ifdef WITH_TIFF
- else if(imtype==R_IMF_IMTYPE_TIFF) {
- if(!BLI_testextensie(string, ".tif") &&
+ else if (imtype==R_IMF_IMTYPE_TIFF) {
+ if (!BLI_testextensie(string, ".tif") &&
!BLI_testextensie(string, ".tiff")) extension= ".tif";
}
#endif
#ifdef WITH_OPENEXR
- else if( ELEM(imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER)) {
- if(!BLI_testextensie(string, ".exr"))
+ else if ( ELEM(imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER)) {
+ if (!BLI_testextensie(string, ".exr"))
extension= ".exr";
}
#endif
#ifdef WITH_CINEON
- else if(imtype==R_IMF_IMTYPE_CINEON) {
+ else if (imtype==R_IMF_IMTYPE_CINEON) {
if (!BLI_testextensie(string, ".cin"))
extension= ".cin";
}
- else if(imtype==R_IMF_IMTYPE_DPX) {
+ else if (imtype==R_IMF_IMTYPE_DPX) {
if (!BLI_testextensie(string, ".dpx"))
extension= ".dpx";
}
#endif
- else if(imtype==R_IMF_IMTYPE_TARGA) {
- if(!BLI_testextensie(string, ".tga"))
+ else if (imtype==R_IMF_IMTYPE_TARGA) {
+ if (!BLI_testextensie(string, ".tga"))
extension= ".tga";
}
#ifdef WITH_OPENJPEG
- else if(imtype==R_IMF_IMTYPE_JP2) {
- if(!BLI_testextensie(string, ".jp2"))
+ else if (imtype==R_IMF_IMTYPE_JP2) {
+ if (!BLI_testextensie(string, ".jp2"))
extension= ".jp2";
}
#endif
else { // R_IMF_IMTYPE_AVICODEC, R_IMF_IMTYPE_AVIRAW, R_IMF_IMTYPE_AVIJPEG, R_IMF_IMTYPE_JPEG90, R_IMF_IMTYPE_QUICKTIME etc
- if(!( BLI_testextensie(string, ".jpg") || BLI_testextensie(string, ".jpeg")))
+ if (!( BLI_testextensie(string, ".jpg") || BLI_testextensie(string, ".jpeg")))
extension= ".jpg";
}
- if(extension) {
+ if (extension) {
/* prefer this in many cases to avoid .png.tga, but in certain cases it breaks */
/* remove any other known image extension */
- if(BLI_testextensie_array(string, imb_ext_image)
+ if (BLI_testextensie_array(string, imb_ext_image)
|| (G.have_quicktime && BLI_testextensie_array(string, imb_ext_image_qt))) {
return BLI_replace_extension(string, FILE_MAX, extension);
}
@@ -1185,14 +1185,16 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d
if (scene->r.stamp & R_STAMP_FILENAME) {
BLI_snprintf(stamp_data->file, sizeof(stamp_data->file), do_prefix ? "File %s":"%s", G.relbase_valid ? G.main->name:"<untitled>");
- } else {
+ }
+ else {
stamp_data->file[0] = '\0';
}
if (scene->r.stamp & R_STAMP_NOTE) {
/* Never do prefix for Note */
BLI_snprintf(stamp_data->note, sizeof(stamp_data->note), "%s", scene->r.stamp_udata);
- } else {
+ }
+ else {
stamp_data->note[0] = '\0';
}
@@ -1201,7 +1203,8 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d
tl = localtime(&t);
BLI_snprintf(text, sizeof(text), "%04d/%02d/%02d %02d:%02d:%02d", tl->tm_year+1900, tl->tm_mon+1, tl->tm_mday, tl->tm_hour, tl->tm_min, tl->tm_sec);
BLI_snprintf(stamp_data->date, sizeof(stamp_data->date), do_prefix ? "Date %s":"%s", text);
- } else {
+ }
+ else {
stamp_data->date[0] = '\0';
}
@@ -1212,7 +1215,8 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d
else BLI_strncpy(text, "<none>", sizeof(text));
BLI_snprintf(stamp_data->marker, sizeof(stamp_data->marker), do_prefix ? "Marker %s":"%s", text);
- } else {
+ }
+ else {
stamp_data->marker[0] = '\0';
}
@@ -1238,7 +1242,8 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d
BLI_snprintf(text, sizeof(text), "%02d:%02d:%02d.%03d", h, m, s, f);
BLI_snprintf(stamp_data->time, sizeof(stamp_data->time), do_prefix ? "Time %s":"%s", text);
- } else {
+ }
+ else {
stamp_data->time[0] = '\0';
}
@@ -1246,18 +1251,20 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d
char fmtstr[32];
int digits= 1;
- if(scene->r.efra>9)
+ if (scene->r.efra>9)
digits= 1 + (int) log10(scene->r.efra);
BLI_snprintf(fmtstr, sizeof(fmtstr), do_prefix ? "Frame %%0%di":"%%0%di", digits);
BLI_snprintf (stamp_data->frame, sizeof(stamp_data->frame), fmtstr, scene->r.cfra);
- } else {
+ }
+ else {
stamp_data->frame[0] = '\0';
}
if (scene->r.stamp & R_STAMP_CAMERA) {
BLI_snprintf(stamp_data->camera, sizeof(stamp_data->camera), do_prefix ? "Camera %s":"%s", camera ? camera->id.name+2 : "<none>");
- } else {
+ }
+ else {
stamp_data->camera[0] = '\0';
}
@@ -1268,13 +1275,15 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d
else BLI_strncpy(text, "<none>", sizeof(text));
BLI_snprintf(stamp_data->cameralens, sizeof(stamp_data->cameralens), do_prefix ? "Lens %s":"%s", text);
- } else {
+ }
+ else {
stamp_data->cameralens[0] = '\0';
}
if (scene->r.stamp & R_STAMP_SCENE) {
BLI_snprintf(stamp_data->scene, sizeof(stamp_data->scene), do_prefix ? "Scene %s":"%s", scene->id.name+2);
- } else {
+ }
+ else {
stamp_data->scene[0] = '\0';
}
@@ -1285,7 +1294,8 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d
else BLI_strncpy(text, "<none>", sizeof(text));
BLI_snprintf(stamp_data->strip, sizeof(stamp_data->strip), do_prefix ? "Strip %s":"%s", text);
- } else {
+ }
+ else {
stamp_data->strip[0] = '\0';
}
@@ -1297,7 +1307,8 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d
BLI_timestr(stats->lastframetime, text);
BLI_snprintf(stamp_data->rendertime, sizeof(stamp_data->rendertime), do_prefix ? "RenderTime %s":"%s", text);
- } else {
+ }
+ else {
stamp_data->rendertime[0] = '\0';
}
}
@@ -1320,7 +1331,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec
stampdata(scene, camera, &stamp_data, 1);
/* TODO, do_versions */
- if(scene->r.stamp_font_id < 8)
+ if (scene->r.stamp_font_id < 8)
scene->r.stamp_font_id= 12;
/* set before return */
@@ -1523,18 +1534,18 @@ void BKE_stamp_info(Scene *scene, Object *camera, struct ImBuf *ibuf)
int BKE_alphatest_ibuf(ImBuf *ibuf)
{
int tot;
- if(ibuf->rect_float) {
+ if (ibuf->rect_float) {
float *buf= ibuf->rect_float;
- for(tot= ibuf->x * ibuf->y; tot--; buf+=4) {
- if(buf[3] < 1.0f) {
+ for (tot= ibuf->x * ibuf->y; tot--; buf+=4) {
+ if (buf[3] < 1.0f) {
return TRUE;
}
}
}
else if (ibuf->rect) {
unsigned char *buf= (unsigned char *)ibuf->rect;
- for(tot= ibuf->x * ibuf->y; tot--; buf+=4) {
- if(buf[3] != 255) {
+ for (tot= ibuf->x * ibuf->y; tot--; buf+=4) {
+ if (buf[3] != 255) {
return TRUE;
}
}
@@ -1553,7 +1564,7 @@ int BKE_write_ibuf(ImBuf *ibuf, const char *name, ImageFormatData *imf)
int ok;
- if(imtype== R_IMF_IMTYPE_IRIS) {
+ if (imtype== R_IMF_IMTYPE_IRIS) {
ibuf->ftype= IMAGIC;
}
#ifdef WITH_HDR
@@ -1564,7 +1575,7 @@ int BKE_write_ibuf(ImBuf *ibuf, const char *name, ImageFormatData *imf)
else if (ELEM5(imtype, R_IMF_IMTYPE_PNG, R_IMF_IMTYPE_FFMPEG, R_IMF_IMTYPE_H264, R_IMF_IMTYPE_THEORA, R_IMF_IMTYPE_XVID)) {
ibuf->ftype= PNG;
- if(imtype==R_IMF_IMTYPE_PNG)
+ if (imtype==R_IMF_IMTYPE_PNG)
ibuf->ftype |= compress;
}
@@ -1580,18 +1591,18 @@ int BKE_write_ibuf(ImBuf *ibuf, const char *name, ImageFormatData *imf)
else if (imtype==R_IMF_IMTYPE_TIFF) {
ibuf->ftype= TIF;
- if(imf->depth == R_IMF_CHAN_DEPTH_16)
+ if (imf->depth == R_IMF_CHAN_DEPTH_16)
ibuf->ftype |= TIF_16BIT;
}
#endif
#ifdef WITH_OPENEXR
else if (imtype==R_IMF_IMTYPE_OPENEXR || imtype==R_IMF_IMTYPE_MULTILAYER) {
ibuf->ftype= OPENEXR;
- if(imf->depth == R_IMF_CHAN_DEPTH_16)
+ if (imf->depth == R_IMF_CHAN_DEPTH_16)
ibuf->ftype |= OPENEXR_HALF;
ibuf->ftype |= (imf->exr_codec & OPENEXR_COMPRESS);
- if(!(imf->flag & R_IMF_FLAG_ZBUF))
+ if (!(imf->flag & R_IMF_FLAG_ZBUF))
ibuf->zbuf_float = NULL; /* signal for exr saving */
}
@@ -1607,17 +1618,18 @@ int BKE_write_ibuf(ImBuf *ibuf, const char *name, ImageFormatData *imf)
else if (imtype==R_IMF_IMTYPE_TARGA) {
ibuf->ftype= TGA;
}
- else if(imtype==R_IMF_IMTYPE_RAWTGA) {
+ else if (imtype==R_IMF_IMTYPE_RAWTGA) {
ibuf->ftype= RAWTGA;
}
#ifdef WITH_OPENJPEG
- else if(imtype==R_IMF_IMTYPE_JP2) {
- if(quality < 10) quality= 90;
+ else if (imtype==R_IMF_IMTYPE_JP2) {
+ if (quality < 10) quality= 90;
ibuf->ftype= JP2|quality;
if (imf->depth == R_IMF_CHAN_DEPTH_16) {
ibuf->ftype |= JP2_16BIT;
- } else if (imf->depth == R_IMF_CHAN_DEPTH_12) {
+ }
+ else if (imf->depth == R_IMF_CHAN_DEPTH_12) {
ibuf->ftype |= JP2_12BIT;
}
@@ -1634,7 +1646,7 @@ int BKE_write_ibuf(ImBuf *ibuf, const char *name, ImageFormatData *imf)
#endif
else {
/* R_IMF_IMTYPE_JPEG90, etc. default we save jpegs */
- if(quality < 10) quality= 90;
+ if (quality < 10) quality= 90;
ibuf->ftype= JPG|quality;
}
@@ -1673,7 +1685,7 @@ int BKE_write_ibuf_as(ImBuf *ibuf, const char *name, ImageFormatData *imf,
int BKE_write_ibuf_stamp(Scene *scene, struct Object *camera, ImBuf *ibuf, const char *name, struct ImageFormatData *imf)
{
- if(scene && scene->r.stamp & R_STAMP_ALL)
+ if (scene && scene->r.stamp & R_STAMP_ALL)
BKE_stamp_info(scene, camera, ibuf);
return BKE_write_ibuf(ibuf, name, imf);
@@ -1686,10 +1698,10 @@ void BKE_makepicstring(char *string, const char *base, const char *relbase, int
BLI_strncpy(string, base, FILE_MAX - 10); /* weak assumption */
BLI_path_abs(string, relbase);
- if(use_frames)
+ if (use_frames)
BLI_path_frame(string, frame, 4);
- if(use_ext)
+ if (use_ext)
BKE_add_image_extension(string, imtype);
}
@@ -1705,7 +1717,7 @@ struct anim *openanim(const char *name, int flags, int streamindex)
ibuf = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE);
if (ibuf == NULL) {
- if(BLI_exists(name))
+ if (BLI_exists(name))
printf("not an anim: %s\n", name);
else
printf("anim file doesn't exist: %s\n", name);
@@ -1744,16 +1756,16 @@ Image *BKE_image_verify_viewer(int type, const char *name)
{
Image *ima;
- for(ima=G.main->image.first; ima; ima= ima->id.next)
- if(ima->source==IMA_SRC_VIEWER)
- if(ima->type==type)
+ for (ima=G.main->image.first; ima; ima= ima->id.next)
+ if (ima->source==IMA_SRC_VIEWER)
+ if (ima->type==type)
break;
- if(ima==NULL)
+ if (ima==NULL)
ima= image_alloc(name, IMA_SRC_VIEWER, type);
/* happens on reload, imagewindow cannot be image user when hidden*/
- if(ima->id.us==0)
+ if (ima->id.us==0)
id_us_plus(&ima->id);
return ima;
@@ -1766,24 +1778,24 @@ void BKE_image_assign_ibuf(Image *ima, ImBuf *ibuf)
void BKE_image_signal(Image *ima, ImageUser *iuser, int signal)
{
- if(ima==NULL)
+ if (ima==NULL)
return;
switch(signal) {
case IMA_SIGNAL_FREE:
image_free_buffers(ima);
- if(iuser)
+ if (iuser)
iuser->ok= 1;
break;
case IMA_SIGNAL_SRC_CHANGE:
- if(ima->type == IMA_TYPE_UV_TEST)
- if(ima->source != IMA_SRC_GENERATED)
+ if (ima->type == IMA_TYPE_UV_TEST)
+ if (ima->source != IMA_SRC_GENERATED)
ima->type= IMA_TYPE_IMAGE;
- if(ima->source==IMA_SRC_GENERATED) {
- if(ima->gen_x==0 || ima->gen_y==0) {
+ if (ima->source==IMA_SRC_GENERATED) {
+ if (ima->gen_x==0 || ima->gen_y==0) {
ImBuf *ibuf= image_get_ibuf(ima, IMA_NO_INDEX, 0);
- if(ibuf) {
+ if (ibuf) {
ima->gen_x= ibuf->x;
ima->gen_y= ibuf->y;
}
@@ -1791,39 +1803,40 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal)
}
/* force reload on first use, but not for multilayer, that makes nodes and buttons in ui drawing fail */
- if(ima->type!=IMA_TYPE_MULTILAYER)
+ if (ima->type!=IMA_TYPE_MULTILAYER)
image_free_buffers(ima);
ima->ok= 1;
- if(iuser)
+ if (iuser)
iuser->ok= 1;
break;
case IMA_SIGNAL_RELOAD:
/* try to repack file */
- if(ima->packedfile) {
+ if (ima->packedfile) {
PackedFile *pf;
pf = newPackedFile(NULL, ima->name, ID_BLEND_PATH(G.main, &ima->id));
if (pf) {
freePackedFile(ima->packedfile);
ima->packedfile = pf;
image_free_buffers(ima);
- } else {
+ }
+ else {
printf("ERROR: Image not available. Keeping packed image\n");
}
}
else
image_free_buffers(ima);
- if(iuser)
+ if (iuser)
iuser->ok= 1;
break;
case IMA_SIGNAL_USER_NEW_IMAGE:
- if(iuser) {
+ if (iuser) {
iuser->ok= 1;
- if(ima->source==IMA_SRC_FILE || ima->source==IMA_SRC_SEQUENCE) {
- if(ima->type==IMA_TYPE_MULTILAYER) {
+ if (ima->source==IMA_SRC_FILE || ima->source==IMA_SRC_SEQUENCE) {
+ if (ima->type==IMA_TYPE_MULTILAYER) {
iuser->multi_index= 0;
iuser->layer= iuser->pass= 0;
}
@@ -1836,8 +1849,8 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal)
* this also makes sure all scenes are accounted for. */
{
Scene *scene;
- for(scene= G.main->scene.first; scene; scene= scene->id.next) {
- if(scene->nodetree) {
+ for (scene= G.main->scene.first; scene; scene= scene->id.next) {
+ if (scene->nodetree) {
nodeUpdateID(scene->nodetree, &ima->id);
}
}
@@ -1852,29 +1865,29 @@ RenderPass *BKE_image_multilayer_index(RenderResult *rr, ImageUser *iuser)
RenderLayer *rl;
RenderPass *rpass= NULL;
- if(rr==NULL)
+ if (rr==NULL)
return NULL;
- if(iuser) {
+ if (iuser) {
short index= 0, rl_index= 0, rp_index;
- for(rl= rr->layers.first; rl; rl= rl->next, rl_index++) {
+ for (rl= rr->layers.first; rl; rl= rl->next, rl_index++) {
rp_index= 0;
- for(rpass= rl->passes.first; rpass; rpass= rpass->next, index++, rp_index++)
- if(iuser->layer==rl_index && iuser->pass==rp_index)
+ for (rpass= rl->passes.first; rpass; rpass= rpass->next, index++, rp_index++)
+ if (iuser->layer==rl_index && iuser->pass==rp_index)
break;
- if(rpass)
+ if (rpass)
break;
}
- if(rpass)
+ if (rpass)
iuser->multi_index= index;
else
iuser->multi_index= 0;
}
- if(rpass==NULL) {
+ if (rpass==NULL) {
rl= rr->layers.first;
- if(rl)
+ if (rl)
rpass= rl->passes.first;
}
@@ -1883,11 +1896,11 @@ RenderPass *BKE_image_multilayer_index(RenderResult *rr, ImageUser *iuser)
RenderResult *BKE_image_acquire_renderresult(Scene *scene, Image *ima)
{
- if(ima->rr) {
+ if (ima->rr) {
return ima->rr;
}
- else if(ima->type==IMA_TYPE_R_RESULT) {
- if(ima->render_slot == ima->last_render_slot)
+ else if (ima->type==IMA_TYPE_R_RESULT) {
+ if (ima->render_slot == ima->last_render_slot)
return RE_AcquireResultRead(RE_GetRender(scene->id.name));
else
return ima->renders[ima->render_slot];
@@ -1898,9 +1911,9 @@ RenderResult *BKE_image_acquire_renderresult(Scene *scene, Image *ima)
void BKE_image_release_renderresult(Scene *scene, Image *ima)
{
- if(ima->rr);
- else if(ima->type==IMA_TYPE_R_RESULT) {
- if(ima->render_slot == ima->last_render_slot)
+ if (ima->rr);
+ else if (ima->type==IMA_TYPE_R_RESULT) {
+ if (ima->render_slot == ima->last_render_slot)
RE_ReleaseResult(RE_GetRender(scene->id.name));
}
}
@@ -1912,8 +1925,8 @@ void BKE_image_backup_render(Scene *scene, Image *ima)
Render *re= RE_GetRender(scene->id.name);
int slot= ima->render_slot, last= ima->last_render_slot;
- if(slot != last) {
- if(ima->renders[slot]) {
+ if (slot != last) {
+ if (ima->renders[slot]) {
RE_FreeRenderResult(ima->renders[slot]);
ima->renders[slot]= NULL;
}
@@ -1937,7 +1950,7 @@ static void image_create_multilayer(Image *ima, ImBuf *ibuf, int framenr)
#endif
ibuf->userdata= NULL;
- if(ima->rr)
+ if (ima->rr)
ima->rr->framenr= framenr;
}
@@ -1945,12 +1958,12 @@ static void image_create_multilayer(Image *ima, ImBuf *ibuf, int framenr)
static void image_initialize_after_load(Image *ima, ImBuf *ibuf)
{
/* preview is NULL when it has never been used as an icon before */
- if(G.background==0 && ima->preview==NULL)
+ if (G.background==0 && ima->preview==NULL)
BKE_icon_changed(BKE_icon_getid(&ima->id));
/* fields */
if (ima->flag & IMA_FIELDS) {
- if(ima->flag & IMA_STD_FIELD) de_interlace_st(ibuf);
+ if (ima->flag & IMA_STD_FIELD) de_interlace_st(ibuf);
else de_interlace_ng(ibuf);
}
/* timer */
@@ -1968,7 +1981,7 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame)
int flag;
/* XXX temp stuff? */
- if(ima->lastframe != frame)
+ if (ima->lastframe != frame)
ima->tpageflag |= IMA_TPAGE_REFRESH;
ima->lastframe= frame;
@@ -1979,16 +1992,17 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame)
BLI_path_abs(name, ID_BLEND_PATH(G.main, &ima->id));
flag= IB_rect|IB_multilayer;
- if(ima->flag & IMA_DO_PREMUL)
+ if (ima->flag & IMA_DO_PREMUL)
flag |= IB_premul;
/* read ibuf */
ibuf = IMB_loadiffname(name, flag);
#if 0
- if(ibuf) {
+ if (ibuf) {
printf(AT" loaded %s\n", name);
- } else {
+ }
+ else {
printf(AT" missed %s\n", name);
}
#endif
@@ -2014,7 +2028,7 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame)
else
ima->ok= 0;
- if(iuser)
+ if (iuser)
iuser->ok= ima->ok;
return ibuf;
@@ -2027,32 +2041,32 @@ static ImBuf *image_load_sequence_multilayer(Image *ima, ImageUser *iuser, int f
/* either we load from RenderResult, or we have to load a new one */
/* check for new RenderResult */
- if(ima->rr==NULL || frame!=ima->rr->framenr) {
+ if (ima->rr==NULL || frame!=ima->rr->framenr) {
/* copy to survive not found multilayer image */
RenderResult *oldrr= ima->rr;
ima->rr= NULL;
ibuf = image_load_sequence_file(ima, iuser, frame);
- if(ibuf) { /* actually an error */
+ if (ibuf) { /* actually an error */
ima->type= IMA_TYPE_IMAGE;
printf("error, multi is normal image\n");
}
// printf("loaded new result %p\n", ima->rr);
/* free result if new one found */
- if(ima->rr) {
+ if (ima->rr) {
// if(oldrr) printf("freed previous result %p\n", oldrr);
- if(oldrr) RE_FreeRenderResult(oldrr);
+ if (oldrr) RE_FreeRenderResult(oldrr);
}
else {
ima->rr= oldrr;
}
}
- if(ima->rr) {
+ if (ima->rr) {
RenderPass *rpass= BKE_image_multilayer_index(ima->rr, iuser);
- if(rpass) {
+ if (rpass) {
// printf("load from pass %s\n", rpass->name);
/* since we free render results, we copy the rect */
ibuf= IMB_allocImBuf(ima->rr->rectx, ima->rr->recty, 32, 0);
@@ -2071,7 +2085,7 @@ static ImBuf *image_load_sequence_multilayer(Image *ima, ImageUser *iuser, int f
else
ima->ok= 0;
- if(iuser)
+ if (iuser)
iuser->ok= ima->ok;
return ibuf;
@@ -2084,7 +2098,7 @@ static ImBuf *image_load_movie_file(Image *ima, ImageUser *iuser, int frame)
ima->lastframe= frame;
- if(ima->anim==NULL) {
+ if (ima->anim==NULL) {
char str[FILE_MAX];
BLI_strncpy(str, ima->name, FILE_MAX);
@@ -2094,24 +2108,24 @@ static ImBuf *image_load_movie_file(Image *ima, ImageUser *iuser, int frame)
ima->anim = openanim(str, IB_rect, 0);
/* let's initialize this user */
- if(ima->anim && iuser && iuser->frames==0)
+ if (ima->anim && iuser && iuser->frames==0)
iuser->frames= IMB_anim_get_duration(ima->anim,
IMB_TC_RECORD_RUN);
}
- if(ima->anim) {
+ if (ima->anim) {
int dur = IMB_anim_get_duration(ima->anim,
IMB_TC_RECORD_RUN);
int fra= frame-1;
- if(fra<0) fra = 0;
- if(fra>(dur-1)) fra= dur-1;
+ if (fra<0) fra = 0;
+ if (fra>(dur-1)) fra= dur-1;
ibuf = IMB_makeSingleUser(
IMB_anim_absolute(ima->anim, fra,
IMB_TC_RECORD_RUN,
IMB_PROXY_NONE));
- if(ibuf) {
+ if (ibuf) {
image_initialize_after_load(ima, ibuf);
image_assign_ibuf(ima, ibuf, 0, frame);
}
@@ -2121,7 +2135,7 @@ static ImBuf *image_load_movie_file(Image *ima, ImageUser *iuser, int frame)
else
ima->ok= 0;
- if(iuser)
+ if (iuser)
iuser->ok= ima->ok;
return ibuf;
@@ -2140,13 +2154,13 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra)
/* is there a PackedFile with this image ? */
if (ima->packedfile) {
flag = IB_rect|IB_multilayer;
- if(ima->flag & IMA_DO_PREMUL) flag |= IB_premul;
+ if (ima->flag & IMA_DO_PREMUL) flag |= IB_premul;
ibuf = IMB_ibImageFromMemory((unsigned char*)ima->packedfile->data, ima->packedfile->size, flag, "<packed data>");
}
else {
flag= IB_rect|IB_multilayer|IB_metadata;
- if(ima->flag & IMA_DO_PREMUL)
+ if (ima->flag & IMA_DO_PREMUL)
flag |= IB_premul;
/* get the right string */
@@ -2180,10 +2194,10 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra)
else
ima->ok= 0;
- if(assign)
+ if (assign)
image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0);
- if(iuser)
+ if (iuser)
iuser->ok= ima->ok;
return ibuf;
@@ -2193,17 +2207,17 @@ static ImBuf *image_get_ibuf_multilayer(Image *ima, ImageUser *iuser)
{
ImBuf *ibuf= NULL;
- if(ima->rr==NULL) {
+ if (ima->rr==NULL) {
ibuf = image_load_image_file(ima, iuser, 0);
- if(ibuf) { /* actually an error */
+ if (ibuf) { /* actually an error */
ima->type= IMA_TYPE_IMAGE;
return ibuf;
}
}
- if(ima->rr) {
+ if (ima->rr) {
RenderPass *rpass= BKE_image_multilayer_index(ima->rr, iuser);
- if(rpass) {
+ if (rpass) {
ibuf= IMB_allocImBuf(ima->rr->rectx, ima->rr->recty, 32, 0);
image_initialize_after_load(ima, ibuf);
@@ -2217,9 +2231,9 @@ static ImBuf *image_get_ibuf_multilayer(Image *ima, ImageUser *iuser)
}
}
- if(ibuf==NULL)
+ if (ibuf==NULL)
ima->ok= 0;
- if(iuser)
+ if (iuser)
iuser->ok= ima->ok;
return ibuf;
@@ -2240,11 +2254,11 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_
ImBuf *ibuf;
int from_render= (ima->render_slot == ima->last_render_slot);
- if(!(iuser && iuser->scene))
+ if (!(iuser && iuser->scene))
return NULL;
/* if we the caller is not going to release the lock, don't give the image */
- if(!lock_r)
+ if (!lock_r)
return NULL;
re= RE_GetRender(iuser->scene->id.name);
@@ -2253,24 +2267,24 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_
layer= (iuser)? iuser->layer: 0;
pass= (iuser)? iuser->pass: 0;
- if(from_render) {
+ if (from_render) {
RE_AcquireResultImage(re, &rres);
}
- else if(ima->renders[ima->render_slot]) {
+ else if (ima->renders[ima->render_slot]) {
rres= *(ima->renders[ima->render_slot]);
rres.have_combined= rres.rectf != NULL;
}
else
memset(&rres, 0, sizeof(RenderResult));
- if(!(rres.rectx > 0 && rres.recty > 0)) {
- if(from_render)
+ if (!(rres.rectx > 0 && rres.recty > 0)) {
+ if (from_render)
RE_ReleaseResultImage(re);
return NULL;
}
/* release is done in BKE_image_release_ibuf using lock_r */
- if(from_render) {
+ if (from_render) {
BLI_lock_thread(LOCK_VIEWER);
*lock_r= re;
}
@@ -2282,27 +2296,27 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_
dither= iuser->scene->r.dither_intensity;
/* combined layer gets added as first layer */
- if(rres.have_combined && layer==0);
- else if(rres.layers.first) {
+ if (rres.have_combined && layer==0);
+ else if (rres.layers.first) {
RenderLayer *rl= BLI_findlink(&rres.layers, layer-(rres.have_combined?1:0));
- if(rl) {
+ if (rl) {
RenderPass *rpass;
/* there's no combined pass, is in renderlayer itself */
- if(pass==0) {
+ if (pass==0) {
rectf= rl->rectf;
}
else {
rpass= BLI_findlink(&rl->passes, pass-1);
- if(rpass) {
+ if (rpass) {
channels= rpass->channels;
rectf= rpass->rect;
dither= 0.0f; /* don't dither passes */
}
}
- for(rpass= rl->passes.first; rpass; rpass= rpass->next)
- if(rpass->passtype == SCE_PASS_Z)
+ for (rpass= rl->passes.first; rpass; rpass= rpass->next)
+ if (rpass->passtype == SCE_PASS_Z)
rectz= rpass->rect;
}
}
@@ -2310,7 +2324,7 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_
ibuf= image_get_ibuf(ima, IMA_NO_INDEX, 0);
/* make ibuf if needed, and initialize it */
- if(ibuf==NULL) {
+ if (ibuf==NULL) {
ibuf= IMB_allocImBuf(rres.rectx, rres.recty, 32, 0);
image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0);
}
@@ -2321,13 +2335,13 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_
/* free rect buffer if float buffer changes, so it can be recreated with
* the updated result, and also in case we got byte buffer from sequencer,
* so we don't keep reference to freed buffer */
- if(ibuf->rect_float!=rectf || rect || !rectf)
+ if (ibuf->rect_float!=rectf || rect || !rectf)
imb_freerectImBuf(ibuf);
- if(rect)
+ if (rect)
ibuf->rect= rect;
- if(rectf) {
+ if (rectf) {
ibuf->rect_float= rectf;
ibuf->flags |= IB_rectfloat;
ibuf->channels= channels;
@@ -2337,7 +2351,7 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_
ibuf->flags &= ~IB_rectfloat;
}
- if(rectz) {
+ if (rectz) {
ibuf->zbuf_float= rectz;
ibuf->flags |= IB_zbuffloat;
}
@@ -2350,7 +2364,7 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_
ibuf->profile= (iuser->scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) ? IB_PROFILE_LINEAR_RGB : IB_PROFILE_NONE;
ibuf->dither= dither;
- if(iuser->scene->r.color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE) {
+ if (iuser->scene->r.color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE) {
ibuf->flags |= IB_cm_predivide;
ima->flag |= IMA_CM_PREDIVIDE;
}
@@ -2370,41 +2384,41 @@ static ImBuf *image_get_ibuf_threadsafe(Image *ima, ImageUser *iuser, int *frame
int frame = 0, index = 0;
/* see if we already have an appropriate ibuf, with image source and type */
- if(ima->source==IMA_SRC_MOVIE) {
+ if (ima->source==IMA_SRC_MOVIE) {
frame= iuser?iuser->framenr:ima->lastframe;
ibuf= image_get_ibuf(ima, 0, frame);
/* XXX temp stuff? */
- if(ima->lastframe != frame)
+ if (ima->lastframe != frame)
ima->tpageflag |= IMA_TPAGE_REFRESH;
ima->lastframe = frame;
}
- else if(ima->source==IMA_SRC_SEQUENCE) {
- if(ima->type==IMA_TYPE_IMAGE) {
+ else if (ima->source==IMA_SRC_SEQUENCE) {
+ if (ima->type==IMA_TYPE_IMAGE) {
frame= iuser?iuser->framenr:ima->lastframe;
ibuf= image_get_ibuf(ima, 0, frame);
/* XXX temp stuff? */
- if(ima->lastframe != frame) {
+ if (ima->lastframe != frame) {
ima->tpageflag |= IMA_TPAGE_REFRESH;
}
ima->lastframe = frame;
}
- else if(ima->type==IMA_TYPE_MULTILAYER) {
+ else if (ima->type==IMA_TYPE_MULTILAYER) {
frame= iuser?iuser->framenr:ima->lastframe;
index= iuser?iuser->multi_index:IMA_NO_INDEX;
ibuf= image_get_ibuf(ima, index, frame);
}
}
- else if(ima->source==IMA_SRC_FILE) {
- if(ima->type==IMA_TYPE_IMAGE)
+ else if (ima->source==IMA_SRC_FILE) {
+ if (ima->type==IMA_TYPE_IMAGE)
ibuf= image_get_ibuf(ima, IMA_NO_INDEX, 0);
- else if(ima->type==IMA_TYPE_MULTILAYER)
+ else if (ima->type==IMA_TYPE_MULTILAYER)
ibuf= image_get_ibuf(ima, iuser?iuser->multi_index:IMA_NO_INDEX, 0);
}
- else if(ima->source == IMA_SRC_GENERATED) {
+ else if (ima->source == IMA_SRC_GENERATED) {
ibuf= image_get_ibuf(ima, IMA_NO_INDEX, 0);
}
- else if(ima->source == IMA_SRC_VIEWER) {
+ else if (ima->source == IMA_SRC_VIEWER) {
/* always verify entirely, not that this shouldn't happen
* as part of texture sampling in rendering anyway, so not
* a big bottleneck */
@@ -2436,87 +2450,87 @@ ImBuf *BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r)
* That means, the last two steps must be, 1) add the ibuf to the list and
* 2) set ima/iuser->ok to 0 to IMA_OK_LOADED */
- if(lock_r)
+ if (lock_r)
*lock_r= NULL;
/* quick reject tests */
- if(ima==NULL)
+ if (ima==NULL)
return NULL;
- if(iuser) {
- if(iuser->ok==0)
+ if (iuser) {
+ if (iuser->ok==0)
return NULL;
}
- else if(ima->ok==0)
+ else if (ima->ok==0)
return NULL;
/* try to get the ibuf without locking */
ibuf= image_get_ibuf_threadsafe(ima, iuser, &frame, &index);
- if(ibuf == NULL) {
+ if (ibuf == NULL) {
/* couldn't get ibuf and image is not ok, so let's lock and try to
* load the image */
BLI_lock_thread(LOCK_IMAGE);
/* need to check ok flag and loading ibuf again, because the situation
* might have changed in the meantime */
- if(iuser) {
- if(iuser->ok==0) {
+ if (iuser) {
+ if (iuser->ok==0) {
BLI_unlock_thread(LOCK_IMAGE);
return NULL;
}
}
- else if(ima->ok==0) {
+ else if (ima->ok==0) {
BLI_unlock_thread(LOCK_IMAGE);
return NULL;
}
ibuf= image_get_ibuf_threadsafe(ima, iuser, &frame, &index);
- if(ibuf == NULL) {
+ if (ibuf == NULL) {
/* we are sure we have to load the ibuf, using source and type */
- if(ima->source==IMA_SRC_MOVIE) {
+ if (ima->source==IMA_SRC_MOVIE) {
/* source is from single file, use flipbook to store ibuf */
ibuf= image_load_movie_file(ima, iuser, frame);
}
- else if(ima->source==IMA_SRC_SEQUENCE) {
- if(ima->type==IMA_TYPE_IMAGE) {
+ else if (ima->source==IMA_SRC_SEQUENCE) {
+ if (ima->type==IMA_TYPE_IMAGE) {
/* regular files, ibufs in flipbook, allows saving */
ibuf= image_load_sequence_file(ima, iuser, frame);
}
/* no else; on load the ima type can change */
- if(ima->type==IMA_TYPE_MULTILAYER) {
+ if (ima->type==IMA_TYPE_MULTILAYER) {
/* only 1 layer/pass stored in imbufs, no exrhandle anim storage, no saving */
ibuf= image_load_sequence_multilayer(ima, iuser, frame);
}
}
- else if(ima->source==IMA_SRC_FILE) {
+ else if (ima->source==IMA_SRC_FILE) {
- if(ima->type==IMA_TYPE_IMAGE)
+ if (ima->type==IMA_TYPE_IMAGE)
ibuf= image_load_image_file(ima, iuser, frame); /* cfra only for '#', this global is OK */
/* no else; on load the ima type can change */
- if(ima->type==IMA_TYPE_MULTILAYER)
+ if (ima->type==IMA_TYPE_MULTILAYER)
/* keeps render result, stores ibufs in listbase, allows saving */
ibuf= image_get_ibuf_multilayer(ima, iuser);
}
- else if(ima->source == IMA_SRC_GENERATED) {
+ else if (ima->source == IMA_SRC_GENERATED) {
/* generated is: ibuf is allocated dynamically */
/* UV testgrid or black or solid etc */
- if(ima->gen_x==0) ima->gen_x= 1024;
- if(ima->gen_y==0) ima->gen_y= 1024;
+ if (ima->gen_x==0) ima->gen_x= 1024;
+ if (ima->gen_y==0) ima->gen_y= 1024;
ibuf= add_ibuf_size(ima->gen_x, ima->gen_y, ima->name, 24, (ima->gen_flag & IMA_GEN_FLOAT) != 0, ima->gen_type, color);
image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0);
ima->ok= IMA_OK_LOADED;
}
- else if(ima->source == IMA_SRC_VIEWER) {
- if(ima->type==IMA_TYPE_R_RESULT) {
+ else if (ima->source == IMA_SRC_VIEWER) {
+ if (ima->type==IMA_TYPE_R_RESULT) {
/* always verify entirely, and potentially
* returns pointer to release later */
ibuf= image_get_render_result(ima, iuser, lock_r);
}
- else if(ima->type==IMA_TYPE_COMPOSITE) {
+ else if (ima->type==IMA_TYPE_COMPOSITE) {
/* requires lock/unlock, otherwise don't return image */
- if(lock_r) {
+ if (lock_r) {
/* unlock in BKE_image_release_ibuf */
BLI_lock_thread(LOCK_VIEWER);
*lock_r= ima;
@@ -2525,7 +2539,7 @@ ImBuf *BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r)
frame= 0; // XXX iuser?iuser->framenr:0;
ibuf= image_get_ibuf(ima, 0, frame);
- if(!ibuf) {
+ if (!ibuf) {
/* Composite Viewer, all handled in compositor */
/* fake ibuf, will be filled in compositor */
ibuf= IMB_allocImBuf(256, 256, 32, IB_rect);
@@ -2547,10 +2561,10 @@ ImBuf *BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r)
void BKE_image_release_ibuf(Image *ima, void *lock)
{
/* for getting image during threaded render / compositing, need to release */
- if(lock == ima) {
+ if (lock == ima) {
BLI_unlock_thread(LOCK_VIEWER); /* viewer image */
}
- else if(lock) {
+ else if (lock) {
RE_ReleaseResultImage(lock); /* render result */
BLI_unlock_thread(LOCK_VIEWER); /* view image imbuf */
}
@@ -2567,7 +2581,7 @@ int BKE_image_user_get_frame(const ImageUser *iuser, int cfra, int fieldnr)
{
const int len= (iuser->fie_ima*iuser->frames)/2;
- if(len==0) {
+ if (len==0) {
return 0;
}
else {
@@ -2575,28 +2589,28 @@ int BKE_image_user_get_frame(const ImageUser *iuser, int cfra, int fieldnr)
cfra= cfra - iuser->sfra+1;
/* cyclic */
- if(iuser->cycl) {
+ if (iuser->cycl) {
cfra= ( (cfra) % len );
- if(cfra < 0) cfra+= len;
- if(cfra==0) cfra= len;
+ if (cfra < 0) cfra+= len;
+ if (cfra==0) cfra= len;
}
- if(cfra<0) cfra= 0;
- else if(cfra>len) cfra= len;
+ if (cfra<0) cfra= 0;
+ else if (cfra>len) cfra= len;
/* convert current frame to current field */
cfra= 2*(cfra);
- if(fieldnr) cfra++;
+ if (fieldnr) cfra++;
/* transform to images space */
framenr= (cfra+iuser->fie_ima-2)/iuser->fie_ima;
- if(framenr>iuser->frames) framenr= iuser->frames;
+ if (framenr>iuser->frames) framenr= iuser->frames;
framenr+= iuser->offset;
- if(iuser->cycl) {
+ if (iuser->cycl) {
framenr= ( (framenr) % len );
- while(framenr < 0) framenr+= len;
- if(framenr==0) framenr= len;
+ while (framenr < 0) framenr+= len;
+ if (framenr==0) framenr= len;
}
return framenr;
@@ -2608,12 +2622,12 @@ void BKE_image_user_calc_frame(ImageUser *iuser, int cfra, int fieldnr)
const int framenr= BKE_image_user_get_frame(iuser, cfra, fieldnr);
/* allows image users to handle redraws */
- if(iuser->flag & IMA_ANIM_ALWAYS)
- if(framenr!=iuser->framenr)
+ if (iuser->flag & IMA_ANIM_ALWAYS)
+ if (framenr!=iuser->framenr)
iuser->flag |= IMA_ANIM_REFRESHED;
iuser->framenr= framenr;
- if(iuser->ok==0) iuser->ok= 1;
+ if (iuser->ok==0) iuser->ok= 1;
}
int BKE_image_has_alpha(struct Image *image)
diff --git a/source/blender/blenkernel/intern/image_gen.c b/source/blender/blenkernel/intern/image_gen.c
index d4185af2f98..675c0771140 100644
--- a/source/blender/blenkernel/intern/image_gen.c
+++ b/source/blender/blenkernel/intern/image_gen.c
@@ -38,22 +38,22 @@ void BKE_image_buf_fill_color(unsigned char *rect, float *rect_float, int width,
int x, y;
/* blank image */
- if(rect_float) {
- for(y= 0; y<height; y++) {
- for(x= 0; x<width; x++) {
+ if (rect_float) {
+ for (y= 0; y<height; y++) {
+ for (x= 0; x<width; x++) {
copy_v4_v4(rect_float, color);
rect_float+= 4;
}
}
}
- if(rect) {
+ if (rect) {
unsigned char ccol[4];
rgba_float_to_uchar(ccol, color);
- for(y= 0; y<height; y++) {
- for(x= 0; x<width; x++) {
+ for (y= 0; y<height; y++) {
+ for (x= 0; x<width; x++) {
rect[0]= ccol[0];
rect[1]= ccol[1];
@@ -81,17 +81,18 @@ void BKE_image_buf_fill_checker(unsigned char *rect, float *rect_float, int widt
float h=0.0, hoffs=0.0, hue=0.0, s=0.9, v=0.9, r, g, b;
/* checkers */
- for(y= 0; y<height; y++) {
+ for (y= 0; y<height; y++) {
dark= powf(-1.0f, floorf(y / checkerwidth));
- for(x= 0; x<width; x++) {
+ for (x= 0; x<width; x++) {
if (x % checkerwidth == 0) dark= -dark;
if (rect_float) {
if (dark > 0) {
rect_float[0]= rect_float[1]= rect_float[2]= 0.25f;
rect_float[3]= 1.0f;
- } else {
+ }
+ else {
rect_float[0]= rect_float[1]= rect_float[2]= 0.58f;
rect_float[3]= 1.0f;
}
@@ -101,7 +102,8 @@ void BKE_image_buf_fill_checker(unsigned char *rect, float *rect_float, int widt
if (dark > 0) {
rect[0]= rect[1]= rect[2]= 64;
rect[3]= 255;
- } else {
+ }
+ else {
rect[0]= rect[1]= rect[2]= 150;
rect[3]= 255;
}
@@ -114,10 +116,10 @@ void BKE_image_buf_fill_checker(unsigned char *rect, float *rect_float, int widt
rect_float= rect_float_orig;
/* 2nd pass, colored + */
- for(y= 0; y<height; y++) {
+ for (y= 0; y<height; y++) {
hoffs= 0.125f * floorf(y / checkerwidth);
- for(x= 0; x<width; x++) {
+ for (x= 0; x<width; x++) {
h= 0.125f * floorf(x / checkerwidth);
if ((fabs((x % checkerwidth) - (checkerwidth / 2)) < 4) &&
@@ -165,13 +167,13 @@ static void checker_board_color_fill(unsigned char *rect, float *rect_float, int
sat= 1.0;
hue_step= power_of_2_max_i(width / 8);
- if(hue_step < 8) hue_step= 8;
+ if (hue_step < 8) hue_step= 8;
- for(y= 0; y < height; y++)
+ for (y= 0; y < height; y++)
{
val= 0.1 + (y * (0.4 / height)); /* use a number lower then 1.0 else its too bright */
- for(x= 0; x < width; x++)
+ for (x= 0; x < width; x++)
{
hue= (float)((double)(x/hue_step) * 1.0 / width * hue_step);
hsv_to_rgb(hue, sat, val, &r, &g, &b);
@@ -248,8 +250,8 @@ static void checker_board_color_tint(unsigned char *rect, float *rect_float, int
static void checker_board_grid_fill(unsigned char *rect, float *rect_float, int width, int height, float blend)
{
int x, y;
- for(y= 0; y < height; y++) {
- for(x= 0; x < width; x++) {
+ for (y= 0; y < height; y++) {
+ for (x= 0; x < width; x++) {
if (((y % 32) == 0) || ((x % 32) == 0) || x == 0) {
if (rect) {
rect[0]= BLEND_CHAR(rect[0], blend);
@@ -269,8 +271,8 @@ static void checker_board_grid_fill(unsigned char *rect, float *rect_float, int
}
}
else {
- if(rect_float) rect_float += 4;
- if(rect) rect += 4;
+ if (rect_float) rect_float += 4;
+ if (rect) rect += 4;
}
}
}
@@ -289,11 +291,11 @@ static void checker_board_text(unsigned char *rect, float *rect_float, int width
BLF_buffer(mono, rect_float, rect, width, height, 4);
- for(y= 0; y < height; y+=step)
+ for (y= 0; y < height; y+=step)
{
text[1]= '1';
- for(x= 0; x < width; x+=step)
+ for (x= 0; x < width; x+=step)
{
/* hard coded offset */
pen_x = x + 33;
diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c
index a271513afc0..2787674036b 100644
--- a/source/blender/blenkernel/intern/implicit.c
+++ b/source/blender/blenkernel/intern/implicit.c
@@ -57,7 +57,7 @@ static LARGE_INTEGER ifreq;
static void itstart(void)
{
static int first = 1;
- if(first) {
+ if (first) {
QueryPerformanceFrequency(&ifreq);
first = 0;
}
@@ -178,7 +178,7 @@ static void print_fvector(float m3[3])
DO_INLINE void print_lfvector(float (*fLongVector)[3], unsigned int verts)
{
unsigned int i = 0;
- for(i = 0; i < verts; i++)
+ for (i = 0; i < verts; i++)
{
print_fvector(fLongVector[i]);
}
@@ -208,7 +208,7 @@ DO_INLINE void cp_lfvector(float (*to)[3], float (*from)[3], unsigned int verts)
DO_INLINE void init_lfvector(float (*fLongVector)[3], float vector[3], unsigned int verts)
{
unsigned int i = 0;
- for(i = 0; i < verts; i++)
+ for (i = 0; i < verts; i++)
{
copy_v3_v3(fLongVector[i], vector);
}
@@ -223,7 +223,7 @@ DO_INLINE void mul_lfvectorS(float (*to)[3], float (*fLongVector)[3], float scal
{
unsigned int i = 0;
- for(i = 0; i < verts; i++)
+ for (i = 0; i < verts; i++)
{
mul_fvector_S(to[i], fLongVector[i], scalar);
}
@@ -233,7 +233,7 @@ DO_INLINE void mul_lfvectorS(float (*to)[3], float (*fLongVector)[3], float scal
DO_INLINE void submul_lfvectorS(float (*to)[3], float (*fLongVector)[3], float scalar, unsigned int verts)
{
unsigned int i = 0;
- for(i = 0; i < verts; i++)
+ for (i = 0; i < verts; i++)
{
VECSUBMUL(to[i], fLongVector[i], scalar);
}
@@ -248,7 +248,7 @@ DO_INLINE float dot_lfvector(float (*fLongVectorA)[3], float (*fLongVectorB)[3],
// different results each time you run it!
// schedule(guided, 2)
//#pragma omp parallel for reduction(+: temp) if(verts > CLOTH_OPENMP_LIMIT)
- for(i = 0; i < (long)verts; i++) {
+ for (i = 0; i < (long)verts; i++) {
temp += dot_v3v3(fLongVectorA[i], fLongVectorB[i]);
}
return temp;
@@ -258,7 +258,7 @@ DO_INLINE void add_lfvector_lfvector(float (*to)[3], float (*fLongVectorA)[3], f
{
unsigned int i = 0;
- for(i = 0; i < verts; i++)
+ for (i = 0; i < verts; i++)
{
VECADD(to[i], fLongVectorA[i], fLongVectorB[i]);
}
@@ -269,7 +269,7 @@ DO_INLINE void add_lfvector_lfvectorS(float (*to)[3], float (*fLongVectorA)[3],
{
unsigned int i = 0;
- for(i = 0; i < verts; i++)
+ for (i = 0; i < verts; i++)
{
VECADDS(to[i], fLongVectorA[i], fLongVectorB[i], bS);
@@ -280,7 +280,7 @@ DO_INLINE void add_lfvectorS_lfvectorS(float (*to)[3], float (*fLongVectorA)[3],
{
unsigned int i = 0;
- for(i = 0; i < verts; i++)
+ for (i = 0; i < verts; i++)
{
VECADDSS(to[i], fLongVectorA[i], aS, fLongVectorB[i], bS);
}
@@ -289,7 +289,7 @@ DO_INLINE void add_lfvectorS_lfvectorS(float (*to)[3], float (*fLongVectorA)[3],
DO_INLINE void sub_lfvector_lfvectorS(float (*to)[3], float (*fLongVectorA)[3], float (*fLongVectorB)[3], float bS, unsigned int verts)
{
unsigned int i = 0;
- for(i = 0; i < verts; i++)
+ for (i = 0; i < verts; i++)
{
VECSUBS(to[i], fLongVectorA[i], fLongVectorB[i], bS);
}
@@ -300,7 +300,7 @@ DO_INLINE void sub_lfvector_lfvector(float (*to)[3], float (*fLongVectorA)[3], f
{
unsigned int i = 0;
- for(i = 0; i < verts; i++)
+ for (i = 0; i < verts; i++)
{
sub_v3_v3v3(to[i], fLongVectorA[i], fLongVectorB[i]);
}
@@ -350,14 +350,14 @@ DO_INLINE void inverse_fmatrix(float to[3][3], float from[3][3])
unsigned int i, j;
float d;
- if((d=det_fmatrix(from))==0)
+ if ((d=det_fmatrix(from))==0)
{
printf("can't build inverse");
exit(0);
}
- for(i=0;i<3;i++)
+ for (i=0;i<3;i++)
{
- for(j=0;j<3;j++)
+ for (j=0;j<3;j++)
{
int i1=(i+1)%3;
int i2=(i+2)%3;
@@ -366,7 +366,7 @@ DO_INLINE void inverse_fmatrix(float to[3][3], float from[3][3])
// reverse indexs i&j to take transpose
to[j][i] = (from[i1][j1]*from[i2][j2]-from[i1][j2]*from[i2][j1])/d;
/*
- if(i==j)
+ if (i==j)
to[i][j] = 1.0f / from[i][j];
else
to[i][j] = 0;
@@ -516,7 +516,7 @@ static void print_bfmatrix(fmatrix3x3 *m3)
{
unsigned int i = 0;
- for(i = 0; i < m3[0].vcount + m3[0].scount; i++)
+ for (i = 0; i < m3[0].vcount + m3[0].scount; i++)
{
print_fmatrix(m3[i].m);
}
@@ -554,7 +554,7 @@ DO_INLINE void init_bfmatrix(fmatrix3x3 *matrix, float m3[3][3])
{
unsigned int i;
- for(i = 0; i < matrix[0].vcount+matrix[0].scount; i++)
+ for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++)
{
cp_fmatrix(matrix[i].m, m3);
}
@@ -567,11 +567,11 @@ DO_INLINE void initdiag_bfmatrix(fmatrix3x3 *matrix, float m3[3][3])
unsigned int i,j;
float tmatrix[3][3] = {{0,0,0},{0,0,0},{0,0,0}};
- for(i = 0; i < matrix[0].vcount; i++)
+ for (i = 0; i < matrix[0].vcount; i++)
{
cp_fmatrix(matrix[i].m, m3);
}
- for(j = matrix[0].vcount; j < matrix[0].vcount+matrix[0].scount; j++)
+ for (j = matrix[0].vcount; j < matrix[0].vcount+matrix[0].scount; j++)
{
cp_fmatrix(matrix[j].m, tmatrix);
}
@@ -581,7 +581,7 @@ DO_INLINE void initdiag_bfmatrix(fmatrix3x3 *matrix, float m3[3][3])
DO_INLINE void mul_bfmatrix_S(fmatrix3x3 *matrix, float scalar)
{
unsigned int i = 0;
- for(i = 0; i < matrix[0].vcount+matrix[0].scount; i++)
+ for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++)
{
mul_fmatrix_S(matrix[i].m, scalar);
}
@@ -601,14 +601,14 @@ DO_INLINE void mul_bfmatrix_lfvector( float (*to)[3], fmatrix3x3 *from, lfVector
{
#pragma omp section
{
- for(i = from[0].vcount; i < from[0].vcount+from[0].scount; i++)
+ for (i = from[0].vcount; i < from[0].vcount+from[0].scount; i++)
{
muladd_fmatrix_fvector(to[from[i].c], from[i].m, fLongVector[from[i].r]);
}
}
#pragma omp section
{
- for(i = 0; i < from[0].vcount+from[0].scount; i++)
+ for (i = 0; i < from[0].vcount+from[0].scount; i++)
{
muladd_fmatrix_fvector(temp[from[i].r], from[i].m, fLongVector[from[i].c]);
}
@@ -627,7 +627,7 @@ DO_INLINE void mul_prevfmatrix_lfvector( float (*to)[3], fmatrix3x3 *from, lfVec
{
unsigned int i = 0;
- for(i = 0; i < from[0].vcount; i++)
+ for (i = 0; i < from[0].vcount; i++)
{
mul_fmatrix_fvector(to[from[i].r], from[i].m, fLongVector[from[i].c]);
}
@@ -639,7 +639,7 @@ DO_INLINE void add_bfmatrix_bfmatrix( fmatrix3x3 *to, fmatrix3x3 *from, fmatrix
unsigned int i = 0;
/* process diagonal elements */
- for(i = 0; i < matrix[0].vcount+matrix[0].scount; i++)
+ for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++)
{
add_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m);
}
@@ -651,7 +651,7 @@ DO_INLINE void addadd_bfmatrix_bfmatrix( fmatrix3x3 *to, fmatrix3x3 *from, fmat
unsigned int i = 0;
/* process diagonal elements */
- for(i = 0; i < matrix[0].vcount+matrix[0].scount; i++)
+ for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++)
{
addadd_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m);
}
@@ -663,7 +663,7 @@ DO_INLINE void subadd_bfmatrix_bfmatrix( fmatrix3x3 *to, fmatrix3x3 *from, fmat
unsigned int i = 0;
/* process diagonal elements */
- for(i = 0; i < matrix[0].vcount+matrix[0].scount; i++)
+ for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++)
{
subadd_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m);
}
@@ -675,7 +675,7 @@ DO_INLINE void sub_bfmatrix_bfmatrix( fmatrix3x3 *to, fmatrix3x3 *from, fmatrix
unsigned int i = 0;
/* process diagonal elements */
- for(i = 0; i < matrix[0].vcount+matrix[0].scount; i++)
+ for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++)
{
sub_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m);
}
@@ -687,7 +687,7 @@ DO_INLINE void sub_bfmatrix_Smatrix( fmatrix3x3 *to, fmatrix3x3 *from, fmatrix3
unsigned int i = 0;
/* process diagonal elements */
- for(i = 0; i < matrix[0].vcount; i++)
+ for (i = 0; i < matrix[0].vcount; i++)
{
sub_fmatrix_fmatrix(to[matrix[i].c].m, from[matrix[i].c].m, matrix[i].m);
}
@@ -699,7 +699,7 @@ DO_INLINE void addsub_bfmatrix_bfmatrix( fmatrix3x3 *to, fmatrix3x3 *from, fmat
unsigned int i = 0;
/* process diagonal elements */
- for(i = 0; i < matrix[0].vcount+matrix[0].scount; i++)
+ for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++)
{
addsub_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m);
}
@@ -713,7 +713,7 @@ DO_INLINE void subadd_bfmatrixS_bfmatrixS( fmatrix3x3 *to, fmatrix3x3 *from, flo
unsigned int i = 0;
/* process diagonal elements */
- for(i = 0; i < matrix[0].vcount+matrix[0].scount; i++)
+ for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++)
{
subadd_fmatrixS_fmatrixS(to[i].m, from[i].m, aS, matrix[i].m, bS);
}
@@ -739,7 +739,7 @@ int implicit_init (Object *UNUSED(ob), ClothModifierData *clmd)
Implicit_Data *id = NULL;
LinkNode *search = NULL;
- if(G.rt > 0)
+ if (G.rt > 0)
printf("implicit_init\n");
// init memory guard
@@ -772,11 +772,11 @@ int implicit_init (Object *UNUSED(ob), ClothModifierData *clmd)
id->dV = create_lfvector(cloth->numverts);
id->z = create_lfvector(cloth->numverts);
- for(i=0;i<cloth->numverts;i++)
+ for (i=0;i<cloth->numverts;i++)
{
id->A[i].r = id->A[i].c = id->dFdV[i].r = id->dFdV[i].c = id->dFdX[i].r = id->dFdX[i].c = id->P[i].c = id->P[i].r = id->Pinv[i].c = id->Pinv[i].r = id->bigI[i].c = id->bigI[i].r = id->M[i].r = id->M[i].c = i;
- if(verts [i].flags & CLOTH_VERT_FLAG_PINNED)
+ if (verts [i].flags & CLOTH_VERT_FLAG_PINNED)
{
id->S[pinned].pinned = 1;
id->S[pinned].c = id->S[pinned].r = i;
@@ -791,7 +791,7 @@ int implicit_init (Object *UNUSED(ob), ClothModifierData *clmd)
// init springs
search = cloth->springs;
- for(i=0;i<cloth->numsprings;i++)
+ for (i=0;i<cloth->numsprings;i++)
{
spring = search->link;
@@ -810,7 +810,7 @@ int implicit_init (Object *UNUSED(ob), ClothModifierData *clmd)
initdiag_bfmatrix(id->bigI, I);
- for(i = 0; i < cloth->numverts; i++)
+ for (i = 0; i < cloth->numverts; i++)
{
copy_v3_v3(id->X[i], verts[i].x);
}
@@ -823,11 +823,11 @@ int implicit_free (ClothModifierData *clmd)
Cloth *cloth;
cloth = (Cloth *)clmd->clothObject;
- if(cloth)
+ if (cloth)
{
id = cloth->implicit;
- if(id)
+ if (id)
{
del_bfmatrix(id->A);
del_bfmatrix(id->dFdV);
@@ -874,7 +874,7 @@ DO_INLINE float fbstar(float length, float L, float kb, float cb)
float fbstar = cb * (length - L);
- if(tempfb < fbstar)
+ if (tempfb < fbstar)
return fbstar;
else
return tempfb;
@@ -886,7 +886,7 @@ DO_INLINE float fbstar_jacobi(float length, float L, float kb, float cb)
float tempfb = kb * fb(length, L);
float fbstar = cb * (length - L);
- if(tempfb < fbstar)
+ if (tempfb < fbstar)
{
return cb;
}
@@ -900,7 +900,7 @@ DO_INLINE void filter(lfVector *V, fmatrix3x3 *S)
{
unsigned int i=0;
- for(i=0;i<S[0].vcount;i++)
+ for (i=0;i<S[0].vcount;i++)
{
mul_fvector_fmatrix(V[S[i].r], V[S[i].r], S[i].m);
}
@@ -936,7 +936,7 @@ static int cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z
s = dot_lfvector(r, r, numverts);
starget = s * sqrt(conjgrad_epsilon);
- while(s>starget && conjgrad_loopcount < conjgrad_looplimit)
+ while (s>starget && conjgrad_loopcount < conjgrad_looplimit)
{
// Mul(q,A,d); // q = A*d;
mul_bfmatrix_lfvector(q, lA, d);
@@ -979,7 +979,7 @@ DO_INLINE void BuildPPinv(fmatrix3x3 *lA, fmatrix3x3 *P, fmatrix3x3 *Pinv)
// Take only the diagonal blocks of A
// #pragma omp parallel for private(i) if(lA[0].vcount > CLOTH_OPENMP_LIMIT)
- for(i = 0; i<lA[0].vcount; i++)
+ for (i = 0; i<lA[0].vcount; i++)
{
// block diagonalizer
cp_fmatrix(P[i].m, lA[i].m);
@@ -1255,12 +1255,12 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
s->flags &= ~CLOTH_SPRING_FLAG_NEEDED;
- if(length > ALMOST_ZERO)
+ if (length > ALMOST_ZERO)
{
/*
- if(length>L)
+ if (length>L)
{
- if((clmd->sim_parms->flags & CSIMSETT_FLAG_TEARING_ENABLED)
+ if ((clmd->sim_parms->flags & CSIMSETT_FLAG_TEARING_ENABLED)
&& ((((length-L)*100.0f/L) > clmd->sim_parms->maxspringlen))) // cut spring!
{
s->flags |= CSPRING_FLAG_DEACTIVATE;
@@ -1276,9 +1276,9 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
}
// calculate force of structural + shear springs
- if((s->type & CLOTH_SPRING_TYPE_STRUCTURAL) || (s->type & CLOTH_SPRING_TYPE_SHEAR))
+ if ((s->type & CLOTH_SPRING_TYPE_STRUCTURAL) || (s->type & CLOTH_SPRING_TYPE_SHEAR))
{
- if(length > L || no_compress)
+ if (length > L || no_compress)
{
s->flags |= CLOTH_SPRING_FLAG_NEEDED;
@@ -1339,7 +1339,7 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
}
else // calculate force of bending springs
{
- if(length < L)
+ if (length < L)
{
s->flags |= CLOTH_SPRING_FLAG_NEEDED;
@@ -1358,9 +1358,9 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
DO_INLINE void cloth_apply_spring_force(ClothModifierData *UNUSED(clmd), ClothSpring *s, lfVector *lF, lfVector *UNUSED(X), lfVector *UNUSED(V), fmatrix3x3 *dFdV, fmatrix3x3 *dFdX)
{
- if(s->flags & CLOTH_SPRING_FLAG_NEEDED)
+ if (s->flags & CLOTH_SPRING_FLAG_NEEDED)
{
- if(!(s->type & CLOTH_SPRING_TYPE_BENDING))
+ if (!(s->type & CLOTH_SPRING_TYPE_BENDING))
{
sub_fmatrix_fmatrix(dFdV[s->ij].m, dFdV[s->ij].m, s->dfdv);
sub_fmatrix_fmatrix(dFdV[s->kl].m, dFdV[s->kl].m, s->dfdv);
@@ -1369,7 +1369,7 @@ DO_INLINE void cloth_apply_spring_force(ClothModifierData *UNUSED(clmd), ClothSp
VECADD(lF[s->ij], lF[s->ij], s->f);
- if(!(s->type & CLOTH_SPRING_TYPE_GOAL))
+ if (!(s->type & CLOTH_SPRING_TYPE_GOAL))
sub_v3_v3v3(lF[s->kl], lF[s->kl], s->f);
sub_fmatrix_fmatrix(dFdX[s->kl].m, dFdX[s->kl].m, s->dfdx);
@@ -1451,13 +1451,13 @@ static void hair_velocity_smoothing(ClothModifierData *clmd, lfVector *lF, lfVec
INIT_MINMAX(gmin, gmax);
- for(i = 0; i < numverts; i++)
+ for (i = 0; i < numverts; i++)
DO_MINMAX(lX[i], gmin, gmax);
/* initialize grid */
- for(i = 0; i < 10; i++) {
- for(j = 0; j < 10; j++) {
- for(k = 0; k < 10; k++) {
+ for (i = 0; i < 10; i++) {
+ for (j = 0; j < 10; j++) {
+ for (k = 0; k < 10; k++) {
grid[i][j][k].velocity[0] = 0.0f;
grid[i][j][k].velocity[1] = 0.0f;
grid[i][j][k].velocity[2] = 0.0f;
@@ -1472,7 +1472,7 @@ static void hair_velocity_smoothing(ClothModifierData *clmd, lfVector *lF, lfVec
}
/* gather velocities & density */
- if(smoothfac > 0.0f) for(v = 0; v < numverts; v++) {
+ if (smoothfac > 0.0f) for(v = 0; v < numverts; v++) {
i = HAIR_GRID_INDEX(lX[v], gmin, gmax, 0);
j = HAIR_GRID_INDEX(lX[v], gmin, gmax, 1);
k = HAIR_GRID_INDEX(lX[v], gmin, gmax, 2);
@@ -1486,22 +1486,22 @@ static void hair_velocity_smoothing(ClothModifierData *clmd, lfVector *lF, lfVec
}
/* gather colliders */
- if(colliders && collfac > 0.0f) for(col = colliders->first; col; col = col->next)
+ if (colliders && collfac > 0.0f) for(col = colliders->first; col; col = col->next)
{
MVert *loc0 = col->collmd->x;
MVert *loc1 = col->collmd->xnew;
float vel[3];
- for(v=0; v<col->collmd->numverts; v++, loc0++, loc1++) {
+ for (v=0; v<col->collmd->numverts; v++, loc0++, loc1++) {
i = HAIR_GRID_INDEX(loc1->co, gmin, gmax, 0);
- if(i>=0 && i<10) {
+ if (i>=0 && i<10) {
j = HAIR_GRID_INDEX(loc1->co, gmin, gmax, 1);
- if(j>=0 && j<10) {
+ if (j>=0 && j<10) {
k = HAIR_GRID_INDEX(loc1->co, gmin, gmax, 2);
- if(k>=0 && k<10) {
+ if (k>=0 && k<10) {
sub_v3_v3v3(vel, loc1->co, loc0->co);
colg[i][j][k].velocity[0] += vel[0];
@@ -1516,18 +1516,18 @@ static void hair_velocity_smoothing(ClothModifierData *clmd, lfVector *lF, lfVec
/* divide velocity with density */
- for(i = 0; i < 10; i++) {
- for(j = 0; j < 10; j++) {
- for(k = 0; k < 10; k++) {
+ for (i = 0; i < 10; i++) {
+ for (j = 0; j < 10; j++) {
+ for (k = 0; k < 10; k++) {
density = grid[i][j][k].density;
- if(density > 0.0f) {
+ if (density > 0.0f) {
grid[i][j][k].velocity[0] /= density;
grid[i][j][k].velocity[1] /= density;
grid[i][j][k].velocity[2] /= density;
}
density = colg[i][j][k].density;
- if(density > 0.0f) {
+ if (density > 0.0f) {
colg[i][j][k].velocity[0] /= density;
colg[i][j][k].velocity[1] /= density;
colg[i][j][k].velocity[2] /= density;
@@ -1537,7 +1537,7 @@ static void hair_velocity_smoothing(ClothModifierData *clmd, lfVector *lF, lfVec
}
/* calculate forces */
- for(v = 0; v < numverts; v++) {
+ for (v = 0; v < numverts; v++) {
i = HAIR_GRID_INDEX(lX[v], gmin, gmax, 0);
j = HAIR_GRID_INDEX(lX[v], gmin, gmax, 1);
k = HAIR_GRID_INDEX(lX[v], gmin, gmax, 2);
@@ -1548,7 +1548,7 @@ static void hair_velocity_smoothing(ClothModifierData *clmd, lfVector *lF, lfVec
lF[v][1] += smoothfac * (grid[i][j][k].velocity[1] - lV[v][1]);
lF[v][2] += smoothfac * (grid[i][j][k].velocity[2] - lV[v][2]);
- if(colg[i][j][k].density > 0.0f) {
+ if (colg[i][j][k].density > 0.0f) {
lF[v][0] += collfac * (colg[i][j][k].velocity[0] - lV[v][0]);
lF[v][1] += collfac * (colg[i][j][k].velocity[1] - lV[v][1]);
lF[v][2] += collfac * (colg[i][j][k].velocity[2] - lV[v][2]);
@@ -1575,7 +1575,7 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec
tm2[0][0]= tm2[1][1]= tm2[2][2]= -spring_air;
/* global acceleration (gravitation) */
- if(clmd->scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) {
+ if (clmd->scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) {
copy_v3_v3(gravity, clmd->scene->physics_settings.gravity);
mul_fvector_S(gravity, gravity, 0.001f * clmd->sim_parms->effector_weights->global_gravity); /* scale gravity force */
}
@@ -1587,13 +1587,13 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec
init_lfvector(lF, gravity, numverts);
- if(clmd->sim_parms->velocity_smooth > 0.0f || clmd->sim_parms->collider_friction > 0.0f)
+ if (clmd->sim_parms->velocity_smooth > 0.0f || clmd->sim_parms->collider_friction > 0.0f)
hair_velocity_smoothing(clmd, lF, lX, lV, numverts);
/* multiply lF with mass matrix
// force = mass * acceleration (in this case: gravity)
*/
- for(i = 0; i < numverts; i++)
+ for (i = 0; i < numverts; i++)
{
float temp[3];
copy_v3_v3(temp, lF[i]);
@@ -1603,22 +1603,22 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec
submul_lfvectorS(lF, lV, spring_air, numverts);
/* handle external forces like wind */
- if(effectors)
+ if (effectors)
{
// 0 = force, 1 = normalized force
winvec = create_lfvector(cloth->numverts);
- if(!winvec)
+ if (!winvec)
printf("winvec: out of memory in implicit.c\n");
// precalculate wind forces
- for(i = 0; i < cloth->numverts; i++)
+ for (i = 0; i < cloth->numverts; i++)
{
pd_point_from_loc(clmd->scene, (float*)lX[i], (float*)lV[i], i, &epoint);
pdDoEffectors(effectors, NULL, clmd->sim_parms->effector_weights, &epoint, winvec[i], NULL);
}
- for(i = 0; i < cloth->numfaces; i++)
+ for (i = 0; i < cloth->numfaces; i++)
{
float trinormal[3]={0,0,0}; // normalized triangle normal
float triunnormal[3]={0,0,0}; // not-normalized-triangle normal
@@ -1627,7 +1627,7 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec
factor *= 0.02;
// calculate face normal
- if(mfaces[i].v4)
+ if (mfaces[i].v4)
CalcFloat4(lX[mfaces[i].v1],lX[mfaces[i].v2],lX[mfaces[i].v3],lX[mfaces[i].v4],triunnormal);
else
CalcFloat(lX[mfaces[i].v1],lX[mfaces[i].v2],lX[mfaces[i].v3],triunnormal);
@@ -1650,7 +1650,7 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec
VECADDS(lF[mfaces[i].v3], lF[mfaces[i].v3], tmp, factor);
// add wind from v4
- if(mfaces[i].v4)
+ if (mfaces[i].v4)
{
copy_v3_v3(tmp, trinormal);
mul_v3_fl(tmp, calculateVertexWindForce(winvec[mfaces[i].v4], triunnormal));
@@ -1659,7 +1659,7 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec
}
/* Hair has only edges */
- if(cloth->numfaces == 0) {
+ if (cloth->numfaces == 0) {
ClothSpring *spring;
float edgevec[3]={0,0,0}; //edge vector
float edgeunnormal[3]={0,0,0}; // not-normalized-edge normal
@@ -1667,10 +1667,10 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec
float factor = 0.01;
search = cloth->springs;
- while(search) {
+ while (search) {
spring = search->link;
- if(spring->type == CLOTH_SPRING_TYPE_STRUCTURAL) {
+ if (spring->type == CLOTH_SPRING_TYPE_STRUCTURAL) {
sub_v3_v3v3(edgevec, (float*)lX[spring->ij], (float*)lX[spring->kl]);
project_v3_v3v3(tmp, winvec[spring->ij], edgevec);
@@ -1692,7 +1692,7 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec
// calculate spring forces
search = cloth->springs;
- while(search)
+ while (search)
{
// only handle active springs
// if(((clmd->sim_parms->flags & CSIMSETT_FLAG_TEARING_ENABLED) && !(springs[i].flags & CSPRING_FLAG_DEACTIVATE))|| !(clmd->sim_parms->flags & CSIMSETT_FLAG_TEARING_ENABLED)) {}
@@ -1703,7 +1703,7 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec
// apply spring forces
search = cloth->springs;
- while(search)
+ while (search)
{
// only handle active springs
// if(((clmd->sim_parms->flags & CSIMSETT_FLAG_TEARING_ENABLED) && !(springs[i].flags & CSPRING_FLAG_DEACTIVATE))|| !(clmd->sim_parms->flags & CSIMSETT_FLAG_TEARING_ENABLED))
@@ -1765,7 +1765,8 @@ int cloth_calc_helper_forces(Object *UNUSED(ob), ClothModifierData * clmd, float
if (cv->goal == 1.0f || len_v3v3(initial_cos[i], cv->tx) != 0.0) {
masses[i] = 1e+10;
- } else {
+ }
+ else {
masses[i] = cv->mass;
}
}
@@ -1835,12 +1836,12 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
Implicit_Data *id = cloth->implicit;
int do_extra_solve;
- if(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) /* do goal stuff */
+ if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) /* do goal stuff */
{
- for(i = 0; i < numverts; i++)
+ for (i = 0; i < numverts; i++)
{
// update velocities with constrained velocities from pinned verts
- if(verts [i].flags & CLOTH_VERT_FLAG_PINNED)
+ if (verts [i].flags & CLOTH_VERT_FLAG_PINNED)
{
sub_v3_v3v3(id->V[i], verts[i].xconst, verts[i].xold);
// mul_v3_fl(id->V[i], clmd->sim_parms->stepsPerFrame);
@@ -1848,7 +1849,7 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
}
}
- while(step < tf)
+ while (step < tf)
{
// damping velocity for artistic reasons
mul_lfvectorS(id->V, id->V, clmd->sim_parms->vel_damping, numverts);
@@ -1863,11 +1864,11 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
add_lfvector_lfvectorS(id->Xnew, id->X, id->Vnew, dt, numverts);
/* move pinned verts to correct position */
- for(i = 0; i < numverts; i++)
+ for (i = 0; i < numverts; i++)
{
- if(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL)
+ if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL)
{
- if(verts [i].flags & CLOTH_VERT_FLAG_PINNED)
+ if (verts [i].flags & CLOTH_VERT_FLAG_PINNED)
{
float tvect[3] = {.0,.0,.0};
sub_v3_v3v3(tvect, verts[i].xconst, verts[i].xold);
@@ -1880,13 +1881,13 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
copy_v3_v3(verts[i].txold, id->X[i]);
}
- if(clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_ENABLED && clmd->clothObject->bvhtree)
+ if (clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_ENABLED && clmd->clothObject->bvhtree)
{
// collisions
// itstart();
// update verts to current positions
- for(i = 0; i < numverts; i++)
+ for (i = 0; i < numverts; i++)
{
copy_v3_v3(verts[i].tx, id->Xnew[i]);
@@ -1903,7 +1904,7 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
do_extra_solve = cloth_bvh_objcollision(ob, clmd, step/clmd->sim_parms->timescale, dt/clmd->sim_parms->timescale);
// copy corrected positions back to simulation
- for(i = 0; i < numverts; i++)
+ for (i = 0; i < numverts; i++)
{
// correct velocity again, just to be sure we had to change it due to adaptive collisions
sub_v3_v3v3(verts[i].tv, verts[i].tx, id->X[i]);
@@ -1912,13 +1913,13 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
//if (do_extra_solve)
// cloth_calc_helper_forces(ob, clmd, initial_cos, step/clmd->sim_parms->timescale, dt/clmd->sim_parms->timescale);
- for(i = 0; i < numverts; i++)
+ for (i = 0; i < numverts; i++)
{
- if(do_extra_solve)
+ if (do_extra_solve)
{
- if((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) && (verts [i].flags & CLOTH_VERT_FLAG_PINNED))
+ if ((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) && (verts [i].flags & CLOTH_VERT_FLAG_PINNED))
continue;
copy_v3_v3(id->Xnew[i], verts[i].tx);
@@ -1932,7 +1933,7 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
// if there were collisions, advance the velocity from v_n+1/2 to v_n+1
- if(do_extra_solve)
+ if (do_extra_solve)
{
// V = Vnew;
cp_lfvector(id->V, id->Vnew, numverts);
@@ -1958,9 +1959,9 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
step += dt;
}
- for(i = 0; i < numverts; i++)
+ for (i = 0; i < numverts; i++)
{
- if((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) && (verts [i].flags & CLOTH_VERT_FLAG_PINNED))
+ if ((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) && (verts [i].flags & CLOTH_VERT_FLAG_PINNED))
{
copy_v3_v3(verts[i].txold, verts[i].xconst); // TODO: test --> should be .x
copy_v3_v3(verts[i].x, verts[i].xconst);
@@ -1986,12 +1987,12 @@ void implicit_set_positions (ClothModifierData *clmd)
unsigned int numverts = cloth->numverts, i;
Implicit_Data *id = cloth->implicit;
- for(i = 0; i < numverts; i++)
+ for (i = 0; i < numverts; i++)
{
copy_v3_v3(id->X[i], verts[i].x);
copy_v3_v3(id->V[i], verts[i].v);
}
- if(G.rt > 0)
+ if (G.rt > 0)
printf("implicit_set_positions\n");
}
diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c
index 6c05ecb33ff..300198ce7ea 100644
--- a/source/blender/blenkernel/intern/key.c
+++ b/source/blender/blenkernel/intern/key.c
@@ -83,9 +83,9 @@ void free_key(Key *key)
BKE_free_animdata((ID *)key);
- while( (kb= key->block.first) ) {
+ while ( (kb= key->block.first) ) {
- if(kb->data) MEM_freeN(kb->data);
+ if (kb->data) MEM_freeN(kb->data);
BLI_remlink(&key->block, kb);
MEM_freeN(kb);
@@ -97,9 +97,9 @@ void free_key_nolib(Key *key)
{
KeyBlock *kb;
- while( (kb= key->block.first) ) {
+ while ( (kb= key->block.first) ) {
- if(kb->data) MEM_freeN(kb->data);
+ if (kb->data) MEM_freeN(kb->data);
BLI_remlink(&key->block, kb);
MEM_freeN(kb);
@@ -133,7 +133,7 @@ Key *add_key(ID *id) /* common function */
key->uidgen = 1;
// XXX the code here uses some defines which will soon be depreceated...
- if( GS(id->name)==ID_ME) {
+ if ( GS(id->name)==ID_ME) {
el= key->elemstr;
el[0]= 3;
@@ -142,7 +142,7 @@ Key *add_key(ID *id) /* common function */
key->elemsize= 12;
}
- else if( GS(id->name)==ID_LT) {
+ else if ( GS(id->name)==ID_LT) {
el= key->elemstr;
el[0]= 3;
@@ -151,7 +151,7 @@ Key *add_key(ID *id) /* common function */
key->elemsize= 12;
}
- else if( GS(id->name)==ID_CU) {
+ else if ( GS(id->name)==ID_CU) {
el= key->elemstr;
el[0]= 4;
@@ -169,7 +169,7 @@ Key *copy_key(Key *key)
Key *keyn;
KeyBlock *kbn, *kb;
- if(key==NULL) return NULL;
+ if (key==NULL) return NULL;
keyn= copy_libblock(&key->id);
@@ -177,10 +177,10 @@ Key *copy_key(Key *key)
kb= key->block.first;
kbn= keyn->block.first;
- while(kbn) {
+ while (kbn) {
- if(kbn->data) kbn->data= MEM_dupallocN(kbn->data);
- if(kb==key->refkey) keyn->refkey= kbn;
+ if (kbn->data) kbn->data= MEM_dupallocN(kbn->data);
+ if (kb==key->refkey) keyn->refkey= kbn;
kbn= kbn->next;
kb= kb->next;
@@ -195,7 +195,7 @@ Key *copy_key_nolib(Key *key)
Key *keyn;
KeyBlock *kbn, *kb;
- if(key==0) return 0;
+ if (key==0) return 0;
keyn= MEM_dupallocN(key);
@@ -205,10 +205,10 @@ Key *copy_key_nolib(Key *key)
kb= key->block.first;
kbn= keyn->block.first;
- while(kbn) {
+ while (kbn) {
- if(kbn->data) kbn->data= MEM_dupallocN(kbn->data);
- if(kb==key->refkey) keyn->refkey= kbn;
+ if (kbn->data) kbn->data= MEM_dupallocN(kbn->data);
+ if (kb==key->refkey) keyn->refkey= kbn;
kbn= kbn->next;
kb= kb->next;
@@ -224,7 +224,7 @@ void make_local_key(Key *key)
* - only local users: set flag
* - mixed: make copy
*/
- if(key==NULL) return;
+ if (key==NULL) return;
key->id.lib= NULL;
new_id(NULL, &key->id, NULL);
@@ -262,15 +262,15 @@ void sort_keys(Key *key)
/* if more than one Ipo curve, see if this key had a curve */
#if 0 // XXX old animation system
- if(key->ipo && key->ipo->curve.first != key->ipo->curve.last ) {
- for(icu= key->ipo->curve.first; icu; icu= icu->next) {
+ if (key->ipo && key->ipo->curve.first != key->ipo->curve.last ) {
+ for (icu= key->ipo->curve.first; icu; icu= icu->next) {
/* if we find the curve, remove it and reinsert in the
* right place */
- if(icu->adrcode==kb->adrcode) {
+ if (icu->adrcode==kb->adrcode) {
IpoCurve *icu2;
BLI_remlink(&key->ipo->curve, icu);
- for(icu2= key->ipo->curve.first; icu2; icu2= icu2->next) {
- if(icu2->adrcode >= kb2->adrcode) {
+ for (icu2= key->ipo->curve.first; icu2; icu2= icu2->next) {
+ if (icu2->adrcode >= kb2->adrcode) {
BLI_insertlink(&key->ipo->curve, icu2->prev, icu);
break;
}
@@ -287,7 +287,7 @@ void sort_keys(Key *key)
adrcode = kb2->adrcode;
for (i = kb->adrcode - adrcode; i >= 0; i--, adrcode++) {
/* if the next ipo curve matches the current key, renumber it */
- if(icu && icu->adrcode == kb->adrcode ) {
+ if (icu && icu->adrcode == kb->adrcode ) {
icu->adrcode = adrcode;
icu = icu->next;
}
@@ -308,13 +308,13 @@ void key_curve_position_weights(float t, float *data, int type)
{
float t2, t3, fc;
- if(type==KEY_LINEAR) {
+ if (type==KEY_LINEAR) {
data[0]= 0.0f;
data[1]= -t + 1.0f;
data[2]= t;
data[3]= 0.0f;
}
- else if(type==KEY_CARDINAL) {
+ else if (type==KEY_CARDINAL) {
t2= t*t;
t3= t2*t;
fc= 0.71f;
@@ -324,7 +324,7 @@ void key_curve_position_weights(float t, float *data, int type)
data[2]= (fc-2.0f)*t3 + (3.0f-2.0f*fc)*t2 + fc*t;
data[3]= fc*t3 - fc*t2;
}
- else if(type==KEY_BSPLINE) {
+ else if (type==KEY_BSPLINE) {
t2= t*t;
t3= t2*t;
@@ -340,13 +340,13 @@ void key_curve_tangent_weights(float t, float *data, int type)
{
float t2, fc;
- if(type==KEY_LINEAR) {
+ if (type==KEY_LINEAR) {
data[0]= 0.0f;
data[1]= -1.0f;
data[2]= 1.0f;
data[3]= 0.0f;
}
- else if(type==KEY_CARDINAL) {
+ else if (type==KEY_CARDINAL) {
t2= t*t;
fc= 0.71f;
@@ -355,7 +355,7 @@ void key_curve_tangent_weights(float t, float *data, int type)
data[2]= 3.0f*(fc-2.0f)*t2 +2.0f*(3.0f-2.0f*fc)*t + fc;
data[3]= 3.0f*fc*t2 -2.0f*fc*t;
}
- else if(type==KEY_BSPLINE) {
+ else if (type==KEY_BSPLINE) {
t2= t*t;
data[0]= -0.5f*t2 + t - 0.5f;
@@ -370,13 +370,13 @@ void key_curve_normal_weights(float t, float *data, int type)
{
float fc;
- if(type==KEY_LINEAR) {
+ if (type==KEY_LINEAR) {
data[0]= 0.0f;
data[1]= 0.0f;
data[2]= 0.0f;
data[3]= 0.0f;
}
- else if(type==KEY_CARDINAL) {
+ else if (type==KEY_CARDINAL) {
fc= 0.71f;
data[0]= -6.0f*fc*t + 4.0f*fc;
@@ -384,7 +384,7 @@ void key_curve_normal_weights(float t, float *data, int type)
data[2]= 6.0f*(fc-2.0f)*t + 2.0f*(3.0f-2.0f*fc);
data[3]= 6.0f*fc*t - 2.0f*fc;
}
- else if(type==KEY_BSPLINE) {
+ else if (type==KEY_BSPLINE) {
data[0]= -1.0f*t + 1.0f;
data[1]= 3.0f*t - 2.0f;
data[2]= -3.0f*t + 1.0f;
@@ -404,22 +404,22 @@ static int setkeys(float fac, ListBase *lb, KeyBlock *k[], float *t, int cycl)
lastpos= k1->pos;
dpos= lastpos - firstkey->pos;
- if(fac < firstkey->pos) fac= firstkey->pos;
- else if(fac > k1->pos) fac= k1->pos;
+ if (fac < firstkey->pos) fac= firstkey->pos;
+ else if (fac > k1->pos) fac= k1->pos;
k1=k[0]=k[1]=k[2]=k[3]= firstkey;
t[0]=t[1]=t[2]=t[3]= k1->pos;
/* if(fac<0.0 || fac>1.0) return 1; */
- if(k1->next==NULL) return 1;
+ if (k1->next==NULL) return 1;
- if(cycl) { /* pre-sort */
+ if (cycl) { /* pre-sort */
k[2]= k1->next;
k[3]= k[2]->next;
- if(k[3]==NULL) k[3]=k1;
- while(k1) {
- if(k1->next==NULL) k[0]=k1;
+ if (k[3]==NULL) k[3]=k1;
+ while (k1) {
+ if (k1->next==NULL) k[0]=k1;
k1=k1->next;
}
/* k1= k[1]; */ /* UNUSED */
@@ -429,29 +429,29 @@ static int setkeys(float fac, ListBase *lb, KeyBlock *k[], float *t, int cycl)
t[3]= k[3]->pos + dpos;
fac+= dpos;
ofs= dpos;
- if(k[3]==k[1]) {
+ if (k[3]==k[1]) {
t[3]+= dpos;
ofs= 2.0f*dpos;
}
- if(fac<t[1]) fac+= dpos;
+ if (fac<t[1]) fac+= dpos;
k1= k[3];
}
else { /* pre-sort */
k[2]= k1->next;
t[2]= k[2]->pos;
k[3]= k[2]->next;
- if(k[3]==NULL) k[3]= k[2];
+ if (k[3]==NULL) k[3]= k[2];
t[3]= k[3]->pos;
k1= k[3];
}
- while( t[2]<fac ) { /* find correct location */
- if(k1->next==NULL) {
- if(cycl) {
+ while ( t[2]<fac ) { /* find correct location */
+ if (k1->next==NULL) {
+ if (cycl) {
k1= firstkey;
ofs+= dpos;
}
- else if(t[2]==t[3]) break;
+ else if (t[2]==t[3]) break;
}
else k1= k1->next;
@@ -464,25 +464,25 @@ static int setkeys(float fac, ListBase *lb, KeyBlock *k[], float *t, int cycl)
t[3]= k1->pos+ofs;
k[3]= k1;
- if(ofs > 2.1f + lastpos) break;
+ if (ofs > 2.1f + lastpos) break;
}
bsplinetype= 0;
- if(k[1]->type==KEY_BSPLINE || k[2]->type==KEY_BSPLINE) bsplinetype= 1;
+ if (k[1]->type==KEY_BSPLINE || k[2]->type==KEY_BSPLINE) bsplinetype= 1;
- if(cycl==0) {
- if(bsplinetype==0) { /* B spline doesn't go through the control points */
- if(fac<=t[1]) { /* fac for 1st key */
+ if (cycl==0) {
+ if (bsplinetype==0) { /* B spline doesn't go through the control points */
+ if (fac<=t[1]) { /* fac for 1st key */
t[2]= t[1];
k[2]= k[1];
return 1;
}
- if(fac>=t[2] ) { /* fac after 2nd key */
+ if (fac>=t[2] ) { /* fac after 2nd key */
return 1;
}
}
- else if(fac>t[2]) { /* last key */
+ else if (fac>t[2]) { /* last key */
fac= t[2];
k[3]= k[2];
t[3]= t[2];
@@ -490,8 +490,8 @@ static int setkeys(float fac, ListBase *lb, KeyBlock *k[], float *t, int cycl)
}
d= t[2]-t[1];
- if(d == 0.0f) {
- if(bsplinetype==0) {
+ if (d == 0.0f) {
+ if (bsplinetype==0) {
return 1; /* both keys equal */
}
}
@@ -501,7 +501,7 @@ static int setkeys(float fac, ListBase *lb, KeyBlock *k[], float *t, int cycl)
key_curve_position_weights(d, t, k[1]->type);
- if(k[1]->type != k[2]->type) {
+ if (k[1]->type != k[2]->type) {
key_curve_position_weights(d, fval, k[2]->type);
temp= 1.0f-d;
@@ -519,7 +519,7 @@ static void flerp(int tot, float *in, float *f0, float *f1, float *f2, float *f3
{
int a;
- for(a=0; a<tot; a++) {
+ for (a=0; a<tot; a++) {
in[a]= t[0]*f0[a]+t[1]*f1[a]+t[2]*f2[a]+t[3]*f3[a];
}
}
@@ -528,17 +528,17 @@ static void rel_flerp(int tot, float *in, float *ref, float *out, float fac)
{
int a;
- for(a=0; a<tot; a++) {
+ for (a=0; a<tot; a++) {
in[a]-= fac*(ref[a]-out[a]);
}
}
static char *key_block_get_data(Key *key, KeyBlock *actkb, KeyBlock *kb, char **freedata)
{
- if(kb == actkb) {
+ if (kb == actkb) {
/* this hack makes it possible to edit shape keys in
* edit mode with shape keys blending applied */
- if(GS(key->from->name) == ID_ME) {
+ if (GS(key->from->name) == ID_ME) {
Mesh *me;
BMVert *eve;
BMIter iter;
@@ -547,7 +547,7 @@ static char *key_block_get_data(Key *key, KeyBlock *actkb, KeyBlock *kb, char **
me= (Mesh*)key->from;
- if(me->edit_btmesh && me->edit_btmesh->bm->totvert == kb->totelem) {
+ if (me->edit_btmesh && me->edit_btmesh->bm->totvert == kb->totelem) {
a= 0;
co= MEM_callocN(sizeof(float)*3*me->edit_btmesh->bm->totvert, "key_block_get_data");
@@ -570,7 +570,7 @@ static char *key_block_get_data(Key *key, KeyBlock *actkb, KeyBlock *kb, char **
/* currently only the first value of 'ofs' may be set. */
static short key_pointer_size(const Key *key, const int mode, int *poinsize, int *ofs)
{
- if(key->from==NULL) {
+ if (key->from==NULL) {
return FALSE;
}
@@ -584,10 +584,11 @@ static short key_pointer_size(const Key *key, const int mode, int *poinsize, int
*poinsize= *ofs;
break;
case ID_CU:
- if(mode == KEY_MODE_BPOINT) {
+ if (mode == KEY_MODE_BPOINT) {
*ofs= sizeof(float)*4;
*poinsize= *ofs;
- } else {
+ }
+ else {
ofs[0]= sizeof(float)*12;
*poinsize= (*ofs) / 3;
}
@@ -611,15 +612,15 @@ static void cp_key(const int start, int end, const int tot, char *poin, Key *key
/* currently always 0, in future key_pointer_size may assign */
ofs[1]= 0;
- if(!key_pointer_size(key, mode, &poinsize, &ofs[0]))
+ if (!key_pointer_size(key, mode, &poinsize, &ofs[0]))
return;
- if(end>tot) end= tot;
+ if (end>tot) end= tot;
- if(tot != kb->totelem) {
+ if (tot != kb->totelem) {
ktot= 0.0;
flagflo= 1;
- if(kb->totelem) {
+ if (kb->totelem) {
kd= kb->totelem/(float)tot;
}
else return;
@@ -629,14 +630,14 @@ static void cp_key(const int start, int end, const int tot, char *poin, Key *key
kref= key_block_get_data(key, actkb, key->refkey, &freekref);
/* this exception is needed for slurphing */
- if(start!=0) {
+ if (start!=0) {
poin+= poinsize*start;
- if(flagflo) {
+ if (flagflo) {
ktot+= start*kd;
a= (int)floor(ktot);
- if(a) {
+ if (a) {
ktot-= a;
k1+= a*key->elemsize;
}
@@ -644,7 +645,7 @@ static void cp_key(const int start, int end, const int tot, char *poin, Key *key
else k1+= start*key->elemsize;
}
- if(mode == KEY_MODE_BEZTRIPLE) {
+ if (mode == KEY_MODE_BEZTRIPLE) {
elemstr[0]= 1;
elemstr[1]= IPO_BEZTRIPLE;
elemstr[2]= 0;
@@ -652,21 +653,21 @@ static void cp_key(const int start, int end, const int tot, char *poin, Key *key
/* just do it here, not above! */
elemsize= key->elemsize;
- if(mode == KEY_MODE_BEZTRIPLE) elemsize*= 3;
+ if (mode == KEY_MODE_BEZTRIPLE) elemsize*= 3;
- for(a=start; a<end; a++) {
+ for (a=start; a<end; a++) {
cp= key->elemstr;
- if(mode == KEY_MODE_BEZTRIPLE) cp= elemstr;
+ if (mode == KEY_MODE_BEZTRIPLE) cp= elemstr;
ofsp= ofs;
- while( cp[0] ) {
+ while ( cp[0] ) {
switch(cp[1]) {
case IPO_FLOAT:
- if(weights) {
+ if (weights) {
memcpy(poin, kref, sizeof(float)*3);
- if(*weights!=0.0f)
+ if (*weights!=0.0f)
rel_flerp(cp[0], (float *)poin, (float *)kref, (float *)k1, *weights);
weights++;
}
@@ -681,8 +682,8 @@ static void cp_key(const int start, int end, const int tot, char *poin, Key *key
break;
default:
/* should never happen */
- if(freek1) MEM_freeN(freek1);
- if(freekref) MEM_freeN(freekref);
+ if (freek1) MEM_freeN(freek1);
+ if (freekref) MEM_freeN(freekref);
BLI_assert(!"invalid 'cp[1]'");
return;
}
@@ -692,9 +693,9 @@ static void cp_key(const int start, int end, const int tot, char *poin, Key *key
}
/* are we going to be nasty? */
- if(flagflo) {
+ if (flagflo) {
ktot+= kd;
- while(ktot >= 1.0f) {
+ while (ktot >= 1.0f) {
ktot -= 1.0f;
k1+= elemsize;
kref+= elemsize;
@@ -705,11 +706,11 @@ static void cp_key(const int start, int end, const int tot, char *poin, Key *key
kref+= elemsize;
}
- if(mode == KEY_MODE_BEZTRIPLE) a+=2;
+ if (mode == KEY_MODE_BEZTRIPLE) a+=2;
}
- if(freek1) MEM_freeN(freek1);
- if(freekref) MEM_freeN(freekref);
+ if (freek1) MEM_freeN(freek1);
+ if (freekref) MEM_freeN(freekref);
}
static void cp_cu_key(Curve *cu, Key *key, KeyBlock *actkb, KeyBlock *kb, const int start, int end, char *out, const int tot)
@@ -717,23 +718,23 @@ static void cp_cu_key(Curve *cu, Key *key, KeyBlock *actkb, KeyBlock *kb, const
Nurb *nu;
int a, step, a1, a2;
- for(a=0, nu=cu->nurb.first; nu; nu=nu->next, a+=step) {
- if(nu->bp) {
+ for (a=0, nu=cu->nurb.first; nu; nu=nu->next, a+=step) {
+ if (nu->bp) {
step= nu->pntsu*nu->pntsv;
a1= MAX2(a, start);
a2= MIN2(a+step, end);
- if(a1<a2) cp_key(a1, a2, tot, out, key, actkb, kb, NULL, KEY_MODE_BPOINT);
+ if (a1<a2) cp_key(a1, a2, tot, out, key, actkb, kb, NULL, KEY_MODE_BPOINT);
}
- else if(nu->bezt) {
+ else if (nu->bezt) {
step= 3*nu->pntsu;
/* exception because keys prefer to work with complete blocks */
a1= MAX2(a, start);
a2= MIN2(a+step, end);
- if(a1<a2) cp_key(a1, a2, tot, out, key, actkb, kb, NULL, KEY_MODE_BEZTRIPLE);
+ if (a1<a2) cp_key(a1, a2, tot, out, key, actkb, kb, NULL, KEY_MODE_BEZTRIPLE);
}
else
step= 0;
@@ -751,10 +752,10 @@ void do_rel_key(const int start, int end, const int tot, char *basispoin, Key *k
/* currently always 0, in future key_pointer_size may assign */
ofs[1]= 0;
- if(!key_pointer_size(key, mode, &poinsize, &ofs[0]))
+ if (!key_pointer_size(key, mode, &poinsize, &ofs[0]))
return;
- if(end>tot) end= tot;
+ if (end>tot) end= tot;
/* in case of beztriple */
elemstr[0]= 1; /* nr of ipofloats */
@@ -763,25 +764,25 @@ void do_rel_key(const int start, int end, const int tot, char *basispoin, Key *k
/* just here, not above! */
elemsize= key->elemsize;
- if(mode == KEY_MODE_BEZTRIPLE) elemsize*= 3;
+ if (mode == KEY_MODE_BEZTRIPLE) elemsize*= 3;
/* step 1 init */
cp_key(start, end, tot, basispoin, key, actkb, key->refkey, NULL, mode);
/* step 2: do it */
- for(kb=key->block.first; kb; kb=kb->next) {
- if(kb!=key->refkey) {
+ for (kb=key->block.first; kb; kb=kb->next) {
+ if (kb!=key->refkey) {
float icuval= kb->curval;
/* only with value, and no difference allowed */
- if(!(kb->flag & KEYBLOCK_MUTE) && icuval!=0.0f && kb->totelem==tot) {
+ if (!(kb->flag & KEYBLOCK_MUTE) && icuval!=0.0f && kb->totelem==tot) {
KeyBlock *refb;
float weight, *weights= kb->weights;
/* reference now can be any block */
refb= BLI_findlink(&key->block, kb->relative);
- if(refb==NULL) continue;
+ if (refb==NULL) continue;
poin= basispoin;
from= key_block_get_data(key, actkb, kb, &freefrom);
@@ -791,19 +792,19 @@ void do_rel_key(const int start, int end, const int tot, char *basispoin, Key *k
reffrom+= key->elemsize*start; // key elemsize yes!
from+= key->elemsize*start;
- for(b=start; b<end; b++) {
+ for (b=start; b<end; b++) {
- if(weights)
+ if (weights)
weight= *weights * icuval;
else
weight= icuval;
cp= key->elemstr;
- if(mode == KEY_MODE_BEZTRIPLE) cp= elemstr;
+ if (mode == KEY_MODE_BEZTRIPLE) cp= elemstr;
ofsp= ofs;
- while( cp[0] ) { /* cp[0]==amount */
+ while ( cp[0] ) { /* cp[0]==amount */
switch(cp[1]) {
case IPO_FLOAT:
@@ -817,8 +818,8 @@ void do_rel_key(const int start, int end, const int tot, char *basispoin, Key *k
break;
default:
/* should never happen */
- if(freefrom) MEM_freeN(freefrom);
- if(freereffrom) MEM_freeN(freereffrom);
+ if (freefrom) MEM_freeN(freefrom);
+ if (freereffrom) MEM_freeN(freereffrom);
BLI_assert(!"invalid 'cp[1]'");
return;
}
@@ -832,12 +833,12 @@ void do_rel_key(const int start, int end, const int tot, char *basispoin, Key *k
reffrom+= elemsize;
from+= elemsize;
- if(mode == KEY_MODE_BEZTRIPLE) b+= 2;
- if(weights) weights++;
+ if (mode == KEY_MODE_BEZTRIPLE) b+= 2;
+ if (weights) weights++;
}
- if(freefrom) MEM_freeN(freefrom);
- if(freereffrom) MEM_freeN(freereffrom);
+ if (freefrom) MEM_freeN(freefrom);
+ if (freereffrom) MEM_freeN(freereffrom);
}
}
}
@@ -856,10 +857,10 @@ static void do_key(const int start, int end, const int tot, char *poin, Key *key
/* currently always 0, in future key_pointer_size may assign */
ofs[1]= 0;
- if(!key_pointer_size(key, mode, &poinsize, &ofs[0]))
+ if (!key_pointer_size(key, mode, &poinsize, &ofs[0]))
return;
- if(end>tot) end= tot;
+ if (end>tot) end= tot;
k1= key_block_get_data(key, actkb, k[0], &freek1);
k2= key_block_get_data(key, actkb, k[1], &freek2);
@@ -867,82 +868,82 @@ static void do_key(const int start, int end, const int tot, char *poin, Key *key
k4= key_block_get_data(key, actkb, k[3], &freek4);
/* test for more or less points (per key!) */
- if(tot != k[0]->totelem) {
+ if (tot != k[0]->totelem) {
k1tot= 0.0;
flagflo |= 1;
- if(k[0]->totelem) {
+ if (k[0]->totelem) {
k1d= k[0]->totelem/(float)tot;
}
else flagdo -= 1;
}
- if(tot != k[1]->totelem) {
+ if (tot != k[1]->totelem) {
k2tot= 0.0;
flagflo |= 2;
- if(k[0]->totelem) {
+ if (k[0]->totelem) {
k2d= k[1]->totelem/(float)tot;
}
else flagdo -= 2;
}
- if(tot != k[2]->totelem) {
+ if (tot != k[2]->totelem) {
k3tot= 0.0;
flagflo |= 4;
- if(k[0]->totelem) {
+ if (k[0]->totelem) {
k3d= k[2]->totelem/(float)tot;
}
else flagdo -= 4;
}
- if(tot != k[3]->totelem) {
+ if (tot != k[3]->totelem) {
k4tot= 0.0;
flagflo |= 8;
- if(k[0]->totelem) {
+ if (k[0]->totelem) {
k4d= k[3]->totelem/(float)tot;
}
else flagdo -= 8;
}
/* this exception needed for slurphing */
- if(start!=0) {
+ if (start!=0) {
poin+= poinsize*start;
- if(flagdo & 1) {
- if(flagflo & 1) {
+ if (flagdo & 1) {
+ if (flagflo & 1) {
k1tot+= start*k1d;
a= (int)floor(k1tot);
- if(a) {
+ if (a) {
k1tot-= a;
k1+= a*key->elemsize;
}
}
else k1+= start*key->elemsize;
}
- if(flagdo & 2) {
- if(flagflo & 2) {
+ if (flagdo & 2) {
+ if (flagflo & 2) {
k2tot+= start*k2d;
a= (int)floor(k2tot);
- if(a) {
+ if (a) {
k2tot-= a;
k2+= a*key->elemsize;
}
}
else k2+= start*key->elemsize;
}
- if(flagdo & 4) {
- if(flagflo & 4) {
+ if (flagdo & 4) {
+ if (flagflo & 4) {
k3tot+= start*k3d;
a= (int)floor(k3tot);
- if(a) {
+ if (a) {
k3tot-= a;
k3+= a*key->elemsize;
}
}
else k3+= start*key->elemsize;
}
- if(flagdo & 8) {
- if(flagflo & 8) {
+ if (flagdo & 8) {
+ if (flagflo & 8) {
k4tot+= start*k4d;
a= (int)floor(k4tot);
- if(a) {
+ if (a) {
k4tot-= a;
k4+= a*key->elemsize;
}
@@ -959,16 +960,16 @@ static void do_key(const int start, int end, const int tot, char *poin, Key *key
/* only here, not above! */
elemsize= key->elemsize;
- if(mode == KEY_MODE_BEZTRIPLE) elemsize*= 3;
+ if (mode == KEY_MODE_BEZTRIPLE) elemsize*= 3;
- for(a=start; a<end; a++) {
+ for (a=start; a<end; a++) {
cp= key->elemstr;
- if(mode == KEY_MODE_BEZTRIPLE) cp= elemstr;
+ if (mode == KEY_MODE_BEZTRIPLE) cp= elemstr;
ofsp= ofs;
- while( cp[0] ) { /* cp[0]==amount */
+ while ( cp[0] ) { /* cp[0]==amount */
switch(cp[1]) {
case IPO_FLOAT:
@@ -982,10 +983,10 @@ static void do_key(const int start, int end, const int tot, char *poin, Key *key
break;
default:
/* should never happen */
- if(freek1) MEM_freeN(freek1);
- if(freek2) MEM_freeN(freek2);
- if(freek3) MEM_freeN(freek3);
- if(freek4) MEM_freeN(freek4);
+ if (freek1) MEM_freeN(freek1);
+ if (freek2) MEM_freeN(freek2);
+ if (freek3) MEM_freeN(freek3);
+ if (freek4) MEM_freeN(freek4);
BLI_assert(!"invalid 'cp[1]'");
return;
}
@@ -995,40 +996,40 @@ static void do_key(const int start, int end, const int tot, char *poin, Key *key
ofsp++;
}
/* lets do it the difficult way: when keys have a different size */
- if(flagdo & 1) {
- if(flagflo & 1) {
+ if (flagdo & 1) {
+ if (flagflo & 1) {
k1tot+= k1d;
- while(k1tot >= 1.0f) {
+ while (k1tot >= 1.0f) {
k1tot -= 1.0f;
k1+= elemsize;
}
}
else k1+= elemsize;
}
- if(flagdo & 2) {
- if(flagflo & 2) {
+ if (flagdo & 2) {
+ if (flagflo & 2) {
k2tot+= k2d;
- while(k2tot >= 1.0f) {
+ while (k2tot >= 1.0f) {
k2tot -= 1.0f;
k2+= elemsize;
}
}
else k2+= elemsize;
}
- if(flagdo & 4) {
- if(flagflo & 4) {
+ if (flagdo & 4) {
+ if (flagflo & 4) {
k3tot+= k3d;
- while(k3tot >= 1.0f) {
+ while (k3tot >= 1.0f) {
k3tot -= 1.0f;
k3+= elemsize;
}
}
else k3+= elemsize;
}
- if(flagdo & 8) {
- if(flagflo & 8) {
+ if (flagdo & 8) {
+ if (flagflo & 8) {
k4tot+= k4d;
- while(k4tot >= 1.0f) {
+ while (k4tot >= 1.0f) {
k4tot -= 1.0f;
k4+= elemsize;
}
@@ -1036,13 +1037,13 @@ static void do_key(const int start, int end, const int tot, char *poin, Key *key
else k4+= elemsize;
}
- if(mode == KEY_MODE_BEZTRIPLE) a+= 2;
+ if (mode == KEY_MODE_BEZTRIPLE) a+= 2;
}
- if(freek1) MEM_freeN(freek1);
- if(freek2) MEM_freeN(freek2);
- if(freek3) MEM_freeN(freek3);
- if(freek4) MEM_freeN(freek4);
+ if (freek1) MEM_freeN(freek1);
+ if (freek2) MEM_freeN(freek2);
+ if (freek3) MEM_freeN(freek3);
+ if (freek4) MEM_freeN(freek4);
}
static float *get_weights_array(Object *ob, char *vgroup)
@@ -1054,45 +1055,45 @@ static float *get_weights_array(Object *ob, char *vgroup)
int totvert= 0, defgrp_index= 0;
/* no vgroup string set? */
- if(vgroup[0]==0) return NULL;
+ if (vgroup[0]==0) return NULL;
/* gather dvert and totvert */
- if(ob->type==OB_MESH) {
+ if (ob->type==OB_MESH) {
Mesh *me= ob->data;
dvert= me->dvert;
totvert= me->totvert;
- if(me->edit_btmesh && me->edit_btmesh->bm->totvert == totvert)
+ if (me->edit_btmesh && me->edit_btmesh->bm->totvert == totvert)
em= me->edit_btmesh;
}
- else if(ob->type==OB_LATTICE) {
+ else if (ob->type==OB_LATTICE) {
Lattice *lt= ob->data;
dvert= lt->dvert;
totvert= lt->pntsu*lt->pntsv*lt->pntsw;
}
- if(dvert==NULL) return NULL;
+ if (dvert==NULL) return NULL;
/* find the group (weak loop-in-loop) */
defgrp_index= defgroup_name_index(ob, vgroup);
- if(defgrp_index >= 0) {
+ if (defgrp_index >= 0) {
float *weights;
int i;
weights= MEM_callocN(totvert*sizeof(float), "weights");
- if(em) {
+ if (em) {
eve = BM_iter_new(&iter, em->bm, BM_VERTS_OF_MESH, NULL);
for (i=0; eve; eve=BM_iter_step(&iter), i++) {
dvert= CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT);
- if(dvert) {
+ if (dvert) {
weights[i]= defvert_find_weight(dvert, defgrp_index);
}
}
}
else {
- for(i=0; i < totvert; i++, dvert++) {
+ for (i=0; i < totvert; i++, dvert++) {
weights[i]= defvert_find_weight(dvert, defgrp_index);
}
}
@@ -1108,12 +1109,12 @@ static void do_mesh_key(Scene *scene, Object *ob, Key *key, char *out, const int
float cfra, ctime, t[4], delta;
int a, flag = 0, step;
- if(key->slurph && key->type!=KEY_RELATIVE ) {
+ if (key->slurph && key->type!=KEY_RELATIVE ) {
delta= key->slurph;
delta/= tot;
step= 1;
- if(tot>100 && slurph_opt) {
+ if (tot>100 && slurph_opt) {
step= tot/50;
delta*= step;
/* in do_key and cp_key the case a>tot is handled */
@@ -1121,11 +1122,11 @@ static void do_mesh_key(Scene *scene, Object *ob, Key *key, char *out, const int
cfra= (float)scene->r.cfra;
- for(a=0; a<tot; a+=step, cfra+= delta) {
+ for (a=0; a<tot; a+=step, cfra+= delta) {
ctime= BKE_curframe(scene);
#if 0 // XXX old animation system
- if(calc_ipo_spec(key->ipo, KEY_SPEED, &ctime)==0) {
+ if (calc_ipo_spec(key->ipo, KEY_SPEED, &ctime)==0) {
ctime /= 100.0;
CLAMP(ctime, 0.0, 1.0);
}
@@ -1136,23 +1137,23 @@ static void do_mesh_key(Scene *scene, Object *ob, Key *key, char *out, const int
flag= setkeys(ctime, &key->block, k, t, 0);
- if(flag==0)
+ if (flag==0)
do_key(a, a+step, tot, (char *)out, key, actkb, k, t, KEY_MODE_DUMMY);
else
cp_key(a, a+step, tot, (char *)out, key, actkb, k[2], NULL, KEY_MODE_DUMMY);
}
}
else {
- if(key->type==KEY_RELATIVE) {
+ if (key->type==KEY_RELATIVE) {
KeyBlock *kb;
- for(kb= key->block.first; kb; kb= kb->next)
+ for (kb= key->block.first; kb; kb= kb->next)
kb->weights= get_weights_array(ob, kb->vgroup);
do_rel_key(0, tot, tot, (char *)out, key, actkb, KEY_MODE_DUMMY);
- for(kb= key->block.first; kb; kb= kb->next) {
- if(kb->weights) MEM_freeN(kb->weights);
+ for (kb= key->block.first; kb; kb= kb->next) {
+ if (kb->weights) MEM_freeN(kb->weights);
kb->weights= NULL;
}
}
@@ -1160,7 +1161,7 @@ static void do_mesh_key(Scene *scene, Object *ob, Key *key, char *out, const int
ctime= BKE_curframe(scene);
#if 0 // XXX old animation system
- if(calc_ipo_spec(key->ipo, KEY_SPEED, &ctime)==0) {
+ if (calc_ipo_spec(key->ipo, KEY_SPEED, &ctime)==0) {
ctime /= 100.0;
CLAMP(ctime, 0.0, 1.0);
}
@@ -1171,7 +1172,7 @@ static void do_mesh_key(Scene *scene, Object *ob, Key *key, char *out, const int
flag= setkeys(ctime, &key->block, k, t, 0);
- if(flag==0)
+ if (flag==0)
do_key(0, tot, tot, (char *)out, key, actkb, k, t, KEY_MODE_DUMMY);
else
cp_key(0, tot, tot, (char *)out, key, actkb, k[2], NULL, KEY_MODE_DUMMY);
@@ -1184,12 +1185,12 @@ static void do_cu_key(Curve *cu, Key *key, KeyBlock *actkb, KeyBlock **k, float
Nurb *nu;
int a, step;
- for(a=0, nu=cu->nurb.first; nu; nu=nu->next, a+=step) {
- if(nu->bp) {
+ for (a=0, nu=cu->nurb.first; nu; nu=nu->next, a+=step) {
+ if (nu->bp) {
step= nu->pntsu*nu->pntsv;
do_key(a, a+step, tot, out, key, actkb, k, t, KEY_MODE_BPOINT);
}
- else if(nu->bezt) {
+ else if (nu->bezt) {
step= 3*nu->pntsu;
do_key(a, a+step, tot, out, key, actkb, k, t, KEY_MODE_BEZTRIPLE);
}
@@ -1203,12 +1204,12 @@ static void do_rel_cu_key(Curve *cu, Key *key, KeyBlock *actkb, float UNUSED(cti
Nurb *nu;
int a, step;
- for(a=0, nu=cu->nurb.first; nu; nu=nu->next, a+=step) {
- if(nu->bp) {
+ for (a=0, nu=cu->nurb.first; nu; nu=nu->next, a+=step) {
+ if (nu->bp) {
step= nu->pntsu*nu->pntsv;
do_rel_key(a, a+step, tot, out, key, actkb, KEY_MODE_BPOINT);
}
- else if(nu->bezt) {
+ else if (nu->bezt) {
step= 3*nu->pntsu;
do_rel_key(a, a+step, tot, out, key, actkb, KEY_MODE_BEZTRIPLE);
}
@@ -1224,14 +1225,14 @@ static void do_curve_key(Scene *scene, Object *ob, Key *key, char *out, const in
float cfra, ctime, t[4], delta;
int a, flag = 0, step = 0;
- if(key->slurph && key->type!=KEY_RELATIVE) {
+ if (key->slurph && key->type!=KEY_RELATIVE) {
Nurb *nu;
int mode=0, i= 0, remain= 0, estep=0, count=0;
delta= (float)key->slurph / tot;
step= 1;
- if(tot>100 && slurph_opt) {
+ if (tot>100 && slurph_opt) {
step= tot/50;
delta*= step;
/* in do_key and cp_key the case a>tot has been handled */
@@ -1239,12 +1240,12 @@ static void do_curve_key(Scene *scene, Object *ob, Key *key, char *out, const in
cfra= (float)scene->r.cfra;
- for(nu=cu->nurb.first; nu; nu=nu->next) {
- if(nu->bp) {
+ for (nu=cu->nurb.first; nu; nu=nu->next) {
+ if (nu->bp) {
mode= KEY_MODE_BPOINT;
estep= nu->pntsu*nu->pntsv;
}
- else if(nu->bezt) {
+ else if (nu->bezt) {
mode= KEY_MODE_BEZTRIPLE;
estep= 3*nu->pntsu;
}
@@ -1269,7 +1270,7 @@ static void do_curve_key(Scene *scene, Object *ob, Key *key, char *out, const in
count += 3 - count % 3;
}
- if(flag==0)
+ if (flag==0)
do_key(i, i+count, tot, (char *)out, key, actkb, k, t, mode);
else
cp_key(i, i+count, tot, (char *)out, key, actkb, k[2], NULL, mode);
@@ -1284,12 +1285,12 @@ static void do_curve_key(Scene *scene, Object *ob, Key *key, char *out, const in
ctime= BKE_curframe(scene);
- if(key->type==KEY_RELATIVE) {
+ if (key->type==KEY_RELATIVE) {
do_rel_cu_key(cu, cu->key, actkb, ctime, out, tot);
}
else {
#if 0 // XXX old animation system
- if(calc_ipo_spec(key->ipo, KEY_SPEED, &ctime)==0) {
+ if (calc_ipo_spec(key->ipo, KEY_SPEED, &ctime)==0) {
ctime /= 100.0;
CLAMP(ctime, 0.0, 1.0);
}
@@ -1297,7 +1298,7 @@ static void do_curve_key(Scene *scene, Object *ob, Key *key, char *out, const in
flag= setkeys(ctime, &key->block, k, t, 0);
- if(flag==0) do_cu_key(cu, key, actkb, k, t, out, tot);
+ if (flag==0) do_cu_key(cu, key, actkb, k, t, out, tot);
else cp_cu_key(cu, key, actkb, k[2], 0, tot, out, tot);
}
}
@@ -1310,17 +1311,17 @@ static void do_latt_key(Scene *scene, Object *ob, Key *key, char *out, const int
float delta, cfra, ctime, t[4];
int a, flag;
- if(key->slurph) {
+ if (key->slurph) {
delta= key->slurph;
delta/= (float)tot;
cfra= (float)scene->r.cfra;
- for(a=0; a<tot; a++, cfra+= delta) {
+ for (a=0; a<tot; a++, cfra+= delta) {
ctime= BKE_curframe(scene);
#if 0 // XXX old animation system
- if(calc_ipo_spec(key->ipo, KEY_SPEED, &ctime)==0) {
+ if (calc_ipo_spec(key->ipo, KEY_SPEED, &ctime)==0) {
ctime /= 100.0;
CLAMP(ctime, 0.0, 1.0);
}
@@ -1328,23 +1329,23 @@ static void do_latt_key(Scene *scene, Object *ob, Key *key, char *out, const int
flag= setkeys(ctime, &key->block, k, t, 0);
- if(flag==0)
+ if (flag==0)
do_key(a, a+1, tot, out, key, actkb, k, t, KEY_MODE_DUMMY);
else
cp_key(a, a+1, tot, out, key, actkb, k[2], NULL, KEY_MODE_DUMMY);
}
}
else {
- if(key->type==KEY_RELATIVE) {
+ if (key->type==KEY_RELATIVE) {
KeyBlock *kb;
- for(kb= key->block.first; kb; kb= kb->next)
+ for (kb= key->block.first; kb; kb= kb->next)
kb->weights= get_weights_array(ob, kb->vgroup);
do_rel_key(0, tot, tot, out, key, actkb, KEY_MODE_DUMMY);
- for(kb= key->block.first; kb; kb= kb->next) {
- if(kb->weights) MEM_freeN(kb->weights);
+ for (kb= key->block.first; kb; kb= kb->next) {
+ if (kb->weights) MEM_freeN(kb->weights);
kb->weights= NULL;
}
}
@@ -1352,7 +1353,7 @@ static void do_latt_key(Scene *scene, Object *ob, Key *key, char *out, const int
ctime= BKE_curframe(scene);
#if 0 // XXX old animation system
- if(calc_ipo_spec(key->ipo, KEY_SPEED, &ctime)==0) {
+ if (calc_ipo_spec(key->ipo, KEY_SPEED, &ctime)==0) {
ctime /= 100.0;
CLAMP(ctime, 0.0, 1.0);
}
@@ -1360,14 +1361,14 @@ static void do_latt_key(Scene *scene, Object *ob, Key *key, char *out, const int
flag= setkeys(ctime, &key->block, k, t, 0);
- if(flag==0)
+ if (flag==0)
do_key(0, tot, tot, (char *)out, key, actkb, k, t, KEY_MODE_DUMMY);
else
cp_key(0, tot, tot, (char *)out, key, actkb, k[2], NULL, KEY_MODE_DUMMY);
}
}
- if(lt->flag & LT_OUTSIDE) outside_lattice(lt);
+ if (lt->flag & LT_OUTSIDE) outside_lattice(lt);
}
/* returns key coordinates (+ tilt) when key applied, NULL otherwise */
@@ -1378,32 +1379,32 @@ float *do_ob_key(Scene *scene, Object *ob)
char *out;
int tot= 0, size= 0;
- if(key==NULL || key->block.first==NULL)
+ if (key==NULL || key->block.first==NULL)
return NULL;
/* compute size of output array */
- if(ob->type == OB_MESH) {
+ if (ob->type == OB_MESH) {
Mesh *me= ob->data;
tot= me->totvert;
size= tot*3*sizeof(float);
}
- else if(ob->type == OB_LATTICE) {
+ else if (ob->type == OB_LATTICE) {
Lattice *lt= ob->data;
tot= lt->pntsu*lt->pntsv*lt->pntsw;
size= tot*3*sizeof(float);
}
- else if(ELEM(ob->type, OB_CURVE, OB_SURF)) {
+ else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
Curve *cu= ob->data;
Nurb *nu;
- for(nu=cu->nurb.first; nu; nu=nu->next) {
- if(nu->bezt) {
+ for (nu=cu->nurb.first; nu; nu=nu->next) {
+ if (nu->bezt) {
tot += 3*nu->pntsu;
size += nu->pntsu*12*sizeof(float);
}
- else if(nu->bp) {
+ else if (nu->bp) {
tot += nu->pntsu*nu->pntsv;
size += nu->pntsu*nu->pntsv*12*sizeof(float);
}
@@ -1411,7 +1412,7 @@ float *do_ob_key(Scene *scene, Object *ob)
}
/* if nothing to interpolate, cancel */
- if(tot == 0 || size == 0)
+ if (tot == 0 || size == 0)
return NULL;
/* allocate array */
@@ -1420,14 +1421,14 @@ float *do_ob_key(Scene *scene, Object *ob)
/* prevent python from screwing this up? anyhoo, the from pointer could be dropped */
key->from= (ID *)ob->data;
- if(ob->shapeflag & OB_SHAPE_LOCK) {
+ if (ob->shapeflag & OB_SHAPE_LOCK) {
/* shape locked, copy the locked shape instead of blending */
KeyBlock *kb= BLI_findlink(&key->block, ob->shapenr-1);
- if(kb && (kb->flag & KEYBLOCK_MUTE))
+ if (kb && (kb->flag & KEYBLOCK_MUTE))
kb= key->refkey;
- if(kb==NULL) {
+ if (kb==NULL) {
kb= key->block.first;
ob->shapenr= 1;
}
@@ -1437,9 +1438,9 @@ float *do_ob_key(Scene *scene, Object *ob)
cp_key(0, tot, tot, out, key, actkb, kb, weights, 0);
- if(weights) MEM_freeN(weights);
+ if (weights) MEM_freeN(weights);
}
- else if(ELEM(ob->type, OB_CURVE, OB_SURF))
+ else if (ELEM(ob->type, OB_CURVE, OB_SURF))
cp_cu_key(ob->data, key, actkb, kb, 0, tot, out, tot);
}
else {
@@ -1448,10 +1449,10 @@ float *do_ob_key(Scene *scene, Object *ob)
BKE_animsys_evaluate_animdata(scene, &key->id, key->adt, ctime, ADT_RECALC_DRIVERS);
- if(ob->type==OB_MESH) do_mesh_key(scene, ob, key, out, tot);
- else if(ob->type==OB_LATTICE) do_latt_key(scene, ob, key, out, tot);
- else if(ob->type==OB_CURVE) do_curve_key(scene, ob, key, out, tot);
- else if(ob->type==OB_SURF) do_curve_key(scene, ob, key, out, tot);
+ if (ob->type==OB_MESH) do_mesh_key(scene, ob, key, out, tot);
+ else if (ob->type==OB_LATTICE) do_latt_key(scene, ob, key, out, tot);
+ else if (ob->type==OB_CURVE) do_curve_key(scene, ob, key, out, tot);
+ else if (ob->type==OB_SURF) do_curve_key(scene, ob, key, out, tot);
}
return (float*)out;
@@ -1459,9 +1460,9 @@ float *do_ob_key(Scene *scene, Object *ob)
Key *ob_get_key(Object *ob)
{
- if(ob==NULL) return NULL;
+ if (ob==NULL) return NULL;
- if(ob->type==OB_MESH) {
+ if (ob->type==OB_MESH) {
Mesh *me= ob->data;
return me->key;
}
@@ -1469,7 +1470,7 @@ Key *ob_get_key(Object *ob)
Curve *cu= ob->data;
return cu->key;
}
- else if(ob->type==OB_LATTICE) {
+ else if (ob->type==OB_LATTICE) {
Lattice *lt= ob->data;
return lt->key;
}
@@ -1483,17 +1484,18 @@ KeyBlock *add_keyblock(Key *key, const char *name)
int tot;
kb= key->block.last;
- if(kb) curpos= kb->pos;
+ if (kb) curpos= kb->pos;
kb= MEM_callocN(sizeof(KeyBlock), "Keyblock");
BLI_addtail(&key->block, kb);
kb->type= KEY_CARDINAL;
tot= BLI_countlist(&key->block);
- if(name) {
+ if (name) {
BLI_strncpy(kb->name, name, sizeof(kb->name));
- } else {
- if(tot==1) BLI_strncpy(kb->name, "Basis", sizeof(kb->name));
+ }
+ else {
+ if (tot==1) BLI_strncpy(kb->name, "Basis", sizeof(kb->name));
else BLI_snprintf(kb->name, sizeof(kb->name), "Key %d", tot-1);
}
@@ -1504,18 +1506,18 @@ KeyBlock *add_keyblock(Key *key, const char *name)
kb->uid = key->uidgen++;
key->totkey++;
- if(key->totkey==1) key->refkey= kb;
+ if (key->totkey==1) key->refkey= kb;
kb->slidermin= 0.0f;
kb->slidermax= 1.0f;
// XXX kb->pos is the confusing old horizontal-line RVK crap in old IPO Editor...
- if(key->type == KEY_RELATIVE)
+ if (key->type == KEY_RELATIVE)
kb->pos= curpos + 0.1f;
else {
#if 0 // XXX old animation system
curpos= BKE_curframe(scene);
- if(calc_ipo_spec(key->ipo, KEY_SPEED, &curpos)==0) {
+ if (calc_ipo_spec(key->ipo, KEY_SPEED, &curpos)==0) {
curpos /= 100.0;
}
kb->pos= curpos;
@@ -1610,16 +1612,16 @@ void latt_to_key(Lattice *lt, KeyBlock *kb)
int a, tot;
tot= lt->pntsu*lt->pntsv*lt->pntsw;
- if(tot==0) return;
+ if (tot==0) return;
- if(kb->data) MEM_freeN(kb->data);
+ if (kb->data) MEM_freeN(kb->data);
kb->data= MEM_callocN(lt->key->elemsize*tot, "kb->data");
kb->totelem= tot;
bp= lt->def;
fp= kb->data;
- for(a=0; a<kb->totelem; a++, fp+=3, bp++) {
+ for (a=0; a<kb->totelem; a++, fp+=3, bp++) {
copy_v3_v3(fp, bp->vec);
}
}
@@ -1636,7 +1638,7 @@ void key_to_latt(KeyBlock *kb, Lattice *lt)
tot= lt->pntsu*lt->pntsv*lt->pntsw;
tot= MIN2(kb->totelem, tot);
- for(a=0; a<tot; a++, fp+=3, bp++) {
+ for (a=0; a<tot; a++, fp+=3, bp++) {
copy_v3_v3(bp->vec, fp);
}
}
@@ -1652,21 +1654,21 @@ void curve_to_key(Curve *cu, KeyBlock *kb, ListBase *nurb)
/* count */
tot= count_curveverts(nurb);
- if(tot==0) return;
+ if (tot==0) return;
- if(kb->data) MEM_freeN(kb->data);
+ if (kb->data) MEM_freeN(kb->data);
kb->data= MEM_callocN(cu->key->elemsize*tot, "kb->data");
kb->totelem= tot;
nu= nurb->first;
fp= kb->data;
- while(nu) {
+ while (nu) {
- if(nu->bezt) {
+ if (nu->bezt) {
bezt= nu->bezt;
a= nu->pntsu;
- while(a--) {
+ while (a--) {
copy_v3_v3(fp, bezt->vec[0]);
fp+= 3;
copy_v3_v3(fp, bezt->vec[1]);
@@ -1681,7 +1683,7 @@ void curve_to_key(Curve *cu, KeyBlock *kb, ListBase *nurb)
else {
bp= nu->bp;
a= nu->pntsu*nu->pntsv;
- while(a--) {
+ while (a--) {
copy_v3_v3(fp, bp->vec);
fp[3]= bp->alfa;
@@ -1708,12 +1710,12 @@ void key_to_curve(KeyBlock *kb, Curve *UNUSED(cu), ListBase *nurb)
tot= MIN2(kb->totelem, tot);
- while(nu && tot>0) {
+ while (nu && tot>0) {
- if(nu->bezt) {
+ if (nu->bezt) {
bezt= nu->bezt;
a= nu->pntsu;
- while(a-- && tot>0) {
+ while (a-- && tot>0) {
copy_v3_v3(bezt->vec[0], fp);
fp+= 3;
copy_v3_v3(bezt->vec[1], fp);
@@ -1730,7 +1732,7 @@ void key_to_curve(KeyBlock *kb, Curve *UNUSED(cu), ListBase *nurb)
else {
bp= nu->bp;
a= nu->pntsu*nu->pntsv;
- while(a-- && tot>0) {
+ while (a-- && tot>0) {
copy_v3_v3(bp->vec, fp);
bp->alfa= fp[3];
@@ -1750,16 +1752,16 @@ void mesh_to_key(Mesh *me, KeyBlock *kb)
float *fp;
int a;
- if(me->totvert==0) return;
+ if (me->totvert==0) return;
- if(kb->data) MEM_freeN(kb->data);
+ if (kb->data) MEM_freeN(kb->data);
kb->data= MEM_callocN(me->key->elemsize*me->totvert, "kb->data");
kb->totelem= me->totvert;
mvert= me->mvert;
fp= kb->data;
- for(a=0; a<kb->totelem; a++, fp+=3, mvert++) {
+ for (a=0; a<kb->totelem; a++, fp+=3, mvert++) {
copy_v3_v3(fp, mvert->co);
}
@@ -1776,7 +1778,7 @@ void key_to_mesh(KeyBlock *kb, Mesh *me)
tot= MIN2(kb->totelem, me->totvert);
- for(a=0; a<tot; a++, fp+=3, mvert++) {
+ for (a=0; a<tot; a++, fp+=3, mvert++) {
copy_v3_v3(mvert->co, fp);
}
}
@@ -1789,13 +1791,15 @@ float (*key_to_vertcos(Object *ob, KeyBlock *kb))[3]
int tot= 0, a;
/* Count of vertex coords in array */
- if(ob->type == OB_MESH) {
+ if (ob->type == OB_MESH) {
Mesh *me= (Mesh*)ob->data;
tot= me->totvert;
- } else if(ob->type == OB_LATTICE) {
+ }
+ else if (ob->type == OB_LATTICE) {
Lattice *lt= (Lattice*)ob->data;
tot= lt->pntsu*lt->pntsv*lt->pntsw;
- } else if(ELEM(ob->type, OB_CURVE, OB_SURF)) {
+ }
+ else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
Curve *cu= (Curve*)ob->data;
tot= count_curveverts(&cu->nurb);
}
@@ -1807,18 +1811,19 @@ float (*key_to_vertcos(Object *ob, KeyBlock *kb))[3]
/* Copy coords to array */
co= (float*)vertCos;
- if(ELEM(ob->type, OB_MESH, OB_LATTICE)) {
+ if (ELEM(ob->type, OB_MESH, OB_LATTICE)) {
for (a= 0; a<tot; a++, fp+=3, co+=3) {
copy_v3_v3(co, fp);
}
- } else if(ELEM(ob->type, OB_CURVE, OB_SURF)) {
+ }
+ else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
Curve *cu= (Curve*)ob->data;
Nurb *nu= cu->nurb.first;
BezTriple *bezt;
BPoint *bp;
while (nu) {
- if(nu->bezt) {
+ if (nu->bezt) {
int i;
bezt= nu->bezt;
a= nu->pntsu;
@@ -1863,15 +1868,17 @@ void vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3])
if (kb->data) MEM_freeN(kb->data);
/* Count of vertex coords in array */
- if(ob->type == OB_MESH) {
+ if (ob->type == OB_MESH) {
Mesh *me= (Mesh*)ob->data;
tot= me->totvert;
elemsize= me->key->elemsize;
- } else if(ob->type == OB_LATTICE) {
+ }
+ else if (ob->type == OB_LATTICE) {
Lattice *lt= (Lattice*)ob->data;
tot= lt->pntsu*lt->pntsv*lt->pntsw;
elemsize= lt->key->elemsize;
- } else if(ELEM(ob->type, OB_CURVE, OB_SURF)) {
+ }
+ else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
Curve *cu= (Curve*)ob->data;
elemsize= cu->key->elemsize;
tot= count_curveverts(&cu->nurb);
@@ -1886,18 +1893,19 @@ void vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3])
/* Copy coords to keyblock */
- if(ELEM(ob->type, OB_MESH, OB_LATTICE)) {
+ if (ELEM(ob->type, OB_MESH, OB_LATTICE)) {
for (a= 0; a<tot; a++, fp+=3, co+=3) {
copy_v3_v3(fp, co);
}
- } else if(ELEM(ob->type, OB_CURVE, OB_SURF)) {
+ }
+ else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
Curve *cu= (Curve*)ob->data;
Nurb *nu= cu->nurb.first;
BezTriple *bezt;
BPoint *bp;
while (nu) {
- if(nu->bezt) {
+ if (nu->bezt) {
int i;
bezt= nu->bezt;
a= nu->pntsu;
@@ -1937,18 +1945,19 @@ void offset_to_key(Object *ob, KeyBlock *kb, float (*ofs)[3])
int a;
float *co= (float*)ofs, *fp= kb->data;
- if(ELEM(ob->type, OB_MESH, OB_LATTICE)) {
+ if (ELEM(ob->type, OB_MESH, OB_LATTICE)) {
for (a= 0; a<kb->totelem; a++, fp+=3, co+=3) {
add_v3_v3(fp, co);
}
- } else if(ELEM(ob->type, OB_CURVE, OB_SURF)) {
+ }
+ else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
Curve *cu= (Curve*)ob->data;
Nurb *nu= cu->nurb.first;
BezTriple *bezt;
BPoint *bp;
while (nu) {
- if(nu->bezt) {
+ if (nu->bezt) {
int i;
bezt= nu->bezt;
a= nu->pntsu;
diff --git a/source/blender/blenkernel/intern/lamp.c b/source/blender/blenkernel/intern/lamp.c
index 4e4dca51e7d..e981d772df6 100644
--- a/source/blender/blenkernel/intern/lamp.c
+++ b/source/blender/blenkernel/intern/lamp.c
@@ -108,8 +108,8 @@ Lamp *copy_lamp(Lamp *la)
lan= copy_libblock(&la->id);
- for(a=0; a<MAX_MTEX; a++) {
- if(lan->mtex[a]) {
+ for (a=0; a<MAX_MTEX; a++) {
+ if (lan->mtex[a]) {
lan->mtex[a]= MEM_mallocN(sizeof(MTex), "copylamptex");
memcpy(lan->mtex[a], la->mtex[a], sizeof(MTex));
id_us_plus((ID *)lan->mtex[a]->tex);
@@ -118,10 +118,10 @@ Lamp *copy_lamp(Lamp *la)
lan->curfalloff = curvemapping_copy(la->curfalloff);
- if(la->nodetree)
+ if (la->nodetree)
lan->nodetree= ntreeCopyTree(la->nodetree);
- if(la->preview)
+ if (la->preview)
lan->preview = BKE_previewimg_copy(la->preview);
return lan;
@@ -135,8 +135,8 @@ Lamp *localize_lamp(Lamp *la)
lan= copy_libblock(&la->id);
BLI_remlink(&G.main->lamp, lan);
- for(a=0; a<MAX_MTEX; a++) {
- if(lan->mtex[a]) {
+ for (a=0; a<MAX_MTEX; a++) {
+ if (lan->mtex[a]) {
lan->mtex[a]= MEM_mallocN(sizeof(MTex), "localize_lamp");
memcpy(lan->mtex[a], la->mtex[a], sizeof(MTex));
/* free lamp decrements */
@@ -146,7 +146,7 @@ Lamp *localize_lamp(Lamp *la)
lan->curfalloff = curvemapping_copy(la->curfalloff);
- if(la->nodetree)
+ if (la->nodetree)
lan->nodetree= ntreeLocalize(la->nodetree);
lan->preview= NULL;
@@ -165,25 +165,25 @@ void make_local_lamp(Lamp *la)
* - mixed: make copy
*/
- if(la->id.lib==NULL) return;
- if(la->id.us==1) {
+ if (la->id.lib==NULL) return;
+ if (la->id.us==1) {
id_clear_lib_data(bmain, &la->id);
return;
}
ob= bmain->object.first;
- while(ob) {
- if(ob->data==la) {
- if(ob->id.lib) is_lib= TRUE;
+ while (ob) {
+ if (ob->data==la) {
+ if (ob->id.lib) is_lib= TRUE;
else is_local= TRUE;
}
ob= ob->id.next;
}
- if(is_local && is_lib == FALSE) {
+ if (is_local && is_lib == FALSE) {
id_clear_lib_data(bmain, &la->id);
}
- else if(is_local && is_lib) {
+ else if (is_local && is_lib) {
Lamp *la_new= copy_lamp(la);
la_new->id.us= 0;
@@ -191,10 +191,10 @@ void make_local_lamp(Lamp *la)
BKE_id_lib_local_paths(bmain, la->id.lib, &la_new->id);
ob= bmain->object.first;
- while(ob) {
- if(ob->data==la) {
+ while (ob) {
+ if (ob->data==la) {
- if(ob->id.lib==NULL) {
+ if (ob->id.lib==NULL) {
ob->data= la_new;
la_new->id.us++;
la->id.us--;
@@ -210,10 +210,10 @@ void free_lamp(Lamp *la)
MTex *mtex;
int a;
- for(a=0; a<MAX_MTEX; a++) {
+ for (a=0; a<MAX_MTEX; a++) {
mtex= la->mtex[a];
- if(mtex && mtex->tex) mtex->tex->id.us--;
- if(mtex) MEM_freeN(mtex);
+ if (mtex && mtex->tex) mtex->tex->id.us--;
+ if (mtex) MEM_freeN(mtex);
}
BKE_free_animdata((ID *)la);
@@ -221,7 +221,7 @@ void free_lamp(Lamp *la)
curvemapping_free(la->curfalloff);
/* is no lib link block, but lamp extension */
- if(la->nodetree) {
+ if (la->nodetree) {
ntreeFreeTree(la->nodetree);
MEM_freeN(la->nodetree);
}
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c
index 0cddd978263..b1513954667 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -96,7 +96,7 @@ void resizelattice(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb)
lt->dvert= NULL;
}
- while(uNew*vNew*wNew > 32000) {
+ while (uNew*vNew*wNew > 32000) {
if ( uNew>=vNew && uNew>=wNew) uNew--;
else if ( vNew>=uNew && vNew>=wNew) vNew--;
else wNew--;
@@ -329,7 +329,8 @@ void init_latt_deform(Object *oblatt, Object *ob)
fp[0] = co[0] - fu;
fp[1] = co[1] - fv;
fp[2] = co[2] - fw;
- } else {
+ }
+ else {
fp[0] = bp->vec[0] - fu;
fp[1] = bp->vec[1] - fv;
fp[2] = bp->vec[2] - fw;
@@ -661,8 +662,10 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target,
use_vgroups = 0;
else
use_vgroups = 1;
- } else
+ }
+ else {
use_vgroups = 0;
+ }
if (vgroup && vgroup[0] && use_vgroups) {
Mesh *me= target->data;
@@ -802,8 +805,10 @@ void lattice_deform_verts(Object *laOb, Object *target, DerivedMesh *dm,
use_vgroups = 0;
else
use_vgroups = 1;
- } else
+ }
+ else {
use_vgroups = 0;
+ }
if (vgroup && vgroup[0] && use_vgroups) {
Mesh *me = target->data;
@@ -822,7 +827,8 @@ void lattice_deform_verts(Object *laOb, Object *target, DerivedMesh *dm,
calc_latt_deform(laOb, vertexCos[a], weight);
}
}
- } else {
+ }
+ else {
for (a = 0; a < numVerts; a++) {
calc_latt_deform(laOb, vertexCos[a], 1.0f);
}
@@ -841,7 +847,8 @@ int object_deform_mball(Object *ob, ListBase *dispbase)
}
return 1;
- } else {
+ }
+ else {
return 0;
}
}
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index 3bfccea4780..eb28e9f641a 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -143,8 +143,8 @@ void BKE_id_lib_local_paths(Main *bmain, Library *lib, ID *id)
void id_lib_extern(ID *id)
{
- if(id) {
- if(id->flag & LIB_INDIRECT) {
+ if (id) {
+ if (id->flag & LIB_INDIRECT) {
id->flag -= LIB_INDIRECT;
id->flag |= LIB_EXTERN;
}
@@ -153,9 +153,9 @@ void id_lib_extern(ID *id)
void id_us_plus(ID *id)
{
- if(id) {
+ if (id) {
id->us++;
- if(id->flag & LIB_INDIRECT) {
+ if (id->flag & LIB_INDIRECT) {
id->flag -= LIB_INDIRECT;
id->flag |= LIB_EXTERN;
}
@@ -164,10 +164,10 @@ void id_us_plus(ID *id)
void id_us_min(ID *id)
{
- if(id) {
- if(id->us<2 && (id->flag & LIB_FAKEUSER))
+ if (id) {
+ if (id->us<2 && (id->flag & LIB_FAKEUSER))
id->us= 1;
- else if(id->us<=0)
+ else if (id->us<=0)
printf("ID user decrement error: %s \n", id->name);
else
id->us--;
@@ -176,7 +176,7 @@ void id_us_min(ID *id)
int id_make_local(ID *id, int test)
{
- if(id->flag & LIB_INDIRECT)
+ if (id->flag & LIB_INDIRECT)
return 0;
switch(GS(id->name)) {
@@ -185,54 +185,54 @@ int id_make_local(ID *id, int test)
case ID_LI:
return 0; /* can't be linked */
case ID_OB:
- if(!test) make_local_object((Object*)id);
+ if (!test) make_local_object((Object*)id);
return 1;
case ID_ME:
- if(!test) {
+ if (!test) {
make_local_mesh((Mesh*)id);
make_local_key(((Mesh*)id)->key);
}
return 1;
case ID_CU:
- if(!test) {
+ if (!test) {
make_local_curve((Curve*)id);
make_local_key(((Curve*)id)->key);
}
return 1;
case ID_MB:
- if(!test) make_local_mball((MetaBall*)id);
+ if (!test) make_local_mball((MetaBall*)id);
return 1;
case ID_MA:
- if(!test) make_local_material((Material*)id);
+ if (!test) make_local_material((Material*)id);
return 1;
case ID_TE:
- if(!test) make_local_texture((Tex*)id);
+ if (!test) make_local_texture((Tex*)id);
return 1;
case ID_IM:
- if(!test) make_local_image((Image*)id);
+ if (!test) make_local_image((Image*)id);
return 1;
case ID_LT:
- if(!test) {
+ if (!test) {
make_local_lattice((Lattice*)id);
make_local_key(((Lattice*)id)->key);
}
return 1;
case ID_LA:
- if(!test) make_local_lamp((Lamp*)id);
+ if (!test) make_local_lamp((Lamp*)id);
return 1;
case ID_CA:
- if(!test) make_local_camera((Camera*)id);
+ if (!test) make_local_camera((Camera*)id);
return 1;
case ID_SPK:
- if(!test) make_local_speaker((Speaker*)id);
+ if (!test) make_local_speaker((Speaker*)id);
return 1;
case ID_IP:
return 0; /* deprecated */
case ID_KE:
- if(!test) make_local_key((Key*)id);
+ if (!test) make_local_key((Key*)id);
return 1;
case ID_WO:
- if(!test) make_local_world((World*)id);
+ if (!test) make_local_world((World*)id);
return 1;
case ID_SCR:
return 0; /* can't be linked */
@@ -247,18 +247,18 @@ int id_make_local(ID *id, int test)
case ID_GR:
return 0; /* not implemented */
case ID_AR:
- if(!test) make_local_armature((bArmature*)id);
+ if (!test) make_local_armature((bArmature*)id);
return 1;
case ID_AC:
- if(!test) make_local_action((bAction*)id);
+ if (!test) make_local_action((bAction*)id);
return 1;
case ID_NT:
return 0; /* not implemented */
case ID_BR:
- if(!test) make_local_brush((Brush*)id);
+ if (!test) make_local_brush((Brush*)id);
return 1;
case ID_PA:
- if(!test) make_local_particlesettings((ParticleSettings*)id);
+ if (!test) make_local_particlesettings((ParticleSettings*)id);
return 1;
case ID_WM:
return 0; /* can't be linked */
@@ -271,7 +271,7 @@ int id_make_local(ID *id, int test)
int id_copy(ID *id, ID **newid, int test)
{
- if(!test) *newid= NULL;
+ if (!test) *newid= NULL;
/* conventions:
* - make shallow copy, only this ID block
@@ -282,74 +282,74 @@ int id_copy(ID *id, ID **newid, int test)
case ID_LI:
return 0; /* can't be copied from here */
case ID_OB:
- if(!test) *newid= (ID*)copy_object((Object*)id);
+ if (!test) *newid= (ID*)copy_object((Object*)id);
return 1;
case ID_ME:
- if(!test) *newid= (ID*)copy_mesh((Mesh*)id);
+ if (!test) *newid= (ID*)copy_mesh((Mesh*)id);
return 1;
case ID_CU:
- if(!test) *newid= (ID*)copy_curve((Curve*)id);
+ if (!test) *newid= (ID*)copy_curve((Curve*)id);
return 1;
case ID_MB:
- if(!test) *newid= (ID*)copy_mball((MetaBall*)id);
+ if (!test) *newid= (ID*)copy_mball((MetaBall*)id);
return 1;
case ID_MA:
- if(!test) *newid= (ID*)copy_material((Material*)id);
+ if (!test) *newid= (ID*)copy_material((Material*)id);
return 1;
case ID_TE:
- if(!test) *newid= (ID*)copy_texture((Tex*)id);
+ if (!test) *newid= (ID*)copy_texture((Tex*)id);
return 1;
case ID_IM:
- if(!test) *newid= (ID*)copy_image((Image*)id);
+ if (!test) *newid= (ID*)copy_image((Image*)id);
return 1;
case ID_LT:
- if(!test) *newid= (ID*)copy_lattice((Lattice*)id);
+ if (!test) *newid= (ID*)copy_lattice((Lattice*)id);
return 1;
case ID_LA:
- if(!test) *newid= (ID*)copy_lamp((Lamp*)id);
+ if (!test) *newid= (ID*)copy_lamp((Lamp*)id);
return 1;
case ID_SPK:
- if(!test) *newid= (ID*)copy_speaker((Speaker*)id);
+ if (!test) *newid= (ID*)copy_speaker((Speaker*)id);
return 1;
case ID_CA:
- if(!test) *newid= (ID*)copy_camera((Camera*)id);
+ if (!test) *newid= (ID*)copy_camera((Camera*)id);
return 1;
case ID_IP:
return 0; /* deprecated */
case ID_KE:
- if(!test) *newid= (ID*)copy_key((Key*)id);
+ if (!test) *newid= (ID*)copy_key((Key*)id);
return 1;
case ID_WO:
- if(!test) *newid= (ID*)copy_world((World*)id);
+ if (!test) *newid= (ID*)copy_world((World*)id);
return 1;
case ID_SCR:
return 0; /* can't be copied from here */
case ID_VF:
return 0; /* not implemented */
case ID_TXT:
- if(!test) *newid= (ID*)copy_text((Text*)id);
+ if (!test) *newid= (ID*)copy_text((Text*)id);
return 1;
case ID_SCRIPT:
return 0; /* deprecated */
case ID_SO:
return 0; /* not implemented */
case ID_GR:
- if(!test) *newid= (ID*)copy_group((Group*)id);
+ if (!test) *newid= (ID*)copy_group((Group*)id);
return 1;
case ID_AR:
- if(!test) *newid= (ID*)copy_armature((bArmature*)id);
+ if (!test) *newid= (ID*)copy_armature((bArmature*)id);
return 1;
case ID_AC:
- if(!test) *newid= (ID*)copy_action((bAction*)id);
+ if (!test) *newid= (ID*)copy_action((bAction*)id);
return 1;
case ID_NT:
- if(!test) *newid= (ID*)ntreeCopyTree((bNodeTree*)id);
+ if (!test) *newid= (ID*)ntreeCopyTree((bNodeTree*)id);
return 1;
case ID_BR:
- if(!test) *newid= (ID*)copy_brush((Brush*)id);
+ if (!test) *newid= (ID*)copy_brush((Brush*)id);
return 1;
case ID_PA:
- if(!test) *newid= (ID*)psys_copy_settings((ParticleSettings*)id);
+ if (!test) *newid= (ID*)psys_copy_settings((ParticleSettings*)id);
return 1;
case ID_WM:
return 0; /* can't be copied from here */
@@ -367,21 +367,21 @@ int id_unlink(ID *id, int test)
switch(GS(id->name)) {
case ID_TXT:
- if(test) return 1;
+ if (test) return 1;
unlink_text(mainlib, (Text*)id);
break;
case ID_GR:
- if(test) return 1;
+ if (test) return 1;
unlink_group((Group*)id);
break;
case ID_OB:
- if(test) return 1;
+ if (test) return 1;
unlink_object((Object*)id);
break;
}
- if(id->us == 0) {
- if(test) return 1;
+ if (id->us == 0) {
+ if (test) return 1;
lb= which_libbase(mainlib, GS(id->name));
free_libblock(lb, id);
@@ -492,10 +492,11 @@ void flag_listbase_ids(ListBase *lb, short flag, short value)
{
ID *id;
if (value) {
- for(id= lb->first; id; id= id->next) id->flag |= flag;
- } else {
+ for (id= lb->first; id; id= id->next) id->flag |= flag;
+ }
+ else {
flag = ~flag;
- for(id= lb->first; id; id= id->next) id->flag &= flag;
+ for (id= lb->first; id; id= id->next) id->flag &= flag;
}
}
@@ -505,7 +506,7 @@ void flag_all_listbases_ids(short flag, short value)
ListBase *lbarray[MAX_LIBARRAY];
int a;
a= set_listbasepointers(G.main, lbarray);
- while(a--) flag_listbase_ids(lbarray[a], flag, value);
+ while (a--) flag_listbase_ids(lbarray[a], flag, value);
}
void recalc_all_library_objects(Main *main)
@@ -513,8 +514,8 @@ void recalc_all_library_objects(Main *main)
Object *ob;
/* flag for full recalc */
- for(ob=main->object.first; ob; ob=ob->id.next)
- if(ob->id.lib)
+ for (ob=main->object.first; ob; ob=ob->id.next)
+ if (ob->id.lib)
ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME;
}
@@ -686,7 +687,7 @@ void *alloc_libblock(ListBase *lb, short type, const char *name)
ID *id= NULL;
id= alloc_libblock_notest(type);
- if(id) {
+ if (id) {
BLI_addtail(lb, id);
id->us= 1;
id->icon_id = 0;
@@ -732,7 +733,7 @@ void *copy_libblock(ID *id)
assert(idn != NULL);
idn_len= MEM_allocN_len(idn);
- if((int)idn_len - (int)sizeof(ID) > 0) { /* signed to allow neg result */
+ if ((int)idn_len - (int)sizeof(ID) > 0) { /* signed to allow neg result */
const char *cp= (const char *)id;
char *cpn= (char *)idn;
@@ -875,7 +876,7 @@ void free_libblock(ListBase *lb, void *idv)
psys_free_settings((ParticleSettings *)id);
break;
case ID_WM:
- if(free_windowmanager_cb)
+ if (free_windowmanager_cb)
free_windowmanager_cb(NULL, (wmWindowManager *)id);
break;
case ID_GD:
@@ -905,12 +906,12 @@ void free_libblock_us(ListBase *lb, void *idv) /* test users */
id->us--;
- if(id->us<0) {
- if(id->lib) printf("ERROR block %s %s users %d\n", id->lib->name, id->name, id->us);
+ if (id->us<0) {
+ if (id->lib) printf("ERROR block %s %s users %d\n", id->lib->name, id->name, id->us);
else printf("ERROR block %s users %d\n", id->name, id->us);
}
- if(id->us==0) {
- if( GS(id->name)==ID_OB ) unlink_object((Object *)id);
+ if (id->us==0) {
+ if ( GS(id->name)==ID_OB ) unlink_object((Object *)id);
free_libblock(lb, id);
}
@@ -924,7 +925,7 @@ void free_main(Main *mainvar)
int a;
a= set_listbasepointers(mainvar, lbarray);
- while(a--) {
+ while (a--) {
ListBase *lb= lbarray[a];
ID *id;
@@ -956,16 +957,16 @@ static void get_flags_for_id(ID *id, char *buf)
* to have that explicit, oh well - zr
*/
- if(GS(id->name)==ID_MA)
+ if (GS(id->name)==ID_MA)
isnode= ((Material *)id)->use_nodes;
- if(GS(id->name)==ID_TE)
+ if (GS(id->name)==ID_TE)
isnode= ((Tex *)id)->use_nodes;
if (id->us<0)
strcpy(buf, "-1W ");
else if (!id->lib && !isfake && id->us && !isnode)
strcpy(buf, " ");
- else if(isnode)
+ else if (isnode)
sprintf(buf, "%c%cN%c ", id->lib?'L':' ', isfake?'F':' ', (id->us==0)?'O':' ');
else
sprintf(buf, "%c%c%c ", id->lib?'L':' ', isfake?'F':' ', (id->us==0)?'O':' ');
@@ -982,7 +983,8 @@ static void IDnames_to_dyn_pupstring(DynStr *pupds, ListBase *lb, ID *link, shor
if (nr && nids>MAX_IDPUP) {
BLI_dynstr_append(pupds, "DataBrowse %x-2");
*nr= -2;
- } else {
+ }
+ else {
ID *id;
for (i=0, id= lb->first; id; id= id->next, i++) {
@@ -1019,7 +1021,7 @@ static void IDnames_to_dyn_pupstring(DynStr *pupds, ListBase *lb, ID *link, shor
break;
}
- if(id->next)
+ if (id->next)
BLI_dynstr_append(pupds, "|");
}
}
@@ -1076,19 +1078,19 @@ static void sort_alpha_id(ListBase *lb, ID *id)
ID *idtest;
/* insert alphabetically */
- if(lb->first!=lb->last) {
+ if (lb->first!=lb->last) {
BLI_remlink(lb, id);
idtest= lb->first;
- while(idtest) {
- if(BLI_strcasecmp(idtest->name, id->name)>0 || idtest->lib) {
+ while (idtest) {
+ if (BLI_strcasecmp(idtest->name, id->name)>0 || idtest->lib) {
BLI_insertlinkbefore(lb, idtest, id);
break;
}
idtest= idtest->next;
}
/* as last */
- if(idtest==NULL) {
+ if (idtest==NULL) {
BLI_addtail(lb, id);
}
}
@@ -1103,13 +1105,13 @@ static ID *is_dupid(ListBase *lb, ID *id, const char *name)
{
ID *idtest=NULL;
- for( idtest = lb->first; idtest; idtest = idtest->next ) {
+ for ( idtest = lb->first; idtest; idtest = idtest->next ) {
/* if idtest is not a lib */
- if( id != idtest && idtest->lib == NULL ) {
+ if ( id != idtest && idtest->lib == NULL ) {
/* do not test alphabetic! */
/* optimized */
- if( idtest->name[2] == name[0] ) {
- if(strcmp(name, idtest->name+2)==0) break;
+ if ( idtest->name[2] == name[0] ) {
+ if (strcmp(name, idtest->name+2)==0) break;
}
}
}
@@ -1145,7 +1147,7 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name)
idtest = is_dupid(lb, id, name);
/* if there is no double, done */
- if( idtest == NULL ) return 0;
+ if ( idtest == NULL ) return 0;
/* we have a dup; need to make a new name */
/* quick check so we can reuse one of first 64 ids if vacant */
@@ -1155,33 +1157,33 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name)
left_len= BLI_split_name_num(left, &nr, name, '.');
/* if new name will be too long, truncate it */
- if(nr > 999 && left_len > (MAX_ID_NAME - 8)) {
+ if (nr > 999 && left_len > (MAX_ID_NAME - 8)) {
left[MAX_ID_NAME - 8]= 0;
left_len= MAX_ID_NAME - 8;
}
- else if(left_len > (MAX_ID_NAME - 7)) {
+ else if (left_len > (MAX_ID_NAME - 7)) {
left[MAX_ID_NAME - 7]= 0;
left_len= MAX_ID_NAME - 7;
}
- for(idtest= lb->first; idtest; idtest= idtest->next) {
- if( (id != idtest) &&
+ for (idtest= lb->first; idtest; idtest= idtest->next) {
+ if ( (id != idtest) &&
(idtest->lib == NULL) &&
(*name == *(idtest->name+2)) &&
(strncmp(name, idtest->name+2, left_len)==0) &&
(BLI_split_name_num(leftest, &nrtest, idtest->name+2, '.') == left_len)
) {
- if(nrtest < sizeof(in_use))
+ if (nrtest < sizeof(in_use))
in_use[nrtest]= 1; /* mark as used */
- if(nr <= nrtest)
+ if (nr <= nrtest)
nr= nrtest+1; /* track largest unused */
}
}
/* decide which value of nr to use */
- for(a=0; a < sizeof(in_use); a++) {
- if(a>=nr) break; /* stop when we've check up to biggest */
- if( in_use[a]==0 ) { /* found an unused value */
+ for (a=0; a < sizeof(in_use); a++) {
+ if (a>=nr) break; /* stop when we've check up to biggest */
+ if ( in_use[a]==0 ) { /* found an unused value */
nr = a;
break;
}
@@ -1203,7 +1205,7 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name)
/* otherwise just continue and use a number suffix */
}
- if(nr > 999 && left_len > (MAX_ID_NAME - 8)) {
+ if (nr > 999 && left_len > (MAX_ID_NAME - 8)) {
/* this would overflow name buffer */
left[MAX_ID_NAME - 8] = 0;
/* left_len = MAX_ID_NAME - 8; */ /* for now this isn't used again */
@@ -1230,14 +1232,14 @@ int new_id(ListBase *lb, ID *id, const char *tname)
char name[MAX_ID_NAME-2];
/* if library, don't rename */
- if(id->lib) return 0;
+ if (id->lib) return 0;
/* if no libdata given, look up based on ID */
- if(lb==NULL) lb= which_libbase(G.main, GS(id->name));
+ if (lb==NULL) lb= which_libbase(G.main, GS(id->name));
/* if no name given, use name of current ID
* else make a copy (tname args can be const) */
- if(tname==NULL)
+ if (tname==NULL)
tname= id->name+2;
strncpy(name, tname, sizeof(name)-1);
@@ -1246,7 +1248,7 @@ int new_id(ListBase *lb, ID *id, const char *tname)
* easier to assign each time then to check if its needed */
name[sizeof(name)-1]= 0;
- if(name[0] == '\0') {
+ if (name[0] == '\0') {
/* disallow empty names */
strcpy(name, ID_FALLBACK_NAME);
}
@@ -1264,7 +1266,7 @@ int new_id(ListBase *lb, ID *id, const char *tname)
* sorting should not hurt, but noting just incause it alters the way other
* functions work, so sort every time */
#if 0
- if( result )
+ if ( result )
sort_alpha_id(lb, id);
#endif
@@ -1292,9 +1294,9 @@ void clear_id_newpoins(void)
int a;
a= set_listbasepointers(G.main, lbarray);
- while(a--) {
+ while (a--) {
id= lbarray[a]->first;
- while(id) {
+ while (id) {
id->newid= NULL;
id->flag &= ~LIB_NEW;
id= id->next;
@@ -1302,21 +1304,21 @@ void clear_id_newpoins(void)
}
}
-#define LIBTAG(a) if(a && a->id.lib) {a->id.flag &=~LIB_INDIRECT; a->id.flag |= LIB_EXTERN;}
+#define LIBTAG(a) if (a && a->id.lib) {a->id.flag &=~LIB_INDIRECT; a->id.flag |= LIB_EXTERN;}
static void lib_indirect_test_id(ID *id, Library *lib)
{
- if(id->lib) {
+ if (id->lib) {
/* datablocks that were indirectly related are now direct links
* without this, appending data that has a link to other data will fail to write */
- if(lib && id->lib->parent == lib) {
+ if (lib && id->lib->parent == lib) {
id_lib_extern(id);
}
return;
}
- if(GS(id->name)==ID_OB) {
+ if (GS(id->name)==ID_OB) {
Object *ob= (Object *)id;
Mesh *me;
@@ -1335,7 +1337,7 @@ static void lib_indirect_test_id(ID *id, Library *lib)
// XXX: new animation system needs something like this?
#endif
- for(a=0; a<ob->totcol; a++) {
+ for (a=0; a<ob->totcol; a++) {
LIBTAG(ob->mat[a]);
}
@@ -1350,13 +1352,13 @@ static void lib_indirect_test_id(ID *id, Library *lib)
void tag_main_lb(ListBase *lb, const short tag)
{
ID *id;
- if(tag) {
- for(id= lb->first; id; id= id->next) {
+ if (tag) {
+ for (id= lb->first; id; id= id->next) {
id->flag |= LIB_DOIT;
}
}
else {
- for(id= lb->first; id; id= id->next) {
+ for (id= lb->first; id; id= id->next) {
id->flag &= ~LIB_DOIT;
}
}
@@ -1375,7 +1377,7 @@ void tag_main(struct Main *mainvar, const short tag)
int a;
a= set_listbasepointers(mainvar, lbarray);
- while(a--) {
+ while (a--) {
tag_main_lb(lbarray[a], tag);
}
}
@@ -1389,10 +1391,10 @@ void BKE_library_make_local(Main *bmain, Library *lib, int untagged_only)
int a;
a= set_listbasepointers(bmain, lbarray);
- while(a--) {
+ while (a--) {
id= lbarray[a]->first;
- while(id) {
+ while (id) {
id->newid= NULL;
idn= id->next; /* id is possibly being inserted again */
@@ -1401,11 +1403,11 @@ void BKE_library_make_local(Main *bmain, Library *lib, int untagged_only)
* appending data, so any libdata already linked wont become local
* (very nasty to discover all your links are lost after appending)
* */
- if(id->flag & (LIB_EXTERN|LIB_INDIRECT|LIB_NEW) &&
+ if (id->flag & (LIB_EXTERN|LIB_INDIRECT|LIB_NEW) &&
(untagged_only==0 || !(id->flag & LIB_PRE_EXISTING)))
{
- if(lib==NULL || id->lib==lib) {
- if(id->lib) {
+ if (lib==NULL || id->lib==lib) {
+ if (id->lib) {
id_clear_lib_data(bmain, id); /* sets 'id->flag' */
/* why sort alphabetically here but not in
@@ -1421,7 +1423,7 @@ void BKE_library_make_local(Main *bmain, Library *lib, int untagged_only)
}
/* patch2: make it aphabetically */
- while( (id=tempbase.first) ) {
+ while ( (id=tempbase.first) ) {
BLI_remlink(&tempbase, id);
BLI_addtail(lbarray[a], id);
new_id(lbarray[a], id, NULL);
@@ -1430,8 +1432,8 @@ void BKE_library_make_local(Main *bmain, Library *lib, int untagged_only)
/* patch 3: make sure library data isn't indirect falsely... */
a= set_listbasepointers(bmain, lbarray);
- while(a--) {
- for(id= lbarray[a]->first; id; id=id->next)
+ while (a--) {
+ for (id= lbarray[a]->first; id; id=id->next)
lib_indirect_test_id(id, lib);
}
}
@@ -1445,22 +1447,22 @@ void test_idbutton(char *name)
lb= which_libbase(G.main, GS(name-2) );
- if(lb==NULL) return;
+ if (lb==NULL) return;
/* search for id */
idtest= BLI_findstring(lb, name, offsetof(ID, name) + 2);
- if(idtest) if( new_id(lb, idtest, name)==0 ) sort_alpha_id(lb, idtest);
+ if (idtest) if( new_id(lb, idtest, name)==0 ) sort_alpha_id(lb, idtest);
}
void text_idbutton(struct ID *id, char *text)
{
- if(id) {
- if(GS(id->name)==ID_SCE)
+ if (id) {
+ if (GS(id->name)==ID_SCE)
strcpy(text, "SCE: ");
- else if(GS(id->name)==ID_SCR)
+ else if (GS(id->name)==ID_SCR)
strcpy(text, "SCR: ");
- else if(GS(id->name)==ID_MA && ((Material*)id)->use_nodes)
+ else if (GS(id->name)==ID_MA && ((Material*)id)->use_nodes)
strcpy(text, "NT: ");
else {
text[0]= id->name[0];
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index 6f47ed427d3..dd25092f7dd 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -307,7 +307,7 @@ void make_local_material(Material *ma)
* lib or local */
/* test objects */
ob= bmain->object.first;
- while(ob) {
+ while (ob) {
if (ob->mat) {
for (a=0; a<ob->totcol; a++) {
if (ob->mat[a]==ma) {
@@ -320,7 +320,7 @@ void make_local_material(Material *ma)
}
/* test meshes */
me= bmain->mesh.first;
- while(me) {
+ while (me) {
if (me->mat) {
for (a=0; a<me->totcol; a++) {
if (me->mat[a]==ma) {
@@ -333,7 +333,7 @@ void make_local_material(Material *ma)
}
/* test curves */
cu= bmain->curve.first;
- while(cu) {
+ while (cu) {
if (cu->mat) {
for (a=0; a<cu->totcol; a++) {
if (cu->mat[a]==ma) {
@@ -346,7 +346,7 @@ void make_local_material(Material *ma)
}
/* test mballs */
mb= bmain->mball.first;
- while(mb) {
+ while (mb) {
if (mb->mat) {
for (a=0; a<mb->totcol; a++) {
if (mb->mat[a]==ma) {
@@ -374,7 +374,7 @@ void make_local_material(Material *ma)
/* do objects */
ob= bmain->object.first;
- while(ob) {
+ while (ob) {
if (ob->mat) {
for (a=0; a<ob->totcol; a++) {
if (ob->mat[a]==ma) {
@@ -390,7 +390,7 @@ void make_local_material(Material *ma)
}
/* do meshes */
me= bmain->mesh.first;
- while(me) {
+ while (me) {
if (me->mat) {
for (a=0; a<me->totcol; a++) {
if (me->mat[a]==ma) {
@@ -406,7 +406,7 @@ void make_local_material(Material *ma)
}
/* do curves */
cu= bmain->curve.first;
- while(cu) {
+ while (cu) {
if (cu->mat) {
for (a=0; a<cu->totcol; a++) {
if (cu->mat[a]==ma) {
@@ -422,7 +422,7 @@ void make_local_material(Material *ma)
}
/* do mballs */
mb= bmain->mball.first;
- while(mb) {
+ while (mb) {
if (mb->mat) {
for (a=0; a<mb->totcol; a++) {
if (mb->mat[a]==ma) {
@@ -840,7 +840,7 @@ void assign_matarar(struct Object *ob, struct Material ***matar, short totcol)
int actcol_orig= ob->actcol;
short i;
- while(object_remove_material_slot(ob)) {};
+ while (object_remove_material_slot(ob)) {};
/* now we have the right number of slots */
for (i=0; i<totcol; i++)
@@ -1144,7 +1144,7 @@ int object_remove_material_slot(Object *ob)
actcol= ob->actcol;
obt= G.main->object.first;
- while(obt) {
+ while (obt) {
if (obt->data==ob->data) {
diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c
index 22f8d38de4a..fe21295ff83 100644
--- a/source/blender/blenkernel/intern/mball.c
+++ b/source/blender/blenkernel/intern/mball.c
@@ -77,7 +77,7 @@ void unlink_mball(MetaBall *mb)
{
int a;
- for(a=0; a<mb->totcol; a++) {
+ for (a=0; a<mb->totcol; a++) {
if (mb->mat[a]) mb->mat[a]->id.us--;
mb->mat[a]= NULL;
}
@@ -125,7 +125,7 @@ MetaBall *copy_mball(MetaBall *mb)
BLI_duplicatelist(&mbn->elems, &mb->elems);
mbn->mat= MEM_dupallocN(mb->mat);
- for(a=0; a<mbn->totcol; a++) {
+ for (a=0; a<mbn->totcol; a++) {
id_us_plus((ID *)mbn->mat[a]);
}
mbn->bb= MEM_dupallocN(mb->bb);
@@ -162,7 +162,7 @@ void make_local_mball(MetaBall *mb)
return;
}
- for(ob= G.main->object.first; ob && ELEM(0, is_lib, is_local); ob= ob->id.next) {
+ for (ob= G.main->object.first; ob && ELEM(0, is_lib, is_local); ob= ob->id.next) {
if (ob->data == mb) {
if (ob->id.lib) is_lib= TRUE;
else is_local= TRUE;
@@ -180,7 +180,7 @@ void make_local_mball(MetaBall *mb)
/* Remap paths of new ID using old library as base. */
BKE_id_lib_local_paths(bmain, mb->id.lib, &mb_new->id);
- for(ob= G.main->object.first; ob; ob= ob->id.next) {
+ for (ob= G.main->object.first; ob; ob= ob->id.next) {
if (ob->data == mb) {
if (ob->id.lib==NULL) {
ob->data= mb_new;
@@ -262,11 +262,11 @@ void tex_space_mball(Object *ob)
(max)[0]= (max)[1]= (max)[2]= -1.0e30f;
dl= ob->disp.first;
- while(dl) {
+ while (dl) {
tot= dl->nr;
if (tot) doit= 1;
data= dl->verts;
- while(tot--) {
+ while (tot--) {
/* Also weird... but longer. From utildefines. */
DO_MINMAX(data, min, max);
data+= 3;
@@ -313,7 +313,7 @@ float *make_orco_mball(Object *ob, ListBase *dispbase)
data= dl->verts;
orco= orcodata;
a= dl->nr;
- while(a--) {
+ while (a--) {
orco[0]= (data[0]-loc[0])/size[0];
orco[1]= (data[1]-loc[1])/size[1];
orco[2]= (data[2]-loc[2])/size[2];
@@ -386,7 +386,7 @@ void copy_mball_properties(Scene *scene, Object *active_object)
if (F_ERROR==next_object(&sce_iter, 0, NULL, NULL))
return;
- while(next_object(&sce_iter, 1, &base, &ob)) {
+ while (next_object(&sce_iter, 1, &base, &ob)) {
if (ob->type==OB_MBALL) {
if (ob != active_object) {
BLI_split_name_num(obname, &obnr, ob->id.name+2, '.');
@@ -432,7 +432,7 @@ Object *find_basis_mball(Scene *scene, Object *basis)
if (F_ERROR==next_object(&sce_iter, 0, NULL, NULL))
return NULL;
- while(next_object(&sce_iter, 1, &base, &ob)) {
+ while (next_object(&sce_iter, 1, &base, &ob)) {
if (ob->type==OB_MBALL) {
if (ob==bob) {
@@ -444,7 +444,7 @@ Object *find_basis_mball(Scene *scene, Object *basis)
/* if bob object is in object mode */
else ml= mb->elems.first;
}
- else{
+ else {
BLI_split_name_num(obname, &obnr, ob->id.name+2, '.');
/* object ob has to be in same "group" ... it means, that it has to have
@@ -617,21 +617,21 @@ octal_node* find_metaball_octal_node(octal_node *node, float x, float y, float z
else
return node;
}
- else{
+ else {
if (node->nodes[1])
return find_metaball_octal_node(node->nodes[1],x,y,z,depth--);
else
return node;
}
}
- else{
+ else {
if (x < node->x) {
if (node->nodes[3])
return find_metaball_octal_node(node->nodes[3],x,y,z,depth--);
else
return node;
}
- else{
+ else {
if (node->nodes[2])
return find_metaball_octal_node(node->nodes[2],x,y,z,depth--);
else
@@ -639,7 +639,7 @@ octal_node* find_metaball_octal_node(octal_node *node, float x, float y, float z
}
}
}
- else{
+ else {
if (y < node->y) {
if (x < node->x) {
if (node->nodes[4])
@@ -647,21 +647,21 @@ octal_node* find_metaball_octal_node(octal_node *node, float x, float y, float z
else
return node;
}
- else{
+ else {
if (node->nodes[5])
return find_metaball_octal_node(node->nodes[5],x,y,z,depth--);
else
return node;
}
}
- else{
+ else {
if (x < node->x) {
if (node->nodes[7])
return find_metaball_octal_node(node->nodes[7],x,y,z,depth--);
else
return node;
}
- else{
+ else {
if (node->nodes[6])
return find_metaball_octal_node(node->nodes[6],x,y,z,depth--);
else
@@ -686,7 +686,7 @@ float metaball(float x, float y, float z)
if (node) {
ml_p= node->elems.first;
- while(ml_p) {
+ while (ml_p) {
dens+=densfunc(ml_p->ml, x, y, z);
ml_p= ml_p->next;
}
@@ -694,13 +694,13 @@ float metaball(float x, float y, float z)
dens+= -0.5f*(metaball_tree->pos - node->pos);
dens+= 0.5f*(metaball_tree->neg - node->neg);
}
- else{
- for(a=0; a<totelem; a++) {
+ else {
+ for (a=0; a<totelem; a++) {
dens += densfunc(mainb[a], x, y, z);
}
}
}
- else{
+ else {
dens += densfunc(mainb[0], x, y, z);
}
@@ -762,7 +762,7 @@ void *new_pgn_element(int size)
}
else if (size== -1) {
cur= lb.first;
- while(cur) {
+ while (cur) {
MEM_freeN(cur->data);
cur= cur->next;
}
@@ -1078,11 +1078,11 @@ void BKE_freecubetable(void)
for (i = 0; i < 256; i++) {
lists= cubetable[i];
- while(lists) {
+ while (lists) {
nlists= lists->next;
ints= lists->list;
- while(ints) {
+ while (ints) {
nints= ints->next;
MEM_freeN(ints);
ints= nints;
@@ -1387,7 +1387,7 @@ void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2,
pos.y = p->y;
pos.z = p->z;
}
- else{
+ else {
neg.x = p->x;
neg.y = p->y;
neg.z = p->z;
@@ -1404,9 +1404,9 @@ void add_cube(PROCESS *mbproc, int i, int j, int k, int count)
/* hmmm, not only one, but eight cube will be added on the stack
* ... */
- for(a=i-1; a<i+count; a++)
- for(b=j-1; b<j+count; b++)
- for(c=k-1; c<k+count; c++) {
+ for (a=i-1; a<i+count; a++)
+ for (b=j-1; b<j+count; b++)
+ for (c=k-1; c<k+count; c++) {
/* test if cube has been found before */
if ( setcenter(mbproc->centers, a, b, c)==0 ) {
/* push cube on stack: */
@@ -1451,7 +1451,7 @@ void find_first_points(PROCESS *mbproc, MetaBall *mb, int a)
calc_mballco(ml, (float *)&in);
in_v = mbproc->function(in.x, in.y, in.z);
- for(i=0;i<3;i++) {
+ for (i=0;i<3;i++) {
switch (ml->type) {
case MB_BALL:
OUT.x = out.x= IN.x + index[i]*ml->rad;
@@ -1464,7 +1464,7 @@ void find_first_points(PROCESS *mbproc, MetaBall *mb, int a)
break;
}
- for(j=0;j<3;j++) {
+ for (j=0;j<3;j++) {
switch (ml->type) {
case MB_BALL:
OUT.y = out.y= IN.y + index[j]*ml->rad;
@@ -1477,7 +1477,7 @@ void find_first_points(PROCESS *mbproc, MetaBall *mb, int a)
break;
}
- for(k=0;k<3;k++) {
+ for (k=0;k<3;k++) {
out.x = OUT.x;
out.y = OUT.y;
switch (ml->type) {
@@ -1514,7 +1514,7 @@ void find_first_points(PROCESS *mbproc, MetaBall *mb, int a)
dz = (out.z - in.z)/MAXN;
len = 0.0;
- while(len<=max_len) {
+ while (len<=max_len) {
workp.x += dx;
workp.y += dy;
workp.z += dz;
@@ -1560,7 +1560,7 @@ void polygonize(PROCESS *mbproc, MetaBall *mb)
mbproc->edges = MEM_callocN(2*HASHSIZE * sizeof(EDGELIST *), "mbproc->edges");
makecubetable();
- for(a=0; a<totelem; a++) {
+ for (a=0; a<totelem; a++) {
/* try to find 8 points on the surface for each MetaElem */
find_first_points(mbproc, mb, a);
@@ -1606,7 +1606,7 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */
/* make main array */
next_object(&sce_iter, 0, NULL, NULL);
- while(next_object(&sce_iter, 1, &base, &bob)) {
+ while (next_object(&sce_iter, 1, &base, &bob)) {
if (bob->type==OB_MBALL) {
zero_size= 0;
@@ -1638,7 +1638,7 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */
}
else if (bob->parent) {
struct Object *pob=bob->parent;
- while(pob) {
+ while (pob) {
if (pob->size[0]==0.0f || pob->size[1]==0.0f || pob->size[2]==0.0f) {
zero_size= 1;
break;
@@ -1649,14 +1649,14 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */
if (zero_size) {
unsigned int ml_count=0;
- while(ml) {
+ while (ml) {
ml_count++;
ml= ml->next;
}
totelem -= ml_count;
}
else {
- while(ml) {
+ while (ml) {
if (!(ml->flag & MB_HIDE)) {
int i;
float temp1[4][4], temp2[4][4], temp3[4][4];
@@ -1737,11 +1737,11 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */
mainb[a]->bb->vec[7][2]= ml->expz;
/* transformation of Metalem bb */
- for(i=0; i<8; i++)
+ for (i=0; i<8; i++)
mul_m4_v3((float ( * )[4])mat, mainb[a]->bb->vec[i]);
/* find max and min of transformed bb */
- for(i=0; i<8; i++) {
+ for (i=0; i<8; i++) {
/* find maximums */
if (mainb[a]->bb->vec[i][0] > max_x) max_x = mainb[a]->bb->vec[i][0];
if (mainb[a]->bb->vec[i][1] > max_y) max_y = mainb[a]->bb->vec[i][1];
@@ -1773,7 +1773,7 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */
/* totsize (= 'manhattan' radius) */
totsize= 0.0;
- for(a=0; a<totelem; a++) {
+ for (a=0; a<totelem; a++) {
vec[0]= mainb[a]->x + mainb[a]->rad + mainb[a]->expx;
vec[1]= mainb[a]->y + mainb[a]->rad + mainb[a]->expy;
@@ -1802,7 +1802,7 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */
if ( size > totsize ) totsize= size;
}
- for(a=0; a<totelem; a++) {
+ for (a=0; a<totelem; a++) {
thresh += densfunc(mainb[a], 2.0f * totsize, 2.0f * totsize, 2.0f * totsize);
}
@@ -1824,7 +1824,7 @@ void fill_metaball_octal_node(octal_node *node, MetaElem *ml, short i)
if (ml->flag & MB_NEGATIVE) {
node->nodes[i]->neg++;
}
- else{
+ else {
node->nodes[i]->pos++;
}
}
@@ -1852,9 +1852,9 @@ void subdivide_metaball_octal_node(octal_node *node, float size_x, float size_y,
int a,i;
/* create new nodes */
- for(a=0;a<8;a++) {
+ for (a=0;a<8;a++) {
node->nodes[a]= MEM_mallocN(sizeof(octal_node),"octal_node");
- for(i=0;i<8;i++)
+ for (i=0;i<8;i++)
node->nodes[a]->nodes[i]= NULL;
node->nodes[a]->parent= node;
node->nodes[a]->elems.first= NULL;
@@ -1933,7 +1933,7 @@ void subdivide_metaball_octal_node(octal_node *node, float size_x, float size_y,
ml_p= node->elems.first;
/* setting up references of MetaElems for new nodes */
- while(ml_p) {
+ while (ml_p) {
ml= ml_p->ml;
if (ml->bb->vec[0][2] < z) {
if (ml->bb->vec[0][1] < y) {
@@ -1982,7 +1982,7 @@ void subdivide_metaball_octal_node(octal_node *node, float size_x, float size_y,
}
/* vec[0][0] is in the (1)second octant */
- else{
+ else {
/* ml belong to the (1)2nd node */
fill_metaball_octal_node(node, ml, 1);
@@ -2003,7 +2003,7 @@ void subdivide_metaball_octal_node(octal_node *node, float size_x, float size_y,
}
}
}
- else{
+ else {
/* vec[0][0] is in the (3)4th octant */
if (ml->bb->vec[0][0] < x) {
/* ml belongs to the (3)4nd node */
@@ -2039,7 +2039,7 @@ void subdivide_metaball_octal_node(octal_node *node, float size_x, float size_y,
}
}
}
- else{
+ else {
if (ml->bb->vec[0][1] < y) {
/* vec[0][0] lies in (4)5th octant */
if (ml->bb->vec[0][0] < x) {
@@ -2059,7 +2059,7 @@ void subdivide_metaball_octal_node(octal_node *node, float size_x, float size_y,
}
}
/* vec[0][0] lies in (5)6th octant */
- else{
+ else {
fill_metaball_octal_node(node, ml, 5);
if (ml->bb->vec[6][1] >= y) {
@@ -2067,7 +2067,7 @@ void subdivide_metaball_octal_node(octal_node *node, float size_x, float size_y,
}
}
}
- else{
+ else {
/* vec[0][0] lies in (7)8th octant */
if (ml->bb->vec[0][0] < x) {
fill_metaball_octal_node(node, ml, 7);
@@ -2093,7 +2093,7 @@ void subdivide_metaball_octal_node(octal_node *node, float size_x, float size_y,
depth--;
if (depth>0) {
- for(a=0;a<8;a++) {
+ for (a=0;a<8;a++) {
if (node->nodes[a]->count > 0) /* if node is not empty, then it is subdivided */
subdivide_metaball_octal_node(node->nodes[a], size_x, size_y, size_z, depth);
}
@@ -2104,7 +2104,7 @@ void subdivide_metaball_octal_node(octal_node *node, float size_x, float size_y,
void free_metaball_octal_node(octal_node *node)
{
int a;
- for(a=0;a<8;a++) {
+ for (a=0;a<8;a++) {
if (node->nodes[a]!=NULL) free_metaball_octal_node(node->nodes[a]);
}
BLI_freelistN(&node->elems);
@@ -2131,14 +2131,14 @@ void init_metaball_octal_tree(int depth)
node->elems.last= NULL;
node->count=0;
- for(a=0;a<8;a++)
+ for (a=0;a<8;a++)
node->nodes[a]=NULL;
node->x_min= node->y_min= node->z_min= FLT_MAX;
node->x_max= node->y_max= node->z_max= -FLT_MAX;
/* size of octal tree scene */
- for(a=0;a<totelem;a++) {
+ for (a=0;a<totelem;a++) {
if (mainb[a]->bb->vec[0][0] < node->x_min) node->x_min= mainb[a]->bb->vec[0][0];
if (mainb[a]->bb->vec[0][1] < node->y_min) node->y_min= mainb[a]->bb->vec[0][1];
if (mainb[a]->bb->vec[0][2] < node->z_min) node->z_min= mainb[a]->bb->vec[0][2];
@@ -2155,7 +2155,7 @@ void init_metaball_octal_tree(int depth)
/* number of negative MetaElem in scene */
metaball_tree->neg++;
}
- else{
+ else {
/* number of positive MetaElem in scene */
metaball_tree->pos++;
}
@@ -2268,7 +2268,7 @@ void metaball_polygonize(Scene *scene, Object *ob, ListBase *dispbase)
dl->verts= ve= MEM_mallocN(sizeof(float)*3*a, "mballverts");
dl->nors= no= MEM_mallocN(sizeof(float)*3*a, "mballnors");
- for(a=0; a<mbproc.vertices.count; a++, no+=3, ve+=3) {
+ for (a=0; a<mbproc.vertices.count; a++, no+=3, ve+=3) {
ve[0]= mbproc.vertices.ptr[a].position.x;
ve[1]= mbproc.vertices.ptr[a].position.y;
ve[2]= mbproc.vertices.ptr[a].position.z;
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index 496c72ce2f8..ed3cf697a9e 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -1483,7 +1483,8 @@ void nurbs_to_mesh(Object *ob)
mesh_calc_normals(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL);
BKE_mesh_calc_edges(me, TRUE);
- } else {
+ }
+ else {
me= add_mesh("Mesh");
DM_to_mesh(dm, me, ob);
}
@@ -1573,7 +1574,8 @@ void mesh_to_curve(Scene *scene, Object *ob)
BLI_edgehash_insert(eh, mf->v3, mf->v4, NULL);
if (!BLI_edgehash_haskey(eh, mf->v4, mf->v1))
BLI_edgehash_insert(eh, mf->v4, mf->v1, NULL);
- } else {
+ }
+ else {
if (!BLI_edgehash_haskey(eh, mf->v3, mf->v1))
BLI_edgehash_insert(eh, mf->v3, mf->v1, NULL);
}
@@ -1737,7 +1739,8 @@ void mesh_set_smooth_flag(Object *meshOb, int enableSmooth)
if (enableSmooth) {
mp->flag |= ME_SMOOTH;
- } else {
+ }
+ else {
mp->flag &= ~ME_SMOOTH;
}
}
@@ -1747,7 +1750,8 @@ void mesh_set_smooth_flag(Object *meshOb, int enableSmooth)
if (enableSmooth) {
mf->flag |= ME_SMOOTH;
- } else {
+ }
+ else {
mf->flag &= ~ME_SMOOTH;
}
}
@@ -2062,7 +2066,8 @@ void convert_mfaces_to_mpolys(Mesh *mesh)
if (mf->v4) {
ML(v3, v4);
ML(v4, v1);
- } else {
+ }
+ else {
ML(v3, v1);
}
@@ -2776,7 +2781,8 @@ static void mesh_calc_ngon_normal(MPoly *mpoly, MLoop *loopstart,
normal[2] = 1.0f;
return;
- } else l = 1.0f / l;
+ }
+ else l = 1.0f / l;
n[0] *= l;
n[1] *= l;
@@ -2854,7 +2860,10 @@ static void mesh_calc_ngon_normal_coords(MPoly *mpoly, MLoop *loopstart,
normal[2] = 1.0f;
return;
- } else l = 1.0f / l;
+ }
+ else {
+ l = 1.0f / l;
+ }
n[0] *= l;
n[1] *= l;
@@ -2996,7 +3005,7 @@ int poly_get_adj_loops_from_vert(unsigned adj_r[3], const MPoly *poly,
&mloop[poly->loopstart],
vert);
- if(corner != -1) {
+ if (corner != -1) {
const MLoop *ml = &mloop[poly->loopstart + corner];
/* vertex was found */
@@ -3017,19 +3026,19 @@ void mesh_flush_hidden_from_verts(const MVert *mvert,
{
int i, j;
- for(i = 0; i < totedge; i++) {
+ for (i = 0; i < totedge; i++) {
MEdge *e = &medge[i];
- if(mvert[e->v1].flag & ME_HIDE ||
+ if (mvert[e->v1].flag & ME_HIDE ||
mvert[e->v2].flag & ME_HIDE)
e->flag |= ME_HIDE;
else
e->flag &= ~ME_HIDE;
}
- for(i = 0; i < totpoly; i++) {
+ for (i = 0; i < totpoly; i++) {
MPoly *p = &mpoly[i];
p->flag &= ~ME_HIDE;
- for(j = 0; j < p->totloop; j++) {
- if(mvert[mloop[p->loopstart + j].v].flag & ME_HIDE)
+ for (j = 0; j < p->totloop; j++) {
+ if (mvert[mloop[p->loopstart + j].v].flag & ME_HIDE)
p->flag |= ME_HIDE;
}
}
diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c
index 0a10184c730..c0f488faf3f 100644
--- a/source/blender/blenkernel/intern/mesh_validate.c
+++ b/source/blender/blenkernel/intern/mesh_validate.c
@@ -131,17 +131,17 @@ int BKE_mesh_validate_arrays(Mesh *mesh,
PRINT("%s: verts(%u), edges(%u), loops(%u), polygons(%u)\n",
__func__, totvert, totedge, totloop, totpoly);
- if(totedge == 0 && totpoly != 0) {
+ if (totedge == 0 && totpoly != 0) {
PRINT(" logical error, %u polygons and 0 edges\n", totpoly);
do_edge_recalc = do_fixes;
}
- for(i=1; i<totvert; i++, mv++) {
+ for (i=1; i<totvert; i++, mv++) {
int j;
int fix_normal= TRUE;
- for(j=0; j<3; j++) {
- if(!finite(mv->co[j])) {
+ for (j=0; j<3; j++) {
+ if (!finite(mv->co[j])) {
PRINT(" vertex %u: has invalid coordinate\n", i);
if (do_fixes) {
@@ -151,11 +151,11 @@ int BKE_mesh_validate_arrays(Mesh *mesh,
}
}
- if(mv->no[j]!=0)
+ if (mv->no[j]!=0)
fix_normal= FALSE;
}
- if(fix_normal) {
+ if (fix_normal) {
PRINT(" vertex %u: has zero normal, assuming Z-up normal\n", i);
if (do_fixes) {
mv->no[2]= SHRT_MAX;
@@ -164,28 +164,28 @@ int BKE_mesh_validate_arrays(Mesh *mesh,
}
}
- for(i=0, me= medges; i<totedge; i++, me++) {
+ for (i=0, me= medges; i<totedge; i++, me++) {
int remove= FALSE;
- if(me->v1 == me->v2) {
+ if (me->v1 == me->v2) {
PRINT(" edge %u: has matching verts, both %u\n", i, me->v1);
remove= do_fixes;
}
- if(me->v1 >= totvert) {
+ if (me->v1 >= totvert) {
PRINT(" edge %u: v1 index out of range, %u\n", i, me->v1);
remove= do_fixes;
}
- if(me->v2 >= totvert) {
+ if (me->v2 >= totvert) {
PRINT(" edge %u: v2 index out of range, %u\n", i, me->v2);
remove= do_fixes;
}
- if(BLI_edgehash_haskey(edge_hash, me->v1, me->v2)) {
+ if (BLI_edgehash_haskey(edge_hash, me->v1, me->v2)) {
PRINT(" edge %u: is a duplicate of %d\n", i,
GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, me->v1, me->v2)));
remove= do_fixes;
}
- if(remove == FALSE) {
+ if (remove == FALSE) {
BLI_edgehash_insert(edge_hash, me->v1, me->v2, SET_INT_IN_POINTER(i));
}
else {
@@ -261,7 +261,7 @@ int BKE_mesh_validate_arrays(Mesh *mesh,
else if (ml->e >= totedge) {
/* Invalid edge idx.
* We already know from previous text that a valid edge exists, use it (if allowed)! */
- if(do_fixes) {
+ if (do_fixes) {
int prev_e = ml->e;
ml->e = GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, v1, v2));
PRINT(" loop %u has invalid edge reference (%u), fixed using edge %u\n",
@@ -277,7 +277,7 @@ int BKE_mesh_validate_arrays(Mesh *mesh,
if (IS_REMOVED_EDGE(me) || !((me->v1 == v1 && me->v2 == v2) || (me->v1 == v2 && me->v2 == v1))) {
/* The pointed edge is invalid (tagged as removed, or vert idx mismatch),
* and we already know from previous test that a valid one exists, use it (if allowed)! */
- if(do_fixes) {
+ if (do_fixes) {
int prev_e = ml->e;
ml->e = GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, v1, v2));
PRINT(" poly %u has invalid edge reference (%u), fixed using edge %u\n",
@@ -387,7 +387,7 @@ int BKE_mesh_validate_arrays(Mesh *mesh,
p1_sub += 0;
p2_sub += 0;
}
- if((p1_nv == p2_nv) && (memcmp(p1_v, p2_v, p1_nv * sizeof(*p1_v)) == 0)) {
+ if ((p1_nv == p2_nv) && (memcmp(p1_v, p2_v, p1_nv * sizeof(*p1_v)) == 0)) {
if (do_verbose) {
PRINT(" polys %u and %u use same vertices (%u",
prev_sp->index, sp->index, *p1_v);
@@ -471,11 +471,11 @@ int BKE_mesh_validate_arrays(Mesh *mesh,
/* fix deform verts */
if (dverts) {
MDeformVert *dv;
- for(i=0, dv= dverts; i<totvert; i++, dv++) {
+ for (i=0, dv= dverts; i<totvert; i++, dv++) {
MDeformWeight *dw;
unsigned int j;
- for(j=0, dw= dv->dw; j < dv->totweight; j++, dw++) {
+ for (j=0, dw= dv->dw; j < dv->totweight; j++, dw++) {
/* note, greater then max defgroups is accounted for in our code, but not < 0 */
if (!finite(dw->weight)) {
PRINT(" vertex deform %u, group %d has weight: %f\n", i, dw->def_nr, dw->weight);
@@ -520,8 +520,8 @@ int BKE_mesh_validate_arrays(Mesh *mesh,
# undef REMOVE_LOOP_TAG
# undef REMOVE_POLY_TAG
- if(mesh) {
- if(do_polyloop_free) {
+ if (mesh) {
+ if (do_polyloop_free) {
mesh_strip_loose_polysloops(mesh);
}
@@ -529,7 +529,7 @@ int BKE_mesh_validate_arrays(Mesh *mesh,
mesh_strip_loose_edges(mesh);
}
- if(do_edge_recalc) {
+ if (do_edge_recalc) {
BKE_mesh_calc_edges(mesh, TRUE);
}
}
@@ -541,22 +541,22 @@ static int mesh_validate_customdata(CustomData *data, short do_verbose, const sh
{
int i= 0, has_fixes= 0;
- while(i<data->totlayer) {
+ while (i<data->totlayer) {
CustomDataLayer *layer= &data->layers[i];
CustomDataMask mask= CD_TYPE_AS_MASK(layer->type);
int ok= 1;
- if((mask&CD_MASK_MESH)==0) {
+ if ((mask&CD_MASK_MESH)==0) {
PRINT("CustomDataLayer type %d which isn't in CD_MASK_MESH is stored in Mehs structure\n", layer->type);
- if(do_fixes) {
+ if (do_fixes) {
CustomData_free_layer(data, layer->type, 0, i);
ok= 0;
has_fixes= 1;
}
}
- if(ok)
+ if (ok)
i++;
}
@@ -583,7 +583,7 @@ int BKE_mesh_validate(Mesh *me, int do_verbose)
{
int layers_fixed= 0, arrays_fixed= 0;
- if(do_verbose) {
+ if (do_verbose) {
printf("MESH: %s\n", me->id.name+2);
}
@@ -624,19 +624,19 @@ void BKE_mesh_calc_edges(Mesh *mesh, int update)
int i, totedge, totpoly = mesh->totpoly;
int med_index;
- if(mesh->totedge==0)
+ if (mesh->totedge==0)
update= 0;
- if(update) {
+ if (update) {
/* assume existing edges are valid
* useful when adding more faces and generating edges from them */
med= mesh->medge;
- for(i= 0; i<mesh->totedge; i++, med++)
+ for (i= 0; i<mesh->totedge; i++, med++)
BLI_edgehash_insert(eh, med->v1, med->v2, med);
}
/* mesh loops (bmesh only) */
- for(i=0; i < totpoly; i++, mp++) {
+ for (i=0; i < totpoly; i++, mp++) {
MLoop *l= &mesh->mloop[mp->loopstart];
int j, l_prev= (l + (mp->totloop-1))->v;
for (j=0; j < mp->totloop; j++, l++) {
@@ -655,12 +655,13 @@ void BKE_mesh_calc_edges(Mesh *mesh, int update)
ehi = BLI_edgehashIterator_new(eh);
med = CustomData_get_layer(&edata, CD_MEDGE);
- for(i = 0; !BLI_edgehashIterator_isDone(ehi);
+ for (i = 0; !BLI_edgehashIterator_isDone(ehi);
BLI_edgehashIterator_step(ehi), ++i, ++med) {
- if(update && (med_orig=BLI_edgehashIterator_getValue(ehi))) {
+ if (update && (med_orig=BLI_edgehashIterator_getValue(ehi))) {
*med= *med_orig; /* copy from the original */
- } else {
+ }
+ else {
BLI_edgehashIterator_getKey(ehi, &med->v1, &med->v2);
med->flag = ME_EDGEDRAW|ME_EDGERENDER|SELECT; /* select for newly created meshes which are selected [#25595] */
}
@@ -674,7 +675,7 @@ void BKE_mesh_calc_edges(Mesh *mesh, int update)
/* second pass, iterate through all loops again and assign
* the newly created edges to them. */
MPoly *mp= mesh->mpoly;
- for(i=0; i < mesh->totpoly; i++, mp++) {
+ for (i=0; i < mesh->totpoly; i++, mp++) {
MLoop *l= &mesh->mloop[mp->loopstart];
MLoop *l_prev= (l + (mp->totloop-1));
int j;
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c
index 138379b1bb9..f5a303033a3 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -77,7 +77,7 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type)
}
/* type unsigned, no need to chech < 0 */
- if(type < NUM_MODIFIER_TYPES && types[type]->name[0] != '\0') {
+ if (type < NUM_MODIFIER_TYPES && types[type]->name[0] != '\0') {
return types[type];
}
else {
@@ -205,8 +205,8 @@ void modifiers_foreachIDLink(Object *ob, IDWalkFunc walk, void *userData)
for (; md; md=md->next) {
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
- if(mti->foreachIDLink) mti->foreachIDLink(md, ob, walk, userData);
- else if(mti->foreachObjectLink) {
+ if (mti->foreachIDLink) mti->foreachIDLink(md, ob, walk, userData);
+ else if (mti->foreachObjectLink) {
/* each Object can masquerade as an ID, so this should be OK */
ObjectWalkFunc fp = (ObjectWalkFunc)walk;
mti->foreachObjectLink(md, ob, fp, userData);
@@ -221,7 +221,7 @@ void modifiers_foreachTexLink(Object *ob, TexWalkFunc walk, void *userData)
for (; md; md=md->next) {
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
- if(mti->foreachTexLink)
+ if (mti->foreachTexLink)
mti->foreachTexLink(md, ob, walk, userData);
}
}
@@ -290,7 +290,7 @@ int modifiers_getCageIndex(struct Scene *scene, Object *ob, int *lastPossibleCag
ModifierData *md = (virtual_)? modifiers_getVirtualModifierList(ob): ob->modifiers.first;
int i, cageIndex = -1;
- if(lastPossibleCageIndex_r) {
+ if (lastPossibleCageIndex_r) {
/* ensure the value is initialized */
*lastPossibleCageIndex_r= -1;
}
@@ -346,11 +346,11 @@ int modifier_isEnabled(struct Scene *scene, ModifierData *md, int required_mode)
md->scene= scene;
- if((md->mode & required_mode) != required_mode) return 0;
- if(mti->isDisabled && mti->isDisabled(md, required_mode == eModifierMode_Render)) return 0;
- if(md->mode & eModifierMode_DisableTemporary) return 0;
- if(required_mode & eModifierMode_Editmode)
- if(!(mti->flags & eModifierTypeFlag_SupportsEditmode)) return 0;
+ if ((md->mode & required_mode) != required_mode) return 0;
+ if (mti->isDisabled && mti->isDisabled(md, required_mode == eModifierMode_Render)) return 0;
+ if (md->mode & eModifierMode_DisableTemporary) return 0;
+ if (required_mode & eModifierMode_Editmode)
+ if (!(mti->flags & eModifierTypeFlag_SupportsEditmode)) return 0;
return 1;
}
@@ -361,12 +361,12 @@ LinkNode *modifiers_calcDataMasks(struct Scene *scene, Object *ob, ModifierData
LinkNode *curr, *prev;
/* build a list of modifier data requirements in reverse order */
- for(; md; md = md->next) {
+ for (; md; md = md->next) {
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
CustomDataMask mask = 0;
- if(modifier_isEnabled(scene, md, required_mode))
- if(mti->requiredDataMask)
+ if (modifier_isEnabled(scene, md, required_mode))
+ if (mti->requiredDataMask)
mask = mti->requiredDataMask(ob, md);
BLI_linklist_prepend(&dataMasks, SET_INT_IN_POINTER(mask));
@@ -378,13 +378,14 @@ LinkNode *modifiers_calcDataMasks(struct Scene *scene, Object *ob, ModifierData
* note the list is currently in reverse order, so "masks that follow it"
* actually means "masks that precede it" at the moment
*/
- for(curr = dataMasks, prev = NULL; curr; prev = curr, curr = curr->next) {
- if(prev) {
+ for (curr = dataMasks, prev = NULL; curr; prev = curr, curr = curr->next) {
+ if (prev) {
CustomDataMask prev_mask = (CustomDataMask)GET_INT_FROM_POINTER(prev->link);
CustomDataMask curr_mask = (CustomDataMask)GET_INT_FROM_POINTER(curr->link);
curr->link = SET_INT_IN_POINTER(curr_mask | prev_mask);
- } else {
+ }
+ else {
CustomDataMask curr_mask = (CustomDataMask)GET_INT_FROM_POINTER(curr->link);
curr->link = SET_INT_IN_POINTER(curr_mask | dataMask);
@@ -405,8 +406,8 @@ ModifierData *modifiers_getLastPreview(struct Scene *scene, ModifierData *md, in
return tmp_md;
/* Find the latest modifier in stack generating preview. */
- for(; md; md = md->next) {
- if(modifier_isEnabled(scene, md, required_mode) && modifier_isPreview(md))
+ for (; md; md = md->next) {
+ if (modifier_isEnabled(scene, md, required_mode) && modifier_isPreview(md))
tmp_md = md;
}
return tmp_md;
@@ -451,18 +452,20 @@ ModifierData *modifiers_getVirtualModifierList(Object *ob)
md = ob->modifiers.first;
- if(ob->parent) {
- if(ob->parent->type==OB_ARMATURE && ob->partype==PARSKEL) {
+ if (ob->parent) {
+ if (ob->parent->type==OB_ARMATURE && ob->partype==PARSKEL) {
amd.object = ob->parent;
amd.modifier.next = md;
amd.deformflag= ((bArmature *)(ob->parent->data))->deformflag;
md = &amd.modifier;
- } else if(ob->parent->type==OB_CURVE && ob->partype==PARSKEL) {
+ }
+ else if (ob->parent->type==OB_CURVE && ob->partype==PARSKEL) {
cmd.object = ob->parent;
cmd.defaxis = ob->trackflag + 1;
cmd.modifier.next = md;
md = &cmd.modifier;
- } else if(ob->parent->type==OB_LATTICE && ob->partype==PARSKEL) {
+ }
+ else if (ob->parent->type==OB_LATTICE && ob->partype==PARSKEL) {
lmd.object = ob->parent;
lmd.modifier.next = md;
md = &lmd.modifier;
@@ -470,8 +473,8 @@ ModifierData *modifiers_getVirtualModifierList(Object *ob)
}
/* shape key modifier, not yet for curves */
- if(ELEM(ob->type, OB_MESH, OB_LATTICE) && ob_get_key(ob)) {
- if(ob->type == OB_MESH && (ob->shapeflag & OB_SHAPE_EDIT_MODE))
+ if (ELEM(ob->type, OB_MESH, OB_LATTICE) && ob_get_key(ob)) {
+ if (ob->type == OB_MESH && (ob->shapeflag & OB_SHAPE_EDIT_MODE))
smd.modifier.mode |= eModifierMode_Editmode|eModifierMode_OnCage;
else
smd.modifier.mode &= ~eModifierMode_Editmode|eModifierMode_OnCage;
@@ -562,9 +565,9 @@ int modifiers_isCorrectableDeformed(Object *ob)
ModifierData *md = modifiers_getVirtualModifierList(ob);
for (; md; md=md->next) {
- if(ob->mode==OB_MODE_EDIT && (md->mode & eModifierMode_Editmode)==0);
+ if (ob->mode==OB_MODE_EDIT && (md->mode & eModifierMode_Editmode)==0);
else
- if(modifier_isCorrectableDeformed(md))
+ if (modifier_isCorrectableDeformed(md))
return 1;
}
return 0;
@@ -596,10 +599,10 @@ int modifiers_indexInObject(Object *ob, ModifierData *md_seek)
void modifier_freeTemporaryData(ModifierData *md)
{
- if(md->type == eModifierType_Armature) {
+ if (md->type == eModifierType_Armature) {
ArmatureModifierData *amd= (ArmatureModifierData*)md;
- if(amd->prevCos) {
+ if (amd->prevCos) {
MEM_freeN(amd->prevCos);
amd->prevCos= NULL;
}
@@ -614,10 +617,10 @@ void test_object_modifiers(Object *ob)
/* just multires checked for now, since only multires
* modifies mesh data */
- if(ob->type != OB_MESH) return;
+ if (ob->type != OB_MESH) return;
- for(md = ob->modifiers.first; md; md = md->next) {
- if(md->type == eModifierType_Multires) {
+ for (md = ob->modifiers.first; md; md = md->next) {
+ if (md->type == eModifierType_Multires) {
MultiresModifierData *mmd = (MultiresModifierData*)md;
multiresModifier_set_levels_from_disps(mmd, ob);
diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c
index 4ef6a69d05b..0cecc09a9d7 100644
--- a/source/blender/blenkernel/intern/movieclip.c
+++ b/source/blender/blenkernel/intern/movieclip.c
@@ -91,7 +91,7 @@ static int sequence_guess_offset(const char *full_name, int head_len, int numlen
static int rendersize_to_proxy(MovieClipUser *user, int flag)
{
- if((flag&MCLIP_USE_PROXY)==0)
+ if ((flag&MCLIP_USE_PROXY)==0)
return IMB_PROXY_NONE;
switch(user->render_size) {
@@ -138,7 +138,7 @@ static int rendersize_to_number(int render_size)
static int get_timecode(MovieClip *clip, int flag)
{
- if((flag&MCLIP_USE_PROXY)==0)
+ if ((flag&MCLIP_USE_PROXY)==0)
return IMB_TC_NONE;
return clip->proxy.tc;
@@ -171,13 +171,14 @@ static void get_proxy_fname(MovieClip *clip, int proxy_render_size, int undistor
BLI_split_dirfile(clip->name, clipdir, clipfile, FILE_MAX, FILE_MAX);
- if(clip->flag&MCLIP_USE_PROXY_CUSTOM_DIR) {
+ if (clip->flag&MCLIP_USE_PROXY_CUSTOM_DIR) {
BLI_strncpy(dir, clip->proxy.dir, sizeof(dir));
- } else {
+ }
+ else {
BLI_snprintf(dir, FILE_MAX, "%s/BL_proxy", clipdir);
}
- if(undistorted)
+ if (undistorted)
BLI_snprintf(name, FILE_MAX, "%s/%s/proxy_%d_undistorted/%08d", dir, clipfile, size, framenr);
else
BLI_snprintf(name, FILE_MAX, "%s/%s/proxy_%d/%08d", dir, clipfile, size, framenr);
@@ -195,10 +196,11 @@ static ImBuf *movieclip_load_sequence_file(MovieClip *clip, MovieClipUser *user,
int loadflag, use_proxy= 0;
use_proxy= (flag&MCLIP_USE_PROXY) && user->render_size != MCLIP_PROXY_RENDER_SIZE_FULL;
- if(use_proxy) {
+ if (use_proxy) {
int undistort= user->render_flag&MCLIP_PROXY_RENDER_UNDISTORT;
get_proxy_fname(clip, user->render_size, undistort, framenr, name);
- } else
+ }
+ else
get_sequence_fname(clip, framenr, name);
loadflag= IB_rect|IB_multilayer;
@@ -216,15 +218,15 @@ static ImBuf *movieclip_load_movie_file(MovieClip *clip, MovieClipUser *user, in
int proxy= rendersize_to_proxy(user, flag);
char str[FILE_MAX];
- if(!clip->anim) {
+ if (!clip->anim) {
BLI_strncpy(str, clip->name, FILE_MAX);
BLI_path_abs(str, ID_BLEND_PATH(G.main, &clip->id));
/* FIXME: make several stream accessible in image editor, too */
clip->anim= openanim(str, IB_rect, 0);
- if(clip->anim) {
- if(clip->flag&MCLIP_USE_PROXY_CUSTOM_DIR) {
+ if (clip->anim) {
+ if (clip->flag&MCLIP_USE_PROXY_CUSTOM_DIR) {
char dir[FILE_MAX];
BLI_strncpy(dir, clip->proxy.dir, sizeof(dir));
BLI_path_abs(dir, G.main->name);
@@ -233,17 +235,17 @@ static ImBuf *movieclip_load_movie_file(MovieClip *clip, MovieClipUser *user, in
}
}
- if(clip->anim) {
+ if (clip->anim) {
int dur;
int fra;
dur= IMB_anim_get_duration(clip->anim, tc);
fra= framenr-1;
- if(fra<0)
+ if (fra<0)
fra= 0;
- if(fra>(dur-1))
+ if (fra>(dur-1))
fra= dur-1;
ibuf= IMB_anim_absolute(clip->anim, fra, tc, proxy);
@@ -313,26 +315,26 @@ static int moviecache_hashcmp(const void *av, const void *bv)
const MovieClipImBufCacheKey *a= (MovieClipImBufCacheKey*)av;
const MovieClipImBufCacheKey *b= (MovieClipImBufCacheKey*)bv;
- if(a->framenr<b->framenr) return -1;
- else if(a->framenr>b->framenr) return 1;
+ if (a->framenr<b->framenr) return -1;
+ else if (a->framenr>b->framenr) return 1;
- if(a->proxy<b->proxy) return -1;
- else if(a->proxy>b->proxy) return 1;
+ if (a->proxy<b->proxy) return -1;
+ else if (a->proxy>b->proxy) return 1;
- if(a->render_flag<b->render_flag) return -1;
- else if(a->render_flag>b->render_flag) return 1;
+ if (a->render_flag<b->render_flag) return -1;
+ else if (a->render_flag>b->render_flag) return 1;
return 0;
}
static ImBuf *get_imbuf_cache(MovieClip *clip, MovieClipUser *user, int flag)
{
- if(clip->cache) {
+ if (clip->cache) {
MovieClipImBufCacheKey key;
key.framenr= user->framenr;
- if(flag&MCLIP_USE_PROXY) {
+ if (flag&MCLIP_USE_PROXY) {
key.proxy= rendersize_to_proxy(user, flag);
key.render_flag= user->render_flag;
}
@@ -351,7 +353,7 @@ static void put_imbuf_cache(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf, i
{
MovieClipImBufCacheKey key;
- if(!clip->cache) {
+ if (!clip->cache) {
clip->cache= MEM_callocN(sizeof(MovieClipCache), "movieClipCache");
clip->cache->moviecache= IMB_moviecache_create(sizeof(MovieClipImBufCacheKey), moviecache_hashhash,
@@ -360,7 +362,7 @@ static void put_imbuf_cache(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf, i
key.framenr= user->framenr;
- if(flag&MCLIP_USE_PROXY) {
+ if (flag&MCLIP_USE_PROXY) {
key.proxy= rendersize_to_proxy(user, flag);
key.render_flag= user->render_flag;
}
@@ -412,15 +414,15 @@ MovieClip *BKE_add_movieclip_file(const char *name)
/* exists? */
file= BLI_open(str, O_BINARY|O_RDONLY,0);
- if(file== -1) return NULL;
+ if (file== -1) return NULL;
close(file);
/* ** first search an identical clip ** */
- for(clip= G.main->movieclip.first; clip; clip= clip->id.next) {
+ for (clip= G.main->movieclip.first; clip; clip= clip->id.next) {
BLI_strncpy(strtest, clip->name, sizeof(clip->name));
BLI_path_abs(strtest, G.main->name);
- if(strcmp(strtest, str)==0) {
+ if (strcmp(strtest, str)==0) {
BLI_strncpy(clip->name, name, sizeof(clip->name)); /* for stringcode */
clip->id.us++; /* officially should not, it doesn't link here! */
@@ -439,12 +441,12 @@ MovieClip *BKE_add_movieclip_file(const char *name)
clip= movieclip_alloc(libname);
BLI_strncpy(clip->name, name, sizeof(clip->name));
- if(BLI_testextensie_array(name, imb_ext_movie)) clip->source= MCLIP_SRC_MOVIE;
+ if (BLI_testextensie_array(name, imb_ext_movie)) clip->source= MCLIP_SRC_MOVIE;
else clip->source= MCLIP_SRC_SEQUENCE;
user.framenr= 1;
BKE_movieclip_get_size(clip, &user, &width, &height);
- if(width && height) {
+ if (width && height) {
clip->tracking.camera.principal[0]= ((float)width)/2;
clip->tracking.camera.principal[1]= ((float)height)/2;
@@ -459,7 +461,7 @@ static void real_ibuf_size(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf, in
*width= ibuf->x;
*height= ibuf->y;
- if(clip->flag&MCLIP_USE_PROXY) {
+ if (clip->flag&MCLIP_USE_PROXY) {
switch(user->render_size) {
case MCLIP_PROXY_RENDER_SIZE_25:
(*width)*= 4;
@@ -487,12 +489,12 @@ static ImBuf *get_undistorted_ibuf(MovieClip *clip, struct MovieDistortion *dist
* otherwise, undistorted proxy can be darker than it should */
imb_freerectfloatImBuf(ibuf);
- if(distortion)
+ if (distortion)
undistibuf= BKE_tracking_distortion_exec(distortion, &clip->tracking, ibuf, ibuf->x, ibuf->y, 0.0f, 1);
else
undistibuf= BKE_tracking_undistort(&clip->tracking, ibuf, ibuf->x, ibuf->y, 0.0f);
- if(undistibuf->userflags&IB_RECT_INVALID) {
+ if (undistibuf->userflags&IB_RECT_INVALID) {
ibuf->userflags&= ~IB_RECT_INVALID;
IMB_rect_from_float(undistibuf);
}
@@ -507,7 +509,7 @@ static int need_undistortion_postprocess(MovieClipUser *user, int flag)
int result = 0;
/* only full undistorted render can be used as on-fly undistorting image */
- if(flag & MCLIP_USE_PROXY) {
+ if (flag & MCLIP_USE_PROXY) {
result |= (user->render_size == MCLIP_PROXY_RENDER_SIZE_FULL) &&
(user->render_flag & MCLIP_PROXY_RENDER_UNDISTORT) != 0;
}
@@ -530,10 +532,10 @@ static int check_undistortion_cache_flags(MovieClip *clip)
MovieTrackingCamera *camera= &clip->tracking.camera;
/* check for distortion model changes */
- if(!equals_v2v2(camera->principal, cache->postprocessed.principal))
+ if (!equals_v2v2(camera->principal, cache->postprocessed.principal))
return 0;
- if(!equals_v3v3(&camera->k1, &cache->postprocessed.k1))
+ if (!equals_v3v3(&camera->k1, &cache->postprocessed.k1))
return 0;
return 1;
@@ -546,31 +548,31 @@ static ImBuf *get_postprocessed_cached_frame(MovieClip *clip, MovieClipUser *use
short proxy= IMB_PROXY_NONE;
int render_flag= 0;
- if(flag&MCLIP_USE_PROXY) {
+ if (flag&MCLIP_USE_PROXY) {
proxy= rendersize_to_proxy(user, flag);
render_flag= user->render_flag;
}
/* no cache or no cached postprocessed image */
- if(!clip->cache || !clip->cache->postprocessed.ibuf)
+ if (!clip->cache || !clip->cache->postprocessed.ibuf)
return NULL;
/* postprocessing happened for other frame */
- if(cache->postprocessed.framenr != framenr)
+ if (cache->postprocessed.framenr != framenr)
return NULL;
/* cached ibuf used different proxy settings */
- if(cache->postprocessed.render_flag != render_flag || cache->postprocessed.proxy != proxy)
+ if (cache->postprocessed.render_flag != render_flag || cache->postprocessed.proxy != proxy)
return NULL;
- if(cache->postprocessed.flag != postprocess_flag)
+ if (cache->postprocessed.flag != postprocess_flag)
return NULL;
- if(need_undistortion_postprocess(user, flag)) {
- if(!check_undistortion_cache_flags(clip))
+ if (need_undistortion_postprocess(user, flag)) {
+ if (!check_undistortion_cache_flags(clip))
return NULL;
}
- else if(cache->postprocessed.undistoriton_used)
+ else if (cache->postprocessed.undistoriton_used)
return NULL;
IMB_refImBuf(cache->postprocessed.ibuf);
@@ -584,13 +586,13 @@ static ImBuf *put_postprocessed_frame_to_cache(MovieClip *clip, MovieClipUser *u
MovieTrackingCamera *camera= &clip->tracking.camera;
ImBuf *postproc_ibuf = NULL;
- if(cache->postprocessed.ibuf)
+ if (cache->postprocessed.ibuf)
IMB_freeImBuf(cache->postprocessed.ibuf);
cache->postprocessed.framenr= user->framenr;
cache->postprocessed.flag = postprocess_flag;
- if(flag&MCLIP_USE_PROXY) {
+ if (flag&MCLIP_USE_PROXY) {
cache->postprocessed.proxy= rendersize_to_proxy(user, flag);
cache->postprocessed.render_flag= user->render_flag;
}
@@ -599,7 +601,7 @@ static ImBuf *put_postprocessed_frame_to_cache(MovieClip *clip, MovieClipUser *u
cache->postprocessed.render_flag = 0;
}
- if(need_undistortion_postprocess(user, flag)) {
+ if (need_undistortion_postprocess(user, flag)) {
copy_v2_v2(cache->postprocessed.principal, camera->principal);
copy_v3_v3(&cache->postprocessed.k1, &camera->k1);
cache->postprocessed.undistoriton_used = 1;
@@ -607,16 +609,16 @@ static ImBuf *put_postprocessed_frame_to_cache(MovieClip *clip, MovieClipUser *u
}
else cache->postprocessed.undistoriton_used = 0;
- if(postprocess_flag) {
+ if (postprocess_flag) {
int disable_red = postprocess_flag & MOVIECLIP_DISABLE_RED,
disable_green = postprocess_flag & MOVIECLIP_DISABLE_GREEN,
disable_blue = postprocess_flag & MOVIECLIP_DISABLE_BLUE,
grayscale = postprocess_flag & MOVIECLIP_PREVIEW_GRAYSCALE;
- if(!postproc_ibuf)
+ if (!postproc_ibuf)
postproc_ibuf = IMB_dupImBuf(ibuf);
- if(disable_red || disable_green || disable_blue || grayscale)
+ if (disable_red || disable_green || disable_blue || grayscale)
BKE_tracking_disable_imbuf_channels(postproc_ibuf, disable_red, disable_green, disable_blue, 1);
}
@@ -624,7 +626,7 @@ static ImBuf *put_postprocessed_frame_to_cache(MovieClip *clip, MovieClipUser *u
cache->postprocessed.ibuf= postproc_ibuf;
- if(cache->stabilized.ibuf) {
+ if (cache->stabilized.ibuf) {
/* force stable buffer be re-calculated */
IMB_freeImBuf(cache->stabilized.ibuf);
cache->stabilized.ibuf= NULL;
@@ -644,39 +646,39 @@ static ImBuf *movieclip_get_postprocessed_ibuf(MovieClip *clip, MovieClipUser *u
BLI_lock_thread(LOCK_MOVIECLIP);
/* try to obtain cached postprocessed frame first */
- if(need_postprocessed_frame(user, flag, postprocess_flag)) {
+ if (need_postprocessed_frame(user, flag, postprocess_flag)) {
ibuf= get_postprocessed_cached_frame(clip, user, flag, postprocess_flag);
- if(!ibuf)
+ if (!ibuf)
need_postprocess= 1;
}
- if(!ibuf)
+ if (!ibuf)
ibuf= get_imbuf_cache(clip, user, flag);
- if(!ibuf) {
+ if (!ibuf) {
int use_sequence= 0;
/* undistorted proxies for movies should be read as image sequence */
use_sequence= (user->render_flag&MCLIP_PROXY_RENDER_UNDISTORT) &&
(user->render_size!=MCLIP_PROXY_RENDER_SIZE_FULL);
- if(clip->source==MCLIP_SRC_SEQUENCE || use_sequence)
+ if (clip->source==MCLIP_SRC_SEQUENCE || use_sequence)
ibuf= movieclip_load_sequence_file(clip, user, framenr, flag);
else {
ibuf= movieclip_load_movie_file(clip, user, framenr, flag);
}
- if(ibuf && (cache_flag & MOVIECLIP_CACHE_SKIP) == 0)
+ if (ibuf && (cache_flag & MOVIECLIP_CACHE_SKIP) == 0)
put_imbuf_cache(clip, user, ibuf, flag);
}
- if(ibuf) {
+ if (ibuf) {
clip->lastframe= framenr;
real_ibuf_size(clip, user, ibuf, &clip->lastsize[0], &clip->lastsize[1]);
/* postprocess frame and put to cache */
- if(need_postprocess) {
+ if (need_postprocess) {
ImBuf *tmpibuf= ibuf;
ibuf= put_postprocessed_frame_to_cache(clip, user, tmpibuf, flag, postprocess_flag);
IMB_freeImBuf(tmpibuf);
@@ -712,27 +714,27 @@ static ImBuf *get_stable_cached_frame(MovieClip *clip, MovieClipUser *user, int
short proxy = IMB_PROXY_NONE;
int render_flag = 0;
- if(clip->flag&MCLIP_USE_PROXY) {
+ if (clip->flag&MCLIP_USE_PROXY) {
proxy = rendersize_to_proxy(user, clip->flag);
render_flag = user->render_flag;
}
/* there's no cached frame or it was calculated for another frame */
- if(!cache->stabilized.ibuf || cache->stabilized.framenr != framenr)
+ if (!cache->stabilized.ibuf || cache->stabilized.framenr != framenr)
return NULL;
/* cached ibuf used different proxy settings */
- if(cache->stabilized.render_flag!=render_flag || cache->stabilized.proxy!=proxy)
+ if (cache->stabilized.render_flag!=render_flag || cache->stabilized.proxy!=proxy)
return NULL;
- if(cache->stabilized.postprocess_flag != postprocess_flag)
+ if (cache->stabilized.postprocess_flag != postprocess_flag)
return NULL;
/* stabilization also depends on pixel aspect ratio */
- if(cache->stabilized.aspect != tracking->camera.pixel_aspect)
+ if (cache->stabilized.aspect != tracking->camera.pixel_aspect)
return NULL;
- if(cache->stabilized.filter != tracking->stabilization.filter)
+ if (cache->stabilized.filter != tracking->stabilization.filter)
return NULL;
stableibuf = cache->stabilized.ibuf;
@@ -740,7 +742,7 @@ static ImBuf *get_stable_cached_frame(MovieClip *clip, MovieClipUser *user, int
BKE_tracking_stabilization_data(&clip->tracking, framenr, stableibuf->x, stableibuf->y, tloc, &tscale, &tangle);
/* check for stabilization parameters */
- if(tscale != cache->stabilized.scale ||
+ if (tscale != cache->stabilized.scale ||
tangle != cache->stabilized.angle ||
!equals_v2v2(tloc, cache->stabilized.loc))
{
@@ -760,7 +762,7 @@ static ImBuf *put_stabilized_frame_to_cache(MovieClip *clip, MovieClipUser *user
ImBuf *stableibuf;
float tloc[2], tscale, tangle;
- if(cache->stabilized.ibuf)
+ if (cache->stabilized.ibuf)
IMB_freeImBuf(cache->stabilized.ibuf);
stableibuf = BKE_tracking_stabilize(&clip->tracking, framenr, ibuf, tloc, &tscale, &tangle);
@@ -775,7 +777,7 @@ static ImBuf *put_stabilized_frame_to_cache(MovieClip *clip, MovieClipUser *user
cache->stabilized.aspect = tracking->camera.pixel_aspect;
cache->stabilized.filter = tracking->stabilization.filter;
- if(clip->flag&MCLIP_USE_PROXY) {
+ if (clip->flag&MCLIP_USE_PROXY) {
cache->stabilized.proxy= rendersize_to_proxy(user, clip->flag);
cache->stabilized.render_flag= user->render_flag;
}
@@ -798,29 +800,30 @@ ImBuf *BKE_movieclip_get_stable_ibuf(MovieClip *clip, MovieClipUser *user, float
ibuf= BKE_movieclip_get_postprocessed_ibuf(clip, user, postprocess_flag);
- if(!ibuf)
+ if (!ibuf)
return NULL;
- if(clip->tracking.stabilization.flag&TRACKING_2D_STABILIZATION) {
+ if (clip->tracking.stabilization.flag&TRACKING_2D_STABILIZATION) {
MovieClipCache *cache= clip->cache;
stableibuf= get_stable_cached_frame(clip, user, framenr, postprocess_flag);
- if(!stableibuf)
+ if (!stableibuf)
stableibuf= put_stabilized_frame_to_cache(clip, user, ibuf, framenr, postprocess_flag);
- if(loc) copy_v2_v2(loc, cache->stabilized.loc);
- if(scale) *scale= cache->stabilized.scale;
- if(angle) *angle= cache->stabilized.angle;
- } else {
- if(loc) zero_v2(loc);
- if(scale) *scale= 1.0f;
- if(angle) *angle= 0.0f;
+ if (loc) copy_v2_v2(loc, cache->stabilized.loc);
+ if (scale) *scale= cache->stabilized.scale;
+ if (angle) *angle= cache->stabilized.angle;
+ }
+ else {
+ if (loc) zero_v2(loc);
+ if (scale) *scale= 1.0f;
+ if (angle) *angle= 0.0f;
stableibuf= ibuf;
}
- if(stableibuf!=ibuf) {
+ if (stableibuf!=ibuf) {
IMB_freeImBuf(ibuf);
ibuf= stableibuf;
}
@@ -833,7 +836,7 @@ int BKE_movieclip_has_frame(MovieClip *clip, MovieClipUser *user)
{
ImBuf *ibuf= BKE_movieclip_get_ibuf(clip, user);
- if(ibuf) {
+ if (ibuf) {
IMB_freeImBuf(ibuf);
return 1;
}
@@ -843,20 +846,22 @@ int BKE_movieclip_has_frame(MovieClip *clip, MovieClipUser *user)
void BKE_movieclip_get_size(MovieClip *clip, MovieClipUser *user, int *width, int *height)
{
- if(user->framenr==clip->lastframe) {
+ if (user->framenr==clip->lastframe) {
*width= clip->lastsize[0];
*height= clip->lastsize[1];
- } else {
+ }
+ else {
ImBuf *ibuf= BKE_movieclip_get_ibuf(clip, user);
- if(ibuf && ibuf->x && ibuf->y) {
+ if (ibuf && ibuf->x && ibuf->y) {
real_ibuf_size(clip, user, ibuf, width, height);
- } else {
+ }
+ else {
*width= 0;
*height= 0;
}
- if(ibuf)
+ if (ibuf)
IMB_freeImBuf(ibuf);
}
}
@@ -880,7 +885,7 @@ void BKE_movieclip_get_cache_segments(MovieClip *clip, MovieClipUser *user, int
*totseg_r= 0;
*points_r= NULL;
- if(clip->cache) {
+ if (clip->cache) {
int proxy= rendersize_to_proxy(user, clip->flag);
IMB_moviecache_get_cache_segments(clip->cache->moviecache, proxy, user->render_flag, totseg_r, points_r);
@@ -896,20 +901,20 @@ void BKE_movieclip_user_set_frame(MovieClipUser *iuser, int framenr)
static void free_buffers(MovieClip *clip)
{
- if(clip->cache) {
+ if (clip->cache) {
IMB_moviecache_free(clip->cache->moviecache);
- if(clip->cache->postprocessed.ibuf)
+ if (clip->cache->postprocessed.ibuf)
IMB_freeImBuf(clip->cache->postprocessed.ibuf);
- if(clip->cache->stabilized.ibuf)
+ if (clip->cache->stabilized.ibuf)
IMB_freeImBuf(clip->cache->stabilized.ibuf);
MEM_freeN(clip->cache);
clip->cache= NULL;
}
- if(clip->anim) {
+ if (clip->anim) {
IMB_free_anim(clip->anim);
clip->anim= FALSE;
}
@@ -925,16 +930,16 @@ void BKE_movieclip_reload(MovieClip *clip)
clip->tracking.stabilization.ok= 0;
/* update clip source */
- if(BLI_testextensie_array(clip->name, imb_ext_movie)) clip->source= MCLIP_SRC_MOVIE;
+ if (BLI_testextensie_array(clip->name, imb_ext_movie)) clip->source= MCLIP_SRC_MOVIE;
else clip->source= MCLIP_SRC_SEQUENCE;
}
void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClipScopes *scopes)
{
- if(scopes->ok)
+ if (scopes->ok)
return;
- if(scopes->track_preview) {
+ if (scopes->track_preview) {
IMB_freeImBuf(scopes->track_preview);
scopes->track_preview= NULL;
}
@@ -942,25 +947,26 @@ void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClip
scopes->marker= NULL;
scopes->track= NULL;
- if(clip) {
+ if (clip) {
MovieTrackingTrack *act_track= BKE_tracking_active_track(&clip->tracking);
- if(act_track) {
+ if (act_track) {
MovieTrackingTrack *track= act_track;
MovieTrackingMarker *marker= BKE_tracking_get_marker(track, user->framenr);
- if(marker->flag&MARKER_DISABLED) {
+ if (marker->flag&MARKER_DISABLED) {
scopes->track_disabled= 1;
- } else {
+ }
+ else {
ImBuf *ibuf= BKE_movieclip_get_ibuf(clip, user);
scopes->track_disabled= 0;
- if(ibuf && ibuf->rect) {
+ if (ibuf && ibuf->rect) {
ImBuf *tmpibuf;
MovieTrackingMarker undist_marker= *marker;
- if(user->render_flag&MCLIP_PROXY_RENDER_UNDISTORT) {
+ if (user->render_flag&MCLIP_PROXY_RENDER_UNDISTORT) {
int width, height;
float aspy= 1.0f/clip->tracking.camera.pixel_aspect;
@@ -979,10 +985,10 @@ void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClip
tmpibuf= BKE_tracking_get_pattern_imbuf(ibuf, track, &undist_marker, 3 /* margin */,
1 /* anchor */, scopes->track_pos, NULL);
- if(tmpibuf->rect_float)
+ if (tmpibuf->rect_float)
IMB_rect_from_float(tmpibuf);
- if(tmpibuf->rect)
+ if (tmpibuf->rect)
scopes->track_preview= tmpibuf;
else
IMB_freeImBuf(tmpibuf);
@@ -991,7 +997,7 @@ void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClip
IMB_freeImBuf(ibuf);
}
- if((track->flag&TRACK_LOCKED)==0) {
+ if ((track->flag&TRACK_LOCKED)==0) {
scopes->marker= marker;
scopes->track= track;
scopes->slide_scale[0]= track->pat_max[0]-track->pat_min[0];
@@ -1024,13 +1030,13 @@ static void movieclip_build_proxy_ibuf(MovieClip *clip, ImBuf *ibuf, int cfra, i
scaleibuf->ftype= JPG | quality;
/* unsupported feature only confuses other s/w */
- if(scaleibuf->planes==32)
+ if (scaleibuf->planes==32)
scaleibuf->planes= 24;
BLI_lock_thread(LOCK_MOVIECLIP);
BLI_make_existing_file(name);
- if(IMB_saveiff(scaleibuf, name, IB_rect)==0)
+ if (IMB_saveiff(scaleibuf, name, IB_rect)==0)
perror(name);
BLI_unlock_thread(LOCK_MOVIECLIP);
@@ -1050,19 +1056,19 @@ void BKE_movieclip_build_proxy_frame(MovieClip *clip, int clip_flag, struct Movi
ibuf= BKE_movieclip_get_ibuf_flag(clip, &user, clip_flag, MOVIECLIP_CACHE_SKIP);
- if(ibuf) {
+ if (ibuf) {
ImBuf *tmpibuf= ibuf;
int i;
- if(undistorted)
+ if (undistorted)
tmpibuf= get_undistorted_ibuf(clip, distortion, ibuf);
- for(i= 0; i<build_count; i++)
+ for (i= 0; i<build_count; i++)
movieclip_build_proxy_ibuf(clip, tmpibuf, cfra, build_sizes[i], undistorted);
IMB_freeImBuf(ibuf);
- if(tmpibuf!=ibuf)
+ if (tmpibuf!=ibuf)
IMB_freeImBuf(tmpibuf);
}
}
@@ -1082,21 +1088,21 @@ void unlink_movieclip(Main *bmain, MovieClip *clip)
Scene *sce;
Object *ob;
- for(scr= bmain->screen.first; scr; scr= scr->id.next) {
- for(area= scr->areabase.first; area; area= area->next) {
- for(sl= area->spacedata.first; sl; sl= sl->next) {
- if(sl->spacetype==SPACE_CLIP) {
+ for (scr= bmain->screen.first; scr; scr= scr->id.next) {
+ for (area= scr->areabase.first; area; area= area->next) {
+ for (sl= area->spacedata.first; sl; sl= sl->next) {
+ if (sl->spacetype==SPACE_CLIP) {
SpaceClip *sc= (SpaceClip *) sl;
- if(sc->clip==clip)
+ if (sc->clip==clip)
sc->clip= NULL;
}
- else if(sl->spacetype==SPACE_VIEW3D) {
+ else if (sl->spacetype==SPACE_VIEW3D) {
View3D *v3d= (View3D *) sl;
BGpic *bgpic;
- for(bgpic= v3d->bgpicbase.first; bgpic; bgpic= bgpic->next) {
- if(bgpic->clip==clip)
+ for (bgpic= v3d->bgpicbase.first; bgpic; bgpic= bgpic->next) {
+ if (bgpic->clip==clip)
bgpic->clip= NULL;
}
}
@@ -1104,27 +1110,27 @@ void unlink_movieclip(Main *bmain, MovieClip *clip)
}
}
- for(sce= bmain->scene.first; sce; sce= sce->id.next) {
- if(sce->clip==clip)
+ for (sce= bmain->scene.first; sce; sce= sce->id.next) {
+ if (sce->clip==clip)
sce->clip= NULL;
}
- for(ob= bmain->object.first; ob; ob= ob->id.next) {
+ for (ob= bmain->object.first; ob; ob= ob->id.next) {
bConstraint *con;
- for(con= ob->constraints.first; con; con= con->next) {
+ for (con= ob->constraints.first; con; con= con->next) {
bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
- if(cti->type==CONSTRAINT_TYPE_FOLLOWTRACK) {
+ if (cti->type==CONSTRAINT_TYPE_FOLLOWTRACK) {
bFollowTrackConstraint *data= (bFollowTrackConstraint *) con->data;
- if(data->clip==clip)
+ if (data->clip==clip)
data->clip= NULL;
}
- else if(cti->type==CONSTRAINT_TYPE_CAMERASOLVER) {
+ else if (cti->type==CONSTRAINT_TYPE_CAMERASOLVER) {
bCameraSolverConstraint *data= (bCameraSolverConstraint *) con->data;
- if(data->clip==clip)
+ if (data->clip==clip)
data->clip= NULL;
}
}
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c
index e9b08f8c66c..d8117aa1344 100644
--- a/source/blender/blenkernel/intern/multires.c
+++ b/source/blender/blenkernel/intern/multires.c
@@ -81,7 +81,7 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm
void multires_customdata_delete(Mesh *me)
{
- if(me->edit_btmesh) {
+ if (me->edit_btmesh) {
BMEditMesh *em= me->edit_btmesh;
/* CustomData_external_remove is used here only to mark layer
* as non-external for further free-ing, so zero element count
@@ -116,7 +116,7 @@ static BLI_bitmap multires_mdisps_upsample_hidden(BLI_bitmap lo_hidden,
BLI_assert(lo_level <= hi_level);
/* fast case */
- if(lo_level == hi_level)
+ if (lo_level == hi_level)
return MEM_dupallocN(lo_hidden);
subd = BLI_BITMAP_NEW(hi_gridsize * hi_gridsize, "MDisps.hidden upsample");
@@ -125,28 +125,28 @@ static BLI_bitmap multires_mdisps_upsample_hidden(BLI_bitmap lo_hidden,
offset = 1 << (hi_level - lo_level - 1);
/* low-res blocks */
- for(yl = 0; yl < lo_gridsize; yl++) {
- for(xl = 0; xl < lo_gridsize; xl++) {
+ for (yl = 0; yl < lo_gridsize; yl++) {
+ for (xl = 0; xl < lo_gridsize; xl++) {
int lo_val = BLI_BITMAP_GET(lo_hidden, yl * lo_gridsize + xl);
/* high-res blocks */
- for(yo = -offset; yo <= offset; yo++) {
+ for (yo = -offset; yo <= offset; yo++) {
yh = yl * factor + yo;
- if(yh < 0 || yh >= hi_gridsize)
+ if (yh < 0 || yh >= hi_gridsize)
continue;
- for(xo = -offset; xo <= offset; xo++) {
+ for (xo = -offset; xo <= offset; xo++) {
xh = xl * factor + xo;
- if(xh < 0 || xh >= hi_gridsize)
+ if (xh < 0 || xh >= hi_gridsize)
continue;
hi_ndx = yh * hi_gridsize + xh;
- if(prev_hidden) {
+ if (prev_hidden) {
/* If prev_hidden is available, copy it to
subd, except when the equivalent element in
lo_hidden is different */
- if(lo_val != prev_hidden[hi_ndx])
+ if (lo_val != prev_hidden[hi_ndx])
BLI_BITMAP_MODIFY(subd, hi_ndx, lo_val);
else
BLI_BITMAP_MODIFY(subd, hi_ndx, prev_hidden[hi_ndx]);
@@ -178,8 +178,8 @@ static BLI_bitmap multires_mdisps_downsample_hidden(BLI_bitmap old_hidden,
- for(y = 0; y < new_gridsize; y++) {
- for(x = 0; x < new_gridsize; x++) {
+ for (y = 0; y < new_gridsize; y++) {
+ for (x = 0; x < new_gridsize; x++) {
old_value = BLI_BITMAP_GET(old_hidden,
factor*y*old_gridsize + x*factor);
@@ -223,7 +223,7 @@ static void multires_mdisps_subdivide_hidden(MDisps *md, int new_level)
BLI_assert(md->hidden);
/* nothing to do if already subdivided enough */
- if(md->level >= new_level)
+ if (md->level >= new_level)
return;
subd = multires_mdisps_upsample_hidden(md->hidden,
@@ -248,13 +248,13 @@ static MDisps *multires_mdisps_initialize_hidden(Mesh *me, int level)
int hide = 0;
for (j = 0; j < me->mpoly[i].totloop; j++) {
- if(me->mvert[me->mloop[me->mpoly[i].loopstart + j].v].flag & ME_HIDE) {
+ if (me->mvert[me->mloop[me->mpoly[i].loopstart + j].v].flag & ME_HIDE) {
hide = 1;
break;
}
}
- if(!hide)
+ if (!hide)
continue;
for (j = 0; j < me->mpoly[i].totloop; j++) {
@@ -264,7 +264,7 @@ static MDisps *multires_mdisps_initialize_hidden(Mesh *me, int level)
md->hidden = BLI_BITMAP_NEW(gridarea, "MDisps.hidden initialize");
- for(k = 0; k < gridarea; k++)
+ for (k = 0; k < gridarea; k++)
BLI_BITMAP_SET(md->hidden, k);
}
}
@@ -1154,21 +1154,21 @@ void multires_modifier_update_hidden(DerivedMesh *dm)
int totlvl = ccgdm->multires.totlvl;
int lvl = ccgdm->multires.lvl;
- if(mdisps) {
+ if (mdisps) {
int i;
- for(i = 0; i < me->totloop; i++) {
+ for (i = 0; i < me->totloop; i++) {
MDisps *md = &mdisps[i];
BLI_bitmap gh = grid_hidden[i];
- if(!gh && md->hidden) {
+ if (!gh && md->hidden) {
MEM_freeN(md->hidden);
md->hidden = NULL;
}
- else if(gh) {
+ else if (gh) {
gh = multires_mdisps_upsample_hidden(gh, lvl, totlvl,
md->hidden);
- if(md->hidden)
+ if (md->hidden)
MEM_freeN(md->hidden);
md->hidden = gh;
@@ -1370,7 +1370,7 @@ DerivedMesh *multires_dm_create_from_derived(MultiresModifierData *mmd,
multiresModifier_disp_run(result, ob->data, dm, APPLY_DISPLACEMENTS, subGridData, mmd->totlvl);
/* copy hidden elements for this level */
- if(ccgdm)
+ if (ccgdm)
multires_output_hidden_to_ccgdm(ccgdm, me, lvl);
for (i = 0; i < numGrids; i++)
diff --git a/source/blender/blenkernel/intern/navmesh_conversion.c b/source/blender/blenkernel/intern/navmesh_conversion.c
index f14482c4cb3..27e309e9d20 100644
--- a/source/blender/blenkernel/intern/navmesh_conversion.c
+++ b/source/blender/blenkernel/intern/navmesh_conversion.c
@@ -501,7 +501,7 @@ exit:
int polyFindVertex(const unsigned short* p, const int vertsPerPoly, unsigned short vertexIdx)
{
int i, res = -1;
- for(i=0; i<vertsPerPoly; i++)
+ for (i=0; i<vertsPerPoly; i++)
{
if (p[i]==0xffff)
break;
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index d319cfe60fc..a1ea201bd7a 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -87,7 +87,7 @@ bNodeTreeType *ntreeGetType(int type)
types_init = 0;
}
- if(type >= 0 && type < NUM_NTREE_TYPES) {
+ if (type >= 0 && type < NUM_NTREE_TYPES) {
return types[type];
}
else {
@@ -98,8 +98,8 @@ bNodeTreeType *ntreeGetType(int type)
static bNodeType *node_get_type(bNodeTree *ntree, int type)
{
bNodeType *ntype = ntreeGetType(ntree->type)->node_types.first;
- for(; ntype; ntype= ntype->next)
- if(ntype->type==type)
+ for (; ntype; ntype= ntype->next)
+ if (ntype->type==type)
return ntype;
return NULL;
@@ -120,7 +120,7 @@ bNodeSocketType *ntreeGetSocketType(int type)
types_init= 0;
}
- if(type < NUM_SOCKET_TYPES) {
+ if (type < NUM_SOCKET_TYPES) {
return types[type];
}
else {
@@ -132,23 +132,23 @@ void ntreeInitTypes(bNodeTree *ntree)
{
bNode *node, *next;
- for(node= ntree->nodes.first; node; node= next) {
+ for (node= ntree->nodes.first; node; node= next) {
next= node->next;
node->typeinfo= node_get_type(ntree, node->type);
- if(node->type==NODE_DYNAMIC) {
+ if (node->type==NODE_DYNAMIC) {
/* needed info if the pynode script fails now: */
node->storage= ntree;
- if(node->id!=NULL) { /* not an empty script node */
+ if (node->id!=NULL) { /* not an empty script node */
node->custom1= 0;
node->custom1= BSET(node->custom1,NODE_DYNAMIC_ADDEXIST);
}
-// if(node->typeinfo)
+// if (node->typeinfo)
// node->typeinfo->initfunc(node);
}
- if(node->typeinfo==NULL) {
+ if (node->typeinfo==NULL) {
printf("Error: Node type %s doesn't exist anymore, removed\n", node->name);
nodeFreeNode(ntree, node);
}
@@ -204,9 +204,9 @@ void nodeRemoveSocket(bNodeTree *ntree, bNode *node, bNodeSocket *sock)
{
bNodeLink *link, *next;
- for(link= ntree->links.first; link; link= next) {
+ for (link= ntree->links.first; link; link= next) {
next= link->next;
- if(link->fromsock==sock || link->tosock==sock) {
+ if (link->fromsock==sock || link->tosock==sock) {
nodeRemLink(ntree, link);
}
}
@@ -226,9 +226,9 @@ void nodeRemoveAllSockets(bNodeTree *ntree, bNode *node)
bNodeSocket *sock;
bNodeLink *link, *next;
- for(link= ntree->links.first; link; link= next) {
+ for (link= ntree->links.first; link; link= next) {
next= link->next;
- if(link->fromnode==node || link->tonode==node) {
+ if (link->fromnode==node || link->tonode==node) {
nodeRemLink(ntree, link);
}
}
@@ -256,28 +256,28 @@ int nodeFindNode(bNodeTree *ntree, bNodeSocket *sock, bNode **nodep, int *sockin
bNodeSocket *tsock;
int index= 0;
- for(node= ntree->nodes.first; node; node= node->next) {
- for(index=0, tsock= node->inputs.first; tsock; tsock= tsock->next, index++) {
- if(tsock==sock) {
+ for (node= ntree->nodes.first; node; node= node->next) {
+ for (index=0, tsock= node->inputs.first; tsock; tsock= tsock->next, index++) {
+ if (tsock==sock) {
if (in_out) *in_out= SOCK_IN;
break;
}
}
- if(tsock)
+ if (tsock)
break;
- for(index=0, tsock= node->outputs.first; tsock; tsock= tsock->next, index++) {
- if(tsock==sock) {
+ for (index=0, tsock= node->outputs.first; tsock; tsock= tsock->next, index++) {
+ if (tsock==sock) {
if (in_out) *in_out= SOCK_OUT;
break;
}
}
- if(tsock)
+ if (tsock)
break;
}
- if(node) {
+ if (node) {
*nodep= node;
- if(sockindex) *sockindex= index;
+ if (sockindex) *sockindex= index;
return 1;
}
@@ -291,17 +291,17 @@ static void node_add_sockets_from_type(bNodeTree *ntree, bNode *node, bNodeType
bNodeSocketTemplate *sockdef;
/* bNodeSocket *sock; */ /* UNUSED */
- if(ntype->inputs) {
+ if (ntype->inputs) {
sockdef= ntype->inputs;
- while(sockdef->type != -1) {
+ while (sockdef->type != -1) {
/* sock = */ node_add_input_from_template(ntree, node, sockdef);
sockdef++;
}
}
- if(ntype->outputs) {
+ if (ntype->outputs) {
sockdef= ntype->outputs;
- while(sockdef->type != -1) {
+ while (sockdef->type != -1) {
/* sock = */ node_add_output_from_template(ntree, node, sockdef);
sockdef++;
@@ -321,7 +321,7 @@ bNode *nodeAddNode(bNodeTree *ntree, struct bNodeTemplate *ntemp)
bNodeType *ntype;
ntype= node_get_type(ntree, ntemp->type);
- if(ntype == NULL) {
+ if (ntype == NULL) {
printf("nodeAddNodeType() error: '%d' type invalid\n", ntemp->type);
return NULL;
}
@@ -339,7 +339,7 @@ bNode *nodeAddNode(bNodeTree *ntree, struct bNodeTemplate *ntemp)
node_add_sockets_from_type(ntree, node, ntype);
- if(ntype->initfunc!=NULL)
+ if (ntype->initfunc!=NULL)
ntype->initfunc(ntree, node, ntemp);
/* initialize the node name with the node label */
@@ -357,14 +357,14 @@ void nodeMakeDynamicType(bNode *node)
{
/* find SH_DYNAMIC_NODE ntype */
bNodeType *ntype= ntreeGetType(NTREE_SHADER)->node_types.first;
- while(ntype) {
- if(ntype->type==NODE_DYNAMIC)
+ while (ntype) {
+ if (ntype->type==NODE_DYNAMIC)
break;
ntype= ntype->next;
}
/* make own type struct to fill */
- if(ntype) {
+ if (ntype) {
/*node->typeinfo= MEM_dupallocN(ntype);*/
bNodeType *newtype= MEM_callocN(sizeof(bNodeType), "dynamic bNodeType");
*newtype= *ntype;
@@ -387,7 +387,7 @@ bNode *nodeCopyNode(struct bNodeTree *ntree, struct bNode *node)
BLI_duplicatelist(&nnode->inputs, &node->inputs);
oldsock= node->inputs.first;
- for(sock= nnode->inputs.first; sock; sock= sock->next, oldsock= oldsock->next) {
+ for (sock= nnode->inputs.first; sock; sock= sock->next, oldsock= oldsock->next) {
oldsock->new_sock= sock;
sock->stack_index= 0;
@@ -402,7 +402,7 @@ bNode *nodeCopyNode(struct bNodeTree *ntree, struct bNode *node)
BLI_duplicatelist(&nnode->outputs, &node->outputs);
oldsock= node->outputs.first;
- for(sock= nnode->outputs.first; sock; sock= sock->next, oldsock= oldsock->next) {
+ for (sock= nnode->outputs.first; sock; sock= sock->next, oldsock= oldsock->next) {
oldsock->new_sock= sock;
sock->stack_index= 0;
@@ -417,7 +417,7 @@ bNode *nodeCopyNode(struct bNodeTree *ntree, struct bNode *node)
/* don't increase node->id users, freenode doesn't decrement either */
- if(node->typeinfo->copystoragefunc)
+ if (node->typeinfo->copystoragefunc)
node->typeinfo->copystoragefunc(node, nnode);
node->new_node= nnode;
@@ -436,67 +436,67 @@ bNodeLink *nodeAddLink(bNodeTree *ntree, bNode *fromnode, bNodeSocket *fromsock,
bNodeLink *link= NULL;
int from= 0, to= 0;
- if(fromnode) {
+ if (fromnode) {
/* test valid input */
- for(sock= fromnode->outputs.first; sock; sock= sock->next)
- if(sock==fromsock)
+ for (sock= fromnode->outputs.first; sock; sock= sock->next)
+ if (sock==fromsock)
break;
- if(sock)
+ if (sock)
from= 1; /* OK */
else {
- for(sock= fromnode->inputs.first; sock; sock= sock->next)
- if(sock==fromsock)
+ for (sock= fromnode->inputs.first; sock; sock= sock->next)
+ if (sock==fromsock)
break;
- if(sock)
+ if (sock)
from= -1; /* OK but flip */
}
}
else {
/* check tree sockets */
- for(sock= ntree->inputs.first; sock; sock= sock->next)
- if(sock==fromsock)
+ for (sock= ntree->inputs.first; sock; sock= sock->next)
+ if (sock==fromsock)
break;
- if(sock)
+ if (sock)
from= 1; /* OK */
else {
- for(sock= ntree->outputs.first; sock; sock= sock->next)
- if(sock==fromsock)
+ for (sock= ntree->outputs.first; sock; sock= sock->next)
+ if (sock==fromsock)
break;
- if(sock)
+ if (sock)
from= -1; /* OK but flip */
}
}
- if(tonode) {
- for(sock= tonode->inputs.first; sock; sock= sock->next)
- if(sock==tosock)
+ if (tonode) {
+ for (sock= tonode->inputs.first; sock; sock= sock->next)
+ if (sock==tosock)
break;
- if(sock)
+ if (sock)
to= 1; /* OK */
else {
- for(sock= tonode->outputs.first; sock; sock= sock->next)
- if(sock==tosock)
+ for (sock= tonode->outputs.first; sock; sock= sock->next)
+ if (sock==tosock)
break;
- if(sock)
+ if (sock)
to= -1; /* OK but flip */
}
}
else {
/* check tree sockets */
- for(sock= ntree->outputs.first; sock; sock= sock->next)
- if(sock==tosock)
+ for (sock= ntree->outputs.first; sock; sock= sock->next)
+ if (sock==tosock)
break;
- if(sock)
+ if (sock)
to= 1; /* OK */
else {
- for(sock= ntree->inputs.first; sock; sock= sock->next)
- if(sock==tosock)
+ for (sock= ntree->inputs.first; sock; sock= sock->next)
+ if (sock==tosock)
break;
- if(sock)
+ if (sock)
to= -1; /* OK but flip */
}
}
- if(from >= 0 && to >= 0) {
+ if (from >= 0 && to >= 0) {
link= MEM_callocN(sizeof(bNodeLink), "link");
BLI_addtail(&ntree->links, link);
link->fromnode= fromnode;
@@ -504,7 +504,7 @@ bNodeLink *nodeAddLink(bNodeTree *ntree, bNode *fromnode, bNodeSocket *fromsock,
link->tonode= tonode;
link->tosock= tosock;
}
- else if(from <= 0 && to <= 0) {
+ else if (from <= 0 && to <= 0) {
link= MEM_callocN(sizeof(bNodeLink), "link");
BLI_addtail(&ntree->links, link);
link->fromnode= tonode;
@@ -521,7 +521,7 @@ bNodeLink *nodeAddLink(bNodeTree *ntree, bNode *fromnode, bNodeSocket *fromsock,
void nodeRemLink(bNodeTree *ntree, bNodeLink *link)
{
BLI_remlink(&ntree->links, link);
- if(link->tosock)
+ if (link->tosock)
link->tosock->link= NULL;
MEM_freeN(link);
@@ -532,9 +532,9 @@ void nodeRemSocketLinks(bNodeTree *ntree, bNodeSocket *sock)
{
bNodeLink *link, *next;
- for(link= ntree->links.first; link; link= next) {
+ for (link= ntree->links.first; link; link= next) {
next= link->next;
- if(link->fromsock==sock || link->tosock==sock) {
+ if (link->fromsock==sock || link->tosock==sock) {
nodeRemLink(ntree, link);
}
}
@@ -669,14 +669,15 @@ bNodeTree *ntreeCopyTree(bNodeTree *ntree)
bNodeLink *link;
bNodeSocket *gsock, *oldgsock;
- if(ntree==NULL) return NULL;
+ if (ntree==NULL) return NULL;
/* is ntree part of library? */
- for(newtree=G.main->nodetree.first; newtree; newtree= newtree->id.next)
- if(newtree==ntree) break;
- if(newtree) {
+ for (newtree=G.main->nodetree.first; newtree; newtree= newtree->id.next)
+ if (newtree==ntree) break;
+ if (newtree) {
newtree= copy_libblock(&ntree->id);
- } else {
+ }
+ else {
newtree= MEM_dupallocN(ntree);
copy_libblock_data(&newtree->id, &ntree->id, TRUE); /* copy animdata and ID props */
}
@@ -690,7 +691,7 @@ bNodeTree *ntreeCopyTree(bNodeTree *ntree)
newtree->links.first= newtree->links.last= NULL;
last = ntree->nodes.last;
- for(node= ntree->nodes.first; node; node= node->next) {
+ for (node= ntree->nodes.first; node; node= node->next) {
node->new_node= NULL;
/* nnode= */ nodeCopyNode(newtree, node); /* sets node->new */
@@ -701,14 +702,14 @@ bNodeTree *ntreeCopyTree(bNodeTree *ntree)
/* socket definition for group usage */
BLI_duplicatelist(&newtree->inputs, &ntree->inputs);
- for(gsock= newtree->inputs.first, oldgsock= ntree->inputs.first; gsock; gsock=gsock->next, oldgsock=oldgsock->next) {
+ for (gsock= newtree->inputs.first, oldgsock= ntree->inputs.first; gsock; gsock=gsock->next, oldgsock=oldgsock->next) {
oldgsock->new_sock= gsock;
gsock->groupsock = (oldgsock->groupsock ? oldgsock->groupsock->new_sock : NULL);
gsock->default_value = node_socket_make_default_value(oldgsock->type);
node_socket_copy_default_value(oldgsock->type, gsock->default_value, oldgsock->default_value);
}
BLI_duplicatelist(&newtree->outputs, &ntree->outputs);
- for(gsock= newtree->outputs.first, oldgsock= ntree->outputs.first; gsock; gsock=gsock->next, oldgsock=oldgsock->next) {
+ for (gsock= newtree->outputs.first, oldgsock= ntree->outputs.first; gsock; gsock=gsock->next, oldgsock=oldgsock->next) {
oldgsock->new_sock= gsock;
gsock->groupsock = (oldgsock->groupsock ? oldgsock->groupsock->new_sock : NULL);
gsock->default_value = node_socket_make_default_value(oldgsock->type);
@@ -717,7 +718,7 @@ bNodeTree *ntreeCopyTree(bNodeTree *ntree)
/* copy links */
BLI_duplicatelist(&newtree->links, &ntree->links);
- for(link= newtree->links.first; link; link= link->next) {
+ for (link= newtree->links.first; link; link= link->next) {
link->fromnode = (link->fromnode ? link->fromnode->new_node : NULL);
link->fromsock = (link->fromsock ? link->fromsock->new_sock : NULL);
link->tonode = (link->tonode ? link->tonode->new_node : NULL);
@@ -741,8 +742,8 @@ void ntreeSwitchID(bNodeTree *ntree, ID *id_from, ID *id_to)
{
bNode *node;
/* for scene duplication only */
- for(node= ntree->nodes.first; node; node= node->next) {
- if(node->id==id_from) {
+ for (node= ntree->nodes.first; node; node= node->next) {
+ if (node->id==id_from) {
node->id= id_to;
}
}
@@ -753,8 +754,8 @@ void ntreeSwitchID(bNodeTree *ntree, ID *id_from, ID *id_to)
void nodeFreePreview(bNode *node)
{
- if(node->preview) {
- if(node->preview->rect)
+ if (node->preview) {
+ if (node->preview->rect)
MEM_freeN(node->preview->rect);
MEM_freeN(node->preview);
node->preview= NULL;
@@ -764,24 +765,24 @@ void nodeFreePreview(bNode *node)
static void node_init_preview(bNode *node, int xsize, int ysize)
{
- if(node->preview==NULL) {
+ if (node->preview==NULL) {
node->preview= MEM_callocN(sizeof(bNodePreview), "node preview");
// printf("added preview %s\n", node->name);
}
/* node previews can get added with variable size this way */
- if(xsize==0 || ysize==0)
+ if (xsize==0 || ysize==0)
return;
/* sanity checks & initialize */
- if(node->preview->rect) {
- if(node->preview->xsize!=xsize && node->preview->ysize!=ysize) {
+ if (node->preview->rect) {
+ if (node->preview->xsize!=xsize && node->preview->ysize!=ysize) {
MEM_freeN(node->preview->rect);
node->preview->rect= NULL;
}
}
- if(node->preview->rect==NULL) {
+ if (node->preview->rect==NULL) {
node->preview->rect= MEM_callocN(4*xsize + xsize*ysize*sizeof(char)*4, "node preview rect");
node->preview->xsize= xsize;
node->preview->ysize= ysize;
@@ -793,20 +794,20 @@ void ntreeInitPreview(bNodeTree *ntree, int xsize, int ysize)
{
bNode *node;
- if(ntree==NULL)
+ if (ntree==NULL)
return;
- for(node= ntree->nodes.first; node; node= node->next) {
- if(node->typeinfo->flag & NODE_PREVIEW) /* hrms, check for closed nodes? */
+ for (node= ntree->nodes.first; node; node= node->next) {
+ if (node->typeinfo->flag & NODE_PREVIEW) /* hrms, check for closed nodes? */
node_init_preview(node, xsize, ysize);
- if(node->type==NODE_GROUP && (node->flag & NODE_GROUP_EDIT))
+ if (node->type==NODE_GROUP && (node->flag & NODE_GROUP_EDIT))
ntreeInitPreview((bNodeTree *)node->id, xsize, ysize);
}
}
static void nodeClearPreview(bNode *node)
{
- if(node->preview && node->preview->rect)
+ if (node->preview && node->preview->rect)
memset(node->preview->rect, 0, MEM_allocN_len(node->preview->rect));
}
@@ -815,13 +816,13 @@ void ntreeClearPreview(bNodeTree *ntree)
{
bNode *node;
- if(ntree==NULL)
+ if (ntree==NULL)
return;
- for(node= ntree->nodes.first; node; node= node->next) {
- if(node->typeinfo->flag & NODE_PREVIEW)
+ for (node= ntree->nodes.first; node; node= node->next) {
+ if (node->typeinfo->flag & NODE_PREVIEW)
nodeClearPreview(node);
- if(node->type==NODE_GROUP && (node->flag & NODE_GROUP_EDIT))
+ if (node->type==NODE_GROUP && (node->flag & NODE_GROUP_EDIT))
ntreeClearPreview((bNodeTree *)node->id);
}
}
@@ -832,12 +833,12 @@ void ntreeClearPreview(bNodeTree *ntree)
void nodeAddToPreview(bNode *node, float *col, int x, int y, int do_manage)
{
bNodePreview *preview= node->preview;
- if(preview) {
- if(x>=0 && y>=0) {
- if(x<preview->xsize && y<preview->ysize) {
+ if (preview) {
+ if (x>=0 && y>=0) {
+ if (x<preview->xsize && y<preview->ysize) {
unsigned char *tar= preview->rect+ 4*((preview->xsize*y) + x);
- if(do_manage) {
+ if (do_manage) {
linearrgb_to_srgb_uchar4(tar, col);
}
else {
@@ -859,25 +860,25 @@ void nodeUnlinkNode(bNodeTree *ntree, bNode *node)
bNodeSocket *sock;
ListBase *lb;
- for(link= ntree->links.first; link; link= next) {
+ for (link= ntree->links.first; link; link= next) {
next= link->next;
- if(link->fromnode==node) {
+ if (link->fromnode==node) {
lb= &node->outputs;
if (link->tonode)
link->tonode->update |= NODE_UPDATE;
}
- else if(link->tonode==node)
+ else if (link->tonode==node)
lb= &node->inputs;
else
lb= NULL;
- if(lb) {
- for(sock= lb->first; sock; sock= sock->next) {
- if(link->fromsock==sock || link->tosock==sock)
+ if (lb) {
+ for (sock= lb->first; sock; sock= sock->next) {
+ if (link->fromsock==sock || link->tosock==sock)
break;
}
- if(sock) {
+ if (sock) {
nodeRemLink(ntree, link);
}
}
@@ -909,7 +910,7 @@ void nodeFreeNode(bNodeTree *ntree, bNode *node)
if (treetype->free_node_cache)
treetype->free_node_cache(ntree, node);
- if(node->typeinfo && node->typeinfo->freestoragefunc)
+ if (node->typeinfo && node->typeinfo->freestoragefunc)
node->typeinfo->freestoragefunc(node);
for (sock=node->inputs.first; sock; sock = nextsock) {
@@ -936,7 +937,7 @@ void ntreeFreeTree(bNodeTree *ntree)
bNode *node, *next;
bNodeSocket *sock;
- if(ntree==NULL) return;
+ if (ntree==NULL) return;
/* XXX hack! node trees should not store execution graphs at all.
* This should be removed when old tree types no longer require it.
@@ -963,7 +964,7 @@ void ntreeFreeTree(bNodeTree *ntree)
BLI_freelistN(&ntree->links); /* do first, then unlink_node goes fast */
- for(node= ntree->nodes.first; node; node= next) {
+ for (node= ntree->nodes.first; node; node= next) {
next= node->next;
nodeFreeNode(ntree, node);
}
@@ -980,7 +981,7 @@ void ntreeFreeCache(bNodeTree *ntree)
{
bNodeTreeType *treetype;
- if(ntree==NULL) return;
+ if (ntree==NULL) return;
treetype= ntreeGetType(ntree->type);
if (treetype->free_cache)
@@ -992,45 +993,45 @@ void ntreeSetOutput(bNodeTree *ntree)
bNode *node;
/* find the active outputs, might become tree type dependent handler */
- for(node= ntree->nodes.first; node; node= node->next) {
- if(node->typeinfo->nclass==NODE_CLASS_OUTPUT) {
+ for (node= ntree->nodes.first; node; node= node->next) {
+ if (node->typeinfo->nclass==NODE_CLASS_OUTPUT) {
bNode *tnode;
int output= 0;
/* we need a check for which output node should be tagged like this, below an exception */
- if(node->type==CMP_NODE_OUTPUT_FILE)
+ if (node->type==CMP_NODE_OUTPUT_FILE)
continue;
/* there is more types having output class, each one is checked */
- for(tnode= ntree->nodes.first; tnode; tnode= tnode->next) {
- if(tnode->typeinfo->nclass==NODE_CLASS_OUTPUT) {
+ for (tnode= ntree->nodes.first; tnode; tnode= tnode->next) {
+ if (tnode->typeinfo->nclass==NODE_CLASS_OUTPUT) {
- if(ntree->type==NTREE_COMPOSIT) {
+ if (ntree->type==NTREE_COMPOSIT) {
/* same type, exception for viewer */
- if(tnode->type==node->type ||
+ if (tnode->type==node->type ||
(ELEM(tnode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER) &&
ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER))) {
- if(tnode->flag & NODE_DO_OUTPUT) {
+ if (tnode->flag & NODE_DO_OUTPUT) {
output++;
- if(output>1)
+ if (output>1)
tnode->flag &= ~NODE_DO_OUTPUT;
}
}
}
else {
/* same type */
- if(tnode->type==node->type) {
- if(tnode->flag & NODE_DO_OUTPUT) {
+ if (tnode->type==node->type) {
+ if (tnode->flag & NODE_DO_OUTPUT) {
output++;
- if(output>1)
+ if (output>1)
tnode->flag &= ~NODE_DO_OUTPUT;
}
}
}
}
}
- if(output==0)
+ if (output==0)
node->flag |= NODE_DO_OUTPUT;
}
}
@@ -1051,9 +1052,9 @@ static void ntreeMakeLocal_CheckLocal(void *calldata, ID *owner_id, bNodeTree *n
bNode *node;
/* find if group is in tree */
- for(node= ntree->nodes.first; node; node= node->next) {
- if(node->id == cd->group_id) {
- if(owner_id->lib) cd->lib= 1;
+ for (node= ntree->nodes.first; node; node= node->next) {
+ if (node->id == cd->group_id) {
+ if (owner_id->lib) cd->lib= 1;
else cd->local= 1;
}
}
@@ -1065,9 +1066,9 @@ static void ntreeMakeLocal_LinkNew(void *calldata, ID *owner_id, bNodeTree *ntre
bNode *node;
/* find if group is in tree */
- for(node= ntree->nodes.first; node; node= node->next) {
- if(node->id == cd->group_id) {
- if(owner_id->lib==NULL) {
+ for (node= ntree->nodes.first; node; node= node->next) {
+ if (node->id == cd->group_id) {
+ if (owner_id->lib==NULL) {
node->id= cd->new_id;
cd->new_id->us++;
cd->group_id->us--;
@@ -1087,8 +1088,8 @@ void ntreeMakeLocal(bNodeTree *ntree)
* - mixed: make copy
*/
- if(ntree->id.lib==NULL) return;
- if(ntree->id.us==1) {
+ if (ntree->id.lib==NULL) return;
+ if (ntree->id.us==1) {
id_clear_lib_data(bmain, (ID *)ntree);
return;
}
@@ -1102,10 +1103,10 @@ void ntreeMakeLocal(bNodeTree *ntree)
treetype->foreach_nodetree(G.main, &cd, &ntreeMakeLocal_CheckLocal);
/* if all users are local, we simply make tree local */
- if(cd.local && cd.lib==0) {
+ if (cd.local && cd.lib==0) {
id_clear_lib_data(bmain, (ID *)ntree);
}
- else if(cd.local && cd.lib) {
+ else if (cd.local && cd.lib) {
/* this is the mixed case, we copy the tree and assign it to local users */
bNodeTree *newtree= ntreeCopyTree(ntree);
@@ -1120,8 +1121,8 @@ void ntreeMakeLocal(bNodeTree *ntree)
int ntreeNodeExists(bNodeTree *ntree, bNode *testnode)
{
bNode *node= ntree->nodes.first;
- for(; node; node= node->next)
- if(node==testnode)
+ for (; node; node= node->next)
+ if (node==testnode)
return 1;
return 0;
}
@@ -1129,8 +1130,8 @@ int ntreeNodeExists(bNodeTree *ntree, bNode *testnode)
int ntreeOutputExists(bNode *node, bNodeSocket *testsock)
{
bNodeSocket *sock= node->outputs.first;
- for(; sock; sock= sock->next)
- if(sock==testsock)
+ for (; sock; sock= sock->next)
+ if (sock==testsock)
return 1;
return 0;
}
@@ -1149,7 +1150,7 @@ bNodeTree *ntreeLocalize(bNodeTree *ntree)
* set action to NULL so animdata actions don't get copied */
AnimData *adt= BKE_animdata_from_id(&ntree->id);
- if(adt) {
+ if (adt) {
action_backup= adt->action;
tmpact_backup= adt->tmpact;
@@ -1160,14 +1161,14 @@ bNodeTree *ntreeLocalize(bNodeTree *ntree)
/* node copy func */
ltree= ntreeCopyTree(ntree);
- if(adt) {
+ if (adt) {
AnimData *ladt= BKE_animdata_from_id(&ltree->id);
adt->action= ladt->action= action_backup;
adt->tmpact= ladt->tmpact= tmpact_backup;
- if(action_backup) action_backup->id.us++;
- if(tmpact_backup) tmpact_backup->id.us++;
+ if (action_backup) action_backup->id.us++;
+ if (tmpact_backup) tmpact_backup->id.us++;
}
/* end animdata uglyness */
@@ -1175,7 +1176,7 @@ bNodeTree *ntreeLocalize(bNodeTree *ntree)
/* ensures only a single output node is enabled */
ntreeSetOutput(ntree);
- for(node= ntree->nodes.first; node; node= node->next) {
+ for (node= ntree->nodes.first; node; node= node->next) {
/* store new_node pointer to original */
node->new_node->new_node= node;
}
@@ -1205,9 +1206,9 @@ void ntreeLocalMerge(bNodeTree *localtree, bNodeTree *ntree)
bNode *lnode;
/* move over the compbufs and previews */
- for(lnode= localtree->nodes.first; lnode; lnode= lnode->next) {
- if(ntreeNodeExists(ntree, lnode->new_node)) {
- if(lnode->preview && lnode->preview->rect) {
+ for (lnode= localtree->nodes.first; lnode; lnode= lnode->next) {
+ if (ntreeNodeExists(ntree, lnode->new_node)) {
+ if (lnode->preview && lnode->preview->rect) {
nodeFreePreview(lnode->new_node);
lnode->new_node->preview= lnode->preview;
lnode->preview= NULL;
@@ -1228,9 +1229,9 @@ int ntreeHasType(bNodeTree *ntree, int type)
{
bNode *node;
- if(ntree)
- for(node= ntree->nodes.first; node; node= node->next)
- if(node->type == type)
+ if (ntree)
+ for (node= ntree->nodes.first; node; node= node->next)
+ if (node->type == type)
return 1;
return 0;
}
@@ -1239,10 +1240,10 @@ bNodeLink *nodeFindLink(bNodeTree *ntree, bNodeSocket *from, bNodeSocket *to)
{
bNodeLink *link;
- for(link= ntree->links.first; link; link= link->next) {
- if(link->fromsock==from && link->tosock==to)
+ for (link= ntree->links.first; link; link= link->next) {
+ if (link->fromsock==from && link->tosock==to)
return link;
- if(link->fromsock==to && link->tosock==from) /* hrms? */
+ if (link->fromsock==to && link->tosock==from) /* hrms? */
return link;
}
return NULL;
@@ -1253,8 +1254,8 @@ int nodeCountSocketLinks(bNodeTree *ntree, bNodeSocket *sock)
bNodeLink *link;
int tot= 0;
- for(link= ntree->links.first; link; link= link->next) {
- if(link->fromsock==sock || link->tosock==sock)
+ for (link= ntree->links.first; link; link= link->next) {
+ if (link->fromsock==sock || link->tosock==sock)
tot++;
}
return tot;
@@ -1264,10 +1265,10 @@ bNode *nodeGetActive(bNodeTree *ntree)
{
bNode *node;
- if(ntree==NULL) return NULL;
+ if (ntree==NULL) return NULL;
- for(node= ntree->nodes.first; node; node= node->next)
- if(node->flag & NODE_ACTIVE)
+ for (node= ntree->nodes.first; node; node= node->next)
+ if (node->flag & NODE_ACTIVE)
break;
return node;
}
@@ -1277,20 +1278,20 @@ bNode *nodeGetActiveID(bNodeTree *ntree, short idtype)
{
bNode *node;
- if(ntree==NULL) return NULL;
+ if (ntree==NULL) return NULL;
/* check for group edit */
- for(node= ntree->nodes.first; node; node= node->next)
- if(node->flag & NODE_GROUP_EDIT)
+ for (node= ntree->nodes.first; node; node= node->next)
+ if (node->flag & NODE_GROUP_EDIT)
break;
- if(node)
+ if (node)
ntree= (bNodeTree*)node->id;
/* now find active node with this id */
- for(node= ntree->nodes.first; node; node= node->next)
- if(node->id && GS(node->id->name)==idtype)
- if(node->flag & NODE_ACTIVE_ID)
+ for (node= ntree->nodes.first; node; node= node->next)
+ if (node->id && GS(node->id->name)==idtype)
+ if (node->flag & NODE_ACTIVE_ID)
break;
return node;
@@ -1301,23 +1302,24 @@ int nodeSetActiveID(bNodeTree *ntree, short idtype, ID *id)
bNode *node;
int ok= FALSE;
- if(ntree==NULL) return ok;
+ if (ntree==NULL) return ok;
/* check for group edit */
- for(node= ntree->nodes.first; node; node= node->next)
- if(node->flag & NODE_GROUP_EDIT)
+ for (node= ntree->nodes.first; node; node= node->next)
+ if (node->flag & NODE_GROUP_EDIT)
break;
- if(node)
+ if (node)
ntree= (bNodeTree*)node->id;
/* now find active node with this id */
- for(node= ntree->nodes.first; node; node= node->next) {
- if(node->id && GS(node->id->name)==idtype) {
- if(id && ok==FALSE && node->id==id) {
+ for (node= ntree->nodes.first; node; node= node->next) {
+ if (node->id && GS(node->id->name)==idtype) {
+ if (id && ok==FALSE && node->id==id) {
node->flag |= NODE_ACTIVE_ID;
ok= TRUE;
- } else {
+ }
+ else {
node->flag &= ~NODE_ACTIVE_ID;
}
}
@@ -1332,10 +1334,10 @@ void nodeClearActiveID(bNodeTree *ntree, short idtype)
{
bNode *node;
- if(ntree==NULL) return;
+ if (ntree==NULL) return;
- for(node= ntree->nodes.first; node; node= node->next)
- if(node->id && GS(node->id->name)==idtype)
+ for (node= ntree->nodes.first; node; node= node->next)
+ if (node->id && GS(node->id->name)==idtype)
node->flag &= ~NODE_ACTIVE_ID;
}
@@ -1345,21 +1347,21 @@ void nodeSetActive(bNodeTree *ntree, bNode *node)
bNode *tnode;
/* make sure only one node is active, and only one per ID type */
- for(tnode= ntree->nodes.first; tnode; tnode= tnode->next) {
+ for (tnode= ntree->nodes.first; tnode; tnode= tnode->next) {
tnode->flag &= ~NODE_ACTIVE;
- if(node->id && tnode->id) {
- if(GS(node->id->name) == GS(tnode->id->name))
+ if (node->id && tnode->id) {
+ if (GS(node->id->name) == GS(tnode->id->name))
tnode->flag &= ~NODE_ACTIVE_ID;
}
- if(node->typeinfo->nclass == NODE_CLASS_TEXTURE)
+ if (node->typeinfo->nclass == NODE_CLASS_TEXTURE)
tnode->flag &= ~NODE_ACTIVE_TEXTURE;
}
node->flag |= NODE_ACTIVE;
- if(node->id)
+ if (node->id)
node->flag |= NODE_ACTIVE_ID;
- if(node->typeinfo->nclass == NODE_CLASS_TEXTURE)
+ if (node->typeinfo->nclass == NODE_CLASS_TEXTURE)
node->flag |= NODE_ACTIVE_TEXTURE;
}
@@ -1393,10 +1395,10 @@ static int node_get_deplist_recurs(bNode *node, bNode ***nsort)
node->done= 1;
/* check linked nodes */
- for(sock= node->inputs.first; sock; sock= sock->next) {
- if(sock->link) {
+ for (sock= node->inputs.first; sock; sock= sock->next) {
+ if (sock->link) {
fromnode= sock->link->fromnode;
- if(fromnode) {
+ if (fromnode) {
if (fromnode->done==0)
fromnode->level= node_get_deplist_recurs(fromnode, nsort);
if (fromnode->level <= level)
@@ -1428,11 +1430,11 @@ void ntreeGetDependencyList(struct bNodeTree *ntree, struct bNode ***deplist, in
*totnodes=0;
/* first clear data */
- for(node= ntree->nodes.first; node; node= node->next) {
+ for (node= ntree->nodes.first; node; node= node->next) {
node->done= 0;
(*totnodes)++;
}
- if(*totnodes==0) {
+ if (*totnodes==0) {
*deplist = NULL;
return;
}
@@ -1440,8 +1442,8 @@ void ntreeGetDependencyList(struct bNodeTree *ntree, struct bNode ***deplist, in
nsort= *deplist= MEM_callocN((*totnodes)*sizeof(bNode*), "sorted node array");
/* recursive check */
- for(node= ntree->nodes.first; node; node= node->next) {
- if(node->done==0) {
+ for (node= ntree->nodes.first; node; node= node->next) {
+ if (node->done==0) {
node->level= node_get_deplist_recurs(node, &nsort);
}
}
@@ -1453,13 +1455,13 @@ static void ntree_update_node_level(bNodeTree *ntree)
bNode *node;
/* first clear tag */
- for(node= ntree->nodes.first; node; node= node->next) {
+ for (node= ntree->nodes.first; node; node= node->next) {
node->done= 0;
}
/* recursive check */
- for(node= ntree->nodes.first; node; node= node->next) {
- if(node->done==0) {
+ for (node= ntree->nodes.first; node; node= node->next) {
+ if (node->done==0) {
node->level= node_get_deplist_recurs(node, NULL);
}
}
@@ -1472,24 +1474,24 @@ static void ntree_update_link_pointers(bNodeTree *ntree)
bNodeLink *link;
/* first clear data */
- for(node= ntree->nodes.first; node; node= node->next) {
- for(sock= node->inputs.first; sock; sock= sock->next) {
+ for (node= ntree->nodes.first; node; node= node->next) {
+ for (sock= node->inputs.first; sock; sock= sock->next) {
sock->link= NULL;
sock->flag &= ~SOCK_IN_USE;
}
- for(sock= node->outputs.first; sock; sock= sock->next) {
+ for (sock= node->outputs.first; sock; sock= sock->next) {
sock->flag &= ~SOCK_IN_USE;
}
}
- for(sock= ntree->inputs.first; sock; sock= sock->next) {
+ for (sock= ntree->inputs.first; sock; sock= sock->next) {
sock->flag &= ~SOCK_IN_USE;
}
- for(sock= ntree->outputs.first; sock; sock= sock->next) {
+ for (sock= ntree->outputs.first; sock; sock= sock->next) {
sock->link= NULL;
sock->flag &= ~SOCK_IN_USE;
}
- for(link= ntree->links.first; link; link= link->next) {
+ for (link= ntree->links.first; link; link= link->next) {
link->tosock->link= link;
link->fromsock->flag |= SOCK_IN_USE;
@@ -1605,14 +1607,14 @@ int nodeUpdateID(bNodeTree *ntree, ID *id)
bNode *node;
int change = FALSE;
- if(ELEM(NULL, id, ntree))
+ if (ELEM(NULL, id, ntree))
return change;
ntreetype = ntreeGetType(ntree->type);
if (ntreetype->update_node) {
- for(node= ntree->nodes.first; node; node= node->next) {
- if(node->id==id) {
+ for (node= ntree->nodes.first; node; node= node->next) {
+ if (node->id==id) {
change = TRUE;
ntreetype->update_node(ntree, node);
/* clear update flag */
@@ -1621,8 +1623,8 @@ int nodeUpdateID(bNodeTree *ntree, ID *id)
}
}
else {
- for(node= ntree->nodes.first; node; node= node->next) {
- if(node->id==id) {
+ for (node= ntree->nodes.first; node; node= node->next) {
+ if (node->id==id) {
change = TRUE;
if (node->typeinfo->updatefunc)
node->typeinfo->updatefunc(ntree, node);
@@ -1706,7 +1708,7 @@ void node_type_base(bNodeTreeType *ttype, bNodeType *ntype, int type, const char
ntype->flag = flag;
/* Default muting stuff. */
- if(ttype)
+ if (ttype)
ntype->internal_connect = ttype->internal_connect;
/* default size values */
@@ -1827,8 +1829,8 @@ static bNodeType *is_nodetype_registered(ListBase *typelist, int type)
{
bNodeType *ntype= typelist->first;
- for(;ntype; ntype= ntype->next )
- if(ntype->type==type)
+ for (;ntype; ntype= ntype->next )
+ if (ntype->type==type)
return ntype;
return NULL;
@@ -1839,7 +1841,7 @@ void nodeRegisterType(bNodeTreeType *ttype, bNodeType *ntype)
ListBase *typelist = &(ttype->node_types);
bNodeType *found= is_nodetype_registered(typelist, ntype->type);
- if(found==NULL)
+ if (found==NULL)
BLI_addtail(typelist, ntype);
}
@@ -2048,14 +2050,14 @@ static void registerTextureNodes(bNodeTreeType *ttype)
static void free_dynamic_typeinfo(bNodeType *ntype)
{
- if(ntype->type==NODE_DYNAMIC) {
- if(ntype->inputs) {
+ if (ntype->type==NODE_DYNAMIC) {
+ if (ntype->inputs) {
MEM_freeN(ntype->inputs);
}
- if(ntype->outputs) {
+ if (ntype->outputs) {
MEM_freeN(ntype->outputs);
}
- if(ntype->name) {
+ if (ntype->name) {
MEM_freeN((void *)ntype->name);
}
}
@@ -2064,13 +2066,13 @@ static void free_dynamic_typeinfo(bNodeType *ntype)
static void free_typeinfos(ListBase *list)
{
bNodeType *ntype, *next;
- for(ntype=list->first; ntype; ntype=next) {
+ for (ntype=list->first; ntype; ntype=next) {
next = ntype->next;
- if(ntype->type==NODE_DYNAMIC)
+ if (ntype->type==NODE_DYNAMIC)
free_dynamic_typeinfo(ntype);
- if(ntype->needs_free)
+ if (ntype->needs_free)
MEM_freeN(ntype);
}
}
@@ -2099,11 +2101,11 @@ void clear_scene_in_nodes(Main *bmain, Scene *sce)
Scene *sce1;
bNode *node;
- for(sce1= bmain->scene.first; sce1; sce1=sce1->id.next) {
- if(sce1!=sce) {
- if(sce1->nodetree) {
- for(node= sce1->nodetree->nodes.first; node; node= node->next) {
- if(node->type==CMP_NODE_R_LAYERS) {
+ for (sce1= bmain->scene.first; sce1; sce1=sce1->id.next) {
+ if (sce1!=sce) {
+ if (sce1->nodetree) {
+ for (node= sce1->nodetree->nodes.first; node; node= node->next) {
+ if (node->type==CMP_NODE_R_LAYERS) {
Scene *nodesce= (Scene *)node->id;
if (nodesce==sce) node->id = NULL;
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 3d6a8d8f5ae..4a9b4978705 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -1789,9 +1789,11 @@ static void give_parvert(Object *par, int nr, float vec[3])
if (count==0) {
/* keep as 0,0,0 */
- } else if (count > 0) {
+ }
+ else if (count > 0) {
mul_v3_fl(vec, 1.0f / count);
- } else {
+ }
+ else {
/* use first index if its out of range */
dm->getVertCo(dm, 0, vec);
}
@@ -2037,7 +2039,7 @@ static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[
if (simul) {
copy_v3_v3(totmat[3], par->obmat[3]);
}
- else{
+ else {
give_parvert(par, ob->par1, vec);
mul_v3_m4v3(totmat[3], par->obmat, vec);
}
@@ -2063,7 +2065,7 @@ static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[
if (simul) {
}
- else{
+ else {
// external usable originmat
copy_m3_m4(originmat, tmat);
@@ -2213,8 +2215,9 @@ void object_get_dimensions(Object *ob, float vec[3])
vec[0] = fabsf(scale[0]) * (bb->vec[4][0] - bb->vec[0][0]);
vec[1] = fabsf(scale[1]) * (bb->vec[2][1] - bb->vec[0][1]);
vec[2] = fabsf(scale[2]) * (bb->vec[1][2] - bb->vec[0][2]);
- } else {
- vec[0] = vec[1] = vec[2] = 0.f;
+ }
+ else {
+ zero_v3(vec);
}
}
@@ -2326,7 +2329,8 @@ int minmax_object_duplis(Scene *scene, Object *ob, float min[3], float max[3])
int ok= 0;
if ((ob->transflag & OB_DUPLI)==0) {
return ok;
- } else {
+ }
+ else {
ListBase *lb;
DupliObject *dob;
@@ -2695,7 +2699,8 @@ void object_sculpt_modifiers_changed(Object *ob)
}
free_sculptsession_deformMats(ob->sculpt);
- } else {
+ }
+ else {
PBVHNode **nodes;
int n, totnode;
diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c
index 3962e6d47fa..ae13613fc14 100644
--- a/source/blender/blenkernel/intern/ocean.c
+++ b/source/blender/blenkernel/intern/ocean.c
@@ -355,7 +355,8 @@ void BKE_ocean_eval_uv(struct Ocean *oc, struct OceanResult *ocr, float u,float
if (oc->_do_chop) {
ocr->disp[0] = BILERP(oc->_disp_x);
ocr->disp[2] = BILERP(oc->_disp_z);
- } else {
+ }
+ else {
ocr->disp[0] = 0.0;
ocr->disp[2] = 0.0;
}
@@ -760,7 +761,7 @@ static void set_height_normalize_factor(struct Ocean *oc)
{
for (j = 0; j < oc->_N; ++j)
{
- if( max_h < fabsf(oc->_disp_y[i*oc->_N+j]))
+ if ( max_h < fabsf(oc->_disp_y[i*oc->_N+j]))
{
max_h = fabsf(oc->_disp_y[i*oc->_N+j]);
}
@@ -916,7 +917,7 @@ void BKE_init_ocean(struct Ocean* o, int M,int N, float Lx, float Lz, float V, f
void BKE_free_ocean_data(struct Ocean *oc)
{
- if(!oc) return;
+ if (!oc) return;
BLI_rw_mutex_lock(&oc->oceanmutex, THREAD_LOCK_WRITE);
@@ -978,7 +979,7 @@ void BKE_free_ocean_data(struct Ocean *oc)
void BKE_free_ocean(struct Ocean *oc)
{
- if(!oc) return;
+ if (!oc) return;
BKE_free_ocean_data(oc);
BLI_rw_mutex_end(&oc->oceanmutex);
@@ -1299,18 +1300,18 @@ void BKE_bake_ocean(struct Ocean *o, struct OceanCache *och, void (*update_cb)(v
/* write the images */
cache_filename(string, och->bakepath, och->relbase, f, CACHE_TYPE_DISPLACE);
- if(0 == BKE_write_ibuf(ibuf_disp, string, &imf))
+ if (0 == BKE_write_ibuf(ibuf_disp, string, &imf))
printf("Cannot save Displacement File Output to %s\n", string);
if (o->_do_jacobian) {
cache_filename(string, och->bakepath, och->relbase, f, CACHE_TYPE_FOAM);
- if(0 == BKE_write_ibuf(ibuf_foam, string, &imf))
+ if (0 == BKE_write_ibuf(ibuf_foam, string, &imf))
printf("Cannot save Foam File Output to %s\n", string);
}
if (o->_do_normals) {
cache_filename(string, och->bakepath, och->relbase, f, CACHE_TYPE_NORMAL);
- if(0 == BKE_write_ibuf(ibuf_normal, string, &imf))
+ if (0 == BKE_write_ibuf(ibuf_normal, string, &imf))
printf("Cannot save Normal File Output to %s\n", string);
}
@@ -1389,7 +1390,7 @@ void BKE_free_ocean_data(struct Ocean *UNUSED(oc))
void BKE_free_ocean(struct Ocean *oc)
{
- if(!oc) return;
+ if (!oc) return;
MEM_freeN(oc);
}
diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c
index 64ccdf9b843..8a940e339bc 100644
--- a/source/blender/blenkernel/intern/packedFile.c
+++ b/source/blender/blenkernel/intern/packedFile.c
@@ -87,7 +87,8 @@ int seekPackedFile(PackedFile *pf, int offset, int whence)
}
if (seek < 0) {
seek = 0;
- } else if (seek > pf->size) {
+ }
+ else if (seek > pf->size) {
seek = pf->size;
}
pf->seek = seek;
@@ -110,12 +111,14 @@ int readPackedFile(PackedFile *pf, void *data, int size)
if (size > 0) {
memcpy(data, ((char *) pf->data) + pf->seek, size);
- } else {
+ }
+ else {
size = 0;
}
pf->seek += size;
- } else {
+ }
+ else {
size = -1;
}
@@ -130,16 +133,16 @@ int countPackedFiles(Main *bmain)
int count = 0;
// let's check if there are packed files...
- for(ima=bmain->image.first; ima; ima=ima->id.next)
- if(ima->packedfile)
+ for (ima=bmain->image.first; ima; ima=ima->id.next)
+ if (ima->packedfile)
count++;
- for(vf=bmain->vfont.first; vf; vf=vf->id.next)
- if(vf->packedfile)
+ for (vf=bmain->vfont.first; vf; vf=vf->id.next)
+ if (vf->packedfile)
count++;
- for(sound=bmain->sound.first; sound; sound=sound->id.next)
- if(sound->packedfile)
+ for (sound=bmain->sound.first; sound; sound=sound->id.next)
+ if (sound->packedfile)
count++;
return count;
@@ -147,7 +150,7 @@ int countPackedFiles(Main *bmain)
void freePackedFile(PackedFile *pf)
{
- if(pf) {
+ if (pf) {
MEM_freeN(pf->data);
MEM_freeN(pf);
}
@@ -173,7 +176,7 @@ PackedFile *newPackedFile(ReportList *reports, const char *filename, const char
/* render result has no filename and can be ignored
* any other files with no name can be ignored too */
- if(filename[0]=='\0')
+ if (filename[0]=='\0')
return NULL;
//XXX waitcursor(1);
@@ -189,14 +192,16 @@ PackedFile *newPackedFile(ReportList *reports, const char *filename, const char
file= BLI_open(name, O_BINARY|O_RDONLY,0);
if (file <= 0) {
BKE_reportf(reports, RPT_ERROR, "Unable to pack file, source path not found: \"%s\"", name);
- } else {
+ }
+ else {
filelen = BLI_file_descriptor_size(file);
if (filelen == 0) {
// MEM_mallocN complains about MEM_mallocN(0, "bla");
// we don't care....
data = MEM_mallocN(1, "packFile");
- } else {
+ }
+ else {
data = MEM_mallocN(filelen, "packFile");
}
if (read(file, data, filelen) == filelen) {
@@ -217,23 +222,23 @@ void packAll(Main *bmain, ReportList *reports)
VFont *vf;
bSound *sound;
- for(ima=bmain->image.first; ima; ima=ima->id.next) {
- if(ima->packedfile == NULL && ima->id.lib==NULL) {
- if(ima->source==IMA_SRC_FILE) {
+ for (ima=bmain->image.first; ima; ima=ima->id.next) {
+ if (ima->packedfile == NULL && ima->id.lib==NULL) {
+ if (ima->source==IMA_SRC_FILE) {
ima->packedfile = newPackedFile(reports, ima->name, ID_BLEND_PATH(bmain, &ima->id));
}
- else if(ELEM(ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) {
+ else if (ELEM(ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) {
BKE_reportf(reports, RPT_WARNING, "Image '%s' skipped, movies and image sequences not supported.", ima->id.name+2);
}
}
}
- for(vf=bmain->vfont.first; vf; vf=vf->id.next)
- if(vf->packedfile == NULL && vf->id.lib==NULL && strcmp(vf->name, FO_BUILTIN_NAME) != 0)
+ for (vf=bmain->vfont.first; vf; vf=vf->id.next)
+ if (vf->packedfile == NULL && vf->id.lib==NULL && strcmp(vf->name, FO_BUILTIN_NAME) != 0)
vf->packedfile = newPackedFile(reports, vf->name, bmain->name);
- for(sound=bmain->sound.first; sound; sound=sound->id.next)
- if(sound->packedfile == NULL && sound->id.lib==NULL)
+ for (sound=bmain->sound.first; sound; sound=sound->id.next)
+ if (sound->packedfile == NULL && sound->id.lib==NULL)
sound->packedfile = newPackedFile(reports, sound->name, bmain->name);
}
@@ -299,7 +304,8 @@ int writePackedFile(ReportList *reports, const char *filename, PackedFile *pf, i
ret_value = RET_ERROR;
}
close(file);
- } else {
+ }
+ else {
BKE_reportf(reports, RPT_ERROR, "Error creating file: %s", name);
ret_value = RET_ERROR;
}
@@ -309,14 +315,15 @@ int writePackedFile(ReportList *reports, const char *filename, PackedFile *pf, i
if (BLI_rename(tempname, name) != 0) {
BKE_reportf(reports, RPT_ERROR, "Error restoring tempfile. Check files: '%s' '%s'", tempname, name);
}
- } else {
+ }
+ else {
if (BLI_delete(tempname, 0, 0) != 0) {
BKE_reportf(reports, RPT_ERROR, "Error deleting '%s' (ignored)", tempname);
}
}
}
- if(guimode) {} //XXX waitcursor(0);
+ if (guimode) {} //XXX waitcursor(0);
return (ret_value);
}
@@ -342,15 +349,18 @@ int checkPackedFile(const char *filename, PackedFile *pf)
if (stat(name, &st)) {
ret_val = PF_NOFILE;
- } else if (st.st_size != pf->size) {
+ }
+ else if (st.st_size != pf->size) {
ret_val = PF_DIFFERS;
- } else {
+ }
+ else {
// we'll have to compare the two...
file = BLI_open(name, O_BINARY | O_RDONLY, 0);
if (file < 0) {
ret_val = PF_NOFILE;
- } else {
+ }
+ else {
ret_val = PF_EQUAL;
for (i = 0; i < pf->size; i += sizeof(buf)) {
@@ -363,7 +373,8 @@ int checkPackedFile(const char *filename, PackedFile *pf)
// read error ...
ret_val = PF_DIFFERS;
break;
- } else {
+ }
+ else {
if (memcmp(buf, ((char *)pf->data) + i, len)) {
ret_val = PF_DIFFERS;
break;
@@ -522,16 +533,16 @@ void unpackAll(Main *bmain, ReportList *reports, int how)
VFont *vf;
bSound *sound;
- for(ima=bmain->image.first; ima; ima=ima->id.next)
- if(ima->packedfile)
+ for (ima=bmain->image.first; ima; ima=ima->id.next)
+ if (ima->packedfile)
unpackImage(reports, ima, how);
- for(vf=bmain->vfont.first; vf; vf=vf->id.next)
- if(vf->packedfile)
+ for (vf=bmain->vfont.first; vf; vf=vf->id.next)
+ if (vf->packedfile)
unpackVFont(reports, vf, how);
- for(sound=bmain->sound.first; sound; sound=sound->id.next)
- if(sound->packedfile)
+ for (sound=bmain->sound.first; sound; sound=sound->id.next)
+ if (sound->packedfile)
unpackSound(bmain, reports, sound, how);
}
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index fe4fdb58951..975602c2918 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -55,10 +55,10 @@ const char PAINT_CURSOR_TEXTURE_PAINT[3] = {255, 255, 255};
Paint *paint_get_active(Scene *sce)
{
- if(sce) {
+ if (sce) {
ToolSettings *ts = sce->toolsettings;
- if(sce->basact && sce->basact->object) {
+ if (sce->basact && sce->basact->object) {
switch(sce->basact->object->mode) {
case OB_MODE_SCULPT:
return &ts->sculpt->paint;
@@ -69,7 +69,7 @@ Paint *paint_get_active(Scene *sce)
case OB_MODE_TEXTURE_PAINT:
return &ts->imapaint.paint;
case OB_MODE_EDIT:
- if(ts->use_uv_sculpt)
+ if (ts->use_uv_sculpt)
return &ts->uvsculpt->paint;
else
return &ts->imapaint.paint;
@@ -90,7 +90,7 @@ Brush *paint_brush(Paint *p)
void paint_brush_set(Paint *p, Brush *br)
{
- if(p) {
+ if (p) {
id_us_min((ID *)p->brush);
id_us_plus((ID *)br);
p->brush= br;
@@ -125,7 +125,7 @@ void paint_init(Paint *p, const char col[3])
/* If there's no brush, create one */
brush = paint_brush(p);
- if(brush == NULL)
+ if (brush == NULL)
brush= add_brush("Brush");
paint_brush_set(p, brush);
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 8228a9da67f..f9634ef2301 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -97,8 +97,8 @@ int count_particles(ParticleSystem *psys)
int tot=0;
LOOP_SHOWN_PARTICLES {
- if(pa->alive == PARS_UNBORN && (part->flag & PART_UNBORN)==0);
- else if(pa->alive == PARS_DEAD && (part->flag & PART_DIED)==0);
+ if (pa->alive == PARS_UNBORN && (part->flag & PART_UNBORN)==0);
+ else if (pa->alive == PARS_DEAD && (part->flag & PART_DIED)==0);
else tot++;
}
return tot;
@@ -110,9 +110,9 @@ int count_particles_mod(ParticleSystem *psys, int totgr, int cur)
int tot=0;
LOOP_SHOWN_PARTICLES {
- if(pa->alive == PARS_UNBORN && (part->flag & PART_UNBORN)==0);
- else if(pa->alive == PARS_DEAD && (part->flag & PART_DIED)==0);
- else if(p%totgr==cur) tot++;
+ if (pa->alive == PARS_UNBORN && (part->flag & PART_UNBORN)==0);
+ else if (pa->alive == PARS_DEAD && (part->flag & PART_DIED)==0);
+ else if (p%totgr==cur) tot++;
}
return tot;
}
@@ -131,12 +131,12 @@ static ParticleCacheKey **psys_alloc_path_cache_buffers(ListBase *bufs, int tot,
totkey = 0;
cache = MEM_callocN(tot*sizeof(void*), "PathCacheArray");
- while(totkey < tot) {
+ while (totkey < tot) {
totbufkey= MIN2(tot-totkey, PATH_CACHE_BUF_SIZE);
buf= MEM_callocN(sizeof(LinkData), "PathCacheLinkData");
buf->data= MEM_callocN(sizeof(ParticleCacheKey)*totbufkey*steps, "ParticleCacheKey");
- for(i=0; i<totbufkey; i++)
+ for (i=0; i<totbufkey; i++)
cache[totkey+i] = ((ParticleCacheKey*)buf->data) + i*steps;
totkey += totbufkey;
@@ -150,10 +150,10 @@ static void psys_free_path_cache_buffers(ParticleCacheKey **cache, ListBase *buf
{
LinkData *buf;
- if(cache)
+ if (cache)
MEM_freeN(cache);
- for(buf= bufs->first; buf; buf=buf->next)
+ for (buf= bufs->first; buf; buf=buf->next)
MEM_freeN(buf->data);
BLI_freelistN(bufs);
}
@@ -165,10 +165,10 @@ static void psys_free_path_cache_buffers(ParticleCacheKey **cache, ListBase *buf
ParticleSystem *psys_get_current(Object *ob)
{
ParticleSystem *psys;
- if(ob==NULL) return NULL;
+ if (ob==NULL) return NULL;
- for(psys=ob->particlesystem.first; psys; psys=psys->next) {
- if(psys->flag & PSYS_CURRENT)
+ for (psys=ob->particlesystem.first; psys; psys=psys->next) {
+ if (psys->flag & PSYS_CURRENT)
return psys;
}
@@ -179,10 +179,10 @@ short psys_get_current_num(Object *ob)
ParticleSystem *psys;
short i;
- if(ob==NULL) return 0;
+ if (ob==NULL) return 0;
- for(psys=ob->particlesystem.first, i=0; psys; psys=psys->next, i++)
- if(psys->flag & PSYS_CURRENT)
+ for (psys=ob->particlesystem.first, i=0; psys; psys=psys->next, i++)
+ if (psys->flag & PSYS_CURRENT)
return i;
return i;
@@ -192,10 +192,10 @@ void psys_set_current_num(Object *ob, int index)
ParticleSystem *psys;
short i;
- if(ob==NULL) return;
+ if (ob==NULL) return;
- for(psys=ob->particlesystem.first, i=0; psys; psys=psys->next, i++) {
- if(i == index)
+ for (psys=ob->particlesystem.first, i=0; psys; psys=psys->next, i++) {
+ if (i == index)
psys->flag |= PSYS_CURRENT;
else
psys->flag &= ~PSYS_CURRENT;
@@ -206,9 +206,9 @@ Object *psys_find_object(Scene *scene, ParticleSystem *psys)
Base *base;
ParticleSystem *tpsys;
- for(base = scene->base.first; base; base = base->next) {
- for(tpsys = base->object->particlesystem.first; psys; psys=psys->next) {
- if(tpsys == psys)
+ for (base = scene->base.first; base; base = base->next) {
+ for (tpsys = base->object->particlesystem.first; psys; psys=psys->next) {
+ if (tpsys == psys)
return base->object;
}
}
@@ -219,18 +219,18 @@ Object *psys_get_lattice(ParticleSimulationData *sim)
{
Object *lattice=NULL;
- if(psys_in_edit_mode(sim->scene, sim->psys)==0) {
+ if (psys_in_edit_mode(sim->scene, sim->psys)==0) {
ModifierData *md = (ModifierData*)psys_get_modifier(sim->ob, sim->psys);
- for(; md; md=md->next) {
- if(md->type==eModifierType_Lattice) {
+ for (; md; md=md->next) {
+ if (md->type==eModifierType_Lattice) {
LatticeModifierData *lmd = (LatticeModifierData *)md;
lattice=lmd->object;
break;
}
}
- if(lattice)
+ if (lattice)
init_latt_deform(lattice, NULL);
}
@@ -240,14 +240,14 @@ void psys_disable_all(Object *ob)
{
ParticleSystem *psys=ob->particlesystem.first;
- for(; psys; psys=psys->next)
+ for (; psys; psys=psys->next)
psys->flag |= PSYS_DISABLED;
}
void psys_enable_all(Object *ob)
{
ParticleSystem *psys=ob->particlesystem.first;
- for(; psys; psys=psys->next)
+ for (; psys; psys=psys->next)
psys->flag &= ~PSYS_DISABLED;
}
int psys_in_edit_mode(Scene *scene, ParticleSystem *psys)
@@ -261,28 +261,28 @@ static void psys_create_frand(ParticleSystem *psys)
BLI_srandom(psys->seed);
- for(i=0; i<1024; i++, rand++)
+ for (i=0; i<1024; i++, rand++)
*rand = BLI_frand();
}
int psys_check_enabled(Object *ob, ParticleSystem *psys)
{
ParticleSystemModifierData *psmd;
- if(psys->flag & PSYS_DISABLED || psys->flag & PSYS_DELETE || !psys->part)
+ if (psys->flag & PSYS_DISABLED || psys->flag & PSYS_DELETE || !psys->part)
return 0;
psmd= psys_get_modifier(ob, psys);
- if(psys->renderdata || G.rendering) {
- if(!(psmd->modifier.mode & eModifierMode_Render))
+ if (psys->renderdata || G.rendering) {
+ if (!(psmd->modifier.mode & eModifierMode_Render))
return 0;
}
- else if(!(psmd->modifier.mode & eModifierMode_Realtime))
+ else if (!(psmd->modifier.mode & eModifierMode_Realtime))
return 0;
/* perhaps not the perfect place, but we have to be sure the rands are there before usage */
- if(!psys->frand)
+ if (!psys->frand)
psys_create_frand(psys);
- else if(psys->recalc & PSYS_RECALC_RESET) {
+ else if (psys->recalc & PSYS_RECALC_RESET) {
MEM_freeN(psys->frand);
psys_create_frand(psys);
}
@@ -292,7 +292,7 @@ int psys_check_enabled(Object *ob, ParticleSystem *psys)
int psys_check_edited(ParticleSystem *psys)
{
- if(psys->part && psys->part->type==PART_HAIR)
+ if (psys->part && psys->part->type==PART_HAIR)
return (psys->flag & PSYS_EDITED || (psys->edit && psys->edit->edited));
else
return (psys->pointcache->edit && psys->pointcache->edit->edited);
@@ -304,11 +304,11 @@ void psys_check_group_weights(ParticleSettings *part)
GroupObject *go;
int current = 0;
- if(part->ren_as == PART_DRAW_GR && part->dup_group && part->dup_group->gobject.first) {
+ if (part->ren_as == PART_DRAW_GR && part->dup_group && part->dup_group->gobject.first) {
/* first remove all weights that don't have an object in the group */
dw = part->dupliweights.first;
- while(dw) {
- if(!object_in_group(dw->ob, part->dup_group)) {
+ while (dw) {
+ if (!object_in_group(dw->ob, part->dup_group)) {
tdw = dw->next;
BLI_freelinkN(&part->dupliweights, dw);
dw = tdw;
@@ -319,12 +319,12 @@ void psys_check_group_weights(ParticleSettings *part)
/* then add objects in the group to new list */
go = part->dup_group->gobject.first;
- while(go) {
+ while (go) {
dw = part->dupliweights.first;
- while(dw && dw->ob != go->ob)
+ while (dw && dw->ob != go->ob)
dw = dw->next;
- if(!dw) {
+ if (!dw) {
dw = MEM_callocN(sizeof(ParticleDupliWeight), "ParticleDupliWeight");
dw->ob = go->ob;
dw->count = 1;
@@ -335,16 +335,16 @@ void psys_check_group_weights(ParticleSettings *part)
}
dw = part->dupliweights.first;
- for(; dw; dw=dw->next) {
- if(dw->flag & PART_DUPLIW_CURRENT) {
+ for (; dw; dw=dw->next) {
+ if (dw->flag & PART_DUPLIW_CURRENT) {
current = 1;
break;
}
}
- if(!current) {
+ if (!current) {
dw = part->dupliweights.first;
- if(dw)
+ if (dw)
dw->flag |= PART_DUPLIW_CURRENT;
}
}
@@ -361,7 +361,7 @@ int psys_uses_gravity(ParticleSimulationData *sim)
/************************************************/
static void fluid_free_settings(SPHFluidSettings *fluid)
{
- if(fluid)
+ if (fluid)
MEM_freeN(fluid);
}
@@ -373,7 +373,7 @@ void psys_free_settings(ParticleSettings *part)
free_partdeflect(part->pd);
free_partdeflect(part->pd2);
- if(part->effector_weights)
+ if (part->effector_weights)
MEM_freeN(part->effector_weights);
BLI_freelistN(&part->dupliweights);
@@ -381,10 +381,10 @@ void psys_free_settings(ParticleSettings *part)
boid_free_settings(part->boids);
fluid_free_settings(part->fluid);
- for(a=0; a<MAX_MTEX; a++) {
+ for (a=0; a<MAX_MTEX; a++) {
mtex= part->mtex[a];
- if(mtex && mtex->tex) mtex->tex->id.us--;
- if(mtex) MEM_freeN(mtex);
+ if (mtex && mtex->tex) mtex->tex->id.us--;
+ if (mtex) MEM_freeN(mtex);
}
}
@@ -393,7 +393,7 @@ void free_hair(Object *UNUSED(ob), ParticleSystem *psys, int dynamics)
PARTICLE_P;
LOOP_PARTICLES {
- if(pa->hair)
+ if (pa->hair)
MEM_freeN(pa->hair);
pa->hair = NULL;
pa->totkey = 0;
@@ -401,8 +401,8 @@ void free_hair(Object *UNUSED(ob), ParticleSystem *psys, int dynamics)
psys->flag &= ~PSYS_HAIR_DONE;
- if(psys->clmd) {
- if(dynamics) {
+ if (psys->clmd) {
+ if (dynamics) {
BKE_ptcache_free_list(&psys->ptcaches);
psys->clmd->point_cache = psys->pointcache = NULL;
psys->clmd->ptcaches.first = psys->clmd->ptcaches.last = NULL;
@@ -417,11 +417,11 @@ void free_hair(Object *UNUSED(ob), ParticleSystem *psys, int dynamics)
}
}
- if(psys->hair_in_dm)
+ if (psys->hair_in_dm)
psys->hair_in_dm->release(psys->hair_in_dm);
psys->hair_in_dm = NULL;
- if(psys->hair_out_dm)
+ if (psys->hair_out_dm)
psys->hair_out_dm->release(psys->hair_out_dm);
psys->hair_out_dm = NULL;
}
@@ -429,14 +429,14 @@ void free_keyed_keys(ParticleSystem *psys)
{
PARTICLE_P;
- if(psys->part->type == PART_HAIR)
+ if (psys->part->type == PART_HAIR)
return;
- if(psys->particles && psys->particles->keys) {
+ if (psys->particles && psys->particles->keys) {
MEM_freeN(psys->particles->keys);
LOOP_PARTICLES {
- if(pa->keys) {
+ if (pa->keys) {
pa->keys= NULL;
pa->totkey= 0;
}
@@ -451,12 +451,12 @@ static void free_child_path_cache(ParticleSystem *psys)
}
void psys_free_path_cache(ParticleSystem *psys, PTCacheEdit *edit)
{
- if(edit) {
+ if (edit) {
psys_free_path_cache_buffers(edit->pathcache, &edit->pathcachebufs);
edit->pathcache= NULL;
edit->totcached= 0;
}
- if(psys) {
+ if (psys) {
psys_free_path_cache_buffers(psys->pathcache, &psys->pathcachebufs);
psys->pathcache= NULL;
psys->totcached= 0;
@@ -466,7 +466,7 @@ void psys_free_path_cache(ParticleSystem *psys, PTCacheEdit *edit)
}
void psys_free_children(ParticleSystem *psys)
{
- if(psys->child) {
+ if (psys->child) {
MEM_freeN(psys->child);
psys->child= NULL;
psys->totchild=0;
@@ -478,18 +478,18 @@ void psys_free_particles(ParticleSystem *psys)
{
PARTICLE_P;
- if(psys->particles) {
- if(psys->part->type==PART_HAIR) {
+ if (psys->particles) {
+ if (psys->part->type==PART_HAIR) {
LOOP_PARTICLES {
- if(pa->hair)
+ if (pa->hair)
MEM_freeN(pa->hair);
}
}
- if(psys->particles->keys)
+ if (psys->particles->keys)
MEM_freeN(psys->particles->keys);
- if(psys->particles->boid)
+ if (psys->particles->boid)
MEM_freeN(psys->particles->boid);
MEM_freeN(psys->particles);
@@ -499,20 +499,20 @@ void psys_free_particles(ParticleSystem *psys)
}
void psys_free_pdd(ParticleSystem *psys)
{
- if(psys->pdd) {
- if(psys->pdd->cdata)
+ if (psys->pdd) {
+ if (psys->pdd->cdata)
MEM_freeN(psys->pdd->cdata);
psys->pdd->cdata = NULL;
- if(psys->pdd->vdata)
+ if (psys->pdd->vdata)
MEM_freeN(psys->pdd->vdata);
psys->pdd->vdata = NULL;
- if(psys->pdd->ndata)
+ if (psys->pdd->ndata)
MEM_freeN(psys->pdd->ndata);
psys->pdd->ndata = NULL;
- if(psys->pdd->vedata)
+ if (psys->pdd->vedata)
MEM_freeN(psys->pdd->vedata);
psys->pdd->vedata = NULL;
@@ -523,7 +523,7 @@ void psys_free_pdd(ParticleSystem *psys)
/* free everything */
void psys_free(Object *ob, ParticleSystem * psys)
{
- if(psys) {
+ if (psys) {
int nr = 0;
ParticleSystem * tpsys;
@@ -533,10 +533,10 @@ void psys_free(Object *ob, ParticleSystem * psys)
psys_free_particles(psys);
- if(psys->edit && psys->free_edit)
+ if (psys->edit && psys->free_edit)
psys->free_edit(psys->edit);
- if(psys->child) {
+ if (psys->child) {
MEM_freeN(psys->child);
psys->child = NULL;
psys->totchild = 0;
@@ -552,10 +552,10 @@ void psys_free(Object *ob, ParticleSystem * psys)
}
}
// clear do-not-draw-flag
- if(!nr)
+ if (!nr)
ob->transflag &= ~OB_DUPLIPARTS;
- if(psys->part) {
+ if (psys->part) {
psys->part->id.us--;
psys->part=NULL;
}
@@ -568,15 +568,15 @@ void psys_free(Object *ob, ParticleSystem * psys)
BLI_bvhtree_free(psys->bvhtree);
BLI_kdtree_free(psys->tree);
- if(psys->fluid_springs)
+ if (psys->fluid_springs)
MEM_freeN(psys->fluid_springs);
pdEndEffectors(&psys->effectors);
- if(psys->frand)
+ if (psys->frand)
MEM_freeN(psys->frand);
- if(psys->pdd) {
+ if (psys->pdd) {
psys_free_pdd(psys);
MEM_freeN(psys->pdd);
}
@@ -648,7 +648,7 @@ static float psys_render_projected_area(ParticleSystem *psys, const float center
/* project point on screen */
mul_m4_v4(data->winmat, co);
- if(co[3] != 0.0f) {
+ if (co[3] != 0.0f) {
co[0]= 0.5f*data->winx*(1.0f + co[0]/co[3]);
co[1]= 0.5f*data->winy*(1.0f + co[1]/co[3]);
}
@@ -659,14 +659,14 @@ static float psys_render_projected_area(ParticleSystem *psys, const float center
/* make smaller using fallof once over screen edge */
*viewport= 1.0f;
- if(co[0]+radius < 0.0f)
+ if (co[0]+radius < 0.0f)
*viewport *= psys_render_viewport_falloff(vprate, -(co[0]+radius), data->winx);
- else if(co[0]-radius > data->winx)
+ else if (co[0]-radius > data->winx)
*viewport *= psys_render_viewport_falloff(vprate, (co[0]-radius) - data->winx, data->winx);
- if(co[1]+radius < 0.0f)
+ if (co[1]+radius < 0.0f)
*viewport *= psys_render_viewport_falloff(vprate, -(co[1]+radius), data->winy);
- else if(co[1]-radius > data->winy)
+ else if (co[1]-radius > data->winy)
*viewport *= psys_render_viewport_falloff(vprate, (co[1]-radius) - data->winy, data->winy);
return area;
@@ -677,9 +677,9 @@ void psys_render_set(Object *ob, ParticleSystem *psys, float viewmat[][4], float
ParticleRenderData*data;
ParticleSystemModifierData *psmd= psys_get_modifier(ob, psys);
- if(!G.rendering)
+ if (!G.rendering)
return;
- if(psys->renderdata)
+ if (psys->renderdata)
return;
data= MEM_callocN(sizeof(ParticleRenderData), "ParticleRenderData");
@@ -695,7 +695,7 @@ void psys_render_set(Object *ob, ParticleSystem *psys, float viewmat[][4], float
data->childcachebufs.last = psys->childcachebufs.last;
data->totchildcache= psys->totchildcache;
- if(psmd->dm)
+ if (psmd->dm)
data->dm= CDDM_copy(psmd->dm);
data->totdmvert= psmd->totdmvert;
data->totdmedge= psmd->totdmedge;
@@ -719,7 +719,7 @@ void psys_render_set(Object *ob, ParticleSystem *psys, float viewmat[][4], float
psys->renderdata= data;
/* Hair can and has to be recalculated if everything isn't displayed. */
- if(psys->part->disp != 100 && psys->part->type == PART_HAIR)
+ if (psys->part->disp != 100 && psys->part->type == PART_HAIR)
psys->recalc |= PSYS_RECALC_RESET;
}
@@ -729,20 +729,20 @@ void psys_render_restore(Object *ob, ParticleSystem *psys)
ParticleSystemModifierData *psmd= psys_get_modifier(ob, psys);
data= psys->renderdata;
- if(!data)
+ if (!data)
return;
- if(data->elems)
+ if (data->elems)
MEM_freeN(data->elems);
- if(psmd->dm) {
+ if (psmd->dm) {
psmd->dm->needsFree= 1;
psmd->dm->release(psmd->dm);
}
psys_free_path_cache(psys, NULL);
- if(psys->child) {
+ if (psys->child) {
MEM_freeN(psys->child);
psys->child= 0;
psys->totchild= 0;
@@ -765,7 +765,7 @@ void psys_render_restore(Object *ob, ParticleSystem *psys)
psmd->totdmface= data->totdmface;
psmd->flag &= ~eParticleSystemFlag_psys_updated;
- if(psmd->dm)
+ if (psmd->dm)
psys_calc_dmcache(ob, psmd->dm, psys);
MEM_freeN(data);
@@ -789,15 +789,15 @@ int psys_render_simplify_distribution(ParticleThreadContext *ctx, int tot)
int *origindex, *facetotvert;
int a, b, totorigface, totface, newtot, skipped;
- if(part->ren_as!=PART_DRAW_PATH || !(part->draw & PART_DRAW_REN_STRAND))
+ if (part->ren_as!=PART_DRAW_PATH || !(part->draw & PART_DRAW_REN_STRAND))
return tot;
- if(!ctx->sim.psys->renderdata)
+ if (!ctx->sim.psys->renderdata)
return tot;
data= ctx->sim.psys->renderdata;
- if(data->timeoffset)
+ if (data->timeoffset)
return 0;
- if(!(part->simplify_flag & PART_SIMPLIFY_ENABLE))
+ if (!(part->simplify_flag & PART_SIMPLIFY_ENABLE))
return tot;
mvert= dm->getVertArray(dm);
@@ -806,7 +806,7 @@ int psys_render_simplify_distribution(ParticleThreadContext *ctx, int tot)
totface= dm->getNumTessFaces(dm);
totorigface= me->totpoly;
- if(totface == 0 || totorigface == 0)
+ if (totface == 0 || totorigface == 0)
return tot;
facearea= MEM_callocN(sizeof(float)*totorigface, "SimplifyFaceArea");
@@ -814,7 +814,7 @@ int psys_render_simplify_distribution(ParticleThreadContext *ctx, int tot)
facetotvert= MEM_callocN(sizeof(int)*totorigface, "SimplifyFaceArea");
elems= MEM_callocN(sizeof(ParticleRenderElem)*totorigface, "SimplifyFaceElem");
- if(data->elems)
+ if (data->elems)
MEM_freeN(data->elems);
data->dosimplify= 1;
@@ -822,17 +822,17 @@ int psys_render_simplify_distribution(ParticleThreadContext *ctx, int tot)
data->origindex= origindex;
/* compute number of children per original face */
- for(a=0; a<tot; a++) {
+ for (a=0; a<tot; a++) {
b= (origindex)? origindex[ctx->index[a]]: ctx->index[a];
- if(b != -1)
+ if (b != -1)
elems[b].totchild++;
}
/* compute areas and centers of original faces */
- for(mf=mface, a=0; a<totface; a++, mf++) {
+ for (mf=mface, a=0; a<totface; a++, mf++) {
b= (origindex)? origindex[a]: a;
- if(b != -1) {
+ if (b != -1) {
copy_v3_v3(co1, mvert[mf->v1].co);
copy_v3_v3(co2, mvert[mf->v2].co);
copy_v3_v3(co3, mvert[mf->v3].co);
@@ -841,7 +841,7 @@ int psys_render_simplify_distribution(ParticleThreadContext *ctx, int tot)
add_v3_v3(facecenter[b], co2);
add_v3_v3(facecenter[b], co3);
- if(mf->v4) {
+ if (mf->v4) {
copy_v3_v3(co4, mvert[mf->v4].co);
add_v3_v3(facecenter[b], co4);
facearea[b] += area_quad_v3(co1, co2, co3, co4);
@@ -854,8 +854,8 @@ int psys_render_simplify_distribution(ParticleThreadContext *ctx, int tot)
}
}
- for(a=0; a<totorigface; a++)
- if(facetotvert[a] > 0)
+ for (a=0; a<totorigface; a++)
+ if (facetotvert[a] > 0)
mul_v3_fl(facecenter[a], 1.0f/facetotvert[a]);
/* for conversion from BU area / pixel area to reference screen size */
@@ -864,17 +864,17 @@ int psys_render_simplify_distribution(ParticleThreadContext *ctx, int tot)
fac= fac*fac;
powrate= log(0.5f)/log(part->simplify_rate*0.5f);
- if(part->simplify_flag & PART_SIMPLIFY_VIEWPORT)
+ if (part->simplify_flag & PART_SIMPLIFY_VIEWPORT)
vprate= pow(1.0f - part->simplify_viewport, 5.0);
else
vprate= 1.0;
/* set simplification parameters per original face */
- for(a=0, elem=elems; a<totorigface; a++, elem++) {
+ for (a=0, elem=elems; a<totorigface; a++, elem++) {
area = psys_render_projected_area(ctx->sim.psys, facecenter[a], facearea[a], vprate, &viewport);
arearatio= fac*area/facearea[a];
- if((arearatio < 1.0f || viewport < 1.0f) && elem->totchild) {
+ if ((arearatio < 1.0f || viewport < 1.0f) && elem->totchild) {
/* lambda is percentage of elements to keep */
lambda= (arearatio < 1.0f)? powf(arearatio, powrate): 1.0f;
lambda *= viewport;
@@ -900,7 +900,7 @@ int psys_render_simplify_distribution(ParticleThreadContext *ctx, int tot)
/* extend lambda to include transition */
lambda= lambda + elem->t;
- if(lambda > 1.0f)
+ if (lambda > 1.0f)
lambda= 1.0f;
}
else {
@@ -925,10 +925,10 @@ int psys_render_simplify_distribution(ParticleThreadContext *ctx, int tot)
ctx->skip= MEM_callocN(sizeof(int)*tot, "SimplificationSkip");
skipped= 0;
- for(a=0, newtot=0; a<tot; a++) {
+ for (a=0, newtot=0; a<tot; a++) {
b= (origindex)? origindex[ctx->index[a]]: ctx->index[a];
- if(b != -1) {
- if(elems[b].curchild++ < ceil(elems[b].lambda*elems[b].totchild)) {
+ if (b != -1) {
+ if (elems[b].curchild++ < ceil(elems[b].lambda*elems[b].totchild)) {
ctx->index[newtot]= ctx->index[a];
ctx->skip[newtot]= skipped;
skipped= 0;
@@ -939,7 +939,7 @@ int psys_render_simplify_distribution(ParticleThreadContext *ctx, int tot)
else skipped++;
}
- for(a=0, elem=elems; a<totorigface; a++, elem++)
+ for (a=0, elem=elems; a<totorigface; a++, elem++)
elem->curchild= 0;
return newtot;
@@ -952,15 +952,15 @@ int psys_render_simplify_params(ParticleSystem *psys, ChildParticle *cpa, float
float x, w, scale, alpha, lambda, t, scalemin, scalemax;
int b;
- if(!(psys->renderdata && (psys->part->simplify_flag & PART_SIMPLIFY_ENABLE)))
+ if (!(psys->renderdata && (psys->part->simplify_flag & PART_SIMPLIFY_ENABLE)))
return 0;
data= psys->renderdata;
- if(!data->dosimplify)
+ if (!data->dosimplify)
return 0;
b= (data->origindex)? data->origindex[cpa->num]: cpa->num;
- if(b == -1)
+ if (b == -1)
return 0;
elem= &data->elems[b];
@@ -970,17 +970,17 @@ int psys_render_simplify_params(ParticleSystem *psys, ChildParticle *cpa, float
scalemin= elem->scalemin;
scalemax= elem->scalemax;
- if(!elem->reduce) {
+ if (!elem->reduce) {
scale= scalemin;
alpha= 1.0f;
}
else {
x= (elem->curchild+0.5f)/elem->totchild;
- if(x < lambda-t) {
+ if (x < lambda-t) {
scale= scalemax;
alpha= 1.0f;
}
- else if(x >= lambda+t) {
+ else if (x >= lambda+t) {
scale= scalemin;
alpha= 0.0f;
}
@@ -1007,7 +1007,7 @@ static float interpolate_particle_value(float v1, float v2, float v3, float v4,
float value;
value= w[0]*v1 + w[1]*v2 + w[2]*v3;
- if(four)
+ if (four)
value += w[3]*v4;
CLAMP(value, 0.f, 1.f);
@@ -1019,7 +1019,7 @@ void psys_interpolate_particle(short type, ParticleKey keys[4], float dt, Partic
{
float t[4];
- if(type<0) {
+ if (type<0) {
interp_cubic_v3( result->co, result->vel,keys[1].co, keys[1].vel, keys[2].co, keys[2].vel, dt);
}
else {
@@ -1027,15 +1027,15 @@ void psys_interpolate_particle(short type, ParticleKey keys[4], float dt, Partic
interp_v3_v3v3v3v3(result->co, keys[0].co, keys[1].co, keys[2].co, keys[3].co, t);
- if(velocity) {
+ if (velocity) {
float temp[3];
- if(dt>0.999f) {
+ if (dt>0.999f) {
key_curve_position_weights(dt-0.001f, t, type);
interp_v3_v3v3v3v3(temp, keys[0].co, keys[1].co, keys[2].co, keys[3].co, t);
sub_v3_v3v3(result->vel, result->co, temp);
}
- else{
+ else {
key_curve_position_weights(dt+0.001f, t, type);
interp_v3_v3v3v3v3(temp, keys[0].co, keys[1].co, keys[2].co, keys[3].co, t);
sub_v3_v3v3(result->vel, temp, result->co);
@@ -1071,15 +1071,15 @@ static void get_pointcache_keys_for_time(Object *UNUSED(ob), PointCache *cache,
static PTCacheMem *pm = NULL;
int index1, index2;
- if(index < 0) { /* initialize */
+ if (index < 0) { /* initialize */
*cur = cache->mem_cache.first;
- if(*cur)
+ if (*cur)
*cur = (*cur)->next;
}
else {
- if(*cur) {
- while(*cur && (*cur)->next && (float)(*cur)->frame < t)
+ if (*cur) {
+ while (*cur && (*cur)->next && (float)(*cur)->frame < t)
*cur = (*cur)->next;
pm = *cur;
@@ -1088,12 +1088,12 @@ static void get_pointcache_keys_for_time(Object *UNUSED(ob), PointCache *cache,
index1 = BKE_ptcache_mem_index_find(pm->prev, index);
BKE_ptcache_make_particle_key(key2, index2, pm->data, (float)pm->frame);
- if(index1 < 0)
+ if (index1 < 0)
copy_particle_key(key1, key2, 1);
else
BKE_ptcache_make_particle_key(key1, index1, pm->prev->data, (float)pm->prev->frame);
}
- else if(cache->mem_cache.first) {
+ else if (cache->mem_cache.first) {
pm = cache->mem_cache.first;
index2 = BKE_ptcache_mem_index_find(pm, index);
BKE_ptcache_make_particle_key(key2, index2, pm->data, (float)pm->frame);
@@ -1106,16 +1106,16 @@ static int get_pointcache_times_for_particle(PointCache *cache, int index, float
PTCacheMem *pm;
int ret = 0;
- for(pm=cache->mem_cache.first; pm; pm=pm->next) {
- if(BKE_ptcache_mem_index_find(pm, index) >= 0) {
+ for (pm=cache->mem_cache.first; pm; pm=pm->next) {
+ if (BKE_ptcache_mem_index_find(pm, index) >= 0) {
*start = pm->frame;
ret++;
break;
}
}
- for(pm=cache->mem_cache.last; pm; pm=pm->prev) {
- if(BKE_ptcache_mem_index_find(pm, index) >= 0) {
+ for (pm=cache->mem_cache.last; pm; pm=pm->prev) {
+ if (BKE_ptcache_mem_index_find(pm, index) >= 0) {
*end = pm->frame;
ret++;
break;
@@ -1130,8 +1130,8 @@ float psys_get_dietime_from_cache(PointCache *cache, int index)
PTCacheMem *pm;
int dietime = 10000000; /* some max value so that we can default to pa->time+lifetime */
- for(pm=cache->mem_cache.last; pm; pm=pm->prev) {
- if(BKE_ptcache_mem_index_find(pm, index) >= 0)
+ for (pm=cache->mem_cache.last; pm; pm=pm->prev) {
+ if (BKE_ptcache_mem_index_find(pm, index) >= 0)
return (float)pm->frame;
}
@@ -1141,7 +1141,7 @@ float psys_get_dietime_from_cache(PointCache *cache, int index)
static void init_particle_interpolation(Object *ob, ParticleSystem *psys, ParticleData *pa, ParticleInterpolationData *pind)
{
- if(pind->epoint) {
+ if (pind->epoint) {
PTCacheEditPoint *point = pind->epoint;
pind->ekey[0] = point->keys;
@@ -1150,7 +1150,7 @@ static void init_particle_interpolation(Object *ob, ParticleSystem *psys, Partic
pind->birthtime = *(point->keys->time);
pind->dietime = *((point->keys + point->totkey - 1)->time);
}
- else if(pind->keyed) {
+ else if (pind->keyed) {
ParticleKey *key = pa->keys;
pind->kkey[0] = key;
pind->kkey[1] = pa->totkey > 1 ? key + 1 : NULL;
@@ -1158,13 +1158,13 @@ static void init_particle_interpolation(Object *ob, ParticleSystem *psys, Partic
pind->birthtime = key->time;
pind->dietime = (key + pa->totkey - 1)->time;
}
- else if(pind->cache) {
+ else if (pind->cache) {
float start=0.0f, end=0.0f;
get_pointcache_keys_for_time(ob, pind->cache, &pind->pm, -1, 0.0f, NULL, NULL);
pind->birthtime = pa ? pa->time : pind->cache->startframe;
pind->dietime = pa ? pa->dietime : pind->cache->endframe;
- if(get_pointcache_times_for_particle(pind->cache, pa - psys->particles, &start, &end)) {
+ if (get_pointcache_times_for_particle(pind->cache, pa - psys->particles, &start, &end)) {
pind->birthtime = MAX2(pind->birthtime, start);
pind->dietime = MIN2(pind->dietime, end);
}
@@ -1177,7 +1177,7 @@ static void init_particle_interpolation(Object *ob, ParticleSystem *psys, Partic
pind->birthtime = key->time;
pind->dietime = (key + pa->totkey - 1)->time;
- if(pind->dm) {
+ if (pind->dm) {
pind->mvert[0] = CDDM_get_vert(pind->dm, pa->hair_index);
pind->mvert[1] = pind->mvert[0] + 1;
}
@@ -1186,7 +1186,7 @@ static void init_particle_interpolation(Object *ob, ParticleSystem *psys, Partic
static void edit_to_particle(ParticleKey *key, PTCacheEditKey *ekey)
{
copy_v3_v3(key->co, ekey->co);
- if(ekey->vel) {
+ if (ekey->vel) {
copy_v3_v3(key->vel, ekey->vel);
}
key->time = *(ekey->time);
@@ -1214,41 +1214,41 @@ static void do_particle_interpolation(ParticleSystem *psys, int p, ParticleData
memset(keys, 0, sizeof(keys));
/* interpret timing and find keys */
- if(point) {
- if(result->time < 0.0f)
+ if (point) {
+ if (result->time < 0.0f)
real_t = -result->time;
else
real_t = *(pind->ekey[0]->time) + t * (*(pind->ekey[0][point->totkey-1].time) - *(pind->ekey[0]->time));
- while(*(pind->ekey[1]->time) < real_t)
+ while (*(pind->ekey[1]->time) < real_t)
pind->ekey[1]++;
pind->ekey[0] = pind->ekey[1] - 1;
}
- else if(pind->keyed) {
+ else if (pind->keyed) {
/* we have only one key, so let's use that */
- if(pind->kkey[1]==NULL) {
+ if (pind->kkey[1]==NULL) {
copy_particle_key(result, pind->kkey[0], 1);
return;
}
- if(result->time < 0.0f)
+ if (result->time < 0.0f)
real_t = -result->time;
else
real_t = pind->kkey[0]->time + t * (pind->kkey[0][pa->totkey-1].time - pind->kkey[0]->time);
- if(psys->part->phystype==PART_PHYS_KEYED && psys->flag & PSYS_KEYED_TIMING) {
+ if (psys->part->phystype==PART_PHYS_KEYED && psys->flag & PSYS_KEYED_TIMING) {
ParticleTarget *pt = psys->targets.first;
pt=pt->next;
- while(pt && pa->time + pt->time < real_t)
+ while (pt && pa->time + pt->time < real_t)
pt= pt->next;
- if(pt) {
+ if (pt) {
pt=pt->prev;
- if(pa->time + pt->time + pt->duration > real_t)
+ if (pa->time + pt->time + pt->duration > real_t)
real_t = pa->time + pt->time;
}
else
@@ -1257,24 +1257,24 @@ static void do_particle_interpolation(ParticleSystem *psys, int p, ParticleData
CLAMP(real_t, pa->time, pa->dietime);
- while(pind->kkey[1]->time < real_t)
+ while (pind->kkey[1]->time < real_t)
pind->kkey[1]++;
pind->kkey[0] = pind->kkey[1] - 1;
}
- else if(pind->cache) {
- if(result->time < 0.0f) /* flag for time in frames */
+ else if (pind->cache) {
+ if (result->time < 0.0f) /* flag for time in frames */
real_t = -result->time;
else
real_t = pa->time + t * (pa->dietime - pa->time);
}
else {
- if(result->time < 0.0f)
+ if (result->time < 0.0f)
real_t = -result->time;
else
real_t = pind->hkey[0]->time + t * (pind->hkey[0][pa->totkey-1].time - pind->hkey[0]->time);
- while(pind->hkey[1]->time < real_t) {
+ while (pind->hkey[1]->time < real_t) {
pind->hkey[1]++;
pind->mvert[1]++;
}
@@ -1283,20 +1283,20 @@ static void do_particle_interpolation(ParticleSystem *psys, int p, ParticleData
}
/* set actual interpolation keys */
- if(point) {
+ if (point) {
edit_to_particle(keys + 1, pind->ekey[0]);
edit_to_particle(keys + 2, pind->ekey[1]);
}
- else if(pind->dm) {
+ else if (pind->dm) {
pind->mvert[0] = pind->mvert[1] - 1;
mvert_to_particle(keys + 1, pind->mvert[0], pind->hkey[0]);
mvert_to_particle(keys + 2, pind->mvert[1], pind->hkey[1]);
}
- else if(pind->keyed) {
+ else if (pind->keyed) {
memcpy(keys + 1, pind->kkey[0], sizeof(ParticleKey));
memcpy(keys + 2, pind->kkey[1], sizeof(ParticleKey));
}
- else if(pind->cache) {
+ else if (pind->cache) {
get_pointcache_keys_for_time(NULL, pind->cache, &pind->pm, p, real_t, keys+1, keys+2);
}
else {
@@ -1305,40 +1305,40 @@ static void do_particle_interpolation(ParticleSystem *psys, int p, ParticleData
}
/* set secondary interpolation keys for hair */
- if(!pind->keyed && !pind->cache && !point_vel) {
- if(point) {
- if(pind->ekey[0] != point->keys)
+ if (!pind->keyed && !pind->cache && !point_vel) {
+ if (point) {
+ if (pind->ekey[0] != point->keys)
edit_to_particle(keys, pind->ekey[0] - 1);
else
edit_to_particle(keys, pind->ekey[0]);
}
- else if(pind->dm) {
- if(pind->hkey[0] != pa->hair)
+ else if (pind->dm) {
+ if (pind->hkey[0] != pa->hair)
mvert_to_particle(keys, pind->mvert[0] - 1, pind->hkey[0] - 1);
else
mvert_to_particle(keys, pind->mvert[0], pind->hkey[0]);
}
else {
- if(pind->hkey[0] != pa->hair)
+ if (pind->hkey[0] != pa->hair)
hair_to_particle(keys, pind->hkey[0] - 1);
else
hair_to_particle(keys, pind->hkey[0]);
}
- if(point) {
- if(pind->ekey[1] != point->keys + point->totkey - 1)
+ if (point) {
+ if (pind->ekey[1] != point->keys + point->totkey - 1)
edit_to_particle(keys + 3, pind->ekey[1] + 1);
else
edit_to_particle(keys + 3, pind->ekey[1]);
}
- else if(pind->dm) {
- if(pind->hkey[1] != pa->hair + pa->totkey - 1)
+ else if (pind->dm) {
+ if (pind->hkey[1] != pa->hair + pa->totkey - 1)
mvert_to_particle(keys + 3, pind->mvert[1] + 1, pind->hkey[1] + 1);
else
mvert_to_particle(keys + 3, pind->mvert[1], pind->hkey[1]);
}
else {
- if(pind->hkey[1] != pa->hair + pa->totkey - 1)
+ if (pind->hkey[1] != pa->hair + pa->totkey - 1)
hair_to_particle(keys + 3, pind->hkey[1] + 1);
else
hair_to_particle(keys + 3, pind->hkey[1]);
@@ -1349,7 +1349,7 @@ static void do_particle_interpolation(ParticleSystem *psys, int p, ParticleData
keytime = (real_t - keys[1].time) / dfra;
/* convert velocity to timestep size */
- if(pind->keyed || pind->cache || point_vel) {
+ if (pind->keyed || pind->cache || point_vel) {
invdt = dfra * 0.04f * (psys ? psys->part->timetweak : 1.f);
mul_v3_fl(keys[1].vel, invdt);
mul_v3_fl(keys[2].vel, invdt);
@@ -1362,7 +1362,7 @@ static void do_particle_interpolation(ParticleSystem *psys, int p, ParticleData
,keys, keytime, result, 1);
/* the velocity needs to be converted back from cubic interpolation */
- if(pind->keyed || pind->cache || point_vel)
+ if (pind->keyed || pind->cache || point_vel)
mul_v3_fl(result->vel, 1.f/invdt);
}
@@ -1374,10 +1374,10 @@ static void interpolate_pathcache(ParticleCacheKey *first, float t, ParticleCach
/* scale the requested time to fit the entire path even if the path is cut early */
t *= (first+first->steps)->time;
- while(i<first->steps && cur->time < t)
+ while (i<first->steps && cur->time < t)
cur++;
- if(cur->time == t)
+ if (cur->time == t)
*result = *cur;
else {
float dt = (t-(cur-1)->time)/(cur->time-(cur-1)->time);
@@ -1388,7 +1388,7 @@ static void interpolate_pathcache(ParticleCacheKey *first, float t, ParticleCach
}
/* first is actual base rotation, others are incremental from first */
- if(cur==first || cur-1==first)
+ if (cur==first || cur-1==first)
copy_qt_qt(result->rot, first->rot);
else
mul_qt_qtqt(result->rot, first->rot, result->rot);
@@ -1416,14 +1416,14 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or
normal_short_to_float_v3(n2, mvert[mface->v2].no);
normal_short_to_float_v3(n3, mvert[mface->v3].no);
- if(mface->v4) {
+ if (mface->v4) {
v4= mvert[mface->v4].co;
normal_short_to_float_v3(n4, mvert[mface->v4].no);
interp_v3_v3v3v3v3(vec, v1, v2, v3, v4, w);
- if(nor) {
- if(mface->flag & ME_SMOOTH)
+ if (nor) {
+ if (mface->flag & ME_SMOOTH)
interp_v3_v3v3v3v3(nor, n1, n2, n3, n4, w);
else
normal_quad_v3(nor,v1,v2,v3,v4);
@@ -1432,8 +1432,8 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or
else {
interp_v3_v3v3v3(vec, v1, v2, v3, w);
- if(nor) {
- if(mface->flag & ME_SMOOTH)
+ if (nor) {
+ if (mface->flag & ME_SMOOTH)
interp_v3_v3v3v3(nor, n1, n2, n3, w);
else
normal_tri_v3(nor,v1,v2,v3);
@@ -1441,23 +1441,23 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or
}
/* calculate tangent vectors */
- if(utan && vtan) {
- if(tface) {
+ if (utan && vtan) {
+ if (tface) {
uv1= tface->uv[0];
uv2= tface->uv[1];
uv3= tface->uv[2];
uv4= tface->uv[3];
}
- else{
+ else {
uv1= tuv[0]; uv2= tuv[1]; uv3= tuv[2]; uv4= tuv[3];
map_to_sphere( uv1, uv1+1,v1[0], v1[1], v1[2]);
map_to_sphere( uv2, uv2+1,v2[0], v2[1], v2[2]);
map_to_sphere( uv3, uv3+1,v3[0], v3[1], v3[2]);
- if(v4)
+ if (v4)
map_to_sphere( uv4, uv4+1,v4[0], v4[1], v4[2]);
}
- if(v4) {
+ if (v4) {
s1= uv3[0] - uv1[0];
s2= uv4[0] - uv1[0];
@@ -1467,7 +1467,7 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or
sub_v3_v3v3(e1, v3, v1);
sub_v3_v3v3(e2, v4, v1);
}
- else{
+ else {
s1= uv2[0] - uv1[0];
s2= uv3[0] - uv1[0];
@@ -1487,30 +1487,30 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or
utan[2] = (t1*e2[2] - t2*e1[2]);
}
- if(orco) {
- if(orcodata) {
+ if (orco) {
+ if (orcodata) {
o1= orcodata[mface->v1];
o2= orcodata[mface->v2];
o3= orcodata[mface->v3];
- if(mface->v4) {
+ if (mface->v4) {
o4= orcodata[mface->v4];
interp_v3_v3v3v3v3(orco, o1, o2, o3, o4, w);
- if(ornor)
+ if (ornor)
normal_quad_v3( ornor,o1, o2, o3, o4);
}
else {
interp_v3_v3v3v3(orco, o1, o2, o3, w);
- if(ornor)
+ if (ornor)
normal_tri_v3( ornor,o1, o2, o3);
}
}
else {
copy_v3_v3(orco, vec);
- if(ornor && nor)
+ if (ornor && nor)
copy_v3_v3(ornor, nor);
}
}
@@ -1525,7 +1525,7 @@ void psys_interpolate_uvs(const MTFace *tface, int quad, const float w[4], float
float v31= tface->uv[2][1];
float v40,v41;
- if(quad) {
+ if (quad) {
v40= tface->uv[3][0];
v41= tface->uv[3][1];
@@ -1547,7 +1547,7 @@ void psys_interpolate_mcol(const MCol *mcol, int quad, const float w[4], MCol *m
cp2= (char *)&mcol[1];
cp3= (char *)&mcol[2];
- if(quad) {
+ if (quad) {
cp4= (char *)&mcol[3];
cp[0]= (int)(w[0]*cp1[0] + w[1]*cp2[0] + w[2]*cp3[0] + w[3]*cp4[0]);
@@ -1565,7 +1565,7 @@ void psys_interpolate_mcol(const MCol *mcol, int quad, const float w[4], MCol *m
static float psys_interpolate_value_from_verts(DerivedMesh *dm, short from, int index, const float fw[4], const float *values)
{
- if(values==0 || index==-1)
+ if (values==0 || index==-1)
return 0.0;
switch(from) {
@@ -1601,7 +1601,7 @@ static void psys_origspace_to_w(OrigSpaceFace *osface, int quad, const float w[4
psys_w_to_origspace(w, co);
co[2]= 0.0f;
- if(quad) {
+ if (quad) {
v[3][0]= osface->uv[3][0]; v[3][1]= osface->uv[3][1]; v[3][2]= 0.0f;
interp_weights_poly_v3(neww, v, 4, co);
}
@@ -1628,50 +1628,51 @@ int psys_particle_dm_face_lookup(Object *ob, DerivedMesh *dm, int index, const f
totface = dm->getNumTessFaces(dm);
- if(osface==NULL || origindex==NULL) {
+ if (osface==NULL || origindex==NULL) {
/* Assume we don't need osface data */
if (index <totface) {
//printf("\tNO CD_ORIGSPACE, assuming not needed\n");
return index;
- } else {
+ }
+ else {
printf("\tNO CD_ORIGSPACE, error out of range\n");
return DMCACHE_NOTFOUND;
}
}
- else if(index >= me->totpoly)
+ else if (index >= me->totpoly)
return DMCACHE_NOTFOUND; /* index not in the original mesh */
psys_w_to_origspace(fw, uv);
- if(node) { /* we have a linked list of faces that we use, faster! */
- for(;node; node=node->next) {
+ if (node) { /* we have a linked list of faces that we use, faster! */
+ for (;node; node=node->next) {
findex= GET_INT_FROM_POINTER(node->link);
faceuv= osface[findex].uv;
quad = (mface[findex].totloop == 4);
/* check that this intersects - Its possible this misses :/ -
* could also check its not between */
- if(quad) {
- if(isect_point_quad_v2(uv, faceuv[0], faceuv[1], faceuv[2], faceuv[3]))
+ if (quad) {
+ if (isect_point_quad_v2(uv, faceuv[0], faceuv[1], faceuv[2], faceuv[3]))
return findex;
}
- else if(isect_point_tri_v2(uv, faceuv[0], faceuv[1], faceuv[2]))
+ else if (isect_point_tri_v2(uv, faceuv[0], faceuv[1], faceuv[2]))
return findex;
}
}
else { /* if we have no node, try every face */
- for(findex=0; findex<totface; findex++) {
- if(origindex[findex] == index) {
+ for (findex=0; findex<totface; findex++) {
+ if (origindex[findex] == index) {
faceuv= osface[findex].uv;
quad = (mface[findex].totloop == 4);
/* check that this intersects - Its possible this misses :/ -
* could also check its not between */
- if(quad) {
- if(isect_point_quad_v2(uv, faceuv[0], faceuv[1], faceuv[2], faceuv[3]))
+ if (quad) {
+ if (isect_point_quad_v2(uv, faceuv[0], faceuv[1], faceuv[2], faceuv[3]))
return findex;
}
- else if(isect_point_tri_v2(uv, faceuv[0], faceuv[1], faceuv[2]))
+ else if (isect_point_tri_v2(uv, faceuv[0], faceuv[1], faceuv[2]))
return findex;
}
}
@@ -1682,30 +1683,31 @@ int psys_particle_dm_face_lookup(Object *ob, DerivedMesh *dm, int index, const f
static int psys_map_index_on_dm(DerivedMesh *dm, int from, int index, int index_dmcache, const float fw[4], float UNUSED(foffset), int *mapindex, float mapfw[4])
{
- if(index < 0)
+ if (index < 0)
return 0;
if (dm->deformedOnly || index_dmcache == DMCACHE_ISCHILD) {
/* for meshes that are either only defined or for child particles, the
* index and fw do not require any mapping, so we can directly use it */
- if(from == PART_FROM_VERT) {
- if(index >= dm->getNumVerts(dm))
+ if (from == PART_FROM_VERT) {
+ if (index >= dm->getNumVerts(dm))
return 0;
*mapindex = index;
}
else { /* FROM_FACE/FROM_VOLUME */
- if(index >= dm->getNumTessFaces(dm))
+ if (index >= dm->getNumTessFaces(dm))
return 0;
*mapindex = index;
copy_v4_v4(mapfw, fw);
}
- } else {
+ }
+ else {
/* for other meshes that have been modified, we try to map the particle
* to their new location, which means a different index, and for faces
* also a new face interpolation weights */
- if(from == PART_FROM_VERT) {
+ if (from == PART_FROM_VERT) {
if (index_dmcache == DMCACHE_NOTFOUND || index_dmcache > dm->getNumVerts(dm))
return 0;
@@ -1719,7 +1721,7 @@ static int psys_map_index_on_dm(DerivedMesh *dm, int from, int index, int index_
i = index_dmcache;
- if(i== DMCACHE_NOTFOUND || i >= dm->getNumTessFaces(dm))
+ if (i== DMCACHE_NOTFOUND || i >= dm->getNumTessFaces(dm))
return 0;
*mapindex = i;
@@ -1729,7 +1731,7 @@ static int psys_map_index_on_dm(DerivedMesh *dm, int from, int index, int index_
osface= dm->getTessFaceDataArray(dm, CD_ORIGSPACE);
mface= dm->getTessFaceData(dm, i, CD_MFACE);
- if(osface == NULL)
+ if (osface == NULL)
mapfw[0]= mapfw[1]= mapfw[2]= mapfw[3]= 0.0f;
else
psys_origspace_to_w(&osface[i], mface->v4, fw, mapfw);
@@ -1746,36 +1748,36 @@ void psys_particle_on_dm(DerivedMesh *dm, int from, int index, int index_dmcache
float (*orcodata)[3];
int mapindex;
- if(!psys_map_index_on_dm(dm, from, index, index_dmcache, fw, foffset, &mapindex, mapfw)) {
- if(vec) { vec[0]=vec[1]=vec[2]=0.0; }
- if(nor) { nor[0]=nor[1]=0.0; nor[2]=1.0; }
- if(orco) { orco[0]=orco[1]=orco[2]=0.0; }
- if(ornor) { ornor[0]=ornor[1]=0.0; ornor[2]=1.0; }
- if(utan) { utan[0]=utan[1]=utan[2]=0.0; }
- if(vtan) { vtan[0]=vtan[1]=vtan[2]=0.0; }
+ if (!psys_map_index_on_dm(dm, from, index, index_dmcache, fw, foffset, &mapindex, mapfw)) {
+ if (vec) { vec[0]=vec[1]=vec[2]=0.0; }
+ if (nor) { nor[0]=nor[1]=0.0; nor[2]=1.0; }
+ if (orco) { orco[0]=orco[1]=orco[2]=0.0; }
+ if (ornor) { ornor[0]=ornor[1]=0.0; ornor[2]=1.0; }
+ if (utan) { utan[0]=utan[1]=utan[2]=0.0; }
+ if (vtan) { vtan[0]=vtan[1]=vtan[2]=0.0; }
return;
}
orcodata= dm->getVertDataArray(dm, CD_ORCO);
- if(from == PART_FROM_VERT) {
+ if (from == PART_FROM_VERT) {
dm->getVertCo(dm,mapindex,vec);
- if(nor) {
+ if (nor) {
dm->getVertNo(dm,mapindex,nor);
normalize_v3(nor);
}
- if(orco)
+ if (orco)
copy_v3_v3(orco, orcodata[mapindex]);
- if(ornor) {
+ if (ornor) {
dm->getVertNo(dm,mapindex,nor);
normalize_v3(nor);
}
- if(utan && vtan) {
+ if (utan && vtan) {
utan[0]= utan[1]= utan[2]= 0.0f;
vtan[0]= vtan[1]= vtan[2]= 0.0f;
}
@@ -1789,12 +1791,12 @@ void psys_particle_on_dm(DerivedMesh *dm, int from, int index, int index_dmcache
mvert=dm->getVertDataArray(dm,CD_MVERT);
mtface=CustomData_get_layer(&dm->faceData,CD_MTFACE);
- if(mtface)
+ if (mtface)
mtface += mapindex;
- if(from==PART_FROM_VOLUME) {
+ if (from==PART_FROM_VOLUME) {
psys_interpolate_face(mvert,mface,mtface,orcodata,mapfw,vec,tmpnor,utan,vtan,orco,ornor);
- if(nor)
+ if (nor)
copy_v3_v3(nor,tmpnor);
normalize_v3(tmpnor);
@@ -1811,7 +1813,7 @@ float psys_particle_value_from_verts(DerivedMesh *dm, short from, ParticleData *
float mapfw[4];
int mapindex;
- if(!psys_map_index_on_dm(dm, from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, &mapindex, mapfw))
+ if (!psys_map_index_on_dm(dm, from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, &mapindex, mapfw))
return 0.0f;
return psys_interpolate_value_from_verts(dm, from, mapindex, mapfw, values);
@@ -1822,10 +1824,10 @@ ParticleSystemModifierData *psys_get_modifier(Object *ob, ParticleSystem *psys)
ModifierData *md;
ParticleSystemModifierData *psmd;
- for(md=ob->modifiers.first; md; md=md->next) {
- if(md->type==eModifierType_ParticleSystem) {
+ for (md=ob->modifiers.first; md; md=md->next) {
+ if (md->type==eModifierType_ParticleSystem) {
psmd= (ParticleSystemModifierData*) md;
- if(psmd->psys==psys) {
+ if (psmd->psys==psys) {
return psmd;
}
}
@@ -1840,22 +1842,22 @@ static void psys_particle_on_shape(int UNUSED(distr), int UNUSED(index), float *
{
/* TODO */
float zerovec[3]={0.0f,0.0f,0.0f};
- if(vec) {
+ if (vec) {
copy_v3_v3(vec,zerovec);
}
- if(nor) {
+ if (nor) {
copy_v3_v3(nor,zerovec);
}
- if(utan) {
+ if (utan) {
copy_v3_v3(utan,zerovec);
}
- if(vtan) {
+ if (vtan) {
copy_v3_v3(vtan,zerovec);
}
- if(orco) {
+ if (orco) {
copy_v3_v3(orco,zerovec);
}
- if(ornor) {
+ if (ornor) {
copy_v3_v3(ornor,zerovec);
}
}
@@ -1864,12 +1866,12 @@ static void psys_particle_on_shape(int UNUSED(distr), int UNUSED(index), float *
/************************************************/
void psys_particle_on_emitter(ParticleSystemModifierData *psmd, int from, int index, int index_dmcache, float *fuv, float foffset, float *vec, float *nor, float *utan, float *vtan, float *orco, float *ornor)
{
- if(psmd) {
- if(psmd->psys->part->distr==PART_DISTR_GRID && psmd->psys->part->from != PART_FROM_VERT) {
- if(vec)
+ if (psmd) {
+ if (psmd->psys->part->distr==PART_DISTR_GRID && psmd->psys->part->from != PART_FROM_VERT) {
+ if (vec)
copy_v3_v3(vec,fuv);
- if(orco)
+ if (orco)
copy_v3_v3(orco, fuv);
return;
}
@@ -1889,13 +1891,13 @@ static void do_kink(ParticleKey *state, ParticleKey *par, float *par_rot, float
float kink[3]={1.f,0.f,0.f}, par_vec[3], q1[4]={1.f,0.f,0.f,0.f};
float t, dt=1.f, result[3];
- if(par == NULL || type == PART_KINK_NO)
+ if (par == NULL || type == PART_KINK_NO)
return;
CLAMP(time, 0.f, 1.f);
- if(shape!=0.0f && type!=PART_KINK_BRAID) {
- if(shape<0.0f)
+ if (shape!=0.0f && type!=PART_KINK_BRAID) {
+ if (shape<0.0f)
time= (float)pow(time, 1.f+shape);
else
time= (float)pow(time, 1.f/(1.f-shape));
@@ -1903,22 +1905,22 @@ static void do_kink(ParticleKey *state, ParticleKey *par, float *par_rot, float
t = time * freq *(float)M_PI;
- if(smooth_start) {
+ if (smooth_start) {
dt = fabs(t);
/* smooth the beginning of kink */
CLAMP(dt, 0.f, (float)M_PI);
dt = sin(dt/2.f);
}
- if(type != PART_KINK_RADIAL) {
+ if (type != PART_KINK_RADIAL) {
float temp[3];
kink[axis]=1.f;
- if(obmat)
+ if (obmat)
mul_mat3_m4_v3(obmat, kink);
- if(par_rot)
+ if (par_rot)
mul_qt_v3(par_rot, kink);
/* make sure kink is normal to strand */
@@ -1935,7 +1937,7 @@ static void do_kink(ParticleKey *state, ParticleKey *par, float *par_rot, float
{
negate_v3(par_vec);
- if(flat > 0.f) {
+ if (flat > 0.f) {
float proj[3];
project_v3_v3v3(proj, par_vec, par->vel);
madd_v3_v3fl(par_vec, proj, -flat);
@@ -1951,7 +1953,7 @@ static void do_kink(ParticleKey *state, ParticleKey *par, float *par_rot, float
madd_v3_v3fl(par_vec, kink, amplitude);
/* rotate kink vector around strand tangent */
- if(t!=0.f) {
+ if (t!=0.f) {
axis_angle_to_quat(q1, par->vel, t);
mul_qt_v3(q1, par_vec);
}
@@ -1961,7 +1963,7 @@ static void do_kink(ParticleKey *state, ParticleKey *par, float *par_rot, float
}
case PART_KINK_RADIAL:
{
- if(flat > 0.f) {
+ if (flat > 0.f) {
float proj[3];
/* flatten along strand */
project_v3_v3v3(proj, par_vec, par->vel);
@@ -1975,7 +1977,7 @@ static void do_kink(ParticleKey *state, ParticleKey *par, float *par_rot, float
{
madd_v3_v3fl(result, kink, amplitude*(float)sin(t));
- if(flat > 0.f) {
+ if (flat > 0.f) {
float proj[3];
/* flatten along wave */
project_v3_v3v3(proj, par_vec, kink);
@@ -1994,7 +1996,7 @@ static void do_kink(ParticleKey *state, ParticleKey *par, float *par_rot, float
float vec_one[3], state_co[3];
float inp_y, inp_z, length;
- if(par_rot) {
+ if (par_rot) {
mul_qt_v3(par_rot, y_vec);
mul_qt_v3(par_rot, z_vec);
}
@@ -2005,20 +2007,20 @@ static void do_kink(ParticleKey *state, ParticleKey *par, float *par_rot, float
inp_y=dot_v3v3(y_vec, vec_one);
inp_z=dot_v3v3(z_vec, vec_one);
- if(inp_y > 0.5f) {
+ if (inp_y > 0.5f) {
copy_v3_v3(state_co, y_vec);
mul_v3_fl(y_vec, amplitude*(float)cos(t));
mul_v3_fl(z_vec, amplitude/2.f*(float)sin(2.f*t));
}
- else if(inp_z > 0.0f) {
+ else if (inp_z > 0.0f) {
mul_v3_v3fl(state_co, z_vec, (float)sin((float)M_PI/3.f));
madd_v3_v3fl(state_co, y_vec, -0.5f);
mul_v3_fl(y_vec, -amplitude * (float)cos(t + (float)M_PI/3.f));
mul_v3_fl(z_vec, amplitude/2.f * (float)cos(2.f*t + (float)M_PI/6.f));
}
- else{
+ else {
mul_v3_v3fl(state_co, z_vec, -(float)sin((float)M_PI/3.f));
madd_v3_v3fl(state_co, y_vec, -0.5f);
@@ -2039,12 +2041,12 @@ static void do_kink(ParticleKey *state, ParticleKey *par, float *par_rot, float
shape = 2.f*(float)M_PI * (1.f+shape);
- if(t<shape) {
+ if (t<shape) {
shape = t/shape;
shape = (float)sqrt((double)shape);
interp_v3_v3v3(result, result, state_co, shape);
}
- else{
+ else {
copy_v3_v3(result, state_co);
}
break;
@@ -2052,7 +2054,7 @@ static void do_kink(ParticleKey *state, ParticleKey *par, float *par_rot, float
}
/* blend the start of the kink */
- if(dt < 1.f)
+ if (dt < 1.f)
interp_v3_v3v3(state->co, state->co, result, dt);
else
copy_v3_v3(state->co, result);
@@ -2062,15 +2064,15 @@ static float do_clump(ParticleKey *state, ParticleKey *par, float time, float cl
{
float clump = 0.f;
- if(par && clumpfac!=0.0f) {
+ if (par && clumpfac!=0.0f) {
float cpow;
- if(clumppow < 0.0f)
+ if (clumppow < 0.0f)
cpow=1.0f+clumppow;
else
cpow=1.0f+9.0f*clumppow;
- if(clumpfac < 0.0f) /* clump roots instead of tips */
+ if (clumpfac < 0.0f) /* clump roots instead of tips */
clump = -clumpfac*pa_clump*(float)pow(1.0-(double)time,(double)cpow);
else
clump = clumpfac*pa_clump*(float)pow((double)time,(double)cpow);
@@ -2091,7 +2093,7 @@ void precalc_guides(ParticleSimulationData *sim, ListBase *effectors)
GuideEffectorData *data;
PARTICLE_P;
- if(!effectors)
+ if (!effectors)
return;
LOOP_PARTICLES {
@@ -2102,11 +2104,11 @@ void precalc_guides(ParticleSimulationData *sim, ListBase *effectors)
pd_point_from_particle(sim, pa, &state, &point);
- for(eff = effectors->first; eff; eff=eff->next) {
- if(eff->pd->forcefield != PFIELD_GUIDE)
+ for (eff = effectors->first; eff; eff=eff->next) {
+ if (eff->pd->forcefield != PFIELD_GUIDE)
continue;
- if(!eff->guide_data)
+ if (!eff->guide_data)
eff->guide_data = MEM_callocN(sizeof(GuideEffectorData)*psys->totpart, "GuideEffectorData");
data = eff->guide_data + p;
@@ -2133,30 +2135,30 @@ int do_guides(ListBase *effectors, ParticleKey *state, int index, float time)
float guidetime, radius, weight, angle, totstrength = 0.0f;
float vec_to_point[3];
- if(effectors) for(eff = effectors->first; eff; eff=eff->next) {
+ if (effectors) for(eff = effectors->first; eff; eff=eff->next) {
pd = eff->pd;
- if(pd->forcefield != PFIELD_GUIDE)
+ if (pd->forcefield != PFIELD_GUIDE)
continue;
data = eff->guide_data + index;
- if(data->strength <= 0.0f)
+ if (data->strength <= 0.0f)
continue;
guidetime = time / (1.0f - pd->free_end);
- if(guidetime>1.0f)
+ if (guidetime>1.0f)
continue;
cu = (Curve*)eff->ob->data;
- if(pd->flag & PFIELD_GUIDE_PATH_ADD) {
- if(where_on_path(eff->ob, data->strength * guidetime, guidevec, guidedir, NULL, &radius, &weight)==0)
+ if (pd->flag & PFIELD_GUIDE_PATH_ADD) {
+ if (where_on_path(eff->ob, data->strength * guidetime, guidevec, guidedir, NULL, &radius, &weight)==0)
return 0;
}
else {
- if(where_on_path(eff->ob, guidetime, guidevec, guidedir, NULL, &radius, &weight)==0)
+ if (where_on_path(eff->ob, guidetime, guidevec, guidedir, NULL, &radius, &weight)==0)
return 0;
}
@@ -2167,7 +2169,7 @@ int do_guides(ListBase *effectors, ParticleKey *state, int index, float time)
copy_v3_v3(vec_to_point, data->vec_to_point);
- if(guidetime != 0.0f) {
+ if (guidetime != 0.0f) {
/* curve direction */
cross_v3_v3v3(temp, eff->guide_dir, guidedir);
angle = dot_v3v3(eff->guide_dir, guidedir)/(len_v3(eff->guide_dir));
@@ -2181,11 +2183,11 @@ int do_guides(ListBase *effectors, ParticleKey *state, int index, float time)
}
/* curve taper */
- if(cu->taperobj)
+ if (cu->taperobj)
mul_v3_fl(vec_to_point, calc_taper(eff->scene, cu->taperobj, (int)(data->strength*guidetime*100.0f), 100));
- else{ /* curve size*/
- if(cu->flag & CU_PATH_RADIUS) {
+ else { /* curve size*/
+ if (cu->flag & CU_PATH_RADIUS) {
mul_v3_fl(vec_to_point, radius);
}
}
@@ -2202,12 +2204,12 @@ int do_guides(ListBase *effectors, ParticleKey *state, int index, float time)
madd_v3_v3fl(veffect, guidedir, data->strength);
totstrength += data->strength;
- if(pd->flag & PFIELD_GUIDE_PATH_WEIGHT)
+ if (pd->flag & PFIELD_GUIDE_PATH_WEIGHT)
totstrength *= weight;
}
- if(totstrength != 0.0f) {
- if(totstrength > 1.0f)
+ if (totstrength != 0.0f) {
+ if (totstrength > 1.0f)
mul_v3_fl(effect, 1.0f / totstrength);
CLAMP(totstrength, 0.0f, 1.0f);
//add_v3_v3(effect,pa_zero);
@@ -2225,8 +2227,8 @@ static void do_rough(float *loc, float mat[4][4], float t, float fac, float size
float rough[3];
float rco[3];
- if(thres != 0.0f)
- if((float)fabs((float)(-1.5f+loc[0]+loc[1]+loc[2]))<1.5f*thres) return;
+ if (thres != 0.0f)
+ if ((float)fabs((float)(-1.5f+loc[0]+loc[1]+loc[2]))<1.5f*thres) return;
copy_v3_v3(rco,loc);
mul_v3_fl(rco,t);
@@ -2259,7 +2261,7 @@ static void do_path_effectors(ParticleSimulationData *sim, int i, ParticleCacheK
EffectedPoint epoint;
/* Don't apply effectors for dynamic hair, otherwise the effectors don't get applied twice. */
- if(sim->psys->flag & PSYS_HAIR_DYNAMICS)
+ if (sim->psys->flag & PSYS_HAIR_DYNAMICS)
return;
copy_v3_v3(eff_key.co,(ca-1)->co);
@@ -2275,17 +2277,17 @@ static void do_path_effectors(ParticleSimulationData *sim, int i, ParticleCacheK
normalize_v3(force);
- if(k < steps)
+ if (k < steps)
sub_v3_v3v3(vec, (ca+1)->co, ca->co);
madd_v3_v3v3fl(ca->co, (ca-1)->co, force, *length);
- if(k < steps)
+ if (k < steps)
*length = len_v3(vec);
}
static int check_path_length(int k, ParticleCacheKey *keys, ParticleCacheKey *state, float max_length, float *cur_length, float length, float *dvec)
{
- if(*cur_length + length > max_length) {
+ if (*cur_length + length > max_length) {
mul_v3_fl(dvec, (max_length - *cur_length) / length);
add_v3_v3v3(state->co, (state - 1)->co, dvec);
keys->steps = k;
@@ -2306,7 +2308,7 @@ static void offset_child(ChildParticle *cpa, ParticleKey *par, float *par_rot, P
copy_v3_v3(child->vel, par->vel);
- if(par_rot) {
+ if (par_rot) {
mul_qt_v3(par_rot, child->co);
copy_qt_qt(child->rot, par_rot);
}
@@ -2319,21 +2321,21 @@ float *psys_cache_vgroup(DerivedMesh *dm, ParticleSystem *psys, int vgroup)
{
float *vg=0;
- if(vgroup < 0) {
+ if (vgroup < 0) {
/* hair dynamics pinning vgroup */
}
- else if(psys->vgroup[vgroup]) {
+ else if (psys->vgroup[vgroup]) {
MDeformVert *dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT);
- if(dvert) {
+ if (dvert) {
int totvert=dm->getNumVerts(dm), i;
vg=MEM_callocN(sizeof(float)*totvert, "vg_cache");
- if(psys->vg_neg&(1<<vgroup)) {
- for(i=0; i<totvert; i++)
+ if (psys->vg_neg&(1<<vgroup)) {
+ for (i=0; i<totvert; i++)
vg[i]= 1.0f - defvert_find_weight(&dvert[i], psys->vgroup[vgroup] - 1);
}
- else{
- for(i=0; i<totvert; i++)
+ else {
+ for (i=0; i<totvert; i++)
vg[i]= defvert_find_weight(&dvert[i], psys->vgroup[vgroup] - 1);
}
}
@@ -2350,19 +2352,19 @@ void psys_find_parents(ParticleSimulationData *sim)
int from=PART_FROM_FACE;
totparent=(int)(totchild*part->parents*0.3f);
- if(G.rendering && part->child_nbr && part->ren_child_nbr)
+ if (G.rendering && part->child_nbr && part->ren_child_nbr)
totparent*=(float)part->child_nbr/(float)part->ren_child_nbr;
tree=BLI_kdtree_new(totparent);
- for(p=0,cpa=sim->psys->child; p<totparent; p++,cpa++) {
+ for (p=0,cpa=sim->psys->child; p<totparent; p++,cpa++) {
psys_particle_on_emitter(sim->psmd,from,cpa->num,DMCACHE_ISCHILD,cpa->fuv,cpa->foffset,co,0,0,0,orco,0);
BLI_kdtree_insert(tree, p, orco, NULL);
}
BLI_kdtree_balance(tree);
- for(; p<totchild; p++,cpa++) {
+ for (; p<totchild; p++,cpa++) {
psys_particle_on_emitter(sim->psmd,from,cpa->num,DMCACHE_ISCHILD,cpa->fuv,cpa->foffset,co,0,0,0,orco,0);
cpa->parent=BLI_kdtree_find_nearest(tree, orco, NULL, NULL);
}
@@ -2374,10 +2376,10 @@ static void get_strand_normal(Material *ma, const float surfnor[3], float surfdi
{
float cross[3], nstrand[3], vnor[3], blend;
- if(!((ma->mode & MA_STR_SURFDIFF) || (ma->strand_surfnor > 0.0f)))
+ if (!((ma->mode & MA_STR_SURFDIFF) || (ma->strand_surfnor > 0.0f)))
return;
- if(ma->mode & MA_STR_SURFDIFF) {
+ if (ma->mode & MA_STR_SURFDIFF) {
cross_v3_v3v3(cross, surfnor, nor);
cross_v3_v3v3(nstrand, nor, cross);
@@ -2391,8 +2393,8 @@ static void get_strand_normal(Material *ma, const float surfnor[3], float surfdi
copy_v3_v3(vnor, nor);
}
- if(ma->strand_surfnor > 0.0f) {
- if(ma->strand_surfnor > surfdist) {
+ if (ma->strand_surfnor > 0.0f) {
+ if (ma->strand_surfnor > surfdist) {
blend= (ma->strand_surfnor - surfdist)/ma->strand_surfnor;
interp_v3_v3v3(vnor, vnor, surfnor, blend);
normalize_v3(vnor);
@@ -2415,41 +2417,41 @@ static int psys_threads_init_path(ParticleThread *threads, Scene *scene, float c
int i, seed, totthread= threads[0].tot;
/*---start figuring out what is actually wanted---*/
- if(psys_in_edit_mode(scene, psys)) {
+ if (psys_in_edit_mode(scene, psys)) {
ParticleEditSettings *pset = &scene->toolsettings->particle;
- if(psys->renderdata==0 && (psys->edit==NULL || pset->flag & PE_DRAW_PART)==0)
+ if (psys->renderdata==0 && (psys->edit==NULL || pset->flag & PE_DRAW_PART)==0)
totchild=0;
steps = (int)pow(2.0, (double)pset->draw_step);
}
- if(totchild && part->childtype==PART_CHILD_FACES) {
+ if (totchild && part->childtype==PART_CHILD_FACES) {
totparent=(int)(totchild*part->parents*0.3f);
- if(G.rendering && part->child_nbr && part->ren_child_nbr)
+ if (G.rendering && part->child_nbr && part->ren_child_nbr)
totparent*=(float)part->child_nbr/(float)part->ren_child_nbr;
/* part->parents could still be 0 so we can't test with totparent */
between=1;
}
- if(psys->renderdata)
+ if (psys->renderdata)
steps=(int)pow(2.0,(double)part->ren_step);
- else{
+ else {
totchild=(int)((float)totchild*(float)part->disp/100.0f);
totparent=MIN2(totparent,totchild);
}
- if(totchild==0) return 0;
+ if (totchild==0) return 0;
/* init random number generator */
seed= 31415926 + ctx->sim.psys->seed;
- if(ctx->editupdate || totchild < 10000)
+ if (ctx->editupdate || totchild < 10000)
totthread= 1;
- for(i=0; i<totthread; i++) {
+ for (i=0; i<totthread; i++) {
threads[i].rng_path= rng_new(seed);
threads[i].tot= totthread;
}
@@ -2472,12 +2474,12 @@ static int psys_threads_init_path(ParticleThread *threads, Scene *scene, float c
ctx->vg_rough1 = psys_cache_vgroup(ctx->dm,psys,PSYS_VG_ROUGH1);
ctx->vg_rough2 = psys_cache_vgroup(ctx->dm,psys,PSYS_VG_ROUGH2);
ctx->vg_roughe = psys_cache_vgroup(ctx->dm,psys,PSYS_VG_ROUGHE);
- if(psys->part->flag & PART_CHILD_EFFECT)
+ if (psys->part->flag & PART_CHILD_EFFECT)
ctx->vg_effector = psys_cache_vgroup(ctx->dm,psys,PSYS_VG_EFFECTOR);
/* set correct ipo timing */
#if 0 // XXX old animation system
- if(part->flag&PART_ABS_TIME && part->ipo) {
+ if (part->flag&PART_ABS_TIME && part->ipo) {
calc_ipo(part->ipo, cfra);
execute_ipo((ID *)part, part->ipo);
}
@@ -2504,10 +2506,10 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle
int k, cpa_num;
short cpa_from;
- if(!pcache)
+ if (!pcache)
return;
- if(ctx->between) {
+ if (ctx->between) {
ParticleData *pa = psys->particles + cpa->pa[0];
int w, needupdate;
float foffset, wsum=0.f;
@@ -2517,26 +2519,26 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle
/* Virtual parents don't work nicely with parting. */
float p_fac = part->parents > 0.f ? 0.f : part->parting_fac;
- if(ctx->editupdate) {
+ if (ctx->editupdate) {
needupdate= 0;
w= 0;
- while(w<4 && cpa->pa[w]>=0) {
- if(psys->edit->points[cpa->pa[w]].flag & PEP_EDIT_RECALC) {
+ while (w<4 && cpa->pa[w]>=0) {
+ if (psys->edit->points[cpa->pa[w]].flag & PEP_EDIT_RECALC) {
needupdate= 1;
break;
}
w++;
}
- if(!needupdate)
+ if (!needupdate)
return;
else
memset(child_keys, 0, sizeof(*child_keys)*(ctx->steps+1));
}
/* get parent paths */
- for(w=0; w<4; w++) {
- if(cpa->pa[w] >= 0) {
+ for (w=0; w<4; w++) {
+ if (cpa->pa[w] >= 0) {
key[w] = pcache[cpa->pa[w]];
weight[w] = cpa->w[w];
}
@@ -2547,11 +2549,11 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle
}
/* modify weights to create parting */
- if(p_fac > 0.f) {
- for(w=0; w<4; w++) {
- if(w && weight[w] > 0.f) {
+ if (p_fac > 0.f) {
+ for (w=0; w<4; w++) {
+ if (w && weight[w] > 0.f) {
float d;
- if(part->flag & PART_CHILD_LONG_HAIR) {
+ if (part->flag & PART_CHILD_LONG_HAIR) {
/* For long hair use tip distance/root distance as parting factor instead of root to tip angle. */
float d1 = len_v3v3(key[0]->co, key[w]->co);
float d2 = len_v3v3((key[0]+key[0]->steps-1)->co, (key[w]+key[w]->steps-1)->co);
@@ -2568,19 +2570,19 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle
d = RAD2DEGF(saacos(dot_v3v3(v1, v2)));
}
- if(p_max > p_min)
+ if (p_max > p_min)
d = (d - p_min)/(p_max - p_min);
else
d = (d - p_min) <= 0.f ? 0.f : 1.f;
CLAMP(d, 0.f, 1.f);
- if(d > 0.f)
+ if (d > 0.f)
weight[w] *= (1.f - d);
}
wsum += weight[w];
}
- for(w=0; w<4; w++)
+ for (w=0; w<4; w++)
weight[w] /= wsum;
interp_v4_v4v4(weight, cpa->w, weight, p_fac);
@@ -2597,16 +2599,16 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle
mul_m4_v3(ob->obmat, co);
- for(w=0; w<4; w++)
+ for (w=0; w<4; w++)
sub_v3_v3v3(off1[w], co, key[w]->co);
psys_mat_hair_to_global(ob, ctx->sim.psmd->dm, psys->part->from, pa, hairmat);
}
- else{
+ else {
ParticleData *pa = psys->particles + cpa->parent;
float co[3];
- if(ctx->editupdate) {
- if(!(psys->edit->points[cpa->parent].flag & PEP_EDIT_RECALC))
+ if (ctx->editupdate) {
+ if (!(psys->edit->points[cpa->parent].flag & PEP_EDIT_RECALC))
return;
memset(child_keys, 0, sizeof(*child_keys)*(ctx->steps+1));
@@ -2630,26 +2632,26 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle
/* get different child parameters from textures & vgroups */
get_child_modifier_parameters(part, ctx, cpa, cpa_from, cpa_num, cpa_fuv, orco, &ptex);
- if(ptex.exist < PSYS_FRAND(i + 24)) {
+ if (ptex.exist < PSYS_FRAND(i + 24)) {
child_keys->steps = -1;
return;
}
/* create the child path */
- for(k=0,child=child_keys; k<=ctx->steps; k++,child++) {
- if(ctx->between) {
+ for (k=0,child=child_keys; k<=ctx->steps; k++,child++) {
+ if (ctx->between) {
int w=0;
zero_v3(child->co);
zero_v3(child->vel);
unit_qt(child->rot);
- for(w=0; w<4; w++) {
+ for (w=0; w<4; w++) {
copy_v3_v3(off2[w], off1[w]);
- if(part->flag & PART_CHILD_LONG_HAIR) {
+ if (part->flag & PART_CHILD_LONG_HAIR) {
/* Use parent rotation (in addition to emission location) to determine child offset. */
- if(k)
+ if (k)
mul_qt_v3((key[w]+k)->rot, off2[w]);
/* Fade the effect of rotation for even lengths in the end */
@@ -2666,8 +2668,8 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle
copy_qt_qt(child->rot, (key[0]+k)->rot);
}
- else{
- if(k) {
+ else {
+ if (k) {
mul_qt_qtqt(rot, (key[0]+k)->rot, key[0]->rot);
par_rot = rot;
}
@@ -2682,9 +2684,9 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle
}
/* apply effectors */
- if(part->flag & PART_CHILD_EFFECT) {
- for(k=0,child=child_keys; k<=ctx->steps; k++,child++) {
- if(k) {
+ if (part->flag & PART_CHILD_EFFECT) {
+ for (k=0,child=child_keys; k<=ctx->steps; k++,child++) {
+ if (k) {
do_path_effectors(&ctx->sim, cpa->pa[0], child, k, ctx->steps, child_keys->co, ptex.effector, 0.0f, ctx->cfra, &eff_length, eff_vec);
}
else {
@@ -2694,17 +2696,17 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle
}
}
- for(k=0,child=child_keys; k<=ctx->steps; k++,child++) {
+ for (k=0,child=child_keys; k<=ctx->steps; k++,child++) {
t = (float)k/(float)ctx->steps;
- if(ctx->totparent)
+ if (ctx->totparent)
/* this is now threadsafe, virtual parents are calculated before rest of children */
par = (i >= ctx->totparent) ? cache[cpa->parent] : NULL;
- else if(cpa->parent >= 0)
+ else if (cpa->parent >= 0)
par = pcache[cpa->parent];
- if(par) {
- if(k) {
+ if (par) {
+ if (k) {
mul_qt_qtqt(rot, (par+k)->rot, par->rot);
par_rot = rot;
}
@@ -2718,37 +2720,37 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle
do_child_modifiers(&ctx->sim, &ptex, (ParticleKey *)par, par_rot, cpa, orco, hairmat, (ParticleKey *)child, t);
/* we have to correct velocity because of kink & clump */
- if(k>1) {
+ if (k>1) {
sub_v3_v3v3((child-1)->vel, child->co, (child-2)->co);
mul_v3_fl((child-1)->vel, 0.5);
- if(ctx->ma && (part->draw_col == PART_DRAW_COL_MAT))
+ if (ctx->ma && (part->draw_col == PART_DRAW_COL_MAT))
get_strand_normal(ctx->ma, ornor, cur_length, (child-1)->vel);
}
- if(k == ctx->steps)
+ if (k == ctx->steps)
sub_v3_v3v3(child->vel, child->co, (child-1)->co);
/* check if path needs to be cut before actual end of data points */
- if(k) {
+ if (k) {
sub_v3_v3v3(dvec, child->co, (child-1)->co);
length = 1.0f/(float)ctx->steps;
k = check_path_length(k, child_keys, child, max_length, &cur_length, length, dvec);
}
- else{
+ else {
/* initialize length calculation */
max_length = ptex.length;
cur_length = 0.0f;
}
- if(ctx->ma && (part->draw_col == PART_DRAW_COL_MAT)) {
+ if (ctx->ma && (part->draw_col == PART_DRAW_COL_MAT)) {
copy_v3_v3(child->col, &ctx->ma->r);
get_strand_normal(ctx->ma, ornor, cur_length, child->vel);
}
}
/* Hide virtual parents */
- if(i < ctx->totparent)
+ if (i < ctx->totparent)
child_keys->steps = -1;
}
@@ -2761,13 +2763,13 @@ static void *exec_child_path_cache(void *data)
ChildParticle *cpa;
int i, totchild= ctx->totchild, first= 0;
- if(thread->tot > 1) {
+ if (thread->tot > 1) {
first= ctx->parent_pass? 0 : ctx->totparent;
totchild= ctx->parent_pass? ctx->totparent : ctx->totchild;
}
cpa= psys->child + first + thread->num;
- for(i=first+thread->num; i<totchild; i+=thread->tot, cpa+=thread->tot)
+ for (i=first+thread->num; i<totchild; i+=thread->tot, cpa+=thread->tot)
psys_thread_create_path(thread, cpa, cache[i], i);
return 0;
@@ -2780,12 +2782,12 @@ void psys_cache_child_paths(ParticleSimulationData *sim, float cfra, int editupd
ListBase threads;
int i, totchild, totparent, totthread;
- if(sim->psys->flag & PSYS_GLOBAL_HAIR)
+ if (sim->psys->flag & PSYS_GLOBAL_HAIR)
return;
pthreads= psys_threads_create(sim);
- if(!psys_threads_init_path(pthreads, sim->scene, cfra, editupdate)) {
+ if (!psys_threads_init_path(pthreads, sim->scene, cfra, editupdate)) {
psys_threads_free(pthreads);
return;
}
@@ -2794,7 +2796,7 @@ void psys_cache_child_paths(ParticleSimulationData *sim, float cfra, int editupd
totchild= ctx->totchild;
totparent= ctx->totparent;
- if(editupdate && sim->psys->childcache && totchild == sim->psys->totchildcache) {
+ if (editupdate && sim->psys->childcache && totchild == sim->psys->totchildcache) {
; /* just overwrite the existing cache */
}
else {
@@ -2806,26 +2808,26 @@ void psys_cache_child_paths(ParticleSimulationData *sim, float cfra, int editupd
totthread= pthreads[0].tot;
- if(totthread > 1) {
+ if (totthread > 1) {
/* make virtual child parents thread safe by calculating them first */
- if(totparent) {
+ if (totparent) {
BLI_init_threads(&threads, exec_child_path_cache, totthread);
- for(i=0; i<totthread; i++) {
+ for (i=0; i<totthread; i++) {
pthreads[i].ctx->parent_pass = 1;
BLI_insert_thread(&threads, &pthreads[i]);
}
BLI_end_threads(&threads);
- for(i=0; i<totthread; i++)
+ for (i=0; i<totthread; i++)
pthreads[i].ctx->parent_pass = 0;
}
BLI_init_threads(&threads, exec_child_path_cache, totthread);
- for(i=0; i<totthread; i++)
+ for (i=0; i<totthread; i++)
BLI_insert_thread(&threads, &pthreads[i]);
BLI_end_threads(&threads);
@@ -2859,7 +2861,7 @@ static void cache_key_incremental_rotation(ParticleCacheKey *key0, ParticleCache
/* note we do the comparison on cosangle instead of
* angle, since floating point accuracy makes it give
* different results across platforms */
- if(cosangle > 0.999999f) {
+ if (cosangle > 0.999999f) {
copy_v4_v4(key1->rot, key2->rot);
}
else {
@@ -2910,11 +2912,11 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra)
int keyed, baked;
/* we don't have anything valid to create paths from so let's quit here */
- if((psys->flag & PSYS_HAIR_DONE || psys->flag & PSYS_KEYED || psys->pointcache)==0)
+ if ((psys->flag & PSYS_HAIR_DONE || psys->flag & PSYS_KEYED || psys->pointcache)==0)
return;
- if(psys_in_edit_mode(sim->scene, psys))
- if(psys->renderdata==0 && (psys->edit==NULL || pset->flag & PE_DRAW_PART)==0)
+ if (psys_in_edit_mode(sim->scene, psys))
+ if (psys->renderdata==0 && (psys->edit==NULL || pset->flag & PE_DRAW_PART)==0)
return;
keyed = psys->flag & PSYS_KEYED;
@@ -2926,14 +2928,14 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra)
psys->lattice = psys_get_lattice(sim);
ma= give_current_material(sim->ob, psys->part->omat);
- if(ma && (psys->part->draw_col == PART_DRAW_COL_MAT))
+ if (ma && (psys->part->draw_col == PART_DRAW_COL_MAT))
copy_v3_v3(col, &ma->r);
- if((psys->flag & PSYS_GLOBAL_HAIR)==0) {
- if((psys->part->flag & PART_CHILD_EFFECT)==0)
+ if ((psys->flag & PSYS_GLOBAL_HAIR)==0) {
+ if ((psys->part->flag & PART_CHILD_EFFECT)==0)
vg_effector = psys_cache_vgroup(psmd->dm, psys, PSYS_VG_EFFECTOR);
- if(!psys->totchild)
+ if (!psys->totchild)
vg_length = psys_cache_vgroup(psmd->dm, psys, PSYS_VG_LENGTH);
}
@@ -2944,10 +2946,10 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra)
/*---first main loop: create all actual particles' paths---*/
LOOP_SHOWN_PARTICLES {
- if(!psys->totchild) {
+ if (!psys->totchild) {
psys_get_texture(sim, pa, &ptex, PAMAP_LENGTH, 0.f);
pa_length = ptex.length * (1.0f - part->randlength * PSYS_FRAND(psys->seed + p));
- if(vg_length)
+ if (vg_length)
pa_length *= psys_particle_value_from_verts(psmd->dm,part->from,pa,vg_length);
}
@@ -2970,7 +2972,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra)
copy_v3_v3(rotmat[1], hairmat[1]);
copy_v3_v3(rotmat[2], hairmat[0]);
- if(part->draw & PART_ABS_PATH_TIME) {
+ if (part->draw & PART_ABS_PATH_TIME) {
birthtime = MAX2(pind.birthtime, part->path_start);
dietime = MIN2(pind.dietime, part->path_end);
}
@@ -2980,7 +2982,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra)
dietime = tb + part->path_end * (pind.dietime - tb);
}
- if(birthtime >= dietime) {
+ if (birthtime >= dietime) {
cache[p]->steps = -1;
continue;
}
@@ -2988,7 +2990,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra)
dietime = birthtime + pa_length * (dietime - birthtime);
/*--interpolate actual path from data points--*/
- for(k=0, ca=cache[p]; k<=steps; k++, ca++) {
+ for (k=0, ca=cache[p]; k<=steps; k++, ca++) {
time = (float)k / (float)steps;
t = birthtime + time * (dietime - birthtime);
result.time = -t;
@@ -2997,9 +2999,9 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra)
/* dynamic hair is in object space */
/* keyed and baked are already in global space */
- if(hair_dm)
+ if (hair_dm)
mul_m4_v3(sim->ob->obmat, ca->co);
- else if(!keyed && !baked && !(psys->flag & PSYS_GLOBAL_HAIR))
+ else if (!keyed && !baked && !(psys->flag & PSYS_GLOBAL_HAIR))
mul_m4_v3(hairmat, ca->co);
copy_v3_v3(ca->col, col);
@@ -3007,45 +3009,45 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra)
/*--modify paths and calculate rotation & velocity--*/
- if(!(psys->flag & PSYS_GLOBAL_HAIR)) {
+ if (!(psys->flag & PSYS_GLOBAL_HAIR)) {
/* apply effectors */
- if((psys->part->flag & PART_CHILD_EFFECT) == 0) {
+ if ((psys->part->flag & PART_CHILD_EFFECT) == 0) {
float effector= 1.0f;
- if(vg_effector)
+ if (vg_effector)
effector*= psys_particle_value_from_verts(psmd->dm,psys->part->from,pa,vg_effector);
sub_v3_v3v3(vec,(cache[p]+1)->co,cache[p]->co);
length = len_v3(vec);
- for(k=1, ca=cache[p]+1; k<=steps; k++, ca++)
+ for (k=1, ca=cache[p]+1; k<=steps; k++, ca++)
do_path_effectors(sim, p, ca, k, steps, cache[p]->co, effector, dfra, cfra, &length, vec);
}
/* apply guide curves to path data */
- if(sim->psys->effectors && (psys->part->flag & PART_CHILD_EFFECT)==0) {
- for(k=0, ca=cache[p]; k<=steps; k++, ca++)
+ if (sim->psys->effectors && (psys->part->flag & PART_CHILD_EFFECT)==0) {
+ for (k=0, ca=cache[p]; k<=steps; k++, ca++)
/* ca is safe to cast, since only co and vel are used */
do_guides(sim->psys->effectors, (ParticleKey*)ca, p, (float)k/(float)steps);
}
/* lattices have to be calculated separately to avoid mixups between effector calculations */
- if(psys->lattice) {
- for(k=0, ca=cache[p]; k<=steps; k++, ca++)
+ if (psys->lattice) {
+ for (k=0, ca=cache[p]; k<=steps; k++, ca++)
calc_latt_deform(psys->lattice, ca->co, 1.0f);
}
}
/* finally do rotation & velocity */
- for(k=1, ca=cache[p]+1; k<=steps; k++, ca++) {
+ for (k=1, ca=cache[p]+1; k<=steps; k++, ca++) {
cache_key_incremental_rotation(ca, ca - 1, ca - 2, prev_tangent, k);
- if(k == steps)
+ if (k == steps)
copy_qt_qt(ca->rot, (ca - 1)->rot);
/* set velocity */
sub_v3_v3v3(ca->vel, ca->co, (ca-1)->co);
- if(k==1)
+ if (k==1)
copy_v3_v3((ca-1)->vel, ca->vel);
ca->time = (float)k/(float)steps;
@@ -3062,15 +3064,15 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra)
psys->totcached = totpart;
- if(psys->lattice) {
+ if (psys->lattice) {
end_latt_deform(psys->lattice);
psys->lattice= NULL;
}
- if(vg_effector)
+ if (vg_effector)
MEM_freeN(vg_effector);
- if(vg_length)
+ if (vg_length)
MEM_freeN(vg_length);
}
void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cfra)
@@ -3099,23 +3101,23 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf
steps = MAX2(steps, 4);
- if(!cache || edit->totpoint != edit->totcached) {
+ if (!cache || edit->totpoint != edit->totcached) {
/* clear out old and create new empty path cache */
psys_free_path_cache(edit->psys, edit);
cache= edit->pathcache= psys_alloc_path_cache_buffers(&edit->pathcachebufs, totpart, steps+1);
/* set flag for update (child particles check this too) */
- for(i=0, point=edit->points; i<totpart; i++, point++)
+ for (i=0, point=edit->points; i<totpart; i++, point++)
point->flag |= PEP_EDIT_RECALC;
recalc_set = 1;
}
/* frs_sec = (psys || edit->pid.flag & PTCACHE_VEL_PER_SEC) ? 25.0f : 1.0f; */ /* UNUSED */
- if(pset->brushtype == PE_BRUSH_WEIGHT) {
+ if (pset->brushtype == PE_BRUSH_WEIGHT) {
;/* use weight painting colors now... */
}
- else{
+ else {
sel_col[0] = (float)edit->sel_col[0] / 255.0f;
sel_col[1] = (float)edit->sel_col[1] / 255.0f;
sel_col[2] = (float)edit->sel_col[2] / 255.0f;
@@ -3125,11 +3127,11 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf
}
/*---first main loop: create all actual particles' paths---*/
- for(i=0, point=edit->points; i<totpart; i++, pa+=pa?1:0, point++) {
- if(edit->totcached && !(point->flag & PEP_EDIT_RECALC))
+ for (i=0, point=edit->points; i<totpart; i++, pa+=pa?1:0, point++) {
+ if (edit->totcached && !(point->flag & PEP_EDIT_RECALC))
continue;
- if(point->totkey == 0)
+ if (point->totkey == 0)
continue;
ekey = point->keys;
@@ -3142,7 +3144,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf
/* should init_particle_interpolation set this ? */
- if(pset->brushtype==PE_BRUSH_WEIGHT) {
+ if (pset->brushtype==PE_BRUSH_WEIGHT) {
pind.hkey[0] = NULL;
/* pa != NULL since the weight brush is only available for hair */
pind.hkey[1] = pa->hair;
@@ -3156,7 +3158,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf
/*--get the first data points--*/
init_particle_interpolation(ob, psys, pa, &pind);
- if(psys) {
+ if (psys) {
psys_mat_hair_to_global(ob, psmd->dm, psys->part->from, pa, hairmat);
copy_v3_v3(rotmat[0], hairmat[2]);
copy_v3_v3(rotmat[1], hairmat[1]);
@@ -3166,13 +3168,13 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf
birthtime = pind.birthtime;
dietime = pind.dietime;
- if(birthtime >= dietime) {
+ if (birthtime >= dietime) {
cache[i]->steps = -1;
continue;
}
/*--interpolate actual path from data points--*/
- for(k=0, ca=cache[i]; k<=steps; k++, ca++) {
+ for (k=0, ca=cache[i]; k<=steps; k++, ca++) {
time = (float)k / (float)steps;
t = birthtime + time * (dietime - birthtime);
result.time = -t;
@@ -3180,19 +3182,19 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf
copy_v3_v3(ca->co, result.co);
/* non-hair points are already in global space */
- if(psys && !(psys->flag & PSYS_GLOBAL_HAIR)) {
+ if (psys && !(psys->flag & PSYS_GLOBAL_HAIR)) {
mul_m4_v3(hairmat, ca->co);
- if(k) {
+ if (k) {
cache_key_incremental_rotation(ca, ca - 1, ca - 2, prev_tangent, k);
- if(k == steps)
+ if (k == steps)
copy_qt_qt(ca->rot, (ca - 1)->rot);
/* set velocity */
sub_v3_v3v3(ca->vel, ca->co, (ca - 1)->co);
- if(k==1)
+ if (k==1)
copy_v3_v3((ca - 1)->vel, ca->vel);
}
}
@@ -3202,12 +3204,13 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf
}
/* selection coloring in edit mode */
- if(pset->brushtype==PE_BRUSH_WEIGHT) {
+ if (pset->brushtype==PE_BRUSH_WEIGHT) {
float t2;
- if(k==0) {
+ if (k==0) {
weight_to_rgb(ca->col, pind.hkey[1]->weight);
- } else {
+ }
+ else {
float w1[3], w2[3];
keytime = (t - (*pind.ekey[0]->time))/((*pind.ekey[1]->time) - (*pind.ekey[0]->time));
@@ -3225,21 +3228,21 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf
pind.hkey[0] = pind.hkey[1] - 1;
}
else {
- if((ekey + (pind.ekey[0] - point->keys))->flag & PEK_SELECT) {
- if((ekey + (pind.ekey[1] - point->keys))->flag & PEK_SELECT) {
+ if ((ekey + (pind.ekey[0] - point->keys))->flag & PEK_SELECT) {
+ if ((ekey + (pind.ekey[1] - point->keys))->flag & PEK_SELECT) {
copy_v3_v3(ca->col, sel_col);
}
- else{
+ else {
keytime = (t - (*pind.ekey[0]->time))/((*pind.ekey[1]->time) - (*pind.ekey[0]->time));
interp_v3_v3v3(ca->col, sel_col, nosel_col, keytime);
}
}
- else{
- if((ekey + (pind.ekey[1] - point->keys))->flag & PEK_SELECT) {
+ else {
+ if ((ekey + (pind.ekey[1] - point->keys))->flag & PEK_SELECT) {
keytime = (t - (*pind.ekey[0]->time))/((*pind.ekey[1]->time) - (*pind.ekey[0]->time));
interp_v3_v3v3(ca->col, nosel_col, sel_col, keytime);
}
- else{
+ else {
copy_v3_v3(ca->col, nosel_col);
}
}
@@ -3247,7 +3250,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf
ca->time = t;
}
- if(psys && !(psys->flag & PSYS_GLOBAL_HAIR)) {
+ if (psys && !(psys->flag & PSYS_GLOBAL_HAIR)) {
/* First rotation is based on emitting face orientation.
* This is way better than having flipping rotations resulting
* from using a global axis as a rotation pole (vec_to_quat()).
@@ -3261,7 +3264,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf
edit->totcached = totpart;
- if(psys) {
+ if (psys) {
ParticleSimulationData sim= {0};
sim.scene= scene;
sim.ob= ob;
@@ -3272,8 +3275,8 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf
}
/* clear recalc flag if set here */
- if(recalc_set) {
- for(i=0, point=edit->points; i<totpart; i++, point++)
+ if (recalc_set) {
+ for (i=0, point=edit->points; i<totpart; i++, point++)
point->flag &= ~PEP_EDIT_RECALC;
}
}
@@ -3282,10 +3285,10 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf
/************************************************/
void copy_particle_key(ParticleKey *to, ParticleKey *from, int time)
{
- if(time) {
+ if (time) {
memcpy(to,from,sizeof(ParticleKey));
}
- else{
+ else {
float to_time=to->time;
memcpy(to,from,sizeof(ParticleKey));
to->time=to_time;
@@ -3293,10 +3296,10 @@ void copy_particle_key(ParticleKey *to, ParticleKey *from, int time)
}
void psys_get_from_key(ParticleKey *key, float *loc, float *vel, float *rot, float *time)
{
- if(loc) copy_v3_v3(loc,key->co);
- if(vel) copy_v3_v3(vel,key->vel);
- if(rot) copy_qt_qt(rot,key->rot);
- if(time) *time=key->time;
+ if (loc) copy_v3_v3(loc,key->co);
+ if (vel) copy_v3_v3(vel,key->vel);
+ if (rot) copy_qt_qt(rot,key->rot);
+ if (time) *time=key->time;
}
/*-------changing particle keys from space to another-------*/
#if 0
@@ -3326,7 +3329,7 @@ static void triatomat(float *v1, float *v2, float *v3, float (*uv)[2], float mat
normal_tri_v3( mat[2],v1, v2, v3);
/* second axis along (1, 0) in uv space */
- if(uv) {
+ if (uv) {
d1[0]= uv[1][0] - uv[0][0];
d1[1]= uv[1][1] - uv[0][1];
d2[0]= uv[2][0] - uv[0][0];
@@ -3334,7 +3337,7 @@ static void triatomat(float *v1, float *v2, float *v3, float (*uv)[2], float mat
det = d2[0]*d1[1] - d2[1]*d1[0];
- if(det != 0.0f) {
+ if (det != 0.0f) {
det= 1.0f/det;
w1= -d2[1]*det;
w2= d1[1]*det;
@@ -3370,14 +3373,14 @@ static void psys_face_mat(Object *ob, DerivedMesh *dm, ParticleData *pa, float m
mface=dm->getTessFaceData(dm,i,CD_MFACE);
osface=dm->getTessFaceData(dm,i,CD_ORIGSPACE);
- if(orco && (orcodata=dm->getVertDataArray(dm, CD_ORCO))) {
+ if (orco && (orcodata=dm->getVertDataArray(dm, CD_ORCO))) {
copy_v3_v3(v[0], orcodata[mface->v1]);
copy_v3_v3(v[1], orcodata[mface->v2]);
copy_v3_v3(v[2], orcodata[mface->v3]);
/* ugly hack to use non-transformed orcos, since only those
* give symmetric results for mirroring in particle mode */
- if(DM_get_vert_data_layer(dm, CD_ORIGINDEX))
+ if (DM_get_vert_data_layer(dm, CD_ORIGINDEX))
transform_mesh_orco_verts(ob->data, v, 3, 1);
}
else {
@@ -3406,7 +3409,7 @@ void psys_mat_hair_to_orco(Object *ob, DerivedMesh *dm, short from, ParticleData
psys_particle_on_dm(dm, from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, vec, 0, 0, 0, orco, 0);
/* see psys_face_mat for why this function is called */
- if(DM_get_vert_data_layer(dm, CD_ORIGINDEX))
+ if (DM_get_vert_data_layer(dm, CD_ORIGINDEX))
transform_mesh_orco_verts(ob->data, &orco, 1, 1);
copy_v3_v3(hairmat[3],orco);
}
@@ -3438,11 +3441,11 @@ ModifierData *object_add_particle_system(Scene *scene, Object *ob, const char *n
ModifierData *md;
ParticleSystemModifierData *psmd;
- if(!ob || ob->type != OB_MESH)
+ if (!ob || ob->type != OB_MESH)
return NULL;
psys = ob->particlesystem.first;
- for(; psys; psys=psys->next)
+ for (; psys; psys=psys->next)
psys->flag &= ~PSYS_CURRENT;
psys = MEM_callocN(sizeof(ParticleSystem), "particle_system");
@@ -3451,14 +3454,14 @@ ModifierData *object_add_particle_system(Scene *scene, Object *ob, const char *n
psys->part = psys_new_settings("ParticleSettings", NULL);
- if(BLI_countlist(&ob->particlesystem)>1)
+ if (BLI_countlist(&ob->particlesystem)>1)
BLI_snprintf(psys->name, sizeof(psys->name), "ParticleSystem %i", BLI_countlist(&ob->particlesystem));
else
strcpy(psys->name, "ParticleSystem");
md= modifier_new(eModifierType_ParticleSystem);
- if(name) BLI_strncpy(md->name, name, sizeof(md->name));
+ if (name) BLI_strncpy(md->name, name, sizeof(md->name));
else BLI_snprintf(md->name, sizeof(md->name), "ParticleSystem %i", BLI_countlist(&ob->particlesystem));
modifier_unique_name(&ob->modifiers, md);
@@ -3481,21 +3484,21 @@ void object_remove_particle_system(Scene *scene, Object *ob)
ParticleSystemModifierData *psmd;
ModifierData *md;
- if(!psys)
+ if (!psys)
return;
/* clear all other appearances of this pointer (like on smoke flow modifier) */
if ((md = modifiers_findByType(ob, eModifierType_Smoke))) {
SmokeModifierData *smd = (SmokeModifierData *)md;
- if((smd->type == MOD_SMOKE_TYPE_FLOW) && smd->flow && smd->flow->psys)
- if(smd->flow->psys == psys)
+ if ((smd->type == MOD_SMOKE_TYPE_FLOW) && smd->flow && smd->flow->psys)
+ if (smd->flow->psys == psys)
smd->flow->psys = NULL;
}
if ((md = modifiers_findByType(ob, eModifierType_DynamicPaint))) {
DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
- if(pmd->brush && pmd->brush->psys)
- if(pmd->brush->psys == psys)
+ if (pmd->brush && pmd->brush->psys)
+ if (pmd->brush->psys == psys)
pmd->brush->psys = NULL;
}
@@ -3508,7 +3511,7 @@ void object_remove_particle_system(Scene *scene, Object *ob)
BLI_remlink(&ob->particlesystem, psys);
psys_free(ob,psys);
- if(ob->particlesystem.first)
+ if (ob->particlesystem.first)
((ParticleSystem *) ob->particlesystem.first)->flag |= PSYS_CURRENT;
else
ob->mode &= ~OB_MODE_PARTICLE_EDIT;
@@ -3591,7 +3594,7 @@ static void default_particle_settings(ParticleSettings *part)
part->simplify_transition= 0.1f;
part->simplify_viewport= 0.8;
- if(!part->effector_weights)
+ if (!part->effector_weights)
part->effector_weights = BKE_add_effector_weights(NULL);
}
@@ -3600,7 +3603,7 @@ ParticleSettings *psys_new_settings(const char *name, Main *main)
{
ParticleSettings *part;
- if(main==NULL)
+ if (main==NULL)
main = G.main;
part= alloc_libblock(&main->particle, ID_PA, name);
@@ -3623,8 +3626,8 @@ ParticleSettings *psys_copy_settings(ParticleSettings *part)
partn->boids = boid_copy_settings(part->boids);
- for(a=0; a<MAX_MTEX; a++) {
- if(part->mtex[a]) {
+ for (a=0; a<MAX_MTEX; a++) {
+ if (part->mtex[a]) {
partn->mtex[a]= MEM_mallocN(sizeof(MTex), "psys_copy_tex");
memcpy(partn->mtex[a], part->mtex[a], sizeof(MTex));
id_us_plus((ID *)partn->mtex[a]->tex);
@@ -3641,8 +3644,8 @@ static void expand_local_particlesettings(ParticleSettings *part)
int i;
id_lib_extern((ID *)part->dup_group);
- for(i=0; i<MAX_MTEX; i++) {
- if(part->mtex[i]) id_lib_extern((ID *)part->mtex[i]->tex);
+ for (i=0; i<MAX_MTEX; i++) {
+ if (part->mtex[i]) id_lib_extern((ID *)part->mtex[i]->tex);
}
}
@@ -3657,29 +3660,29 @@ void make_local_particlesettings(ParticleSettings *part)
* - mixed: make copy
*/
- if(part->id.lib==0) return;
- if(part->id.us==1) {
+ if (part->id.lib==0) return;
+ if (part->id.us==1) {
id_clear_lib_data(bmain, &part->id);
expand_local_particlesettings(part);
return;
}
/* test objects */
- for(ob= bmain->object.first; ob && ELEM(FALSE, is_lib, is_local); ob= ob->id.next) {
+ for (ob= bmain->object.first; ob && ELEM(FALSE, is_lib, is_local); ob= ob->id.next) {
ParticleSystem *psys=ob->particlesystem.first;
- for(; psys; psys=psys->next) {
- if(psys->part==part) {
- if(ob->id.lib) is_lib= TRUE;
+ for (; psys; psys=psys->next) {
+ if (psys->part==part) {
+ if (ob->id.lib) is_lib= TRUE;
else is_local= TRUE;
}
}
}
- if(is_local && is_lib==FALSE) {
+ if (is_local && is_lib==FALSE) {
id_clear_lib_data(bmain, &part->id);
expand_local_particlesettings(part);
}
- else if(is_local && is_lib) {
+ else if (is_local && is_lib) {
ParticleSettings *part_new= psys_copy_settings(part);
part_new->id.us= 0;
@@ -3687,10 +3690,10 @@ void make_local_particlesettings(ParticleSettings *part)
BKE_id_lib_local_paths(bmain, part->id.lib, &part_new->id);
/* do objects */
- for(ob= bmain->object.first; ob; ob= ob->id.next) {
+ for (ob= bmain->object.first; ob; ob= ob->id.next) {
ParticleSystem *psys;
- for(psys= ob->particlesystem.first; psys; psys=psys->next) {
- if(psys->part==part && ob->id.lib==0) {
+ for (psys= ob->particlesystem.first; psys; psys=psys->next) {
+ if (psys->part==part && ob->id.lib==0) {
psys->part= part_new;
part_new->id.us++;
part->id.us--;
@@ -3712,15 +3715,15 @@ static int get_particle_uv(DerivedMesh *dm, ParticleData *pa, int face_index, co
tf= CustomData_get_layer_named(&dm->faceData, CD_MTFACE, name);
- if(tf == NULL)
+ if (tf == NULL)
tf= CustomData_get_layer(&dm->faceData, CD_MTFACE);
- if(tf == NULL)
+ if (tf == NULL)
return 0;
- if(pa) {
+ if (pa) {
i= (pa->num_dmcache==DMCACHE_NOTFOUND)? pa->num: pa->num_dmcache;
- if(i >= dm->getNumTessFaces(dm))
+ if (i >= dm->getNumTessFaces(dm))
i = -1;
}
else
@@ -3761,14 +3764,14 @@ static void get_cpa_texture(DerivedMesh *dm, ParticleSystem *psys, ParticleSetti
ptex->length= 1.0f - part->randlength * PSYS_FRAND(child_index + 26);
ptex->length*= part->clength_thres < PSYS_FRAND(child_index + 27) ? part->clength : 1.0f;
- for(m=0; m<MAX_MTEX; m++, mtexp++) {
+ for (m=0; m<MAX_MTEX; m++, mtexp++) {
mtex = *mtexp;
- if(mtex && mtex->mapto) {
+ if (mtex && mtex->mapto) {
float def=mtex->def_var;
short blend=mtex->blendtype;
short texco = mtex->texco;
- if(ELEM(texco, TEXCO_UV, TEXCO_ORCO) && (ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME) == 0 || part->distr == PART_DISTR_GRID))
+ if (ELEM(texco, TEXCO_UV, TEXCO_ORCO) && (ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME) == 0 || part->distr == PART_DISTR_GRID))
texco = TEXCO_GLOB;
switch(texco) {
@@ -3777,11 +3780,11 @@ static void get_cpa_texture(DerivedMesh *dm, ParticleSystem *psys, ParticleSetti
break;
case TEXCO_OBJECT:
copy_v3_v3(texvec, par->state.co);
- if(mtex->object)
+ if (mtex->object)
mul_m4_v3(mtex->object->imat, texvec);
break;
case TEXCO_UV:
- if(fw && get_particle_uv(dm, NULL, face_index, fw, mtex->uvname, texvec))
+ if (fw && get_particle_uv(dm, NULL, face_index, fw, mtex->uvname, texvec))
break;
/* no break, failed to get uv's, so let's try orco's */
case TEXCO_ORCO:
@@ -3797,7 +3800,7 @@ static void get_cpa_texture(DerivedMesh *dm, ParticleSystem *psys, ParticleSetti
externtex(mtex, texvec, &value, rgba, rgba+1, rgba+2, rgba+3, 0);
- if((event & mtex->mapto) & PAMAP_ROUGH)
+ if ((event & mtex->mapto) & PAMAP_ROUGH)
ptex->rough1= ptex->rough2= ptex->roughe= texture_value_blend(def,ptex->rough1,value,mtex->roughfac,blend);
SET_PARTICLE_TEXTURE(PAMAP_LENGTH, ptex->length, mtex->lengthfac);
@@ -3829,14 +3832,14 @@ void psys_get_texture(ParticleSimulationData *sim, ParticleData *pa, ParticleTex
ptex->time = (float)(pa - sim->psys->particles)/(float)sim->psys->totpart;
- for(m=0; m<MAX_MTEX; m++, mtexp++) {
+ for (m=0; m<MAX_MTEX; m++, mtexp++) {
mtex = *mtexp;
- if(mtex && mtex->mapto) {
+ if (mtex && mtex->mapto) {
float def=mtex->def_var;
short blend=mtex->blendtype;
short texco = mtex->texco;
- if(texco == TEXCO_UV && (ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME) == 0 || part->distr == PART_DISTR_GRID))
+ if (texco == TEXCO_UV && (ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME) == 0 || part->distr == PART_DISTR_GRID))
texco = TEXCO_GLOB;
switch(texco) {
@@ -3845,11 +3848,11 @@ void psys_get_texture(ParticleSimulationData *sim, ParticleData *pa, ParticleTex
break;
case TEXCO_OBJECT:
copy_v3_v3(texvec, pa->state.co);
- if(mtex->object)
+ if (mtex->object)
mul_m4_v3(mtex->object->imat, texvec);
break;
case TEXCO_UV:
- if(get_particle_uv(sim->psmd->dm, pa, 0, pa->fuv, mtex->uvname, texvec))
+ if (get_particle_uv(sim->psmd->dm, pa, 0, pa->fuv, mtex->uvname, texvec))
break;
/* no break, failed to get uv's, so let's try orco's */
case TEXCO_ORCO:
@@ -3865,9 +3868,9 @@ void psys_get_texture(ParticleSimulationData *sim, ParticleData *pa, ParticleTex
externtex(mtex, texvec, &value, rgba, rgba+1, rgba+2, rgba+3, 0);
- if((event & mtex->mapto) & PAMAP_TIME) {
+ if ((event & mtex->mapto) & PAMAP_TIME) {
/* the first time has to set the base value for time regardless of blend mode */
- if((setvars&MAP_PA_TIME)==0) {
+ if ((setvars&MAP_PA_TIME)==0) {
int flip= (mtex->timefac < 0.0f);
float timefac= fabsf(mtex->timefac);
ptex->time *= 1.0f - timefac;
@@ -3910,26 +3913,26 @@ float psys_get_child_time(ParticleSystem *psys, ChildParticle *cpa, float cfra,
ParticleSettings *part = psys->part;
float time, life;
- if(part->childtype==PART_CHILD_FACES) {
+ if (part->childtype==PART_CHILD_FACES) {
int w=0;
time=0.0;
- while(w<4 && cpa->pa[w]>=0) {
+ while (w<4 && cpa->pa[w]>=0) {
time+=cpa->w[w]*(psys->particles+cpa->pa[w])->time;
w++;
}
life = part->lifetime * (1.0f - part->randlife * PSYS_FRAND(cpa - psys->child + 25));
}
- else{
+ else {
ParticleData *pa = psys->particles + cpa->parent;
time = pa->time;
life = pa->lifetime;
}
- if(birthtime)
+ if (birthtime)
*birthtime = time;
- if(dietime)
+ if (dietime)
*dietime = time+life;
return (cfra-time)/life;
@@ -3939,14 +3942,14 @@ float psys_get_child_size(ParticleSystem *psys, ChildParticle *cpa, float UNUSED
ParticleSettings *part = psys->part;
float size; // time XXX
- if(part->childtype==PART_CHILD_FACES)
+ if (part->childtype==PART_CHILD_FACES)
size=part->size;
else
size=psys->particles[cpa->parent].size;
size*=part->childsize;
- if(part->childrandsize != 0.0f)
+ if (part->childrandsize != 0.0f)
size *= 1.0f - part->childrandsize * PSYS_FRAND(cpa - psys->child + 26);
return size;
@@ -3959,22 +3962,22 @@ static void get_child_modifier_parameters(ParticleSettings *part, ParticleThread
get_cpa_texture(ctx->dm, psys, part, psys->particles + cpa->pa[0], i, cpa_num, cpa_fuv, orco, ptex, PAMAP_DENS|PAMAP_CHILD, psys->cfra);
- if(ptex->exist < PSYS_FRAND(i + 24))
+ if (ptex->exist < PSYS_FRAND(i + 24))
return;
- if(ctx->vg_length)
+ if (ctx->vg_length)
ptex->length*=psys_interpolate_value_from_verts(ctx->dm,cpa_from,cpa_num,cpa_fuv,ctx->vg_length);
- if(ctx->vg_clump)
+ if (ctx->vg_clump)
ptex->clump*=psys_interpolate_value_from_verts(ctx->dm,cpa_from,cpa_num,cpa_fuv,ctx->vg_clump);
- if(ctx->vg_kink)
+ if (ctx->vg_kink)
ptex->kink*=psys_interpolate_value_from_verts(ctx->dm,cpa_from,cpa_num,cpa_fuv,ctx->vg_kink);
- if(ctx->vg_rough1)
+ if (ctx->vg_rough1)
ptex->rough1*=psys_interpolate_value_from_verts(ctx->dm,cpa_from,cpa_num,cpa_fuv,ctx->vg_rough1);
- if(ctx->vg_rough2)
+ if (ctx->vg_rough2)
ptex->rough2*=psys_interpolate_value_from_verts(ctx->dm,cpa_from,cpa_num,cpa_fuv,ctx->vg_rough2);
- if(ctx->vg_roughe)
+ if (ctx->vg_roughe)
ptex->roughe*=psys_interpolate_value_from_verts(ctx->dm,cpa_from,cpa_num,cpa_fuv,ctx->vg_roughe);
- if(ctx->vg_effector)
+ if (ctx->vg_effector)
ptex->effector*=psys_interpolate_value_from_verts(ctx->dm,cpa_from,cpa_num,cpa_fuv,ctx->vg_effector);
}
static void do_child_modifiers(ParticleSimulationData *sim, ParticleTexture *ptex, ParticleKey *par, float *par_rot, ChildParticle *cpa, float *orco, float mat[4][4], ParticleKey *state, float t)
@@ -3988,21 +3991,21 @@ static void do_child_modifiers(ParticleSimulationData *sim, ParticleTexture *pte
float rough2 = part->rough2;
float rough_end = part->rough_end;
- if(ptex) {
+ if (ptex) {
kink_freq *= ptex->kink;
rough1 *= ptex->rough1;
rough2 *= ptex->rough2;
rough_end *= ptex->roughe;
}
- if(part->flag & PART_CHILD_EFFECT)
+ if (part->flag & PART_CHILD_EFFECT)
/* state is safe to cast, since only co and vel are used */
guided = do_guides(sim->psys->effectors, (ParticleKey*)state, cpa->parent, t);
- if(guided==0) {
+ if (guided==0) {
float clump = do_clump(state, par, t, part->clumpfac, part->clumppow, ptex ? ptex->clump : 1.f);
- if(kink_freq != 0.f) {
+ if (kink_freq != 0.f) {
float kink_amp = part->kink_amp * (1.f - part->kink_amp_clump * clump);
do_kink(state, par, par_rot, t, kink_freq, part->kink_shape,
@@ -4011,13 +4014,13 @@ static void do_child_modifiers(ParticleSimulationData *sim, ParticleTexture *pte
}
}
- if(rough1 > 0.f)
+ if (rough1 > 0.f)
do_rough(orco, mat, t, rough1, part->rough1_size, 0.0, state);
- if(rough2 > 0.f)
+ if (rough2 > 0.f)
do_rough(sim->psys->frand + ((i + 27) % (PSYS_FRAND_COUNT - 3)), mat, t, rough2, part->rough2_size, part->rough2_thres, state);
- if(rough_end > 0.f)
+ if (rough_end > 0.f)
do_rough_end(sim->psys->frand + ((i + 27) % (PSYS_FRAND_COUNT - 3)), mat, t, rough_end, part->rough_end_shape, state);
}
/* get's hair (or keyed) particles state at the "path time" specified in state->time */
@@ -4052,9 +4055,9 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey *
t=state->time;
CLAMP(t, 0.0f, 1.0f);
- if(p<totpart) {
+ if (p<totpart) {
/* interpolate pathcache directly if it exist */
- if(psys->pathcache) {
+ if (psys->pathcache) {
ParticleCacheKey result;
interpolate_pathcache(psys->pathcache[p], t, &result);
copy_v3_v3(state->co, result.co);
@@ -4075,32 +4078,32 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey *
init_particle_interpolation(sim->ob, psys, pa, &pind);
do_particle_interpolation(psys, p, pa, t, &pind, state);
- if(pind.dm) {
+ if (pind.dm) {
mul_m4_v3(sim->ob->obmat, state->co);
mul_mat3_m4_v3(sim->ob->obmat, state->vel);
}
- else if(!keyed && !cached && !(psys->flag & PSYS_GLOBAL_HAIR)) {
- if((pa->flag & PARS_REKEY)==0) {
+ else if (!keyed && !cached && !(psys->flag & PSYS_GLOBAL_HAIR)) {
+ if ((pa->flag & PARS_REKEY)==0) {
psys_mat_hair_to_global(sim->ob, sim->psmd->dm, part->from, pa, hairmat);
mul_m4_v3(hairmat, state->co);
mul_mat3_m4_v3(hairmat, state->vel);
- if(sim->psys->effectors && (part->flag & PART_CHILD_GUIDE)==0) {
+ if (sim->psys->effectors && (part->flag & PART_CHILD_GUIDE)==0) {
do_guides(sim->psys->effectors, state, p, state->time);
/* TODO: proper velocity handling */
}
- if(psys->lattice && edit==0)
+ if (psys->lattice && edit==0)
calc_latt_deform(psys->lattice, state->co,1.0f);
}
}
}
}
- else if(totchild) {
+ else if (totchild) {
//invert_m4_m4(imat,ob->obmat);
/* interpolate childcache directly if it exists */
- if(psys->childcache) {
+ if (psys->childcache) {
ParticleCacheKey result;
interpolate_pathcache(psys->childcache[p-totpart], t, &result);
copy_v3_v3(state->co, result.co);
@@ -4110,19 +4113,19 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey *
else {
cpa=psys->child+p-totpart;
- if(state->time < 0.0f)
+ if (state->time < 0.0f)
t = psys_get_child_time(psys, cpa, -state->time, NULL, NULL);
- if(totchild && part->childtype==PART_CHILD_FACES) {
+ if (totchild && part->childtype==PART_CHILD_FACES) {
/* part->parents could still be 0 so we can't test with totparent */
between=1;
}
- if(between) {
+ if (between) {
int w = 0;
float foffset;
/* get parent states */
- while(w<4 && cpa->pa[w]>=0) {
+ while (w<4 && cpa->pa[w]>=0) {
keys[w].time = state->time;
psys_get_particle_on_path(sim, cpa->pa[w], keys+w, 1);
w++;
@@ -4144,14 +4147,14 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey *
pa = psys->particles + cpa->parent;
- if(part->type == PART_HAIR)
+ if (part->type == PART_HAIR)
psys_mat_hair_to_global(sim->ob, sim->psmd->dm, psys->part->from, pa, hairmat);
else
unit_m4(hairmat);
pa=0;
}
- else{
+ else {
/* get the parent state */
keys->time = state->time;
psys_get_particle_on_path(sim, cpa->parent, keys,1);
@@ -4165,7 +4168,7 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey *
- if(part->type == PART_HAIR) {
+ if (part->type == PART_HAIR) {
psys_particle_on_emitter(psmd,cpa_from,cpa_num,DMCACHE_ISCHILD,cpa_fuv,pa->foffset,co,0,0,0,orco,0);
psys_mat_hair_to_global(sim->ob, sim->psmd->dm, psys->part->from, pa, hairmat);
}
@@ -4177,7 +4180,7 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey *
/* correct child ipo timing */
#if 0 // XXX old animation system
- if((part->flag&PART_ABS_TIME)==0 && part->ipo) {
+ if ((part->flag&PART_ABS_TIME)==0 && part->ipo) {
calc_ipo(part->ipo, 100.0f*t);
execute_ipo((ID *)part, part->ipo);
}
@@ -4191,14 +4194,14 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey *
/* TODO: assign vertex groups */
get_child_modifier_parameters(part, &ctx, cpa, cpa_from, cpa_num, cpa_fuv, orco, &ptex);
- if(between) {
+ if (between) {
int w=0;
state->co[0] = state->co[1] = state->co[2] = 0.0f;
state->vel[0] = state->vel[1] = state->vel[2] = 0.0f;
/* child position is the weighted sum of parent positions */
- while(w<4 && cpa->pa[w]>=0) {
+ while (w<4 && cpa->pa[w]>=0) {
state->co[0] += cpa->w[w] * keys[w].co[0];
state->co[1] += cpa->w[w] * keys[w].co[1];
state->co[2] += cpa->w[w] * keys[w].co[2];
@@ -4211,31 +4214,31 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey *
/* apply offset for correct positioning */
//add_v3_v3(state->co, cpa_1st);
}
- else{
+ else {
/* offset the child from the parent position */
offset_child(cpa, keys, keys->rot, state, part->childflat, part->childrad);
}
par = keys;
- if(vel)
+ if (vel)
copy_particle_key(&tstate, state, 1);
/* apply different deformations to the child path */
do_child_modifiers(sim, &ptex, par, par->rot, cpa, orco, hairmat, state, t);
/* try to estimate correct velocity */
- if(vel) {
+ if (vel) {
ParticleKey tstate;
float length = len_v3(state->vel);
- if(t>=0.001f) {
+ if (t>=0.001f) {
tstate.time=t-0.001f;
psys_get_particle_on_path(sim,p,&tstate,0);
sub_v3_v3v3(state->vel,state->co,tstate.co);
normalize_v3(state->vel);
}
- else{
+ else {
tstate.time=t+0.001f;
psys_get_particle_on_path(sim,p,&tstate,0);
sub_v3_v3v3(state->vel,tstate.co,state->co);
@@ -4261,20 +4264,20 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta
/* negative time means "use current time" */
cfra = state->time > 0 ? state->time : BKE_curframe(sim->scene);
- if(p>=totpart) {
- if(!psys->totchild)
+ if (p>=totpart) {
+ if (!psys->totchild)
return 0;
- if(part->childtype == PART_CHILD_FACES) {
- if(!(psys->flag & PSYS_KEYED))
+ if (part->childtype == PART_CHILD_FACES) {
+ if (!(psys->flag & PSYS_KEYED))
return 0;
cpa = psys->child + p - totpart;
state->time = psys_get_child_time(psys, cpa, cfra, NULL, NULL);
- if(!always)
- if((state->time < 0.0f && !(part->flag & PART_UNBORN))
+ if (!always)
+ if ((state->time < 0.0f && !(part->flag & PART_UNBORN))
|| (state->time > 1.0f && !(part->flag & PART_DIED)))
return 0;
@@ -4292,22 +4295,22 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta
pa = sim->psys->particles + p;
}
- if(pa) {
- if(!always)
- if((cfra < pa->time && (part->flag & PART_UNBORN)==0)
+ if (pa) {
+ if (!always)
+ if ((cfra < pa->time && (part->flag & PART_UNBORN)==0)
|| (cfra > pa->dietime && (part->flag & PART_DIED)==0))
return 0;
cfra = MIN2(cfra, pa->dietime);
}
- if(sim->psys->flag & PSYS_KEYED) {
+ if (sim->psys->flag & PSYS_KEYED) {
state->time= -cfra;
psys_get_particle_on_path(sim, p, state,1);
return 1;
}
- else{
- if(cpa) {
+ else {
+ if (cpa) {
float mat[4][4];
ParticleKey *key1;
float t = (cfra - pa->time) / pa->lifetime;
@@ -4320,19 +4323,19 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta
unit_m4(mat);
do_child_modifiers(sim, NULL, key1, key1->rot, cpa, cpa->fuv, mat, state, t);
- if(psys->lattice)
+ if (psys->lattice)
calc_latt_deform(sim->psys->lattice, state->co,1.0f);
}
- else{
- if(pa->state.time==cfra || ELEM(part->phystype,PART_PHYS_NO,PART_PHYS_KEYED))
+ else {
+ if (pa->state.time==cfra || ELEM(part->phystype,PART_PHYS_NO,PART_PHYS_KEYED))
copy_particle_key(state, &pa->state, 1);
- else if(pa->prev_state.time==cfra)
+ else if (pa->prev_state.time==cfra)
copy_particle_key(state, &pa->prev_state, 1);
else {
float dfra, frs_sec = sim->scene->r.frs_sec;
/* let's interpolate to try to be as accurate as possible */
- if(pa->state.time + 2.f >= state->time && pa->prev_state.time - 2.f <= state->time) {
- if(pa->prev_state.time >= pa->state.time || pa->prev_state.time < 0.f) {
+ if (pa->state.time + 2.f >= state->time && pa->prev_state.time - 2.f <= state->time) {
+ if (pa->prev_state.time >= pa->state.time || pa->prev_state.time < 0.f) {
/* prev_state is wrong so let's not use it, this can happen at frames 1, 0 or particle birth */
dfra = state->time - pa->state.time;
@@ -4364,7 +4367,7 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta
interp_qt_qtqt(state->rot, keys[1].rot, keys[2].rot, keytime);
}
}
- else if(pa->state.time + 1.f >= state->time && pa->state.time - 1.f <= state->time) {
+ else if (pa->state.time + 1.f >= state->time && pa->state.time - 1.f <= state->time) {
/* linear interpolation using only pa->state */
dfra = state->time - pa->state.time;
@@ -4379,7 +4382,7 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta
}
}
- if(sim->psys->lattice)
+ if (sim->psys->lattice)
calc_latt_deform(sim->psys->lattice, state->co,1.0f);
}
@@ -4396,10 +4399,10 @@ void psys_get_dupli_texture(ParticleSystem *psys, ParticleSettings *part, Partic
uv[0] = uv[1] = 0.f;
- if(cpa) {
- if(part->childtype == PART_CHILD_FACES) {
+ if (cpa) {
+ if (part->childtype == PART_CHILD_FACES) {
mtface= CustomData_get_layer(&psmd->dm->faceData, CD_MTFACE);
- if(mtface) {
+ if (mtface) {
mface= psmd->dm->getTessFaceData(psmd->dm, cpa->num, CD_MFACE);
mtface += cpa->num;
psys_interpolate_uvs(mtface, mface->v4, cpa->fuv, uv);
@@ -4413,11 +4416,11 @@ void psys_get_dupli_texture(ParticleSystem *psys, ParticleSettings *part, Partic
}
}
- if(part->from == PART_FROM_FACE) {
+ if (part->from == PART_FROM_FACE) {
mtface= CustomData_get_layer(&psmd->dm->faceData, CD_MTFACE);
num= pa->num_dmcache;
- if(num == DMCACHE_NOTFOUND)
+ if (num == DMCACHE_NOTFOUND)
num= pa->num;
if (num >= psmd->dm->getNumTessFaces(psmd->dm)) {
@@ -4426,7 +4429,7 @@ void psys_get_dupli_texture(ParticleSystem *psys, ParticleSettings *part, Partic
num= DMCACHE_NOTFOUND;
}
- if(mtface && num != DMCACHE_NOTFOUND) {
+ if (mtface && num != DMCACHE_NOTFOUND) {
mface= psmd->dm->getTessFaceData(psmd->dm, num, CD_MFACE);
mtface += num;
psys_interpolate_uvs(mtface, mface->v4, pa->fuv, uv);
@@ -4447,23 +4450,23 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim, ParticleData *pa
sub_v3_v3v3(vec, (cache+cache->steps)->co, cache->co);
len= normalize_v3(vec);
- if(pa == NULL && psys->part->childflat != PART_CHILD_FACES)
+ if (pa == NULL && psys->part->childflat != PART_CHILD_FACES)
pa = psys->particles + cpa->pa[0];
- if(pa)
+ if (pa)
psys_particle_on_emitter(psmd,sim->psys->part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,loc,nor,0,0,0,0);
else
psys_particle_on_emitter(psmd,PART_FROM_FACE,cpa->num,DMCACHE_ISCHILD,cpa->fuv,cpa->foffset,loc,nor,0,0,0,0);
- if(psys->part->rotmode == PART_ROT_VEL) {
+ if (psys->part->rotmode == PART_ROT_VEL) {
copy_m3_m4(nmat, ob->imat);
transpose_m3(nmat);
mul_m3_v3(nmat, nor);
normalize_v3(nor);
/* make sure that we get a proper side vector */
- if(fabs(dot_v3v3(nor,vec))>0.999999) {
- if(fabs(dot_v3v3(nor,xvec))>0.999999) {
+ if (fabs(dot_v3v3(nor,vec))>0.999999) {
+ if (fabs(dot_v3v3(nor,xvec))>0.999999) {
nor[0] = 0.0f;
nor[1] = 1.0f;
nor[2] = 0.0f;
@@ -4478,10 +4481,10 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim, ParticleData *pa
normalize_v3(side);
/* rotate side vector around vec */
- if(psys->part->phasefac != 0) {
+ if (psys->part->phasefac != 0) {
float q_phase[4];
float phasefac = psys->part->phasefac;
- if(psys->part->randphasefac != 0.0f)
+ if (psys->part->randphasefac != 0.0f)
phasefac += psys->part->randphasefac * PSYS_FRAND((pa-psys->particles) + 20);
axis_angle_to_quat( q_phase, vec, phasefac*(float)M_PI);
@@ -4512,7 +4515,7 @@ void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3]
/* can happen with bad pointcache or physics calculation
* since this becomes geometry, nan's and inf's crash raytrace code.
* better not allow this. */
- if( !finite(bb->vec[0]) || !finite(bb->vec[1]) || !finite(bb->vec[2]) ||
+ if ( !finite(bb->vec[0]) || !finite(bb->vec[1]) || !finite(bb->vec[2]) ||
!finite(bb->vel[0]) || !finite(bb->vel[1]) || !finite(bb->vel[2]) )
{
zero_v3(bb->vec);
@@ -4526,22 +4529,22 @@ void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3]
return;
}
- if(bb->align < PART_BB_VIEW)
+ if (bb->align < PART_BB_VIEW)
onevec[bb->align]=1.0f;
- if(bb->lock && (bb->align == PART_BB_VIEW)) {
+ if (bb->lock && (bb->align == PART_BB_VIEW)) {
normalize_v3_v3(xvec, bb->ob->obmat[0]);
normalize_v3_v3(yvec, bb->ob->obmat[1]);
normalize_v3_v3(zvec, bb->ob->obmat[2]);
}
- else if(bb->align == PART_BB_VEL) {
+ else if (bb->align == PART_BB_VEL) {
float temp[3];
normalize_v3_v3(temp, bb->vel);
sub_v3_v3v3(zvec, bb->ob->obmat[3], bb->vec);
- if(bb->lock) {
+ if (bb->lock) {
float fac = -dot_v3v3(zvec, temp);
madd_v3_v3fl(zvec, temp, fac);
@@ -4555,11 +4558,11 @@ void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3]
}
else {
sub_v3_v3v3(zvec, bb->ob->obmat[3], bb->vec);
- if(bb->lock)
+ if (bb->lock)
zvec[bb->align] = 0.0f;
normalize_v3(zvec);
- if(bb->align < PART_BB_VIEW)
+ if (bb->align < PART_BB_VIEW)
cross_v3_v3v3(xvec, onevec, zvec);
else
cross_v3_v3v3(xvec, bb->ob->obmat[1], zvec);
@@ -4596,18 +4599,18 @@ void psys_apply_hair_lattice(Scene *scene, Object *ob, ParticleSystem *psys)
psys->lattice = psys_get_lattice(&sim);
- if(psys->lattice) {
+ if (psys->lattice) {
ParticleData *pa = psys->particles;
HairKey *hkey;
int p, h;
float hairmat[4][4], imat[4][4];
- for(p=0; p<psys->totpart; p++, pa++) {
+ for (p=0; p<psys->totpart; p++, pa++) {
psys_mat_hair_to_global(sim.ob, sim.psmd->dm, psys->part->from, pa, hairmat);
invert_m4_m4(imat, hairmat);
hkey = pa->hair;
- for(h=0; h<pa->totkey; h++, hkey++) {
+ for (h=0; h<pa->totkey; h++, hkey++) {
mul_m4_v3(hairmat, hkey->co);
calc_latt_deform(psys->lattice, hkey->co, 1.0f);
mul_m4_v3(imat, hkey->co);
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 978971a04a4..4a1f0a425cb 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -113,10 +113,10 @@
static int particles_are_dynamic(ParticleSystem *psys)
{
- if(psys->pointcache->flag & PTCACHE_BAKED)
+ if (psys->pointcache->flag & PTCACHE_BAKED)
return 0;
- if(psys->part->type == PART_HAIR)
+ if (psys->part->type == PART_HAIR)
return psys->flag & PSYS_HAIR_DYNAMICS;
else
return ELEM3(psys->part->phystype, PART_PHYS_NEWTON, PART_PHYS_BOIDS, PART_PHYS_FLUID);
@@ -126,7 +126,7 @@ static int psys_get_current_display_percentage(ParticleSystem *psys)
{
ParticleSettings *part=psys->part;
- if((psys->renderdata && !particles_are_dynamic(psys)) /* non-dynamic particles can be rendered fully */
+ if ((psys->renderdata && !particles_are_dynamic(psys)) /* non-dynamic particles can be rendered fully */
|| (part->child_nbr && part->childtype) /* display percentage applies to children */
|| (psys->pointcache->flag & PTCACHE_BAKING)) /* baking is always done with full amount */
return 100;
@@ -136,9 +136,9 @@ static int psys_get_current_display_percentage(ParticleSystem *psys)
static int tot_particles(ParticleSystem *psys, PTCacheID *pid)
{
- if(pid && psys->pointcache->flag & PTCACHE_EXTERNAL)
+ if (pid && psys->pointcache->flag & PTCACHE_EXTERNAL)
return pid->cache->totpoint;
- else if(psys->part->distr == PART_DISTR_GRID && psys->part->from != PART_FROM_VERT)
+ else if (psys->part->distr == PART_DISTR_GRID && psys->part->from != PART_FROM_VERT)
return psys->part->grid_res * psys->part->grid_res * psys->part->grid_res - psys->totunexist;
else
return psys->part->totpart - psys->totunexist;
@@ -148,10 +148,10 @@ void psys_reset(ParticleSystem *psys, int mode)
{
PARTICLE_P;
- if(ELEM(mode, PSYS_RESET_ALL, PSYS_RESET_DEPSGRAPH)) {
- if(mode == PSYS_RESET_ALL || !(psys->flag & PSYS_EDITED)) {
+ if (ELEM(mode, PSYS_RESET_ALL, PSYS_RESET_DEPSGRAPH)) {
+ if (mode == PSYS_RESET_ALL || !(psys->flag & PSYS_EDITED)) {
/* don't free if not absolutely necessary */
- if(psys->totpart != tot_particles(psys, NULL)) {
+ if (psys->totpart != tot_particles(psys, NULL)) {
psys_free_particles(psys);
psys->totpart= 0;
}
@@ -159,21 +159,21 @@ void psys_reset(ParticleSystem *psys, int mode)
psys->totkeyed= 0;
psys->flag &= ~(PSYS_HAIR_DONE|PSYS_KEYED);
- if(psys->edit && psys->free_edit) {
+ if (psys->edit && psys->free_edit) {
psys->free_edit(psys->edit);
psys->edit = NULL;
psys->free_edit = NULL;
}
}
}
- else if(mode == PSYS_RESET_CACHE_MISS) {
+ else if (mode == PSYS_RESET_CACHE_MISS) {
/* set all particles to be skipped */
LOOP_PARTICLES
pa->flag |= PARS_NO_DISP;
}
/* reset children */
- if(psys->child) {
+ if (psys->child) {
MEM_freeN(psys->child);
psys->child= NULL;
}
@@ -186,7 +186,7 @@ void psys_reset(ParticleSystem *psys, int mode)
/* reset point cache */
BKE_ptcache_invalidate(psys->pointcache);
- if(psys->fluid_springs) {
+ if (psys->fluid_springs) {
MEM_freeN(psys->fluid_springs);
psys->fluid_springs = NULL;
}
@@ -203,8 +203,8 @@ static void realloc_particles(ParticleSimulationData *sim, int new_totpart)
PARTICLE_P;
int totpart, totsaved = 0;
- if(new_totpart<0) {
- if(part->distr==PART_DISTR_GRID && part->from != PART_FROM_VERT) {
+ if (new_totpart<0) {
+ if (part->distr==PART_DISTR_GRID && part->from != PART_FROM_VERT) {
totpart= part->grid_res;
totpart*=totpart*totpart;
}
@@ -214,55 +214,55 @@ static void realloc_particles(ParticleSimulationData *sim, int new_totpart)
else
totpart=new_totpart;
- if(totpart != psys->totpart) {
- if(psys->edit && psys->free_edit) {
+ if (totpart != psys->totpart) {
+ if (psys->edit && psys->free_edit) {
psys->free_edit(psys->edit);
psys->edit = NULL;
psys->free_edit = NULL;
}
- if(totpart) {
+ if (totpart) {
newpars= MEM_callocN(totpart*sizeof(ParticleData), "particles");
- if(newpars == NULL)
+ if (newpars == NULL)
return;
- if(psys->part->phystype == PART_PHYS_BOIDS) {
+ if (psys->part->phystype == PART_PHYS_BOIDS) {
newboids= MEM_callocN(totpart*sizeof(BoidParticle), "boid particles");
- if(newboids == NULL) {
+ if (newboids == NULL) {
/* allocation error! */
- if(newpars)
+ if (newpars)
MEM_freeN(newpars);
return;
}
}
}
- if(psys->particles) {
+ if (psys->particles) {
totsaved=MIN2(psys->totpart,totpart);
/*save old pars*/
- if(totsaved) {
+ if (totsaved) {
memcpy(newpars,psys->particles,totsaved*sizeof(ParticleData));
- if(psys->particles->boid)
+ if (psys->particles->boid)
memcpy(newboids, psys->particles->boid, totsaved*sizeof(BoidParticle));
}
- if(psys->particles->keys)
+ if (psys->particles->keys)
MEM_freeN(psys->particles->keys);
- if(psys->particles->boid)
+ if (psys->particles->boid)
MEM_freeN(psys->particles->boid);
- for(p=0, pa=newpars; p<totsaved; p++, pa++) {
- if(pa->keys) {
+ for (p=0, pa=newpars; p<totsaved; p++, pa++) {
+ if (pa->keys) {
pa->keys= NULL;
pa->totkey= 0;
}
}
- for(p=totsaved, pa=psys->particles+totsaved; p<psys->totpart; p++, pa++)
- if(pa->hair) MEM_freeN(pa->hair);
+ for (p=totsaved, pa=psys->particles+totsaved; p<psys->totpart; p++, pa++)
+ if (pa->hair) MEM_freeN(pa->hair);
MEM_freeN(psys->particles);
psys_free_pdd(psys);
@@ -271,13 +271,13 @@ static void realloc_particles(ParticleSimulationData *sim, int new_totpart)
psys->particles=newpars;
psys->totpart=totpart;
- if(newboids) {
+ if (newboids) {
LOOP_PARTICLES
pa->boid = newboids++;
}
}
- if(psys->child) {
+ if (psys->child) {
MEM_freeN(psys->child);
psys->child=NULL;
psys->totchild=0;
@@ -288,10 +288,10 @@ static int get_psys_child_number(struct Scene *scene, ParticleSystem *psys)
{
int nbr;
- if(!psys->part->childtype)
+ if (!psys->part->childtype)
return 0;
- if(psys->renderdata)
+ if (psys->renderdata)
nbr= psys->part->ren_child_nbr;
else
nbr= psys->part->child_nbr;
@@ -306,9 +306,9 @@ static int get_psys_tot_child(struct Scene *scene, ParticleSystem *psys)
static void alloc_child_particles(ParticleSystem *psys, int tot)
{
- if(psys->child) {
+ if (psys->child) {
/* only re-allocate if we have to */
- if(psys->part->childtype && psys->totchild == tot) {
+ if (psys->part->childtype && psys->totchild == tot) {
memset(psys->child, 0, tot*sizeof(ChildParticle));
return;
}
@@ -318,9 +318,9 @@ static void alloc_child_particles(ParticleSystem *psys, int tot)
psys->totchild=0;
}
- if(psys->part->childtype) {
+ if (psys->part->childtype) {
psys->totchild= tot;
- if(psys->totchild)
+ if (psys->totchild)
psys->child= MEM_callocN(psys->totchild*sizeof(ChildParticle), "child_particles");
}
}
@@ -341,12 +341,12 @@ void psys_calc_dmcache(Object *ob, DerivedMesh *dm, ParticleSystem *psys)
PARTICLE_P;
/* CACHE LOCATIONS */
- if(!dm->deformedOnly) {
+ if (!dm->deformedOnly) {
/* Will use later to speed up subsurf/derivedmesh */
LinkNode *node, *nodedmelem, **nodearray;
int totdmelem, totelem, i, *origindex;
- if(psys->part->from == PART_FROM_VERT) {
+ if (psys->part->from == PART_FROM_VERT) {
totdmelem= dm->getNumVerts(dm);
totelem= me->totvert;
origindex= dm->getVertDataArray(dm, CD_ORIGINDEX);
@@ -360,11 +360,11 @@ void psys_calc_dmcache(Object *ob, DerivedMesh *dm, ParticleSystem *psys)
nodedmelem= MEM_callocN(sizeof(LinkNode)*totdmelem, "psys node elems");
nodearray= MEM_callocN(sizeof(LinkNode *)*totelem, "psys node array");
- for(i=0, node=nodedmelem; i<totdmelem; i++, origindex++, node++) {
+ for (i=0, node=nodedmelem; i<totdmelem; i++, origindex++, node++) {
node->link= SET_INT_IN_POINTER(i);
- if(*origindex != -1) {
- if(nodearray[*origindex]) {
+ if (*origindex != -1) {
+ if (nodearray[*origindex]) {
/* prepend */
node->next = nodearray[*origindex];
nodearray[*origindex]= node;
@@ -376,13 +376,13 @@ void psys_calc_dmcache(Object *ob, DerivedMesh *dm, ParticleSystem *psys)
/* cache the verts/faces! */
LOOP_PARTICLES {
- if(pa->num < 0) {
+ if (pa->num < 0) {
pa->num_dmcache = -1;
continue;
}
- if(psys->part->from == PART_FROM_VERT) {
- if(nodearray[pa->num])
+ if (psys->part->from == PART_FROM_VERT) {
+ if (nodearray[pa->num])
pa->num_dmcache= GET_INT_FROM_POINTER(nodearray[pa->num]->link);
}
else { /* FROM_FACE/FROM_VOLUME */
@@ -415,13 +415,13 @@ static void distribute_simple_children(Scene *scene, Object *ob, DerivedMesh *fi
alloc_child_particles(psys, totpart);
cpa = psys->child;
- for(i=0; i<child_nbr; i++) {
- for(p=0; p<psys->totpart; p++,cpa++) {
+ for (i=0; i<child_nbr; i++) {
+ for (p=0; p<psys->totpart; p++,cpa++) {
float length=2.0;
cpa->parent=p;
/* create even spherical distribution inside unit sphere */
- while(length>=1.0f) {
+ while (length>=1.0f) {
cpa->fuv[0]=2.0f*BLI_frand()-1.0f;
cpa->fuv[1]=2.0f*BLI_frand()-1.0f;
cpa->fuv[2]=2.0f*BLI_frand()-1.0f;
@@ -449,7 +449,7 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys)
copy_v3_v3(max, mv->co);
mv++;
- for(i=1; i<totvert; i++, mv++) {
+ for (i=1; i<totvert; i++, mv++) {
min[0]=MIN2(min[0],mv->co[0]);
min[1]=MIN2(min[1],mv->co[1]);
min[2]=MIN2(min[2],mv->co[2]);
@@ -483,9 +483,9 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys)
min[1]+= d < delta[1] ? d/2.f : delta[1]/2.f;
min[2]+= d < delta[2] ? d/2.f : delta[2]/2.f;
- for(i=0,p=0,pa=psys->particles; i<res; i++) {
- for(j=0; j<res; j++) {
- for(k=0; k<res; k++,p++,pa++) {
+ for (i=0,p=0,pa=psys->particles; i<res; i++) {
+ for (j=0; j<res; j++) {
+ for (k=0; k<res; k++,p++,pa++) {
pa->fuv[0] = min[0] + (float)i*d;
pa->fuv[1] = min[1] + (float)j*d;
pa->fuv[2] = min[2] + (float)k*d;
@@ -496,7 +496,7 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys)
}
/* enable particles near verts/edges/faces/inside surface */
- if(from==PART_FROM_VERT) {
+ if (from==PART_FROM_VERT) {
float vec[3];
pa=psys->particles;
@@ -505,7 +505,7 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys)
min[1] -= d/2.0f;
min[2] -= d/2.0f;
- for(i=0,mv=mvert; i<totvert; i++,mv++) {
+ for (i=0,mv=mvert; i<totvert; i++,mv++) {
sub_v3_v3v3(vec,mv->co,min);
vec[0]/=delta[0];
vec[1]/=delta[1];
@@ -515,7 +515,7 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys)
+(int)(vec[2]*(size[2]-1)))->flag &= ~PARS_UNEXIST;
}
}
- else if(ELEM(from,PART_FROM_FACE,PART_FROM_VOLUME)) {
+ else if (ELEM(from,PART_FROM_FACE,PART_FROM_VOLUME)) {
float co1[3], co2[3];
MFace *mface= NULL, *mface_array;
@@ -526,13 +526,13 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys)
totface=dm->getNumTessFaces(dm);
mface=mface_array=dm->getTessFaceDataArray(dm,CD_MFACE);
- for(a=0; a<amax; a++) {
- if(a==0) { a0mul=res*res; a1mul=res; a2mul=1; }
- else if(a==1) { a0mul=res; a1mul=1; a2mul=res*res; }
- else{ a0mul=1; a1mul=res*res; a2mul=res; }
+ for (a=0; a<amax; a++) {
+ if (a==0) { a0mul=res*res; a1mul=res; a2mul=1; }
+ else if (a==1) { a0mul=res; a1mul=1; a2mul=res*res; }
+ else { a0mul=1; a1mul=res*res; a2mul=res; }
- for(a1=0; a1<size[(a+1)%3]; a1++) {
- for(a2=0; a2<size[(a+2)%3]; a2++) {
+ for (a1=0; a1<size[(a+1)%3]; a1++) {
+ for (a2=0; a2<size[(a+2)%3]; a2++) {
mface= mface_array;
pa = psys->particles + a1*a1mul + a2*a2mul;
@@ -543,23 +543,23 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys)
co1[a] -= 0.001f*d;
/* lets intersect the faces */
- for(i=0; i<totface; i++,mface++) {
+ for (i=0; i<totface; i++,mface++) {
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(isect_axial_line_tri_v3(a, co1, co2, v2, v3, v1, &lambda)) {
- if(from==PART_FROM_FACE)
+ if (isect_axial_line_tri_v3(a, co1, co2, v2, v3, v1, &lambda)) {
+ if (from==PART_FROM_FACE)
(pa+(int)(lambda*size[a])*a0mul)->flag &= ~PARS_UNEXIST;
else /* store number of intersections */
(pa+(int)(lambda*size[a])*a0mul)->hair_index++;
}
- if(mface->v4) {
+ if (mface->v4) {
copy_v3_v3(v4, mvert[mface->v4].co);
- if(isect_axial_line_tri_v3(a, co1, co2, v4, v1, v3, &lambda)) {
- if(from==PART_FROM_FACE)
+ if (isect_axial_line_tri_v3(a, co1, co2, v4, v1, v3, &lambda)) {
+ if (from==PART_FROM_FACE)
(pa+(int)(lambda*size[a])*a0mul)->flag &= ~PARS_UNEXIST;
else
(pa+(int)(lambda*size[a])*a0mul)->hair_index++;
@@ -567,11 +567,11 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys)
}
}
- if(from==PART_FROM_VOLUME) {
+ if (from==PART_FROM_VOLUME) {
int in=pa->hair_index%2;
- if(in) pa->hair_index++;
- for(i=0; i<size[0]; i++) {
- if(in || (pa+i*a0mul)->hair_index%2)
+ if (in) pa->hair_index++;
+ for (i=0; i<size[0]; i++) {
+ if (in || (pa+i*a0mul)->hair_index%2)
(pa+i*a0mul)->flag &= ~PARS_UNEXIST;
/* odd intersections == in->out / out->in */
/* even intersections -> in stays same */
@@ -583,14 +583,14 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys)
}
}
- if(psys->part->flag & PART_GRID_HEXAGONAL) {
- for(i=0,p=0,pa=psys->particles; i<res; i++) {
- for(j=0; j<res; j++) {
- for(k=0; k<res; k++,p++,pa++) {
- if(j%2)
+ if (psys->part->flag & PART_GRID_HEXAGONAL) {
+ for (i=0,p=0,pa=psys->particles; i<res; i++) {
+ for (j=0; j<res; j++) {
+ for (k=0; k<res; k++,p++,pa++) {
+ if (j%2)
pa->fuv[0] += d/2.f;
- if(k%2) {
+ if (k%2) {
pa->fuv[0] += d/2.f;
pa->fuv[1] += d/2.f;
}
@@ -599,21 +599,21 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys)
}
}
- if(psys->part->flag & PART_GRID_INVERT) {
- for(i=0; i<size[0]; i++) {
- for(j=0; j<size[1]; j++) {
+ if (psys->part->flag & PART_GRID_INVERT) {
+ for (i=0; i<size[0]; i++) {
+ for (j=0; j<size[1]; j++) {
pa=psys->particles + res*(i*res + j);
- for(k=0; k<size[2]; k++, pa++) {
+ for (k=0; k<size[2]; k++, pa++) {
pa->flag ^= PARS_UNEXIST;
}
}
}
}
- if(psys->part->grid_rand > 0.f) {
+ if (psys->part->grid_rand > 0.f) {
float rfac = d * psys->part->grid_rand;
- for(p=0,pa=psys->particles; p<psys->totpart; p++,pa++) {
- if(pa->flag & PARS_UNEXIST)
+ for (p=0,pa=psys->particles; p<psys->totpart; p++,pa++) {
+ if (pa->flag & PARS_UNEXIST)
continue;
pa->fuv[0] += rfac * (PSYS_FRAND(p + 31) - 0.5f);
@@ -653,7 +653,7 @@ static void init_mv_jit(float *jit, int num, int seed2, float amount)
float *jit2, x, rad1, rad2, rad3;
int i, num2;
- if(num==0) return;
+ if (num==0) return;
rad1= (float)(1.0f/sqrtf((float)num));
rad2= (float)(1.0f/((float)num));
@@ -662,7 +662,7 @@ static void init_mv_jit(float *jit, int num, int seed2, float amount)
rng = rng_new(31415926 + num + seed2);
x= 0;
num2 = 2 * num;
- for(i=0; i<num2; i+=2) {
+ for (i=0; i<num2; i+=2) {
jit[i]= x + amount*rad1*(0.5f - rng_getFloat(rng));
jit[i+1]= i/(2.0f*num) + amount*rad1*(0.5f - rng_getFloat(rng));
@@ -689,8 +689,8 @@ static void psys_uv_to_w(float u, float v, int quad, float *w)
{
float vert[4][3], co[3];
- if(!quad) {
- if(u+v > 1.0f)
+ if (!quad) {
+ if (u+v > 1.0f)
v= 1.0f-v;
else
u= 1.0f-u;
@@ -704,7 +704,7 @@ static void psys_uv_to_w(float u, float v, int quad, float *w)
co[1]= v;
co[2]= 0.0f;
- if(quad) {
+ if (quad) {
vert[3][0]= 0.0f; vert[3][1]= 1.0f; vert[3][2]= 0.0f;
interp_weights_poly_v3( w,vert, 4, co);
}
@@ -719,18 +719,18 @@ static int distribute_binary_search(float *sum, int n, float value)
{
int mid, low=0, high=n;
- if(value == 0.f)
+ if (value == 0.f)
return 0;
- while(low <= high) {
+ while (low <= high) {
mid= (low + high)/2;
- if(sum[mid] < value && value <= sum[mid+1])
+ if (sum[mid] < value && value <= sum[mid+1])
return mid;
- if(sum[mid] >= value)
+ if (sum[mid] >= value)
high= mid - 1;
- else if(sum[mid] < value)
+ else if (sum[mid] < value)
low= mid + 1;
else
return mid;
@@ -758,14 +758,14 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch
int i, intersect, tot;
int rng_skip_tot= PSYS_RND_DIST_SKIP; /* count how many rng_* calls wont need skipping */
- if(from == PART_FROM_VERT) {
+ if (from == PART_FROM_VERT) {
/* TODO_PARTICLE - use original index */
pa->num= ctx->index[p];
pa->fuv[0] = 1.0f;
pa->fuv[1] = pa->fuv[2] = pa->fuv[3] = 0.0;
#if ONLY_WORKING_WITH_PA_VERTS
- if(ctx->tree) {
+ if (ctx->tree) {
KDTreeNearest ptn[3];
int w, maxw;
@@ -773,13 +773,13 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch
transform_mesh_orco_verts((Mesh*)ob->data, &orco1, 1, 1);
maxw = BLI_kdtree_find_n_nearest(ctx->tree,3,orco1,NULL,ptn);
- for(w=0; w<maxw; w++) {
+ for (w=0; w<maxw; w++) {
pa->verts[w]=ptn->num;
}
}
#endif
}
- else if(from == PART_FROM_FACE || from == PART_FROM_VOLUME) {
+ else if (from == PART_FROM_FACE || from == PART_FROM_VOLUME) {
MFace *mface;
pa->num = i = ctx->index[p];
@@ -787,8 +787,8 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch
switch(distr) {
case PART_DISTR_JIT:
- if(ctx->jitlevel == 1) {
- if(mface->v4)
+ if (ctx->jitlevel == 1) {
+ if (mface->v4)
psys_uv_to_w(0.5f, 0.5f, mface->v4, pa->fuv);
else
psys_uv_to_w(0.33333f, 0.33333f, mface->v4, pa->fuv);
@@ -810,7 +810,7 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch
pa->foffset= 0.0f;
/* experimental */
- if(from==PART_FROM_VOLUME) {
+ if (from==PART_FROM_VOLUME) {
MVert *mvert=dm->getVertDataArray(dm,CD_MVERT);
tot=dm->getNumTessFaces(dm);
@@ -825,25 +825,25 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch
min_d=2.0;
intersect=0;
- for(i=0,mface=dm->getTessFaceDataArray(dm,CD_MFACE); i<tot; i++,mface++) {
- if(i==pa->num) continue;
+ for (i=0,mface=dm->getTessFaceDataArray(dm,CD_MFACE); i<tot; i++,mface++) {
+ if (i==pa->num) continue;
v1=mvert[mface->v1].co;
v2=mvert[mface->v2].co;
v3=mvert[mface->v3].co;
- if(isect_line_tri_v3(co1, co2, v2, v3, v1, &cur_d, 0)) {
- if(cur_d<min_d) {
+ if (isect_line_tri_v3(co1, co2, v2, v3, v1, &cur_d, 0)) {
+ if (cur_d<min_d) {
min_d=cur_d;
pa->foffset=cur_d*50.0f; /* to the middle of volume */
intersect=1;
}
}
- if(mface->v4) {
+ if (mface->v4) {
v4=mvert[mface->v4].co;
- if(isect_line_tri_v3(co1, co2, v4, v1, v3, &cur_d, 0)) {
- if(cur_d<min_d) {
+ if (isect_line_tri_v3(co1, co2, v4, v1, v3, &cur_d, 0)) {
+ if (cur_d<min_d) {
min_d=cur_d;
pa->foffset=cur_d*50.0f; /* to the middle of volume */
intersect=1;
@@ -851,7 +851,7 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch
}
}
}
- if(intersect==0)
+ if (intersect==0)
pa->foffset=0.0;
else switch(distr) {
case PART_DISTR_JIT:
@@ -863,10 +863,10 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch
}
}
}
- else if(from == PART_FROM_CHILD) {
+ else if (from == PART_FROM_CHILD) {
MFace *mf;
- if(ctx->index[p] < 0) {
+ if (ctx->index[p] < 0) {
cpa->num=0;
cpa->fuv[0]=cpa->fuv[1]=cpa->fuv[2]=cpa->fuv[3]=0.0f;
cpa->pa[0]=cpa->pa[1]=cpa->pa[2]=cpa->pa[3]=0;
@@ -883,7 +883,7 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch
cpa->num = ctx->index[p];
- if(ctx->tree) {
+ if (ctx->tree) {
KDTreeNearest ptn[10];
int w,maxw;//, do_seams;
float maxd /*, mind,dd */, totw= 0.0f;
@@ -898,36 +898,36 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch
/* mind=ptn[0].dist; */ /* UNUSED */
/* the weights here could be done better */
- for(w=0; w<maxw; w++) {
+ for (w=0; w<maxw; w++) {
parent[w]=ptn[w].index;
pweight[w]=(float)pow(2.0,(double)(-6.0f*ptn[w].dist/maxd));
}
- for(;w<10; w++) {
+ for (;w<10; w++) {
parent[w]=-1;
pweight[w]=0.0f;
}
- for(w=0,i=0; w<maxw && i<4; w++) {
- if(parent[w]>=0) {
+ for (w=0,i=0; w<maxw && i<4; w++) {
+ if (parent[w]>=0) {
cpa->pa[i]=parent[w];
cpa->w[i]=pweight[w];
totw+=pweight[w];
i++;
}
}
- for(;i<4; i++) {
+ for (;i<4; i++) {
cpa->pa[i]=-1;
cpa->w[i]=0.0f;
}
- if(totw>0.0f) for(w=0; w<4; w++)
+ if (totw>0.0f) for(w=0; w<4; w++)
cpa->w[w]/=totw;
cpa->parent=cpa->pa[0];
}
}
- if(rng_skip_tot > 0) /* should never be below zero */
+ if (rng_skip_tot > 0) /* should never be below zero */
rng_skip(thread->rng, rng_skip_tot);
}
@@ -939,15 +939,15 @@ static void *distribute_threads_exec_cb(void *data)
ChildParticle *cpa;
int p, totpart;
- if(thread->ctx->from == PART_FROM_CHILD) {
+ if (thread->ctx->from == PART_FROM_CHILD) {
totpart= psys->totchild;
cpa= psys->child;
- for(p=0; p<totpart; p++, cpa++) {
- if(thread->ctx->skip) /* simplification skip */
+ for (p=0; p<totpart; p++, cpa++) {
+ if (thread->ctx->skip) /* simplification skip */
rng_skip(thread->rng, PSYS_RND_DIST_SKIP * thread->ctx->skip[p]);
- if((p+thread->num) % thread->tot == 0)
+ if ((p+thread->num) % thread->tot == 0)
distribute_threads_exec(thread, NULL, cpa, p);
else /* thread skip */
rng_skip(thread->rng, PSYS_RND_DIST_SKIP);
@@ -956,7 +956,7 @@ static void *distribute_threads_exec_cb(void *data)
else {
totpart= psys->totpart;
pa= psys->particles + thread->num;
- for(p=thread->num; p<totpart; p+=thread->tot, pa+=thread->tot)
+ for (p=thread->num; p<totpart; p+=thread->tot, pa+=thread->tot)
distribute_threads_exec(thread, pa, NULL, p);
}
@@ -970,14 +970,14 @@ static int distribute_compare_orig_index(const void *p1, const void *p2)
int index1 = COMPARE_ORIG_INDEX[*(const int*)p1];
int index2 = COMPARE_ORIG_INDEX[*(const int*)p2];
- if(index1 < index2)
+ if (index1 < index2)
return -1;
- else if(index1 == index2) {
+ else if (index1 == index2) {
/* this pointer comparison appears to make qsort stable for glibc,
* and apparently on solaris too, makes the renders reproducible */
- if(p1 < p2)
+ if (p1 < p2)
return -1;
- else if(p1 == p2)
+ else if (p1 == p2)
return 0;
else
return 1;
@@ -988,12 +988,12 @@ static int distribute_compare_orig_index(const void *p1, const void *p2)
static void distribute_invalid(Scene *scene, ParticleSystem *psys, int from)
{
- if(from == PART_FROM_CHILD) {
+ if (from == PART_FROM_CHILD) {
ChildParticle *cpa;
int p, totchild = get_psys_tot_child(scene, psys);
- if(psys->child && totchild) {
- for(p=0,cpa=psys->child; p<totchild; p++,cpa++) {
+ if (psys->child && totchild) {
+ for (p=0,cpa=psys->child; p<totchild; p++,cpa++) {
cpa->fuv[0]=cpa->fuv[1]=cpa->fuv[2]=cpa->fuv[3]= 0.0;
cpa->foffset= 0.0f;
cpa->parent=0;
@@ -1032,12 +1032,12 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D
float *element_weight=NULL,*element_sum=NULL,*jitter_offset=NULL, *vweight=NULL;
float cur, maxweight=0.0, tweight, totweight, inv_totweight, co[3], nor[3], orco[3], ornor[3];
- if(ELEM3(NULL, ob, psys, psys->part))
+ if (ELEM3(NULL, ob, psys, psys->part))
return 0;
part=psys->part;
totpart=psys->totpart;
- if(totpart==0)
+ if (totpart==0)
return 0;
if (!finaldm->deformedOnly && !finaldm->getTessFaceDataArray(finaldm, CD_ORIGINDEX)) {
@@ -1047,9 +1047,9 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D
}
/* First handle special cases */
- if(from == PART_FROM_CHILD) {
+ if (from == PART_FROM_CHILD) {
/* Simple children */
- if(part->childtype != PART_CHILD_FACES) {
+ if (part->childtype != PART_CHILD_FACES) {
BLI_srandom(31415926 + psys->seed + psys->child_seed);
distribute_simple_children(scene, ob, finaldm, psys);
return 0;
@@ -1057,7 +1057,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D
}
else {
/* Grid distribution */
- if(part->distr==PART_DISTR_GRID && from != PART_FROM_VERT) {
+ if (part->distr==PART_DISTR_GRID && from != PART_FROM_VERT) {
BLI_srandom(31415926 + psys->seed);
dm= CDDM_from_mesh((Mesh*)ob->data, ob);
distribute_grid(dm,psys);
@@ -1067,7 +1067,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D
}
/* Create trees and original coordinates if needed */
- if(from == PART_FROM_CHILD) {
+ if (from == PART_FROM_CHILD) {
distr=PART_DISTR_RAND;
BLI_srandom(31415926 + psys->seed + psys->child_seed);
dm= finaldm;
@@ -1079,7 +1079,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D
tree=BLI_kdtree_new(totpart);
- for(p=0,pa=psys->particles; p<totpart; p++,pa++) {
+ for (p=0,pa=psys->particles; p<totpart; p++,pa++) {
psys_particle_on_dm(dm,part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,co,nor,0,0,orco,ornor);
transform_mesh_orco_verts((Mesh*)ob->data, &orco, 1, 1);
BLI_kdtree_insert(tree, p, orco, ornor);
@@ -1104,15 +1104,15 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D
/* we need orco for consistent distributions */
DM_add_vert_layer(dm, CD_ORCO, CD_ASSIGN, get_mesh_orco_verts(ob));
- if(from == PART_FROM_VERT) {
+ if (from == PART_FROM_VERT) {
MVert *mv= dm->getVertDataArray(dm, CD_MVERT);
float (*orcodata)[3]= dm->getVertDataArray(dm, CD_ORCO);
int totvert = dm->getNumVerts(dm);
tree=BLI_kdtree_new(totvert);
- for(p=0; p<totvert; p++) {
- if(orcodata) {
+ for (p=0; p<totvert; p++) {
+ if (orcodata) {
copy_v3_v3(co,orcodata[p]);
transform_mesh_orco_verts((Mesh*)ob->data, &co, 1, 1);
}
@@ -1128,13 +1128,13 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D
/* Get total number of emission elements and allocate needed arrays */
totelem = (from == PART_FROM_VERT) ? dm->getNumVerts(dm) : dm->getNumTessFaces(dm);
- if(totelem == 0) {
+ if (totelem == 0) {
distribute_invalid(scene, psys, children ? PART_FROM_CHILD : 0);
- if(G.f & G_DEBUG)
+ if (G.f & G_DEBUG)
fprintf(stderr,"Particle distribution error: Nothing to emit from!\n");
- if(dm != finaldm) dm->release(dm);
+ if (dm != finaldm) dm->release(dm);
BLI_kdtree_free(tree);
@@ -1147,24 +1147,24 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D
jitter_offset = MEM_callocN(sizeof(float)*totelem, "particle_distribution_jitoff");
/* Calculate weights from face areas */
- if((part->flag&PART_EDISTR || children) && from != PART_FROM_VERT) {
+ if ((part->flag&PART_EDISTR || children) && from != PART_FROM_VERT) {
MVert *v1, *v2, *v3, *v4;
float totarea=0.f, co1[3], co2[3], co3[3], co4[3];
float (*orcodata)[3];
orcodata= dm->getVertDataArray(dm, CD_ORCO);
- for(i=0; i<totelem; i++) {
+ for (i=0; i<totelem; i++) {
MFace *mf=dm->getTessFaceData(dm,i,CD_MFACE);
- if(orcodata) {
+ if (orcodata) {
copy_v3_v3(co1, orcodata[mf->v1]);
copy_v3_v3(co2, orcodata[mf->v2]);
copy_v3_v3(co3, orcodata[mf->v3]);
transform_mesh_orco_verts((Mesh*)ob->data, &co1, 1, 1);
transform_mesh_orco_verts((Mesh*)ob->data, &co2, 1, 1);
transform_mesh_orco_verts((Mesh*)ob->data, &co3, 1, 1);
- if(mf->v4) {
+ if (mf->v4) {
copy_v3_v3(co4, orcodata[mf->v4]);
transform_mesh_orco_verts((Mesh*)ob->data, &co4, 1, 1);
}
@@ -1176,7 +1176,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D
copy_v3_v3(co1, v1->co);
copy_v3_v3(co2, v2->co);
copy_v3_v3(co3, v3->co);
- if(mf->v4) {
+ if (mf->v4) {
v4= (MVert*)dm->getVertData(dm,mf->v4,CD_MVERT);
copy_v3_v3(co4, v4->co);
}
@@ -1184,21 +1184,21 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D
cur = mf->v4 ? area_quad_v3(co1, co2, co3, co4) : area_tri_v3(co1, co2, co3);
- if(cur > maxweight)
+ if (cur > maxweight)
maxweight = cur;
element_weight[i] = cur;
totarea += cur;
}
- for(i=0; i<totelem; i++)
+ for (i=0; i<totelem; i++)
element_weight[i] /= totarea;
maxweight /= totarea;
}
- else{
+ else {
float min=1.0f/(float)(MIN2(totelem,totpart));
- for(i=0; i<totelem; i++)
+ for (i=0; i<totelem; i++)
element_weight[i]=min;
maxweight=min;
}
@@ -1206,17 +1206,17 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D
/* Calculate weights from vgroup */
vweight = psys_cache_vgroup(dm,psys,PSYS_VG_DENSITY);
- if(vweight) {
- if(from==PART_FROM_VERT) {
- for(i=0;i<totelem; i++)
+ if (vweight) {
+ if (from==PART_FROM_VERT) {
+ for (i=0;i<totelem; i++)
element_weight[i]*=vweight[i];
}
else { /* PART_FROM_FACE / PART_FROM_VOLUME */
- for(i=0;i<totelem; i++) {
+ for (i=0;i<totelem; i++) {
MFace *mf=dm->getTessFaceData(dm,i,CD_MFACE);
tweight = vweight[mf->v1] + vweight[mf->v2] + vweight[mf->v3];
- if(mf->v4) {
+ if (mf->v4) {
tweight += vweight[mf->v4];
tweight /= 4.0f;
}
@@ -1232,21 +1232,21 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D
/* Calculate total weight of all elements */
totweight= 0.0f;
- for(i=0;i<totelem; i++)
+ for (i=0;i<totelem; i++)
totweight += element_weight[i];
inv_totweight = (totweight > 0.f ? 1.f/totweight : 0.f);
/* Calculate cumulative weights */
element_sum[0]= 0.0f;
- for(i=0; i<totelem; i++)
+ for (i=0; i<totelem; i++)
element_sum[i+1]= element_sum[i] + element_weight[i] * inv_totweight;
/* Finally assign elements to particles */
- if((part->flag&PART_TRAND) || (part->simplify_flag&PART_SIMPLIFY_ENABLE)) {
+ if ((part->flag&PART_TRAND) || (part->simplify_flag&PART_SIMPLIFY_ENABLE)) {
float pos;
- for(p=0; p<totpart; p++) {
+ for (p=0; p<totpart; p++) {
/* In theory element_sum[totelem] should be 1.0, but due to float errors this is not necessarily always true, so scale pos accordingly. */
pos= BLI_frand() * element_sum[totelem];
particle_element[p]= distribute_binary_search(element_sum, totelem, pos);
@@ -1261,14 +1261,14 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D
pos= 1e-6; /* tiny offset to avoid zero weight face */
i= 0;
- for(p=0; p<totpart; p++, pos+=step) {
- while((i < totelem) && (pos > element_sum[i+1]))
+ for (p=0; p<totpart; p++, pos+=step) {
+ while ((i < totelem) && (pos > element_sum[i+1]))
i++;
particle_element[p]= MIN2(totelem-1, i);
/* avoid zero weight face */
- if(p == totpart-1 && element_weight[particle_element[p]] == 0.0f)
+ if (p == totpart-1 && element_weight[particle_element[p]] == 0.0f)
particle_element[p]= particle_element[p-1];
jitter_offset[particle_element[p]]= pos;
@@ -1279,32 +1279,32 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D
/* For hair, sort by origindex (allows optimization's in rendering), */
/* however with virtual parents the children need to be in random order. */
- if(part->type == PART_HAIR && !(part->childtype==PART_CHILD_FACES && part->parents!=0.0f)) {
+ if (part->type == PART_HAIR && !(part->childtype==PART_CHILD_FACES && part->parents!=0.0f)) {
COMPARE_ORIG_INDEX = NULL;
- if(from == PART_FROM_VERT) {
- if(dm->numVertData)
+ if (from == PART_FROM_VERT) {
+ if (dm->numVertData)
COMPARE_ORIG_INDEX= dm->getVertDataArray(dm, CD_ORIGINDEX);
}
else {
- if(dm->numTessFaceData)
+ if (dm->numTessFaceData)
COMPARE_ORIG_INDEX= dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
}
- if(COMPARE_ORIG_INDEX) {
+ if (COMPARE_ORIG_INDEX) {
qsort(particle_element, totpart, sizeof(int), distribute_compare_orig_index);
COMPARE_ORIG_INDEX = NULL;
}
}
/* Create jittering if needed */
- if(distr==PART_DISTR_JIT && ELEM(from,PART_FROM_FACE,PART_FROM_VOLUME)) {
+ if (distr==PART_DISTR_JIT && ELEM(from,PART_FROM_FACE,PART_FROM_VOLUME)) {
jitlevel= part->userjit;
- if(jitlevel == 0) {
+ if (jitlevel == 0) {
jitlevel= totpart/totelem;
- if(part->flag & PART_EDISTR) jitlevel*= 2; /* looks better in general, not very scietific */
- if(jitlevel<3) jitlevel= 3;
+ if (part->flag & PART_EDISTR) jitlevel*= 2; /* looks better in general, not very scietific */
+ if (jitlevel<3) jitlevel= 3;
}
jit= MEM_callocN((2+ jitlevel*2)*sizeof(float), "jit");
@@ -1312,7 +1312,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D
/* for small amounts of particles we use regular jitter since it looks
* a bit better, for larger amounts we switch to hammersley sequence
* because it is much faster */
- if(jitlevel < 25)
+ if (jitlevel < 25)
init_mv_jit(jit, jitlevel, psys->seed, part->jitfac);
else
hammersley_create(jit, jitlevel+1, psys->seed, part->jitfac);
@@ -1336,16 +1336,16 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D
ctx->dm= dm;
ctx->tpars= tpars;
- if(children) {
+ if (children) {
totpart= psys_render_simplify_distribution(ctx, totpart);
alloc_child_particles(psys, totpart);
}
- if(!children || psys->totchild < 10000)
+ if (!children || psys->totchild < 10000)
totthread= 1;
seed= 31415926 + ctx->sim.psys->seed;
- for(i=0; i<totthread; i++) {
+ for (i=0; i<totthread; i++) {
threads[i].rng= rng_new(seed);
threads[i].tot= totthread;
}
@@ -1363,16 +1363,16 @@ static void distribute_particles_on_dm(ParticleSimulationData *sim, int from)
pthreads= psys_threads_create(sim);
- if(!distribute_threads_init_data(pthreads, sim->scene, finaldm, from)) {
+ if (!distribute_threads_init_data(pthreads, sim->scene, finaldm, from)) {
psys_threads_free(pthreads);
return;
}
totthread= pthreads[0].tot;
- if(totthread > 1) {
+ if (totthread > 1) {
BLI_init_threads(&threads, distribute_threads_exec_cb, totthread);
- for(i=0; i<totthread; i++)
+ for (i=0; i<totthread; i++)
BLI_insert_thread(&threads, &pthreads[i]);
BLI_end_threads(&threads);
@@ -1383,7 +1383,7 @@ static void distribute_particles_on_dm(ParticleSimulationData *sim, int from)
psys_calc_dmcache(sim->ob, finaldm, sim->psys);
ctx= pthreads[0].ctx;
- if(ctx->dm != finaldm)
+ if (ctx->dm != finaldm)
ctx->dm->release(ctx->dm);
psys_threads_free(pthreads);
@@ -1402,8 +1402,8 @@ static void distribute_particles(ParticleSimulationData *sim, int from)
PARTICLE_PSMD;
int distr_error=0;
- if(psmd) {
- if(psmd->dm)
+ if (psmd) {
+ if (psmd->dm)
distribute_particles_on_dm(sim, from);
else
distr_error=1;
@@ -1411,7 +1411,7 @@ static void distribute_particles(ParticleSimulationData *sim, int from)
else
distribute_particles_on_shape(sim, from);
- if(distr_error) {
+ if (distr_error) {
distribute_invalid(sim->scene, sim->psys, from);
fprintf(stderr,"Particle distribution error!\n");
@@ -1425,7 +1425,7 @@ ParticleThread *psys_threads_create(ParticleSimulationData *sim)
ParticleThreadContext *ctx;
int i, totthread;
- if(sim->scene->r.mode & R_FIXED_THREADS)
+ if (sim->scene->r.mode & R_FIXED_THREADS)
totthread= sim->scene->r.threads;
else
totthread= BLI_system_thread_count();
@@ -1439,7 +1439,7 @@ ParticleThread *psys_threads_create(ParticleSimulationData *sim)
memset(threads, 0, sizeof(ParticleThread)*totthread);
- for(i=0; i<totthread; i++) {
+ for (i=0; i<totthread; i++) {
threads[i].ctx= ctx;
threads[i].num= i;
threads[i].tot= totthread;
@@ -1454,39 +1454,39 @@ void psys_threads_free(ParticleThread *threads)
int i, totthread= threads[0].tot;
/* path caching */
- if(ctx->vg_length)
+ if (ctx->vg_length)
MEM_freeN(ctx->vg_length);
- if(ctx->vg_clump)
+ if (ctx->vg_clump)
MEM_freeN(ctx->vg_clump);
- if(ctx->vg_kink)
+ if (ctx->vg_kink)
MEM_freeN(ctx->vg_kink);
- if(ctx->vg_rough1)
+ if (ctx->vg_rough1)
MEM_freeN(ctx->vg_rough1);
- if(ctx->vg_rough2)
+ if (ctx->vg_rough2)
MEM_freeN(ctx->vg_rough2);
- if(ctx->vg_roughe)
+ if (ctx->vg_roughe)
MEM_freeN(ctx->vg_roughe);
- if(ctx->sim.psys->lattice) {
+ if (ctx->sim.psys->lattice) {
end_latt_deform(ctx->sim.psys->lattice);
ctx->sim.psys->lattice= NULL;
}
/* distribution */
- if(ctx->jit) MEM_freeN(ctx->jit);
- if(ctx->jitoff) MEM_freeN(ctx->jitoff);
- if(ctx->weight) MEM_freeN(ctx->weight);
- if(ctx->index) MEM_freeN(ctx->index);
- if(ctx->skip) MEM_freeN(ctx->skip);
- if(ctx->seams) MEM_freeN(ctx->seams);
+ if (ctx->jit) MEM_freeN(ctx->jit);
+ if (ctx->jitoff) MEM_freeN(ctx->jitoff);
+ if (ctx->weight) MEM_freeN(ctx->weight);
+ if (ctx->index) MEM_freeN(ctx->index);
+ if (ctx->skip) MEM_freeN(ctx->skip);
+ if (ctx->seams) MEM_freeN(ctx->seams);
//if(ctx->vertpart) MEM_freeN(ctx->vertpart);
BLI_kdtree_free(ctx->tree);
/* threads */
- for(i=0; i<totthread; i++) {
- if(threads[i].rng)
+ for (i=0; i<totthread; i++) {
+ if (threads[i].rng)
rng_free(threads[i].rng);
- if(threads[i].rng_path)
+ if (threads[i].rng_path)
rng_free(threads[i].rng_path);
}
@@ -1503,10 +1503,10 @@ void initialize_particle(ParticleSimulationData *sim, ParticleData *pa, int p)
pa->flag &= ~PARS_UNEXIST;
- if(part->type != PART_FLUID) {
+ if (part->type != PART_FLUID) {
psys_get_texture(sim, pa, &ptex, PAMAP_INIT, 0.f);
- if(ptex.exist < PSYS_FRAND(p+125))
+ if (ptex.exist < PSYS_FRAND(p+125))
pa->flag |= PARS_UNEXIST;
pa->time = (part->type == PART_HAIR) ? 0.f : part->sta + (part->end - part->sta)*ptex.time;
@@ -1525,16 +1525,16 @@ static void initialize_all_particles(ParticleSimulationData *sim)
psys->totunexist = 0;
LOOP_PARTICLES {
- if((pa->flag & PARS_UNEXIST)==0)
+ if ((pa->flag & PARS_UNEXIST)==0)
initialize_particle(sim, pa, p);
- if(pa->flag & PARS_UNEXIST)
+ if (pa->flag & PARS_UNEXIST)
psys->totunexist++;
}
/* Free unexisting particles. */
- if(psys->totpart && psys->totunexist == psys->totpart) {
- if(psys->particles->boid)
+ if (psys->totpart && psys->totunexist == psys->totpart) {
+ if (psys->particles->boid)
MEM_freeN(psys->particles->boid);
MEM_freeN(psys->particles);
@@ -1542,26 +1542,26 @@ static void initialize_all_particles(ParticleSimulationData *sim)
psys->totpart = psys->totunexist = 0;
}
- if(psys->totunexist) {
+ if (psys->totunexist) {
int newtotpart = psys->totpart - psys->totunexist;
ParticleData *npa, *newpars;
npa = newpars = MEM_callocN(newtotpart * sizeof(ParticleData), "particles");
- for(p=0, pa=psys->particles; p<newtotpart; p++, pa++, npa++) {
- while(pa->flag & PARS_UNEXIST)
+ for (p=0, pa=psys->particles; p<newtotpart; p++, pa++, npa++) {
+ while (pa->flag & PARS_UNEXIST)
pa++;
memcpy(npa, pa, sizeof(ParticleData));
}
- if(psys->particles->boid)
+ if (psys->particles->boid)
MEM_freeN(psys->particles->boid);
MEM_freeN(psys->particles);
psys->particles = newpars;
psys->totpart -= psys->totunexist;
- if(psys->particles->boid) {
+ if (psys->particles->boid) {
BoidParticle *newboids = MEM_callocN(psys->totpart * sizeof(BoidParticle), "boid particles");
LOOP_PARTICLES
@@ -1623,7 +1623,7 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P
part=psys->part;
/* get birth location from object */
- if(part->tanfac != 0.f)
+ if (part->tanfac != 0.f)
psys_particle_on_emitter(sim->psmd, part->from,pa->num, pa->num_dmcache, pa->fuv,pa->foffset,loc,nor,utan,vtan,0,0);
else
psys_particle_on_emitter(sim->psmd, part->from,pa->num, pa->num_dmcache, pa->fuv,pa->foffset,loc,nor,0,0,0,0);
@@ -1641,7 +1641,7 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P
normalize_v3(nor);
/* -tangent */
- if(part->tanfac!=0.0f) {
+ if (part->tanfac!=0.0f) {
//float phase=vg_rot?2.0f*(psys_particle_value_from_verts(sim->psmd->dm,part->from,pa,vg_rot)-0.5f):0.0f;
float phase=0.0f;
mul_v3_fl(vtan,-cosf((float)M_PI*(part->tanphase+phase)));
@@ -1659,7 +1659,7 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P
/* -velocity (boids need this even if there's no random velocity) */
- if(part->randfac != 0.0f || (part->phystype==PART_PHYS_BOIDS && pa->boid)) {
+ if (part->randfac != 0.0f || (part->phystype==PART_PHYS_BOIDS && pa->boid)) {
r_vel[0] = 2.0f * (PSYS_FRAND(p + 10) - 0.5f);
r_vel[1] = 2.0f * (PSYS_FRAND(p + 11) - 0.5f);
r_vel[2] = 2.0f * (PSYS_FRAND(p + 12) - 0.5f);
@@ -1669,7 +1669,7 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P
}
/* -angular velocity */
- if(part->avemode==PART_AVE_RAND) {
+ if (part->avemode==PART_AVE_RAND) {
r_ave[0] = 2.0f * (PSYS_FRAND(p + 13) - 0.5f);
r_ave[1] = 2.0f * (PSYS_FRAND(p + 14) - 0.5f);
r_ave[2] = 2.0f * (PSYS_FRAND(p + 15) - 0.5f);
@@ -1679,7 +1679,7 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P
}
/* -rotation */
- if(part->randrotfac != 0.0f) {
+ if (part->randrotfac != 0.0f) {
r_rot[0] = 2.0f * (PSYS_FRAND(p + 16) - 0.5f);
r_rot[1] = 2.0f * (PSYS_FRAND(p + 17) - 0.5f);
r_rot[2] = 2.0f * (PSYS_FRAND(p + 18) - 0.5f);
@@ -1690,7 +1690,7 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P
mul_qt_qtqt(r_rot,r_rot,rot);
}
- if(part->phystype==PART_PHYS_BOIDS && pa->boid) {
+ if (part->phystype==PART_PHYS_BOIDS && pa->boid) {
float dvec[3], q[4], mat[3][3];
copy_v3_v3(state->co,loc);
@@ -1699,7 +1699,7 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P
zero_v3(state->vel);
/* boids store direction in ave */
- if(fabsf(nor[2])==1.0f) {
+ if (fabsf(nor[2])==1.0f) {
sub_v3_v3v3(state->ave, loc, ob->obmat[3]);
normalize_v3(state->ave);
}
@@ -1724,34 +1724,34 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P
/* -velocity from: */
/* *reactions */
- if(dtime > 0.f) {
+ if (dtime > 0.f) {
sub_v3_v3v3(vel, pa->state.vel, pa->prev_state.vel);
}
/* *emitter velocity */
- if(dtime != 0.f && part->obfac != 0.f) {
+ if (dtime != 0.f && part->obfac != 0.f) {
sub_v3_v3v3(vel, loc, state->co);
mul_v3_fl(vel, part->obfac/dtime);
}
/* *emitter normal */
- if(part->normfac != 0.f)
+ if (part->normfac != 0.f)
madd_v3_v3fl(vel, nor, part->normfac);
/* *emitter tangent */
- if(sim->psmd && part->tanfac != 0.f)
+ if (sim->psmd && part->tanfac != 0.f)
madd_v3_v3fl(vel, vtan, part->tanfac);
/* *emitter object orientation */
- if(part->ob_vel[0] != 0.f) {
+ if (part->ob_vel[0] != 0.f) {
normalize_v3_v3(vec, ob->obmat[0]);
madd_v3_v3fl(vel, vec, part->ob_vel[0]);
}
- if(part->ob_vel[1] != 0.f) {
+ if (part->ob_vel[1] != 0.f) {
normalize_v3_v3(vec, ob->obmat[1]);
madd_v3_v3fl(vel, vec, part->ob_vel[1]);
}
- if(part->ob_vel[2] != 0.f) {
+ if (part->ob_vel[2] != 0.f) {
normalize_v3_v3(vec, ob->obmat[2]);
madd_v3_v3fl(vel, vec, part->ob_vel[2]);
}
@@ -1760,11 +1760,11 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P
/* TODO */
/* *random */
- if(part->randfac != 0.f)
+ if (part->randfac != 0.f)
madd_v3_v3fl(vel, r_vel, part->randfac);
/* *particle */
- if(part->partfac != 0.f)
+ if (part->partfac != 0.f)
madd_v3_v3fl(vel, p_vel, part->partfac);
mul_v3_v3fl(state->vel, vel, ptex.ivel);
@@ -1775,7 +1775,7 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P
/* -rotation */
unit_qt(state->rot);
- if(part->rotmode) {
+ if (part->rotmode) {
/* create vector into which rotation is aligned */
switch(part->rotmode) {
case PART_ROT_NOR:
@@ -1801,14 +1801,14 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P
vec_to_quat( q2,rot_vec, OB_POSX, OB_POSZ);
/* randomize rotation quat */
- if(part->randrotfac!=0.0f)
+ if (part->randrotfac!=0.0f)
interp_qt_qtqt(rot, q2, r_rot, part->randrotfac);
else
copy_qt_qt(rot,q2);
/* rotation phase */
phasefac = part->phasefac;
- if(part->randphasefac != 0.0f)
+ if (part->randphasefac != 0.0f)
phasefac += part->randphasefac * PSYS_FRAND(p + 20);
axis_angle_to_quat( q_phase,x_vec, phasefac*(float)M_PI);
@@ -1820,8 +1820,8 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P
zero_v3(state->ave);
- if(part->avemode) {
- if(part->avemode == PART_AVE_RAND)
+ if (part->avemode) {
+ if (part->avemode == PART_AVE_RAND)
copy_v3_v3(state->ave, r_ave);
else
get_angular_velocity_vector(part->avemode, state, state->ave);
@@ -1842,9 +1842,9 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
part=psys->part;
/* get precise emitter matrix if particle is born */
- if(part->type!=PART_HAIR && dtime > 0.f && pa->time < cfra && pa->time >= sim->psys->cfra) {
+ if (part->type!=PART_HAIR && dtime > 0.f && pa->time < cfra && pa->time >= sim->psys->cfra) {
/* we have to force RECALC_ANIM here since where_is_objec_time only does drivers */
- while(ob) {
+ while (ob) {
BKE_animsys_evaluate_animdata(sim->scene, &ob->id, ob->adt, pa->time, ADT_RECALC_ANIM);
ob = ob->parent;
}
@@ -1856,13 +1856,13 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
psys_get_birth_coordinates(sim, pa, &pa->state, dtime, cfra);
- if(part->phystype==PART_PHYS_BOIDS && pa->boid) {
+ if (part->phystype==PART_PHYS_BOIDS && pa->boid) {
BoidParticle *bpa = pa->boid;
/* and gravity in r_ve */
bpa->gravity[0] = bpa->gravity[1] = 0.0f;
bpa->gravity[2] = -1.0f;
- if((sim->scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY)
+ if ((sim->scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY)
&& sim->scene->physics_settings.gravity[2]!=0.0f)
bpa->gravity[2] = sim->scene->physics_settings.gravity[2];
@@ -1873,30 +1873,30 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
}
- if(part->type == PART_HAIR) {
+ if (part->type == PART_HAIR) {
pa->lifetime = 100.0f;
}
- else{
+ else {
/* get possible textural influence */
psys_get_texture(sim, pa, &ptex, PAMAP_LIFE, cfra);
pa->lifetime = part->lifetime * ptex.life;
- if(part->randlife != 0.0f)
+ if (part->randlife != 0.0f)
pa->lifetime *= 1.0f - part->randlife * PSYS_FRAND(p + 21);
}
pa->dietime = pa->time + pa->lifetime;
- if(sim->psys->pointcache && sim->psys->pointcache->flag & PTCACHE_BAKED &&
+ if (sim->psys->pointcache && sim->psys->pointcache->flag & PTCACHE_BAKED &&
sim->psys->pointcache->mem_cache.first) {
float dietime = psys_get_dietime_from_cache(sim->psys->pointcache, p);
pa->dietime = MIN2(pa->dietime, dietime);
}
- if(pa->time > cfra)
+ if (pa->time > cfra)
pa->alive = PARS_UNBORN;
- else if(pa->dietime <= cfra)
+ else if (pa->dietime <= cfra)
pa->alive = PARS_DEAD;
else
pa->alive = PARS_ALIVE;
@@ -1908,7 +1908,7 @@ static void reset_all_particles(ParticleSimulationData *sim, float dtime, float
ParticleData *pa;
int p, totpart=sim->psys->totpart;
- for(p=from, pa=sim->psys->particles+from; p<totpart; p++, pa++)
+ for (p=from, pa=sim->psys->particles+from; p<totpart; p++, pa++)
reset_particle(sim, pa, dtime, cfra);
}
/************************************************/
@@ -1918,12 +1918,12 @@ ParticleSystem *psys_get_target_system(Object *ob, ParticleTarget *pt)
{
ParticleSystem *psys = NULL;
- if(pt->ob == NULL || pt->ob == ob)
+ if (pt->ob == NULL || pt->ob == ob)
psys = BLI_findlink(&ob->particlesystem, pt->psys-1);
else
psys = BLI_findlink(&pt->ob->particlesystem, pt->psys-1);
- if(psys)
+ if (psys)
pt->flag |= PTARGET_VALID;
else
pt->flag &= ~PTARGET_VALID;
@@ -1941,12 +1941,12 @@ void psys_count_keyed_targets(ParticleSimulationData *sim)
int keys_valid = 1;
psys->totkeyed = 0;
- for(; pt; pt=pt->next) {
+ for (; pt; pt=pt->next) {
kpsys = psys_get_target_system(sim->ob, pt);
- if(kpsys && kpsys->totpart) {
+ if (kpsys && kpsys->totpart) {
psys->totkeyed += keys_valid;
- if(psys->flag & PSYS_KEYED_TIMING && pt->duration != 0.0f)
+ if (psys->flag & PSYS_KEYED_TIMING && pt->duration != 0.0f)
psys->totkeyed += 1;
}
else {
@@ -1970,13 +1970,13 @@ static void set_keyed_keys(ParticleSimulationData *sim)
ksim.scene= sim->scene;
/* no proper targets so let's clear and bail out */
- if(psys->totkeyed==0) {
+ if (psys->totkeyed==0) {
free_keyed_keys(psys);
psys->flag &= ~PSYS_KEYED;
return;
}
- if(totpart && psys->particles->totkey != totkeys) {
+ if (totpart && psys->particles->totkey != totkeys) {
free_keyed_keys(psys);
key = MEM_callocN(totpart*totkeys*sizeof(ParticleKey), "Keyed keys");
@@ -1992,7 +1992,7 @@ static void set_keyed_keys(ParticleSimulationData *sim)
pt = psys->targets.first;
- for(k=0; k<totkeys; k++) {
+ for (k=0; k<totkeys; k++) {
ksim.ob = pt->ob ? pt->ob : sim->ob;
ksim.psys = BLI_findlink(&ksim.ob->particlesystem, pt->psys - 1);
keyed_flag = (ksim.psys->flag & PSYS_KEYED);
@@ -2004,20 +2004,20 @@ static void set_keyed_keys(ParticleSimulationData *sim)
psys_get_particle_state(&ksim, p%ksim.psys->totpart, key, 1);
- if(psys->flag & PSYS_KEYED_TIMING) {
+ if (psys->flag & PSYS_KEYED_TIMING) {
key->time = pa->time + pt->time;
- if(pt->duration != 0.0f && k+1 < totkeys) {
+ if (pt->duration != 0.0f && k+1 < totkeys) {
copy_particle_key(key+1, key, 1);
(key+1)->time = pa->time + pt->time + pt->duration;
}
}
- else if(totkeys > 1)
+ else if (totkeys > 1)
key->time = pa->time + (float)k / (float)(totkeys - 1) * pa->lifetime;
else
key->time = pa->time;
}
- if(psys->flag & PSYS_KEYED_TIMING && pt->duration!=0.0f)
+ if (psys->flag & PSYS_KEYED_TIMING && pt->duration!=0.0f)
k++;
ksim.psys->flag |= keyed_flag;
@@ -2035,7 +2035,7 @@ void psys_make_temp_pointcache(Object *ob, ParticleSystem *psys)
{
PointCache *cache = psys->pointcache;
- if(cache->flag & PTCACHE_DISK_CACHE && cache->mem_cache.first == NULL) {
+ if (cache->flag & PTCACHE_DISK_CACHE && cache->mem_cache.first == NULL) {
PTCacheID pid;
BKE_ptcache_id_from_particles(&pid, ob, psys);
cache->flag &= ~PTCACHE_DISK_CACHE;
@@ -2045,7 +2045,7 @@ void psys_make_temp_pointcache(Object *ob, ParticleSystem *psys)
}
static void psys_clear_temp_pointcache(ParticleSystem *psys)
{
- if(psys->pointcache->flag & PTCACHE_DISK_CACHE)
+ if (psys->pointcache->flag & PTCACHE_DISK_CACHE)
BKE_ptcache_free_mem(&psys->pointcache->mem_cache);
}
void psys_get_pointcache_start_end(Scene *scene, ParticleSystem *psys, int *sfra, int *efra)
@@ -2061,11 +2061,11 @@ void psys_get_pointcache_start_end(Scene *scene, ParticleSystem *psys, int *sfra
/************************************************/
static void psys_update_particle_bvhtree(ParticleSystem *psys, float cfra)
{
- if(psys) {
+ if (psys) {
PARTICLE_P;
int totpart = 0;
- if(!psys->bvhtree || psys->bvhtree_frame != cfra) {
+ if (!psys->bvhtree || psys->bvhtree_frame != cfra) {
LOOP_SHOWN_PARTICLES {
totpart++;
}
@@ -2074,8 +2074,8 @@ static void psys_update_particle_bvhtree(ParticleSystem *psys, float cfra)
psys->bvhtree = BLI_bvhtree_new(totpart, 0.0, 4, 6);
LOOP_SHOWN_PARTICLES {
- if(pa->alive == PARS_ALIVE) {
- if(pa->state.time == cfra)
+ if (pa->alive == PARS_ALIVE) {
+ if (pa->state.time == cfra)
BLI_bvhtree_insert(psys->bvhtree, p, pa->prev_state.co, 1);
else
BLI_bvhtree_insert(psys->bvhtree, p, pa->state.co, 1);
@@ -2089,11 +2089,11 @@ static void psys_update_particle_bvhtree(ParticleSystem *psys, float cfra)
}
void psys_update_particle_tree(ParticleSystem *psys, float cfra)
{
- if(psys) {
+ if (psys) {
PARTICLE_P;
int totpart = 0;
- if(!psys->tree || psys->tree_frame != cfra) {
+ if (!psys->tree || psys->tree_frame != cfra) {
LOOP_SHOWN_PARTICLES {
totpart++;
}
@@ -2102,8 +2102,8 @@ void psys_update_particle_tree(ParticleSystem *psys, float cfra)
psys->tree = BLI_kdtree_new(psys->totpart);
LOOP_SHOWN_PARTICLES {
- if(pa->alive == PARS_ALIVE) {
- if(pa->state.time == cfra)
+ if (pa->alive == PARS_ALIVE) {
+ if (pa->state.time == cfra)
BLI_kdtree_insert(psys->tree, p, pa->prev_state.co, NULL);
else
BLI_kdtree_insert(psys->tree, p, pa->state.co, NULL);
@@ -2134,7 +2134,7 @@ static void integrate_particle(ParticleSettings *part, ParticleData *pa, float d
copy_v3_v3(oldpos, pa->state.co);
/* Verlet integration behaves strangely with moving emitters, so do first step with euler. */
- if(pa->prev_state.time < 0.f && integrator == PART_INT_VERLET)
+ if (pa->prev_state.time < 0.f && integrator == PART_INT_VERLET)
integrator = PART_INT_EULER;
switch(integrator) {
@@ -2156,7 +2156,7 @@ static void integrate_particle(ParticleSettings *part, ParticleData *pa, float d
states->time = 0.f;
- for(i=0; i<steps; i++) {
+ for (i=0; i<steps; i++) {
zero_v3(force);
zero_v3(impulse);
@@ -2165,7 +2165,7 @@ static void integrate_particle(ParticleSettings *part, ParticleData *pa, float d
/* force to acceleration*/
mul_v3_v3fl(acceleration, force, 1.0f/pa_mass);
- if(external_acceleration)
+ if (external_acceleration)
add_v3_v3(acceleration, external_acceleration);
/* calculate next state */
@@ -2177,13 +2177,13 @@ static void integrate_particle(ParticleSettings *part, ParticleData *pa, float d
madd_v3_v3v3fl(pa->state.vel, states->vel, acceleration, dtime);
break;
case PART_INT_MIDPOINT:
- if(i==0) {
+ if (i==0) {
madd_v3_v3v3fl(states[1].co, states->co, states->vel, dtime*0.5f);
madd_v3_v3v3fl(states[1].vel, states->vel, acceleration, dtime*0.5f);
states[1].time = dtime*0.5f;
/*fra=sim->psys->cfra+0.5f*dfra;*/
}
- else{
+ else {
madd_v3_v3v3fl(pa->state.co, states->co, states[1].vel, dtime);
madd_v3_v3v3fl(pa->state.vel, states->vel, acceleration, dtime);
}
@@ -2268,11 +2268,11 @@ static void integrate_particle(ParticleSettings *part, ParticleData *pa, float d
static ParticleSpring *sph_spring_add(ParticleSystem *psys, ParticleSpring *spring)
{
/* Are more refs required? */
- if(psys->alloc_fluidsprings == 0 || psys->fluid_springs == NULL) {
+ if (psys->alloc_fluidsprings == 0 || psys->fluid_springs == NULL) {
psys->alloc_fluidsprings = PSYS_FLUID_SPRINGS_INITIAL_SIZE;
psys->fluid_springs = (ParticleSpring*)MEM_callocN(psys->alloc_fluidsprings * sizeof(ParticleSpring), "Particle Fluid Springs");
}
- else if(psys->tot_fluidsprings == psys->alloc_fluidsprings) {
+ else if (psys->tot_fluidsprings == psys->alloc_fluidsprings) {
/* Double the number of refs allocated */
psys->alloc_fluidsprings *= 2;
psys->fluid_springs = (ParticleSpring*)MEM_reallocN(psys->fluid_springs, psys->alloc_fluidsprings * sizeof(ParticleSpring));
@@ -2309,11 +2309,11 @@ static void sph_springs_modify(ParticleSystem *psys, float dtime)
/* scale things according to dtime */
float timefix = 25.f * dtime;
- if((fluid->flag & SPH_VISCOELASTIC_SPRINGS)==0 || fluid->spring_k == 0.f)
+ if ((fluid->flag & SPH_VISCOELASTIC_SPRINGS)==0 || fluid->spring_k == 0.f)
return;
/* Loop through the springs */
- for(i=0; i<psys->tot_fluidsprings; i++, spring++) {
+ for (i=0; i<psys->tot_fluidsprings; i++, spring++) {
pa1 = psys->particles + spring->particle_index[0];
pa2 = psys->particles + spring->particle_index[1];
@@ -2326,18 +2326,18 @@ static void sph_springs_modify(ParticleSystem *psys, float dtime)
if (rij > Lij + d) // Stretch
spring->rest_length += plasticity * (rij - Lij - d) * timefix;
- else if(rij < Lij - d) // Compress
+ else if (rij < Lij - d) // Compress
spring->rest_length -= plasticity * (Lij - d - rij) * timefix;
h = 4.f*pa1->size;
- if(spring->rest_length > h)
+ if (spring->rest_length > h)
spring->delete_flag = 1;
}
/* Loop through springs backwaqrds - for efficient delete function */
for (i=psys->tot_fluidsprings-1; i >= 0; i--) {
- if(psys->fluid_springs[i].delete_flag)
+ if (psys->fluid_springs[i].delete_flag)
sph_spring_delete(psys, i);
}
}
@@ -2349,7 +2349,7 @@ static EdgeHash *sph_springhash_build(ParticleSystem *psys)
springhash = BLI_edgehash_new();
- for(i=0, spring=psys->fluid_springs; i<psys->tot_fluidsprings; i++, spring++)
+ for (i=0, spring=psys->fluid_springs; i<psys->tot_fluidsprings; i++, spring++)
BLI_edgehash_insert(springhash, spring->particle_index[0], spring->particle_index[1], SET_INT_IN_POINTER(i+1));
return springhash;
@@ -2399,7 +2399,7 @@ static void sph_density_accum_cb(void *userdata, int index, float squared_dist)
float q;
float dist;
- if(npa == pfr->pa || squared_dist < FLT_EPSILON)
+ if (npa == pfr->pa || squared_dist < FLT_EPSILON)
return;
/* Ugh! One particle has too many neighbors! If some aren't taken into
@@ -2408,7 +2408,7 @@ static void sph_density_accum_cb(void *userdata, int index, float squared_dist)
* But, we have to stop somewhere, and it's not the end of the world.
* - jahka and z0r
*/
- if(pfr->tot_neighbors >= SPH_NEIGHBORS)
+ if (pfr->tot_neighbors >= SPH_NEIGHBORS)
return;
pfr->neighbors[pfr->tot_neighbors].index = index;
@@ -2418,7 +2418,7 @@ static void sph_density_accum_cb(void *userdata, int index, float squared_dist)
dist = sqrtf(squared_dist);
q = (1.f - dist/pfr->h) * pfr->massfac;
- if(pfr->use_size)
+ if (pfr->use_size)
q *= npa->size;
pfr->density += q*q;
@@ -2447,7 +2447,8 @@ static void sph_particle_courant(SPHData *sphdata, SPHRangeData *pfr)
dist += sphdata->psys[0]->part->fluid->radius; // TODO: remove this? - z0r
sphdata->element_size = dist / pfr->tot_neighbors;
mul_v3_v3fl(sphdata->flow, flow, 1.0f / pfr->tot_neighbors);
- } else {
+ }
+ else {
sphdata->element_size = MAXFLOAT;
copy_v3_v3(sphdata->flow, flow);
}
@@ -2493,7 +2494,7 @@ static void sph_force_cb(void *sphdata_v, ParticleKey *state, float *force, floa
pfr.h = h;
pfr.pa = pa;
- for(i=0; i<10 && psys[i]; i++) {
+ for (i=0; i<10 && psys[i]; i++) {
pfr.npsys = psys[i];
pfr.massfac = psys[i]->part->mass*inv_mass;
pfr.use_size = psys[i]->part->flag & PART_SIZEMASS;
@@ -2505,7 +2506,7 @@ static void sph_force_cb(void *sphdata_v, ParticleKey *state, float *force, floa
near_pressure = stiffness_near_fac * pfr.near_density;
pfn = pfr.neighbors;
- for(i=0; i<pfr.tot_neighbors; i++, pfn++) {
+ for (i=0; i<pfr.tot_neighbors; i++, pfn++) {
npa = pfn->psys->particles + pfn->index;
madd_v3_v3v3fl(co, npa->prev_state.co, npa->prev_state.vel, state->time);
@@ -2515,7 +2516,7 @@ static void sph_force_cb(void *sphdata_v, ParticleKey *state, float *force, floa
q = (1.f - rij/h) * pfn->psys->part->mass * inv_mass;
- if(pfn->psys->part->flag & PART_SIZEMASS)
+ if (pfn->psys->part->flag & PART_SIZEMASS)
q *= npa->size;
copy_v3_v3(vel, npa->prev_state.vel);
@@ -2524,29 +2525,29 @@ static void sph_force_cb(void *sphdata_v, ParticleKey *state, float *force, floa
madd_v3_v3fl(force, vec, -(pressure + near_pressure*q)*q);
/* Viscosity */
- if(visc > 0.f || stiff_visc > 0.f) {
+ if (visc > 0.f || stiff_visc > 0.f) {
sub_v3_v3v3(dv, vel, state->vel);
u = dot_v3v3(vec, dv);
- if(u < 0.f && visc > 0.f)
+ if (u < 0.f && visc > 0.f)
madd_v3_v3fl(force, vec, 0.5f * q * visc * u );
- if(u > 0.f && stiff_visc > 0.f)
+ if (u > 0.f && stiff_visc > 0.f)
madd_v3_v3fl(force, vec, 0.5f * q * stiff_visc * u );
}
- if(spring_constant > 0.f) {
+ if (spring_constant > 0.f) {
/* Viscoelastic spring force */
if (pfn->psys == psys[0] && fluid->flag & SPH_VISCOELASTIC_SPRINGS && springhash) {
/* BLI_edgehash_lookup appears to be thread-safe. - z0r */
spring_index = GET_INT_FROM_POINTER(BLI_edgehash_lookup(springhash, index, pfn->index));
- if(spring_index) {
+ if (spring_index) {
spring = psys[0]->fluid_springs + spring_index - 1;
madd_v3_v3fl(force, vec, -10.f * spring_constant * (1.f - rij/h) * (spring->rest_length - rij));
}
- else if(fluid->spring_frames == 0 || (pa->prev_state.time-pa->time) <= fluid->spring_frames) {
+ else if (fluid->spring_frames == 0 || (pa->prev_state.time-pa->time) <= fluid->spring_frames) {
ParticleSpring temp_spring;
temp_spring.particle_index[0] = index;
temp_spring.particle_index[1] = pfn->index;
@@ -2580,7 +2581,7 @@ static void sph_solver_init(ParticleSimulationData *sim, SPHData *sphdata)
// Add other coupled particle systems.
sphdata->psys[0] = sim->psys;
- for(i=1, pt=sim->psys->targets.first; i<10; i++, pt=(pt?pt->next:NULL))
+ for (i=1, pt=sim->psys->targets.first; i<10; i++, pt=(pt?pt->next:NULL))
sphdata->psys[i] = pt ? psys_get_target_system(sim->ob, pt) : NULL;
if (psys_uses_gravity(sim))
@@ -2648,18 +2649,18 @@ static void basic_force_cb(void *efdata_v, ParticleKey *state, float *force, flo
/* add effectors */
pd_point_from_particle(efdata->sim, efdata->pa, state, &epoint);
- if(part->type != PART_HAIR || part->effector_weights->flag & EFF_WEIGHT_DO_HAIR)
+ if (part->type != PART_HAIR || part->effector_weights->flag & EFF_WEIGHT_DO_HAIR)
pdDoEffectors(sim->psys->effectors, sim->colliders, part->effector_weights, &epoint, force, impulse);
mul_v3_fl(force, efdata->ptex.field);
mul_v3_fl(impulse, efdata->ptex.field);
/* calculate air-particle interaction */
- if(part->dragfac != 0.0f)
+ if (part->dragfac != 0.0f)
madd_v3_v3fl(force, state->vel, -part->dragfac * pa->size * pa->size * len_v3(state->vel));
/* brownian force */
- if(part->brownfac != 0.0f) {
+ if (part->brownfac != 0.0f) {
force[0] += (BLI_frand()-0.5f) * part->brownfac;
force[1] += (BLI_frand()-0.5f) * part->brownfac;
force[2] += (BLI_frand()-0.5f) * part->brownfac;
@@ -2681,7 +2682,7 @@ static void basic_integrate(ParticleSimulationData *sim, int p, float dfra, floa
efdata.sim = sim;
/* add global acceleration (gravitation) */
- if(psys_uses_gravity(sim)
+ if (psys_uses_gravity(sim)
/* normal gravity is too strong for hair so it's disabled by default */
&& (part->type != PART_HAIR || part->effector_weights->flag & EFF_WEIGHT_DO_HAIR)) {
zero_v3(gr);
@@ -2695,7 +2696,7 @@ static void basic_integrate(ParticleSimulationData *sim, int p, float dfra, floa
integrate_particle(part, pa, dtime, gravity, basic_force_cb, &efdata);
/* damp affects final velocity */
- if(part->dampfac != 0.f)
+ if (part->dampfac != 0.f)
mul_v3_fl(pa->state.vel, 1.f - part->dampfac * efdata.ptex.damp * 25.f * dtime);
//copy_v3_v3(pa->state.ave, states->ave);
@@ -2708,8 +2709,8 @@ static void basic_integrate(ParticleSimulationData *sim, int p, float dfra, floa
copy_v3_v3(tkey.vel,pa->state.vel);
tkey.time=pa->state.time;
- if(part->type != PART_HAIR) {
- if(do_guides(sim->psys->effectors, &tkey, p, time)) {
+ if (part->type != PART_HAIR) {
+ if (do_guides(sim->psys->effectors, &tkey, p, time)) {
copy_v3_v3(pa->state.co,tkey.co);
/* guides don't produce valid velocity */
sub_v3_v3v3(pa->state.vel, tkey.co, pa->prev_state.co);
@@ -2722,21 +2723,21 @@ static void basic_rotate(ParticleSettings *part, ParticleData *pa, float dfra, f
{
float rotfac, rot1[4], rot2[4]={1.0,0.0,0.0,0.0}, dtime=dfra*timestep;
- if((part->flag & PART_ROTATIONS)==0) {
+ if ((part->flag & PART_ROTATIONS)==0) {
pa->state.rot[0]=1.0f;
pa->state.rot[1]=pa->state.rot[2]=pa->state.rot[3]=0;
return;
}
- if((part->flag & PART_ROT_DYN)==0 && ELEM3(part->avemode, PART_AVE_VELOCITY, PART_AVE_HORIZONTAL, PART_AVE_VERTICAL)) {
+ if ((part->flag & PART_ROT_DYN)==0 && ELEM3(part->avemode, PART_AVE_VELOCITY, PART_AVE_HORIZONTAL, PART_AVE_VERTICAL)) {
float angle;
float len1 = len_v3(pa->prev_state.vel);
float len2 = len_v3(pa->state.vel);
float vec[3];
- if(len1==0.0f || len2==0.0f)
+ if (len1==0.0f || len2==0.0f)
pa->state.ave[0] = pa->state.ave[1] = pa->state.ave[2] = 0.0f;
- else{
+ else {
cross_v3_v3v3(pa->state.ave, pa->prev_state.vel, pa->state.vel);
normalize_v3(pa->state.ave);
angle = dot_v3v3(pa->prev_state.vel, pa->state.vel) / (len1 * len2);
@@ -2748,11 +2749,11 @@ static void basic_rotate(ParticleSettings *part, ParticleData *pa, float dfra, f
}
rotfac = len_v3(pa->state.ave);
- if(rotfac == 0.0f) { /* unit_qt(in VecRotToQuat) doesn't give unit quat [1,0,0,0]?? */
+ if (rotfac == 0.0f) { /* unit_qt(in VecRotToQuat) doesn't give unit quat [1,0,0,0]?? */
rot1[0]=1.0f;
rot1[1]=rot1[2]=rot1[3]=0;
}
- else{
+ else {
axis_angle_to_quat(rot1,pa->state.ave,rotfac*dtime);
}
mul_qt_qtqt(pa->state.rot,rot1,pa->prev_state.rot);
@@ -2783,14 +2784,14 @@ static float nr_signed_distance_to_plane(float *p, float radius, ParticleCollisi
d = dot_v3v3(p0, nor);
- if(pce->inv_nor == -1) {
- if(d < 0.f)
+ if (pce->inv_nor == -1) {
+ if (d < 0.f)
pce->inv_nor = 1;
else
pce->inv_nor = 0;
}
- if(pce->inv_nor == 1) {
+ if (pce->inv_nor == 1) {
negate_v3(nor);
d = -d;
}
@@ -2820,13 +2821,13 @@ static void collision_interpolate_element(ParticleCollisionElement *pce, float t
/* the col->fac's are factors for the particle subframe step start and end during collision modifier step */
float f = fac + t*(1.f-fac);
float mul = col->fac1 + f * (col->fac2-col->fac1);
- if(pce->tot > 0) {
+ if (pce->tot > 0) {
madd_v3_v3v3fl(pce->x0, pce->x[0], pce->v[0], mul);
- if(pce->tot > 1) {
+ if (pce->tot > 1) {
madd_v3_v3v3fl(pce->x1, pce->x[1], pce->v[1], mul);
- if(pce->tot > 2)
+ if (pce->tot > 2)
madd_v3_v3v3fl(pce->x2, pce->x[2], pce->v[2], mul);
}
}
@@ -2837,11 +2838,11 @@ static void collision_point_velocity(ParticleCollisionElement *pce)
copy_v3_v3(pce->vel, pce->v[0]);
- if(pce->tot > 1) {
+ if (pce->tot > 1) {
sub_v3_v3v3(v, pce->v[1], pce->v[0]);
madd_v3_v3fl(pce->vel, v, pce->uv[0]);
- if(pce->tot > 2) {
+ if (pce->tot > 2) {
sub_v3_v3v3(v, pce->v[2], pce->v[0]);
madd_v3_v3fl(pce->vel, v, pce->uv[1]);
}
@@ -2849,7 +2850,7 @@ static void collision_point_velocity(ParticleCollisionElement *pce)
}
static float collision_point_distance_with_normal(float p[3], ParticleCollisionElement *pce, float fac, ParticleCollision *col, float *nor)
{
- if(fac >= 0.f)
+ if (fac >= 0.f)
collision_interpolate_element(pce, 0.f, fac, col);
switch(pce->tot) {
@@ -2910,7 +2911,7 @@ static void collision_point_on_surface(float p[3], ParticleCollisionElement *pce
cross_v3_v3v3(nor, e1, e2);
normalize_v3(nor);
- if(pce->inv_nor == 1)
+ if (pce->inv_nor == 1)
negate_v3(nor);
madd_v3_v3v3fl(co, pce->x0, nor, col->radius);
@@ -2935,7 +2936,7 @@ static float collision_newton_rhapson(ParticleCollision *col, float radius, Part
t1 = 0.001f;
d1 = 0.f;
- for(iter=0; iter<10; iter++) {//, itersum++) {
+ for (iter=0; iter<10; iter++) {//, itersum++) {
/* get current location */
collision_interpolate_element(pce, t1, col->f, col);
interp_v3_v3v3(pce->p, col->co1, col->co2, t1);
@@ -2943,12 +2944,12 @@ static float collision_newton_rhapson(ParticleCollision *col, float radius, Part
d1 = distance_func(pce->p, radius, pce, n);
/* no movement, so no collision */
- if(d1 == d0) {
+ if (d1 == d0) {
return -1.f;
}
/* particle already inside face, so report collision */
- if(iter == 0 && d0 < 0.f && d0 > -radius) {
+ if (iter == 0 && d0 < 0.f && d0 > -radius) {
copy_v3_v3(pce->p, col->co1);
copy_v3_v3(pce->nor, n);
pce->inside = 1;
@@ -2963,7 +2964,7 @@ static float collision_newton_rhapson(ParticleCollision *col, float radius, Part
t1 -= d1*dd;
/* particle movin away from plane could also mean a strangely rotating face, so check from end */
- if(iter == 0 && t1 < 0.f) {
+ if (iter == 0 && t1 < 0.f) {
t0 = 1.f;
collision_interpolate_element(pce, t0, col->f, col);
d0 = distance_func(col->co2, radius, pce, n);
@@ -2972,12 +2973,12 @@ static float collision_newton_rhapson(ParticleCollision *col, float radius, Part
continue;
}
- else if(iter == 1 && (t1 < -COLLISION_ZERO || t1 > 1.f))
+ else if (iter == 1 && (t1 < -COLLISION_ZERO || t1 > 1.f))
return -1.f;
- if(d1 <= COLLISION_ZERO && d1 >= -COLLISION_ZERO) {
- if(t1 >= -COLLISION_ZERO && t1 <= 1.f) {
- if(distance_func == nr_signed_distance_to_plane)
+ if (d1 <= COLLISION_ZERO && d1 >= -COLLISION_ZERO) {
+ if (t1 >= -COLLISION_ZERO && t1 <= 1.f) {
+ if (distance_func == nr_signed_distance_to_plane)
copy_v3_v3(pce->nor, n);
CLAMP(t1, 0.f, 1.f);
@@ -3000,7 +3001,7 @@ static int collision_sphere_to_tri(ParticleCollision *col, float radius, Particl
ct = collision_newton_rhapson(col, radius, pce, nr_signed_distance_to_plane);
- if(ct >= 0.f && ct < *t && (result->inside==0 || pce->inside==1) ) {
+ if (ct >= 0.f && ct < *t && (result->inside==0 || pce->inside==1) ) {
float e1[3], e2[3], p0[3];
float e1e1, e1e2, e1p0, e2e2, e2p0, inv;
@@ -3019,7 +3020,7 @@ static int collision_sphere_to_tri(ParticleCollision *col, float radius, Particl
u = (e2e2 * e1p0 - e1e2 * e2p0) * inv;
v = (e1e1 * e2p0 - e1e2 * e1p0) * inv;
- if(u>=0.f && u<=1.f && v>=0.f && u+v<=1.f) {
+ if (u>=0.f && u<=1.f && v>=0.f && u+v<=1.f) {
*result = *pce;
/* normal already calculated in pce */
@@ -3041,9 +3042,9 @@ static int collision_sphere_to_edges(ParticleCollision *col, float radius, Parti
float ct;
int i;
- for(i=0; i<3; i++) {
+ for (i=0; i<3; i++) {
/* in case of a quad, no need to check "edge" that goes through face twice */
- if((pce->x[3] && i==2))
+ if ((pce->x[3] && i==2))
continue;
cur = edge+i;
@@ -3054,14 +3055,14 @@ static int collision_sphere_to_edges(ParticleCollision *col, float radius, Parti
ct = collision_newton_rhapson(col, radius, cur, nr_distance_to_edge);
- if(ct >= 0.f && ct < *t) {
+ if (ct >= 0.f && ct < *t) {
float u, e[3], vec[3];
sub_v3_v3v3(e, cur->x1, cur->x0);
sub_v3_v3v3(vec, cur->p, cur->x0);
u = dot_v3v3(vec, e) / dot_v3v3(e, e);
- if(u < 0.f || u > 1.f)
+ if (u < 0.f || u > 1.f)
break;
*result = *cur;
@@ -3088,9 +3089,9 @@ static int collision_sphere_to_verts(ParticleCollision *col, float radius, Parti
float ct;
int i;
- for(i=0; i<3; i++) {
+ for (i=0; i<3; i++) {
/* in case of quad, only check one vert the first time */
- if(pce->x[3] && i != 1)
+ if (pce->x[3] && i != 1)
continue;
cur = vert+i;
@@ -3101,7 +3102,7 @@ static int collision_sphere_to_verts(ParticleCollision *col, float radius, Parti
ct = collision_newton_rhapson(col, radius, cur, nr_distance_to_vert);
- if(ct >= 0.f && ct < *t) {
+ if (ct >= 0.f && ct < *t) {
*result = *cur;
sub_v3_v3v3(result->nor, cur->p, cur->x0);
@@ -3141,18 +3142,18 @@ void BKE_psys_collision_neartest_cb(void *userdata, int index, const BVHTreeRay
pce.index = index;
/* don't collide with same face again */
- if(col->hit == col->current && col->pce.index == index && col->pce.tot == 3)
+ if (col->hit == col->current && col->pce.index == index && col->pce.tot == 3)
return;
do
{
collision = collision_sphere_to_tri(col, ray->radius, &pce, &t);
- if(col->pce.inside == 0) {
+ if (col->pce.inside == 0) {
collision += collision_sphere_to_edges(col, ray->radius, &pce, &t);
collision += collision_sphere_to_verts(col, ray->radius, &pce, &t);
}
- if(collision) {
+ if (collision) {
hit->dist = col->original_ray_length * t;
hit->index = index;
@@ -3169,14 +3170,14 @@ void BKE_psys_collision_neartest_cb(void *userdata, int index, const BVHTreeRay
pce.v[2] = pce.v[3];
pce.v[3] = NULL;
- } while(pce.x[2]);
+ } while (pce.x[2]);
}
static int collision_detect(ParticleData *pa, ParticleCollision *col, BVHTreeRayHit *hit, ListBase *colliders)
{
ColliderCache *coll;
float ray_dir[3];
- if(colliders->first == NULL)
+ if (colliders->first == NULL)
return 0;
sub_v3_v3v3(ray_dir, col->co2, col->co1);
@@ -3186,16 +3187,16 @@ static int collision_detect(ParticleData *pa, ParticleCollision *col, BVHTreeRay
/* even if particle is stationary we want to check for moving colliders */
/* if hit.dist is zero the bvhtree_ray_cast will just ignore everything */
- if(hit->dist == 0.0f)
+ if (hit->dist == 0.0f)
hit->dist = col->original_ray_length = 0.000001f;
- for(coll = colliders->first; coll; coll=coll->next) {
+ for (coll = colliders->first; coll; coll=coll->next) {
/* for boids: don't check with current ground object */
- if(coll->ob == col->skip)
+ if (coll->ob == col->skip)
continue;
/* particles should not collide with emitter at birth */
- if(coll->ob == col->emitter && pa->time < col->cfra && pa->time >= col->old_cfra)
+ if (coll->ob == col->emitter && pa->time < col->cfra && pa->time >= col->old_cfra)
continue;
col->current = coll->ob;
@@ -3203,7 +3204,7 @@ static int collision_detect(ParticleData *pa, ParticleCollision *col, BVHTreeRay
col->fac1 = (col->old_cfra - coll->collmd->time_x) / (coll->collmd->time_xnew - coll->collmd->time_x);
col->fac2 = (col->cfra - coll->collmd->time_x) / (coll->collmd->time_xnew - coll->collmd->time_x);
- if(col->md && col->md->bvhtree)
+ if (col->md && col->md->bvhtree)
BLI_bvhtree_ray_cast(col->md->bvhtree, col->co1, ray_dir, col->radius, hit, BKE_psys_collision_neartest_cb, col);
}
@@ -3224,7 +3225,7 @@ static int collision_response(ParticleData *pa, ParticleCollision *col, BVHTreeR
interp_v3_v3v3(co, col->co1, col->co2, x);
/* particle dies in collision */
- if(through == 0 && (kill || pd->flag & PDEFLE_KILL_PART)) {
+ if (through == 0 && (kill || pd->flag & PDEFLE_KILL_PART)) {
pa->alive = PARS_DYING;
pa->dietime = col->old_cfra + (col->cfra - col->old_cfra) * f;
@@ -3265,9 +3266,9 @@ static int collision_response(ParticleData *pa, ParticleCollision *col, BVHTreeR
madd_v3_v3v3fl(vc_tan, pce->vel, pce->nor, -vc_dot);
/* handle friction effects (tangential and angular velocity) */
- if(frict > 0.0f) {
+ if (frict > 0.0f) {
/* angular <-> linear velocity */
- if(dynamic_rotation) {
+ if (dynamic_rotation) {
float vr_tan[3], v1_tan[3], ave[3];
/* linear velocity of particle surface */
@@ -3309,9 +3310,9 @@ static int collision_response(ParticleData *pa, ParticleCollision *col, BVHTreeR
/* stickness was possibly added before, so cancel that before calculating new normal velocity */
/* otherwise particles go flying out of the surface because of high reversed sticky velocity */
- if(v0_dot < 0.0f) {
+ if (v0_dot < 0.0f) {
v0_dot += pd->pdef_stickness;
- if(v0_dot > 0.0f)
+ if (v0_dot > 0.0f)
v0_dot = 0.0f;
}
@@ -3321,9 +3322,9 @@ static int collision_response(ParticleData *pa, ParticleCollision *col, BVHTreeR
/* calculate normal particle velocity */
/* special case for object hitting the particle from behind */
- if(through==0 && ((vc_dot>0.0f && v0_dot>0.0f && vc_dot>v0_dot) || (vc_dot<0.0f && v0_dot<0.0f && vc_dot<v0_dot)))
+ if (through==0 && ((vc_dot>0.0f && v0_dot>0.0f && vc_dot>v0_dot) || (vc_dot<0.0f && v0_dot<0.0f && vc_dot<v0_dot)))
mul_v3_v3fl(v0_nor, pce->nor, vc_dot);
- else if(v0_dot > 0.f)
+ else if (v0_dot > 0.f)
mul_v3_v3fl(v0_nor, pce->nor, vc_dot + (through ? -1.0f : 1.0f) * v0_dot);
else
mul_v3_v3fl(v0_nor, pce->nor, vc_dot + (through ? 1.0f : -1.0f) * v0_dot);
@@ -3331,10 +3332,10 @@ static int collision_response(ParticleData *pa, ParticleCollision *col, BVHTreeR
/* combine components together again */
add_v3_v3v3(v0, v0_nor, v0_tan);
- if(col->boid) {
+ if (col->boid) {
/* keep boids above ground */
BoidParticle *bpa = pa->boid;
- if(bpa->data.mode == eBoidMode_OnLand || co[2] <= col->boid_z) {
+ if (bpa->data.mode == eBoidMode_OnLand || co[2] <= col->boid_z) {
co[2] = col->boid_z;
v0[2] = 0.0f;
}
@@ -3346,23 +3347,23 @@ static int collision_response(ParticleData *pa, ParticleCollision *col, BVHTreeR
madd_v3_v3v3fl(pa->state.vel, v0, col->acc, dt2);
/* make sure particle stays on the right side of the surface */
- if(!through) {
+ if (!through) {
distance = collision_point_distance_with_normal(co, pce, -1.f, col, nor);
- if(distance < col->radius + COLLISION_MIN_DISTANCE)
+ if (distance < col->radius + COLLISION_MIN_DISTANCE)
madd_v3_v3fl(co, nor, col->radius + COLLISION_MIN_DISTANCE - distance);
dot = dot_v3v3(nor, v0);
- if(dot < 0.f)
+ if (dot < 0.f)
madd_v3_v3fl(v0, nor, -dot);
distance = collision_point_distance_with_normal(pa->state.co, pce, 1.f, col, nor);
- if(distance < col->radius + COLLISION_MIN_DISTANCE)
+ if (distance < col->radius + COLLISION_MIN_DISTANCE)
madd_v3_v3fl(pa->state.co, nor, col->radius + COLLISION_MIN_DISTANCE - distance);
dot = dot_v3v3(nor, pa->state.vel);
- if(dot < 0.f)
+ if (dot < 0.f)
madd_v3_v3fl(pa->state.vel, nor, -dot);
}
@@ -3437,21 +3438,21 @@ static void collision_check(ParticleSimulationData *sim, int p, float dfra, floa
col.radius = ((part->flag & PART_SIZE_DEFL) || (part->phystype == PART_PHYS_BOIDS)) ? pa->size : COLLISION_MIN_RADIUS;
/* override for boids */
- if(part->phystype == PART_PHYS_BOIDS && part->boids->options & BOID_ALLOW_LAND) {
+ if (part->phystype == PART_PHYS_BOIDS && part->boids->options & BOID_ALLOW_LAND) {
col.boid = 1;
col.boid_z = pa->state.co[2];
col.skip = pa->boid->ground;
}
/* 10 iterations to catch multiple collisions */
- while(collision_count < COLLISION_MAX_COLLISIONS) {
- if(collision_detect(pa, &col, &hit, sim->colliders)) {
+ while (collision_count < COLLISION_MAX_COLLISIONS) {
+ if (collision_detect(pa, &col, &hit, sim->colliders)) {
collision_count++;
- if(collision_count == COLLISION_MAX_COLLISIONS)
+ if (collision_count == COLLISION_MAX_COLLISIONS)
collision_fail(pa, &col);
- else if(collision_response(pa, &col, &hit, part->flag & PART_DIE_ON_COL, part->flag & PART_ROT_DYN)==0)
+ else if (collision_response(pa, &col, &hit, part->flag & PART_DIE_ON_COL, part->flag & PART_ROT_DYN)==0)
return;
}
else
@@ -3470,22 +3471,22 @@ static void psys_update_path_cache(ParticleSimulationData *sim, float cfra)
Base *base;
int distr=0, alloc=0, skip=0;
- if((psys->part->childtype && psys->totchild != get_psys_tot_child(sim->scene, psys)) || psys->recalc&PSYS_RECALC_RESET)
+ if ((psys->part->childtype && psys->totchild != get_psys_tot_child(sim->scene, psys)) || psys->recalc&PSYS_RECALC_RESET)
alloc=1;
- if(alloc || psys->recalc&PSYS_RECALC_CHILD || (psys->vgroup[PSYS_VG_DENSITY] && (sim->ob && sim->ob->mode & OB_MODE_WEIGHT_PAINT)))
+ if (alloc || psys->recalc&PSYS_RECALC_CHILD || (psys->vgroup[PSYS_VG_DENSITY] && (sim->ob && sim->ob->mode & OB_MODE_WEIGHT_PAINT)))
distr=1;
- if(distr) {
- if(alloc)
+ if (distr) {
+ if (alloc)
realloc_particles(sim, sim->psys->totpart);
- if(get_psys_tot_child(sim->scene, psys)) {
+ if (get_psys_tot_child(sim->scene, psys)) {
/* don't generate children while computing the hair keys */
- if(!(psys->part->type == PART_HAIR) || (psys->flag & PSYS_HAIR_DONE)) {
+ if (!(psys->part->type == PART_HAIR) || (psys->flag & PSYS_HAIR_DONE)) {
distribute_particles(sim, PART_FROM_CHILD);
- if(part->childtype==PART_CHILD_FACES && part->parents != 0.0f)
+ if (part->childtype==PART_CHILD_FACES && part->parents != 0.0f)
psys_find_parents(sim);
}
}
@@ -3493,19 +3494,19 @@ static void psys_update_path_cache(ParticleSimulationData *sim, float cfra)
psys_free_children(psys);
}
- if((part->type==PART_HAIR || psys->flag&PSYS_KEYED || psys->pointcache->flag & PTCACHE_BAKED)==0)
+ if ((part->type==PART_HAIR || psys->flag&PSYS_KEYED || psys->pointcache->flag & PTCACHE_BAKED)==0)
skip = 1; /* only hair, keyed and baked stuff can have paths */
- else if(part->ren_as != PART_DRAW_PATH && !(part->type==PART_HAIR && ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR)))
+ else if (part->ren_as != PART_DRAW_PATH && !(part->type==PART_HAIR && ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR)))
skip = 1; /* particle visualization must be set as path */
- else if(!psys->renderdata) {
- if(part->draw_as != PART_DRAW_REND)
+ else if (!psys->renderdata) {
+ if (part->draw_as != PART_DRAW_REND)
skip = 1; /* draw visualization */
- else if(psys->pointcache->flag & PTCACHE_BAKING)
+ else if (psys->pointcache->flag & PTCACHE_BAKING)
skip = 1; /* no need to cache paths while baking dynamics */
- else if(psys_in_edit_mode(sim->scene, psys)) {
- if((pset->flag & PE_DRAW_PART)==0)
+ else if (psys_in_edit_mode(sim->scene, psys)) {
+ if ((pset->flag & PE_DRAW_PART)==0)
skip = 1;
- else if(part->childtype==0 && (psys->flag & PSYS_HAIR_DYNAMICS && psys->pointcache->flag & PTCACHE_BAKED)==0)
+ else if (part->childtype==0 && (psys->flag & PSYS_HAIR_DYNAMICS && psys->pointcache->flag & PTCACHE_BAKED)==0)
skip = 1; /* in edit mode paths are needed for child particles and dynamic hair */
}
}
@@ -3514,30 +3515,30 @@ static void psys_update_path_cache(ParticleSimulationData *sim, float cfra)
/* particle instance modifier with "path" option need cached paths even if particle system doesn't */
for (base = sim->scene->base.first; base; base= base->next) {
ModifierData *md = modifiers_findByType(base->object, eModifierType_ParticleInstance);
- if(md) {
+ if (md) {
ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData *)md;
- if(pimd->flag & eParticleInstanceFlag_Path && pimd->ob == sim->ob && pimd->psys == (psys - (ParticleSystem*)sim->ob->particlesystem.first)) {
+ if (pimd->flag & eParticleInstanceFlag_Path && pimd->ob == sim->ob && pimd->psys == (psys - (ParticleSystem*)sim->ob->particlesystem.first)) {
skip = 0;
break;
}
}
}
- if(!skip) {
+ if (!skip) {
psys_cache_paths(sim, cfra);
/* for render, child particle paths are computed on the fly */
- if(part->childtype) {
- if(!psys->totchild)
+ if (part->childtype) {
+ if (!psys->totchild)
skip = 1;
- else if(psys->part->type == PART_HAIR && (psys->flag & PSYS_HAIR_DONE)==0)
+ else if (psys->part->type == PART_HAIR && (psys->flag & PSYS_HAIR_DONE)==0)
skip = 1;
- if(!skip)
+ if (!skip)
psys_cache_child_paths(sim, cfra, 0);
}
}
- else if(psys->pathcache)
+ else if (psys->pathcache)
psys_free_path_cache(psys, NULL);
}
@@ -3556,7 +3557,7 @@ static void do_hair_dynamics(ParticleSimulationData *sim)
float hairmat[4][4];
float (*deformedVerts)[3];
- if(!psys->clmd) {
+ if (!psys->clmd) {
psys->clmd = (ClothModifierData*)modifier_new(eModifierType_Cloth);
psys->clmd->sim_parms->goalspring = 0.0f;
psys->clmd->sim_parms->flags |= CLOTH_SIMSETTINGS_FLAG_GOAL|CLOTH_SIMSETTINGS_FLAG_NO_SPRING_COMPRESS;
@@ -3570,12 +3571,12 @@ static void do_hair_dynamics(ParticleSimulationData *sim)
totedge = totpoint;
totpoint += psys->totpart;
- if(dm && (totpoint != dm->getNumVerts(dm) || totedge != dm->getNumEdges(dm))) {
+ if (dm && (totpoint != dm->getNumVerts(dm) || totedge != dm->getNumEdges(dm))) {
dm->release(dm);
dm = psys->hair_in_dm = NULL;
}
- if(!dm) {
+ if (!dm) {
dm = psys->hair_in_dm = CDDM_new(totpoint, totedge, 0, 0, 0);
DM_add_vert_layer(dm, CD_MDEFORMVERT, CD_CALLOC, NULL);
}
@@ -3589,15 +3590,15 @@ static void do_hair_dynamics(ParticleSimulationData *sim)
/* make vgroup for pin roots etc.. */
psys->particles->hair_index = 1;
LOOP_PARTICLES {
- if(p)
+ if (p)
pa->hair_index = (pa-1)->hair_index + (pa-1)->totkey + 1;
psys_mat_hair_to_object(sim->ob, sim->psmd->dm, psys->part->from, pa, hairmat);
- for(k=0, key=pa->hair; k<pa->totkey; k++,key++) {
+ for (k=0, key=pa->hair; k<pa->totkey; k++,key++) {
/* create fake root before actual root to resist bending */
- if(k==0) {
+ if (k==0) {
float temp[3];
sub_v3_v3v3(temp, key->co, (key+1)->co);
copy_v3_v3(mvert->co, key->co);
@@ -3609,8 +3610,8 @@ static void do_hair_dynamics(ParticleSimulationData *sim)
medge->v2 = pa->hair_index;
medge++;
- if(dvert) {
- if(!dvert->totweight) {
+ if (dvert) {
+ if (!dvert->totweight) {
dvert->dw = MEM_callocN(sizeof(MDeformWeight), "deformWeight");
dvert->totweight = 1;
}
@@ -3624,14 +3625,14 @@ static void do_hair_dynamics(ParticleSimulationData *sim)
mul_m4_v3(hairmat, mvert->co);
mvert++;
- if(k) {
+ if (k) {
medge->v1 = pa->hair_index + k - 1;
medge->v2 = pa->hair_index + k;
medge++;
}
- if(dvert) {
- if(!dvert->totweight) {
+ if (dvert) {
+ if (!dvert->totweight) {
dvert->dw = MEM_callocN(sizeof(MDeformWeight), "deformWeight");
dvert->totweight = 1;
}
@@ -3642,7 +3643,7 @@ static void do_hair_dynamics(ParticleSimulationData *sim)
}
}
- if(psys->hair_out_dm)
+ if (psys->hair_out_dm)
psys->hair_out_dm->release(psys->hair_out_dm);
psys->clmd->point_cache = psys->pointcache;
@@ -3669,25 +3670,25 @@ static void hair_step(ParticleSimulationData *sim, float cfra)
LOOP_PARTICLES {
pa->size = part->size;
- if(part->randsize > 0.0f)
+ if (part->randsize > 0.0f)
pa->size *= 1.0f - part->randsize * PSYS_FRAND(p + 1);
- if(PSYS_FRAND(p) > disp)
+ if (PSYS_FRAND(p) > disp)
pa->flag |= PARS_NO_DISP;
else
pa->flag &= ~PARS_NO_DISP;
}
- if(psys->recalc & PSYS_RECALC_RESET) {
+ if (psys->recalc & PSYS_RECALC_RESET) {
/* need this for changing subsurf levels */
psys_calc_dmcache(sim->ob, sim->psmd->dm, psys);
- if(psys->clmd)
+ if (psys->clmd)
cloth_free_modifier(psys->clmd);
}
/* dynamics with cloth simulation, psys->particles can be NULL with 0 particles [#25519] */
- if(psys->part->type==PART_HAIR && psys->flag & PSYS_HAIR_DYNAMICS && psys->particles)
+ if (psys->part->type==PART_HAIR && psys->flag & PSYS_HAIR_DYNAMICS && psys->particles)
do_hair_dynamics(sim);
/* following lines were removed r29079 but cause bug [#22811], see report for details */
@@ -3708,12 +3709,12 @@ static void save_hair(ParticleSimulationData *sim, float UNUSED(cfra))
psys->lattice= psys_get_lattice(sim);
- if(psys->totpart==0) return;
+ if (psys->totpart==0) return;
/* save new keys for elements if needed */
LOOP_PARTICLES {
/* first time alloc */
- if(pa->totkey==0 || pa->hair==NULL) {
+ if (pa->totkey==0 || pa->hair==NULL) {
pa->hair = MEM_callocN((psys->part->hair_step + 1) * sizeof(HairKey), "HairKeys");
pa->totkey = 0;
}
@@ -3725,7 +3726,7 @@ static void save_hair(ParticleSimulationData *sim, float UNUSED(cfra))
copy_v3_v3(key->co, pa->state.co);
mul_m4_v3(ob->imat, key->co);
- if(pa->totkey) {
+ if (pa->totkey) {
sub_v3_v3(key->co, root->co);
psys_vec_rot_to_face(sim->psmd->dm, pa, key->co);
}
@@ -3737,7 +3738,7 @@ static void save_hair(ParticleSimulationData *sim, float UNUSED(cfra))
pa->totkey++;
/* root is always in the origin of hair space so we set it to be so after the last key is saved*/
- if(pa->totkey == psys->part->hair_step + 1)
+ if (pa->totkey == psys->part->hair_step + 1)
root->co[0] = root->co[1] = root->co[2] = 0.0f;
}
}
@@ -3806,11 +3807,11 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
timestep = psys_get_timestep(sim);
dtime= dfra*timestep;
- if(dfra < 0.0f) {
+ if (dfra < 0.0f) {
LOOP_EXISTING_PARTICLES {
psys_get_texture(sim, pa, &ptex, PAMAP_SIZE, cfra);
pa->size = part->size*ptex.size;
- if(part->randsize > 0.0f)
+ if (part->randsize > 0.0f)
pa->size *= 1.0f - part->randsize * PSYS_FRAND(p + 1);
reset_particle(sim, pa, dtime, cfra);
@@ -3822,7 +3823,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
psys_update_effectors(sim);
- if(part->type != PART_HAIR)
+ if (part->type != PART_HAIR)
sim->colliders = get_collider_cache(sim->scene, sim->ob, NULL);
/* initialize physics type specific stuff */
@@ -3840,8 +3841,8 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
boids_precalc_rules(part, cfra);
- for(; pt; pt=pt->next) {
- if(pt->ob)
+ for (; pt; pt=pt->next) {
+ if (pt->ob)
psys_update_particle_tree(BLI_findlink(&pt->ob->particlesystem, pt->psys-1), cfra);
}
break;
@@ -3851,8 +3852,8 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
ParticleTarget *pt = psys->targets.first;
psys_update_particle_bvhtree(psys, cfra);
- for(; pt; pt=pt->next) { /* Updating others systems particle tree for fluid-fluid interaction */
- if(pt->ob)
+ for (; pt; pt=pt->next) { /* Updating others systems particle tree for fluid-fluid interaction */
+ if (pt->ob)
psys_update_particle_bvhtree(BLI_findlink(&pt->ob->particlesystem, pt->psys-1), cfra);
}
break;
@@ -3865,7 +3866,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
psys_get_texture(sim, pa, &ptex, PAMAP_SIZE, cfra);
pa->size = part->size*ptex.size;
- if(part->randsize > 0.0f)
+ if (part->randsize > 0.0f)
pa->size *= 1.0f - part->randsize * PSYS_FRAND(p + 1);
birthtime = pa->time;
@@ -3874,29 +3875,29 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
/* store this, so we can do multiple loops over particles */
pa->state.time = dfra;
- if(dietime <= cfra && psys->cfra < dietime) {
+ if (dietime <= cfra && psys->cfra < dietime) {
/* particle dies some time between this and last step */
pa->state.time = dietime - ((birthtime > psys->cfra) ? birthtime : psys->cfra);
pa->alive = PARS_DYING;
}
- else if(birthtime <= cfra && birthtime >= psys->cfra) {
+ else if (birthtime <= cfra && birthtime >= psys->cfra) {
/* particle is born some time between this and last step*/
reset_particle(sim, pa, dfra*timestep, cfra);
pa->alive = PARS_ALIVE;
pa->state.time = cfra - birthtime;
}
- else if(dietime < cfra) {
+ else if (dietime < cfra) {
/* nothing to be done when particle is dead */
}
/* only reset unborn particles if they're shown or if the particle is born soon*/
- if(pa->alive==PARS_UNBORN
+ if (pa->alive==PARS_UNBORN
&& (part->flag & PART_UNBORN || cfra + psys->pointcache->step > pa->time))
reset_particle(sim, pa, dtime, cfra);
- else if(part->phystype == PART_PHYS_NO)
+ else if (part->phystype == PART_PHYS_NO)
reset_particle(sim, pa, dtime, cfra);
- if(ELEM(pa->alive, PARS_ALIVE, PARS_DYING)==0 || (pa->flag & (PARS_UNEXIST|PARS_NO_DISP)))
+ if (ELEM(pa->alive, PARS_ALIVE, PARS_DYING)==0 || (pa->flag & (PARS_UNEXIST|PARS_NO_DISP)))
pa->state.time = -1.f;
}
@@ -3908,7 +3909,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
basic_integrate(sim, p, pa->state.time, cfra);
/* deflection */
- if(sim->colliders)
+ if (sim->colliders)
collision_check(sim, p, pa->state.time, cfra);
/* rotations */
@@ -3923,11 +3924,11 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
boid_brain(&bbd, p, pa);
- if(pa->alive != PARS_DYING) {
+ if (pa->alive != PARS_DYING) {
boid_body(&bbd, pa);
/* deflection */
- if(sim->colliders)
+ if (sim->colliders)
collision_check(sim, p, pa->state.time, cfra);
}
}
@@ -3946,7 +3947,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
/* actual fluids calculations */
sph_integrate(sim, pa, pa->state.time, &sphdata);
- if(sim->colliders)
+ if (sim->colliders)
collision_check(sim, p, pa->state.time, cfra);
/* SPH particles are not physical particles, just interpolation
@@ -3967,7 +3968,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
/* finalize particle state and time after dynamics */
LOOP_DYNAMIC_PARTICLES {
- if(pa->alive == PARS_DYING) {
+ if (pa->alive == PARS_DYING) {
pa->alive=PARS_DEAD;
pa->state.time=pa->dietime;
}
@@ -3979,11 +3980,11 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
}
static void update_children(ParticleSimulationData *sim)
{
- if((sim->psys->part->type == PART_HAIR) && (sim->psys->flag & PSYS_HAIR_DONE)==0)
+ if ((sim->psys->part->type == PART_HAIR) && (sim->psys->flag & PSYS_HAIR_DONE)==0)
/* don't generate children while growing hair - waste of time */
psys_free_children(sim->psys);
- else if(sim->psys->part->childtype) {
- if(sim->psys->totchild != get_psys_tot_child(sim->scene, sim->psys))
+ else if (sim->psys->part->childtype) {
+ if (sim->psys->totchild != get_psys_tot_child(sim->scene, sim->psys))
distribute_particles(sim, PART_FROM_CHILD);
else {
/* Children are up to date, nothing to do. */
@@ -4008,7 +4009,7 @@ static void cached_step(ParticleSimulationData *sim, float cfra)
LOOP_PARTICLES {
psys_get_texture(sim, pa, &ptex, PAMAP_SIZE, cfra);
pa->size = part->size*ptex.size;
- if(part->randsize > 0.0f)
+ if (part->randsize > 0.0f)
pa->size *= 1.0f - part->randsize * PSYS_FRAND(p + 1);
psys->lattice= psys_get_lattice(sim);
@@ -4016,22 +4017,22 @@ static void cached_step(ParticleSimulationData *sim, float cfra)
dietime = pa->dietime;
/* update alive status and push events */
- if(pa->time > cfra) {
+ if (pa->time > cfra) {
pa->alive = PARS_UNBORN;
- if(part->flag & PART_UNBORN && (psys->pointcache->flag & PTCACHE_EXTERNAL) == 0)
+ if (part->flag & PART_UNBORN && (psys->pointcache->flag & PTCACHE_EXTERNAL) == 0)
reset_particle(sim, pa, 0.0f, cfra);
}
- else if(dietime <= cfra)
+ else if (dietime <= cfra)
pa->alive = PARS_DEAD;
else
pa->alive = PARS_ALIVE;
- if(psys->lattice) {
+ if (psys->lattice) {
end_latt_deform(psys->lattice);
psys->lattice= NULL;
}
- if(PSYS_FRAND(p) > disp)
+ if (PSYS_FRAND(p) > disp)
pa->flag |= PARS_NO_DISP;
else
pa->flag &= ~PARS_NO_DISP;
@@ -4041,7 +4042,7 @@ static void cached_step(ParticleSimulationData *sim, float cfra)
static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra))
{
ParticleSystem *psys = sim->psys;
- if(psys->particles) {
+ if (psys->particles) {
MEM_freeN(psys->particles);
psys->particles = 0;
psys->totpart = 0;
@@ -4052,7 +4053,7 @@ static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra))
{
FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(sim->ob, eModifierType_Fluidsim);
- if( fluidmd && fluidmd->fss) {
+ if ( fluidmd && fluidmd->fss) {
FluidsimSettings *fss= fluidmd->fss;
ParticleSettings *part = psys->part;
ParticleData *pa=NULL;
@@ -4063,7 +4064,7 @@ static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra))
int readMask, activeParts = 0, fileParts = 0;
gzFile gzf;
-// XXX if(ob==G.obedit) // off...
+// XXX if (ob==G.obedit) // off...
// return;
// ok, start loading
@@ -4093,24 +4094,24 @@ static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra))
// set up reading mask
readMask = fss->typeFlags;
- for(p=0, pa=psys->particles; p<totpart; p++, pa++) {
+ for (p=0, pa=psys->particles; p<totpart; p++, pa++) {
int ptype=0;
gzread(gzf, &ptype, sizeof( ptype ));
- if(ptype&readMask) {
+ if (ptype&readMask) {
activeParts++;
gzread(gzf, &(pa->size), sizeof( float ));
pa->size /= 10.0f;
- for(j=0; j<3; j++) {
+ for (j=0; j<3; j++) {
float wrf;
gzread(gzf, &wrf, sizeof( wrf ));
pa->state.co[j] = wrf;
//fprintf(stderr,"Rj%d ",j);
}
- for(j=0; j<3; j++) {
+ for (j=0; j<3; j++) {
float wrf;
gzread(gzf, &wrf, sizeof( wrf ));
pa->state.vel[j] = wrf;
@@ -4125,9 +4126,10 @@ static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra))
pa->lifetime = sim->scene->r.efra;
pa->alive = PARS_ALIVE;
//if(a<25) fprintf(stderr,"FSPARTICLE debug set %s , a%d = %f,%f,%f , life=%f \n", filename, a, pa->co[0],pa->co[1],pa->co[2], pa->lifetime );
- } else {
+ }
+ else {
// skip...
- for(j=0; j<2*3+1; j++) {
+ for (j=0; j<2*3+1; j++) {
float wrf; gzread(gzf, &wrf, sizeof( wrf ));
}
}
@@ -4151,7 +4153,7 @@ static int emit_particles(ParticleSimulationData *sim, PTCacheID *pid, float UNU
int oldtotpart = psys->totpart;
int totpart = tot_particles(psys, pid);
- if(totpart != oldtotpart)
+ if (totpart != oldtotpart)
realloc_particles(sim, totpart);
return totpart - oldtotpart;
@@ -4174,11 +4176,11 @@ static void system_step(ParticleSimulationData *sim, float cfra)
int startframe = 0, endframe = 100, oldtotpart = 0;
/* cache shouldn't be used for hair or "continue physics" */
- if(part->type != PART_HAIR && BKE_ptcache_get_continue_physics() == 0) {
+ if (part->type != PART_HAIR && BKE_ptcache_get_continue_physics() == 0) {
psys_clear_temp_pointcache(psys);
/* set suitable cache range automatically */
- if((cache->flag & (PTCACHE_BAKING|PTCACHE_BAKED))==0)
+ if ((cache->flag & (PTCACHE_BAKING|PTCACHE_BAKED))==0)
psys_get_pointcache_start_end(sim->scene, psys, &cache->startframe, &cache->endframe);
pid = &ptcacheid;
@@ -4187,7 +4189,7 @@ static void system_step(ParticleSimulationData *sim, float cfra)
BKE_ptcache_id_time(pid, sim->scene, 0.0f, &startframe, &endframe, NULL);
/* clear everythin on start frame */
- if(cfra == startframe) {
+ if (cfra == startframe) {
BKE_ptcache_id_reset(sim->scene, pid, PTCACHE_RESET_OUTDATED);
BKE_ptcache_validate(cache, startframe);
cache->flag &= ~PTCACHE_REDO_NEEDED;
@@ -4198,7 +4200,7 @@ static void system_step(ParticleSimulationData *sim, float cfra)
/* 1. emit particles and redo particles if needed */
oldtotpart = psys->totpart;
- if(emit_particles(sim, pid, cfra) || psys->recalc & PSYS_RECALC_RESET) {
+ if (emit_particles(sim, pid, cfra) || psys->recalc & PSYS_RECALC_RESET) {
distribute_particles(sim, part->from);
initialize_all_particles(sim);
/* reset only just created particles (on startframe all particles are recreated) */
@@ -4218,33 +4220,33 @@ static void system_step(ParticleSimulationData *sim, float cfra)
}
/* 2. try to read from the cache */
- if(pid) {
+ if (pid) {
int cache_result = BKE_ptcache_read(pid, cache_cfra);
- if(ELEM(cache_result, PTCACHE_READ_EXACT, PTCACHE_READ_INTERPOLATED)) {
+ if (ELEM(cache_result, PTCACHE_READ_EXACT, PTCACHE_READ_INTERPOLATED)) {
cached_step(sim, cfra);
update_children(sim);
psys_update_path_cache(sim, cfra);
BKE_ptcache_validate(cache, (int)cache_cfra);
- if(cache_result == PTCACHE_READ_INTERPOLATED && cache->flag & PTCACHE_REDO_NEEDED)
+ if (cache_result == PTCACHE_READ_INTERPOLATED && cache->flag & PTCACHE_REDO_NEEDED)
BKE_ptcache_write(pid, (int)cache_cfra);
return;
}
/* Cache is supposed to be baked, but no data was found so bail out */
- else if(cache->flag & PTCACHE_BAKED) {
+ else if (cache->flag & PTCACHE_BAKED) {
psys_reset(psys, PSYS_RESET_CACHE_MISS);
return;
}
- else if(cache_result == PTCACHE_READ_OLD) {
+ else if (cache_result == PTCACHE_READ_OLD) {
psys->cfra = (float)cache->simframe;
cached_step(sim, psys->cfra);
}
/* if on second frame, write cache for first frame */
- if(psys->cfra == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact==0))
+ if (psys->cfra == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact==0))
BKE_ptcache_write(pid, startframe);
}
else
@@ -4255,33 +4257,35 @@ static void system_step(ParticleSimulationData *sim, float cfra)
disp= (float)psys_get_current_display_percentage(psys)/100.0f;
LOOP_PARTICLES {
- if(PSYS_FRAND(p) > disp)
+ if (PSYS_FRAND(p) > disp)
pa->flag |= PARS_NO_DISP;
else
pa->flag &= ~PARS_NO_DISP;
}
- if(psys->totpart) {
+ if (psys->totpart) {
int dframe, totframesback = 0;
float t_frac, dt_frac;
/* handle negative frame start at the first frame by doing
* all the steps before the first frame */
- if((int)cfra == startframe && part->sta < startframe)
+ if ((int)cfra == startframe && part->sta < startframe)
totframesback = (startframe - (int)part->sta);
if (!(part->time_flag & PART_TIME_AUTOSF)) {
/* Constant time step */
psys->dt_frac = 1.0f / (float) (part->subframes + 1);
- } else if ((int)cfra == startframe) {
+ }
+ else if ((int)cfra == startframe) {
/* Variable time step; use a very conservative value at the start.
* If it doesn't need to be so small, it will quickly grow. */
psys->dt_frac = 1.0;
- } else if (psys->dt_frac < MIN_TIMESTEP) {
+ }
+ else if (psys->dt_frac < MIN_TIMESTEP) {
psys->dt_frac = MIN_TIMESTEP;
}
- for(dframe=-totframesback; dframe<=0; dframe++) {
+ for (dframe=-totframesback; dframe<=0; dframe++) {
/* simulate each subframe */
dt_frac = psys->dt_frac;
for (t_frac = dt_frac; t_frac <= 1.0f; t_frac += dt_frac) {
@@ -4298,16 +4302,16 @@ static void system_step(ParticleSimulationData *sim, float cfra)
}
/* 4. only write cache starting from second frame */
- if(pid) {
+ if (pid) {
BKE_ptcache_validate(cache, (int)cache_cfra);
- if((int)cache_cfra != startframe)
+ if ((int)cache_cfra != startframe)
BKE_ptcache_write(pid, (int)cache_cfra);
}
update_children(sim);
/* cleanup */
- if(psys->lattice) {
+ if (psys->lattice) {
end_latt_deform(psys->lattice);
psys->lattice= NULL;
}
@@ -4321,17 +4325,17 @@ static void psys_changed_type(ParticleSimulationData *sim)
BKE_ptcache_id_from_particles(&pid, sim->ob, sim->psys);
- if(part->phystype != PART_PHYS_KEYED)
+ if (part->phystype != PART_PHYS_KEYED)
sim->psys->flag &= ~PSYS_KEYED;
- if(part->type == PART_HAIR) {
- if(ELEM4(part->ren_as, PART_DRAW_NOT, PART_DRAW_PATH, PART_DRAW_OB, PART_DRAW_GR)==0)
+ if (part->type == PART_HAIR) {
+ if (ELEM4(part->ren_as, PART_DRAW_NOT, PART_DRAW_PATH, PART_DRAW_OB, PART_DRAW_GR)==0)
part->ren_as = PART_DRAW_PATH;
- if(part->distr == PART_DISTR_GRID)
+ if (part->distr == PART_DISTR_GRID)
part->distr = PART_DISTR_JIT;
- if(ELEM3(part->draw_as, PART_DRAW_NOT, PART_DRAW_REND, PART_DRAW_PATH)==0)
+ if (ELEM3(part->draw_as, PART_DRAW_NOT, PART_DRAW_REND, PART_DRAW_PATH)==0)
part->draw_as = PART_DRAW_REND;
CLAMP(part->path_start, 0.0f, 100.0f);
@@ -4355,18 +4359,18 @@ void psys_check_boid_data(ParticleSystem *psys)
pa = psys->particles;
- if(!pa)
+ if (!pa)
return;
- if(psys->part && psys->part->phystype==PART_PHYS_BOIDS) {
- if(!pa->boid) {
+ if (psys->part && psys->part->phystype==PART_PHYS_BOIDS) {
+ if (!pa->boid) {
bpa = MEM_callocN(psys->totpart * sizeof(BoidParticle), "Boid Data");
LOOP_PARTICLES
pa->boid = bpa++;
}
}
- else if(pa->boid) {
+ else if (pa->boid) {
MEM_freeN(pa->boid);
LOOP_PARTICLES
pa->boid = NULL;
@@ -4395,7 +4399,7 @@ static void psys_prepare_physics(ParticleSimulationData *sim)
{
ParticleSettings *part = sim->psys->part;
- if(ELEM(part->phystype, PART_PHYS_NO, PART_PHYS_KEYED)) {
+ if (ELEM(part->phystype, PART_PHYS_NO, PART_PHYS_KEYED)) {
PTCacheID pid;
BKE_ptcache_id_from_particles(&pid, sim->ob, sim->psys);
BKE_ptcache_id_clear(&pid, PTCACHE_CLEAR_ALL, 0);
@@ -4405,7 +4409,7 @@ static void psys_prepare_physics(ParticleSimulationData *sim)
sim->psys->flag &= ~PSYS_KEYED;
}
- if(part->phystype == PART_PHYS_BOIDS && part->boids == NULL) {
+ if (part->phystype == PART_PHYS_BOIDS && part->boids == NULL) {
BoidState *state;
part->boids = MEM_callocN(sizeof(BoidSettings), "Boid Settings");
@@ -4420,7 +4424,7 @@ static void psys_prepare_physics(ParticleSimulationData *sim)
state->flag |= BOIDSTATE_CURRENT;
BLI_addtail(&part->boids->states, state);
}
- else if(part->phystype == PART_PHYS_FLUID && part->fluid == NULL) {
+ else if (part->phystype == PART_PHYS_FLUID && part->fluid == NULL) {
part->fluid = MEM_callocN(sizeof(SPHFluidSettings), "SPH Fluid Settings");
fluid_default_settings(part);
}
@@ -4429,7 +4433,7 @@ static void psys_prepare_physics(ParticleSimulationData *sim)
}
static int hair_needs_recalc(ParticleSystem *psys)
{
- if(!(psys->flag & PSYS_EDITED) && (!psys->edit || !psys->edit->edited) &&
+ if (!(psys->flag & PSYS_EDITED) && (!psys->edit || !psys->edit->edited) &&
((psys->flag & PSYS_HAIR_DONE)==0 || psys->recalc & PSYS_RECALC_RESET || (psys->part->flag & PART_HAIR_REGROW && !psys->edit))) {
return 1;
}
@@ -4446,9 +4450,9 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys)
float cfra;
/* drawdata is outdated after ANY change */
- if(psys->pdd) psys->pdd->flag &= ~PARTICLE_DRAW_DATA_UPDATED;
+ if (psys->pdd) psys->pdd->flag &= ~PARTICLE_DRAW_DATA_UPDATED;
- if(!psys_check_enabled(ob, psys))
+ if (!psys_check_enabled(ob, psys))
return;
cfra= BKE_curframe(scene);
@@ -4459,14 +4463,14 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys)
sim.psmd= psys_get_modifier(ob, psys);
/* system was already updated from modifier stack */
- if(sim.psmd->flag & eParticleSystemFlag_psys_updated) {
+ if (sim.psmd->flag & eParticleSystemFlag_psys_updated) {
sim.psmd->flag &= ~eParticleSystemFlag_psys_updated;
/* make sure it really was updated to cfra */
- if(psys->cfra == cfra)
+ if (psys->cfra == cfra)
return;
}
- if(!sim.psmd->dm)
+ if (!sim.psmd->dm)
return;
if (part->from != PART_FROM_VERT) {
@@ -4479,10 +4483,10 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys)
/* to verify if we need to restore object afterwards */
psys->flag &= ~PSYS_OB_ANIM_RESTORE;
- if(psys->recalc & PSYS_RECALC_TYPE)
+ if (psys->recalc & PSYS_RECALC_TYPE)
psys_changed_type(&sim);
- if(psys->recalc & PSYS_RECALC_RESET)
+ if (psys->recalc & PSYS_RECALC_RESET)
psys->totunexist = 0;
/* setup necessary physics type dependent additional data if it doesn't yet exist */
@@ -4492,19 +4496,19 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys)
case PART_HAIR:
{
/* nothing to do so bail out early */
- if(psys->totpart == 0 && part->totpart == 0) {
+ if (psys->totpart == 0 && part->totpart == 0) {
psys_free_path_cache(psys, NULL);
free_hair(ob, psys, 0);
psys->flag |= PSYS_HAIR_DONE;
}
/* (re-)create hair */
- else if(hair_needs_recalc(psys)) {
+ else if (hair_needs_recalc(psys)) {
float hcfra=0.0f;
int i, recalc = psys->recalc;
free_hair(ob, psys, 0);
- if(psys->edit && psys->free_edit) {
+ if (psys->edit && psys->free_edit) {
psys->free_edit(psys->edit);
psys->edit = NULL;
psys->free_edit = NULL;
@@ -4513,9 +4517,9 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys)
/* first step is negative so particles get killed and reset */
psys->cfra= 1.0f;
- for(i=0; i<=part->hair_step; i++) {
+ for (i=0; i<=part->hair_step; i++) {
hcfra=100.0f*(float)i/(float)psys->part->hair_step;
- if((part->flag & PART_HAIR_REGROW)==0)
+ if ((part->flag & PART_HAIR_REGROW)==0)
BKE_animsys_evaluate_animdata(scene, &part->id, part->adt, hcfra, ADT_RECALC_ANIM);
system_step(&sim, hcfra);
psys->cfra = hcfra;
@@ -4526,10 +4530,10 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys)
psys->flag |= PSYS_HAIR_DONE;
psys->recalc = recalc;
}
- else if(psys->flag & PSYS_EDITED)
+ else if (psys->flag & PSYS_EDITED)
psys->flag |= PSYS_HAIR_DONE;
- if(psys->flag & PSYS_HAIR_DONE)
+ if (psys->flag & PSYS_HAIR_DONE)
hair_step(&sim, cfra);
break;
}
@@ -4548,10 +4552,10 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys)
float disp = (float)psys_get_current_display_percentage(psys)/100.0f;
/* Particles without dynamics haven't been reset yet because they don't use pointcache */
- if(psys->recalc & PSYS_RECALC_RESET)
+ if (psys->recalc & PSYS_RECALC_RESET)
psys_reset(psys, PSYS_RESET_ALL);
- if(emit_particles(&sim, NULL, cfra) || (psys->recalc & PSYS_RECALC_RESET)) {
+ if (emit_particles(&sim, NULL, cfra) || (psys->recalc & PSYS_RECALC_RESET)) {
free_keyed_keys(psys);
distribute_particles(&sim, part->from);
initialize_all_particles(&sim);
@@ -4562,18 +4566,18 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys)
LOOP_EXISTING_PARTICLES {
pa->size = part->size;
- if(part->randsize > 0.0f)
+ if (part->randsize > 0.0f)
pa->size *= 1.0f - part->randsize * PSYS_FRAND(p + 1);
reset_particle(&sim, pa, 0.0, cfra);
- if(PSYS_FRAND(p) > disp)
+ if (PSYS_FRAND(p) > disp)
pa->flag |= PARS_NO_DISP;
else
pa->flag &= ~PARS_NO_DISP;
}
- if(part->phystype == PART_PHYS_KEYED) {
+ if (part->phystype == PART_PHYS_KEYED) {
psys_count_keyed_targets(&sim);
set_keyed_keys(&sim);
psys_update_path_cache(&sim,(int)cfra);
@@ -4592,8 +4596,8 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys)
}
/* make sure emitter is left at correct time (particle emission can change this) */
- if(psys->flag & PSYS_OB_ANIM_RESTORE) {
- while(ob) {
+ if (psys->flag & PSYS_OB_ANIM_RESTORE) {
+ while (ob) {
BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, cfra, ADT_RECALC_ANIM);
ob = ob->parent;
}
@@ -4607,7 +4611,7 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys)
psys->recalc = 0;
/* save matrix for duplicators, at rendertime the actual dupliobject's matrix is used so don't update! */
- if(psys->renderdata==0)
+ if (psys->renderdata==0)
invert_m4_m4(psys->imat, ob->obmat);
}
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index a2425b0a3ac..643dd217e4d 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -97,8 +97,8 @@
#include "BLI_winstuff.h"
#endif
-#define PTCACHE_DATA_FROM(data, type, from) if(data[type]) { memcpy(data[type], from, ptcache_data_size[type]); }
-#define PTCACHE_DATA_TO(data, type, index, to) if(data[type]) { memcpy(to, (char*)data[type] + (index ? index * ptcache_data_size[type] : 0), ptcache_data_size[type]); }
+#define PTCACHE_DATA_FROM(data, type, from) if (data[type]) { memcpy(data[type], from, ptcache_data_size[type]); }
+#define PTCACHE_DATA_TO(data, type, index, to) if (data[type]) { memcpy(to, (char*)data[type] + (index ? index * ptcache_data_size[type] : 0), ptcache_data_size[type]); }
/* could be made into a pointcache option */
#define DURIAN_POINTCACHE_LIB_OK 1
@@ -131,10 +131,10 @@ static int ptcache_basic_header_read(PTCacheFile *pf)
int error=0;
/* Custom functions should read these basic elements too! */
- if(!error && !fread(&pf->totpoint, sizeof(unsigned int), 1, pf->fp))
+ if (!error && !fread(&pf->totpoint, sizeof(unsigned int), 1, pf->fp))
error = 1;
- if(!error && !fread(&pf->data_types, sizeof(unsigned int), 1, pf->fp))
+ if (!error && !fread(&pf->data_types, sizeof(unsigned int), 1, pf->fp))
error = 1;
return !error;
@@ -142,10 +142,10 @@ static int ptcache_basic_header_read(PTCacheFile *pf)
static int ptcache_basic_header_write(PTCacheFile *pf)
{
/* Custom functions should write these basic elements too! */
- if(!fwrite(&pf->totpoint, sizeof(unsigned int), 1, pf->fp))
+ if (!fwrite(&pf->totpoint, sizeof(unsigned int), 1, pf->fp))
return 0;
- if(!fwrite(&pf->data_types, sizeof(unsigned int), 1, pf->fp))
+ if (!fwrite(&pf->data_types, sizeof(unsigned int), 1, pf->fp))
return 0;
return 1;
@@ -166,7 +166,7 @@ static void ptcache_softbody_read(int index, void *soft_v, void **data, float UN
SoftBody *soft= soft_v;
BodyPoint *bp = soft->bpoint + index;
- if(old_data) {
+ if (old_data) {
memcpy(bp->pos, data, 3 * sizeof(float));
memcpy(bp->vec, data + 3, 3 * sizeof(float));
}
@@ -182,13 +182,13 @@ static void ptcache_softbody_interpolate(int index, void *soft_v, void **data, f
ParticleKey keys[4];
float dfra;
- if(cfra1 == cfra2)
+ if (cfra1 == cfra2)
return;
copy_v3_v3(keys[1].co, bp->pos);
copy_v3_v3(keys[1].vel, bp->vec);
- if(old_data) {
+ if (old_data) {
memcpy(keys[2].co, old_data, 3 * sizeof(float));
memcpy(keys[2].vel, old_data + 3, 3 * sizeof(float));
}
@@ -219,7 +219,7 @@ void BKE_ptcache_make_particle_key(ParticleKey *key, int index, void **data, flo
PTCACHE_DATA_TO(data, BPHYS_DATA_VELOCITY, index, key->vel);
/* no rotation info, so make something nice up */
- if(data[BPHYS_DATA_ROTATION]==NULL) {
+ if (data[BPHYS_DATA_ROTATION]==NULL) {
vec_to_quat( key->rot, key->vel, OB_NEGX, OB_POSZ);
}
else {
@@ -238,7 +238,7 @@ static int ptcache_particle_write(int index, void *psys_v, void **data, int cfr
int step = psys->pointcache->step;
/* No need to store unborn or died particles outside cache step bounds */
- if(data[BPHYS_DATA_INDEX] && (cfra < pa->time - step || cfra > pa->dietime + step))
+ if (data[BPHYS_DATA_INDEX] && (cfra < pa->time - step || cfra > pa->dietime + step))
return 0;
times[0]= pa->time;
@@ -253,7 +253,7 @@ static int ptcache_particle_write(int index, void *psys_v, void **data, int cfr
PTCACHE_DATA_FROM(data, BPHYS_DATA_SIZE, &pa->size);
PTCACHE_DATA_FROM(data, BPHYS_DATA_TIMES, times);
- if(boid)
+ if (boid)
PTCACHE_DATA_FROM(data, BPHYS_DATA_BOIDS, &boid->data);
/* return flag 1+1=2 for newly born particles to copy exact birth location to previously cached frame */
@@ -266,16 +266,16 @@ static void ptcache_particle_read(int index, void *psys_v, void **data, float cf
BoidParticle *boid;
float timestep = 0.04f*psys->part->timetweak;
- if(index >= psys->totpart)
+ if (index >= psys->totpart)
return;
pa = psys->particles + index;
boid = (psys->part->phystype == PART_PHYS_BOIDS) ? pa->boid : NULL;
- if(cfra > pa->state.time)
+ if (cfra > pa->state.time)
memcpy(&pa->prev_state, &pa->state, sizeof(ParticleKey));
- if(old_data) {
+ if (old_data) {
/* old format cache */
memcpy(&pa->state, old_data, sizeof(ParticleKey));
return;
@@ -284,15 +284,15 @@ static void ptcache_particle_read(int index, void *psys_v, void **data, float cf
BKE_ptcache_make_particle_key(&pa->state, 0, data, cfra);
/* set frames cached before birth to birth time */
- if(cfra < pa->time)
+ if (cfra < pa->time)
pa->state.time = pa->time;
- else if(cfra > pa->dietime)
+ else if (cfra > pa->dietime)
pa->state.time = pa->dietime;
- if(data[BPHYS_DATA_SIZE])
+ if (data[BPHYS_DATA_SIZE])
PTCACHE_DATA_TO(data, BPHYS_DATA_SIZE, 0, &pa->size);
- if(data[BPHYS_DATA_TIMES]) {
+ if (data[BPHYS_DATA_TIMES]) {
float times[3];
PTCACHE_DATA_TO(data, BPHYS_DATA_TIMES, 0, &times);
pa->time = times[0];
@@ -300,12 +300,12 @@ static void ptcache_particle_read(int index, void *psys_v, void **data, float cf
pa->lifetime = times[2];
}
- if(boid)
+ if (boid)
PTCACHE_DATA_TO(data, BPHYS_DATA_BOIDS, 0, &boid->data);
/* determine velocity from previous location */
- if(data[BPHYS_DATA_LOCATION] && !data[BPHYS_DATA_VELOCITY]) {
- if(cfra > pa->prev_state.time) {
+ if (data[BPHYS_DATA_LOCATION] && !data[BPHYS_DATA_VELOCITY]) {
+ if (cfra > pa->prev_state.time) {
sub_v3_v3v3(pa->state.vel, pa->state.co, pa->prev_state.co);
mul_v3_fl(pa->state.vel, (cfra - pa->prev_state.time) * timestep);
}
@@ -316,7 +316,7 @@ static void ptcache_particle_read(int index, void *psys_v, void **data, float cf
}
/* default to no rotation */
- if(data[BPHYS_DATA_LOCATION] && !data[BPHYS_DATA_ROTATION]) {
+ if (data[BPHYS_DATA_LOCATION] && !data[BPHYS_DATA_ROTATION]) {
pa->state.rot[0]=1.0f;
pa->state.rot[1]=pa->state.rot[2]=pa->state.rot[3]=0;
}
@@ -328,31 +328,31 @@ static void ptcache_particle_interpolate(int index, void *psys_v, void **data, f
ParticleKey keys[4];
float dfra, timestep = 0.04f*psys->part->timetweak;
- if(index >= psys->totpart)
+ if (index >= psys->totpart)
return;
pa = psys->particles + index;
/* particle wasn't read from first cache so can't interpolate */
- if((int)cfra1 < pa->time - psys->pointcache->step || (int)cfra1 > pa->dietime + psys->pointcache->step)
+ if ((int)cfra1 < pa->time - psys->pointcache->step || (int)cfra1 > pa->dietime + psys->pointcache->step)
return;
cfra = MIN2(cfra, pa->dietime);
cfra1 = MIN2(cfra1, pa->dietime);
cfra2 = MIN2(cfra2, pa->dietime);
- if(cfra1 == cfra2)
+ if (cfra1 == cfra2)
return;
memcpy(keys+1, &pa->state, sizeof(ParticleKey));
- if(old_data)
+ if (old_data)
memcpy(keys+2, old_data, sizeof(ParticleKey));
else
BKE_ptcache_make_particle_key(keys+2, 0, data, cfra2);
/* determine velocity from previous location */
- if(data[BPHYS_DATA_LOCATION] && !data[BPHYS_DATA_VELOCITY]) {
- if(keys[1].time > keys[2].time) {
+ if (data[BPHYS_DATA_LOCATION] && !data[BPHYS_DATA_VELOCITY]) {
+ if (keys[1].time > keys[2].time) {
sub_v3_v3v3(keys[2].vel, keys[1].co, keys[2].co);
mul_v3_fl(keys[2].vel, (keys[1].time - keys[2].time) * timestep);
}
@@ -363,11 +363,11 @@ static void ptcache_particle_interpolate(int index, void *psys_v, void **data, f
}
/* determine rotation from velocity */
- if(data[BPHYS_DATA_LOCATION] && !data[BPHYS_DATA_ROTATION]) {
+ if (data[BPHYS_DATA_LOCATION] && !data[BPHYS_DATA_ROTATION]) {
vec_to_quat( keys[2].rot,keys[2].vel, OB_NEGX, OB_POSZ);
}
- if(cfra > pa->time)
+ if (cfra > pa->time)
cfra1 = MAX2(cfra1, pa->time);
dfra = cfra2 - cfra1;
@@ -395,10 +395,10 @@ static int ptcache_particle_totwrite(void *psys_v, int cfra)
int p, step = psys->pointcache->step;
int totwrite = 0;
- if(cfra == 0)
+ if (cfra == 0)
return psys->totpart;
- for(p=0; p<psys->totpart; p++,pa++)
+ for (p=0; p<psys->totpart; p++,pa++)
totwrite += (cfra >= pa->time - step && cfra <= pa->dietime + step);
return totwrite;
@@ -409,7 +409,7 @@ static void ptcache_particle_extra_write(void *psys_v, PTCacheMem *pm, int UNUSE
ParticleSystem *psys = psys_v;
PTCacheExtra *extra = NULL;
- if(psys->part->phystype == PART_PHYS_FLUID &&
+ if (psys->part->phystype == PART_PHYS_FLUID &&
psys->part->fluid && psys->part->fluid->flag & SPH_VISCOELASTIC_SPRINGS &&
psys->tot_fluidsprings && psys->fluid_springs) {
@@ -430,11 +430,11 @@ static void ptcache_particle_extra_read(void *psys_v, PTCacheMem *pm, float UNUS
ParticleSystem *psys = psys_v;
PTCacheExtra *extra = pm->extradata.first;
- for(; extra; extra=extra->next) {
+ for (; extra; extra=extra->next) {
switch(extra->type) {
case BPHYS_EXTRA_FLUID_SPRINGS:
{
- if(psys->fluid_springs)
+ if (psys->fluid_springs)
MEM_freeN(psys->fluid_springs);
psys->fluid_springs = MEM_dupallocN(extra->data);
@@ -464,7 +464,7 @@ static void ptcache_cloth_read(int index, void *cloth_v, void **data, float UNUS
Cloth *cloth= clmd->clothObject;
ClothVertex *vert = cloth->verts + index;
- if(old_data) {
+ if (old_data) {
memcpy(vert->x, data, 3 * sizeof(float));
memcpy(vert->xconst, data + 3, 3 * sizeof(float));
memcpy(vert->v, data + 6, 3 * sizeof(float));
@@ -483,13 +483,13 @@ static void ptcache_cloth_interpolate(int index, void *cloth_v, void **data, flo
ParticleKey keys[4];
float dfra;
- if(cfra1 == cfra2)
+ if (cfra1 == cfra2)
return;
copy_v3_v3(keys[1].co, vert->x);
copy_v3_v3(keys[1].vel, vert->v);
- if(old_data) {
+ if (old_data) {
memcpy(keys[2].co, old_data, 3 * sizeof(float));
memcpy(keys[2].vel, old_data + 6, 3 * sizeof(float));
}
@@ -524,7 +524,7 @@ static int ptcache_smoke_totpoint(void *smoke_v, int UNUSED(cfra))
SmokeModifierData *smd= (SmokeModifierData *)smoke_v;
SmokeDomainSettings *sds = smd->domain;
- if(sds->fluid) {
+ if (sds->fluid) {
return sds->res[0]*sds->res[1]*sds->res[2];
}
else
@@ -536,7 +536,7 @@ static int ptcache_smoke_write(PTCacheFile *pf, void *smoke_v)
SmokeDomainSettings *sds = smd->domain;
int ret = 0;
- if(sds->fluid) {
+ if (sds->fluid) {
size_t res = sds->res[0]*sds->res[1]*sds->res[2];
float dt, dx, *dens, *densold, *heat, *heatold, *vx, *vy, *vz, *vxold, *vyold, *vzold;
unsigned char *obstacles;
@@ -568,7 +568,7 @@ static int ptcache_smoke_write(PTCacheFile *pf, void *smoke_v)
ret = 1;
}
- if(sds->wt) {
+ if (sds->wt) {
int res_big_array[3];
int res_big;
int res = sds->res[0]*sds->res[1]*sds->res[2];
@@ -609,7 +609,7 @@ static int ptcache_smoke_read(PTCacheFile *pf, void *smoke_v)
SmokeModifierData *smd= (SmokeModifierData *)smoke_v;
SmokeDomainSettings *sds = smd->domain;
- if(sds->fluid) {
+ if (sds->fluid) {
size_t res = sds->res[0]*sds->res[1]*sds->res[2];
float dt, dx, *dens, *densold, *heat, *heatold, *vx, *vy, *vz, *vxold, *vyold, *vzold;
unsigned char *obstacles;
@@ -632,7 +632,7 @@ static int ptcache_smoke_read(PTCacheFile *pf, void *smoke_v)
ptcache_file_read(pf, &dt, 1, sizeof(float));
ptcache_file_read(pf, &dx, 1, sizeof(float));
- if(pf->data_types & (1<<BPHYS_DATA_SMOKE_HIGH) && sds->wt) {
+ if (pf->data_types & (1<<BPHYS_DATA_SMOKE_HIGH) && sds->wt) {
int res = sds->res[0]*sds->res[1]*sds->res[2];
int res_big, res_big_array[3];
float *dens, *densold, *tcu, *tcv, *tcw;
@@ -680,7 +680,7 @@ static int ptcache_dynamicpaint_write(PTCacheFile *pf, void *dp_v)
/* version header */
ptcache_file_write(pf, DPAINT_CACHE_VERSION, 1, sizeof(char)*4);
- if(surface->format != MOD_DPAINT_SURFACE_F_IMAGESEQ && surface->data) {
+ if (surface->format != MOD_DPAINT_SURFACE_F_IMAGESEQ && surface->data) {
int total_points=surface->data->total_points;
unsigned int in_len;
unsigned char *out;
@@ -714,7 +714,7 @@ static int ptcache_dynamicpaint_read(PTCacheFile *pf, void *dp_v)
ptcache_file_read(pf, version, 1, sizeof(char)*4);
if (strncmp(version, DPAINT_CACHE_VERSION,4)) {printf("Dynamic Paint: Invalid cache version: %s!\n",version); return 0;}
- if(surface->format != MOD_DPAINT_SURFACE_F_IMAGESEQ && surface->data) {
+ if (surface->format != MOD_DPAINT_SURFACE_F_IMAGESEQ && surface->data) {
unsigned int data_len;
int surface_type;
@@ -787,7 +787,7 @@ void BKE_ptcache_id_from_particles(PTCacheID *pid, Object *ob, ParticleSystem *p
pid->cache_ptr= &psys->pointcache;
pid->ptcaches= &psys->ptcaches;
- if(psys->part->type != PART_HAIR)
+ if (psys->part->type != PART_HAIR)
pid->flag |= PTCACHE_VEL_PER_SEC;
pid->totpoint = ptcache_particle_totpoint;
@@ -809,17 +809,17 @@ void BKE_ptcache_id_from_particles(PTCacheID *pid, Object *ob, ParticleSystem *p
pid->data_types = (1<<BPHYS_DATA_LOCATION) | (1<<BPHYS_DATA_VELOCITY) | (1<<BPHYS_DATA_INDEX);
- if(psys->part->phystype == PART_PHYS_BOIDS)
+ if (psys->part->phystype == PART_PHYS_BOIDS)
pid->data_types|= (1<<BPHYS_DATA_AVELOCITY) | (1<<BPHYS_DATA_ROTATION) | (1<<BPHYS_DATA_BOIDS);
- else if(psys->part->phystype == PART_PHYS_FLUID && psys->part->fluid && psys->part->fluid->flag & SPH_VISCOELASTIC_SPRINGS) {
+ else if (psys->part->phystype == PART_PHYS_FLUID && psys->part->fluid && psys->part->fluid->flag & SPH_VISCOELASTIC_SPRINGS) {
pid->write_extra_data = ptcache_particle_extra_write;
pid->read_extra_data = ptcache_particle_extra_read;
}
- if(psys->part->flag & PART_ROTATIONS) {
+ if (psys->part->flag & PART_ROTATIONS) {
pid->data_types|= (1<<BPHYS_DATA_ROTATION);
- if(psys->part->rotmode!=PART_ROT_VEL
+ if (psys->part->rotmode!=PART_ROT_VEL
|| psys->part->avemode==PART_AVE_RAND || psys->part->avefac!=0.0f)
pid->data_types|= (1<<BPHYS_DATA_AVELOCITY);
}
@@ -897,9 +897,9 @@ void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeMo
pid->data_types= 0;
pid->info_types= 0;
- if(sds->fluid)
+ if (sds->fluid)
pid->data_types |= (1<<BPHYS_DATA_SMOKE_LOW);
- if(sds->wt)
+ if (sds->wt)
pid->data_types |= (1<<BPHYS_DATA_SMOKE_HIGH);
pid->default_step = 1;
@@ -950,25 +950,25 @@ void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob, Scene *scene, int dup
lb->first= lb->last= NULL;
- if(ob->soft) {
+ if (ob->soft) {
pid= MEM_callocN(sizeof(PTCacheID), "PTCacheID");
BKE_ptcache_id_from_softbody(pid, ob, ob->soft);
BLI_addtail(lb, pid);
}
- for(psys=ob->particlesystem.first; psys; psys=psys->next) {
- if(psys->part==NULL)
+ for (psys=ob->particlesystem.first; psys; psys=psys->next) {
+ if (psys->part==NULL)
continue;
/* check to make sure point cache is actually used by the particles */
- if(ELEM(psys->part->phystype, PART_PHYS_NO, PART_PHYS_KEYED))
+ if (ELEM(psys->part->phystype, PART_PHYS_NO, PART_PHYS_KEYED))
continue;
/* hair needs to be included in id-list for cache edit mode to work */
/* if(psys->part->type == PART_HAIR && (psys->flag & PSYS_HAIR_DYNAMICS)==0) */
/* continue; */
- if(psys->part->type == PART_FLUID)
+ if (psys->part->type == PART_FLUID)
continue;
pid= MEM_callocN(sizeof(PTCacheID), "PTCacheID");
@@ -976,24 +976,24 @@ void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob, Scene *scene, int dup
BLI_addtail(lb, pid);
}
- for(md=ob->modifiers.first; md; md=md->next) {
- if(md->type == eModifierType_Cloth) {
+ for (md=ob->modifiers.first; md; md=md->next) {
+ if (md->type == eModifierType_Cloth) {
pid= MEM_callocN(sizeof(PTCacheID), "PTCacheID");
BKE_ptcache_id_from_cloth(pid, ob, (ClothModifierData*)md);
BLI_addtail(lb, pid);
}
- else if(md->type == eModifierType_Smoke) {
+ else if (md->type == eModifierType_Smoke) {
SmokeModifierData *smd = (SmokeModifierData *)md;
- if(smd->type & MOD_SMOKE_TYPE_DOMAIN)
+ if (smd->type & MOD_SMOKE_TYPE_DOMAIN)
{
pid= MEM_callocN(sizeof(PTCacheID), "PTCacheID");
BKE_ptcache_id_from_smoke(pid, ob, (SmokeModifierData*)md);
BLI_addtail(lb, pid);
}
}
- else if(md->type == eModifierType_DynamicPaint) {
+ else if (md->type == eModifierType_DynamicPaint) {
DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
- if(pmd->canvas)
+ if (pmd->canvas)
{
DynamicPaintSurface *surface = pmd->canvas->surfaces.first;
@@ -1006,17 +1006,17 @@ void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob, Scene *scene, int dup
}
}
- if(scene && (duplis-- > 0) && (ob->transflag & OB_DUPLI)) {
+ if (scene && (duplis-- > 0) && (ob->transflag & OB_DUPLI)) {
ListBase *lb_dupli_ob;
- if((lb_dupli_ob=object_duplilist(scene, ob))) {
+ if ((lb_dupli_ob=object_duplilist(scene, ob))) {
DupliObject *dob;
- for(dob= lb_dupli_ob->first; dob; dob= dob->next) {
- if(dob->ob != ob) { /* avoids recursive loops with dupliframes: bug 22988 */
+ for (dob= lb_dupli_ob->first; dob; dob= dob->next) {
+ if (dob->ob != ob) { /* avoids recursive loops with dupliframes: bug 22988 */
ListBase lb_dupli_pid;
BKE_ptcache_ids_from_object(&lb_dupli_pid, dob->ob, scene, duplis);
BLI_movelisttolist(lb, &lb_dupli_pid);
- if(lb_dupli_pid.first)
+ if (lb_dupli_pid.first)
printf("Adding Dupli\n");
}
}
@@ -1043,10 +1043,10 @@ static int ptcache_path(PTCacheID *pid, char *filename)
const char *blendfilename= (lib && (pid->cache->flag & PTCACHE_IGNORE_LIBPATH)==0) ? lib->filepath: G.main->name;
size_t i;
- if(pid->cache->flag & PTCACHE_EXTERNAL) {
+ if (pid->cache->flag & PTCACHE_EXTERNAL) {
strcpy(filename, pid->cache->path);
- if(strncmp(filename, "//", 2)==0)
+ if (strncmp(filename, "//", 2)==0)
BLI_path_abs(filename, blendfilename);
return BLI_add_slash(filename); /* new strlen() */
@@ -1088,10 +1088,10 @@ static int ptcache_filename(PTCacheID *pid, char *filename, int cfra, short do_p
len = ptcache_path(pid, filename);
newname += len;
}
- if(pid->cache->name[0] == '\0' && (pid->cache->flag & PTCACHE_EXTERNAL)==0) {
+ if (pid->cache->name[0] == '\0' && (pid->cache->flag & PTCACHE_EXTERNAL)==0) {
idname = (pid->ob->id.name+2);
/* convert chars to hex so they are always a valid filename */
- while('\0' != *idname) {
+ while ('\0' != *idname) {
BLI_snprintf(newname, MAX_PTCACHE_FILE, "%02X", (char)(*idname++));
newname+=2;
len += 2;
@@ -1106,11 +1106,11 @@ static int ptcache_filename(PTCacheID *pid, char *filename, int cfra, short do_p
if (do_ext) {
- if(pid->cache->index < 0)
+ if (pid->cache->index < 0)
pid->cache->index = pid->stack_index = object_insert_ptcache(pid->ob);
- if(pid->cache->flag & PTCACHE_EXTERNAL) {
- if(pid->cache->index >= 0)
+ if (pid->cache->flag & PTCACHE_EXTERNAL) {
+ if (pid->cache->index >= 0)
BLI_snprintf(newname, MAX_PTCACHE_FILE, "_%06d_%02u"PTCACHE_EXT, cfra, pid->stack_index); /* always 6 chars */
else
BLI_snprintf(newname, MAX_PTCACHE_FILE, "_%06d"PTCACHE_EXT, cfra); /* always 6 chars */
@@ -1133,7 +1133,7 @@ static PTCacheFile *ptcache_file_open(PTCacheID *pid, int mode, int cfra)
#ifndef DURIAN_POINTCACHE_LIB_OK
/* don't allow writing for linked objects */
- if(pid->ob->id.lib && mode == PTCACHE_FILE_WRITE)
+ if (pid->ob->id.lib && mode == PTCACHE_FILE_WRITE)
return NULL;
#endif
if (!G.relbase_valid && (pid->cache->flag & PTCACHE_EXTERNAL)==0) return NULL; /* save blend file before using disk pointcache */
@@ -1145,10 +1145,12 @@ static PTCacheFile *ptcache_file_open(PTCacheID *pid, int mode, int cfra)
return NULL;
}
fp = BLI_fopen(filename, "rb");
- } else if (mode==PTCACHE_FILE_WRITE) {
+ }
+ else if (mode==PTCACHE_FILE_WRITE) {
BLI_make_existing_file(filename); /* will create the dir if needs be, same as //textures is created */
fp = BLI_fopen(filename, "wb");
- } else if (mode==PTCACHE_FILE_UPDATE) {
+ }
+ else if (mode==PTCACHE_FILE_UPDATE) {
BLI_make_existing_file(filename);
fp = BLI_fopen(filename, "rb+");
}
@@ -1165,7 +1167,7 @@ static PTCacheFile *ptcache_file_open(PTCacheID *pid, int mode, int cfra)
}
static void ptcache_file_close(PTCacheFile *pf)
{
- if(pf) {
+ if (pf) {
fclose(pf->fp);
MEM_freeN(pf);
}
@@ -1183,22 +1185,22 @@ static int ptcache_file_compressed_read(PTCacheFile *pf, unsigned char *result,
unsigned char *props = MEM_callocN(16*sizeof(char), "tmp");
ptcache_file_read(pf, &compressed, 1, sizeof(unsigned char));
- if(compressed) {
+ if (compressed) {
unsigned int size;
ptcache_file_read(pf, &size, 1, sizeof(unsigned int));
in_len = (size_t)size;
- if(in_len==0) {
+ if (in_len==0) {
/* do nothing */
}
else {
in = (unsigned char *)MEM_callocN(sizeof(unsigned char)*in_len, "pointcache_compressed_buffer");
ptcache_file_read(pf, in, in_len, sizeof(unsigned char));
#ifdef WITH_LZO
- if(compressed == 1)
+ if (compressed == 1)
r = lzo1x_decompress_safe(in, (lzo_uint)in_len, result, (lzo_uint *)&out_len, NULL);
#endif
#ifdef WITH_LZMA
- if(compressed == 2)
+ if (compressed == 2)
{
size_t sizeOfIt;
size_t leni = in_len, leno = out_len;
@@ -1231,7 +1233,7 @@ static int ptcache_file_compressed_write(PTCacheFile *pf, unsigned char *in, uns
#ifdef WITH_LZO
out_len= LZO_OUT_LEN(in_len);
- if(mode == 1) {
+ if (mode == 1) {
LZO_HEAP_ALLOC(wrkmem, LZO1X_MEM_COMPRESS);
r = lzo1x_1_compress(in, (lzo_uint)in_len, out, (lzo_uint *)&out_len, wrkmem);
@@ -1242,12 +1244,12 @@ static int ptcache_file_compressed_write(PTCacheFile *pf, unsigned char *in, uns
}
#endif
#ifdef WITH_LZMA
- if(mode == 2) {
+ if (mode == 2) {
r = LzmaCompress(out, &out_len, in, in_len,//assume sizeof(char)==1....
props, &sizeOfIt, 5, 1 << 24, 3, 0, 2, 32, 2);
- if(!(r == SZ_OK) || (out_len >= in_len))
+ if (!(r == SZ_OK) || (out_len >= in_len))
compressed = 0;
else
compressed = 2;
@@ -1255,7 +1257,7 @@ static int ptcache_file_compressed_write(PTCacheFile *pf, unsigned char *in, uns
#endif
ptcache_file_write(pf, &compressed, 1, sizeof(unsigned char));
- if(compressed) {
+ if (compressed) {
unsigned int size = out_len;
ptcache_file_write(pf, &size, 1, sizeof(unsigned int));
ptcache_file_write(pf, out, out_len, sizeof(unsigned char));
@@ -1263,7 +1265,7 @@ static int ptcache_file_compressed_write(PTCacheFile *pf, unsigned char *in, uns
else
ptcache_file_write(pf, in, in_len, sizeof(unsigned char));
- if(compressed == 2)
+ if (compressed == 2)
{
unsigned int size = sizeOfIt;
ptcache_file_write(pf, &sizeOfIt, 1, sizeof(unsigned int));
@@ -1286,8 +1288,8 @@ static int ptcache_file_data_read(PTCacheFile *pf)
{
int i;
- for(i=0; i<BPHYS_TOT_DATA; i++) {
- if((pf->data_types & (1<<i)) && !ptcache_file_read(pf, pf->cur[i], 1, ptcache_data_size[i]))
+ for (i=0; i<BPHYS_TOT_DATA; i++) {
+ if ((pf->data_types & (1<<i)) && !ptcache_file_read(pf, pf->cur[i], 1, ptcache_data_size[i]))
return 0;
}
@@ -1297,8 +1299,8 @@ static int ptcache_file_data_write(PTCacheFile *pf)
{
int i;
- for(i=0; i<BPHYS_TOT_DATA; i++) {
- if((pf->data_types & (1<<i)) && !ptcache_file_write(pf, pf->cur[i], 1, ptcache_data_size[i]))
+ for (i=0; i<BPHYS_TOT_DATA; i++) {
+ if ((pf->data_types & (1<<i)) && !ptcache_file_write(pf, pf->cur[i], 1, ptcache_data_size[i]))
return 0;
}
@@ -1312,20 +1314,20 @@ static int ptcache_file_header_begin_read(PTCacheFile *pf)
pf->data_types = 0;
- if(fread(bphysics, sizeof(char), 8, pf->fp) != 8)
+ if (fread(bphysics, sizeof(char), 8, pf->fp) != 8)
error = 1;
- if(!error && strncmp(bphysics, "BPHYSICS", 8))
+ if (!error && strncmp(bphysics, "BPHYSICS", 8))
error = 1;
- if(!error && !fread(&typeflag, sizeof(unsigned int), 1, pf->fp))
+ if (!error && !fread(&typeflag, sizeof(unsigned int), 1, pf->fp))
error = 1;
pf->type = (typeflag & PTCACHE_TYPEFLAG_TYPEMASK);
pf->flag = (typeflag & PTCACHE_TYPEFLAG_FLAGMASK);
/* if there was an error set file as it was */
- if(error)
+ if (error)
fseek(pf->fp, 0, SEEK_SET);
return !error;
@@ -1335,10 +1337,10 @@ static int ptcache_file_header_begin_write(PTCacheFile *pf)
const char *bphysics = "BPHYSICS";
unsigned int typeflag = pf->type + pf->flag;
- if(fwrite(bphysics, sizeof(char), 8, pf->fp) != 8)
+ if (fwrite(bphysics, sizeof(char), 8, pf->fp) != 8)
return 0;
- if(!fwrite(&typeflag, sizeof(unsigned int), 1, pf->fp))
+ if (!fwrite(&typeflag, sizeof(unsigned int), 1, pf->fp))
return 0;
return 1;
@@ -1367,23 +1369,23 @@ static void ptcache_file_pointers_init(PTCacheFile *pf)
/* Check to see if point number "index" is in pm, uses binary search for index data. */
int BKE_ptcache_mem_index_find(PTCacheMem *pm, unsigned int index)
{
- if(pm->data[BPHYS_DATA_INDEX]) {
+ if (pm->data[BPHYS_DATA_INDEX]) {
unsigned int *data = pm->data[BPHYS_DATA_INDEX];
unsigned int mid, low = 0, high = pm->totpoint - 1;
- if(index < *data || index > *(data+high))
+ if (index < *data || index > *(data+high))
return -1;
/* check simple case for continuous indexes first */
- if(index-*data < high && data[index-*data] == index)
+ if (index-*data < high && data[index-*data] == index)
return index-*data;
- while(low <= high) {
+ while (low <= high) {
mid= (low + high)/2;
- if(data[mid] > index)
+ if (data[mid] > index)
high = mid - 1;
- else if(data[mid] < index)
+ else if (data[mid] < index)
low = mid + 1;
else
return mid;
@@ -1401,7 +1403,7 @@ void BKE_ptcache_mem_pointers_init(PTCacheMem *pm)
int data_types = pm->data_types;
int i;
- for(i=0; i<BPHYS_TOT_DATA; i++)
+ for (i=0; i<BPHYS_TOT_DATA; i++)
pm->cur[i] = ((data_types & (1<<i)) ? pm->data[i] : NULL);
}
@@ -1409,8 +1411,8 @@ void BKE_ptcache_mem_pointers_incr(PTCacheMem *pm)
{
int i;
- for(i=0; i<BPHYS_TOT_DATA; i++) {
- if(pm->cur[i])
+ for (i=0; i<BPHYS_TOT_DATA; i++) {
+ if (pm->cur[i])
pm->cur[i] = (char*)pm->cur[i] + ptcache_data_size[i];
}
}
@@ -1419,7 +1421,7 @@ int BKE_ptcache_mem_pointers_seek(int point_index, PTCacheMem *pm)
int data_types = pm->data_types;
int i, index = BKE_ptcache_mem_index_find(pm, point_index);
- if(index < 0) {
+ if (index < 0) {
/* Can't give proper location without reallocation, so don't give any location.
* Some points will be cached improperly, but this only happens with simulation
* steps bigger than cache->step, so the cache has to be recalculated anyways
@@ -1428,7 +1430,7 @@ int BKE_ptcache_mem_pointers_seek(int point_index, PTCacheMem *pm)
return 0;
}
- for(i=0; i<BPHYS_TOT_DATA; i++)
+ for (i=0; i<BPHYS_TOT_DATA; i++)
pm->cur[i] = data_types & (1<<i) ? (char*)pm->data[i] + index * ptcache_data_size[i] : NULL;
return 1;
@@ -1439,8 +1441,8 @@ static void ptcache_data_alloc(PTCacheMem *pm)
int totpoint = pm->totpoint;
int i;
- for(i=0; i<BPHYS_TOT_DATA; i++) {
- if(data_types & (1<<i))
+ for (i=0; i<BPHYS_TOT_DATA; i++) {
+ if (data_types & (1<<i))
pm->data[i] = MEM_callocN(totpoint * ptcache_data_size[i], "PTCache Data");
}
}
@@ -1449,18 +1451,18 @@ static void ptcache_data_free(PTCacheMem *pm)
void **data = pm->data;
int i;
- for(i=0; i<BPHYS_TOT_DATA; i++) {
- if(data[i])
+ for (i=0; i<BPHYS_TOT_DATA; i++) {
+ if (data[i])
MEM_freeN(data[i]);
}
}
static void ptcache_data_copy(void *from[], void *to[])
{
int i;
- for(i=0; i<BPHYS_TOT_DATA; i++) {
+ for (i=0; i<BPHYS_TOT_DATA; i++) {
/* note, durian file 03.4b_comp crashes if to[i] is not tested
* its NULL, not sure if this should be fixed elsewhere but for now its needed */
- if(from[i] && to[i])
+ if (from[i] && to[i])
memcpy(to[i], from[i], ptcache_data_size[i]);
}
}
@@ -1469,9 +1471,9 @@ static void ptcache_extra_free(PTCacheMem *pm)
{
PTCacheExtra *extra = pm->extradata.first;
- if(extra) {
- for(; extra; extra=extra->next) {
- if(extra->data)
+ if (extra) {
+ for (; extra; extra=extra->next) {
+ if (extra->data)
MEM_freeN(extra->data);
}
@@ -1480,11 +1482,11 @@ static void ptcache_extra_free(PTCacheMem *pm)
}
static int ptcache_old_elemsize(PTCacheID *pid)
{
- if(pid->type==PTCACHE_TYPE_SOFTBODY)
+ if (pid->type==PTCACHE_TYPE_SOFTBODY)
return 6 * sizeof(float);
- else if(pid->type==PTCACHE_TYPE_PARTICLES)
+ else if (pid->type==PTCACHE_TYPE_PARTICLES)
return sizeof(ParticleKey);
- else if(pid->type==PTCACHE_TYPE_CLOTH)
+ else if (pid->type==PTCACHE_TYPE_CLOTH)
return 9 * sizeof(float);
return 0;
@@ -1492,22 +1494,22 @@ static int ptcache_old_elemsize(PTCacheID *pid)
static void ptcache_find_frames_around(PTCacheID *pid, unsigned int frame, int *fra1, int *fra2)
{
- if(pid->cache->flag & PTCACHE_DISK_CACHE) {
+ if (pid->cache->flag & PTCACHE_DISK_CACHE) {
int cfra1=frame, cfra2=frame+1;
- while(cfra1 >= pid->cache->startframe && !BKE_ptcache_id_exist(pid, cfra1))
+ while (cfra1 >= pid->cache->startframe && !BKE_ptcache_id_exist(pid, cfra1))
cfra1--;
- if(cfra1 < pid->cache->startframe)
+ if (cfra1 < pid->cache->startframe)
cfra1 = 0;
- while(cfra2 <= pid->cache->endframe && !BKE_ptcache_id_exist(pid, cfra2))
+ while (cfra2 <= pid->cache->endframe && !BKE_ptcache_id_exist(pid, cfra2))
cfra2++;
- if(cfra2 > pid->cache->endframe)
+ if (cfra2 > pid->cache->endframe)
cfra2 = 0;
- if(cfra1 && !cfra2) {
+ if (cfra1 && !cfra2) {
*fra1 = 0;
*fra2 = cfra1;
}
@@ -1516,23 +1518,23 @@ static void ptcache_find_frames_around(PTCacheID *pid, unsigned int frame, int *
*fra2 = cfra2;
}
}
- else if(pid->cache->mem_cache.first) {
+ else if (pid->cache->mem_cache.first) {
PTCacheMem *pm = pid->cache->mem_cache.first;
PTCacheMem *pm2 = pid->cache->mem_cache.last;
- while(pm->next && pm->next->frame <= frame)
+ while (pm->next && pm->next->frame <= frame)
pm= pm->next;
- if(pm2->frame < frame) {
+ if (pm2->frame < frame) {
pm2 = NULL;
}
else {
- while(pm2->prev && pm2->prev->frame > frame) {
+ while (pm2->prev && pm2->prev->frame > frame) {
pm2= pm2->prev;
}
}
- if(!pm2) {
+ if (!pm2) {
*fra1 = 0;
*fra2 = pm->frame;
}
@@ -1549,16 +1551,16 @@ static PTCacheMem *ptcache_disk_frame_to_mem(PTCacheID *pid, int cfra)
PTCacheMem *pm = NULL;
unsigned int i, error = 0;
- if(pf == NULL)
+ if (pf == NULL)
return NULL;
- if(!ptcache_file_header_begin_read(pf))
+ if (!ptcache_file_header_begin_read(pf))
error = 1;
- if(!error && (pf->type != pid->type || !pid->read_header(pf)))
+ if (!error && (pf->type != pid->type || !pid->read_header(pf)))
error = 1;
- if(!error) {
+ if (!error) {
pm = MEM_callocN(sizeof(PTCacheMem), "Pointcache mem");
pm->totpoint = pf->totpoint;
@@ -1567,10 +1569,10 @@ static PTCacheMem *ptcache_disk_frame_to_mem(PTCacheID *pid, int cfra)
ptcache_data_alloc(pm);
- if(pf->flag & PTCACHE_TYPEFLAG_COMPRESS) {
- for(i=0; i<BPHYS_TOT_DATA; i++) {
+ if (pf->flag & PTCACHE_TYPEFLAG_COMPRESS) {
+ for (i=0; i<BPHYS_TOT_DATA; i++) {
unsigned int out_len = pm->totpoint*ptcache_data_size[i];
- if(pf->data_types & (1<<i))
+ if (pf->data_types & (1<<i))
ptcache_file_compressed_read(pf, (unsigned char*)(pm->data[i]), out_len);
}
}
@@ -1578,8 +1580,8 @@ static PTCacheMem *ptcache_disk_frame_to_mem(PTCacheID *pid, int cfra)
BKE_ptcache_mem_pointers_init(pm);
ptcache_file_pointers_init(pf);
- for(i=0; i<pm->totpoint; i++) {
- if(!ptcache_file_data_read(pf)) {
+ for (i=0; i<pm->totpoint; i++) {
+ if (!ptcache_file_data_read(pf)) {
error = 1;
break;
}
@@ -1589,10 +1591,10 @@ static PTCacheMem *ptcache_disk_frame_to_mem(PTCacheID *pid, int cfra)
}
}
- if(!error && pf->flag & PTCACHE_TYPEFLAG_EXTRADATA) {
+ if (!error && pf->flag & PTCACHE_TYPEFLAG_EXTRADATA) {
unsigned int extratype = 0;
- while(ptcache_file_read(pf, &extratype, 1, sizeof(unsigned int))) {
+ while (ptcache_file_read(pf, &extratype, 1, sizeof(unsigned int))) {
PTCacheExtra *extra = MEM_callocN(sizeof(PTCacheExtra), "Pointcache extradata");
extra->type = extratype;
@@ -1601,7 +1603,7 @@ static PTCacheMem *ptcache_disk_frame_to_mem(PTCacheID *pid, int cfra)
extra->data = MEM_callocN(extra->totdata * ptcache_extra_datasize[extra->type], "Pointcache extradata->data");
- if(pf->flag & PTCACHE_TYPEFLAG_COMPRESS)
+ if (pf->flag & PTCACHE_TYPEFLAG_COMPRESS)
ptcache_file_compressed_read(pf, (unsigned char*)(extra->data), extra->totdata*ptcache_extra_datasize[extra->type]);
else
ptcache_file_read(pf, extra->data, extra->totdata, ptcache_extra_datasize[extra->type]);
@@ -1610,7 +1612,7 @@ static PTCacheMem *ptcache_disk_frame_to_mem(PTCacheID *pid, int cfra)
}
}
- if(error && pm) {
+ if (error && pm) {
ptcache_data_free(pm);
ptcache_extra_free(pm);
MEM_freeN(pm);
@@ -1633,7 +1635,7 @@ static int ptcache_mem_frame_to_disk(PTCacheID *pid, PTCacheMem *pm)
pf = ptcache_file_open(pid, PTCACHE_FILE_WRITE, pm->frame);
- if(pf==NULL) {
+ if (pf==NULL) {
if (G.f & G_DEBUG)
printf("Error opening disk cache file for writing\n");
return 0;
@@ -1644,19 +1646,19 @@ static int ptcache_mem_frame_to_disk(PTCacheID *pid, PTCacheMem *pm)
pf->type = pid->type;
pf->flag = 0;
- if(pm->extradata.first)
+ if (pm->extradata.first)
pf->flag |= PTCACHE_TYPEFLAG_EXTRADATA;
- if(pid->cache->compression)
+ if (pid->cache->compression)
pf->flag |= PTCACHE_TYPEFLAG_COMPRESS;
- if(!ptcache_file_header_begin_write(pf) || !pid->write_header(pf))
+ if (!ptcache_file_header_begin_write(pf) || !pid->write_header(pf))
error = 1;
- if(!error) {
- if(pid->cache->compression) {
- for(i=0; i<BPHYS_TOT_DATA; i++) {
- if(pm->data[i]) {
+ if (!error) {
+ if (pid->cache->compression) {
+ for (i=0; i<BPHYS_TOT_DATA; i++) {
+ if (pm->data[i]) {
unsigned int in_len = pm->totpoint*ptcache_data_size[i];
unsigned char *out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len)*4, "pointcache_lzo_buffer");
ptcache_file_compressed_write(pf, (unsigned char*)(pm->data[i]), in_len, out, pid->cache->compression);
@@ -1668,9 +1670,9 @@ static int ptcache_mem_frame_to_disk(PTCacheID *pid, PTCacheMem *pm)
BKE_ptcache_mem_pointers_init(pm);
ptcache_file_pointers_init(pf);
- for(i=0; i<pm->totpoint; i++) {
+ for (i=0; i<pm->totpoint; i++) {
ptcache_data_copy(pm->cur, pf->cur);
- if(!ptcache_file_data_write(pf)) {
+ if (!ptcache_file_data_write(pf)) {
error = 1;
break;
}
@@ -1679,17 +1681,17 @@ static int ptcache_mem_frame_to_disk(PTCacheID *pid, PTCacheMem *pm)
}
}
- if(!error && pm->extradata.first) {
+ if (!error && pm->extradata.first) {
PTCacheExtra *extra = pm->extradata.first;
- for(; extra; extra=extra->next) {
- if(extra->data == NULL || extra->totdata == 0)
+ for (; extra; extra=extra->next) {
+ if (extra->data == NULL || extra->totdata == 0)
continue;
ptcache_file_write(pf, &extra->type, 1, sizeof(unsigned int));
ptcache_file_write(pf, &extra->totdata, 1, sizeof(unsigned int));
- if(pid->cache->compression) {
+ if (pid->cache->compression) {
unsigned int in_len = extra->totdata * ptcache_extra_datasize[extra->type];
unsigned char *out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len)*4, "pointcache_lzo_buffer");
ptcache_file_compressed_write(pf, (unsigned char*)(extra->data), in_len, out, pid->cache->compression);
@@ -1714,25 +1716,25 @@ static int ptcache_read_stream(PTCacheID *pid, int cfra)
PTCacheFile *pf = ptcache_file_open(pid, PTCACHE_FILE_READ, cfra);
int error = 0;
- if(pid->read_stream == NULL)
+ if (pid->read_stream == NULL)
return 0;
- if(pf == NULL) {
+ if (pf == NULL) {
if (G.f & G_DEBUG)
printf("Error opening disk cache file for reading\n");
return 0;
}
- if(!ptcache_file_header_begin_read(pf))
+ if (!ptcache_file_header_begin_read(pf))
error = 1;
- if(!error && (pf->type != pid->type || !pid->read_header(pf)))
+ if (!error && (pf->type != pid->type || !pid->read_header(pf)))
error = 1;
- if(!error && pf->totpoint != pid->totpoint(pid->calldata, cfra))
+ if (!error && pf->totpoint != pid->totpoint(pid->calldata, cfra))
error = 1;
- if(!error) {
+ if (!error) {
ptcache_file_pointers_init(pf);
// we have stream reading here
@@ -1751,27 +1753,27 @@ static int ptcache_read(PTCacheID *pid, int cfra)
int *index = &i;
/* get a memory cache to read from */
- if(pid->cache->flag & PTCACHE_DISK_CACHE) {
+ if (pid->cache->flag & PTCACHE_DISK_CACHE) {
pm = ptcache_disk_frame_to_mem(pid, cfra);
}
else {
pm = pid->cache->mem_cache.first;
- while(pm && pm->frame != cfra)
+ while (pm && pm->frame != cfra)
pm = pm->next;
}
/* read the cache */
- if(pm) {
+ if (pm) {
int totpoint = pm->totpoint;
- if((pid->data_types & (1<<BPHYS_DATA_INDEX)) == 0)
+ if ((pid->data_types & (1<<BPHYS_DATA_INDEX)) == 0)
totpoint = MIN2(totpoint, pid->totpoint(pid->calldata, cfra));
BKE_ptcache_mem_pointers_init(pm);
- for(i=0; i<totpoint; i++) {
- if(pm->data_types & (1<<BPHYS_DATA_INDEX))
+ for (i=0; i<totpoint; i++) {
+ if (pm->data_types & (1<<BPHYS_DATA_INDEX))
index = pm->cur[BPHYS_DATA_INDEX];
pid->read_point(*index, pid->calldata, pm->cur, (float)pm->frame, NULL);
@@ -1779,11 +1781,11 @@ static int ptcache_read(PTCacheID *pid, int cfra)
BKE_ptcache_mem_pointers_incr(pm);
}
- if(pid->read_extra_data && pm->extradata.first)
+ if (pid->read_extra_data && pm->extradata.first)
pid->read_extra_data(pid->calldata, pm, (float)pm->frame);
/* clean up temporary memory cache */
- if(pid->cache->flag & PTCACHE_DISK_CACHE) {
+ if (pid->cache->flag & PTCACHE_DISK_CACHE) {
ptcache_data_free(pm);
ptcache_extra_free(pm);
MEM_freeN(pm);
@@ -1799,38 +1801,38 @@ static int ptcache_interpolate(PTCacheID *pid, float cfra, int cfra1, int cfra2)
int *index = &i;
/* get a memory cache to read from */
- if(pid->cache->flag & PTCACHE_DISK_CACHE) {
+ if (pid->cache->flag & PTCACHE_DISK_CACHE) {
pm = ptcache_disk_frame_to_mem(pid, cfra2);
}
else {
pm = pid->cache->mem_cache.first;
- while(pm && pm->frame != cfra2)
+ while (pm && pm->frame != cfra2)
pm = pm->next;
}
/* read the cache */
- if(pm) {
+ if (pm) {
int totpoint = pm->totpoint;
- if((pid->data_types & (1<<BPHYS_DATA_INDEX)) == 0)
+ if ((pid->data_types & (1<<BPHYS_DATA_INDEX)) == 0)
totpoint = MIN2(totpoint, pid->totpoint(pid->calldata, (int)cfra));
BKE_ptcache_mem_pointers_init(pm);
- for(i=0; i<totpoint; i++) {
- if(pm->data_types & (1<<BPHYS_DATA_INDEX))
+ for (i=0; i<totpoint; i++) {
+ if (pm->data_types & (1<<BPHYS_DATA_INDEX))
index = pm->cur[BPHYS_DATA_INDEX];
pid->interpolate_point(*index, pid->calldata, pm->cur, cfra, (float)cfra1, (float)cfra2, NULL);
BKE_ptcache_mem_pointers_incr(pm);
}
- if(pid->interpolate_extra_data && pm->extradata.first)
+ if (pid->interpolate_extra_data && pm->extradata.first)
pid->interpolate_extra_data(pid->calldata, pm, cfra, (float)cfra1, (float)cfra2);
/* clean up temporary memory cache */
- if(pid->cache->flag & PTCACHE_DISK_CACHE) {
+ if (pid->cache->flag & PTCACHE_DISK_CACHE) {
ptcache_data_free(pm);
ptcache_extra_free(pm);
MEM_freeN(pm);
@@ -1847,70 +1849,70 @@ int BKE_ptcache_read(PTCacheID *pid, float cfra)
int ret = 0;
/* nothing to read to */
- if(pid->totpoint(pid->calldata, cfrai) == 0)
+ if (pid->totpoint(pid->calldata, cfrai) == 0)
return 0;
- if(pid->cache->flag & PTCACHE_READ_INFO) {
+ if (pid->cache->flag & PTCACHE_READ_INFO) {
pid->cache->flag &= ~PTCACHE_READ_INFO;
ptcache_read(pid, 0);
}
/* first check if we have the actual frame cached */
- if(cfra == (float)cfrai && BKE_ptcache_id_exist(pid, cfrai))
+ if (cfra == (float)cfrai && BKE_ptcache_id_exist(pid, cfrai))
cfra1 = cfrai;
/* no exact cache frame found so try to find cached frames around cfra */
- if(cfra1 == 0)
+ if (cfra1 == 0)
ptcache_find_frames_around(pid, cfrai, &cfra1, &cfra2);
- if(cfra1 == 0 && cfra2 == 0)
+ if (cfra1 == 0 && cfra2 == 0)
return 0;
/* don't read old cache if already simulated past cached frame */
- if(cfra1 == 0 && cfra2 && cfra2 <= pid->cache->simframe)
+ if (cfra1 == 0 && cfra2 && cfra2 <= pid->cache->simframe)
return 0;
- if(cfra1 && cfra1 == cfra2)
+ if (cfra1 && cfra1 == cfra2)
return 0;
- if(cfra1) {
+ if (cfra1) {
- if(pid->read_stream) {
+ if (pid->read_stream) {
if (!ptcache_read_stream(pid, cfra1))
return 0;
}
- else if(pid->read_point)
+ else if (pid->read_point)
ptcache_read(pid, cfra1);
}
- if(cfra2) {
+ if (cfra2) {
- if(pid->read_stream) {
+ if (pid->read_stream) {
if (!ptcache_read_stream(pid, cfra2))
return 0;
}
- else if(pid->read_point) {
- if(cfra1 && cfra2 && pid->interpolate_point)
+ else if (pid->read_point) {
+ if (cfra1 && cfra2 && pid->interpolate_point)
ptcache_interpolate(pid, cfra, cfra1, cfra2);
else
ptcache_read(pid, cfra2);
}
}
- if(cfra1)
+ if (cfra1)
ret = (cfra2 ? PTCACHE_READ_INTERPOLATED : PTCACHE_READ_EXACT);
- else if(cfra2) {
+ else if (cfra2) {
ret = PTCACHE_READ_OLD;
pid->cache->simframe = cfra2;
}
- if((pid->cache->flag & PTCACHE_QUICK_CACHE)==0) {
+ if ((pid->cache->flag & PTCACHE_QUICK_CACHE)==0) {
cfrai = (int)cfra;
/* clear invalid cache frames so that better stuff can be simulated */
- if(pid->cache->flag & PTCACHE_OUTDATED) {
+ if (pid->cache->flag & PTCACHE_OUTDATED) {
BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_AFTER, cfrai);
}
- else if(pid->cache->flag & PTCACHE_FRAMES_SKIPPED) {
- if(cfra <= pid->cache->last_exact)
+ else if (pid->cache->flag & PTCACHE_FRAMES_SKIPPED) {
+ if (cfra <= pid->cache->last_exact)
pid->cache->flag &= ~PTCACHE_FRAMES_SKIPPED;
BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_AFTER, MAX2(cfrai, pid->cache->last_exact));
@@ -1928,7 +1930,7 @@ static int ptcache_write_stream(PTCacheID *pid, int cfra, int totpoint)
pf = ptcache_file_open(pid, PTCACHE_FILE_WRITE, cfra);
- if(pf==NULL) {
+ if (pf==NULL) {
if (G.f & G_DEBUG)
printf("Error opening disk cache file for writing\n");
return 0;
@@ -1939,10 +1941,10 @@ static int ptcache_write_stream(PTCacheID *pid, int cfra, int totpoint)
pf->type = pid->type;
pf->flag = 0;
- if(!error && (!ptcache_file_header_begin_write(pf) || !pid->write_header(pf)))
+ if (!error && (!ptcache_file_header_begin_write(pf) || !pid->write_header(pf)))
error = 1;
- if(!error && pid->write_stream)
+ if (!error && pid->write_stream)
pid->write_stream(pf, pid->calldata);
ptcache_file_close(pf);
@@ -1967,11 +1969,11 @@ static int ptcache_write(PTCacheID *pid, int cfra, int overwrite)
ptcache_data_alloc(pm);
BKE_ptcache_mem_pointers_init(pm);
- if(overwrite) {
- if(cache->flag & PTCACHE_DISK_CACHE) {
+ if (overwrite) {
+ if (cache->flag & PTCACHE_DISK_CACHE) {
int fra = cfra-1;
- while(fra >= cache->startframe && !BKE_ptcache_id_exist(pid, fra))
+ while (fra >= cache->startframe && !BKE_ptcache_id_exist(pid, fra))
fra--;
pm2 = ptcache_disk_frame_to_mem(pid, fra);
@@ -1980,25 +1982,25 @@ static int ptcache_write(PTCacheID *pid, int cfra, int overwrite)
pm2 = cache->mem_cache.last;
}
- if(pid->write_point) {
- for(i=0; i<totpoint; i++) {
+ if (pid->write_point) {
+ for (i=0; i<totpoint; i++) {
int write = pid->write_point(i, pid->calldata, pm->cur, cfra);
- if(write) {
+ if (write) {
BKE_ptcache_mem_pointers_incr(pm);
/* newly born particles have to be copied to previous cached frame */
- if(overwrite && write == 2 && pm2 && BKE_ptcache_mem_pointers_seek(i, pm2))
+ if (overwrite && write == 2 && pm2 && BKE_ptcache_mem_pointers_seek(i, pm2))
pid->write_point(i, pid->calldata, pm2->cur, cfra);
}
}
}
- if(pid->write_extra_data)
+ if (pid->write_extra_data)
pid->write_extra_data(pid->calldata, pm, cfra);
pm->frame = cfra;
- if(cache->flag & PTCACHE_DISK_CACHE) {
+ if (cache->flag & PTCACHE_DISK_CACHE) {
error += !ptcache_mem_frame_to_disk(pid, pm);
// if(pm) /* pm is always set */
@@ -2008,7 +2010,7 @@ static int ptcache_write(PTCacheID *pid, int cfra, int overwrite)
MEM_freeN(pm);
}
- if(pm2) {
+ if (pm2) {
error += !ptcache_mem_frame_to_disk(pid, pm2);
ptcache_data_free(pm2);
ptcache_extra_free(pm2);
@@ -2027,40 +2029,40 @@ static int ptcache_write_needed(PTCacheID *pid, int cfra, int *overwrite)
int ofra = 0, efra = cache->endframe;
/* allways start from scratch on the first frame */
- if(cfra && cfra == cache->startframe) {
+ if (cfra && cfra == cache->startframe) {
BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, cfra);
cache->flag &= ~PTCACHE_REDO_NEEDED;
return 1;
}
- if(pid->cache->flag & PTCACHE_DISK_CACHE) {
- if(cfra==0 && cache->startframe > 0)
+ if (pid->cache->flag & PTCACHE_DISK_CACHE) {
+ if (cfra==0 && cache->startframe > 0)
return 1;
/* find last cached frame */
- while(efra > cache->startframe && !BKE_ptcache_id_exist(pid, efra))
+ while (efra > cache->startframe && !BKE_ptcache_id_exist(pid, efra))
efra--;
/* find second last cached frame */
ofra = efra-1;
- while(ofra > cache->startframe && !BKE_ptcache_id_exist(pid, ofra))
+ while (ofra > cache->startframe && !BKE_ptcache_id_exist(pid, ofra))
ofra--;
}
else {
PTCacheMem *pm = cache->mem_cache.last;
/* don't write info file in memory */
- if(cfra == 0)
+ if (cfra == 0)
return 0;
- if(pm == NULL)
+ if (pm == NULL)
return 1;
efra = pm->frame;
ofra = (pm->prev ? pm->prev->frame : efra - cache->step);
}
- if(efra >= cache->startframe && cfra > efra) {
- if(ofra >= cache->startframe && efra - ofra < cache->step) {
+ if (efra >= cache->startframe && cfra > efra) {
+ if (ofra >= cache->startframe && efra - ofra < cache->step) {
/* overwrite previous frame */
BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_FRAME, efra);
*overwrite = 1;
@@ -2077,30 +2079,30 @@ int BKE_ptcache_write(PTCacheID *pid, unsigned int cfra)
int totpoint = pid->totpoint(pid->calldata, cfra);
int overwrite = 0, error = 0;
- if(totpoint == 0 || (cfra ? pid->data_types == 0 : pid->info_types == 0))
+ if (totpoint == 0 || (cfra ? pid->data_types == 0 : pid->info_types == 0))
return 0;
- if(ptcache_write_needed(pid, cfra, &overwrite)==0)
+ if (ptcache_write_needed(pid, cfra, &overwrite)==0)
return 0;
- if(pid->write_stream) {
+ if (pid->write_stream) {
ptcache_write_stream(pid, cfra, totpoint);
}
- else if(pid->write_point) {
+ else if (pid->write_point) {
error += ptcache_write(pid, cfra, overwrite);
}
/* Mark frames skipped if more than 1 frame forwards since last non-skipped frame. */
- if(cfra - cache->last_exact == 1 || cfra == cache->startframe) {
+ if (cfra - cache->last_exact == 1 || cfra == cache->startframe) {
cache->last_exact = cfra;
cache->flag &= ~PTCACHE_FRAMES_SKIPPED;
}
/* Don't mark skipped when writing info file (frame 0) */
- else if(cfra)
+ else if (cfra)
cache->flag |= PTCACHE_FRAMES_SKIPPED;
/* Update timeline cache display */
- if(cfra && cache->cached_frames)
+ if (cfra && cache->cached_frames)
cache->cached_frames[cfra-cache->startframe] = 1;
BKE_ptcache_update_info(pid);
@@ -2125,7 +2127,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
char path_full[MAX_PTCACHE_FILE];
char ext[MAX_PTCACHE_PATH];
- if(!pid || !pid->cache || pid->cache->flag & PTCACHE_BAKED)
+ if (!pid || !pid->cache || pid->cache->flag & PTCACHE_BAKED)
return;
if (pid->cache->flag & PTCACHE_IGNORE_CLEAR)
@@ -2136,7 +2138,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
#ifndef DURIAN_POINTCACHE_LIB_OK
/* don't allow clearing for linked objects */
- if(pid->ob->id.lib)
+ if (pid->ob->id.lib)
return;
#endif
@@ -2147,7 +2149,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
case PTCACHE_CLEAR_ALL:
case PTCACHE_CLEAR_BEFORE:
case PTCACHE_CLEAR_AFTER:
- if(pid->cache->flag & PTCACHE_DISK_CACHE) {
+ if (pid->cache->flag & PTCACHE_DISK_CACHE) {
ptcache_path(pid, path);
len = ptcache_filename(pid, filename, cfra, 0, 0); /* no path */
@@ -2165,7 +2167,8 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
pid->cache->last_exact = MIN2(pid->cache->startframe, 0);
BLI_join_dirfile(path_full, sizeof(path_full), path, de->d_name);
BLI_delete(path_full, 0, 0);
- } else {
+ }
+ else {
/* read the number of the file */
unsigned int frame, len2 = (int)strlen(de->d_name);
char num[7];
@@ -2174,12 +2177,12 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
BLI_strncpy(num, de->d_name + (strlen(de->d_name) - 15), sizeof(num));
frame = atoi(num);
- if((mode==PTCACHE_CLEAR_BEFORE && frame < cfra) ||
+ if ((mode==PTCACHE_CLEAR_BEFORE && frame < cfra) ||
(mode==PTCACHE_CLEAR_AFTER && frame > cfra) ) {
BLI_join_dirfile(path_full, sizeof(path_full), path, de->d_name);
BLI_delete(path_full, 0, 0);
- if(pid->cache->cached_frames && frame >=sta && frame <= end)
+ if (pid->cache->cached_frames && frame >=sta && frame <= end)
pid->cache->cached_frames[frame-sta] = 0;
}
}
@@ -2189,30 +2192,31 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
}
closedir(dir);
- if(mode == PTCACHE_CLEAR_ALL && pid->cache->cached_frames)
+ if (mode == PTCACHE_CLEAR_ALL && pid->cache->cached_frames)
memset(pid->cache->cached_frames, 0, MEM_allocN_len(pid->cache->cached_frames));
}
else {
PTCacheMem *pm= pid->cache->mem_cache.first;
PTCacheMem *link= NULL;
- if(mode == PTCACHE_CLEAR_ALL) {
+ if (mode == PTCACHE_CLEAR_ALL) {
/*we want startframe if the cache starts before zero*/
pid->cache->last_exact = MIN2(pid->cache->startframe, 0);
- for(; pm; pm=pm->next) {
+ for (; pm; pm=pm->next) {
ptcache_data_free(pm);
ptcache_extra_free(pm);
}
BLI_freelistN(&pid->cache->mem_cache);
- if(pid->cache->cached_frames)
+ if (pid->cache->cached_frames)
memset(pid->cache->cached_frames, 0, MEM_allocN_len(pid->cache->cached_frames));
- } else {
- while(pm) {
- if((mode==PTCACHE_CLEAR_BEFORE && pm->frame < cfra) ||
+ }
+ else {
+ while (pm) {
+ if ((mode==PTCACHE_CLEAR_BEFORE && pm->frame < cfra) ||
(mode==PTCACHE_CLEAR_AFTER && pm->frame > cfra) ) {
link = pm;
- if(pid->cache->cached_frames && pm->frame >=sta && pm->frame <= end)
+ if (pid->cache->cached_frames && pm->frame >=sta && pm->frame <= end)
pid->cache->cached_frames[pm->frame-sta] = 0;
ptcache_data_free(pm);
ptcache_extra_free(pm);
@@ -2227,8 +2231,8 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
break;
case PTCACHE_CLEAR_FRAME:
- if(pid->cache->flag & PTCACHE_DISK_CACHE) {
- if(BKE_ptcache_id_exist(pid, cfra)) {
+ if (pid->cache->flag & PTCACHE_DISK_CACHE) {
+ if (BKE_ptcache_id_exist(pid, cfra)) {
ptcache_filename(pid, filename, cfra, 1, 1); /* no path */
BLI_delete(filename, 0, 0);
}
@@ -2236,8 +2240,8 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
else {
PTCacheMem *pm = pid->cache->mem_cache.first;
- for(; pm; pm=pm->next) {
- if(pm->frame == cfra) {
+ for (; pm; pm=pm->next) {
+ if (pm->frame == cfra) {
ptcache_data_free(pm);
ptcache_extra_free(pm);
BLI_freelinkN(&pid->cache->mem_cache, pm);
@@ -2245,7 +2249,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
}
}
}
- if(pid->cache->cached_frames && cfra>=sta && cfra<=end)
+ if (pid->cache->cached_frames && cfra>=sta && cfra<=end)
pid->cache->cached_frames[cfra-sta] = 0;
break;
}
@@ -2254,16 +2258,16 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
}
int BKE_ptcache_id_exist(PTCacheID *pid, int cfra)
{
- if(!pid->cache)
+ if (!pid->cache)
return 0;
- if(cfra<pid->cache->startframe || cfra > pid->cache->endframe)
+ if (cfra<pid->cache->startframe || cfra > pid->cache->endframe)
return 0;
- if(pid->cache->cached_frames && pid->cache->cached_frames[cfra-pid->cache->startframe]==0)
+ if (pid->cache->cached_frames && pid->cache->cached_frames[cfra-pid->cache->startframe]==0)
return 0;
- if(pid->cache->flag & PTCACHE_DISK_CACHE) {
+ if (pid->cache->flag & PTCACHE_DISK_CACHE) {
char filename[MAX_PTCACHE_FILE];
ptcache_filename(pid, filename, cfra, 1, 1);
@@ -2273,8 +2277,8 @@ int BKE_ptcache_id_exist(PTCacheID *pid, int cfra)
else {
PTCacheMem *pm = pid->cache->mem_cache.first;
- for(; pm; pm=pm->next) {
- if(pm->frame==cfra)
+ for (; pm; pm=pm->next) {
+ if (pm->frame==cfra)
return 1;
}
return 0;
@@ -2302,14 +2306,14 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra
/* ob= pid->ob; */ /* UNUSED */
cache= pid->cache;
- if(timescale) {
+ if (timescale) {
time= BKE_curframe(scene);
nexttime= BKE_frame_to_ctime(scene, CFRA+1);
*timescale= MAX2(nexttime - time, 0.0f);
}
- if(startframe && endframe) {
+ if (startframe && endframe) {
*startframe= cache->startframe;
*endframe= cache->endframe;
@@ -2328,20 +2332,20 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra
}
/* verify cached_frames array is up to date */
- if(cache->cached_frames) {
- if(MEM_allocN_len(cache->cached_frames) != sizeof(char) * (cache->endframe-cache->startframe+1)) {
+ if (cache->cached_frames) {
+ if (MEM_allocN_len(cache->cached_frames) != sizeof(char) * (cache->endframe-cache->startframe+1)) {
MEM_freeN(cache->cached_frames);
cache->cached_frames = NULL;
}
}
- if(cache->cached_frames==NULL && cache->endframe > cache->startframe) {
+ if (cache->cached_frames==NULL && cache->endframe > cache->startframe) {
unsigned int sta=cache->startframe;
unsigned int end=cache->endframe;
cache->cached_frames = MEM_callocN(sizeof(char) * (cache->endframe-cache->startframe+1), "cached frames array");
- if(pid->cache->flag & PTCACHE_DISK_CACHE) {
+ if (pid->cache->flag & PTCACHE_DISK_CACHE) {
/* mode is same as fopen's modes */
DIR *dir;
struct dirent *de;
@@ -2371,7 +2375,7 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra
BLI_strncpy(num, de->d_name + (strlen(de->d_name) - 15), sizeof(num));
frame = atoi(num);
- if(frame >= sta && frame <= end)
+ if (frame >= sta && frame <= end)
cache->cached_frames[frame-sta] = 1;
}
}
@@ -2382,8 +2386,8 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra
else {
PTCacheMem *pm= pid->cache->mem_cache.first;
- while(pm) {
- if(pm->frame >= sta && pm->frame <= end)
+ while (pm) {
+ if (pm->frame >= sta && pm->frame <= end)
cache->cached_frames[pm->frame-sta] = 1;
pm = pm->next;
}
@@ -2395,7 +2399,7 @@ int BKE_ptcache_id_reset(Scene *scene, PTCacheID *pid, int mode)
PointCache *cache;
int reset, clear, after;
- if(!pid->cache)
+ if (!pid->cache)
return 0;
cache= pid->cache;
@@ -2403,9 +2407,9 @@ int BKE_ptcache_id_reset(Scene *scene, PTCacheID *pid, int mode)
clear= 0;
after= 0;
- if(mode == PTCACHE_RESET_DEPSGRAPH) {
- if(!(cache->flag & PTCACHE_BAKED) && !BKE_ptcache_get_continue_physics()) {
- if(cache->flag & PTCACHE_QUICK_CACHE)
+ if (mode == PTCACHE_RESET_DEPSGRAPH) {
+ if (!(cache->flag & PTCACHE_BAKED) && !BKE_ptcache_get_continue_physics()) {
+ if (cache->flag & PTCACHE_QUICK_CACHE)
clear= 1;
after= 1;
@@ -2413,43 +2417,43 @@ int BKE_ptcache_id_reset(Scene *scene, PTCacheID *pid, int mode)
cache->flag |= PTCACHE_OUTDATED;
}
- else if(mode == PTCACHE_RESET_BAKED) {
- if(!BKE_ptcache_get_continue_physics()) {
+ else if (mode == PTCACHE_RESET_BAKED) {
+ if (!BKE_ptcache_get_continue_physics()) {
reset= 1;
clear= 1;
}
else
cache->flag |= PTCACHE_OUTDATED;
}
- else if(mode == PTCACHE_RESET_OUTDATED) {
+ else if (mode == PTCACHE_RESET_OUTDATED) {
reset = 1;
- if(cache->flag & PTCACHE_OUTDATED && !(cache->flag & PTCACHE_BAKED)) {
+ if (cache->flag & PTCACHE_OUTDATED && !(cache->flag & PTCACHE_BAKED)) {
clear= 1;
cache->flag &= ~PTCACHE_OUTDATED;
}
}
- if(reset) {
+ if (reset) {
BKE_ptcache_invalidate(cache);
cache->flag &= ~PTCACHE_REDO_NEEDED;
- if(pid->type == PTCACHE_TYPE_CLOTH)
+ if (pid->type == PTCACHE_TYPE_CLOTH)
cloth_free_modifier(pid->calldata);
- else if(pid->type == PTCACHE_TYPE_SOFTBODY)
+ else if (pid->type == PTCACHE_TYPE_SOFTBODY)
sbFreeSimulation(pid->calldata);
- else if(pid->type == PTCACHE_TYPE_PARTICLES)
+ else if (pid->type == PTCACHE_TYPE_PARTICLES)
psys_reset(pid->calldata, PSYS_RESET_DEPSGRAPH);
- else if(pid->type == PTCACHE_TYPE_SMOKE_DOMAIN)
+ else if (pid->type == PTCACHE_TYPE_SMOKE_DOMAIN)
smokeModifier_reset(pid->calldata);
- else if(pid->type == PTCACHE_TYPE_SMOKE_HIGHRES)
+ else if (pid->type == PTCACHE_TYPE_SMOKE_HIGHRES)
smokeModifier_reset_turbulence(pid->calldata);
- else if(pid->type == PTCACHE_TYPE_DYNAMICPAINT)
+ else if (pid->type == PTCACHE_TYPE_DYNAMICPAINT)
dynamicPaint_clearSurface((DynamicPaintSurface*)pid->calldata);
}
- if(clear)
+ if (clear)
BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
- else if(after)
+ else if (after)
BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_AFTER, CFRA);
return (reset || clear || after);
@@ -2464,47 +2468,47 @@ int BKE_ptcache_object_reset(Scene *scene, Object *ob, int mode)
reset= 0;
skip= 0;
- if(ob->soft) {
+ if (ob->soft) {
BKE_ptcache_id_from_softbody(&pid, ob, ob->soft);
reset |= BKE_ptcache_id_reset(scene, &pid, mode);
}
- for(psys=ob->particlesystem.first; psys; psys=psys->next) {
+ for (psys=ob->particlesystem.first; psys; psys=psys->next) {
/* children or just redo can be calculated without reseting anything */
- if(psys->recalc & PSYS_RECALC_REDO || psys->recalc & PSYS_RECALC_CHILD)
+ if (psys->recalc & PSYS_RECALC_REDO || psys->recalc & PSYS_RECALC_CHILD)
skip = 1;
/* Baked cloth hair has to be checked too, because we don't want to reset */
/* particles or cloth in that case -jahka */
- else if(psys->clmd) {
+ else if (psys->clmd) {
BKE_ptcache_id_from_cloth(&pid, ob, psys->clmd);
- if(mode == PSYS_RESET_ALL || !(psys->part->type == PART_HAIR && (pid.cache->flag & PTCACHE_BAKED)))
+ if (mode == PSYS_RESET_ALL || !(psys->part->type == PART_HAIR && (pid.cache->flag & PTCACHE_BAKED)))
reset |= BKE_ptcache_id_reset(scene, &pid, mode);
else
skip = 1;
}
- if(skip == 0 && psys->part) {
+ if (skip == 0 && psys->part) {
BKE_ptcache_id_from_particles(&pid, ob, psys);
reset |= BKE_ptcache_id_reset(scene, &pid, mode);
}
}
- for(md=ob->modifiers.first; md; md=md->next) {
- if(md->type == eModifierType_Cloth) {
+ for (md=ob->modifiers.first; md; md=md->next) {
+ if (md->type == eModifierType_Cloth) {
BKE_ptcache_id_from_cloth(&pid, ob, (ClothModifierData*)md);
reset |= BKE_ptcache_id_reset(scene, &pid, mode);
}
- if(md->type == eModifierType_Smoke) {
+ if (md->type == eModifierType_Smoke) {
SmokeModifierData *smd = (SmokeModifierData *)md;
- if(smd->type & MOD_SMOKE_TYPE_DOMAIN)
+ if (smd->type & MOD_SMOKE_TYPE_DOMAIN)
{
BKE_ptcache_id_from_smoke(&pid, ob, (SmokeModifierData*)md);
reset |= BKE_ptcache_id_reset(scene, &pid, mode);
}
}
- if(md->type == eModifierType_DynamicPaint) {
+ if (md->type == eModifierType_DynamicPaint) {
DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
- if(pmd->canvas)
+ if (pmd->canvas)
{
DynamicPaintSurface *surface = pmd->canvas->surfaces.first;
@@ -2542,18 +2546,21 @@ void BKE_ptcache_remove(void)
return;
while ((de = readdir(dir)) != NULL) {
- if( strcmp(de->d_name, ".")==0 || strcmp(de->d_name, "..")==0) {
+ if ( strcmp(de->d_name, ".")==0 || strcmp(de->d_name, "..")==0) {
/* do nothing */
- } else if (strstr(de->d_name, PTCACHE_EXT)) { /* do we have the right extension?*/
+ }
+ else if (strstr(de->d_name, PTCACHE_EXT)) { /* do we have the right extension?*/
BLI_join_dirfile(path_full, sizeof(path_full), path, de->d_name);
BLI_delete(path_full, 0, 0);
- } else {
+ }
+ else {
rmdir = 0; /* unknown file, don't remove the dir */
}
}
closedir(dir);
- } else {
+ }
+ else {
rmdir = 0; /* path dosnt exist */
}
@@ -2570,12 +2577,12 @@ void BKE_ptcache_set_continue_physics(Main *bmain, Scene *scene, int enable)
{
Object *ob;
- if(CONTINUE_PHYSICS != enable) {
+ if (CONTINUE_PHYSICS != enable) {
CONTINUE_PHYSICS = enable;
- if(CONTINUE_PHYSICS == 0) {
- for(ob=bmain->object.first; ob; ob=ob->id.next)
- if(BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_OUTDATED))
+ if (CONTINUE_PHYSICS == 0) {
+ for (ob=bmain->object.first; ob; ob=ob->id.next)
+ if (BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_OUTDATED))
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
}
}
@@ -2607,8 +2614,8 @@ void BKE_ptcache_free_mem(ListBase *mem_cache)
{
PTCacheMem *pm = mem_cache->first;
- if(pm) {
- for(; pm; pm=pm->next) {
+ if (pm) {
+ for (; pm; pm=pm->next) {
ptcache_data_free(pm);
ptcache_extra_free(pm);
}
@@ -2619,9 +2626,9 @@ void BKE_ptcache_free_mem(ListBase *mem_cache)
void BKE_ptcache_free(PointCache *cache)
{
BKE_ptcache_free_mem(&cache->mem_cache);
- if(cache->edit && cache->free_edit)
+ if (cache->edit && cache->free_edit)
cache->free_edit(cache->edit);
- if(cache->cached_frames)
+ if (cache->cached_frames)
MEM_freeN(cache->cached_frames);
MEM_freeN(cache);
}
@@ -2629,7 +2636,7 @@ void BKE_ptcache_free_list(ListBase *ptcaches)
{
PointCache *cache = ptcaches->first;
- while(cache) {
+ while (cache) {
BLI_remlink(ptcaches, cache);
BKE_ptcache_free(cache);
cache = ptcaches->first;
@@ -2660,7 +2667,7 @@ PointCache *BKE_ptcache_copy_list(ListBase *ptcaches_new, ListBase *ptcaches_old
ptcaches_new->first = ptcaches_new->last = NULL;
- for(; cache; cache=cache->next)
+ for (; cache; cache=cache->next)
BLI_addtail(ptcaches_new, ptcache_copy(cache));
return ptcaches_new->first;
@@ -2702,8 +2709,8 @@ typedef struct {
static void ptcache_dt_to_str(char *str, double dtime)
{
- if(dtime > 60.0) {
- if(dtime > 3600.0)
+ if (dtime > 60.0) {
+ if (dtime > 3600.0)
sprintf(str, "%ih %im %is", (int)(dtime/3600), ((int)(dtime/60))%60, ((int)dtime) % 60);
else
sprintf(str, "%im %is", ((int)(dtime/60))%60, ((int)dtime) % 60);
@@ -2724,9 +2731,9 @@ static void *ptcache_bake_thread(void *ptr)
sfra = *data->cfra_ptr;
efra = data->endframe;
- for(; (*data->cfra_ptr <= data->endframe) && !data->break_operation; *data->cfra_ptr+=data->step) {
+ for (; (*data->cfra_ptr <= data->endframe) && !data->break_operation; *data->cfra_ptr+=data->step) {
scene_update_for_newframe(data->main, data->scene, data->scene->lay);
- if(G.background) {
+ if (G.background) {
printf("bake: frame %d :: %d\n", (int)*data->cfra_ptr, data->endframe);
}
else {
@@ -2734,7 +2741,7 @@ static void *ptcache_bake_thread(void *ptr)
fetd = (ctime-ptime)*(efra-*data->cfra_ptr)/data->step;
- if(usetimer || fetd > 60.0) {
+ if (usetimer || fetd > 60.0) {
usetimer = 1;
ptcache_dt_to_str(cur, ctime-ptime);
@@ -2747,7 +2754,7 @@ static void *ptcache_bake_thread(void *ptr)
}
}
- if(usetimer) {
+ if (usetimer) {
ptcache_dt_to_str(run, PIL_check_seconds_timer()-stime);
printf("Bake %s %s (%i frames simulated). \n", (data->break_operation ? "canceled after" : "finished in"), run, *data->cfra_ptr-sfra);
}
@@ -2784,29 +2791,29 @@ void BKE_ptcache_bake(PTCacheBaker* baker)
G.afbreek = 0;
/* set caches to baking mode and figure out start frame */
- if(pid) {
+ if (pid) {
/* cache/bake a single object */
cache = pid->cache;
- if((cache->flag & PTCACHE_BAKED)==0) {
- if(pid->type==PTCACHE_TYPE_PARTICLES) {
+ if ((cache->flag & PTCACHE_BAKED)==0) {
+ if (pid->type==PTCACHE_TYPE_PARTICLES) {
ParticleSystem *psys= pid->calldata;
/* a bit confusing, could make this work better in the UI */
- if(psys->part->type == PART_EMITTER)
+ if (psys->part->type == PART_EMITTER)
psys_get_pointcache_start_end(scene, pid->calldata, &cache->startframe, &cache->endframe);
}
- else if(pid->type == PTCACHE_TYPE_SMOKE_HIGHRES) {
+ else if (pid->type == PTCACHE_TYPE_SMOKE_HIGHRES) {
/* get all pids from the object and search for smoke low res */
ListBase pidlist2;
PTCacheID *pid2;
BKE_ptcache_ids_from_object(&pidlist2, pid->ob, scene, MAX_DUPLI_RECUR);
- for(pid2=pidlist2.first; pid2; pid2=pid2->next) {
- if(pid2->type == PTCACHE_TYPE_SMOKE_DOMAIN)
+ for (pid2=pidlist2.first; pid2; pid2=pid2->next) {
+ if (pid2->type == PTCACHE_TYPE_SMOKE_DOMAIN)
{
- if(pid2->cache && !(pid2->cache->flag & PTCACHE_BAKED)) {
- if(bake || pid2->cache->flag & PTCACHE_REDO_NEEDED)
+ if (pid2->cache && !(pid2->cache->flag & PTCACHE_BAKED)) {
+ if (bake || pid2->cache->flag & PTCACHE_REDO_NEEDED)
BKE_ptcache_id_clear(pid2, PTCACHE_CLEAR_ALL, 0);
- if(bake) {
+ if (bake) {
pid2->cache->flag |= PTCACHE_BAKING;
pid2->cache->flag &= ~PTCACHE_BAKED;
}
@@ -2816,12 +2823,12 @@ void BKE_ptcache_bake(PTCacheBaker* baker)
BLI_freelistN(&pidlist2);
}
- if(bake || cache->flag & PTCACHE_REDO_NEEDED)
+ if (bake || cache->flag & PTCACHE_REDO_NEEDED)
BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
startframe = MAX2(cache->last_exact, cache->startframe);
- if(bake) {
+ if (bake) {
thread_data.endframe = cache->endframe;
cache->flag |= PTCACHE_BAKING;
}
@@ -2836,28 +2843,28 @@ void BKE_ptcache_bake(PTCacheBaker* baker)
/* cache/bake everything in the scene */
BKE_ptcache_ids_from_object(&pidlist, base->object, scene, MAX_DUPLI_RECUR);
- for(pid=pidlist.first; pid; pid=pid->next) {
+ for (pid=pidlist.first; pid; pid=pid->next) {
cache = pid->cache;
- if((cache->flag & PTCACHE_BAKED)==0) {
- if(pid->type==PTCACHE_TYPE_PARTICLES) {
+ if ((cache->flag & PTCACHE_BAKED)==0) {
+ if (pid->type==PTCACHE_TYPE_PARTICLES) {
ParticleSystem *psys = (ParticleSystem*)pid->calldata;
/* skip hair & keyed particles */
- if(psys->part->type == PART_HAIR || psys->part->phystype == PART_PHYS_KEYED)
+ if (psys->part->type == PART_HAIR || psys->part->phystype == PART_PHYS_KEYED)
continue;
psys_get_pointcache_start_end(scene, pid->calldata, &cache->startframe, &cache->endframe);
}
- if((cache->flag & PTCACHE_REDO_NEEDED || (cache->flag & PTCACHE_SIMULATION_VALID)==0)
+ if ((cache->flag & PTCACHE_REDO_NEEDED || (cache->flag & PTCACHE_SIMULATION_VALID)==0)
&& ((cache->flag & PTCACHE_QUICK_CACHE)==0 || render || bake))
BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
startframe = MIN2(startframe, cache->startframe);
- if(bake || render) {
+ if (bake || render) {
cache->flag |= PTCACHE_BAKING;
- if(bake)
+ if (bake)
thread_data.endframe = MAX2(thread_data.endframe, cache->endframe);
}
@@ -2876,7 +2883,7 @@ void BKE_ptcache_bake(PTCacheBaker* baker)
WM_cursor_wait(1);
- if(G.background) {
+ if (G.background) {
ptcache_bake_thread((void*)&thread_data);
}
else {
@@ -2885,7 +2892,7 @@ void BKE_ptcache_bake(PTCacheBaker* baker)
while (thread_data.thread_ended == FALSE) {
- if(bake)
+ if (bake)
progress = (int)(100.0f * (float)(CFRA - startframe)/(float)(thread_data.endframe-startframe));
else
progress = CFRA;
@@ -2900,7 +2907,7 @@ void BKE_ptcache_bake(PTCacheBaker* baker)
PIL_sleep_ms(200);
/* NOTE: breaking baking should leave calculated frames in cache, not clear it */
- if(blender_test_break() && !thread_data.break_operation) {
+ if (blender_test_break() && !thread_data.break_operation) {
thread_data.break_operation = TRUE;
if (baker->progressend)
baker->progressend(baker->progresscontext);
@@ -2911,36 +2918,36 @@ void BKE_ptcache_bake(PTCacheBaker* baker)
BLI_end_threads(&threads);
}
/* clear baking flag */
- if(pid) {
+ if (pid) {
cache->flag &= ~(PTCACHE_BAKING|PTCACHE_REDO_NEEDED);
cache->flag |= PTCACHE_SIMULATION_VALID;
- if(bake) {
+ if (bake) {
cache->flag |= PTCACHE_BAKED;
/* write info file */
- if(cache->flag & PTCACHE_DISK_CACHE)
+ if (cache->flag & PTCACHE_DISK_CACHE)
BKE_ptcache_write(pid, 0);
}
}
else for(SETLOOPER(scene, sce_iter, base)) {
BKE_ptcache_ids_from_object(&pidlist, base->object, scene, MAX_DUPLI_RECUR);
- for(pid=pidlist.first; pid; pid=pid->next) {
+ for (pid=pidlist.first; pid; pid=pid->next) {
/* skip hair particles */
- if(pid->type==PTCACHE_TYPE_PARTICLES && ((ParticleSystem*)pid->calldata)->part->type == PART_HAIR)
+ if (pid->type==PTCACHE_TYPE_PARTICLES && ((ParticleSystem*)pid->calldata)->part->type == PART_HAIR)
continue;
cache = pid->cache;
- if(thread_data.step > 1)
+ if (thread_data.step > 1)
cache->flag &= ~(PTCACHE_BAKING|PTCACHE_OUTDATED);
else
cache->flag &= ~(PTCACHE_BAKING|PTCACHE_REDO_NEEDED);
cache->flag |= PTCACHE_SIMULATION_VALID;
- if(bake) {
+ if (bake) {
cache->flag |= PTCACHE_BAKED;
- if(cache->flag & PTCACHE_DISK_CACHE)
+ if (cache->flag & PTCACHE_DISK_CACHE)
BKE_ptcache_write(pid, 0);
}
}
@@ -2950,7 +2957,7 @@ void BKE_ptcache_bake(PTCacheBaker* baker)
scene->r.framelen = frameleno;
CFRA = cfrao;
- if(bake) /* already on cfra unless baking */
+ if (bake) /* already on cfra unless baking */
scene_update_for_newframe(bmain, scene, scene->lay);
if (thread_data.break_operation)
@@ -2979,10 +2986,10 @@ void BKE_ptcache_disk_to_mem(PTCacheID *pid)
/* restore possible bake flag */
cache->flag |= baked;
- for(cfra=sfra; cfra <= efra; cfra++) {
+ for (cfra=sfra; cfra <= efra; cfra++) {
pm = ptcache_disk_frame_to_mem(pid, cfra);
- if(pm)
+ if (pm)
BLI_addtail(&pid->cache->mem_cache, pm);
}
}
@@ -3001,15 +3008,15 @@ void BKE_ptcache_mem_to_disk(PTCacheID *pid)
/* restore possible bake flag */
cache->flag |= baked;
- for(; pm; pm=pm->next) {
- if(ptcache_mem_frame_to_disk(pid, pm)==0) {
+ for (; pm; pm=pm->next) {
+ if (ptcache_mem_frame_to_disk(pid, pm)==0) {
cache->flag &= ~PTCACHE_DISK_CACHE;
break;
}
}
/* write info file */
- if(cache->flag & PTCACHE_BAKED)
+ if (cache->flag & PTCACHE_BAKED)
BKE_ptcache_write(pid, 0);
}
void BKE_ptcache_toggle_disk_cache(PTCacheID *pid)
@@ -3024,12 +3031,12 @@ void BKE_ptcache_toggle_disk_cache(PTCacheID *pid)
return;
}
- if(cache->cached_frames) {
+ if (cache->cached_frames) {
MEM_freeN(cache->cached_frames);
cache->cached_frames=NULL;
}
- if(cache->flag & PTCACHE_DISK_CACHE)
+ if (cache->flag & PTCACHE_DISK_CACHE)
BKE_ptcache_mem_to_disk(pid);
else
BKE_ptcache_disk_to_mem(pid);
@@ -3068,7 +3075,7 @@ void BKE_ptcache_disk_cache_rename(PTCacheID *pid, const char *name_src, const c
ptcache_path(pid, path);
dir = opendir(path);
- if(dir==NULL) {
+ if (dir==NULL) {
BLI_strncpy(pid->cache->name, old_name, sizeof(pid->cache->name));
return;
}
@@ -3117,7 +3124,7 @@ void BKE_ptcache_load_external(PTCacheID *pid)
char filename[MAX_PTCACHE_FILE];
char ext[MAX_PTCACHE_PATH];
- if(!cache)
+ if (!cache)
return;
ptcache_path(pid, path);
@@ -3128,7 +3135,7 @@ void BKE_ptcache_load_external(PTCacheID *pid)
if (dir==NULL)
return;
- if(cache->index >= 0)
+ if (cache->index >= 0)
BLI_snprintf(ext, sizeof(ext), "_%02d"PTCACHE_EXT, cache->index);
else
BLI_strncpy(ext, PTCACHE_EXT, sizeof(ext));
@@ -3144,7 +3151,7 @@ void BKE_ptcache_load_external(PTCacheID *pid)
BLI_strncpy(num, de->d_name + (strlen(de->d_name) - 15), sizeof(num));
frame = atoi(num);
- if(frame) {
+ if (frame) {
start = MIN2(start, frame);
end = MAX2(end, frame);
}
@@ -3156,22 +3163,22 @@ void BKE_ptcache_load_external(PTCacheID *pid)
}
closedir(dir);
- if(start != MAXFRAME) {
+ if (start != MAXFRAME) {
PTCacheFile *pf;
cache->startframe = start;
cache->endframe = end;
cache->totpoint = 0;
- if(pid->type == PTCACHE_TYPE_SMOKE_DOMAIN)
+ if (pid->type == PTCACHE_TYPE_SMOKE_DOMAIN)
; /*necessary info in every file*/
/* read totpoint from info file (frame 0) */
- else if(info) {
+ else if (info) {
pf= ptcache_file_open(pid, PTCACHE_FILE_READ, 0);
- if(pf) {
- if(ptcache_file_header_begin_read(pf)) {
- if(pf->type == pid->type && pid->read_header(pf)) {
+ if (pf) {
+ if (ptcache_file_header_begin_read(pf)) {
+ if (pf->type == pid->type && pid->read_header(pf)) {
cache->totpoint = pf->totpoint;
cache->flag |= PTCACHE_READ_INFO;
}
@@ -3188,8 +3195,8 @@ void BKE_ptcache_load_external(PTCacheID *pid)
int elemsize = ptcache_old_elemsize(pid);
pf= ptcache_file_open(pid, PTCACHE_FILE_READ, cache->startframe);
- if(pf) {
- while(ptcache_file_read(pf, old_data, 1, elemsize))
+ if (pf) {
+ while (ptcache_file_read(pf, old_data, 1, elemsize))
cache->totpoint++;
ptcache_file_close(pf);
@@ -3209,30 +3216,30 @@ void BKE_ptcache_update_info(PTCacheID *pid)
int totframes = 0;
char mem_info[64];
- if(cache->flag & PTCACHE_EXTERNAL) {
+ if (cache->flag & PTCACHE_EXTERNAL) {
int cfra = cache->startframe;
- for(; cfra<=cache->endframe; cfra++) {
- if(BKE_ptcache_id_exist(pid, cfra))
+ for (; cfra<=cache->endframe; cfra++) {
+ if (BKE_ptcache_id_exist(pid, cfra))
totframes++;
}
/* smoke doesn't use frame 0 as info frame so can't check based on totpoint */
- if(pid->type == PTCACHE_TYPE_SMOKE_DOMAIN && totframes)
+ if (pid->type == PTCACHE_TYPE_SMOKE_DOMAIN && totframes)
BLI_snprintf(cache->info, sizeof(cache->info), "%i frames found!", totframes);
- else if(totframes && cache->totpoint)
+ else if (totframes && cache->totpoint)
BLI_snprintf(cache->info, sizeof(cache->info), "%i points found!", cache->totpoint);
else
BLI_snprintf(cache->info, sizeof(cache->info), "No valid data to read!");
return;
}
- if(cache->flag & PTCACHE_DISK_CACHE) {
- if(pid->type == PTCACHE_TYPE_SMOKE_DOMAIN)
+ if (cache->flag & PTCACHE_DISK_CACHE) {
+ if (pid->type == PTCACHE_TYPE_SMOKE_DOMAIN)
{
int totpoint = pid->totpoint(pid->calldata, 0);
- if(cache->totpoint > totpoint)
+ if (cache->totpoint > totpoint)
BLI_snprintf(mem_info, sizeof(mem_info), "%i cells + High Resolution cached", totpoint);
else
BLI_snprintf(mem_info, sizeof(mem_info), "%i cells cached", totpoint);
@@ -3240,8 +3247,8 @@ void BKE_ptcache_update_info(PTCacheID *pid)
else {
int cfra = cache->startframe;
- for(; cfra<=cache->endframe; cfra++) {
- if(BKE_ptcache_id_exist(pid, cfra))
+ for (; cfra<=cache->endframe; cfra++) {
+ if (BKE_ptcache_id_exist(pid, cfra))
totframes++;
}
@@ -3253,11 +3260,11 @@ void BKE_ptcache_update_info(PTCacheID *pid)
float bytes = 0.0f;
int i, mb;
- for(; pm; pm=pm->next) {
- for(i=0; i<BPHYS_TOT_DATA; i++)
+ for (; pm; pm=pm->next) {
+ for (i=0; i<BPHYS_TOT_DATA; i++)
bytes += MEM_allocN_len(pm->data[i]);
- for(extra=pm->extradata.first; extra; extra=extra->next) {
+ for (extra=pm->extradata.first; extra; extra=extra->next) {
bytes += MEM_allocN_len(extra->data);
bytes += sizeof(PTCacheExtra);
}
@@ -3275,10 +3282,10 @@ void BKE_ptcache_update_info(PTCacheID *pid)
mb ? "Mb" : "kb");
}
- if(cache->flag & PTCACHE_OUTDATED) {
+ if (cache->flag & PTCACHE_OUTDATED) {
BLI_snprintf(cache->info, sizeof(cache->info), "%s, cache is outdated!", mem_info);
}
- else if(cache->flag & PTCACHE_FRAMES_SKIPPED) {
+ else if (cache->flag & PTCACHE_FRAMES_SKIPPED) {
BLI_snprintf(cache->info, sizeof(cache->info), "%s, not exact since frame %i.", mem_info, cache->last_exact);
}
else {
@@ -3288,14 +3295,14 @@ void BKE_ptcache_update_info(PTCacheID *pid)
void BKE_ptcache_validate(PointCache *cache, int framenr)
{
- if(cache) {
+ if (cache) {
cache->flag |= PTCACHE_SIMULATION_VALID;
cache->simframe = framenr;
}
}
void BKE_ptcache_invalidate(PointCache *cache)
{
- if(cache) {
+ if (cache) {
cache->flag &= ~PTCACHE_SIMULATION_VALID;
cache->simframe = 0;
cache->last_exact = MIN2(cache->startframe, 0);
diff --git a/source/blender/blenkernel/intern/property.c b/source/blender/blenkernel/intern/property.c
index 9daee575080..066de61575d 100644
--- a/source/blender/blenkernel/intern/property.c
+++ b/source/blender/blenkernel/intern/property.c
@@ -48,7 +48,7 @@
void free_property(bProperty *prop)
{
- if(prop->poin && prop->poin != &prop->data) MEM_freeN(prop->poin);
+ if (prop->poin && prop->poin != &prop->data) MEM_freeN(prop->poin);
MEM_freeN(prop);
}
@@ -57,7 +57,7 @@ void free_properties(ListBase *lb)
{
bProperty *prop;
- while( (prop= lb->first) ) {
+ while ( (prop= lb->first) ) {
BLI_remlink(lb, prop);
free_property(prop);
}
@@ -68,7 +68,7 @@ bProperty *copy_property(bProperty *prop)
bProperty *propn;
propn= MEM_dupallocN(prop);
- if(prop->poin && prop->poin != &prop->data) {
+ if (prop->poin && prop->poin != &prop->data) {
propn->poin= MEM_dupallocN(prop->poin);
}
else propn->poin= &propn->data;
@@ -81,7 +81,7 @@ void copy_properties(ListBase *lbn, ListBase *lbo)
bProperty *prop, *propn;
free_properties(lbn); /* in case we are copying to an object with props */
prop= lbo->first;
- while(prop) {
+ while (prop) {
propn= copy_property(prop);
BLI_addtail(lbn, propn);
prop= prop->next;
@@ -94,7 +94,7 @@ void init_property(bProperty *prop)
{
/* also use when property changes type */
- if(prop->poin && prop->poin != &prop->data) MEM_freeN(prop->poin);
+ if (prop->poin && prop->poin != &prop->data) MEM_freeN(prop->poin);
prop->poin= NULL;
prop->data= 0;
@@ -131,7 +131,7 @@ bProperty *new_property(int type)
static bProperty *get_property__internal(bProperty *first, bProperty *self, const char *name)
{
bProperty *p;
- for(p= first; p; p= p->next) {
+ for (p= first; p; p= p->next) {
if (p!=self && (strcmp(p->name, name)==0))
return p;
}
@@ -142,21 +142,22 @@ void unique_property(bProperty *first, bProperty *prop, int force)
bProperty *p;
/* set the first if its not set */
- if(first==NULL) {
+ if (first==NULL) {
first= prop;
- while(first->prev) {
+ while (first->prev) {
first= first->prev;
}
}
- if(force) {
+ if (force) {
/* change other names to make them unique */
- while((p = get_property__internal(first, prop, prop->name))) {
+ while ((p = get_property__internal(first, prop, prop->name))) {
unique_property(first, p, 0);
}
- }else {
+ }
+ else {
/* change our own name until its unique */
- if(get_property__internal(first, prop, prop->name)) {
+ if (get_property__internal(first, prop, prop->name)) {
/* there is a collision */
char new_name[sizeof(prop->name)];
char base_name[sizeof(prop->name)];
@@ -165,7 +166,7 @@ void unique_property(bProperty *first, bProperty *prop, int force)
/* strip numbers */
BLI_strncpy(base_name, prop->name, sizeof(base_name));
- for(i= strlen(base_name)-1; (i>=0 && isdigit(base_name[i])); i--) {
+ for (i= strlen(base_name)-1; (i>=0 && isdigit(base_name[i])); i--) {
base_name[i]= '\0';
}
i= 0;
@@ -174,7 +175,7 @@ void unique_property(bProperty *first, bProperty *prop, int force)
BLI_snprintf(num, sizeof(num), "%d", i++);
BLI_strncpy(new_name, base_name, sizeof(prop->name) - strlen(num));
strcat(new_name, num);
- } while(get_property__internal(first, prop, new_name));
+ } while (get_property__internal(first, prop, new_name));
BLI_strncpy(prop->name, new_name, sizeof(prop->name));
}
@@ -190,7 +191,7 @@ void set_ob_property(Object *ob, bProperty *propc)
{
bProperty *prop;
prop= get_ob_property(ob, propc->name);
- if(prop) {
+ if (prop) {
free_property(prop);
BLI_remlink(&ob->prop, prop);
}
@@ -207,12 +208,12 @@ int compare_property(bProperty *prop, const char *str)
switch(prop->type) {
case GPROP_BOOL:
- if(BLI_strcasecmp(str, "true")==0) {
- if(prop->data==1) return 0;
+ if (BLI_strcasecmp(str, "true")==0) {
+ if (prop->data==1) return 0;
else return 1;
}
- else if(BLI_strcasecmp(str, "false")==0) {
- if(prop->data==0) return 0;
+ else if (BLI_strcasecmp(str, "false")==0) {
+ if (prop->data==0) return 0;
else return 1;
}
/* no break, do GPROP_int too! */
@@ -226,8 +227,8 @@ int compare_property(bProperty *prop, const char *str)
// function isn't used currently
fvalue= *((float *)&prop->data);
ftest= (float)atof(str);
- if( fvalue > ftest) return 1;
- else if( fvalue < ftest) return -1;
+ if ( fvalue > ftest) return 1;
+ else if ( fvalue < ftest) return -1;
return 0;
case GPROP_STRING:
@@ -243,8 +244,8 @@ void set_property(bProperty *prop, const char *str)
switch(prop->type) {
case GPROP_BOOL:
- if(BLI_strcasecmp(str, "true")==0) prop->data= 1;
- else if(BLI_strcasecmp(str, "false")==0) prop->data= 0;
+ if (BLI_strcasecmp(str, "true")==0) prop->data= 1;
+ else if (BLI_strcasecmp(str, "false")==0) prop->data= 0;
else prop->data= (atoi(str)!=0);
break;
case GPROP_INT:
@@ -285,7 +286,7 @@ void set_property_valstr(bProperty *prop, char *str)
{
// extern int Gdfra; /* sector.c */
- if(str == NULL) return;
+ if (str == NULL) return;
switch(prop->type) {
case GPROP_BOOL:
diff --git a/source/blender/blenkernel/intern/report.c b/source/blender/blenkernel/intern/report.c
index 9ce1cba2794..b3e288dfc74 100644
--- a/source/blender/blenkernel/intern/report.c
+++ b/source/blender/blenkernel/intern/report.c
@@ -58,7 +58,7 @@ static const char *report_type_str(int type)
void BKE_reports_init(ReportList *reports, int flag)
{
- if(!reports)
+ if (!reports)
return;
memset(reports, 0, sizeof(ReportList));
@@ -72,7 +72,7 @@ void BKE_reports_clear(ReportList *reports)
{
Report *report, *report_next;
- if(!reports)
+ if (!reports)
return;
report= reports->list.first;
@@ -94,12 +94,12 @@ void BKE_report(ReportList *reports, ReportType type, const char *message)
/* in background mode always print otherwise there are cases the errors wont be displayed,
* but still add to the report list since this is used for python exception handling */
- if(G.background || !reports || ((reports->flag & RPT_PRINT) && (type >= reports->printlevel))) {
+ if (G.background || !reports || ((reports->flag & RPT_PRINT) && (type >= reports->printlevel))) {
printf("%s: %s\n", report_type_str(type), message);
fflush(stdout); /* this ensures the message is printed before a crash */
}
- if(reports && (reports->flag & RPT_STORE) && (type >= reports->storelevel)) {
+ if (reports && (reports->flag & RPT_STORE) && (type >= reports->storelevel)) {
char *message_alloc;
report= MEM_callocN(sizeof(Report), "Report");
report->type= type;
@@ -120,7 +120,7 @@ void BKE_reportf(ReportList *reports, ReportType type, const char *format, ...)
Report *report;
va_list args;
- if(G.background || !reports || ((reports->flag & RPT_PRINT) && (type >= reports->printlevel))) {
+ if (G.background || !reports || ((reports->flag & RPT_PRINT) && (type >= reports->printlevel))) {
va_start(args, format);
vprintf(format, args);
va_end(args);
@@ -128,7 +128,7 @@ void BKE_reportf(ReportList *reports, ReportType type, const char *format, ...)
fflush(stdout); /* this ensures the message is printed before a crash */
}
- if(reports && (reports->flag & RPT_STORE) && (type >= reports->storelevel)) {
+ if (reports && (reports->flag & RPT_STORE) && (type >= reports->storelevel)) {
report= MEM_callocN(sizeof(Report), "Report");
ds= BLI_dynstr_new();
@@ -152,10 +152,10 @@ void BKE_reports_prepend(ReportList *reports, const char *prepend)
Report *report;
DynStr *ds;
- if(!reports)
+ if (!reports)
return;
- for(report=reports->list.first; report; report=report->next) {
+ for (report=reports->list.first; report; report=report->next) {
ds= BLI_dynstr_new();
BLI_dynstr_append(ds, prepend);
@@ -175,10 +175,10 @@ void BKE_reports_prependf(ReportList *reports, const char *prepend, ...)
DynStr *ds;
va_list args;
- if(!reports)
+ if (!reports)
return;
- for(report=reports->list.first; report; report=report->next) {
+ for (report=reports->list.first; report; report=report->next) {
ds= BLI_dynstr_new();
va_start(args, prepend);
BLI_dynstr_vappendf(ds, prepend, args);
@@ -196,7 +196,7 @@ void BKE_reports_prependf(ReportList *reports, const char *prepend, ...)
ReportType BKE_report_print_level(ReportList *reports)
{
- if(!reports)
+ if (!reports)
return RPT_ERROR;
return reports->printlevel;
@@ -204,7 +204,7 @@ ReportType BKE_report_print_level(ReportList *reports)
void BKE_report_print_level_set(ReportList *reports, ReportType level)
{
- if(!reports)
+ if (!reports)
return;
reports->printlevel= level;
@@ -212,7 +212,7 @@ void BKE_report_print_level_set(ReportList *reports, ReportType level)
ReportType BKE_report_store_level(ReportList *reports)
{
- if(!reports)
+ if (!reports)
return RPT_ERROR;
return reports->storelevel;
@@ -220,7 +220,7 @@ ReportType BKE_report_store_level(ReportList *reports)
void BKE_report_store_level_set(ReportList *reports, ReportType level)
{
- if(!reports)
+ if (!reports)
return;
reports->storelevel= level;
@@ -232,12 +232,12 @@ char *BKE_reports_string(ReportList *reports, ReportType level)
DynStr *ds;
char *cstring;
- if(!reports || !reports->list.first)
+ if (!reports || !reports->list.first)
return NULL;
ds= BLI_dynstr_new();
- for(report=reports->list.first; report; report=report->next)
- if(report->type >= level)
+ for (report=reports->list.first; report; report=report->next)
+ if (report->type >= level)
BLI_dynstr_appendf(ds, "%s: %s\n", report->typestr, report->message);
if (BLI_dynstr_get_len(ds))
@@ -277,8 +277,8 @@ int BKE_reports_contain(ReportList *reports, ReportType level)
{
Report *report;
if (reports != NULL) {
- for(report=reports->list.first; report; report=report->next)
- if(report->type >= level)
+ for (report=reports->list.first; report; report=report->next)
+ if (report->type >= level)
return TRUE;
}
return FALSE;
diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c
index 30a7449be1b..8123cbf3f0b 100644
--- a/source/blender/blenkernel/intern/sca.c
+++ b/source/blender/blenkernel/intern/sca.c
@@ -54,8 +54,8 @@
void free_sensor(bSensor *sens)
{
- if(sens->links) MEM_freeN(sens->links);
- if(sens->data) MEM_freeN(sens->data);
+ if (sens->links) MEM_freeN(sens->links);
+ if (sens->data) MEM_freeN(sens->data);
MEM_freeN(sens);
}
@@ -64,7 +64,7 @@ void free_sensors(ListBase *lb)
{
bSensor *sens;
- while((sens= lb->first)) {
+ while ((sens= lb->first)) {
BLI_remlink(lb, sens);
free_sensor(sens);
}
@@ -76,11 +76,11 @@ bSensor *copy_sensor(bSensor *sens)
sensn= MEM_dupallocN(sens);
sensn->flag |= SENS_NEW;
- if(sens->data) {
+ if (sens->data) {
sensn->data= MEM_dupallocN(sens->data);
}
- if(sens->links) sensn->links= MEM_dupallocN(sens->links);
+ if (sens->links) sensn->links= MEM_dupallocN(sens->links);
return sensn;
}
@@ -91,7 +91,7 @@ void copy_sensors(ListBase *lbn, ListBase *lbo)
lbn->first= lbn->last= NULL;
sens= lbo->first;
- while(sens) {
+ while (sens) {
sensn= copy_sensor(sens);
BLI_addtail(lbn, sensn);
sens= sens->next;
@@ -106,7 +106,7 @@ void init_sensor(bSensor *sens)
bJoystickSensor *js;
bRaySensor *rs;
- if(sens->data) MEM_freeN(sens->data);
+ if (sens->data) MEM_freeN(sens->data);
sens->data= NULL;
sens->pulse = 0;
@@ -196,9 +196,9 @@ void unlink_controller(bController *cont)
/* check for controller pointers in sensors */
ob= G.main->object.first;
- while(ob) {
+ while (ob) {
sens= ob->sensors.first;
- while(sens) {
+ while (sens) {
unlink_logicbricks((void **)&cont, (void ***)&(sens->links), &sens->totlinks);
sens= sens->next;
}
@@ -216,10 +216,10 @@ void unlink_controllers(ListBase *lb)
void free_controller(bController *cont)
{
- if(cont->links) MEM_freeN(cont->links);
+ if (cont->links) MEM_freeN(cont->links);
/* the controller itself */
- if(cont->data) MEM_freeN(cont->data);
+ if (cont->data) MEM_freeN(cont->data);
MEM_freeN(cont);
}
@@ -228,9 +228,9 @@ void free_controllers(ListBase *lb)
{
bController *cont;
- while((cont= lb->first)) {
+ while ((cont= lb->first)) {
BLI_remlink(lb, cont);
- if(cont->slinks) MEM_freeN(cont->slinks);
+ if (cont->slinks) MEM_freeN(cont->slinks);
free_controller(cont);
}
}
@@ -241,11 +241,11 @@ bController *copy_controller(bController *cont)
cont->mynew=contn= MEM_dupallocN(cont);
contn->flag |= CONT_NEW;
- if(cont->data) {
+ if (cont->data) {
contn->data= MEM_dupallocN(cont->data);
}
- if(cont->links) contn->links= MEM_dupallocN(cont->links);
+ if (cont->links) contn->links= MEM_dupallocN(cont->links);
contn->slinks= NULL;
contn->totslinks= 0;
@@ -258,7 +258,7 @@ void copy_controllers(ListBase *lbn, ListBase *lbo)
lbn->first= lbn->last= NULL;
cont= lbo->first;
- while(cont) {
+ while (cont) {
contn= copy_controller(cont);
BLI_addtail(lbn, contn);
cont= cont->next;
@@ -269,7 +269,7 @@ void init_controller(bController *cont)
{
/* also use when controller changes type, leave actuators... */
- if(cont->data) MEM_freeN(cont->data);
+ if (cont->data) MEM_freeN(cont->data);
cont->data= NULL;
switch(cont->type) {
@@ -307,9 +307,9 @@ void unlink_actuator(bActuator *act)
/* check for actuator pointers in controllers */
ob= G.main->object.first;
- while(ob) {
+ while (ob) {
cont= ob->controllers.first;
- while(cont) {
+ while (cont) {
unlink_logicbricks((void **)&act, (void ***)&(cont->links), &cont->totlinks);
cont= cont->next;
}
@@ -329,11 +329,11 @@ void free_actuator(bActuator *act)
{
bSoundActuator *sa;
- if(act->data) {
+ if (act->data) {
switch (act->type) {
case ACT_SOUND:
sa = (bSoundActuator *) act->data;
- if(sa->sound)
+ if (sa->sound)
id_us_min((ID *) sa->sound);
break;
}
@@ -347,7 +347,7 @@ void free_actuators(ListBase *lb)
{
bActuator *act;
- while((act= lb->first)) {
+ while ((act= lb->first)) {
BLI_remlink(lb, act);
free_actuator(act);
}
@@ -360,14 +360,14 @@ bActuator *copy_actuator(bActuator *act)
act->mynew=actn= MEM_dupallocN(act);
actn->flag |= ACT_NEW;
- if(act->data) {
+ if (act->data) {
actn->data= MEM_dupallocN(act->data);
}
switch (act->type) {
case ACT_SOUND:
sa= (bSoundActuator *)act->data;
- if(sa->sound)
+ if (sa->sound)
id_us_plus((ID *) sa->sound);
break;
}
@@ -380,7 +380,7 @@ void copy_actuators(ListBase *lbn, ListBase *lbo)
lbn->first= lbn->last= NULL;
act= lbo->first;
- while(act) {
+ while (act) {
actn= copy_actuator(act);
BLI_addtail(lbn, actn);
act= act->next;
@@ -397,7 +397,7 @@ void init_actuator(bActuator *act)
bSteeringActuator *sta;
bArmatureActuator *arma;
- if(act->data) MEM_freeN(act->data);
+ if (act->data) MEM_freeN(act->data);
act->data= NULL;
switch(act->type) {
@@ -512,18 +512,18 @@ void clear_sca_new_poins_ob(Object *ob)
bActuator *act;
sens= ob->sensors.first;
- while(sens) {
+ while (sens) {
sens->flag &= ~SENS_NEW;
sens= sens->next;
}
cont= ob->controllers.first;
- while(cont) {
+ while (cont) {
cont->mynew= NULL;
cont->flag &= ~CONT_NEW;
cont= cont->next;
}
act= ob->actuators.first;
- while(act) {
+ while (act) {
act->mynew= NULL;
act->flag &= ~ACT_NEW;
act= act->next;
@@ -535,7 +535,7 @@ void clear_sca_new_poins(void)
Object *ob;
ob= G.main->object.first;
- while(ob) {
+ while (ob) {
clear_sca_new_poins_ob(ob);
ob= ob->id.next;
}
@@ -549,10 +549,10 @@ void set_sca_new_poins_ob(Object *ob)
int a;
sens= ob->sensors.first;
- while(sens) {
- if(sens->flag & SENS_NEW) {
- for(a=0; a<sens->totlinks; a++) {
- if(sens->links[a] && sens->links[a]->mynew)
+ while (sens) {
+ if (sens->flag & SENS_NEW) {
+ for (a=0; a<sens->totlinks; a++) {
+ if (sens->links[a] && sens->links[a]->mynew)
sens->links[a]= sens->links[a]->mynew;
}
}
@@ -560,10 +560,10 @@ void set_sca_new_poins_ob(Object *ob)
}
cont= ob->controllers.first;
- while(cont) {
- if(cont->flag & CONT_NEW) {
- for(a=0; a<cont->totlinks; a++) {
- if( cont->links[a] && cont->links[a]->mynew)
+ while (cont) {
+ if (cont->flag & CONT_NEW) {
+ for (a=0; a<cont->totlinks; a++) {
+ if ( cont->links[a] && cont->links[a]->mynew)
cont->links[a]= cont->links[a]->mynew;
}
}
@@ -572,42 +572,42 @@ void set_sca_new_poins_ob(Object *ob)
act= ob->actuators.first;
- while(act) {
- if(act->flag & ACT_NEW) {
- if(act->type==ACT_EDIT_OBJECT) {
+ while (act) {
+ if (act->flag & ACT_NEW) {
+ if (act->type==ACT_EDIT_OBJECT) {
bEditObjectActuator *eoa= act->data;
ID_NEW(eoa->ob);
}
- else if(act->type==ACT_SCENE) {
+ else if (act->type==ACT_SCENE) {
bSceneActuator *sca= act->data;
ID_NEW(sca->camera);
}
- else if(act->type==ACT_CAMERA) {
+ else if (act->type==ACT_CAMERA) {
bCameraActuator *ca= act->data;
ID_NEW(ca->ob);
}
- else if(act->type==ACT_OBJECT) {
+ else if (act->type==ACT_OBJECT) {
bObjectActuator *oa= act->data;
ID_NEW(oa->reference);
}
- else if(act->type==ACT_MESSAGE) {
+ else if (act->type==ACT_MESSAGE) {
bMessageActuator *ma= act->data;
ID_NEW(ma->toObject);
}
- else if(act->type==ACT_PARENT) {
+ else if (act->type==ACT_PARENT) {
bParentActuator *para = act->data;
ID_NEW(para->ob);
}
- else if(act->type==ACT_ARMATURE) {
+ else if (act->type==ACT_ARMATURE) {
bArmatureActuator *aa = act->data;
ID_NEW(aa->target);
ID_NEW(aa->subtarget);
}
- else if(act->type==ACT_PROPERTY) {
+ else if (act->type==ACT_PROPERTY) {
bPropertyActuator *pa= act->data;
ID_NEW(pa->ob);
}
- else if(act->type==ACT_STEERING) {
+ else if (act->type==ACT_STEERING) {
bSteeringActuator *sta = act->data;
ID_NEW(sta->navmesh);
ID_NEW(sta->target);
@@ -623,7 +623,7 @@ void set_sca_new_poins(void)
Object *ob;
ob= G.main->object.first;
- while(ob) {
+ while (ob) {
set_sca_new_poins_ob(ob);
ob= ob->id.next;
}
@@ -646,41 +646,41 @@ void sca_remove_ob_poin(Object *obt, Object *ob)
sens= obt->sensors.first;
- while(sens) {
+ while (sens) {
switch(sens->type) {
case SENS_MESSAGE:
ms= sens->data;
- if(ms->fromObject==ob) ms->fromObject= NULL;
+ if (ms->fromObject==ob) ms->fromObject= NULL;
}
sens= sens->next;
}
act= obt->actuators.first;
- while(act) {
+ while (act) {
switch(act->type) {
case ACT_CAMERA:
ca= act->data;
- if(ca->ob==ob) ca->ob= NULL;
+ if (ca->ob==ob) ca->ob= NULL;
break;
case ACT_OBJECT:
oa= act->data;
- if(oa->reference==ob) oa->reference= NULL;
+ if (oa->reference==ob) oa->reference= NULL;
break;
case ACT_PROPERTY:
pa= act->data;
- if(pa->ob==ob) pa->ob= NULL;
+ if (pa->ob==ob) pa->ob= NULL;
break;
case ACT_SCENE:
sa= act->data;
- if(sa->camera==ob) sa->camera= NULL;
+ if (sa->camera==ob) sa->camera= NULL;
break;
case ACT_EDIT_OBJECT:
eoa= act->data;
- if(eoa->ob==ob) eoa->ob= NULL;
+ if (eoa->ob==ob) eoa->ob= NULL;
break;
case ACT_MESSAGE:
ma= act->data;
- if(ma->toObject==ob) ma->toObject= NULL;
+ if (ma->toObject==ob) ma->toObject= NULL;
break;
case ACT_PARENT:
para = act->data;
@@ -710,14 +710,14 @@ void sca_move_sensor(bSensor *sens_to_move, Object *ob, int move_up)
/* make sure this sensor belongs to this object */
sens= ob->sensors.first;
- while(sens) {
- if(sens == sens_to_move) break;
+ while (sens) {
+ if (sens == sens_to_move) break;
sens= sens->next;
}
- if(!sens) return;
+ if (!sens) return;
/* move up */
- if( val==1 && sens->prev) {
+ if ( val==1 && sens->prev) {
for (tmp=sens->prev; tmp; tmp=tmp->prev) {
if (tmp->flag & SENS_VISIBLE)
break;
@@ -728,7 +728,7 @@ void sca_move_sensor(bSensor *sens_to_move, Object *ob, int move_up)
}
}
/* move down */
- else if( val==2 && sens->next) {
+ else if ( val==2 && sens->next) {
for (tmp=sens->next; tmp; tmp=tmp->next) {
if (tmp->flag & SENS_VISIBLE)
break;
@@ -749,18 +749,18 @@ void sca_move_controller(bController *cont_to_move, Object *ob, int move_up)
/* make sure this controller belongs to this object */
cont= ob->controllers.first;
- while(cont) {
- if(cont == cont_to_move) break;
+ while (cont) {
+ if (cont == cont_to_move) break;
cont= cont->next;
}
- if(!cont) return;
+ if (!cont) return;
/* move up */
- if( val==1 && cont->prev) {
+ if ( val==1 && cont->prev) {
/* locate the controller that has the same state mask but is earlier in the list */
tmp = cont->prev;
- while(tmp) {
- if(tmp->state_mask & cont->state_mask)
+ while (tmp) {
+ if (tmp->state_mask & cont->state_mask)
break;
tmp = tmp->prev;
}
@@ -771,10 +771,10 @@ void sca_move_controller(bController *cont_to_move, Object *ob, int move_up)
}
/* move down */
- else if( val==2 && cont->next) {
+ else if ( val==2 && cont->next) {
tmp = cont->next;
- while(tmp) {
- if(tmp->state_mask & cont->state_mask)
+ while (tmp) {
+ if (tmp->state_mask & cont->state_mask)
break;
tmp = tmp->next;
}
@@ -792,14 +792,14 @@ void sca_move_actuator(bActuator *act_to_move, Object *ob, int move_up)
/* make sure this actuator belongs to this object */
act= ob->actuators.first;
- while(act) {
- if(act == act_to_move) break;
+ while (act) {
+ if (act == act_to_move) break;
act= act->next;
}
- if(!act) return;
+ if (!act) return;
/* move up */
- if( val==1 && act->prev) {
+ if ( val==1 && act->prev) {
/* locate the first visible actuators before this one */
for (tmp = act->prev; tmp; tmp=tmp->prev) {
if (tmp->flag & ACT_VISIBLE)
@@ -811,7 +811,7 @@ void sca_move_actuator(bActuator *act_to_move, Object *ob, int move_up)
}
}
/* move down */
- else if( val==2 && act->next) {
+ else if ( val==2 && act->next) {
/* locate the first visible actuators after this one */
for (tmp=act->next; tmp; tmp=tmp->next) {
if (tmp->flag & ACT_VISIBLE)
@@ -847,7 +847,7 @@ void link_logicbricks(void **poin, void ***ppoin, short *tot, short size)
}
(*ppoin)[ibrick] = *poin;
- if(old_links) MEM_freeN(old_links);
+ if (old_links) MEM_freeN(old_links);
}
else {
(*tot) = 1;
@@ -862,14 +862,14 @@ void unlink_logicbricks(void **poin, void ***ppoin, short *tot)
removed= 0;
for (ibrick=0; ibrick < *tot; ibrick++) {
- if(removed) (*ppoin)[ibrick - removed] = (*ppoin)[ibrick];
- else if((*ppoin)[ibrick] == *poin) removed = 1;
+ if (removed) (*ppoin)[ibrick - removed] = (*ppoin)[ibrick];
+ else if ((*ppoin)[ibrick] == *poin) removed = 1;
}
if (removed) {
(*tot) --;
- if(*tot == 0) {
+ if (*tot == 0) {
MEM_freeN(*ppoin);
(*ppoin)= NULL;
}
diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c
index fe4316bf8d6..158fc91c03c 100644
--- a/source/blender/blenkernel/intern/screen.c
+++ b/source/blender/blenkernel/intern/screen.c
@@ -59,15 +59,15 @@ static void spacetype_free(SpaceType *st)
PanelType *pt;
HeaderType *ht;
- for(art= st->regiontypes.first; art; art= art->next) {
+ for (art= st->regiontypes.first; art; art= art->next) {
BLI_freelistN(&art->drawcalls);
- for(pt= art->paneltypes.first; pt; pt= pt->next)
- if(pt->ext.free)
+ for (pt= art->paneltypes.first; pt; pt= pt->next)
+ if (pt->ext.free)
pt->ext.free(pt->ext.data);
- for(ht= art->headertypes.first; ht; ht= ht->next)
- if(ht->ext.free)
+ for (ht= art->headertypes.first; ht; ht= ht->next)
+ if (ht->ext.free)
ht->ext.free(ht->ext.data);
BLI_freelistN(&art->paneltypes);
@@ -83,7 +83,7 @@ void BKE_spacetypes_free(void)
{
SpaceType *st;
- for(st= spacetypes.first; st; st= st->next) {
+ for (st= spacetypes.first; st; st= st->next) {
spacetype_free(st);
}
@@ -94,8 +94,8 @@ SpaceType *BKE_spacetype_from_id(int spaceid)
{
SpaceType *st;
- for(st= spacetypes.first; st; st= st->next) {
- if(st->spaceid==spaceid)
+ for (st= spacetypes.first; st; st= st->next) {
+ if (st->spaceid==spaceid)
return st;
}
return NULL;
@@ -105,8 +105,8 @@ ARegionType *BKE_regiontype_from_id(SpaceType *st, int regionid)
{
ARegionType *art;
- for(art= st->regiontypes.first; art; art= art->next)
- if(art->regionid==regionid)
+ for (art= st->regiontypes.first; art; art= art->next)
+ if (art->regionid==regionid)
return art;
printf("Error, region type missing in - name:\"%s\", id:%d\n", st->name, st->spaceid);
@@ -125,7 +125,7 @@ void BKE_spacetype_register(SpaceType *st)
/* sanity check */
stype= BKE_spacetype_from_id(st->spaceid);
- if(stype) {
+ if (stype) {
printf("error: redefinition of spacetype %s\n", stype->name);
spacetype_free(stype);
MEM_freeN(stype);
@@ -145,12 +145,12 @@ void BKE_spacedata_freelist(ListBase *lb)
SpaceType *st= BKE_spacetype_from_id(sl->spacetype);
/* free regions for pushed spaces */
- for(ar=sl->regionbase.first; ar; ar=ar->next)
+ for (ar=sl->regionbase.first; ar; ar=ar->next)
BKE_area_region_free(st, ar);
BLI_freelistN(&sl->regionbase);
- if(st && st->free)
+ if (st && st->free)
st->free(sl);
}
@@ -168,27 +168,27 @@ ARegion *BKE_area_region_copy(SpaceType *st, ARegion *ar)
newar->swinid= 0;
/* use optional regiondata callback */
- if(ar->regiondata) {
+ if (ar->regiondata) {
ARegionType *art= BKE_regiontype_from_id(st, ar->regiontype);
- if(art && art->duplicate)
+ if (art && art->duplicate)
newar->regiondata= art->duplicate(ar->regiondata);
else
newar->regiondata= MEM_dupallocN(ar->regiondata);
}
- if(ar->v2d.tab_offset)
+ if (ar->v2d.tab_offset)
newar->v2d.tab_offset= MEM_dupallocN(ar->v2d.tab_offset);
newar->panels.first= newar->panels.last= NULL;
BLI_duplicatelist(&newar->panels, &ar->panels);
/* copy panel pointers */
- for(newpa= newar->panels.first; newpa; newpa= newpa->next) {
+ for (newpa= newar->panels.first; newpa; newpa= newpa->next) {
patab= newar->panels.first;
pa= ar->panels.first;
- while(patab) {
- if(newpa->paneltab == pa) {
+ while (patab) {
+ if (newpa->paneltab == pa) {
newpa->paneltab = patab;
break;
}
@@ -209,7 +209,7 @@ static void region_copylist(SpaceType *st, ListBase *lb1, ListBase *lb2)
/* to be sure */
lb1->first= lb1->last= NULL;
- for(ar= lb2->first; ar; ar= ar->next) {
+ for (ar= lb2->first; ar; ar= ar->next) {
ARegion *arnew= BKE_area_region_copy(st, ar);
BLI_addtail(lb1, arnew);
}
@@ -226,7 +226,7 @@ void BKE_spacedata_copylist(ListBase *lb1, ListBase *lb2)
for (sl= lb2->first; sl; sl= sl->next) {
SpaceType *st= BKE_spacetype_from_id(sl->spacetype);
- if(st && st->duplicate) {
+ if (st && st->duplicate) {
SpaceLink *slnew= st->duplicate(sl);
BLI_addtail(lb1, slnew);
@@ -243,11 +243,11 @@ void BKE_spacedata_draw_locks(int set)
{
SpaceType *st;
- for(st= spacetypes.first; st; st= st->next) {
+ for (st= spacetypes.first; st; st= st->next) {
ARegionType *art;
- for(art= st->regiontypes.first; art; art= art->next) {
- if(set)
+ for (art= st->regiontypes.first; art; art= art->next) {
+ if (set)
art->do_lock= art->lock;
else
art->do_lock= 0;
@@ -259,19 +259,19 @@ void BKE_spacedata_draw_locks(int set)
/* not region itself */
void BKE_area_region_free(SpaceType *st, ARegion *ar)
{
- if(st) {
+ if (st) {
ARegionType *art= BKE_regiontype_from_id(st, ar->regiontype);
- if(art && art->free)
+ if (art && art->free)
art->free(ar);
- if(ar->regiondata)
+ if (ar->regiondata)
printf("regiondata free error\n");
}
- else if(ar->type && ar->type->free)
+ else if (ar->type && ar->type->free)
ar->type->free(ar);
- if(ar->v2d.tab_offset) {
+ if (ar->v2d.tab_offset) {
MEM_freeN(ar->v2d.tab_offset);
ar->v2d.tab_offset= NULL;
}
@@ -285,7 +285,7 @@ void BKE_screen_area_free(ScrArea *sa)
SpaceType *st= BKE_spacetype_from_id(sa->spacetype);
ARegion *ar;
- for(ar=sa->regionbase.first; ar; ar=ar->next)
+ for (ar=sa->regionbase.first; ar; ar=ar->next)
BKE_area_region_free(st, ar);
BLI_freelistN(&sa->regionbase);
@@ -301,12 +301,12 @@ void free_screen(bScreen *sc)
ScrArea *sa, *san;
ARegion *ar;
- for(ar=sc->regionbase.first; ar; ar=ar->next)
+ for (ar=sc->regionbase.first; ar; ar=ar->next)
BKE_area_region_free(NULL, ar);
BLI_freelistN(&sc->regionbase);
- for(sa= sc->areabase.first; sa; sa= san) {
+ for (sa= sc->areabase.first; sa; sa= san) {
san= sa->next;
BKE_screen_area_free(sa);
}
@@ -322,14 +322,14 @@ unsigned int BKE_screen_visible_layers(bScreen *screen, Scene *scene)
ScrArea *sa;
unsigned int layer= 0;
- if(screen) {
+ if (screen) {
/* get all used view3d layers */
- for(sa= screen->areabase.first; sa; sa= sa->next)
- if(sa->spacetype==SPACE_VIEW3D)
+ for (sa= screen->areabase.first; sa; sa= sa->next)
+ if (sa->spacetype==SPACE_VIEW3D)
layer |= ((View3D *)sa->spacedata.first)->lay;
}
- if(!layer)
+ if (!layer)
return scene->lay;
return layer;
@@ -359,7 +359,7 @@ struct ScrArea *BKE_screen_find_big_area(struct bScreen *sc, const int spacetype
ScrArea *sa, *big= NULL;
int size, maxsize= 0;
- for(sa= sc->areabase.first; sa; sa= sa->next) {
+ for (sa= sc->areabase.first; sa; sa= sa->next) {
if ((spacetype == -1) || sa->spacetype == spacetype) {
if (min <= sa->winx && min <= sa->winy) {
size= sa->winx*sa->winy;
@@ -378,25 +378,25 @@ void BKE_screen_view3d_sync(struct View3D *v3d, struct Scene *scene)
{
int bit;
- if(v3d->scenelock && v3d->localvd==NULL) {
+ if (v3d->scenelock && v3d->localvd==NULL) {
v3d->lay= scene->lay;
v3d->camera= scene->camera;
- if(v3d->camera==NULL) {
+ if (v3d->camera==NULL) {
ARegion *ar;
- for(ar=v3d->regionbase.first; ar; ar= ar->next) {
- if(ar->regiontype == RGN_TYPE_WINDOW) {
+ for (ar=v3d->regionbase.first; ar; ar= ar->next) {
+ if (ar->regiontype == RGN_TYPE_WINDOW) {
RegionView3D *rv3d= ar->regiondata;
- if(rv3d->persp==RV3D_CAMOB)
+ if (rv3d->persp==RV3D_CAMOB)
rv3d->persp= RV3D_PERSP;
}
}
}
- if((v3d->lay & v3d->layact) == 0) {
- for(bit= 0; bit<32; bit++) {
- if(v3d->lay & (1<<bit)) {
+ if ((v3d->lay & v3d->layact) == 0) {
+ for (bit= 0; bit<32; bit++) {
+ if (v3d->lay & (1<<bit)) {
v3d->layact= 1<<bit;
break;
}
@@ -409,10 +409,10 @@ void BKE_screen_view3d_scene_sync(bScreen *sc)
{
/* are there cameras in the views that are not in the scene? */
ScrArea *sa;
- for(sa= sc->areabase.first; sa; sa= sa->next) {
+ for (sa= sc->areabase.first; sa; sa= sa->next) {
SpaceLink *sl;
- for(sl= sa->spacedata.first; sl; sl= sl->next) {
- if(sl->spacetype==SPACE_VIEW3D) {
+ for (sl= sa->spacedata.first; sl; sl= sl->next) {
+ if (sl->spacetype==SPACE_VIEW3D) {
View3D *v3d= (View3D*) sl;
BKE_screen_view3d_sync(v3d, sc->scene);
}
@@ -427,13 +427,13 @@ void BKE_screen_view3d_main_sync(ListBase *screen_lb, Scene *scene)
SpaceLink *sl;
/* from scene copy to the other views */
- for(sc=screen_lb->first; sc; sc=sc->id.next) {
- if(sc->scene!=scene)
+ for (sc=screen_lb->first; sc; sc=sc->id.next) {
+ if (sc->scene!=scene)
continue;
- for(sa=sc->areabase.first; sa; sa=sa->next)
- for(sl=sa->spacedata.first; sl; sl=sl->next)
- if(sl->spacetype==SPACE_VIEW3D)
+ for (sa=sc->areabase.first; sa; sa=sa->next)
+ for (sl=sa->spacedata.first; sl; sl=sl->next)
+ if (sl->spacetype==SPACE_VIEW3D)
BKE_screen_view3d_sync((View3D*)sl, scene);
}
}
diff --git a/source/blender/blenkernel/intern/seqcache.c b/source/blender/blenkernel/intern/seqcache.c
index c5761dcc456..f1f3dd47d8b 100644
--- a/source/blender/blenkernel/intern/seqcache.c
+++ b/source/blender/blenkernel/intern/seqcache.c
@@ -91,13 +91,13 @@ static int seqcache_hashcmp(const void *a_, const void *b_)
void seq_stripelem_cache_destruct(void)
{
- if(moviecache)
+ if (moviecache)
IMB_moviecache_free(moviecache);
}
void seq_stripelem_cache_cleanup(void)
{
- if(moviecache) {
+ if (moviecache) {
IMB_moviecache_free(moviecache);
moviecache = IMB_moviecache_create(sizeof(seqCacheKey), seqcache_hashhash,
seqcache_hashcmp, NULL);
@@ -109,7 +109,7 @@ struct ImBuf * seq_stripelem_cache_get(
float cfra, seq_stripelem_ibuf_t type)
{
- if(moviecache && seq) {
+ if (moviecache && seq) {
seqCacheKey key;
key.seq = seq;
@@ -133,7 +133,7 @@ void seq_stripelem_cache_put(
return;
}
- if(!moviecache) {
+ if (!moviecache) {
moviecache = IMB_moviecache_create(sizeof(seqCacheKey), seqcache_hashhash,
seqcache_hashcmp, NULL);
}
diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c
index f42220780b9..21f724732ec 100644
--- a/source/blender/blenkernel/intern/seqeffects.c
+++ b/source/blender/blenkernel/intern/seqeffects.c
@@ -85,13 +85,15 @@ static struct ImBuf * prepare_effect_imbufs(
if (!ibuf1 && !ibuf2 && !ibuf3) {
/* hmmm, global float option ? */
out = IMB_allocImBuf((short)x, (short)y, 32, IB_rect);
- } else if ((ibuf1 && ibuf1->rect_float) ||
+ }
+ else if ((ibuf1 && ibuf1->rect_float) ||
(ibuf2 && ibuf2->rect_float) ||
(ibuf3 && ibuf3->rect_float)) {
/* if any inputs are rectfloat, output is float too */
out = IMB_allocImBuf((short)x, (short)y, 32, IB_rectfloat);
- } else {
+ }
+ else {
out = IMB_allocImBuf((short)x, (short)y, 32, IB_rect);
}
@@ -144,7 +146,7 @@ static void open_plugin_seq(PluginSeq *pis, const char *seqname)
/* open the needed object */
pis->handle= BLI_dynlib_open(pis->name);
- if(test_dlerr(pis->name, pis->name)) return;
+ if (test_dlerr(pis->name, pis->name)) return;
if (pis->handle != NULL) {
/* find the address of the version function */
@@ -159,7 +161,7 @@ static void open_plugin_seq(PluginSeq *pis, const char *seqname)
info_func= (int (*)(PluginInfo *))BLI_dynlib_find_symbol(pis->handle, "plugin_getinfo");
- if(info_func == NULL) error("No info func");
+ if (info_func == NULL) error("No info func");
else {
info_func(info);
@@ -176,8 +178,9 @@ static void open_plugin_seq(PluginSeq *pis, const char *seqname)
MEM_freeN(info);
cp= BLI_dynlib_find_symbol(pis->handle, "seqname");
- if(cp) BLI_strncpy(cp, seqname, SEQ_NAME_MAXSTR);
- } else {
+ if (cp) BLI_strncpy(cp, seqname, SEQ_NAME_MAXSTR);
+ }
+ else {
printf ("Plugin returned unrecognized version number\n");
return;
}
@@ -205,8 +208,8 @@ static PluginSeq *add_plugin_seq(const char *str, const char *seqname)
BLI_strncpy(pis->name, str, FILE_MAX);
open_plugin_seq(pis, seqname);
- if(pis->doit==NULL) {
- if(pis->handle==NULL) error("no plugin: %s", str);
+ if (pis->doit==NULL) {
+ if (pis->handle==NULL) error("no plugin: %s", str);
else error("in plugin: %s", str);
MEM_freeN(pis);
return NULL;
@@ -214,10 +217,10 @@ static PluginSeq *add_plugin_seq(const char *str, const char *seqname)
/* default values */
varstr= pis->varstr;
- for(a=0; a<pis->vars; a++, varstr++) {
- if( (varstr->type & FLO)==FLO)
+ for (a=0; a<pis->vars; a++, varstr++) {
+ if ( (varstr->type & FLO)==FLO)
pis->data[a]= varstr->def;
- else if( (varstr->type & INT)==INT)
+ else if ( (varstr->type & INT)==INT)
*((int *)(pis->data+a))= (int) varstr->def;
}
@@ -226,7 +229,7 @@ static PluginSeq *add_plugin_seq(const char *str, const char *seqname)
static void free_plugin_seq(PluginSeq *pis)
{
- if(pis==NULL) return;
+ if (pis==NULL) return;
/* no BLI_dynlib_close: same plugin can be opened multiple times with 1 handle */
@@ -265,7 +268,7 @@ static void load_plugin(Sequence * seq)
static void copy_plugin(Sequence * dst, Sequence * src)
{
- if(src->plugin) {
+ if (src->plugin) {
dst->plugin= MEM_dupallocN(src->plugin);
open_plugin_seq(dst->plugin, dst->name+2);
}
@@ -295,9 +298,9 @@ static struct ImBuf * do_plugin_effect(
int x = context.rectx;
int y = context.recty;
- if(seq->plugin && seq->plugin->doit) {
+ if (seq->plugin && seq->plugin->doit) {
- if(seq->plugin->cfra)
+ if (seq->plugin->cfra)
*(seq->plugin->cfra)= cfra;
cp = BLI_dynlib_find_symbol(
@@ -306,7 +309,7 @@ static struct ImBuf * do_plugin_effect(
/* XXX: it's crappy to limit copying buffer by it's lemgth,
* but assuming plugin stuff is using correct buffer size
* it should be fine */
- if(cp) strncpy(cp, seq->name+2, sizeof(seq->name)-2);
+ if (cp) strncpy(cp, seq->name+2, sizeof(seq->name)-2);
if (seq->plugin->current_private_data) {
*seq->plugin->current_private_data
@@ -342,9 +345,9 @@ static struct ImBuf * do_plugin_effect(
}
if (seq->plugin->version<=2) {
- if(ibuf1) IMB_convert_rgba_to_abgr(ibuf1);
- if(ibuf2) IMB_convert_rgba_to_abgr(ibuf2);
- if(ibuf3) IMB_convert_rgba_to_abgr(ibuf3);
+ if (ibuf1) IMB_convert_rgba_to_abgr(ibuf1);
+ if (ibuf2) IMB_convert_rgba_to_abgr(ibuf2);
+ if (ibuf3) IMB_convert_rgba_to_abgr(ibuf3);
}
if (seq->plugin->version<=4) {
@@ -354,7 +357,8 @@ static struct ImBuf * do_plugin_effect(
IMB_cast_away_list(ibuf2),
IMB_cast_away_list(out),
IMB_cast_away_list(ibuf3));
- } else {
+ }
+ else {
((SeqDoit)seq->plugin->doit)(
seq->plugin->data, facf0, facf1, x, y,
ibuf1, ibuf2, out, ibuf3);
@@ -362,9 +366,9 @@ static struct ImBuf * do_plugin_effect(
if (seq->plugin->version<=2) {
if (!use_temp_bufs) {
- if(ibuf1) IMB_convert_rgba_to_abgr(ibuf1);
- if(ibuf2) IMB_convert_rgba_to_abgr(ibuf2);
- if(ibuf3) IMB_convert_rgba_to_abgr(ibuf3);
+ if (ibuf1) IMB_convert_rgba_to_abgr(ibuf1);
+ if (ibuf2) IMB_convert_rgba_to_abgr(ibuf2);
+ if (ibuf3) IMB_convert_rgba_to_abgr(ibuf3);
}
IMB_convert_rgba_to_abgr(out);
}
@@ -421,51 +425,51 @@ static void do_alphaover_effect_byte(float facf0, float facf1, int x, int y,
fac2= (int)(256.0f*facf0);
fac4= (int)(256.0f*facf1);
- while(y--) {
+ while (y--) {
x= xo;
- while(x--) {
+ while (x--) {
/* rt = rt1 over rt2 (alpha from rt1) */
fac= fac2;
mfac= 256 - ( (fac2*rt1[3])>>8 );
- if(fac==0) *( (unsigned int *)rt) = *( (unsigned int *)rt2);
- else if(mfac==0) *( (unsigned int *)rt) = *( (unsigned int *)rt1);
+ if (fac==0) *( (unsigned int *)rt) = *( (unsigned int *)rt2);
+ else if (mfac==0) *( (unsigned int *)rt) = *( (unsigned int *)rt1);
else {
tempc= ( fac*rt1[0] + mfac*rt2[0])>>8;
- if(tempc>255) rt[0]= 255; else rt[0]= tempc;
+ if (tempc>255) rt[0]= 255; else rt[0]= tempc;
tempc= ( fac*rt1[1] + mfac*rt2[1])>>8;
- if(tempc>255) rt[1]= 255; else rt[1]= tempc;
+ if (tempc>255) rt[1]= 255; else rt[1]= tempc;
tempc= ( fac*rt1[2] + mfac*rt2[2])>>8;
- if(tempc>255) rt[2]= 255; else rt[2]= tempc;
+ if (tempc>255) rt[2]= 255; else rt[2]= tempc;
tempc= ( fac*rt1[3] + mfac*rt2[3])>>8;
- if(tempc>255) rt[3]= 255; else rt[3]= tempc;
+ if (tempc>255) rt[3]= 255; else rt[3]= tempc;
}
rt1+= 4; rt2+= 4; rt+= 4;
}
- if(y==0) break;
+ if (y==0) break;
y--;
x= xo;
- while(x--) {
+ while (x--) {
fac= fac4;
mfac= 256 - ( (fac4*rt1[3])>>8 );
- if(fac==0) *( (unsigned int *)rt) = *( (unsigned int *)rt2);
- else if(mfac==0) *( (unsigned int *)rt) = *( (unsigned int *)rt1);
+ if (fac==0) *( (unsigned int *)rt) = *( (unsigned int *)rt2);
+ else if (mfac==0) *( (unsigned int *)rt) = *( (unsigned int *)rt1);
else {
tempc= ( fac*rt1[0] + mfac*rt2[0])>>8;
- if(tempc>255) rt[0]= 255; else rt[0]= tempc;
+ if (tempc>255) rt[0]= 255; else rt[0]= tempc;
tempc= ( fac*rt1[1] + mfac*rt2[1])>>8;
- if(tempc>255) rt[1]= 255; else rt[1]= tempc;
+ if (tempc>255) rt[1]= 255; else rt[1]= tempc;
tempc= ( fac*rt1[2] + mfac*rt2[2])>>8;
- if(tempc>255) rt[2]= 255; else rt[2]= tempc;
+ if (tempc>255) rt[2]= 255; else rt[2]= tempc;
tempc= ( fac*rt1[3] + mfac*rt2[3])>>8;
- if(tempc>255) rt[3]= 255; else rt[3]= tempc;
+ if (tempc>255) rt[3]= 255; else rt[3]= tempc;
}
rt1+= 4; rt2+= 4; rt+= 4;
}
@@ -487,21 +491,23 @@ static void do_alphaover_effect_float(float facf0, float facf1, int x, int y,
fac2= facf0;
fac4= facf1;
- while(y--) {
+ while (y--) {
x= xo;
- while(x--) {
+ while (x--) {
/* rt = rt1 over rt2 (alpha from rt1) */
fac= fac2;
mfac= 1.0f - (fac2 * rt1[3]);
- if(fac <= 0.0f) {
+ if (fac <= 0.0f) {
memcpy(rt, rt2, 4 * sizeof(float));
- } else if(mfac <=0) {
+ }
+ else if (mfac <=0) {
memcpy(rt, rt1, 4 * sizeof(float));
- } else {
+ }
+ else {
rt[0] = fac*rt1[0] + mfac*rt2[0];
rt[1] = fac*rt1[1] + mfac*rt2[1];
rt[2] = fac*rt1[2] + mfac*rt2[2];
@@ -510,20 +516,22 @@ static void do_alphaover_effect_float(float facf0, float facf1, int x, int y,
rt1+= 4; rt2+= 4; rt+= 4;
}
- if(y==0) break;
+ if (y==0) break;
y--;
x= xo;
- while(x--) {
+ while (x--) {
fac= fac4;
mfac= 1.0f - (fac4*rt1[3]);
- if(fac <= 0.0f) {
+ if (fac <= 0.0f) {
memcpy(rt, rt2, 4 * sizeof(float));
- } else if(mfac <= 0.0f) {
+ }
+ else if (mfac <= 0.0f) {
memcpy(rt, rt1, 4 * sizeof(float));
- } else {
+ }
+ else {
rt[0] = fac*rt1[0] + mfac*rt2[0];
rt[1] = fac*rt1[1] + mfac*rt2[1];
rt[2] = fac*rt1[2] + mfac*rt2[2];
@@ -547,7 +555,8 @@ static struct ImBuf * do_alphaover_effect(
facf0, facf1, context.rectx, context.recty,
ibuf1->rect_float, ibuf2->rect_float,
out->rect_float);
- } else {
+ }
+ else {
do_alphaover_effect_byte(
facf0, facf1, context.rectx, context.recty,
(char*) ibuf1->rect, (char*) ibuf2->rect,
@@ -577,23 +586,23 @@ static void do_alphaunder_effect_byte(
fac2= (int)(256.0f*facf0);
fac4= (int)(256.0f*facf1);
- while(y--) {
+ while (y--) {
x= xo;
- while(x--) {
+ while (x--) {
/* rt = rt1 under rt2 (alpha from rt2) */
/* this complex optimalisation is because the
* 'skybuf' can be crossed in
*/
- if(rt2[3]==0 && fac2==256) *( (unsigned int *)rt) = *( (unsigned int *)rt1);
- else if(rt2[3]==255) *( (unsigned int *)rt) = *( (unsigned int *)rt2);
+ if (rt2[3]==0 && fac2==256) *( (unsigned int *)rt) = *( (unsigned int *)rt1);
+ else if (rt2[3]==255) *( (unsigned int *)rt) = *( (unsigned int *)rt2);
else {
mfac= rt2[3];
fac= (fac2*(256-mfac))>>8;
- if(fac==0) *( (unsigned int *)rt) = *( (unsigned int *)rt2);
+ if (fac==0) *( (unsigned int *)rt) = *( (unsigned int *)rt2);
else {
rt[0]= ( fac*rt1[0] + mfac*rt2[0])>>8;
rt[1]= ( fac*rt1[1] + mfac*rt2[1])>>8;
@@ -604,19 +613,19 @@ static void do_alphaunder_effect_byte(
rt1+= 4; rt2+= 4; rt+= 4;
}
- if(y==0) break;
+ if (y==0) break;
y--;
x= xo;
- while(x--) {
+ while (x--) {
- if(rt2[3]==0 && fac4==256) *( (unsigned int *)rt) = *( (unsigned int *)rt1);
- else if(rt2[3]==255) *( (unsigned int *)rt) = *( (unsigned int *)rt2);
+ if (rt2[3]==0 && fac4==256) *( (unsigned int *)rt) = *( (unsigned int *)rt1);
+ else if (rt2[3]==255) *( (unsigned int *)rt) = *( (unsigned int *)rt2);
else {
mfac= rt2[3];
fac= (fac4*(256-mfac))>>8;
- if(fac==0) *( (unsigned int *)rt) = *( (unsigned int *)rt2);
+ if (fac==0) *( (unsigned int *)rt) = *( (unsigned int *)rt2);
else {
rt[0]= ( fac*rt1[0] + mfac*rt2[0])>>8;
rt[1]= ( fac*rt1[1] + mfac*rt2[1])>>8;
@@ -646,27 +655,30 @@ static void do_alphaunder_effect_float(float facf0, float facf1, int x, int y,
fac2= facf0;
fac4= facf1;
- while(y--) {
+ while (y--) {
x= xo;
- while(x--) {
+ while (x--) {
/* rt = rt1 under rt2 (alpha from rt2) */
/* this complex optimalisation is because the
* 'skybuf' can be crossed in
*/
- if( rt2[3]<=0 && fac2 >= 1.0f) {
+ if ( rt2[3]<=0 && fac2 >= 1.0f) {
memcpy(rt, rt1, 4 * sizeof(float));
- } else if(rt2[3] >= 1.0f) {
+ }
+ else if (rt2[3] >= 1.0f) {
memcpy(rt, rt2, 4 * sizeof(float));
- } else {
+ }
+ else {
mfac = rt2[3];
fac = fac2 * (1.0f - mfac);
- if(fac == 0) {
+ if (fac == 0) {
memcpy(rt, rt2, 4 * sizeof(float));
- } else {
+ }
+ else {
rt[0]= fac*rt1[0] + mfac*rt2[0];
rt[1]= fac*rt1[1] + mfac*rt2[1];
rt[2]= fac*rt1[2] + mfac*rt2[2];
@@ -676,24 +688,27 @@ static void do_alphaunder_effect_float(float facf0, float facf1, int x, int y,
rt1+= 4; rt2+= 4; rt+= 4;
}
- if(y==0) break;
+ if (y==0) break;
y--;
x= xo;
- while(x--) {
+ while (x--) {
- if(rt2[3]<=0 && fac4 >= 1.0f) {
+ if (rt2[3]<=0 && fac4 >= 1.0f) {
memcpy(rt, rt1, 4 * sizeof(float));
- } else if(rt2[3]>=1.0f) {
+ }
+ else if (rt2[3]>=1.0f) {
memcpy(rt, rt2, 4 * sizeof(float));
- } else {
+ }
+ else {
mfac= rt2[3];
fac= fac4*(1.0f-mfac);
- if(fac == 0) {
+ if (fac == 0) {
memcpy(rt, rt2, 4 * sizeof(float));
- } else {
+ }
+ else {
rt[0]= fac * rt1[0] + mfac * rt2[0];
rt[1]= fac * rt1[1] + mfac * rt2[1];
rt[2]= fac * rt1[2] + mfac * rt2[2];
@@ -719,7 +734,8 @@ static struct ImBuf* do_alphaunder_effect(
facf0, facf1, context.rectx, context.recty,
ibuf1->rect_float, ibuf2->rect_float,
out->rect_float);
- } else {
+ }
+ else {
do_alphaunder_effect_byte(
facf0, facf1, context.rectx, context.recty,
(char*) ibuf1->rect, (char*) ibuf2->rect,
@@ -751,10 +767,10 @@ static void do_cross_effect_byte(float facf0, float facf1, int x, int y,
fac4= (int)(256.0f*facf1);
fac3= 256-fac4;
- while(y--) {
+ while (y--) {
x= xo;
- while(x--) {
+ while (x--) {
rt[0]= (fac1*rt1[0] + fac2*rt2[0])>>8;
rt[1]= (fac1*rt1[1] + fac2*rt2[1])>>8;
@@ -764,11 +780,11 @@ static void do_cross_effect_byte(float facf0, float facf1, int x, int y,
rt1+= 4; rt2+= 4; rt+= 4;
}
- if(y==0) break;
+ if (y==0) break;
y--;
x= xo;
- while(x--) {
+ while (x--) {
rt[0]= (fac3*rt1[0] + fac4*rt2[0])>>8;
rt[1]= (fac3*rt1[1] + fac4*rt2[1])>>8;
@@ -798,10 +814,10 @@ static void do_cross_effect_float(float facf0, float facf1, int x, int y,
fac4= facf1;
fac3= 1.0f - fac4;
- while(y--) {
+ while (y--) {
x= xo;
- while(x--) {
+ while (x--) {
rt[0]= fac1*rt1[0] + fac2*rt2[0];
rt[1]= fac1*rt1[1] + fac2*rt2[1];
@@ -811,11 +827,11 @@ static void do_cross_effect_float(float facf0, float facf1, int x, int y,
rt1+= 4; rt2+= 4; rt+= 4;
}
- if(y==0) break;
+ if (y==0) break;
y--;
x= xo;
- while(x--) {
+ while (x--) {
rt[0]= fac3*rt1[0] + fac4*rt2[0];
rt[1]= fac3*rt1[1] + fac4*rt2[1];
@@ -844,7 +860,8 @@ static struct ImBuf* do_cross_effect(
facf0, facf1, context.rectx, context.recty,
ibuf1->rect_float, ibuf2->rect_float,
out->rect_float);
- } else {
+ }
+ else {
do_cross_effect_byte(
facf0, facf1, context.rectx, context.recty,
(char*) ibuf1->rect, (char*) ibuf2->rect,
@@ -956,19 +973,19 @@ static void gamtabs(float gamma)
int a;
/* gamtab: in short, out short */
- for(a=0; a<65536; a++) {
+ for (a=0; a<65536; a++) {
val= a;
val/= 65535.0f;
- if(gamma==2.0f) val= sqrt(val);
- else if(gamma!=1.0f) val= pow(val, igamma);
+ if (gamma==2.0f) val= sqrt(val);
+ else if (gamma!=1.0f) val= pow(val, igamma);
gamtab[a]= (65535.99f*val);
}
/* inverse gamtab1 : in byte, out short */
- for(a=1; a<=256; a++) {
- if(gamma==2.0f) igamtab1[a-1]= a*a-1;
- else if(gamma==1.0f) igamtab1[a-1]= 256*a-1;
+ for (a=1; a<=256; a++) {
+ if (gamma==2.0f) igamtab1[a-1]= a*a-1;
+ else if (gamma==1.0f) igamtab1[a-1]= 256*a-1;
else {
val= a/256.0f;
igamtab1[a - 1]= (65535.0 * pow(val, gamma)) - 1;
@@ -1016,37 +1033,37 @@ static void do_gammacross_effect_byte(float facf0, float UNUSED(facf1),
fac2= (int)(256.0f*facf0);
fac1= 256-fac2;
- while(y--) {
+ while (y--) {
x= xo;
- while(x--) {
+ while (x--) {
col= (fac1*igamtab1[rt1[0]] + fac2*igamtab1[rt2[0]])>>8;
- if(col>65535) rt[0]= 255; else rt[0]= ( (char *)(gamtab+col))[MOST_SIG_BYTE];
+ if (col>65535) rt[0]= 255; else rt[0]= ( (char *)(gamtab+col))[MOST_SIG_BYTE];
col=(fac1*igamtab1[rt1[1]] + fac2*igamtab1[rt2[1]])>>8;
- if(col>65535) rt[1]= 255; else rt[1]= ( (char *)(gamtab+col))[MOST_SIG_BYTE];
+ if (col>65535) rt[1]= 255; else rt[1]= ( (char *)(gamtab+col))[MOST_SIG_BYTE];
col= (fac1*igamtab1[rt1[2]] + fac2*igamtab1[rt2[2]])>>8;
- if(col>65535) rt[2]= 255; else rt[2]= ( (char *)(gamtab+col))[MOST_SIG_BYTE];
+ if (col>65535) rt[2]= 255; else rt[2]= ( (char *)(gamtab+col))[MOST_SIG_BYTE];
col= (fac1*igamtab1[rt1[3]] + fac2*igamtab1[rt2[3]])>>8;
- if(col>65535) rt[3]= 255; else rt[3]= ( (char *)(gamtab+col))[MOST_SIG_BYTE];
+ if (col>65535) rt[3]= 255; else rt[3]= ( (char *)(gamtab+col))[MOST_SIG_BYTE];
rt1+= 4; rt2+= 4; rt+= 4;
}
- if(y==0) break;
+ if (y==0) break;
y--;
x= xo;
- while(x--) {
+ while (x--) {
col= (fac1*igamtab1[rt1[0]] + fac2*igamtab1[rt2[0]])>>8;
- if(col>65535) rt[0]= 255; else rt[0]= ( (char *)(gamtab+col))[MOST_SIG_BYTE];
+ if (col>65535) rt[0]= 255; else rt[0]= ( (char *)(gamtab+col))[MOST_SIG_BYTE];
col= (fac1*igamtab1[rt1[1]] + fac2*igamtab1[rt2[1]])>>8;
- if(col>65535) rt[1]= 255; else rt[1]= ( (char *)(gamtab+col))[MOST_SIG_BYTE];
+ if (col>65535) rt[1]= 255; else rt[1]= ( (char *)(gamtab+col))[MOST_SIG_BYTE];
col= (fac1*igamtab1[rt1[2]] + fac2*igamtab1[rt2[2]])>>8;
- if(col>65535) rt[2]= 255; else rt[2]= ( (char *)(gamtab+col))[MOST_SIG_BYTE];
+ if (col>65535) rt[2]= 255; else rt[2]= ( (char *)(gamtab+col))[MOST_SIG_BYTE];
col= (fac1*igamtab1[rt1[3]] + fac2*igamtab1[rt2[3]])>>8;
- if(col>65535) rt[3]= 255; else rt[3]= ( (char *)(gamtab+col))[MOST_SIG_BYTE];
+ if (col>65535) rt[3]= 255; else rt[3]= ( (char *)(gamtab+col))[MOST_SIG_BYTE];
rt1+= 4; rt2+= 4; rt+= 4;
}
@@ -1071,10 +1088,10 @@ static void do_gammacross_effect_float(float facf0, float UNUSED(facf1),
fac2= facf0;
fac1= 1.0f - fac2;
- while(y--) {
+ while (y--) {
x= xo * 4;
- while(x--) {
+ while (x--) {
*rt= gammaCorrect(
fac1 * invGammaCorrect(*rt1)
@@ -1082,11 +1099,11 @@ static void do_gammacross_effect_float(float facf0, float UNUSED(facf1),
rt1++; rt2++; rt++;
}
- if(y==0) break;
+ if (y==0) break;
y--;
x= xo * 4;
- while(x--) {
+ while (x--) {
*rt= gammaCorrect(
fac1*invGammaCorrect(*rt1)
@@ -1113,7 +1130,8 @@ static struct ImBuf * do_gammacross_effect(
facf0, facf1, context.rectx, context.recty,
ibuf1->rect_float, ibuf2->rect_float,
out->rect_float);
- } else {
+ }
+ else {
do_gammacross_effect_byte(
facf0, facf1, context.rectx, context.recty,
(unsigned char*) ibuf1->rect, (unsigned char*) ibuf2->rect,
@@ -1142,37 +1160,37 @@ static void do_add_effect_byte(float facf0, float facf1, int x, int y,
fac1= (int)(256.0f*facf0);
fac3= (int)(256.0f*facf1);
- while(y--) {
+ while (y--) {
x= xo;
- while(x--) {
+ while (x--) {
col= rt1[0]+ ((fac1*rt2[0])>>8);
- if(col>255) rt[0]= 255; else rt[0]= col;
+ if (col>255) rt[0]= 255; else rt[0]= col;
col= rt1[1]+ ((fac1*rt2[1])>>8);
- if(col>255) rt[1]= 255; else rt[1]= col;
+ if (col>255) rt[1]= 255; else rt[1]= col;
col= rt1[2]+ ((fac1*rt2[2])>>8);
- if(col>255) rt[2]= 255; else rt[2]= col;
+ if (col>255) rt[2]= 255; else rt[2]= col;
col= rt1[3]+ ((fac1*rt2[3])>>8);
- if(col>255) rt[3]= 255; else rt[3]= col;
+ if (col>255) rt[3]= 255; else rt[3]= col;
rt1+= 4; rt2+= 4; rt+= 4;
}
- if(y==0) break;
+ if (y==0) break;
y--;
x= xo;
- while(x--) {
+ while (x--) {
col= rt1[0]+ ((fac3*rt2[0])>>8);
- if(col>255) rt[0]= 255; else rt[0]= col;
+ if (col>255) rt[0]= 255; else rt[0]= col;
col= rt1[1]+ ((fac3*rt2[1])>>8);
- if(col>255) rt[1]= 255; else rt[1]= col;
+ if (col>255) rt[1]= 255; else rt[1]= col;
col= rt1[2]+ ((fac3*rt2[2])>>8);
- if(col>255) rt[2]= 255; else rt[2]= col;
+ if (col>255) rt[2]= 255; else rt[2]= col;
col= rt1[3]+ ((fac3*rt2[3])>>8);
- if(col>255) rt[3]= 255; else rt[3]= col;
+ if (col>255) rt[3]= 255; else rt[3]= col;
rt1+= 4; rt2+= 4; rt+= 4;
}
@@ -1195,20 +1213,20 @@ static void do_add_effect_float(float facf0, float facf1, int x, int y,
fac1= facf0;
fac3= facf1;
- while(y--) {
+ while (y--) {
x= xo * 4;
- while(x--) {
+ while (x--) {
*rt = *rt1 + fac1 * (*rt2);
rt1++; rt2++; rt++;
}
- if(y==0) break;
+ if (y==0) break;
y--;
x= xo * 4;
- while(x--) {
+ while (x--) {
*rt = *rt1 + fac3 * (*rt2);
rt1++; rt2++; rt++;
@@ -1229,7 +1247,8 @@ static struct ImBuf * do_add_effect(SeqRenderData context,
facf0, facf1, context.rectx, context.recty,
ibuf1->rect_float, ibuf2->rect_float,
out->rect_float);
- } else {
+ }
+ else {
do_add_effect_byte(
facf0, facf1, context.rectx, context.recty,
(unsigned char*) ibuf1->rect, (unsigned char*) ibuf2->rect,
@@ -1258,37 +1277,37 @@ static void do_sub_effect_byte(float facf0, float facf1,
fac1= (int)(256.0f*facf0);
fac3= (int)(256.0f*facf1);
- while(y--) {
+ while (y--) {
x= xo;
- while(x--) {
+ while (x--) {
col= rt1[0]- ((fac1*rt2[0])>>8);
- if(col<0) rt[0]= 0; else rt[0]= col;
+ if (col<0) rt[0]= 0; else rt[0]= col;
col= rt1[1]- ((fac1*rt2[1])>>8);
- if(col<0) rt[1]= 0; else rt[1]= col;
+ if (col<0) rt[1]= 0; else rt[1]= col;
col= rt1[2]- ((fac1*rt2[2])>>8);
- if(col<0) rt[2]= 0; else rt[2]= col;
+ if (col<0) rt[2]= 0; else rt[2]= col;
col= rt1[3]- ((fac1*rt2[3])>>8);
- if(col<0) rt[3]= 0; else rt[3]= col;
+ if (col<0) rt[3]= 0; else rt[3]= col;
rt1+= 4; rt2+= 4; rt+= 4;
}
- if(y==0) break;
+ if (y==0) break;
y--;
x= xo;
- while(x--) {
+ while (x--) {
col= rt1[0]- ((fac3*rt2[0])>>8);
- if(col<0) rt[0]= 0; else rt[0]= col;
+ if (col<0) rt[0]= 0; else rt[0]= col;
col= rt1[1]- ((fac3*rt2[1])>>8);
- if(col<0) rt[1]= 0; else rt[1]= col;
+ if (col<0) rt[1]= 0; else rt[1]= col;
col= rt1[2]- ((fac3*rt2[2])>>8);
- if(col<0) rt[2]= 0; else rt[2]= col;
+ if (col<0) rt[2]= 0; else rt[2]= col;
col= rt1[3]- ((fac3*rt2[3])>>8);
- if(col<0) rt[3]= 0; else rt[3]= col;
+ if (col<0) rt[3]= 0; else rt[3]= col;
rt1+= 4; rt2+= 4; rt+= 4;
}
@@ -1311,20 +1330,20 @@ static void do_sub_effect_float(float facf0, float facf1, int x, int y,
fac1= facf0;
fac3= facf1;
- while(y--) {
+ while (y--) {
x= xo * 4;
- while(x--) {
+ while (x--) {
*rt = *rt1 - fac1 * (*rt2);
rt1++; rt2++; rt++;
}
- if(y==0) break;
+ if (y==0) break;
y--;
x= xo * 4;
- while(x--) {
+ while (x--) {
*rt = *rt1 - fac3 * (*rt2);
rt1++; rt2++; rt++;
@@ -1345,7 +1364,8 @@ static struct ImBuf * do_sub_effect(
facf0, facf1, context.rectx, context.recty,
ibuf1->rect_float, ibuf2->rect_float,
out->rect_float);
- } else {
+ }
+ else {
do_sub_effect_byte(
facf0, facf1, context.rectx, context.recty,
(char*) ibuf1->rect, (char*) ibuf2->rect,
@@ -1380,7 +1400,7 @@ static void do_drop_effect_byte(float facf0, float facf1, int x, int y,
rt1= (char*) rect1i;
out= (char*) outi;
for (y=0; y<height-YOFF; y++) {
- if(field) fac= fac1;
+ if (field) fac= fac1;
else fac= fac2;
field= !field;
@@ -1421,7 +1441,7 @@ static void do_drop_effect_float(float facf0, float facf1, int x, int y,
rt1= rect1i;
out= outi;
for (y=0; y<height-YOFF; y++) {
- if(field) fac= fac1;
+ if (field) fac= fac1;
else fac= fac2;
field= !field;
@@ -1467,10 +1487,10 @@ static void do_mul_effect_byte(float facf0, float facf1, int x, int y,
* yaux= -s*px + c*py;//+centy
*/
- while(y--) {
+ while (y--) {
x= xo;
- while(x--) {
+ while (x--) {
rt[0]= rt1[0] + ((fac1*rt1[0]*(rt2[0]-256))>>16);
rt[1]= rt1[1] + ((fac1*rt1[1]*(rt2[1]-256))>>16);
@@ -1480,11 +1500,11 @@ static void do_mul_effect_byte(float facf0, float facf1, int x, int y,
rt1+= 4; rt2+= 4; rt+= 4;
}
- if(y==0) break;
+ if (y==0) break;
y--;
x= xo;
- while(x--) {
+ while (x--) {
rt[0]= rt1[0] + ((fac3*rt1[0]*(rt2[0]-256))>>16);
rt[1]= rt1[1] + ((fac3*rt1[1]*(rt2[1]-256))>>16);
@@ -1516,10 +1536,10 @@ static void do_mul_effect_float(float facf0, float facf1, int x, int y,
* fac*(a*b) + (1-fac)*a => fac*a*(b-1)+a
*/
- while(y--) {
+ while (y--) {
x= xo;
- while(x--) {
+ while (x--) {
rt[0]= rt1[0] + fac1*rt1[0]*(rt2[0]-1.0f);
rt[1]= rt1[1] + fac1*rt1[1]*(rt2[1]-1.0f);
@@ -1529,11 +1549,11 @@ static void do_mul_effect_float(float facf0, float facf1, int x, int y,
rt1+= 4; rt2+= 4; rt+= 4;
}
- if(y==0) break;
+ if (y==0) break;
y--;
x= xo;
- while(x--) {
+ while (x--) {
rt[0]= rt1[0] + fac3*rt1[0]*(rt2[0]-1.0f);
rt[1]= rt1[1] + fac3*rt1[1]*(rt2[1]-1.0f);
@@ -1558,7 +1578,8 @@ static struct ImBuf * do_mul_effect(
facf0, facf1, context.rectx, context.recty,
ibuf1->rect_float, ibuf2->rect_float,
out->rect_float);
- } else {
+ }
+ else {
do_mul_effect_byte(
facf0, facf1, context.rectx, context.recty,
(unsigned char*) ibuf1->rect, (unsigned char*) ibuf2->rect,
@@ -1595,18 +1616,18 @@ static float in_band(float width,float dist,int side,int dir)
{
float alpha;
- if(width == 0)
+ if (width == 0)
return (float)side;
- if(width < dist)
+ if (width < dist)
return (float)side;
- if(side == 1)
+ if (side == 1)
alpha = (dist+0.5f*width) / (width);
else
alpha = (0.5f*width-dist) / (width);
- if(dir == 0)
+ if (dir == 0)
alpha = 1-alpha;
return alpha;
@@ -1627,13 +1648,14 @@ static float check_zone(WipeZone *wipezone, int x, int y,
WipeVars *wipe = (WipeVars *)seq->effectdata;
int width;
- if(wipezone->flip) x = xo - x;
+ if (wipezone->flip) x = xo - x;
angle = wipezone->angle;
- if(wipe->forward) {
+ if (wipe->forward) {
posx = facf0 * xo;
posy = facf0 * yo;
- } else{
+ }
+ else {
posx = xo - facf0 * xo;
posy = yo - facf0 * yo;
}
@@ -1642,7 +1664,7 @@ static float check_zone(WipeZone *wipezone, int x, int y,
case DO_SINGLE_WIPE:
width = wipezone->width;
- if(angle == 0.0f) {
+ if (angle == 0.0f) {
b1 = posy;
b2 = y;
hyp = fabs(y - posy);
@@ -1653,20 +1675,20 @@ static float check_zone(WipeZone *wipezone, int x, int y,
hyp = fabsf(angle*x+y+(-posy-angle*posx))*wipezone->pythangle;
}
- if(angle < 0) {
+ if (angle < 0) {
temp1 = b1;
b1 = b2;
b2 = temp1;
}
- if(wipe->forward) {
- if(b1 < b2)
+ if (wipe->forward) {
+ if (b1 < b2)
output = in_band(width,hyp,1,1);
else
output = in_band(width,hyp,0,1);
}
else {
- if(b1 < b2)
+ if (b1 < b2)
output = in_band(width,hyp,0,1);
else
output = in_band(width,hyp,1,1);
@@ -1674,7 +1696,7 @@ static float check_zone(WipeZone *wipezone, int x, int y,
break;
case DO_DOUBLE_WIPE:
- if(!wipe->forward)
+ if (!wipe->forward)
facf0 = 1.0f-facf0; // Go the other direction
width = wipezone->width; // calculate the blur width
@@ -1698,19 +1720,21 @@ static float check_zone(WipeZone *wipezone, int x, int y,
hwidth = minf(hwidth, fabsf(b3-b1)/2.0f);
- if(b2 < b1 && b2 < b3 ) {
+ if (b2 < b1 && b2 < b3 ) {
output = in_band(hwidth,hyp,0,1);
- } else if(b2 > b1 && b2 > b3 ) {
+ }
+ else if (b2 > b1 && b2 > b3 ) {
output = in_band(hwidth,hyp2,0,1);
- } else {
- if( hyp < hwidth && hyp2 > hwidth )
+ }
+ else {
+ if ( hyp < hwidth && hyp2 > hwidth )
output = in_band(hwidth,hyp,1,1);
- else if( hyp > hwidth && hyp2 < hwidth )
+ else if ( hyp > hwidth && hyp2 < hwidth )
output = in_band(hwidth,hyp2,1,1);
else
output = in_band(hwidth,hyp2,1,1) * in_band(hwidth,hyp,1,1);
}
- if(!wipe->forward)output = 1-output;
+ if (!wipe->forward)output = 1-output;
break;
case DO_CLOCK_WIPE:
/*
@@ -1723,7 +1747,7 @@ static float check_zone(WipeZone *wipezone, int x, int y,
widthf = wipe->edgeWidth*2.0f*(float)M_PI;
temp1 = 2.0f * (float)M_PI * facf0;
- if(wipe->forward) {
+ if (wipe->forward) {
temp1 = 2.0f*(float)M_PI - temp1;
}
@@ -1731,14 +1755,15 @@ static float check_zone(WipeZone *wipezone, int x, int y,
y = y - halfy;
temp2 = asin(abs(y)/sqrt(x*x + y*y));
- if(x <= 0 && y >= 0) temp2 = (float)M_PI - temp2;
- else if(x<=0 && y <= 0) temp2 += (float)M_PI;
- else if(x >= 0 && y <= 0) temp2 = 2.0f*(float)M_PI - temp2;
+ if (x <= 0 && y >= 0) temp2 = (float)M_PI - temp2;
+ else if (x<=0 && y <= 0) temp2 += (float)M_PI;
+ else if (x >= 0 && y <= 0) temp2 = 2.0f*(float)M_PI - temp2;
- if(wipe->forward) {
+ if (wipe->forward) {
temp3 = temp1-(widthf*0.5f)*facf0;
temp4 = temp1+(widthf*0.5f)*(1-facf0);
- } else{
+ }
+ else {
temp3 = temp1-(widthf*0.5f)*(1-facf0);
temp4 = temp1+(widthf*0.5f)*facf0;
}
@@ -1746,19 +1771,19 @@ static float check_zone(WipeZone *wipezone, int x, int y,
if (temp4 > 2.0f*(float)M_PI) temp4 = 2.0f*(float)M_PI;
- if(temp2 < temp3) output = 0;
+ if (temp2 < temp3) output = 0;
else if (temp2 > temp4) output = 1;
else output = (temp2-temp3)/(temp4-temp3);
- if(x == 0 && y == 0) output = 1;
- if(output != output) output = 1;
- if(wipe->forward) output = 1 - output;
+ if (x == 0 && y == 0) output = 1;
+ if (output != output) output = 1;
+ if (wipe->forward) output = 1 - output;
break;
/* BOX WIPE IS NOT WORKING YET */
/* case DO_CROSS_WIPE: */
/* BOX WIPE IS NOT WORKING YET */
/*
case DO_BOX_WIPE:
- if(invert)facf0 = 1-facf0;
+ if (invert)facf0 = 1-facf0;
width = (int)(wipe->edgeWidth*((xo+yo)/2.0));
hwidth = (float)width/2.0;
@@ -1774,22 +1799,24 @@ static float check_zone(WipeZone *wipezone, int x, int y,
temp2 = yo*(1-facf0/2)-yo*facf0/2;
pointdist = sqrt(temp1*temp1 + temp2*temp2);
- if(b2 < b1 && b2 < b3 ) {
- if(hwidth < pointdist)
+ if (b2 < b1 && b2 < b3 ) {
+ if (hwidth < pointdist)
output = in_band(wipezone,hwidth,hyp,facf0,0,1);
- } else if(b2 > b1 && b2 > b3 ) {
- if(hwidth < pointdist)
+ }
+ else if (b2 > b1 && b2 > b3 ) {
+ if (hwidth < pointdist)
output = in_band(wipezone,hwidth,hyp2,facf0,0,1);
- } else {
- if( hyp < hwidth && hyp2 > hwidth )
+ }
+ else {
+ if ( hyp < hwidth && hyp2 > hwidth )
output = in_band(wipezone,hwidth,hyp,facf0,1,1);
- else if( hyp > hwidth && hyp2 < hwidth )
+ else if ( hyp > hwidth && hyp2 < hwidth )
output = in_band(wipezone,hwidth,hyp2,facf0,1,1);
else
output = in_band(wipezone,hwidth,hyp2,facf0,1,1) * in_band(wipezone,hwidth,hyp,facf0,1,1);
}
- if(invert)facf0 = 1-facf0;
+ if (invert)facf0 = 1-facf0;
angle = -1/angle;
b1 = posy/2 - (-angle)*posx/2;
b3 = (yo-posy/2) - (-angle)*(xo-posx/2);
@@ -1798,16 +1825,18 @@ static float check_zone(WipeZone *wipezone, int x, int y,
hyp = abs(angle*x+y+(-posy/2-angle*posx/2))*wipezone->pythangle;
hyp2 = abs(angle*x+y+(-(yo-posy/2)-angle*(xo-posx/2)))*wipezone->pythangle;
- if(b2 < b1 && b2 < b3 ) {
- if(hwidth < pointdist)
+ if (b2 < b1 && b2 < b3 ) {
+ if (hwidth < pointdist)
output *= in_band(wipezone,hwidth,hyp,facf0,0,1);
- } else if(b2 > b1 && b2 > b3 ) {
- if(hwidth < pointdist)
+ }
+ else if (b2 > b1 && b2 > b3 ) {
+ if (hwidth < pointdist)
output *= in_band(wipezone,hwidth,hyp2,facf0,0,1);
- } else {
- if( hyp < hwidth && hyp2 > hwidth )
+ }
+ else {
+ if ( hyp < hwidth && hyp2 > hwidth )
output *= in_band(wipezone,hwidth,hyp,facf0,1,1);
- else if( hyp > hwidth && hyp2 < hwidth )
+ else if ( hyp > hwidth && hyp2 < hwidth )
output *= in_band(wipezone,hwidth,hyp2,facf0,1,1);
else
output *= in_band(wipezone,hwidth,hyp2,facf0,1,1) * in_band(wipezone,hwidth,hyp,facf0,1,1);
@@ -1816,10 +1845,10 @@ static float check_zone(WipeZone *wipezone, int x, int y,
break;
*/
case DO_IRIS_WIPE:
- if(xo > yo) yo = xo;
+ if (xo > yo) yo = xo;
else xo = yo;
- if(!wipe->forward) facf0 = 1-facf0;
+ if (!wipe->forward) facf0 = 1-facf0;
width = wipezone->width;
hwidth = width*0.5f;
@@ -1828,21 +1857,21 @@ static float check_zone(WipeZone *wipezone, int x, int y,
pointdist = sqrt(temp1*temp1 + temp1*temp1);
temp2 = sqrt((halfx-x)*(halfx-x) + (halfy-y)*(halfy-y));
- if(temp2 > pointdist) output = in_band(hwidth,fabs(temp2-pointdist),0,1);
+ if (temp2 > pointdist) output = in_band(hwidth,fabs(temp2-pointdist),0,1);
else output = in_band(hwidth,fabs(temp2-pointdist),1,1);
- if(!wipe->forward) output = 1-output;
+ if (!wipe->forward) output = 1-output;
break;
}
if (output < 0) output = 0;
- else if(output > 1) output = 1;
+ else if (output > 1) output = 1;
return output;
}
static void init_wipe_effect(Sequence *seq)
{
- if(seq->effectdata)MEM_freeN(seq->effectdata);
+ if (seq->effectdata)MEM_freeN(seq->effectdata);
seq->effectdata = MEM_callocN(sizeof(struct WipeVars), "wipevars");
}
@@ -1853,7 +1882,7 @@ static int num_inputs_wipe(void)
static void free_wipe_effect(Sequence *seq)
{
- if(seq->effectdata)MEM_freeN(seq->effectdata);
+ if (seq->effectdata)MEM_freeN(seq->effectdata);
seq->effectdata = NULL;
}
@@ -1880,8 +1909,8 @@ static void do_wipe_effect_byte(Sequence *seq, float facf0, float UNUSED(facf1),
xo = x;
yo = y;
- for(y=0;y<yo;y++) {
- for(x=0;x<xo;x++) {
+ for (y=0;y<yo;y++) {
+ for (x=0;x<xo;x++) {
float check = check_zone(&wipezone,x,y,seq,facf0);
if (check) {
if (rt1) {
@@ -1889,19 +1918,22 @@ static void do_wipe_effect_byte(Sequence *seq, float facf0, float UNUSED(facf1),
rt[1] = (int)(rt1[1]*check)+ (int)(rt2[1]*(1-check));
rt[2] = (int)(rt1[2]*check)+ (int)(rt2[2]*(1-check));
rt[3] = (int)(rt1[3]*check)+ (int)(rt2[3]*(1-check));
- } else {
+ }
+ else {
rt[0] = 0;
rt[1] = 0;
rt[2] = 0;
rt[3] = 255;
}
- } else {
+ }
+ else {
if (rt2) {
rt[0] = rt2[0];
rt[1] = rt2[1];
rt[2] = rt2[2];
rt[3] = rt2[3];
- } else {
+ }
+ else {
rt[0] = 0;
rt[1] = 0;
rt[2] = 0;
@@ -1910,10 +1942,10 @@ static void do_wipe_effect_byte(Sequence *seq, float facf0, float UNUSED(facf1),
}
rt+=4;
- if(rt1 !=NULL) {
+ if (rt1 !=NULL) {
rt1+=4;
}
- if(rt2 !=NULL) {
+ if (rt2 !=NULL) {
rt2+=4;
}
}
@@ -1938,8 +1970,8 @@ static void do_wipe_effect_float(Sequence *seq, float facf0, float UNUSED(facf1)
xo = x;
yo = y;
- for(y=0;y<yo;y++) {
- for(x=0;x<xo;x++) {
+ for (y=0;y<yo;y++) {
+ for (x=0;x<xo;x++) {
float check = check_zone(&wipezone,x,y,seq,facf0);
if (check) {
if (rt1) {
@@ -1947,19 +1979,22 @@ static void do_wipe_effect_float(Sequence *seq, float facf0, float UNUSED(facf1)
rt[1] = rt1[1]*check+ rt2[1]*(1-check);
rt[2] = rt1[2]*check+ rt2[2]*(1-check);
rt[3] = rt1[3]*check+ rt2[3]*(1-check);
- } else {
+ }
+ else {
rt[0] = 0;
rt[1] = 0;
rt[2] = 0;
rt[3] = 1.0;
}
- } else {
+ }
+ else {
if (rt2) {
rt[0] = rt2[0];
rt[1] = rt2[1];
rt[2] = rt2[2];
rt[3] = rt2[3];
- } else {
+ }
+ else {
rt[0] = 0;
rt[1] = 0;
rt[2] = 0;
@@ -1968,10 +2003,10 @@ static void do_wipe_effect_float(Sequence *seq, float facf0, float UNUSED(facf1)
}
rt+=4;
- if(rt1 !=NULL) {
+ if (rt1 !=NULL) {
rt1+=4;
}
- if(rt2 !=NULL) {
+ if (rt2 !=NULL) {
rt2+=4;
}
}
@@ -1991,7 +2026,8 @@ static struct ImBuf * do_wipe_effect(
facf0, facf1, context.rectx, context.recty,
ibuf1->rect_float, ibuf2->rect_float,
out->rect_float);
- } else {
+ }
+ else {
do_wipe_effect_byte(seq,
facf0, facf1, context.rectx, context.recty,
(unsigned char*) ibuf1->rect, (unsigned char*) ibuf2->rect,
@@ -2007,7 +2043,7 @@ static void init_transform_effect(Sequence *seq)
{
TransformVars *transform;
- if(seq->effectdata)MEM_freeN(seq->effectdata);
+ if (seq->effectdata)MEM_freeN(seq->effectdata);
seq->effectdata = MEM_callocN(sizeof(struct TransformVars), "transformvars");
transform = (TransformVars *)seq->effectdata;
@@ -2032,7 +2068,7 @@ static int num_inputs_transform(void)
static void free_transform_effect(Sequence *seq)
{
- if(seq->effectdata)MEM_freeN(seq->effectdata);
+ if (seq->effectdata)MEM_freeN(seq->effectdata);
seq->effectdata = NULL;
}
@@ -2100,18 +2136,20 @@ static void do_transform(Scene *scene, Sequence *seq, float UNUSED(facf0), int x
// Scale
if (transform->uniform_scale) {
scale_x = scale_y = transform->ScalexIni;
- } else {
+ }
+ else {
scale_x = transform->ScalexIni;
scale_y = transform->ScaleyIni;
}
// Translate
- if(!transform->percent) {
+ if (!transform->percent) {
float rd_s = (scene->r.size/100.0f);
translate_x = transform->xIni*rd_s+(x/2.0f);
translate_y = transform->yIni*rd_s+(y/2.0f);
- }else{
+ }
+ else {
translate_x = x*(transform->xIni/100.0f)+(x/2.0f);
translate_y = y*(transform->yIni/100.0f)+(y/2.0f);
}
@@ -2527,7 +2565,7 @@ static void RVIsolateHighlights_byte (unsigned char* in, unsigned char* out,
int intensity;
- for(y=0;y< height;y++) {
+ for (y=0;y< height;y++) {
for (x=0;x< width;x++) {
index= (x+y*width)*4;
@@ -2538,7 +2576,8 @@ static void RVIsolateHighlights_byte (unsigned char* in, unsigned char* out,
out[index+GlowG]=MIN2(255*clamp, (in[index+GlowG]*boost*intensity)/255);
out[index+GlowB]=MIN2(255*clamp, (in[index+GlowB]*boost*intensity)/255);
out[index+GlowA]=MIN2(255*clamp, (in[index+GlowA]*boost*intensity)/255);
- } else{
+ }
+ else {
out[index+GlowR]=0;
out[index+GlowG]=0;
out[index+GlowB]=0;
@@ -2556,7 +2595,7 @@ static void RVIsolateHighlights_float (float* in, float* out,
float intensity;
- for(y=0;y< height;y++) {
+ for (y=0;y< height;y++) {
for (x=0;x< width;x++) {
index= (x+y*width)*4;
@@ -2567,7 +2606,8 @@ static void RVIsolateHighlights_float (float* in, float* out,
out[index+GlowG]=MIN2(clamp, (in[index+GlowG]*boost*intensity));
out[index+GlowB]=MIN2(clamp, (in[index+GlowB]*boost*intensity));
out[index+GlowA]=MIN2(clamp, (in[index+GlowA]*boost*intensity));
- } else{
+ }
+ else {
out[index+GlowR]=0;
out[index+GlowG]=0;
out[index+GlowB]=0;
@@ -2581,7 +2621,7 @@ static void init_glow_effect(Sequence *seq)
{
GlowVars *glow;
- if(seq->effectdata)MEM_freeN(seq->effectdata);
+ if (seq->effectdata)MEM_freeN(seq->effectdata);
seq->effectdata = MEM_callocN(sizeof(struct GlowVars), "glowvars");
glow = (GlowVars *)seq->effectdata;
@@ -2600,7 +2640,7 @@ static int num_inputs_glow(void)
static void free_glow_effect(Sequence *seq)
{
- if(seq->effectdata)MEM_freeN(seq->effectdata);
+ if (seq->effectdata)MEM_freeN(seq->effectdata);
seq->effectdata = NULL;
}
@@ -2654,7 +2694,8 @@ static struct ImBuf * do_glow_effect(
context.rectx, context.recty,
ibuf1->rect_float, ibuf2->rect_float,
out->rect_float);
- } else {
+ }
+ else {
do_glow_effect_byte(seq, render_size,
facf0, facf1,
context.rectx, context.recty,
@@ -2673,7 +2714,7 @@ static void init_solid_color(Sequence *seq)
{
SolidColorVars *cv;
- if(seq->effectdata)MEM_freeN(seq->effectdata);
+ if (seq->effectdata)MEM_freeN(seq->effectdata);
seq->effectdata = MEM_callocN(sizeof(struct SolidColorVars), "solidcolor");
cv = (SolidColorVars *)seq->effectdata;
@@ -2687,7 +2728,7 @@ static int num_inputs_color(void)
static void free_solid_color(Sequence *seq)
{
- if(seq->effectdata)MEM_freeN(seq->effectdata);
+ if (seq->effectdata)MEM_freeN(seq->effectdata);
seq->effectdata = NULL;
}
@@ -2731,8 +2772,8 @@ static struct ImBuf * do_solid_color(
rect = (unsigned char *)out->rect;
- for(y=0; y<out->y; y++) {
- for(x=0; x<out->x; x++, rect+=4) {
+ for (y=0; y<out->y; y++) {
+ for (x=0; x<out->x; x++, rect+=4) {
rect[0]= col0[0];
rect[1]= col0[1];
rect[2]= col0[2];
@@ -2740,7 +2781,7 @@ static struct ImBuf * do_solid_color(
}
y++;
if (y<out->y) {
- for(x=0; x<out->x; x++, rect+=4) {
+ for (x=0; x<out->x; x++, rect+=4) {
rect[0]= col1[0];
rect[1]= col1[1];
rect[2]= col1[2];
@@ -2749,7 +2790,8 @@ static struct ImBuf * do_solid_color(
}
}
- } else if (out->rect_float) {
+ }
+ else if (out->rect_float) {
float col0[3];
float col1[3];
@@ -2763,8 +2805,8 @@ static struct ImBuf * do_solid_color(
rect_float = out->rect_float;
- for(y=0; y<out->y; y++) {
- for(x=0; x<out->x; x++, rect_float+=4) {
+ for (y=0; y<out->y; y++) {
+ for (x=0; x<out->x; x++, rect_float+=4) {
rect_float[0]= col0[0];
rect_float[1]= col0[1];
rect_float[2]= col0[2];
@@ -2772,7 +2814,7 @@ static struct ImBuf * do_solid_color(
}
y++;
if (y<out->y) {
- for(x=0; x<out->x; x++, rect_float+=4) {
+ for (x=0; x<out->x; x++, rect_float+=4) {
rect_float[0]= col1[0];
rect_float[1]= col1[1];
rect_float[2]= col1[2];
@@ -2831,7 +2873,8 @@ static struct ImBuf * do_multicam(
if (input_have_to_preprocess(context, seq, cfra)) {
out = IMB_dupImBuf(i);
IMB_freeImBuf(i);
- } else {
+ }
+ else {
out = i;
}
@@ -2908,7 +2951,8 @@ static struct ImBuf * do_adjustment(
if (input_have_to_preprocess(context, seq, cfra)) {
out = IMB_dupImBuf(i);
IMB_freeImBuf(i);
- } else {
+ }
+ else {
out = i;
}
@@ -2922,7 +2966,7 @@ static void init_speed_effect(Sequence *seq)
{
SpeedControlVars * v;
- if(seq->effectdata) MEM_freeN(seq->effectdata);
+ if (seq->effectdata) MEM_freeN(seq->effectdata);
seq->effectdata = MEM_callocN(sizeof(struct SpeedControlVars),
"speedcontrolvars");
@@ -2949,8 +2993,8 @@ static int num_inputs_speed(void)
static void free_speed_effect(Sequence *seq)
{
SpeedControlVars * v = (SpeedControlVars *)seq->effectdata;
- if(v->frameMap) MEM_freeN(v->frameMap);
- if(seq->effectdata) MEM_freeN(seq->effectdata);
+ if (v->frameMap) MEM_freeN(v->frameMap);
+ if (seq->effectdata) MEM_freeN(seq->effectdata);
seq->effectdata = NULL;
}
@@ -2980,11 +3024,13 @@ static void store_icu_yrange_speed(struct Sequence * seq,
if ((v->flags & SEQ_SPEED_INTEGRATE) != 0) {
*ymin = -100.0;
*ymax = 100.0;
- } else {
+ }
+ else {
if (v->flags & SEQ_SPEED_COMPRESS_IPO_Y) {
*ymin = 0.0;
*ymax = 1.0;
- } else {
+ }
+ else {
*ymin = 0.0;
*ymax = seq->len;
}
@@ -3037,7 +3083,8 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force)
flags = SEQ_SPEED_INTEGRATE;
fcu = NULL;
}
- } else {
+ }
+ else {
/* if there is no fcurve, use value as simple multiplier */
if (!fcu) {
fallback_fac = seq->speed_fader; /* same as speed_factor in rna*/
@@ -3052,9 +3099,10 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force)
v->lastValidFrame = 0;
for (cfra = 1; cfra < v->length; cfra++) {
- if(fcu) {
+ if (fcu) {
facf = evaluate_fcurve(fcu, seq->startdisp + cfra);
- } else {
+ }
+ else {
facf = fallback_fac;
}
facf *= v->globalSpeed;
@@ -3063,20 +3111,23 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force)
if (cursor >= seq->seq1->len) {
v->frameMap[cfra] = seq->seq1->len - 1;
- } else {
+ }
+ else {
v->frameMap[cfra] = cursor;
v->lastValidFrame = cfra;
}
}
- } else {
+ }
+ else {
float facf;
v->lastValidFrame = 0;
for (cfra = 0; cfra < v->length; cfra++) {
- if(fcu) {
+ if (fcu) {
facf = evaluate_fcurve(fcu, seq->startdisp + cfra);
- } else {
+ }
+ else {
facf = fallback_fac;
}
@@ -3087,7 +3138,8 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force)
if (facf >= seq->seq1->len) {
facf = seq->seq1->len - 1;
- } else {
+ }
+ else {
v->lastValidFrame = cfra;
}
v->frameMap[cfra] = facf;
@@ -3136,7 +3188,8 @@ static int early_out_fade(struct Sequence *UNUSED(seq),
{
if (facf0 == 0.0f && facf1 == 0.0f) {
return 1;
- } else if (facf0 == 1.0f && facf1 == 1.0f) {
+ }
+ else if (facf0 == 1.0f && facf1 == 1.0f) {
return 2;
}
return 0;
@@ -3193,7 +3246,8 @@ static struct ImBuf * do_overdrop_effect(SeqRenderData context,
facf0, facf1, x, y,
ibuf1->rect_float, ibuf2->rect_float,
out->rect_float);
- } else {
+ }
+ else {
do_drop_effect_byte(
facf0, facf1, x, y,
(char*) ibuf1->rect,
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index ed8361f0cfc..18749d7b5a6 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -105,8 +105,8 @@ void printf_strip(Sequence *seq)
int seqbase_recursive_apply(ListBase *seqbase, int (*apply_func)(Sequence *seq, void *), void *arg)
{
Sequence *iseq;
- for(iseq= seqbase->first; iseq; iseq= iseq->next) {
- if(seq_recursive_apply(iseq, apply_func, arg) == -1)
+ for (iseq= seqbase->first; iseq; iseq= iseq->next) {
+ if (seq_recursive_apply(iseq, apply_func, arg) == -1)
return -1; /* bail out */
}
return 1;
@@ -116,10 +116,10 @@ int seq_recursive_apply(Sequence *seq, int (*apply_func)(Sequence *, void *), vo
{
int ret= apply_func(seq, arg);
- if(ret == -1)
+ if (ret == -1)
return -1; /* bail out */
- if(ret && seq->seqbase.first)
+ if (ret && seq->seqbase.first)
ret = seqbase_recursive_apply(&seq->seqbase, apply_func, arg);
return ret;
@@ -142,8 +142,8 @@ static void free_proxy_seq(Sequence *seq)
void seq_free_strip(Strip *strip)
{
strip->us--;
- if(strip->us>0) return;
- if(strip->us<0) {
+ if (strip->us>0) return;
+ if (strip->us<0) {
printf("error: negative users in strip\n");
return;
}
@@ -174,9 +174,9 @@ void seq_free_strip(Strip *strip)
void seq_free_sequence(Scene *scene, Sequence *seq)
{
- if(seq->strip) seq_free_strip(seq->strip);
+ if (seq->strip) seq_free_strip(seq->strip);
- if(seq->anim) IMB_free_anim(seq->anim);
+ if (seq->anim) IMB_free_anim(seq->anim);
if (seq->type & SEQ_EFFECT) {
struct SeqEffectHandle sh = get_sequence_effect(seq);
@@ -184,18 +184,18 @@ void seq_free_sequence(Scene *scene, Sequence *seq)
sh.free(seq);
}
- if(seq->sound) {
+ if (seq->sound) {
((ID *)seq->sound)->us--;
}
/* clipboard has no scene and will never have a sound handle or be active */
- if(scene) {
+ if (scene) {
Editing *ed = scene->ed;
if (ed->act_seq==seq)
ed->act_seq= NULL;
- if(seq->scene_sound && ELEM(seq->type, SEQ_SOUND, SEQ_SCENE))
+ if (seq->scene_sound && ELEM(seq->type, SEQ_SOUND, SEQ_SCENE))
sound_remove_scene_sound(scene, seq->scene_sound);
seq_free_animdata(scene, seq);
@@ -208,7 +208,7 @@ void seq_free_sequence_recurse(Scene *scene, Sequence *seq)
{
Sequence *iseq;
- for(iseq= seq->seqbase.first; iseq; iseq= iseq->next) {
+ for (iseq= seq->seqbase.first; iseq; iseq= iseq->next) {
seq_free_sequence_recurse(scene, iseq);
}
@@ -231,7 +231,7 @@ static void seq_free_clipboard_recursive(Sequence *seq_parent)
{
Sequence *seq, *nseq;
- for(seq= seq_parent->seqbase.first; seq; seq= nseq) {
+ for (seq= seq_parent->seqbase.first; seq; seq= nseq) {
nseq= seq->next;
seq_free_clipboard_recursive(seq);
}
@@ -243,7 +243,7 @@ void seq_free_clipboard(void)
{
Sequence *seq, *nseq;
- for(seq= seqbase_clipboard.first; seq; seq= nseq) {
+ for (seq= seqbase_clipboard.first; seq; seq= nseq) {
nseq= seq->next;
seq_free_clipboard_recursive(seq);
}
@@ -256,7 +256,7 @@ void seq_free_editing(Scene *scene)
MetaStack *ms;
Sequence *seq;
- if(ed==NULL)
+ if (ed==NULL)
return;
SEQ_BEGIN(ed, seq) {
@@ -264,7 +264,7 @@ void seq_free_editing(Scene *scene)
}
SEQ_END
- while((ms= ed->metastack.first)) {
+ while ((ms= ed->metastack.first)) {
BLI_remlink(&ed->metastack, ms);
MEM_freeN(ms);
}
@@ -371,10 +371,10 @@ static void seq_count(ListBase *seqbase, int *tot)
{
Sequence *seq;
- for(seq=seqbase->first; seq; seq=seq->next) {
+ for (seq=seqbase->first; seq; seq=seq->next) {
(*tot)++;
- if(seq->seqbase.first)
+ if (seq->seqbase.first)
seq_count(&seq->seqbase, tot);
}
}
@@ -383,10 +383,10 @@ static void seq_build_array(ListBase *seqbase, Sequence ***array, int depth)
{
Sequence *seq;
- for(seq=seqbase->first; seq; seq=seq->next) {
+ for (seq=seqbase->first; seq; seq=seq->next) {
seq->depth= depth;
- if(seq->seqbase.first)
+ if (seq->seqbase.first)
seq_build_array(&seq->seqbase, array, depth+1);
**array= seq;
@@ -401,19 +401,19 @@ void seq_array(Editing *ed, Sequence ***seqarray, int *tot, int use_pointer)
*seqarray= NULL;
*tot= 0;
- if(ed == NULL)
+ if (ed == NULL)
return;
- if(use_pointer)
+ if (use_pointer)
seq_count(ed->seqbasep, tot);
else
seq_count(&ed->seqbase, tot);
- if(*tot == 0)
+ if (*tot == 0)
return;
*seqarray= array= MEM_mallocN(sizeof(Sequence *)*(*tot), "SeqArray");
- if(use_pointer)
+ if (use_pointer)
seq_build_array(ed->seqbasep, &array, 0);
else
seq_build_array(&ed->seqbase, &array, 0);
@@ -424,7 +424,7 @@ void seq_begin(Editing *ed, SeqIterator *iter, int use_pointer)
memset(iter, 0, sizeof(*iter));
seq_array(ed, &iter->array, &iter->tot, use_pointer);
- if(iter->tot) {
+ if (iter->tot) {
iter->cur= 0;
iter->seq= iter->array[iter->cur];
iter->valid= 1;
@@ -433,7 +433,7 @@ void seq_begin(Editing *ed, SeqIterator *iter, int use_pointer)
void seq_next(SeqIterator *iter)
{
- if(++iter->cur < iter->tot)
+ if (++iter->cur < iter->tot)
iter->seq= iter->array[iter->cur];
else
iter->valid= 0;
@@ -441,7 +441,7 @@ void seq_next(SeqIterator *iter)
void seq_end(SeqIterator *iter)
{
- if(iter->array)
+ if (iter->array)
MEM_freeN(iter->array);
iter->valid= 0;
@@ -462,12 +462,12 @@ static void do_seq_count_cb(ListBase *seqbase, int *totseq,
Sequence *seq;
seq= seqbase->first;
- while(seq) {
+ while (seq) {
int test = test_func(seq);
if (test & BUILD_SEQAR_COUNT_CURRENT) {
(*totseq)++;
}
- if(seq->seqbase.first && (test & BUILD_SEQAR_COUNT_CHILDREN)) {
+ if (seq->seqbase.first && (test & BUILD_SEQAR_COUNT_CHILDREN)) {
do_seq_count_cb(&seq->seqbase, totseq, test_func);
}
seq= seq->next;
@@ -480,11 +480,11 @@ static void do_build_seqar_cb(ListBase *seqbase, Sequence ***seqar, int depth,
Sequence *seq;
seq= seqbase->first;
- while(seq) {
+ while (seq) {
int test = test_func(seq);
seq->depth= depth;
- if(seq->seqbase.first && (test & BUILD_SEQAR_COUNT_CHILDREN)) {
+ if (seq->seqbase.first && (test & BUILD_SEQAR_COUNT_CHILDREN)) {
do_build_seqar_cb(&seq->seqbase, seqar, depth+1, test_func);
}
if (test & BUILD_SEQAR_COUNT_CURRENT) {
@@ -503,7 +503,7 @@ void build_seqar_cb(ListBase *seqbase, Sequence ***seqar, int *totseq,
*totseq= 0;
do_seq_count_cb(seqbase, totseq, test_func);
- if(*totseq==0) {
+ if (*totseq==0) {
*seqar= NULL;
return;
}
@@ -521,18 +521,18 @@ static void seq_update_sound_bounds_recursive(Scene *scene, Sequence *metaseq)
/* for sound we go over full meta tree to update bounds of the sound strips,
* since sound is played outside of evaluating the imbufs, */
- for(seq=metaseq->seqbase.first; seq; seq=seq->next) {
- if(seq->type == SEQ_META) {
+ for (seq=metaseq->seqbase.first; seq; seq=seq->next) {
+ if (seq->type == SEQ_META) {
seq_update_sound_bounds_recursive(scene, seq);
}
- else if(ELEM(seq->type, SEQ_SOUND, SEQ_SCENE)) {
- if(seq->scene_sound) {
+ else if (ELEM(seq->type, SEQ_SOUND, SEQ_SCENE)) {
+ if (seq->scene_sound) {
int startofs = seq->startofs;
int endofs = seq->endofs;
- if(seq->startofs + seq->start < metaseq->start + metaseq->startofs)
+ if (seq->startofs + seq->start < metaseq->start + metaseq->startofs)
startofs = metaseq->start + metaseq->startofs - seq->start;
- if(seq->start + seq->len - seq->endofs > metaseq->start + metaseq->len - metaseq->endofs)
+ if (seq->start + seq->len - seq->endofs > metaseq->start + metaseq->len - metaseq->endofs)
endofs = seq->start + seq->len - metaseq->start - metaseq->len + metaseq->endofs;
sound_move_scene_sound(scene, seq->scene_sound, seq->start + startofs, seq->start+seq->len - endofs, startofs);
}
@@ -542,24 +542,24 @@ static void seq_update_sound_bounds_recursive(Scene *scene, Sequence *metaseq)
void calc_sequence_disp(Scene *scene, Sequence *seq)
{
- if(seq->startofs && seq->startstill) seq->startstill= 0;
- if(seq->endofs && seq->endstill) seq->endstill= 0;
+ if (seq->startofs && seq->startstill) seq->startstill= 0;
+ if (seq->endofs && seq->endstill) seq->endstill= 0;
seq->startdisp= seq->start + seq->startofs - seq->startstill;
seq->enddisp= seq->start+seq->len - seq->endofs + seq->endstill;
seq->handsize= 10.0; /* 10 frames */
- if( seq->enddisp-seq->startdisp < 10 ) {
+ if ( seq->enddisp-seq->startdisp < 10 ) {
seq->handsize= (float)(0.5*(seq->enddisp-seq->startdisp));
}
- else if(seq->enddisp-seq->startdisp > 250) {
+ else if (seq->enddisp-seq->startdisp > 250) {
seq->handsize= (float)((seq->enddisp-seq->startdisp)/25);
}
- if(ELEM(seq->type, SEQ_SOUND, SEQ_SCENE)) {
+ if (ELEM(seq->type, SEQ_SOUND, SEQ_SCENE)) {
seq_update_sound_bounds(scene, seq);
}
- else if(seq->type == SEQ_META)
+ else if (seq->type == SEQ_META)
seq_update_sound_bounds_recursive(scene, seq);
}
@@ -570,17 +570,17 @@ void calc_sequence(Scene *scene, Sequence *seq)
/* check all metas recursively */
seqm= seq->seqbase.first;
- while(seqm) {
- if(seqm->seqbase.first) calc_sequence(scene, seqm);
+ while (seqm) {
+ if (seqm->seqbase.first) calc_sequence(scene, seqm);
seqm= seqm->next;
}
/* effects and meta: automatic start and end */
- if(seq->type & SEQ_EFFECT) {
+ if (seq->type & SEQ_EFFECT) {
/* pointers */
- if(seq->seq2==NULL) seq->seq2= seq->seq1;
- if(seq->seq3==NULL) seq->seq3= seq->seq1;
+ if (seq->seq2==NULL) seq->seq2= seq->seq1;
+ if (seq->seq3==NULL) seq->seq3= seq->seq1;
/* effecten go from seq1 -> seq2: test */
@@ -597,7 +597,7 @@ void calc_sequence(Scene *scene, Sequence *seq)
seq->enddisp= MIN3(seq->seq1->enddisp, seq->seq2->enddisp, seq->seq3->enddisp);
/* we cant help if strips don't overlap, it wont give useful results.
* but at least ensure 'len' is never negative which causes bad bugs elsewhere. */
- if(seq->enddisp < seq->startdisp) {
+ if (seq->enddisp < seq->startdisp) {
/* simple start/end swap */
seq->start= seq->enddisp;
seq->enddisp = seq->startdisp;
@@ -615,14 +615,14 @@ void calc_sequence(Scene *scene, Sequence *seq)
}
}
else {
- if(seq->type==SEQ_META) {
+ if (seq->type==SEQ_META) {
seqm= seq->seqbase.first;
- if(seqm) {
+ if (seqm) {
min= MAXFRAME * 2;
max= -MAXFRAME * 2;
- while(seqm) {
- if(seqm->startdisp < min) min= seqm->startdisp;
- if(seqm->enddisp > max) max= seqm->enddisp;
+ while (seqm) {
+ if (seqm->startdisp < min) min= seqm->startdisp;
+ if (seqm->enddisp > max) max= seqm->enddisp;
seqm= seqm->next;
}
seq->start= min + seq->anim_startofs;
@@ -647,7 +647,7 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq, int lock_range)
return;
}
- if(lock_range) {
+ if (lock_range) {
/* keep so we don't have to move the actual start and end points (only the data) */
calc_sequence_disp(scene, seq);
prev_startdisp= seq->startdisp;
@@ -673,7 +673,7 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq, int lock_range)
seq->strip->stripdata->name);
BLI_path_abs(str, G.main->name);
- if(seq->anim) IMB_free_anim(seq->anim);
+ if (seq->anim) IMB_free_anim(seq->anim);
seq->anim = openanim(str, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0), seq->streamindex);
if (!seq->anim) {
@@ -695,7 +695,7 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq, int lock_range)
break;
case SEQ_SOUND:
#ifdef WITH_AUDASPACE
- if(!seq->sound)
+ if (!seq->sound)
return;
seq->len = ceil(AUD_getInfo(seq->sound->playback_handle).length * FPS);
seq->len -= seq->anim_startofs;
@@ -721,7 +721,7 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq, int lock_range)
free_proxy_seq(seq);
- if(lock_range) {
+ if (lock_range) {
seq_tx_set_final_left(seq, prev_startdisp);
seq_tx_set_final_right(seq, prev_enddisp);
seq_single_fix(seq);
@@ -738,35 +738,35 @@ void sort_seq(Scene *scene)
Sequence *seq, *seqt;
- if(ed==NULL) return;
+ if (ed==NULL) return;
seqbase.first= seqbase.last= NULL;
effbase.first= effbase.last= NULL;
- while( (seq= ed->seqbasep->first) ) {
+ while ( (seq= ed->seqbasep->first) ) {
BLI_remlink(ed->seqbasep, seq);
- if(seq->type & SEQ_EFFECT) {
+ if (seq->type & SEQ_EFFECT) {
seqt= effbase.first;
- while(seqt) {
- if(seqt->machine>=seq->machine) {
+ while (seqt) {
+ if (seqt->machine>=seq->machine) {
BLI_insertlinkbefore(&effbase, seqt, seq);
break;
}
seqt= seqt->next;
}
- if(seqt==NULL) BLI_addtail(&effbase, seq);
+ if (seqt==NULL) BLI_addtail(&effbase, seq);
}
else {
seqt= seqbase.first;
- while(seqt) {
- if(seqt->machine>=seq->machine) {
+ while (seqt) {
+ if (seqt->machine>=seq->machine) {
BLI_insertlinkbefore(&seqbase, seqt, seq);
break;
}
seqt= seqt->next;
}
- if(seqt==NULL) BLI_addtail(&seqbase, seq);
+ if (seqt==NULL) BLI_addtail(&seqbase, seq);
}
}
@@ -777,7 +777,7 @@ void sort_seq(Scene *scene)
static int clear_scene_in_allseqs_cb(Sequence *seq, void *arg_pt)
{
- if(seq->scene==(Scene *)arg_pt)
+ if (seq->scene==(Scene *)arg_pt)
seq->scene= NULL;
return 1;
}
@@ -787,8 +787,8 @@ void clear_scene_in_allseqs(Main *bmain, Scene *scene)
Scene *scene_iter;
/* when a scene is deleted: test all seqs */
- for(scene_iter= bmain->scene.first; scene_iter; scene_iter= scene_iter->id.next) {
- if(scene_iter != scene && scene_iter->ed) {
+ for (scene_iter= bmain->scene.first; scene_iter; scene_iter= scene_iter->id.next) {
+ if (scene_iter != scene && scene_iter->ed) {
seqbase_recursive_apply(&scene_iter->ed->seqbase, clear_scene_in_allseqs_cb, scene);
}
}
@@ -811,7 +811,7 @@ static void seqbase_unique_name(ListBase *seqbasep, Sequence *seq)
static void seqbase_unique_name(ListBase *seqbasep, SeqUniqueInfo *sui)
{
Sequence *seq;
- for(seq=seqbasep->first; seq; seq= seq->next) {
+ for (seq=seqbasep->first; seq; seq= seq->next) {
if (sui->seq != seq && strcmp(sui->name_dest, seq->name+2)==0) {
/* SEQ_NAME_MAXSTR - 2 for prefix, -1 for \0, -4 for the number */
BLI_snprintf(sui->name_dest, sizeof(sui->name_dest), "%.59s.%03d", sui->name_src, sui->count++);
@@ -822,7 +822,7 @@ static void seqbase_unique_name(ListBase *seqbasep, SeqUniqueInfo *sui)
static int seqbase_unique_name_recursive_cb(Sequence *seq, void *arg_pt)
{
- if(seq->seqbase.first)
+ if (seq->seqbase.first)
seqbase_unique_name(&seq->seqbase, (SeqUniqueInfo *)arg_pt);
return 1;
}
@@ -843,11 +843,11 @@ void seqbase_unique_name_recursive(ListBase *seqbasep, struct Sequence *seq)
*dot= '\0';
dot++;
- if(*dot)
+ if (*dot)
sui.count= atoi(dot) + 1;
}
- while(sui.match) {
+ while (sui.match) {
sui.match= 0;
seqbase_unique_name(seqbasep, &sui);
seqbase_recursive_apply(seqbasep, seqbase_unique_name_recursive_cb, &sui);
@@ -890,16 +890,19 @@ const char *give_seqname(Sequence *seq)
const char *name = give_seqname_by_type(seq->type);
if (!name) {
- if(seq->type<SEQ_EFFECT) {
+ if (seq->type<SEQ_EFFECT) {
return seq->strip->dir;
- } else if(seq->type==SEQ_PLUGIN) {
- if(!(seq->flag & SEQ_EFFECT_NOT_LOADED) &&
+ }
+ else if (seq->type==SEQ_PLUGIN) {
+ if (!(seq->flag & SEQ_EFFECT_NOT_LOADED) &&
seq->plugin && seq->plugin->doit) {
return seq->plugin->pname;
- } else {
+ }
+ else {
return "Plugin";
}
- } else {
+ }
+ else {
return "Effect";
}
}
@@ -914,7 +917,7 @@ static void make_black_ibuf(ImBuf *ibuf)
float *rect_float;
int tot;
- if(ibuf==NULL || (ibuf->rect==NULL && ibuf->rect_float==NULL)) return;
+ if (ibuf==NULL || (ibuf->rect==NULL && ibuf->rect_float==NULL)) return;
tot= ibuf->x*ibuf->y;
@@ -943,23 +946,23 @@ static void multibuf(ImBuf *ibuf, float fmul)
if (rt) {
a= ibuf->x*ibuf->y;
- while(a--) {
+ while (a--) {
icol= (mul*rt[0])>>8;
- if(icol>254) rt[0]= 255; else rt[0]= icol;
+ if (icol>254) rt[0]= 255; else rt[0]= icol;
icol= (mul*rt[1])>>8;
- if(icol>254) rt[1]= 255; else rt[1]= icol;
+ if (icol>254) rt[1]= 255; else rt[1]= icol;
icol= (mul*rt[2])>>8;
- if(icol>254) rt[2]= 255; else rt[2]= icol;
+ if (icol>254) rt[2]= 255; else rt[2]= icol;
icol= (mul*rt[3])>>8;
- if(icol>254) rt[3]= 255; else rt[3]= icol;
+ if (icol>254) rt[3]= 255; else rt[3]= icol;
rt+= 4;
}
}
if (rt_float) {
a= ibuf->x*ibuf->y;
- while(a--) {
+ while (a--) {
rt_float[0] *= fmul;
rt_float[1] *= fmul;
rt_float[2] *= fmul;
@@ -980,18 +983,19 @@ static float give_stripelem_index(Sequence *seq, float cfra)
end = seq->enddisp;
}
- if(end < sta) {
+ if (end < sta) {
return -1;
}
- if(seq->flag&SEQ_REVERSE_FRAMES) {
+ if (seq->flag&SEQ_REVERSE_FRAMES) {
/*reverse frame in this sequence */
- if(cfra <= sta) nr= end - sta;
- else if(cfra >= end) nr= 0;
+ if (cfra <= sta) nr= end - sta;
+ else if (cfra >= end) nr= 0;
else nr= end - cfra;
- } else {
- if(cfra <= sta) nr= 0;
- else if(cfra >= end) nr= end - sta;
+ }
+ else {
+ if (cfra <= sta) nr= 0;
+ else if (cfra >= end) nr= end - sta;
else nr= cfra - sta;
}
@@ -1008,7 +1012,7 @@ StripElem *give_stripelem(Sequence *seq, int cfra)
{
StripElem *se= seq->strip->stripdata;
- if(seq->type == SEQ_IMAGE) { /* only
+ if (seq->type == SEQ_IMAGE) { /* only
* IMAGE strips use the whole array,
* MOVIE strips use only
* the first element, all other strips
@@ -1030,8 +1034,8 @@ static int evaluate_seq_frame_gen(Sequence ** seq_arr, ListBase *seqbase, int cf
memset(seq_arr, 0, sizeof(Sequence*) * (MAXSEQ+1));
seq= seqbase->first;
- while(seq) {
- if(seq->startdisp <=cfra && seq->enddisp > cfra) {
+ while (seq) {
+ if (seq->startdisp <=cfra && seq->enddisp > cfra) {
seq_arr[seq->machine]= seq;
totseq++;
}
@@ -1046,7 +1050,7 @@ int evaluate_seq_frame(Scene *scene, int cfra)
Editing *ed= seq_give_editing(scene, FALSE);
Sequence *seq_arr[MAXSEQ+1];
- if(ed==NULL) return 0;
+ if (ed==NULL) return 0;
return evaluate_seq_frame_gen(seq_arr, ed->seqbasep, cfra);
}
@@ -1065,7 +1069,7 @@ static int get_shown_sequences( ListBase * seqbasep, int cfra, int chanshown, Se
return 0;
}
- if(evaluate_seq_frame_gen(seq_arr, seqbasep, cfra)) {
+ if (evaluate_seq_frame_gen(seq_arr, seqbasep, cfra)) {
if (b == 0) {
b = MAXSEQ;
}
@@ -1150,7 +1154,7 @@ static void seq_open_anim_file(Sequence * seq)
char name[FILE_MAX];
StripProxy * proxy;
- if(seq->anim != NULL) {
+ if (seq->anim != NULL) {
return;
}
@@ -1197,9 +1201,11 @@ static int seq_proxy_get_fname(Sequence * seq, int cfra, int render_size, char *
if (seq->flag & (SEQ_USE_PROXY_CUSTOM_DIR|SEQ_USE_PROXY_CUSTOM_FILE)) {
BLI_strncpy(dir, seq->strip->proxy->dir, sizeof(dir));
- } else if (seq->type == SEQ_IMAGE) {
+ }
+ else if (seq->type == SEQ_IMAGE) {
BLI_snprintf(dir, PROXY_MAXFILE, "%s/BL_proxy", seq->strip->dir);
- } else {
+ }
+ else {
return FALSE;
}
@@ -1218,7 +1224,8 @@ static int seq_proxy_get_fname(Sequence * seq, int cfra, int render_size, char *
render_size,
give_stripelem(seq, cfra)->name);
frameno = 1;
- } else {
+ }
+ else {
frameno = (int) give_stripelem_index(seq, cfra) + seq->anim_startofs;
BLI_snprintf(name, PROXY_MAXFILE, "%s/proxy_misc/%d/####", dir,
render_size);
@@ -1284,7 +1291,8 @@ static struct ImBuf * seq_proxy_fetch(SeqRenderData context, Sequence * seq, int
if (BLI_exists(name)) {
return IMB_loadiffname(name, IB_rect);
- } else {
+ }
+ else {
return NULL;
}
}
@@ -1318,7 +1326,7 @@ static void seq_proxy_build_frame(SeqRenderData context,
ibuf->ftype= JPG | quality;
/* unsupported feature only confuses other s/w */
- if(ibuf->planes==32)
+ if (ibuf->planes==32)
ibuf->planes= 24;
BLI_make_existing_file(name);
@@ -1420,7 +1428,7 @@ void seq_proxy_rebuild(SeqIndexBuildContext *context, short *stop, short *do_upd
- seq->startdisp + seq->startstill);
*do_update= 1;
- if(*stop || G.afbreek)
+ if (*stop || G.afbreek)
break;
}
}
@@ -1451,11 +1459,11 @@ static StripColorBalance calc_cb(StripColorBalance * cb_)
cb.lift[c] = 2.0f - cb.lift[c];
}
- if(cb.flag & SEQ_COLOR_BALANCE_INVERSE_LIFT) {
+ if (cb.flag & SEQ_COLOR_BALANCE_INVERSE_LIFT) {
for (c = 0; c < 3; c++) {
/* tweak to give more subtle results
* values above 1.0 are scaled */
- if(cb.lift[c] > 1.0f)
+ if (cb.lift[c] > 1.0f)
cb.lift[c] = pow(cb.lift[c] - 1.0f, 2.0) + 1.0;
cb.lift[c] = 2.0f - cb.lift[c];
@@ -1466,7 +1474,8 @@ static StripColorBalance calc_cb(StripColorBalance * cb_)
for (c = 0; c < 3; c++) {
if (cb.gain[c] != 0.0f) {
cb.gain[c] = 1.0f / cb.gain[c];
- } else {
+ }
+ else {
cb.gain[c] = 1000000; /* should be enough :) */
}
}
@@ -1476,7 +1485,8 @@ static StripColorBalance calc_cb(StripColorBalance * cb_)
for (c = 0; c < 3; c++) {
if (cb.gamma[c] != 0.0f) {
cb.gamma[c] = 1.0f/cb.gamma[c];
- } else {
+ }
+ else {
cb.gamma[c] = 1000000; /* should be enough :) */
}
}
@@ -1594,9 +1604,11 @@ static void color_balance(Sequence * seq, ImBuf* ibuf, float mul)
{
if (ibuf->rect_float) {
color_balance_float_float(seq, ibuf, mul);
- } else if(seq->flag & SEQ_MAKE_FLOAT) {
+ }
+ else if (seq->flag & SEQ_MAKE_FLOAT) {
color_balance_byte_float(seq, ibuf, mul);
- } else {
+ }
+ else {
color_balance_byte_byte(seq, ibuf, mul);
}
}
@@ -1631,7 +1643,7 @@ int input_have_to_preprocess(
mul = seq->mul;
- if(seq->blend_mode == SEQ_BLEND_REPLACE) {
+ if (seq->blend_mode == SEQ_BLEND_REPLACE) {
mul *= seq->blend_opacity / 100.0f;
}
@@ -1654,12 +1666,12 @@ static ImBuf * input_preprocess(
ibuf = IMB_makeSingleUser(ibuf);
- if((seq->flag & SEQ_FILTERY)
+ if ((seq->flag & SEQ_FILTERY)
&& !ELEM(seq->type, SEQ_MOVIE, SEQ_MOVIECLIP)) {
IMB_filtery(ibuf);
}
- if(seq->flag & (SEQ_USE_CROP|SEQ_USE_TRANSFORM)) {
+ if (seq->flag & (SEQ_USE_CROP|SEQ_USE_TRANSFORM)) {
StripCrop c= {0};
StripTransform t= {0};
int sx,sy,dx,dy;
@@ -1676,10 +1688,10 @@ static ImBuf * input_preprocess(
}
}
- if(seq->flag & SEQ_USE_CROP && seq->strip->crop) {
+ if (seq->flag & SEQ_USE_CROP && seq->strip->crop) {
c = *seq->strip->crop;
}
- if(seq->flag & SEQ_USE_TRANSFORM && seq->strip->transform) {
+ if (seq->flag & SEQ_USE_TRANSFORM && seq->strip->transform) {
t = *seq->strip->transform;
}
@@ -1704,7 +1716,8 @@ static ImBuf * input_preprocess(
if (is_preprocessed) {
dx = context.rectx;
dy = context.recty;
- } else {
+ }
+ else {
dx = context.scene->r.xsch;
dy = context.scene->r.ysch;
}
@@ -1713,7 +1726,8 @@ static ImBuf * input_preprocess(
if (c.top+c.bottom >= ibuf->y || c.left+c.right >= ibuf->x ||
t.xofs >= dx || t.yofs >= dy) {
make_black_ibuf(ibuf);
- } else {
+ }
+ else {
ImBuf * i = IMB_allocImBuf(
dx, dy, 32,
ibuf->rect_float ? IB_rectfloat : IB_rect);
@@ -1727,30 +1741,30 @@ static ImBuf * input_preprocess(
}
}
- if(seq->flag & SEQ_FLIPX) {
+ if (seq->flag & SEQ_FLIPX) {
IMB_flipx(ibuf);
}
- if(seq->flag & SEQ_FLIPY) {
+ if (seq->flag & SEQ_FLIPY) {
IMB_flipy(ibuf);
}
- if(seq->sat != 1.0f) {
+ if (seq->sat != 1.0f) {
IMB_saturation(ibuf, seq->sat);
}
mul = seq->mul;
- if(seq->blend_mode == SEQ_BLEND_REPLACE) {
+ if (seq->blend_mode == SEQ_BLEND_REPLACE) {
mul *= seq->blend_opacity / 100.0f;
}
- if(seq->flag & SEQ_USE_COLOR_BALANCE && seq->strip->color_balance) {
+ if (seq->flag & SEQ_USE_COLOR_BALANCE && seq->strip->color_balance) {
color_balance(seq, ibuf, mul);
mul = 1.0;
}
- if(seq->flag & SEQ_MAKE_FLOAT) {
+ if (seq->flag & SEQ_MAKE_FLOAT) {
if (!ibuf->rect_float)
IMB_float_from_rect_simple(ibuf);
@@ -1759,21 +1773,22 @@ static ImBuf * input_preprocess(
}
}
- if(mul != 1.0f) {
+ if (mul != 1.0f) {
multibuf(ibuf, mul);
}
- if(seq->flag & SEQ_MAKE_PREMUL) {
- if(ibuf->planes == 32 && ibuf->zbuf == NULL) {
+ if (seq->flag & SEQ_MAKE_PREMUL) {
+ if (ibuf->planes == 32 && ibuf->zbuf == NULL) {
IMB_premultiply_alpha(ibuf);
}
}
- if(ibuf->x != context.rectx || ibuf->y != context.recty ) {
- if(context.scene->r.mode & R_OSA) {
+ if (ibuf->x != context.rectx || ibuf->y != context.recty ) {
+ if (context.scene->r.mode & R_OSA) {
IMB_scaleImBuf(ibuf, (short)context.rectx, (short)context.recty);
- } else {
+ }
+ else {
IMB_scalefastImBuf(ibuf, (short)context.rectx, (short)context.recty);
}
}
@@ -1790,7 +1805,8 @@ static ImBuf * copy_from_ibuf_still(SeqRenderData context, Sequence * seq,
ibuf = seq_stripelem_cache_get(
context, seq, seq->start,
SEQ_STRIPELEM_IBUF_STARTSTILL);
- } else if (nr == seq->len - 1) {
+ }
+ else if (nr == seq->len - 1) {
ibuf = seq_stripelem_cache_get(
context, seq, seq->start,
SEQ_STRIPELEM_IBUF_ENDSTILL);
@@ -1872,10 +1888,11 @@ static ImBuf* seq_render_effect_strip_impl(
fcu = id_data_find_fcurve(&context.scene->id, seq, &RNA_Sequence, "effect_fader", 0, NULL);
if (fcu) {
fac = facf = evaluate_fcurve(fcu, cfra);
- if( context.scene->r.mode & R_FIELDS ) {
+ if ( context.scene->r.mode & R_FIELDS ) {
facf = evaluate_fcurve(fcu, cfra + 0.5f);
}
- } else {
+ }
+ else {
fac = facf = seq->effect_fader;
}
}
@@ -1888,8 +1905,8 @@ static ImBuf* seq_render_effect_strip_impl(
NULL, NULL, NULL);
break;
case EARLY_DO_EFFECT:
- for(i=0; i<3; i++) {
- if(input[i])
+ for (i=0; i<3; i++) {
+ if (input[i])
ibuf[i] = seq_render_strip(
context, input[i], cfra);
}
@@ -1906,7 +1923,8 @@ static ImBuf* seq_render_effect_strip_impl(
if (ibuf[0]) {
if (input_have_to_preprocess(context, seq, cfra)) {
out = IMB_dupImBuf(ibuf[0]);
- } else {
+ }
+ else {
out = ibuf[0];
IMB_refImBuf(out);
}
@@ -1919,7 +1937,8 @@ static ImBuf* seq_render_effect_strip_impl(
if (ibuf[1]) {
if (input_have_to_preprocess(context, seq, cfra)) {
out = IMB_dupImBuf(ibuf[1]);
- } else {
+ }
+ else {
out = ibuf[1];
IMB_refImBuf(out);
}
@@ -1945,7 +1964,7 @@ static ImBuf * seq_render_movieclip_strip(
MovieClipUser user;
float tloc[2], tscale, tangle;
- if(!seq->clip) {
+ if (!seq->clip) {
return NULL;
}
@@ -1981,7 +2000,8 @@ static ImBuf * seq_render_movieclip_strip(
ibuf = BKE_movieclip_get_stable_ibuf(
seq->clip, &user, tloc, &tscale, &tangle,
0);
- } else {
+ }
+ else {
ibuf = BKE_movieclip_get_ibuf_flag(
seq->clip, &user, 0, MOVIECLIP_CACHE_SKIP);
}
@@ -2036,7 +2056,7 @@ static ImBuf * seq_render_scene_strip(
Scene *scene;
/* don't refer to seq->scene above this point!, it can be NULL */
- if(seq->scene == NULL) {
+ if (seq->scene == NULL) {
return NULL;
}
@@ -2048,14 +2068,14 @@ static ImBuf * seq_render_scene_strip(
oldcfra= scene->r.cfra;
scene->r.cfra= frame;
- if(seq->scene_camera)
+ if (seq->scene_camera)
camera= seq->scene_camera;
else {
scene_camera_switch_update(scene);
camera= scene->camera;
}
- if(have_seq==FALSE && camera==NULL) {
+ if (have_seq==FALSE && camera==NULL) {
scene->r.cfra= oldcfra;
return NULL;
}
@@ -2072,17 +2092,17 @@ static ImBuf * seq_render_scene_strip(
(void)oldmarkers;
#endif
- if(sequencer_view3d_cb && BLI_thread_is_main() && doseq_gl && (scene == context.scene || have_seq==0) && camera) {
+ if (sequencer_view3d_cb && BLI_thread_is_main() && doseq_gl && (scene == context.scene || have_seq==0) && camera) {
char err_out[256]= "unknown";
/* for old scened this can be uninitialized, should probably be added to do_versions at some point if the functionality stays */
- if(context.scene->r.seq_prev_type==0)
+ if (context.scene->r.seq_prev_type==0)
context.scene->r.seq_prev_type = 3 /* ==OB_SOLID */;
/* opengl offscreen render */
scene_update_for_newframe(context.bmain, scene, scene->lay);
ibuf = sequencer_view3d_cb(scene, camera, context.rectx, context.recty,
IB_rect, context.scene->r.seq_prev_type, TRUE, err_out);
- if(ibuf == NULL) {
+ if (ibuf == NULL) {
fprintf(stderr, "seq_render_scene_strip failed to get opengl buffer: %s\n", err_out);
}
}
@@ -2091,8 +2111,8 @@ static ImBuf * seq_render_scene_strip(
RenderResult rres;
/* XXX: this if can be removed when sequence preview rendering uses the job system */
- if(rendering || context.scene != scene) {
- if(re==NULL)
+ if (rendering || context.scene != scene) {
+ if (re==NULL)
re= RE_NewRender(scene->id.name);
RE_BlenderFrame(re, context.bmain, scene, NULL, camera, scene->lay, frame, FALSE);
@@ -2103,16 +2123,16 @@ static ImBuf * seq_render_scene_strip(
RE_AcquireResultImage(re, &rres);
- if(rres.rectf) {
+ if (rres.rectf) {
ibuf= IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rectfloat);
memcpy(ibuf->rect_float, rres.rectf, 4*sizeof(float)*rres.rectx*rres.recty);
- if(rres.rectz) {
+ if (rres.rectz) {
addzbuffloatImBuf(ibuf);
memcpy(ibuf->zbuf_float, rres.rectz, sizeof(float)*rres.rectx*rres.recty);
}
/* float buffers in the sequencer are not linear */
- if(scene->r.color_mgt_flag & R_COLOR_MANAGEMENT)
+ if (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT)
ibuf->profile= IB_PROFILE_LINEAR_RGB;
else
ibuf->profile= IB_PROFILE_NONE;
@@ -2133,7 +2153,7 @@ static ImBuf * seq_render_scene_strip(
scene->r.cfra = oldcfra;
- if(frame != oldcfra)
+ if (frame != oldcfra)
scene_update_for_newframe(context.bmain, scene, scene->lay);
#ifdef DURIAN_CAMERA_SWITCH
@@ -2171,19 +2191,19 @@ static ImBuf * seq_render_strip(SeqRenderData context, Sequence * seq, float cfr
is_proxy_image = (ibuf != NULL);
}
- if(ibuf == NULL) switch(type) {
+ if (ibuf == NULL) switch(type) {
case SEQ_META:
{
ImBuf * meta_ibuf = NULL;
- if(seq->seqbase.first)
+ if (seq->seqbase.first)
meta_ibuf = seq_render_strip_stack(
context, &seq->seqbase,
seq->start + nr, 0);
- if(meta_ibuf) {
+ if (meta_ibuf) {
ibuf = meta_ibuf;
- if(ibuf && use_preprocess) {
+ if (ibuf && use_preprocess) {
struct ImBuf * i = IMB_dupImBuf(ibuf);
IMB_freeImBuf(ibuf);
@@ -2210,7 +2230,7 @@ static ImBuf * seq_render_strip(SeqRenderData context, Sequence * seq, float cfr
if (child_ibuf) {
ibuf = child_ibuf;
- if(ibuf && use_preprocess) {
+ if (ibuf && use_preprocess) {
struct ImBuf * i = IMB_dupImBuf(ibuf);
IMB_freeImBuf(ibuf);
@@ -2241,7 +2261,7 @@ static ImBuf * seq_render_strip(SeqRenderData context, Sequence * seq, float cfr
imb_freerectImBuf(ibuf);
/* all sequencer color is done in SRGB space, linear gives odd crossfades */
- if(ibuf->profile == IB_PROFILE_LINEAR_RGB)
+ if (ibuf->profile == IB_PROFILE_LINEAR_RGB)
IMB_convert_profile(ibuf, IB_PROFILE_NONE);
copy_to_ibuf_still(context, seq, nr, ibuf);
@@ -2255,7 +2275,7 @@ static ImBuf * seq_render_strip(SeqRenderData context, Sequence * seq, float cfr
{
seq_open_anim_file(seq);
- if(seq->anim) {
+ if (seq->anim) {
IMB_anim_set_preseek(seq->anim,
seq->anim_preseek);
@@ -2292,7 +2312,7 @@ static ImBuf * seq_render_strip(SeqRenderData context, Sequence * seq, float cfr
{
ibuf = seq_render_movieclip_strip(context, seq, nr);
- if(ibuf && use_preprocess) {
+ if (ibuf && use_preprocess) {
struct ImBuf * i = IMB_dupImBuf(ibuf);
IMB_freeImBuf(ibuf);
@@ -2351,7 +2371,8 @@ static int seq_get_early_out_for_blend_mode(Sequence * seq)
if (seq_must_swap_input_in_blend_mode(seq)) {
if (early_out == EARLY_USE_INPUT_2) {
return EARLY_USE_INPUT_1;
- } else if (early_out == EARLY_USE_INPUT_1) {
+ }
+ else if (early_out == EARLY_USE_INPUT_1) {
return EARLY_USE_INPUT_2;
}
}
@@ -2373,7 +2394,7 @@ static ImBuf* seq_render_strip_stack(
}
#if 0 /* commentind since this breaks keyframing, since it resets the value on draw */
- if(scene->r.cfra != cfra) {
+ if (scene->r.cfra != cfra) {
// XXX for prefetch and overlay offset!..., very bad!!!
AnimData *adt= BKE_animdata_from_id(&scene->id);
BKE_animsys_evaluate_animdata(scene, &scene->id, adt, cfra, ADT_RECALC_ANIM);
@@ -2387,7 +2408,7 @@ static ImBuf* seq_render_strip_stack(
return out;
}
- if(count == 1) {
+ if (count == 1) {
out = seq_render_strip(context, seq_arr[0], cfra);
seq_stripelem_cache_put(context, seq_arr[0], cfra,
SEQ_STRIPELEM_IBUF_COMP, out);
@@ -2456,7 +2477,8 @@ static ImBuf* seq_render_strip_stack(
out = sh.execute(context, seq, cfra,
facf, facf,
ibuf2, ibuf1, NULL);
- } else {
+ }
+ else {
out = sh.execute(context, seq, cfra,
facf, facf,
ibuf1, ibuf2, NULL);
@@ -2484,13 +2506,14 @@ ImBuf *give_ibuf_seq(SeqRenderData context, float cfra, int chanshown)
int count;
ListBase *seqbasep;
- if(ed==NULL) return NULL;
+ if (ed==NULL) return NULL;
count = BLI_countlist(&ed->metastack);
- if((chanshown < 0) && (count > 0)) {
+ if ((chanshown < 0) && (count > 0)) {
count = MAX2(count + chanshown, 0);
seqbasep= ((MetaStack*)BLI_findlink(&ed->metastack, count))->oldbasep;
- } else {
+ }
+ else {
seqbasep= ed->seqbasep;
}
@@ -2514,7 +2537,8 @@ static int seq_can_blend(Sequence *seq)
{
if (ELEM4(seq->type, SEQ_IMAGE, SEQ_META, SEQ_SCENE, SEQ_MOVIE)) {
return 1;
- } else {
+ }
+ else {
return 0;
}
}
@@ -2687,7 +2711,7 @@ static void seq_stop_threads()
pthread_cond_broadcast(&wakeup_cond);
pthread_mutex_unlock(&wakeup_lock);
- for(tslot = running_threads.first; tslot; tslot= tslot->next) {
+ for (tslot = running_threads.first; tslot; tslot= tslot->next) {
pthread_join(tslot->pthread, NULL);
}
@@ -2746,8 +2770,8 @@ static void seq_wait_for_prefetch_ready()
pthread_mutex_lock(&prefetch_ready_lock);
- for(;;) {
- for(tslot = running_threads.first; tslot; tslot= tslot->next) {
+ for (;;) {
+ for (tslot = running_threads.first; tslot; tslot= tslot->next) {
if (tslot->running) {
break;
}
@@ -2852,7 +2876,7 @@ ImBuf *give_ibuf_seq_threaded(SeqRenderData context, float cfra, int chanshown)
static void free_anim_seq(Sequence *seq)
{
- if(seq->anim) {
+ if (seq->anim) {
IMB_free_anim(seq->anim);
seq->anim = NULL;
}
@@ -2889,18 +2913,18 @@ void free_imbuf_seq(Scene *scene, ListBase * seqbase, int check_mem_usage,
seq_stripelem_cache_cleanup();
- for(seq= seqbase->first; seq; seq= seq->next) {
- if(seq->strip) {
- if(seq->type==SEQ_MOVIE && !keep_file_handles)
+ for (seq= seqbase->first; seq; seq= seq->next) {
+ if (seq->strip) {
+ if (seq->type==SEQ_MOVIE && !keep_file_handles)
free_anim_seq(seq);
- if(seq->type==SEQ_SPEED) {
+ if (seq->type==SEQ_SPEED) {
sequence_effect_speed_rebuild_map(scene, seq, 1);
}
}
- if(seq->type==SEQ_META) {
+ if (seq->type==SEQ_META) {
free_imbuf_seq(scene, &seq->seqbase, FALSE, keep_file_handles);
}
- if(seq->type==SEQ_SCENE) {
+ if (seq->type==SEQ_SCENE) {
/* FIXME: recurs downwards,
but do recurs protection somehow! */
}
@@ -2915,36 +2939,36 @@ static int update_changed_seq_recurs(Scene *scene, Sequence *seq, Sequence *chan
/* recurs downwards to see if this seq depends on the changed seq */
- if(seq == NULL)
+ if (seq == NULL)
return 0;
- if(seq == changed_seq)
+ if (seq == changed_seq)
free_imbuf = 1;
- for(subseq=seq->seqbase.first; subseq; subseq=subseq->next)
- if(update_changed_seq_recurs(scene, subseq, changed_seq, len_change, ibuf_change))
+ for (subseq=seq->seqbase.first; subseq; subseq=subseq->next)
+ if (update_changed_seq_recurs(scene, subseq, changed_seq, len_change, ibuf_change))
free_imbuf = TRUE;
- if(seq->seq1)
- if(update_changed_seq_recurs(scene, seq->seq1, changed_seq, len_change, ibuf_change))
+ if (seq->seq1)
+ if (update_changed_seq_recurs(scene, seq->seq1, changed_seq, len_change, ibuf_change))
free_imbuf = TRUE;
- if(seq->seq2 && (seq->seq2 != seq->seq1))
- if(update_changed_seq_recurs(scene, seq->seq2, changed_seq, len_change, ibuf_change))
+ if (seq->seq2 && (seq->seq2 != seq->seq1))
+ if (update_changed_seq_recurs(scene, seq->seq2, changed_seq, len_change, ibuf_change))
free_imbuf = TRUE;
- if(seq->seq3 && (seq->seq3 != seq->seq1) && (seq->seq3 != seq->seq2))
- if(update_changed_seq_recurs(scene, seq->seq3, changed_seq, len_change, ibuf_change))
+ if (seq->seq3 && (seq->seq3 != seq->seq1) && (seq->seq3 != seq->seq2))
+ if (update_changed_seq_recurs(scene, seq->seq3, changed_seq, len_change, ibuf_change))
free_imbuf = TRUE;
- if(free_imbuf) {
- if(ibuf_change) {
- if(seq->type == SEQ_MOVIE)
+ if (free_imbuf) {
+ if (ibuf_change) {
+ if (seq->type == SEQ_MOVIE)
free_anim_seq(seq);
- if(seq->type == SEQ_SPEED) {
+ if (seq->type == SEQ_SPEED) {
sequence_effect_speed_rebuild_map(scene, seq, 1);
}
}
- if(len_change)
+ if (len_change)
calc_sequence(scene, seq);
}
@@ -2982,7 +3006,8 @@ int seq_tx_get_final_left(Sequence *seq, int metaclip)
if (metaclip && seq->tmp) {
/* return the range clipped by the parents range */
return MAX2( seq_tx_get_final_left(seq, 0), seq_tx_get_final_left((Sequence *)seq->tmp, 1) );
- } else {
+ }
+ else {
return (seq->start - seq->startstill) + seq->startofs;
}
@@ -2992,7 +3017,8 @@ int seq_tx_get_final_right(Sequence *seq, int metaclip)
if (metaclip && seq->tmp) {
/* return the range clipped by the parents range */
return MIN2( seq_tx_get_final_right(seq, 0), seq_tx_get_final_right((Sequence *)seq->tmp, 1) );
- } else {
+ }
+ else {
return ((seq->start+seq->len) + seq->endstill) - seq->endofs;
}
}
@@ -3002,7 +3028,8 @@ void seq_tx_set_final_left(Sequence *seq, int val)
if (val < (seq)->start) {
seq->startstill = abs(val - (seq)->start);
seq->startofs = 0;
- } else {
+ }
+ else {
seq->startofs = abs(val - (seq)->start);
seq->startstill = 0;
}
@@ -3013,7 +3040,8 @@ void seq_tx_set_final_right(Sequence *seq, int val)
if (val > (seq)->start + (seq)->len) {
seq->endstill = abs(val - (seq->start + (seq)->len));
seq->endofs = 0;
- } else {
+ }
+ else {
seq->endofs = abs(val - ((seq)->start + (seq)->len));
seq->endstill = 0;
}
@@ -3036,29 +3064,29 @@ int seqbase_isolated_sel_check(ListBase *seqbase)
/* is there more than 1 select */
int ok= FALSE;
- for(seq= seqbase->first; seq; seq= seq->next) {
- if(seq->flag & SELECT) {
+ for (seq= seqbase->first; seq; seq= seq->next) {
+ if (seq->flag & SELECT) {
ok= TRUE;
break;
}
}
- if(ok == FALSE)
+ if (ok == FALSE)
return FALSE;
/* test relationships */
- for(seq= seqbase->first; seq; seq= seq->next) {
- if((seq->type & SEQ_EFFECT)==0)
+ for (seq= seqbase->first; seq; seq= seq->next) {
+ if ((seq->type & SEQ_EFFECT)==0)
continue;
- if(seq->flag & SELECT) {
- if( (seq->seq1 && (seq->seq1->flag & SELECT)==0) ||
+ if (seq->flag & SELECT) {
+ if ( (seq->seq1 && (seq->seq1->flag & SELECT)==0) ||
(seq->seq2 && (seq->seq2->flag & SELECT)==0) ||
(seq->seq3 && (seq->seq3->flag & SELECT)==0) )
return FALSE;
}
else {
- if( (seq->seq1 && (seq->seq1->flag & SELECT)) ||
+ if ( (seq->seq1 && (seq->seq1->flag & SELECT)) ||
(seq->seq2 && (seq->seq2->flag & SELECT)) ||
(seq->seq3 && (seq->seq3->flag & SELECT)) )
return FALSE;
@@ -3072,7 +3100,7 @@ int seqbase_isolated_sel_check(ListBase *seqbase)
* Cant use the SEQ_LEFTSEL and SEQ_LEFTSEL directly because the strip may be in a metastrip */
void seq_tx_handle_xlimits(Sequence *seq, int leftflag, int rightflag)
{
- if(leftflag) {
+ if (leftflag) {
if (seq_tx_get_final_left(seq, 0) >= seq_tx_get_final_right(seq, 0)) {
seq_tx_set_final_left(seq, seq_tx_get_final_right(seq, 0)-1);
}
@@ -3094,7 +3122,7 @@ void seq_tx_handle_xlimits(Sequence *seq, int leftflag, int rightflag)
}
}
- if(rightflag) {
+ if (rightflag) {
if (seq_tx_get_final_right(seq, 0) <= seq_tx_get_final_left(seq, 0)) {
seq_tx_set_final_right(seq, seq_tx_get_final_left(seq, 0)+1);
}
@@ -3147,8 +3175,8 @@ int seq_test_overlap(ListBase * seqbasep, Sequence *test)
Sequence *seq;
seq= seqbasep->first;
- while(seq) {
- if(seq_overlap(test, seq))
+ while (seq) {
+ if (seq_overlap(test, seq))
return 1;
seq= seq->next;
@@ -3162,9 +3190,9 @@ void seq_translate(Scene *evil_scene, Sequence *seq, int delta)
seq_offset_animdata(evil_scene, seq, delta);
seq->start += delta;
- if(seq->type==SEQ_META) {
+ if (seq->type==SEQ_META) {
Sequence *seq_child;
- for(seq_child= seq->seqbase.first; seq_child; seq_child= seq_child->next) {
+ for (seq_child= seq->seqbase.first; seq_child; seq_child= seq_child->next) {
seq_translate(evil_scene, seq_child, delta);
}
}
@@ -3174,17 +3202,17 @@ void seq_translate(Scene *evil_scene, Sequence *seq, int delta)
void seq_sound_init(Scene *scene, Sequence *seq)
{
- if(seq->type==SEQ_META) {
+ if (seq->type==SEQ_META) {
Sequence *seq_child;
- for(seq_child= seq->seqbase.first; seq_child; seq_child= seq_child->next) {
+ for (seq_child= seq->seqbase.first; seq_child; seq_child= seq_child->next) {
seq_sound_init(scene, seq_child);
}
}
else {
- if(seq->sound) {
+ if (seq->sound) {
seq->scene_sound = sound_add_scene_sound_defaults(scene, seq);
}
- if(seq->scene) {
+ if (seq->scene) {
sound_scene_add_scene_sound_defaults(scene, seq);
}
}
@@ -3196,10 +3224,10 @@ Sequence *seq_foreground_frame_get(Scene *scene, int frame)
Sequence *seq, *best_seq=NULL;
int best_machine = -1;
- if(!ed) return NULL;
+ if (!ed) return NULL;
for (seq=ed->seqbasep->first; seq; seq= seq->next) {
- if(seq->flag & SEQ_MUTE || seq->startdisp > frame || seq->enddisp <= frame)
+ if (seq->flag & SEQ_MUTE || seq->startdisp > frame || seq->enddisp <= frame)
continue;
/* only use elements you can see - not */
if (ELEM5(seq->type, SEQ_IMAGE, SEQ_META, SEQ_SCENE, SEQ_MOVIE, SEQ_COLOR)) {
@@ -3218,8 +3246,8 @@ int shuffle_seq(ListBase * seqbasep, Sequence *test, Scene *evil_scene)
int orig_machine= test->machine;
test->machine++;
calc_sequence(evil_scene, test);
- while( seq_test_overlap(seqbasep, test) ) {
- if(test->machine >= MAXSEQ) {
+ while ( seq_test_overlap(seqbasep, test) ) {
+ if (test->machine >= MAXSEQ) {
break;
}
test->machine++;
@@ -3227,14 +3255,14 @@ int shuffle_seq(ListBase * seqbasep, Sequence *test, Scene *evil_scene)
}
- if(test->machine >= MAXSEQ) {
+ if (test->machine >= MAXSEQ) {
/* Blender 2.4x would remove the strip.
* nicer to move it to the end */
Sequence *seq;
int new_frame= test->enddisp;
- for(seq= seqbasep->first; seq; seq= seq->next) {
+ for (seq= seqbasep->first; seq; seq= seq->next) {
if (seq->machine == orig_machine)
new_frame = MAX2(new_frame, seq->enddisp);
}
@@ -3245,7 +3273,8 @@ int shuffle_seq(ListBase * seqbasep, Sequence *test, Scene *evil_scene)
calc_sequence(evil_scene, test);
return 0;
- } else {
+ }
+ else {
return 1;
}
}
@@ -3255,11 +3284,11 @@ static int shuffle_seq_time_offset_test(ListBase * seqbasep, char dir)
int offset= 0;
Sequence *seq, *seq_other;
- for(seq= seqbasep->first; seq; seq= seq->next) {
- if(seq->tmp) {
- for(seq_other= seqbasep->first; seq_other; seq_other= seq_other->next) {
- if(!seq_other->tmp && seq_overlap(seq, seq_other)) {
- if(dir=='L') {
+ for (seq= seqbasep->first; seq; seq= seq->next) {
+ if (seq->tmp) {
+ for (seq_other= seqbasep->first; seq_other; seq_other= seq_other->next) {
+ if (!seq_other->tmp && seq_overlap(seq, seq_other)) {
+ if (dir=='L') {
offset= MIN2(offset, seq_other->startdisp - seq->enddisp);
}
else {
@@ -3277,9 +3306,9 @@ static int shuffle_seq_time_offset(Scene* scene, ListBase * seqbasep, char dir)
int ofs= 0;
int tot_ofs= 0;
Sequence *seq;
- while( (ofs= shuffle_seq_time_offset_test(seqbasep, dir)) ) {
- for(seq= seqbasep->first; seq; seq= seq->next) {
- if(seq->tmp) {
+ while ( (ofs= shuffle_seq_time_offset_test(seqbasep, dir)) ) {
+ for (seq= seqbasep->first; seq; seq= seq->next) {
+ if (seq->tmp) {
/* seq_test_overlap only tests display values */
seq->startdisp += ofs;
seq->enddisp += ofs;
@@ -3289,8 +3318,8 @@ static int shuffle_seq_time_offset(Scene* scene, ListBase * seqbasep, char dir)
tot_ofs+= ofs;
}
- for(seq= seqbasep->first; seq; seq= seq->next) {
- if(seq->tmp)
+ for (seq= seqbasep->first; seq; seq= seq->next) {
+ if (seq->tmp)
calc_sequence_disp(scene, seq); /* corrects dummy startdisp/enddisp values */
}
@@ -3307,9 +3336,9 @@ int shuffle_seq_time(ListBase * seqbasep, Scene *evil_scene)
int offset_r = shuffle_seq_time_offset(evil_scene, seqbasep, 'R');
int offset = (-offset_l < offset_r) ? offset_l:offset_r;
- if(offset) {
- for(seq= seqbasep->first; seq; seq= seq->next) {
- if(seq->tmp) {
+ if (offset) {
+ for (seq= seqbasep->first; seq; seq= seq->next) {
+ if (seq->tmp) {
seq_translate(evil_scene, seq, offset);
seq->flag &= ~SEQ_OVERLAP;
}
@@ -3323,14 +3352,14 @@ void seq_update_sound_bounds_all(Scene *scene)
{
Editing *ed = scene->ed;
- if(ed) {
+ if (ed) {
Sequence *seq;
- for(seq = ed->seqbase.first; seq; seq = seq->next) {
- if(seq->type == SEQ_META) {
+ for (seq = ed->seqbase.first; seq; seq = seq->next) {
+ if (seq->type == SEQ_META) {
seq_update_sound_bounds_recursive(scene, seq);
}
- else if(ELEM(seq->type, SEQ_SOUND, SEQ_SCENE)) {
+ else if (ELEM(seq->type, SEQ_SOUND, SEQ_SCENE)) {
seq_update_sound_bounds(scene, seq);
}
}
@@ -3350,19 +3379,19 @@ static void seq_update_muting_recursive(ListBase *seqbasep, Sequence *metaseq, i
/* for sound we go over full meta tree to update muted state,
* since sound is played outside of evaluating the imbufs, */
- for(seq=seqbasep->first; seq; seq=seq->next) {
+ for (seq=seqbasep->first; seq; seq=seq->next) {
seqmute= (mute || (seq->flag & SEQ_MUTE));
- if(seq->type == SEQ_META) {
+ if (seq->type == SEQ_META) {
/* if this is the current meta sequence, unmute because
* all sequences above this were set to mute */
- if(seq == metaseq)
+ if (seq == metaseq)
seqmute= 0;
seq_update_muting_recursive(&seq->seqbase, metaseq, seqmute);
}
- else if(ELEM(seq->type, SEQ_SOUND, SEQ_SCENE)) {
- if(seq->scene_sound) {
+ else if (ELEM(seq->type, SEQ_SOUND, SEQ_SCENE)) {
+ if (seq->scene_sound) {
sound_mute_scene_sound(seq->scene_sound, seqmute);
}
}
@@ -3371,11 +3400,11 @@ static void seq_update_muting_recursive(ListBase *seqbasep, Sequence *metaseq, i
void seq_update_muting(Editing *ed)
{
- if(ed) {
+ if (ed) {
/* mute all sounds up to current metastack list */
MetaStack *ms= ed->metastack.last;
- if(ms)
+ if (ms)
seq_update_muting_recursive(&ed->seqbase, ms->parseq, 1);
else
seq_update_muting_recursive(&ed->seqbase, NULL, 0);
@@ -3386,12 +3415,12 @@ static void seq_update_sound_recursive(Scene *scene, ListBase *seqbasep, bSound
{
Sequence *seq;
- for(seq=seqbasep->first; seq; seq=seq->next) {
- if(seq->type == SEQ_META) {
+ for (seq=seqbasep->first; seq; seq=seq->next) {
+ if (seq->type == SEQ_META) {
seq_update_sound_recursive(scene, &seq->seqbase, sound);
}
- else if(seq->type == SEQ_SOUND) {
- if(seq->scene_sound && sound == seq->sound) {
+ else if (seq->type == SEQ_SOUND) {
+ if (seq->scene_sound && sound == seq->sound) {
sound_update_scene_sound(seq->scene_sound, sound);
}
}
@@ -3400,7 +3429,7 @@ static void seq_update_sound_recursive(Scene *scene, ListBase *seqbasep, bSound
void seq_update_sound(struct Scene *scene, struct bSound *sound)
{
- if(scene->ed) {
+ if (scene->ed) {
seq_update_sound_recursive(scene, &scene->ed->seqbase, sound);
}
}
@@ -3411,11 +3440,11 @@ ListBase *seq_seqbase(ListBase *seqbase, Sequence *seq)
Sequence *iseq;
ListBase *lb= NULL;
- for(iseq= seqbase->first; iseq; iseq= iseq->next) {
- if(seq==iseq) {
+ for (iseq= seqbase->first; iseq; iseq= iseq->next) {
+ if (seq==iseq) {
return seqbase;
}
- else if(iseq->seqbase.first && (lb= seq_seqbase(&iseq->seqbase, seq))) {
+ else if (iseq->seqbase.first && (lb= seq_seqbase(&iseq->seqbase, seq))) {
return lb;
}
}
@@ -3427,12 +3456,13 @@ Sequence *seq_metastrip(ListBase * seqbase, Sequence * meta, Sequence *seq)
{
Sequence * iseq;
- for(iseq = seqbase->first; iseq; iseq = iseq->next) {
+ for (iseq = seqbase->first; iseq; iseq = iseq->next) {
Sequence * rval;
if (seq == iseq) {
return meta;
- } else if(iseq->seqbase.first &&
+ }
+ else if (iseq->seqbase.first &&
(rval = seq_metastrip(&iseq->seqbase, iseq, seq))) {
return rval;
}
@@ -3445,26 +3475,26 @@ int seq_swap(Sequence *seq_a, Sequence *seq_b, const char **error_str)
{
char name[sizeof(seq_a->name)];
- if(seq_a->len != seq_b->len) {
+ if (seq_a->len != seq_b->len) {
*error_str= "Strips must be the same length";
return 0;
}
/* type checking, could be more advanced but disalow sound vs non-sound copy */
- if(seq_a->type != seq_b->type) {
- if(seq_a->type == SEQ_SOUND || seq_b->type == SEQ_SOUND) {
+ if (seq_a->type != seq_b->type) {
+ if (seq_a->type == SEQ_SOUND || seq_b->type == SEQ_SOUND) {
*error_str= "Strips were not compatible";
return 0;
}
/* disallow effects to swap with non-effects strips */
- if((seq_a->type & SEQ_EFFECT) != (seq_b->type & SEQ_EFFECT)) {
+ if ((seq_a->type & SEQ_EFFECT) != (seq_b->type & SEQ_EFFECT)) {
*error_str= "Strips were not compatible";
return 0;
}
- if((seq_a->type & SEQ_EFFECT) && (seq_b->type & SEQ_EFFECT)) {
- if(get_sequence_effect_num_inputs(seq_a->type) != get_sequence_effect_num_inputs(seq_b->type)) {
+ if ((seq_a->type & SEQ_EFFECT) && (seq_b->type & SEQ_EFFECT)) {
+ if (get_sequence_effect_num_inputs(seq_a->type) != get_sequence_effect_num_inputs(seq_b->type)) {
*error_str= "Strips must have the same number of inputs";
return 0;
}
@@ -3503,13 +3533,13 @@ void seq_offset_animdata(Scene *scene, Sequence *seq, int ofs)
char str[SEQ_NAME_MAXSTR+3];
FCurve *fcu;
- if(scene->adt==NULL || ofs==0 || scene->adt->action==NULL)
+ if (scene->adt==NULL || ofs==0 || scene->adt->action==NULL)
return;
BLI_snprintf(str, sizeof(str), "[\"%s\"]", seq->name+2);
for (fcu= scene->adt->action->curves.first; fcu; fcu= fcu->next) {
- if(strstr(fcu->rna_path, "sequence_editor.sequences_all[") && strstr(fcu->rna_path, str)) {
+ if (strstr(fcu->rna_path, "sequence_editor.sequences_all[") && strstr(fcu->rna_path, str)) {
unsigned int i;
for (i = 0; i < fcu->totvert; i++) {
BezTriple *bezt= &fcu->bezt[i];
@@ -3529,7 +3559,7 @@ void seq_dupe_animdata(Scene *scene, const char *name_src, const char *name_dst)
FCurve *fcu_cpy;
ListBase lb= {NULL, NULL};
- if(scene->adt==NULL || scene->adt->action==NULL)
+ if (scene->adt==NULL || scene->adt->action==NULL)
return;
BLI_snprintf(str_from, sizeof(str_from), "[\"%s\"]", name_src);
@@ -3537,7 +3567,7 @@ void seq_dupe_animdata(Scene *scene, const char *name_src, const char *name_dst)
fcu_last= scene->adt->action->curves.last;
for (fcu= scene->adt->action->curves.first; fcu && fcu->prev != fcu_last; fcu= fcu->next) {
- if(strstr(fcu->rna_path, "sequence_editor.sequences_all[") && strstr(fcu->rna_path, str_from)) {
+ if (strstr(fcu->rna_path, "sequence_editor.sequences_all[") && strstr(fcu->rna_path, str_from)) {
fcu_cpy= copy_fcurve(fcu);
BLI_addtail(&lb, fcu_cpy);
}
@@ -3556,7 +3586,7 @@ static void seq_free_animdata(Scene *scene, Sequence *seq)
char str[SEQ_NAME_MAXSTR+3];
FCurve *fcu;
- if(scene->adt==NULL || scene->adt->action==NULL)
+ if (scene->adt==NULL || scene->adt->action==NULL)
return;
BLI_snprintf(str, sizeof(str), "[\"%s\"]", seq->name+2);
@@ -3564,14 +3594,15 @@ static void seq_free_animdata(Scene *scene, Sequence *seq)
fcu= scene->adt->action->curves.first;
while (fcu) {
- if(strstr(fcu->rna_path, "sequence_editor.sequences_all[") && strstr(fcu->rna_path, str)) {
+ if (strstr(fcu->rna_path, "sequence_editor.sequences_all[") && strstr(fcu->rna_path, str)) {
FCurve *next_fcu = fcu->next;
BLI_remlink(&scene->adt->action->curves, fcu);
free_fcurve(fcu);
fcu = next_fcu;
- } else {
+ }
+ else {
fcu = fcu->next;
}
}
@@ -3586,7 +3617,7 @@ Sequence *get_seq_by_name(ListBase *seqbase, const char *name, int recursive)
for (iseq=seqbase->first; iseq; iseq=iseq->next) {
if (strcmp(name, iseq->name+2) == 0)
return iseq;
- else if(recursive && (iseq->seqbase.first) && (rseq=get_seq_by_name(&iseq->seqbase, name, 1))) {
+ else if (recursive && (iseq->seqbase.first) && (rseq=get_seq_by_name(&iseq->seqbase, name, 1))) {
return rseq;
}
}
@@ -3598,14 +3629,14 @@ Sequence *get_seq_by_name(ListBase *seqbase, const char *name, int recursive)
Sequence *seq_active_get(Scene *scene)
{
Editing *ed= seq_give_editing(scene, FALSE);
- if(ed==NULL) return NULL;
+ if (ed==NULL) return NULL;
return ed->act_seq;
}
void seq_active_set(Scene *scene, Sequence *seq)
{
Editing *ed= seq_give_editing(scene, FALSE);
- if(ed==NULL) return;
+ if (ed==NULL) return;
ed->act_seq= seq;
}
@@ -3616,7 +3647,7 @@ int seq_active_pair_get(Scene *scene, Sequence **seq_act, Sequence **seq_other)
*seq_act= seq_active_get(scene);
- if(*seq_act == NULL) {
+ if (*seq_act == NULL) {
return 0;
}
else {
@@ -3624,9 +3655,9 @@ int seq_active_pair_get(Scene *scene, Sequence **seq_act, Sequence **seq_other)
*seq_other= NULL;
- for(seq= ed->seqbasep->first; seq; seq= seq->next) {
- if(seq->flag & SELECT && (seq != (*seq_act))) {
- if(*seq_other) {
+ for (seq= ed->seqbasep->first; seq; seq= seq->next) {
+ if (seq->flag & SELECT && (seq != (*seq_act))) {
+ if (*seq_other) {
return 0;
}
else {
@@ -3643,21 +3674,21 @@ int seq_active_pair_get(Scene *scene, Sequence **seq_act, Sequence **seq_other)
void seq_load_apply(Scene *scene, Sequence *seq, SeqLoadInfo *seq_load)
{
- if(seq) {
+ if (seq) {
BLI_strncpy(seq->name+2, seq_load->name, sizeof(seq->name)-2);
seqbase_unique_name_recursive(&scene->ed->seqbase, seq);
- if(seq_load->flag & SEQ_LOAD_FRAME_ADVANCE) {
+ if (seq_load->flag & SEQ_LOAD_FRAME_ADVANCE) {
seq_load->start_frame += (seq->enddisp - seq->startdisp);
}
- if(seq_load->flag & SEQ_LOAD_REPLACE_SEL) {
+ if (seq_load->flag & SEQ_LOAD_REPLACE_SEL) {
seq_load->flag |= SELECT;
seq_active_set(scene, seq);
}
- if(seq_load->flag & SEQ_LOAD_SOUND_CACHE) {
- if(seq->sound)
+ if (seq_load->flag & SEQ_LOAD_SOUND_CACHE) {
+ if (seq->sound)
sound_cache(seq->sound);
}
@@ -3800,7 +3831,7 @@ Sequence *sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo
an = openanim(path, IB_rect, 0);
- if(an==NULL)
+ if (an==NULL)
return NULL;
seq = alloc_sequence(seqbasep, seq_load->start_frame, seq_load->channel);
@@ -3825,7 +3856,7 @@ Sequence *sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo
calc_sequence_disp(scene, seq);
- if(seq_load->flag & SEQ_LOAD_MOVIE_SOUND) {
+ if (seq_load->flag & SEQ_LOAD_MOVIE_SOUND) {
int start_frame_back= seq_load->start_frame;
seq_load->channel++;
@@ -3835,7 +3866,7 @@ Sequence *sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo
seq_load->channel--;
}
- if(seq_load->name[0] == '\0')
+ if (seq_load->name[0] == '\0')
BLI_strncpy(seq_load->name, se->name, sizeof(seq_load->name));
/* can be NULL */
@@ -3873,54 +3904,60 @@ static Sequence *seq_dupli(struct Scene *scene, struct Scene *scene_to, Sequence
= MEM_dupallocN(seq->strip->color_balance);
}
- if(seq->type==SEQ_META) {
+ if (seq->type==SEQ_META) {
seqn->strip->stripdata = NULL;
seqn->seqbase.first= seqn->seqbase.last= NULL;
/* WATCH OUT!!! - This metastrip is not recursively duplicated here - do this after!!! */
/* - seq_dupli_recursive(&seq->seqbase,&seqn->seqbase);*/
- } else if(seq->type == SEQ_SCENE) {
+ }
+ else if (seq->type == SEQ_SCENE) {
seqn->strip->stripdata = NULL;
- if(seq->scene_sound)
+ if (seq->scene_sound)
seqn->scene_sound = sound_scene_add_scene_sound_defaults(sce_audio, seqn);
- } else if(seq->type == SEQ_MOVIE) {
+ }
+ else if (seq->type == SEQ_MOVIE) {
seqn->strip->stripdata =
MEM_dupallocN(seq->strip->stripdata);
seqn->anim= NULL;
- } else if(seq->type == SEQ_SOUND) {
+ }
+ else if (seq->type == SEQ_SOUND) {
seqn->strip->stripdata =
MEM_dupallocN(seq->strip->stripdata);
- if(seq->scene_sound)
+ if (seq->scene_sound)
seqn->scene_sound = sound_add_scene_sound_defaults(sce_audio, seqn);
seqn->sound->id.us++;
- } else if(seq->type == SEQ_IMAGE) {
+ }
+ else if (seq->type == SEQ_IMAGE) {
seqn->strip->stripdata =
MEM_dupallocN(seq->strip->stripdata);
- } else if(seq->type >= SEQ_EFFECT) {
- if(seq->seq1 && seq->seq1->tmp) seqn->seq1= seq->seq1->tmp;
- if(seq->seq2 && seq->seq2->tmp) seqn->seq2= seq->seq2->tmp;
- if(seq->seq3 && seq->seq3->tmp) seqn->seq3= seq->seq3->tmp;
+ }
+ else if (seq->type >= SEQ_EFFECT) {
+ if (seq->seq1 && seq->seq1->tmp) seqn->seq1= seq->seq1->tmp;
+ if (seq->seq2 && seq->seq2->tmp) seqn->seq2= seq->seq2->tmp;
+ if (seq->seq3 && seq->seq3->tmp) seqn->seq3= seq->seq3->tmp;
if (seq->type & SEQ_EFFECT) {
struct SeqEffectHandle sh;
sh = get_sequence_effect(seq);
- if(sh.copy)
+ if (sh.copy)
sh.copy(seq, seqn);
}
seqn->strip->stripdata = NULL;
- } else {
+ }
+ else {
fprintf(stderr, "Aiiiiekkk! sequence type not "
"handled in duplicate!\nExpect a crash"
" now...\n");
}
- if(dupe_flag & SEQ_DUPE_UNIQUE_NAME)
+ if (dupe_flag & SEQ_DUPE_UNIQUE_NAME)
seqbase_unique_name_recursive(&scene->ed->seqbase, seqn);
- if(dupe_flag & SEQ_DUPE_ANIM)
+ if (dupe_flag & SEQ_DUPE_ANIM)
seq_dupe_animdata(scene, seq->name+2, seqn->name+2);
return seqn;
@@ -3931,7 +3968,7 @@ Sequence * seq_dupli_recursive(struct Scene *scene, struct Scene *scene_to, Sequ
Sequence * seqn = seq_dupli(scene, scene_to, seq, dupe_flag);
if (seq->type == SEQ_META) {
Sequence *s;
- for(s= seq->seqbase.first; s; s = s->next) {
+ for (s= seq->seqbase.first; s; s = s->next) {
Sequence *n = seq_dupli_recursive(scene, scene_to, s, dupe_flag);
if (n) {
BLI_addtail(&seqn->seqbase, n);
@@ -3947,21 +3984,21 @@ void seqbase_dupli_recursive(Scene *scene, Scene *scene_to, ListBase *nseqbase,
Sequence *seqn = NULL;
Sequence *last_seq = seq_active_get(scene);
- for(seq= seqbase->first; seq; seq= seq->next) {
+ for (seq= seqbase->first; seq; seq= seq->next) {
seq->tmp= NULL;
- if((seq->flag & SELECT) || (dupe_flag & SEQ_DUPE_ALL)) {
+ if ((seq->flag & SELECT) || (dupe_flag & SEQ_DUPE_ALL)) {
seqn = seq_dupli(scene, scene_to, seq, dupe_flag);
if (seqn) { /*should never fail */
- if(dupe_flag & SEQ_DUPE_CONTEXT) {
+ if (dupe_flag & SEQ_DUPE_CONTEXT) {
seq->flag &= ~SEQ_ALLSEL;
seqn->flag &= ~(SEQ_LEFTSEL+SEQ_RIGHTSEL+SEQ_LOCK);
}
BLI_addtail(nseqbase, seqn);
- if(seq->type==SEQ_META)
+ if (seq->type==SEQ_META)
seqbase_dupli_recursive(scene, scene_to, &seqn->seqbase, &seq->seqbase, dupe_flag);
- if(dupe_flag & SEQ_DUPE_CONTEXT) {
+ if (dupe_flag & SEQ_DUPE_CONTEXT) {
if (seq == last_seq) {
seq_active_set(scene, seqn);
}
diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c
index 664a1d0d7f9..6513399c962 100644
--- a/source/blender/blenkernel/intern/shrinkwrap.c
+++ b/source/blender/blenkernel/intern/shrinkwrap.c
@@ -75,7 +75,7 @@
_t1 = ( double ) _tstart.tv_sec + ( double ) _tstart.tv_usec/ ( 1000*1000 ); \
_t2 = ( double ) _tend.tv_sec + ( double ) _tend.tv_usec/ ( 1000*1000 ); \
printf("%s: %fs (real) %fs (cpu)\n", #a, _t2-_t1, (float)(clock()-_clock_init)/CLOCKS_PER_SEC);\
- } while(0)
+ } while (0)
#else
@@ -92,7 +92,7 @@ DerivedMesh *object_get_derived_final(Object *ob)
Mesh *me= ob->data;
BMEditMesh *em = me->edit_btmesh;
- if(em) {
+ if (em) {
DerivedMesh *dm = em->derivedFinal;
return dm;
}
@@ -146,7 +146,7 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc)
BENCH(bvhtree_from_mesh_verts(&treeData, calc->target, 0.0, 2, 6));
- if(treeData.tree == NULL)
+ if (treeData.tree == NULL)
{
OUT_OF_MEMORY();
return;
@@ -158,16 +158,16 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc)
#ifndef __APPLE__
#pragma omp parallel for default(none) private(i) firstprivate(nearest) shared(treeData,calc) schedule(static)
#endif
- for(i = 0; i<calc->numVerts; ++i)
+ for (i = 0; i<calc->numVerts; ++i)
{
float *co = calc->vertexCos[i];
float tmp_co[3];
float weight = defvert_array_find_weight_safe(calc->dvert, i, calc->vgroup);
- if(weight == 0.0f) continue;
+ if (weight == 0.0f) continue;
//Convert the vertex to tree coordinates
- if(calc->vert) {
+ if (calc->vert) {
copy_v3_v3(tmp_co, calc->vert[i].co);
}
else {
@@ -180,7 +180,7 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc)
//If we already had an hit before.. we assume this vertex is going to have a close hit to that other vertex
//so we can initiate the "nearest.dist" with the expected value to that last hit.
//This will lead in prunning of the search tree.
- if(nearest.index != -1)
+ if (nearest.index != -1)
nearest.dist = len_squared_v3v3(tmp_co, nearest.co);
else
nearest.dist = FLT_MAX;
@@ -189,11 +189,11 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc)
//Found the nearest vertex
- if(nearest.index != -1)
+ if (nearest.index != -1)
{
//Adjusting the vertex weight, so that after interpolating it keeps a certain distance from the nearest position
float dist = sasqrt(nearest.dist);
- if(dist > FLT_EPSILON) weight *= (dist - calc->keepDist)/dist;
+ if (dist > FLT_EPSILON) weight *= (dist - calc->keepDist)/dist;
//Convert the coordinates back to mesh coordinates
copy_v3_v3(tmp_co, nearest.co);
@@ -224,7 +224,7 @@ int normal_projection_project_vertex(char options, const float *vert, const floa
memcpy( &hit_tmp, hit, sizeof(hit_tmp) );
//Apply space transform (TODO readjust dist)
- if(transf)
+ if (transf)
{
copy_v3_v3( tmp_co, vert );
space_transform_apply( transf, tmp_co );
@@ -245,23 +245,23 @@ int normal_projection_project_vertex(char options, const float *vert, const floa
BLI_bvhtree_ray_cast(tree, co, no, 0.0f, &hit_tmp, callback, userdata);
- if(hit_tmp.index != -1) {
+ if (hit_tmp.index != -1) {
/* invert the normal first so face culling works on rotated objects */
- if(transf) {
+ if (transf) {
space_transform_invert_normal(transf, hit_tmp.no);
}
if (options & (MOD_SHRINKWRAP_CULL_TARGET_FRONTFACE|MOD_SHRINKWRAP_CULL_TARGET_BACKFACE)) {
/* apply backface */
const float dot= dot_v3v3(dir, hit_tmp.no);
- if( ((options & MOD_SHRINKWRAP_CULL_TARGET_FRONTFACE) && dot <= 0.0f) ||
+ if ( ((options & MOD_SHRINKWRAP_CULL_TARGET_FRONTFACE) && dot <= 0.0f) ||
((options & MOD_SHRINKWRAP_CULL_TARGET_BACKFACE) && dot >= 0.0f)
) {
return FALSE; /* Ignore hit */
}
}
- if(transf) {
+ if (transf) {
/* Inverting space transform (TODO make coeherent with the initial dist readjust) */
space_transform_invert(transf, hit_tmp.co);
hit_tmp.dist = len_v3v3((float *)vert, hit_tmp.co);
@@ -293,62 +293,63 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
//If the user doesn't allows to project in any direction of projection axis
//then theres nothing todo.
- if((use_normal & (MOD_SHRINKWRAP_PROJECT_ALLOW_POS_DIR | MOD_SHRINKWRAP_PROJECT_ALLOW_NEG_DIR)) == 0)
+ if ((use_normal & (MOD_SHRINKWRAP_PROJECT_ALLOW_POS_DIR | MOD_SHRINKWRAP_PROJECT_ALLOW_NEG_DIR)) == 0)
return;
//Prepare data to retrieve the direction in which we should project each vertex
- if(calc->smd->projAxis == MOD_SHRINKWRAP_PROJECT_OVER_NORMAL)
+ if (calc->smd->projAxis == MOD_SHRINKWRAP_PROJECT_OVER_NORMAL)
{
- if(calc->vert == NULL) return;
+ if (calc->vert == NULL) return;
}
else {
//The code supports any axis that is a combination of X,Y,Z
//although currently UI only allows to set the 3 different axis
- if(calc->smd->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_X_AXIS) proj_axis[0] = 1.0f;
- if(calc->smd->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_Y_AXIS) proj_axis[1] = 1.0f;
- if(calc->smd->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_Z_AXIS) proj_axis[2] = 1.0f;
+ if (calc->smd->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_X_AXIS) proj_axis[0] = 1.0f;
+ if (calc->smd->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_Y_AXIS) proj_axis[1] = 1.0f;
+ if (calc->smd->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_Z_AXIS) proj_axis[2] = 1.0f;
normalize_v3(proj_axis);
//Invalid projection direction
- if(dot_v3v3(proj_axis, proj_axis) < FLT_EPSILON)
+ if (dot_v3v3(proj_axis, proj_axis) < FLT_EPSILON)
return;
}
- if(calc->smd->auxTarget)
+ if (calc->smd->auxTarget)
{
auxMesh = object_get_derived_final(calc->smd->auxTarget);
- if(!auxMesh)
+ if (!auxMesh)
return;
space_transform_setup( &local2aux, calc->ob, calc->smd->auxTarget);
}
//After sucessufuly build the trees, start projection vertexs
- if( bvhtree_from_mesh_faces(&treeData, calc->target, 0.0, 4, 6)
+ if ( bvhtree_from_mesh_faces(&treeData, calc->target, 0.0, 4, 6)
&& (auxMesh == NULL || bvhtree_from_mesh_faces(&auxData, auxMesh, 0.0, 4, 6)))
{
#ifndef __APPLE__
#pragma omp parallel for private(i,hit) schedule(static)
#endif
- for(i = 0; i<calc->numVerts; ++i)
+ for (i = 0; i<calc->numVerts; ++i)
{
float *co = calc->vertexCos[i];
float tmp_co[3], tmp_no[3];
float weight = defvert_array_find_weight_safe(calc->dvert, i, calc->vgroup);
- if(weight == 0.0f) continue;
+ if (weight == 0.0f) continue;
- if(calc->vert)
+ if (calc->vert)
{
/* calc->vert contains verts from derivedMesh */
/* this coordinated are deformed by vertexCos only for normal projection (to get correct normals) */
/* for other cases calc->varts contains undeformed coordinates and vertexCos should be used */
- if(calc->smd->projAxis == MOD_SHRINKWRAP_PROJECT_OVER_NORMAL) {
+ if (calc->smd->projAxis == MOD_SHRINKWRAP_PROJECT_OVER_NORMAL) {
copy_v3_v3(tmp_co, calc->vert[i].co);
normal_short_to_float_v3(tmp_no, calc->vert[i].no);
- } else {
+ }
+ else {
copy_v3_v3(tmp_co, co);
copy_v3_v3(tmp_no, proj_axis);
}
@@ -363,29 +364,29 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
hit.dist = 10000.0f; //TODO: we should use FLT_MAX here, but sweepsphere code isn't prepared for that
//Project over positive direction of axis
- if(use_normal & MOD_SHRINKWRAP_PROJECT_ALLOW_POS_DIR)
+ if (use_normal & MOD_SHRINKWRAP_PROJECT_ALLOW_POS_DIR)
{
- if(auxData.tree)
+ if (auxData.tree)
normal_projection_project_vertex(0, tmp_co, tmp_no, &local2aux, auxData.tree, &hit, auxData.raycast_callback, &auxData);
normal_projection_project_vertex(calc->smd->shrinkOpts, tmp_co, tmp_no, &calc->local2target, treeData.tree, &hit, treeData.raycast_callback, &treeData);
}
//Project over negative direction of axis
- if(use_normal & MOD_SHRINKWRAP_PROJECT_ALLOW_NEG_DIR && hit.index == -1)
+ if (use_normal & MOD_SHRINKWRAP_PROJECT_ALLOW_NEG_DIR && hit.index == -1)
{
float inv_no[3];
negate_v3_v3(inv_no, tmp_no);
- if(auxData.tree)
+ if (auxData.tree)
normal_projection_project_vertex(0, tmp_co, inv_no, &local2aux, auxData.tree, &hit, auxData.raycast_callback, &auxData);
normal_projection_project_vertex(calc->smd->shrinkOpts, tmp_co, inv_no, &calc->local2target, treeData.tree, &hit, treeData.raycast_callback, &treeData);
}
- if(hit.index != -1)
+ if (hit.index != -1)
{
madd_v3_v3v3fl(hit.co, hit.co, tmp_no, calc->keepDist);
interp_v3_v3v3(co, co, hit.co, weight);
@@ -413,7 +414,7 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
//Create a bvh-tree of the given target
BENCH(bvhtree_from_mesh_faces( &treeData, calc->target, 0.0, 2, 6));
- if(treeData.tree == NULL)
+ if (treeData.tree == NULL)
{
OUT_OF_MEMORY();
return;
@@ -428,15 +429,15 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
#ifndef __APPLE__
#pragma omp parallel for default(none) private(i) firstprivate(nearest) shared(calc,treeData) schedule(static)
#endif
- for(i = 0; i<calc->numVerts; ++i)
+ for (i = 0; i<calc->numVerts; ++i)
{
float *co = calc->vertexCos[i];
float tmp_co[3];
float weight = defvert_array_find_weight_safe(calc->dvert, i, calc->vgroup);
- if(weight == 0.0f) continue;
+ if (weight == 0.0f) continue;
//Convert the vertex to tree coordinates
- if(calc->vert) {
+ if (calc->vert) {
copy_v3_v3(tmp_co, calc->vert[i].co);
}
else {
@@ -449,7 +450,7 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
//If we already had an hit before.. we assume this vertex is going to have a close hit to that other vertex
//so we can initiate the "nearest.dist" with the expected value to that last hit.
//This will lead in prunning of the search tree.
- if(nearest.index != -1)
+ if (nearest.index != -1)
nearest.dist = len_squared_v3v3(tmp_co, nearest.co);
else
nearest.dist = FLT_MAX;
@@ -457,9 +458,9 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
BLI_bvhtree_find_nearest(treeData.tree, tmp_co, &nearest, treeData.nearest_callback, &treeData);
//Found the nearest vertex
- if(nearest.index != -1)
+ if (nearest.index != -1)
{
- if(calc->smd->shrinkOpts & MOD_SHRINKWRAP_KEEP_ABOVE_SURFACE)
+ if (calc->smd->shrinkOpts & MOD_SHRINKWRAP_KEEP_ABOVE_SURFACE)
{
//Make the vertex stay on the front side of the face
madd_v3_v3v3fl(tmp_co, nearest.co, nearest.no, calc->keepDist);
@@ -467,7 +468,7 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
else {
//Adjusting the vertex weight, so that after interpolating it keeps a certain distance from the nearest position
float dist = sasqrt( nearest.dist );
- if(dist > FLT_EPSILON)
+ if (dist > FLT_EPSILON)
interp_v3_v3v3(tmp_co, tmp_co, nearest.co, (dist - calc->keepDist)/dist); //linear interpolation
else
copy_v3_v3( tmp_co, nearest.co );
@@ -490,8 +491,8 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM
ShrinkwrapCalcData calc = NULL_ShrinkwrapCalcData;
//remove loop dependencies on derived meshs (TODO should this be done elsewhere?)
- if(smd->target == ob) smd->target = NULL;
- if(smd->auxTarget == ob) smd->auxTarget = NULL;
+ if (smd->target == ob) smd->target = NULL;
+ if (smd->auxTarget == ob) smd->auxTarget = NULL;
//Configure Shrinkwrap calc data
@@ -502,7 +503,7 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM
//DeformVertex
calc.vgroup = defgroup_name_index(calc.ob, calc.smd->vgroup_name);
- if(dm) {
+ if (dm) {
calc.dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT);
}
else if (calc.ob->type == OB_LATTICE) {
@@ -510,7 +511,7 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM
}
- if(smd->target)
+ if (smd->target)
{
calc.target = object_get_derived_final(smd->target);
@@ -527,14 +528,14 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM
calc.vgroup = defgroup_name_index(calc.ob, smd->vgroup_name);
- if(dm != NULL && smd->shrinkType == MOD_SHRINKWRAP_PROJECT)
+ if (dm != NULL && smd->shrinkType == MOD_SHRINKWRAP_PROJECT)
{
//Setup arrays to get vertexs positions, normals and deform weights
calc.vert = dm->getVertDataArray(dm, CD_MVERT);
calc.dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT);
//Using vertexs positions/normals as if a subsurface was applied
- if(smd->subsurfLevels)
+ if (smd->subsurfLevels)
{
SubsurfModifierData ssmd= {{NULL}};
ssmd.subdivType = ME_CC_SUBSURF; //catmull clark
@@ -542,10 +543,10 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM
ss_mesh = subsurf_make_derived_from_derived(dm, &ssmd, FALSE, NULL, 0, 0, (ob->mode & OB_MODE_EDIT));
- if(ss_mesh)
+ if (ss_mesh)
{
calc.vert = ss_mesh->getVertDataArray(ss_mesh, CD_MVERT);
- if(calc.vert)
+ if (calc.vert)
{
//TRICKY: this code assumes subsurface will have the transformed original vertices
//in their original order at the end of the vert array.
@@ -578,7 +579,7 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM
}
//free memory
- if(ss_mesh)
+ if (ss_mesh)
ss_mesh->release(ss_mesh);
}
diff --git a/source/blender/blenkernel/intern/sketch.c b/source/blender/blenkernel/intern/sketch.c
index 90d530cb239..71ea85de716 100644
--- a/source/blender/blenkernel/intern/sketch.c
+++ b/source/blender/blenkernel/intern/sketch.c
@@ -414,7 +414,7 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end)
float max_dist = 16; /* more than 4 pixels */
/* find the next marked point */
- while(marked[le] == 0)
+ while (marked[le] == 0)
{
le++;
}
@@ -424,7 +424,7 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end)
v1[0] = old_points[ls].p2d[1] - old_points[le].p2d[1];
- for( i = ls + 1; i < le; i++ )
+ for ( i = ls + 1; i < le; i++ )
{
float mul;
float dist;
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index ff5ed0d4348..96194ff5b09 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -159,7 +159,7 @@ void smokeModifier_do(SmokeModifierData *UNUSED(smd), Scene *UNUSED(scene), Obje
static int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, DerivedMesh *dm)
{
- if((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain && !smd->domain->fluid)
+ if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain && !smd->domain->fluid)
{
size_t i;
float min[3] = {FLT_MAX, FLT_MAX, FLT_MAX}, max[3] = {-FLT_MAX, -FLT_MAX, -FLT_MAX};
@@ -171,7 +171,7 @@ static int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene,
res = smd->domain->maxres;
// get BB of domain
- for(i = 0; i < dm->getNumVerts(dm); i++)
+ for (i = 0; i < dm->getNumVerts(dm); i++)
{
float tmp[3];
@@ -198,12 +198,12 @@ static int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene,
// printf("size: %f, %f, %f\n", size[0], size[1], size[2]);
// prevent crash when initializing a plane as domain
- if((size[0] < FLT_EPSILON) || (size[1] < FLT_EPSILON) || (size[2] < FLT_EPSILON))
+ if ((size[0] < FLT_EPSILON) || (size[1] < FLT_EPSILON) || (size[2] < FLT_EPSILON))
return 0;
- if(size[0] > size[1])
+ if (size[0] > size[1])
{
- if(size[0] > size[2])
+ if (size[0] > size[2])
{
scale = res / size[0];
smd->domain->dx = size[0] / res;
@@ -220,7 +220,7 @@ static int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene,
}
}
else {
- if(size[1] > size[2])
+ if (size[1] > size[2])
{
scale = res / size[1];
smd->domain->dx = size[1] / res;
@@ -246,7 +246,7 @@ static int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene,
smd->domain->fluid = smoke_init(smd->domain->res, smd->domain->p0);
smd->time = scene->r.cfra;
- if(smd->domain->flags & MOD_SMOKE_HIGHRES)
+ if (smd->domain->flags & MOD_SMOKE_HIGHRES)
{
smd->domain->wt = smoke_turbulence_init(smd->domain->res, smd->domain->amplify + 1, smd->domain->noise);
smd->domain->res_wt[0] = smd->domain->res[0] * (smd->domain->amplify + 1);
@@ -257,19 +257,19 @@ static int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene,
// printf("(smd->domain->flags & MOD_SMOKE_HIGHRES)\n");
}
- if(!smd->domain->shadow)
+ if (!smd->domain->shadow)
smd->domain->shadow = MEM_callocN(sizeof(float) * smd->domain->res[0] * smd->domain->res[1] * smd->domain->res[2], "SmokeDomainShadow");
smoke_initBlenderRNA(smd->domain->fluid, &(smd->domain->alpha), &(smd->domain->beta), &(smd->domain->time_scale), &(smd->domain->vorticity), &(smd->domain->border_collisions));
- if(smd->domain->wt)
+ if (smd->domain->wt)
{
smoke_initWaveletBlenderRNA(smd->domain->wt, &(smd->domain->strength));
// printf("smoke_initWaveletBlenderRNA\n");
}
return 1;
}
- else if((smd->type & MOD_SMOKE_TYPE_FLOW) && smd->flow)
+ else if ((smd->type & MOD_SMOKE_TYPE_FLOW) && smd->flow)
{
// handle flow object here
// XXX TODO
@@ -279,7 +279,7 @@ static int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene,
// update particle lifetime to be one frame
// smd->flow->psys->part->lifetime = scene->r.efra + 1;
/*
- if(!smd->flow->bvh)
+ if (!smd->flow->bvh)
{
// smd->flow->bvh = MEM_callocN(sizeof(BVHTreeFromMesh), "smoke_bvhfromfaces");
// bvhtree_from_mesh_faces(smd->flow->bvh, dm, 0.0, 2, 6);
@@ -292,15 +292,15 @@ static int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene,
return 1;
}
- else if((smd->type & MOD_SMOKE_TYPE_COLL))
+ else if ((smd->type & MOD_SMOKE_TYPE_COLL))
{
smd->time = scene->r.cfra;
// todo: delete this when loading colls work -dg
- if(!smd->coll)
+ if (!smd->coll)
smokeModifier_createType(smd);
- if(!smd->coll->points)
+ if (!smd->coll->points)
{
// init collision points
SmokeCollSettings *scs = smd->coll;
@@ -313,7 +313,7 @@ static int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene,
fill_scs_points(ob, dm, scs);
}
- if(!smd->coll->bvhtree)
+ if (!smd->coll->bvhtree)
{
smd->coll->bvhtree = NULL; // bvhtree_build_from_smoke ( ob->obmat, dm->getTessFaceArray(dm), dm->getNumTessFaces(dm), dm->getVertArray(dm), dm->getNumVerts(dm), 0.0 );
}
@@ -334,16 +334,16 @@ static void fill_scs_points(Object *ob, DerivedMesh *dm, SmokeCollSettings *scs)
int quads = 0, facecounter = 0;
// count quads
- for(i = 0; i < dm->getNumTessFaces(dm); i++)
+ for (i = 0; i < dm->getNumTessFaces(dm); i++)
{
- if(mface[i].v4)
+ if (mface[i].v4)
quads++;
}
calcTriangleDivs(ob, mvert, dm->getNumVerts(dm), mface, dm->getNumTessFaces(dm), dm->getNumTessFaces(dm) + quads, &tridivs, cell_len);
// count triangle divisions
- for(i = 0; i < dm->getNumTessFaces(dm) + quads; i++)
+ for (i = 0; i < dm->getNumTessFaces(dm) + quads; i++)
{
divs += (tridivs[3 * i] + 1) * (tridivs[3 * i + 1] + 1) * (tridivs[3 * i + 2] + 1);
}
@@ -352,7 +352,7 @@ static void fill_scs_points(Object *ob, DerivedMesh *dm, SmokeCollSettings *scs)
scs->points = MEM_callocN(sizeof(float) * (dm->getNumVerts(dm) + divs) * 3, "SmokeCollPoints");
- for(i = 0; i < dm->getNumVerts(dm); i++)
+ for (i = 0; i < dm->getNumVerts(dm); i++)
{
float tmpvec[3];
copy_v3_v3(tmpvec, mvert[i].co);
@@ -360,7 +360,7 @@ static void fill_scs_points(Object *ob, DerivedMesh *dm, SmokeCollSettings *scs)
copy_v3_v3(&scs->points[i * 3], tmpvec);
}
- for(i = 0, facecounter = 0; i < dm->getNumTessFaces(dm); i++)
+ for (i = 0, facecounter = 0; i < dm->getNumTessFaces(dm); i++)
{
int again = 0;
do
@@ -371,7 +371,7 @@ static void fill_scs_points(Object *ob, DerivedMesh *dm, SmokeCollSettings *scs)
//int divs3 = tridivs[3 * facecounter + 2];
float side1[3], side2[3], trinormorg[3], trinorm[3];
- if(again == 1 && mface[i].v4)
+ if (again == 1 && mface[i].v4)
{
sub_v3_v3v3(side1, mvert[ mface[i].v3 ].co, mvert[ mface[i].v1 ].co);
sub_v3_v3v3(side2, mvert[ mface[i].v4 ].co, mvert[ mface[i].v1 ].co);
@@ -386,23 +386,23 @@ static void fill_scs_points(Object *ob, DerivedMesh *dm, SmokeCollSettings *scs)
copy_v3_v3(trinorm, trinormorg);
mul_v3_fl(trinorm, 0.25 * cell_len);
- for(j = 0; j <= divs1; j++)
+ for (j = 0; j <= divs1; j++)
{
- for(k = 0; k <= divs2; k++)
+ for (k = 0; k <= divs2; k++)
{
float p1[3], p2[3], p3[3], p[3]={0,0,0};
const float uf = (float)(j + TRI_UVOFFSET) / (float)(divs1 + 0.0);
const float vf = (float)(k + TRI_UVOFFSET) / (float)(divs2 + 0.0);
float tmpvec[3];
- if(uf+vf > 1.0)
+ if (uf+vf > 1.0)
{
// printf("bigger - divs1: %d, divs2: %d\n", divs1, divs2);
continue;
}
copy_v3_v3(p1, mvert[ mface[i].v1 ].co);
- if(again == 1 && mface[i].v4)
+ if (again == 1 && mface[i].v4)
{
copy_v3_v3(p2, mvert[ mface[i].v3 ].co);
copy_v3_v3(p3, mvert[ mface[i].v4 ].co);
@@ -419,7 +419,7 @@ static void fill_scs_points(Object *ob, DerivedMesh *dm, SmokeCollSettings *scs)
add_v3_v3v3(p, p1, p2);
add_v3_v3(p, p3);
- if(newdivs > divs)
+ if (newdivs > divs)
printf("mem problem\n");
// mMovPoints.push_back(p + trinorm);
@@ -428,7 +428,7 @@ static void fill_scs_points(Object *ob, DerivedMesh *dm, SmokeCollSettings *scs)
copy_v3_v3(&scs->points[3 * (dm->getNumVerts(dm) + newdivs)], tmpvec);
newdivs++;
- if(newdivs > divs)
+ if (newdivs > divs)
printf("mem problem\n");
// mMovPoints.push_back(p - trinorm);
@@ -440,14 +440,14 @@ static void fill_scs_points(Object *ob, DerivedMesh *dm, SmokeCollSettings *scs)
}
}
- if(again == 0 && mface[i].v4)
+ if (again == 0 && mface[i].v4)
again++;
else
again = 0;
facecounter++;
- } while(again!=0);
+ } while (again!=0);
}
scs->numpoints = dm->getNumVerts(dm) + newdivs;
@@ -467,18 +467,18 @@ static void calcTriangleDivs(Object *ob, MVert *verts, int UNUSED(numverts), MFa
float maxpart = ABS(maxscale[0]);
float scaleFac = 0;
float fsTri = 0;
- if(ABS(maxscale[1])>maxpart) maxpart = ABS(maxscale[1]);
- if(ABS(maxscale[2])>maxpart) maxpart = ABS(maxscale[2]);
+ if (ABS(maxscale[1])>maxpart) maxpart = ABS(maxscale[1]);
+ if (ABS(maxscale[2])>maxpart) maxpart = ABS(maxscale[2]);
scaleFac = 1.0 / maxpart;
// featureSize = mLevel[mMaxRefine].nodeSize
fsTri = cell_len * 0.5 * scaleFac;
- if(*tridivs)
+ if (*tridivs)
MEM_freeN(*tridivs);
*tridivs = MEM_callocN(sizeof(int) * numtris * 3, "Smoke_Tridivs");
- for(i = 0, facecounter = 0; i < numfaces; i++)
+ for (i = 0, facecounter = 0; i < numfaces; i++)
{
float p0[3], p1[3], p2[3];
float side1[3];
@@ -497,19 +497,19 @@ static void calcTriangleDivs(Object *ob, MVert *verts, int UNUSED(numverts), MFa
sub_v3_v3v3(side2, p2, p0);
sub_v3_v3v3(side3, p1, p2);
- if(dot_v3v3(side1, side1) > fsTri*fsTri)
+ if (dot_v3v3(side1, side1) > fsTri*fsTri)
{
float tmp = normalize_v3(side1);
divs1 = (int)ceil(tmp/fsTri);
}
- if(dot_v3v3(side2, side2) > fsTri*fsTri)
+ if (dot_v3v3(side2, side2) > fsTri*fsTri)
{
float tmp = normalize_v3(side2);
divs2 = (int)ceil(tmp/fsTri);
/*
// debug
- if(i==0)
+ if (i==0)
printf("b tmp: %f, fsTri: %f, divs2: %d\n", tmp, fsTri, divs2);
*/
}
@@ -519,7 +519,7 @@ static void calcTriangleDivs(Object *ob, MVert *verts, int UNUSED(numverts), MFa
(*tridivs)[3 * facecounter + 2] = divs3;
// TODO quad case
- if(faces[i].v4)
+ if (faces[i].v4)
{
divs1=0, divs2=0, divs3=0;
@@ -536,12 +536,12 @@ static void calcTriangleDivs(Object *ob, MVert *verts, int UNUSED(numverts), MFa
sub_v3_v3v3(side2, p2, p0);
sub_v3_v3v3(side3, p1, p2);
- if(dot_v3v3(side1, side1) > fsTri*fsTri)
+ if (dot_v3v3(side1, side1) > fsTri*fsTri)
{
float tmp = normalize_v3(side1);
divs1 = (int)ceil(tmp/fsTri);
}
- if(dot_v3v3(side2, side2) > fsTri*fsTri)
+ if (dot_v3v3(side2, side2) > fsTri*fsTri)
{
float tmp = normalize_v3(side2);
divs2 = (int)ceil(tmp/fsTri);
@@ -559,19 +559,19 @@ static void calcTriangleDivs(Object *ob, MVert *verts, int UNUSED(numverts), MFa
static void smokeModifier_freeDomain(SmokeModifierData *smd)
{
- if(smd->domain)
+ if (smd->domain)
{
- if(smd->domain->shadow)
+ if (smd->domain->shadow)
MEM_freeN(smd->domain->shadow);
smd->domain->shadow = NULL;
- if(smd->domain->fluid)
+ if (smd->domain->fluid)
smoke_free(smd->domain->fluid);
- if(smd->domain->wt)
+ if (smd->domain->wt)
smoke_turbulence_free(smd->domain->wt);
- if(smd->domain->effector_weights)
+ if (smd->domain->effector_weights)
MEM_freeN(smd->domain->effector_weights);
smd->domain->effector_weights = NULL;
@@ -585,10 +585,10 @@ static void smokeModifier_freeDomain(SmokeModifierData *smd)
static void smokeModifier_freeFlow(SmokeModifierData *smd)
{
- if(smd->flow)
+ if (smd->flow)
{
/*
- if(smd->flow->bvh)
+ if (smd->flow->bvh)
{
free_bvhtree_from_mesh(smd->flow->bvh);
MEM_freeN(smd->flow->bvh);
@@ -602,22 +602,22 @@ static void smokeModifier_freeFlow(SmokeModifierData *smd)
static void smokeModifier_freeCollision(SmokeModifierData *smd)
{
- if(smd->coll)
+ if (smd->coll)
{
- if(smd->coll->points)
+ if (smd->coll->points)
{
MEM_freeN(smd->coll->points);
smd->coll->points = NULL;
}
- if(smd->coll->bvhtree)
+ if (smd->coll->bvhtree)
{
BLI_bvhtree_free(smd->coll->bvhtree);
smd->coll->bvhtree = NULL;
}
#ifdef USE_SMOKE_COLLISION_DM
- if(smd->coll->dm)
+ if (smd->coll->dm)
smd->coll->dm->release(smd->coll->dm);
smd->coll->dm = NULL;
#endif
@@ -629,7 +629,7 @@ static void smokeModifier_freeCollision(SmokeModifierData *smd)
void smokeModifier_reset_turbulence(struct SmokeModifierData *smd)
{
- if(smd && smd->domain && smd->domain->wt)
+ if (smd && smd->domain && smd->domain->wt)
{
smoke_turbulence_free(smd->domain->wt);
smd->domain->wt = NULL;
@@ -638,15 +638,15 @@ void smokeModifier_reset_turbulence(struct SmokeModifierData *smd)
void smokeModifier_reset(struct SmokeModifierData *smd)
{
- if(smd)
+ if (smd)
{
- if(smd->domain)
+ if (smd->domain)
{
- if(smd->domain->shadow)
+ if (smd->domain->shadow)
MEM_freeN(smd->domain->shadow);
smd->domain->shadow = NULL;
- if(smd->domain->fluid)
+ if (smd->domain->fluid)
{
smoke_free(smd->domain->fluid);
smd->domain->fluid = NULL;
@@ -658,10 +658,10 @@ void smokeModifier_reset(struct SmokeModifierData *smd)
// printf("reset domain end\n");
}
- else if(smd->flow)
+ else if (smd->flow)
{
/*
- if(smd->flow->bvh)
+ if (smd->flow->bvh)
{
free_bvhtree_from_mesh(smd->flow->bvh);
MEM_freeN(smd->flow->bvh);
@@ -669,22 +669,22 @@ void smokeModifier_reset(struct SmokeModifierData *smd)
smd->flow->bvh = NULL;
*/
}
- else if(smd->coll)
+ else if (smd->coll)
{
- if(smd->coll->points)
+ if (smd->coll->points)
{
MEM_freeN(smd->coll->points);
smd->coll->points = NULL;
}
- if(smd->coll->bvhtree)
+ if (smd->coll->bvhtree)
{
BLI_bvhtree_free(smd->coll->bvhtree);
smd->coll->bvhtree = NULL;
}
#ifdef USE_SMOKE_COLLISION_DM
- if(smd->coll->dm)
+ if (smd->coll->dm)
smd->coll->dm->release(smd->coll->dm);
smd->coll->dm = NULL;
#endif
@@ -695,7 +695,7 @@ void smokeModifier_reset(struct SmokeModifierData *smd)
void smokeModifier_free (SmokeModifierData *smd)
{
- if(smd)
+ if (smd)
{
smokeModifier_freeDomain(smd);
smokeModifier_freeFlow(smd);
@@ -705,11 +705,11 @@ void smokeModifier_free (SmokeModifierData *smd)
void smokeModifier_createType(struct SmokeModifierData *smd)
{
- if(smd)
+ if (smd)
{
- if(smd->type & MOD_SMOKE_TYPE_DOMAIN)
+ if (smd->type & MOD_SMOKE_TYPE_DOMAIN)
{
- if(smd->domain)
+ if (smd->domain)
smokeModifier_freeDomain(smd);
smd->domain = MEM_callocN(sizeof(SmokeDomainSettings), "SmokeDomain");
@@ -746,9 +746,9 @@ void smokeModifier_createType(struct SmokeModifierData *smd)
smd->domain->viewsettings = MOD_SMOKE_VIEW_SHOWBIG;
smd->domain->effector_weights = BKE_add_effector_weights(NULL);
}
- else if(smd->type & MOD_SMOKE_TYPE_FLOW)
+ else if (smd->type & MOD_SMOKE_TYPE_FLOW)
{
- if(smd->flow)
+ if (smd->flow)
smokeModifier_freeFlow(smd);
smd->flow = MEM_callocN(sizeof(SmokeFlowSettings), "SmokeFlow");
@@ -764,9 +764,9 @@ void smokeModifier_createType(struct SmokeModifierData *smd)
smd->flow->psys = NULL;
}
- else if(smd->type & MOD_SMOKE_TYPE_COLL)
+ else if (smd->type & MOD_SMOKE_TYPE_COLL)
{
- if(smd->coll)
+ if (smd->coll)
smokeModifier_freeCollision(smd);
smd->coll = MEM_callocN(sizeof(SmokeCollSettings), "SmokeColl");
@@ -809,14 +809,16 @@ void smokeModifier_copy(struct SmokeModifierData *smd, struct SmokeModifierData
MEM_freeN(tsmd->domain->effector_weights);
tsmd->domain->effector_weights = MEM_dupallocN(smd->domain->effector_weights);
- } else if (tsmd->flow) {
+ }
+ else if (tsmd->flow) {
tsmd->flow->density = smd->flow->density;
tsmd->flow->temp = smd->flow->temp;
tsmd->flow->psys = smd->flow->psys;
tsmd->flow->type = smd->flow->type;
tsmd->flow->flags = smd->flow->flags;
tsmd->flow->vel_multi = smd->flow->vel_multi;
- } else if (tsmd->coll) {
+ }
+ else if (tsmd->coll) {
;
/* leave it as initialized, collision settings is mostly caches */
}
@@ -834,15 +836,15 @@ static int get_lamp(Scene *scene, float *light)
int found_lamp = 0;
// try to find a lamp, preferably local
- for(base_tmp = scene->base.first; base_tmp; base_tmp= base_tmp->next) {
- if(base_tmp->object->type == OB_LAMP) {
+ for (base_tmp = scene->base.first; base_tmp; base_tmp= base_tmp->next) {
+ if (base_tmp->object->type == OB_LAMP) {
Lamp *la = base_tmp->object->data;
- if(la->type == LA_LOCAL) {
+ if (la->type == LA_LOCAL) {
copy_v3_v3(light, base_tmp->object->obmat[3]);
return 1;
}
- else if(!found_lamp) {
+ else if (!found_lamp) {
copy_v3_v3(light, base_tmp->object->obmat[3]);
found_lamp = 1;
}
@@ -859,29 +861,29 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd)
Base *base = NULL;
// do collisions, needs to be done before emission, so that smoke isn't emitted inside collision cells
- if(1)
+ if (1)
{
Object *otherobj = NULL;
ModifierData *md = NULL;
- if(sds->coll_group) // we use groups since we have 2 domains
+ if (sds->coll_group) // we use groups since we have 2 domains
go = sds->coll_group->gobject.first;
else
base = scene->base.first;
- while(base || go)
+ while (base || go)
{
otherobj = NULL;
- if(sds->coll_group)
+ if (sds->coll_group)
{
- if(go->ob)
+ if (go->ob)
otherobj = go->ob;
}
else
otherobj = base->object;
- if(!otherobj)
+ if (!otherobj)
{
- if(sds->coll_group)
+ if (sds->coll_group)
go = go->next;
else
base= base->next;
@@ -890,18 +892,18 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd)
md = modifiers_findByType(otherobj, eModifierType_Smoke);
// check for active smoke modifier
- if(md && md->mode & (eModifierMode_Realtime | eModifierMode_Render))
+ if (md && md->mode & (eModifierMode_Realtime | eModifierMode_Render))
{
SmokeModifierData *smd2 = (SmokeModifierData *)md;
- if((smd2->type & MOD_SMOKE_TYPE_COLL) && smd2->coll && smd2->coll->points)
+ if ((smd2->type & MOD_SMOKE_TYPE_COLL) && smd2->coll && smd2->coll->points)
{
// we got nice collision object
SmokeCollSettings *scs = smd2->coll;
size_t i, j;
unsigned char *obstacles = smoke_get_obstacle(smd->domain->fluid);
- for(i = 0; i < scs->numpoints; i++)
+ for (i = 0; i < scs->numpoints; i++)
{
int badcell = 0;
size_t index = 0;
@@ -911,14 +913,14 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd)
get_cell(smd->domain->p0, smd->domain->res, smd->domain->dx, &scs->points[3 * i], cell, 0);
// check if cell is valid (in the domain boundary)
- for(j = 0; j < 3; j++)
- if((cell[j] > sds->res[j] - 1) || (cell[j] < 0))
+ for (j = 0; j < 3; j++)
+ if ((cell[j] > sds->res[j] - 1) || (cell[j] < 0))
{
badcell = 1;
break;
}
- if(badcell)
+ if (badcell)
continue;
// 2. set cell values (heat, density and velocity)
index = smoke_get_index(cell[0], sds->res[0], cell[1], sds->res[1], cell[2]);
@@ -935,11 +937,11 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd)
{
const LbmFloat usqr = (objvel[0]*objvel[0]+objvel[1]*objvel[1]+objvel[2]*objvel[2])*1.5;
USQRMAXCHECK(usqr, objvel[0],objvel[1],objvel[2], mMaxVlen, mMxvx,mMxvy,mMxvz);
- if(usqr>maxusqr) {
+ if (usqr>maxusqr) {
// cutoff at maxVelVal
- for(int jj=0; jj<3; jj++) {
- if(objvel[jj]>0.) objvel[jj] = maxVelVal;
- if(objvel[jj]<0.) objvel[jj] = -maxVelVal;
+ for (int jj=0; jj<3; jj++) {
+ if (objvel[jj]>0.) objvel[jj] = maxVelVal;
+ if (objvel[jj]<0.) objvel[jj] = -maxVelVal;
}
}
}
@@ -951,7 +953,7 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd)
}
}
- if(sds->coll_group)
+ if (sds->coll_group)
go = go->next;
else
base= base->next;
@@ -959,27 +961,27 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd)
}
// do flows and fluids
- if(1)
+ if (1)
{
Object *otherobj = NULL;
ModifierData *md = NULL;
- if(sds->fluid_group) // we use groups since we have 2 domains
+ if (sds->fluid_group) // we use groups since we have 2 domains
go = sds->fluid_group->gobject.first;
else
base = scene->base.first;
- while(base || go)
+ while (base || go)
{
otherobj = NULL;
- if(sds->fluid_group)
+ if (sds->fluid_group)
{
- if(go->ob)
+ if (go->ob)
otherobj = go->ob;
}
else
otherobj = base->object;
- if(!otherobj)
+ if (!otherobj)
{
- if(sds->fluid_group)
+ if (sds->fluid_group)
go = go->next;
else
base= base->next;
@@ -990,17 +992,17 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd)
md = modifiers_findByType(otherobj, eModifierType_Smoke);
// check for active smoke modifier
- if(md && md->mode & (eModifierMode_Realtime | eModifierMode_Render))
+ if (md && md->mode & (eModifierMode_Realtime | eModifierMode_Render))
{
SmokeModifierData *smd2 = (SmokeModifierData *)md;
// check for initialized smoke object
- if((smd2->type & MOD_SMOKE_TYPE_FLOW) && smd2->flow)
+ if ((smd2->type & MOD_SMOKE_TYPE_FLOW) && smd2->flow)
{
// we got nice flow object
SmokeFlowSettings *sfs = smd2->flow;
- if(sfs && sfs->psys && sfs->psys->part && sfs->psys->part->type==PART_EMITTER) // is particle system selected
+ if (sfs && sfs->psys && sfs->psys->part && sfs->psys->part->type==PART_EMITTER) // is particle system selected
{
ParticleSimulationData sim;
ParticleSystem *psys = sfs->psys;
@@ -1029,7 +1031,7 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd)
sim.psys = psys;
// initialize temp emission map
- if(!(sfs->type & MOD_SMOKE_FLOW_TYPE_OUTFLOW))
+ if (!(sfs->type & MOD_SMOKE_FLOW_TYPE_OUTFLOW))
{
int i;
temp_emission_map = MEM_callocN(sizeof(float) * sds->res[0]*sds->res[1]*sds->res[2], "SmokeTempEmission");
@@ -1040,10 +1042,10 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd)
}
// mostly copied from particle code
- if(psys->part->type==PART_HAIR)
+ if (psys->part->type==PART_HAIR)
{
/*
- if(psys->childcache)
+ if (psys->childcache)
{
totchild = psys->totchildcache;
}
@@ -1056,7 +1058,7 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd)
else
totchild=psys->totchild*psys->part->disp/100;
- for(p=0; p<totpart+totchild; p++)
+ for (p=0; p<totpart+totchild; p++)
{
int cell[3];
size_t i = 0;
@@ -1064,21 +1066,21 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd)
int badcell = 0;
ParticleKey state;
- if(p < totpart)
+ if (p < totpart)
{
- if(psys->particles[p].flag & (PARS_NO_DISP|PARS_UNEXIST))
+ if (psys->particles[p].flag & (PARS_NO_DISP|PARS_UNEXIST))
continue;
}
else {
/* handle child particle */
ChildParticle *cpa = &psys->child[p - totpart];
- if(psys->particles[cpa->parent].flag & (PARS_NO_DISP|PARS_UNEXIST))
+ if (psys->particles[cpa->parent].flag & (PARS_NO_DISP|PARS_UNEXIST))
continue;
}
state.time = smd->time;
- if(psys_get_particle_state(&sim, p, &state, 0) == 0)
+ if (psys_get_particle_state(&sim, p, &state, 0) == 0)
continue;
// copy_v3_v3(pos, pa->state.co);
@@ -1086,19 +1088,19 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd)
// 1. get corresponding cell
get_cell(smd->domain->p0, smd->domain->res, smd->domain->dx, state.co, cell, 0);
// check if cell is valid (in the domain boundary)
- for(i = 0; i < 3; i++)
+ for (i = 0; i < 3; i++)
{
- if((cell[i] > sds->res[i] - 1) || (cell[i] < 0))
+ if ((cell[i] > sds->res[i] - 1) || (cell[i] < 0))
{
badcell = 1;
break;
}
}
- if(badcell)
+ if (badcell)
continue;
// 2. set cell values (heat, density and velocity)
index = smoke_get_index(cell[0], sds->res[0], cell[1], sds->res[1], cell[2]);
- if(!(sfs->type & MOD_SMOKE_FLOW_TYPE_OUTFLOW) && !(obstacle[index])) // this is inflow
+ if (!(sfs->type & MOD_SMOKE_FLOW_TYPE_OUTFLOW) && !(obstacle[index])) // this is inflow
{
// heat[index] += sfs->temp * 0.1;
// density[index] += sfs->density * 0.1;
@@ -1108,14 +1110,14 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd)
temp_emission_map[index] = sfs->density;
// Uses particle velocity as initial velocity for smoke
- if(sfs->flags & MOD_SMOKE_FLOW_INITVELOCITY && (psys->part->phystype != PART_PHYS_NO))
+ if (sfs->flags & MOD_SMOKE_FLOW_INITVELOCITY && (psys->part->phystype != PART_PHYS_NO))
{
velocity_x[index] = state.vel[0]*sfs->vel_multi;
velocity_y[index] = state.vel[1]*sfs->vel_multi;
velocity_z[index] = state.vel[2]*sfs->vel_multi;
}
}
- else if(sfs->type & MOD_SMOKE_FLOW_TYPE_OUTFLOW) // outflow
+ else if (sfs->type & MOD_SMOKE_FLOW_TYPE_OUTFLOW) // outflow
{
heat[index] = 0.f;
density[index] = 0.f;
@@ -1123,15 +1125,15 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd)
velocity_y[index] = 0.f;
velocity_z[index] = 0.f;
// we need different handling for the high-res feature
- if(bigdensity)
+ if (bigdensity)
{
// init all surrounding cells according to amplification, too
int i, j, k;
smoke_turbulence_get_res(smd->domain->wt, bigres);
- for(i = 0; i < smd->domain->amplify + 1; i++)
- for(j = 0; j < smd->domain->amplify + 1; j++)
- for(k = 0; k < smd->domain->amplify + 1; k++)
+ for (i = 0; i < smd->domain->amplify + 1; i++)
+ for (j = 0; j < smd->domain->amplify + 1; j++)
+ for (k = 0; k < smd->domain->amplify + 1; k++)
{
index = smoke_get_index((smd->domain->amplify + 1)* cell[0] + i, bigres[0], (smd->domain->amplify + 1)* cell[1] + j, bigres[1], (smd->domain->amplify + 1)* cell[2] + k);
bigdensity[index] = 0.f;
@@ -1142,7 +1144,7 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd)
// apply emission values
- if(!(sfs->type & MOD_SMOKE_FLOW_TYPE_OUTFLOW)) {
+ if (!(sfs->type & MOD_SMOKE_FLOW_TYPE_OUTFLOW)) {
// initialize variables
int ii, jj, kk, x, y, z, block_size;
@@ -1153,9 +1155,9 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd)
// loop through every low res cell
- for(x = 0; x < sds->res[0]; x++)
- for(y = 0; y < sds->res[1]; y++)
- for(z = 0; z < sds->res[2]; z++)
+ for (x = 0; x < sds->res[0]; x++)
+ for (y = 0; y < sds->res[1]; y++)
+ for (z = 0; z < sds->res[2]; z++)
{
// neighbor cell emission densities (for high resolution smoke smooth interpolation)
@@ -1191,9 +1193,9 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd)
loop through high res blocks if high res enabled
*/
if (bigdensity)
- for(ii = 0; ii < block_size; ii++)
- for(jj = 0; jj < block_size; jj++)
- for(kk = 0; kk < block_size; kk++)
+ for (ii = 0; ii < block_size; ii++)
+ for (jj = 0; jj < block_size; jj++)
+ for (kk = 0; kk < block_size; kk++)
{
float fx,fy,fz, interpolated_value;
@@ -1269,7 +1271,7 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd)
}
else {
/*
- for()
+ for ()
{
// no psys
BVHTreeNearest nearest;
@@ -1281,7 +1283,7 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd)
}
}
}
- if(sds->fluid_group)
+ if (sds->fluid_group)
go = go->next;
else
base= base->next;
@@ -1292,7 +1294,7 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd)
{
ListBase *effectors = pdInitEffectors(scene, ob, NULL, sds->effector_weights);
- if(effectors)
+ if (effectors)
{
float *density = smoke_get_density(sds->fluid);
float *force_x = smoke_get_force_x(sds->fluid);
@@ -1304,15 +1306,15 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd)
int x, y, z;
// precalculate wind forces
- for(x = 0; x < sds->res[0]; x++)
- for(y = 0; y < sds->res[1]; y++)
- for(z = 0; z < sds->res[2]; z++)
+ for (x = 0; x < sds->res[0]; x++)
+ for (y = 0; y < sds->res[1]; y++)
+ for (z = 0; z < sds->res[2]; z++)
{
EffectedPoint epoint;
float voxelCenter[3] = {0,0,0} , vel[3] = {0,0,0} , retvel[3] = {0,0,0};
unsigned int index = smoke_get_index(x, sds->res[0], y, sds->res[1], z);
- if(density[index] < FLT_EPSILON)
+ if (density[index] < FLT_EPSILON)
continue;
vel[0] = velocity_x[index];
@@ -1339,12 +1341,12 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd)
}
void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedMesh *dm)
{
- if((smd->type & MOD_SMOKE_TYPE_FLOW))
+ if ((smd->type & MOD_SMOKE_TYPE_FLOW))
{
- if(scene->r.cfra >= smd->time)
+ if (scene->r.cfra >= smd->time)
smokeModifier_init(smd, ob, scene, dm);
- if(scene->r.cfra > smd->time)
+ if (scene->r.cfra > smd->time)
{
// XXX TODO
smd->time = scene->r.cfra;
@@ -1355,24 +1357,24 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM
copy_m4_m4(smd->flow->mat, ob->obmat);
*/
}
- else if(scene->r.cfra < smd->time)
+ else if (scene->r.cfra < smd->time)
{
smd->time = scene->r.cfra;
smokeModifier_reset(smd);
}
}
- else if(smd->type & MOD_SMOKE_TYPE_COLL)
+ else if (smd->type & MOD_SMOKE_TYPE_COLL)
{
- if(scene->r.cfra >= smd->time)
+ if (scene->r.cfra >= smd->time)
smokeModifier_init(smd, ob, scene, dm);
- if(scene->r.cfra > smd->time)
+ if (scene->r.cfra > smd->time)
{
// XXX TODO
smd->time = scene->r.cfra;
#ifdef USE_SMOKE_COLLISION_DM
- if(smd->coll->dm)
+ if (smd->coll->dm)
smd->coll->dm->release(smd->coll->dm);
smd->coll->dm = CDDM_copy_from_tessface(dm);
@@ -1382,13 +1384,13 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM
copy_m4_m4(smd->coll->mat_old, smd->coll->mat);
copy_m4_m4(smd->coll->mat, ob->obmat);
}
- else if(scene->r.cfra < smd->time)
+ else if (scene->r.cfra < smd->time)
{
smd->time = scene->r.cfra;
smokeModifier_reset(smd);
}
}
- else if(smd->type & MOD_SMOKE_TYPE_DOMAIN)
+ else if (smd->type & MOD_SMOKE_TYPE_DOMAIN)
{
SmokeDomainSettings *sds = smd->domain;
float light[3];
@@ -1405,14 +1407,14 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM
BKE_ptcache_id_from_smoke(&pid, ob, smd);
BKE_ptcache_id_time(&pid, scene, framenr, &startframe, &endframe, &timescale);
- if(!smd->domain->fluid || framenr == startframe)
+ if (!smd->domain->fluid || framenr == startframe)
{
BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
BKE_ptcache_validate(cache, framenr);
cache->flag &= ~PTCACHE_REDO_NEEDED;
}
- if(!smd->domain->fluid && (framenr != startframe) && (smd->domain->flags & MOD_SMOKE_FILE_LOAD)==0 && (cache->flag & PTCACHE_BAKED)==0)
+ if (!smd->domain->fluid && (framenr != startframe) && (smd->domain->flags & MOD_SMOKE_FILE_LOAD)==0 && (cache->flag & PTCACHE_BAKED)==0)
return;
smd->domain->flags &= ~MOD_SMOKE_FILE_LOAD;
@@ -1425,21 +1427,21 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM
// printf("startframe: %d, framenr: %d\n", startframe, framenr);
- if(smokeModifier_init(smd, ob, scene, dm)==0)
+ if (smokeModifier_init(smd, ob, scene, dm)==0)
{
printf("bad smokeModifier_init\n");
return;
}
/* try to read from cache */
- if(BKE_ptcache_read(&pid, (float)framenr) == PTCACHE_READ_EXACT) {
+ if (BKE_ptcache_read(&pid, (float)framenr) == PTCACHE_READ_EXACT) {
BKE_ptcache_validate(cache, framenr);
smd->time = framenr;
return;
}
/* only calculate something when we advanced a single frame */
- if(framenr != (int)smd->time+1)
+ if (framenr != (int)smd->time+1)
return;
/* don't simulate if viewing start frame, but scene frame is not real start frame */
@@ -1451,14 +1453,14 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM
smoke_calc_domain(scene, ob, smd);
/* if on second frame, write cache for first frame */
- if((int)smd->time == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact==0)) {
+ if ((int)smd->time == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact==0)) {
// create shadows straight after domain initialization so we get nice shadows for startframe, too
- if(get_lamp(scene, light))
+ if (get_lamp(scene, light))
smoke_calc_transparency(sds->shadow, smoke_get_density(sds->fluid), sds->p0, sds->p1, sds->res, sds->dx, light, calc_voxel_transp, -7.0*sds->dx);
- if(sds->wt)
+ if (sds->wt)
{
- if(sds->flags & MOD_SMOKE_DISSOLVE)
+ if (sds->flags & MOD_SMOKE_DISSOLVE)
smoke_dissolve_wavelet(sds->wt, sds->diss_speed, sds->flags & MOD_SMOKE_DISSOLVE_LOG);
smoke_turbulence_step(sds->wt, sds->fluid);
}
@@ -1475,26 +1477,26 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM
// simulate the actual smoke (c++ code in intern/smoke)
// DG: interesting commenting this line + deactivating loading of noise files
- if(framenr!=startframe)
+ if (framenr!=startframe)
{
- if(sds->flags & MOD_SMOKE_DISSOLVE)
+ if (sds->flags & MOD_SMOKE_DISSOLVE)
smoke_dissolve(sds->fluid, sds->diss_speed, sds->flags & MOD_SMOKE_DISSOLVE_LOG);
smoke_step(sds->fluid, smd->time, scene->r.frs_sec / scene->r.frs_sec_base);
}
// create shadows before writing cache so they get stored
- if(get_lamp(scene, light))
+ if (get_lamp(scene, light))
smoke_calc_transparency(sds->shadow, smoke_get_density(sds->fluid), sds->p0, sds->p1, sds->res, sds->dx, light, calc_voxel_transp, -7.0*sds->dx);
- if(sds->wt)
+ if (sds->wt)
{
- if(sds->flags & MOD_SMOKE_DISSOLVE)
+ if (sds->flags & MOD_SMOKE_DISSOLVE)
smoke_dissolve_wavelet(sds->wt, sds->diss_speed, sds->flags & MOD_SMOKE_DISSOLVE_LOG);
smoke_turbulence_step(sds->wt, sds->fluid);
}
BKE_ptcache_validate(cache, framenr);
- if(framenr != startframe)
+ if (framenr != startframe)
BKE_ptcache_write(&pid, framenr);
tend();
@@ -1509,7 +1511,7 @@ static float calc_voxel_transp(float *result, float *input, int res[3], int *pix
// T_ray *= T_vox
*tRay *= exp(input[index]*correct);
- if(result[index] < 0.0f)
+ if (result[index] < 0.0f)
{
#pragma omp critical
result[index] = *tRay;
@@ -1563,7 +1565,7 @@ static void bresenham_linie_3D(int x1, int y1, int z1, int x2, int y2, int z2, f
err_1 = dy2 - l;
err_2 = dz2 - l;
for (i = 0; i < l; i++) {
- if(cb(result, input, res, pixel, tRay, correct) <= FLT_EPSILON)
+ if (cb(result, input, res, pixel, tRay, correct) <= FLT_EPSILON)
break;
if (err_1 > 0) {
pixel[1] += y_inc;
@@ -1577,11 +1579,12 @@ static void bresenham_linie_3D(int x1, int y1, int z1, int x2, int y2, int z2, f
err_2 += dz2;
pixel[0] += x_inc;
}
- } else if ((m >= l) && (m >= n)) {
+ }
+ else if ((m >= l) && (m >= n)) {
err_1 = dx2 - m;
err_2 = dz2 - m;
for (i = 0; i < m; i++) {
- if(cb(result, input, res, pixel, tRay, correct) <= FLT_EPSILON)
+ if (cb(result, input, res, pixel, tRay, correct) <= FLT_EPSILON)
break;
if (err_1 > 0) {
pixel[0] += x_inc;
@@ -1595,11 +1598,12 @@ static void bresenham_linie_3D(int x1, int y1, int z1, int x2, int y2, int z2, f
err_2 += dz2;
pixel[1] += y_inc;
}
- } else {
+ }
+ else {
err_1 = dy2 - n;
err_2 = dx2 - n;
for (i = 0; i < n; i++) {
- if(cb(result, input, res, pixel, tRay, correct) <= FLT_EPSILON)
+ if (cb(result, input, res, pixel, tRay, correct) <= FLT_EPSILON)
break;
if (err_1 > 0) {
pixel[1] += y_inc;
@@ -1641,7 +1645,7 @@ static void smoke_calc_transparency(float *result, float *input, float *p0, floa
float bv[6];
int a, z, slabsize=res[0]*res[1], size= res[0]*res[1]*res[2];
- for(a=0; a<size; a++)
+ for (a=0; a<size; a++)
result[a]= -1.0f;
bv[0] = p0[0];
@@ -1654,27 +1658,27 @@ static void smoke_calc_transparency(float *result, float *input, float *p0, floa
bv[5] = p1[2];
#pragma omp parallel for schedule(static,1)
- for(z = 0; z < res[2]; z++)
+ for (z = 0; z < res[2]; z++)
{
size_t index = z*slabsize;
int x,y;
- for(y = 0; y < res[1]; y++)
- for(x = 0; x < res[0]; x++, index++)
+ for (y = 0; y < res[1]; y++)
+ for (x = 0; x < res[0]; x++, index++)
{
float voxelCenter[3];
float pos[3];
int cell[3];
float tRay = 1.0;
- if(result[index] >= 0.0f)
+ if (result[index] >= 0.0f)
continue;
voxelCenter[0] = p0[0] + dx * x + dx * 0.5;
voxelCenter[1] = p0[1] + dx * y + dx * 0.5;
voxelCenter[2] = p0[2] + dx * z + dx * 0.5;
// get starting position (in voxel coords)
- if(BLI_bvhtree_bb_raycast(bv, light, voxelCenter, pos) > FLT_EPSILON)
+ if (BLI_bvhtree_bb_raycast(bv, light, voxelCenter, pos) > FLT_EPSILON)
{
// we're ouside
get_cell(p0, res, dx, pos, cell, 1);
diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c
index cb2e6681e95..4206c9921df 100644
--- a/source/blender/blenkernel/intern/softbody.c
+++ b/source/blender/blenkernel/intern/softbody.c
@@ -1065,7 +1065,7 @@ static int sb_detect_aabb_collisionCached( float UNUSED(force[3]), unsigned int
deflected = 2;
}
- else{
+ else {
/*aye that should be cached*/
printf("missing cache error \n");
BLI_ghashIterator_step(ihash);
@@ -1132,7 +1132,7 @@ static int sb_detect_face_pointCached(float face_v1[3],float face_v2[3],float fa
}
}
- else{
+ else {
/*aye that should be cached*/
printf("missing cache error \n");
BLI_ghashIterator_step(ihash);
@@ -1142,7 +1142,7 @@ static int sb_detect_face_pointCached(float face_v1[3],float face_v2[3],float fa
/* use mesh*/
if (mvert) {
- while(a) {
+ while (a) {
copy_v3_v3(nv1,mvert[a-1].co);
if (mprevvert) {
mul_v3_fl(nv1,time);
@@ -1169,7 +1169,7 @@ static int sb_detect_face_pointCached(float face_v1[3],float face_v2[3],float fa
}
}
a--;
- }/* while(a)*/
+ }/* while (a)*/
} /* if (mvert) */
} /* if (ob->pd && ob->pd->deflect) */
BLI_ghashIterator_step(ihash);
@@ -1227,7 +1227,7 @@ static int sb_detect_face_collisionCached(float face_v1[3],float face_v2[3],floa
}
}
- else{
+ else {
/*aye that should be cached*/
printf("missing cache error \n");
BLI_ghashIterator_step(ihash);
@@ -1455,7 +1455,7 @@ static int sb_detect_edge_collisionCached(float edge_v1[3],float edge_v2[3],floa
}
}
- else{
+ else {
/*aye that should be cached*/
printf("missing cache error \n");
BLI_ghashIterator_step(ihash);
@@ -1601,7 +1601,7 @@ static void _scan_for_ext_spring_forces(Scene *scene, Object *ob, float timenow,
add_v3_v3(vel, speed);
}
/* media in rest */
- else{
+ else {
add_v3_v3v3(vel, sb->bpoint[bs->v1].vec , sb->bpoint[bs->v2].vec);
}
f = normalize_v3(vel);
@@ -1617,7 +1617,7 @@ static void _scan_for_ext_spring_forces(Scene *scene, Object *ob, float timenow,
normalize_v3(sp);
Vec3PlusStVec(bs->ext_force,f*(1.0f-ABS(dot_v3v3(vel,sp))),vel);
}
- else{
+ else {
Vec3PlusStVec(bs->ext_force,f,vel); // to keep compatible with 2.45 release files
}
}
@@ -1792,7 +1792,7 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3],
continue;
}
}
- else{
+ else {
/*aye that should be cached*/
printf("missing cache error \n");
BLI_ghashIterator_step(ihash);
@@ -2048,7 +2048,7 @@ static void dfdx_spring(int ia, int ic, int op, float dir[3],float L,float len,f
nlMatrixAdd(ia+i,op+ic+j,m);
}
}
- else{
+ else {
for (i=0;i<3;i++)
for (j=0;j<3;j++) {
m=factor*dir[i]*dir[j];
@@ -2097,7 +2097,7 @@ static void sb_spring_force(Object *ob,int bpi,BodySpring *bs,float iks,float UN
ic =3*bs->v1;
#endif
}
- else{
+ else {
/* TODO make this debug option */
/**/
printf("bodypoint <bpi> is not attached to spring <*bs> --> sb_spring_force()\n");
@@ -2490,7 +2490,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa
softbody_calc_forcesEx(scene, ob, forcetime, timenow, nl_flags);
return;
}
- else{
+ else {
/* so the following will die */
/* |||||||||||||||||||||||||| */
/* VVVVVVVVVVVVVVVVVVVVVVVVVV */
@@ -2762,7 +2762,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa
*/
Vec3PlusStVec(bp->pos,-intrusion,facenormal);
}
- else{
+ else {
sub_v3_v3v3(cfforce,bp->vec,vel);
Vec3PlusStVec(bp->force,-cf*50.0f,cfforce);
@@ -2773,7 +2773,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa
bp->loc_flag |= SBF_DOFUZZY;
bp->choke = sb->choke*0.01f;
}
- else{
+ else {
sub_v3_v3v3(cfforce,bp->vec,vel);
Vec3PlusStVec(bp->force,-cf*50.0f,cfforce);
}
@@ -2873,7 +2873,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa
}
*/
}
- else{
+ else {
printf("Matrix inversion failed \n");
for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
copy_v3_v3(bp->impdv,bp->force);
@@ -2963,7 +2963,7 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float *
if ((dot_v3v3(dx,dx)<freezeloc )&&(dot_v3v3(bp->force,bp->force)<freezeforce )) {
bp->frozen /=2;
}
- else{
+ else {
bp->frozen = MIN2(bp->frozen*1.05f,1.0f);
}
mul_v3_fl(dx,bp->frozen);
@@ -3295,7 +3295,7 @@ static void mesh_to_softbody(Scene *scene, Object *ob)
/* should be fixed for meshes */
// bp->goal= sb->mingoal + bp->goal*goalfac; /* do not do here jow_go_for2_5 */
}
- else{
+ else {
/* in consequence if no group was set .. but we want to animate it laters */
/* logically attach to goal with default first */
if (ob->softflag & OB_SB_GOAL) {bp->goal = sb->defgoal;}
@@ -4032,7 +4032,7 @@ static void softbody_step(Scene *scene, Object *ob, SoftBody *sb, float dtime)
//removed
}/*SOLVER SELECT*/
- else{
+ else {
printf("softbody no valid solver ID!");
}/*SOLVER SELECT*/
if (sb->plastic) { apply_spring_memory(ob);}
diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c
index 67e392fa296..c2dbb518837 100644
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@ -86,7 +86,7 @@ struct bSound* sound_new_file(struct Main *bmain, const char *filename)
BLI_path_abs(str, path);
len = strlen(filename);
- while(len > 0 && filename[len-1] != '/' && filename[len-1] != '\\')
+ while (len > 0 && filename[len-1] != '/' && filename[len-1] != '\\')
len--;
sound = alloc_libblock(&bmain->sound, ID_SO, filename+len);
@@ -141,7 +141,7 @@ static void sound_sync_callback(void* data, int mode, float time)
struct Scene* scene;
scene = bmain->scene.first;
- while(scene)
+ while (scene)
{
if (scene->audio.flag & AUDIO_SYNC)
{
@@ -765,7 +765,7 @@ void sound_update_scene(struct Scene* scene)
}
}
- while((handle = AUD_getSet(scene->speaker_handles)))
+ while ((handle = AUD_getSet(scene->speaker_handles)))
{
AUD_removeSequence(scene->sound_scene, handle);
}
diff --git a/source/blender/blenkernel/intern/speaker.c b/source/blender/blenkernel/intern/speaker.c
index a5d24c79bba..5466630f621 100644
--- a/source/blender/blenkernel/intern/speaker.c
+++ b/source/blender/blenkernel/intern/speaker.c
@@ -70,7 +70,7 @@ Speaker *copy_speaker(Speaker *spk)
Speaker *spkn;
spkn= copy_libblock(&spk->id);
- if(spkn->sound)
+ if (spkn->sound)
spkn->sound->id.us++;
return spkn;
@@ -87,25 +87,25 @@ void make_local_speaker(Speaker *spk)
* - mixed: make copy
*/
- if(spk->id.lib==NULL) return;
- if(spk->id.us==1) {
+ if (spk->id.lib==NULL) return;
+ if (spk->id.us==1) {
id_clear_lib_data(bmain, &spk->id);
return;
}
ob= bmain->object.first;
- while(ob) {
- if(ob->data==spk) {
- if(ob->id.lib) is_lib= TRUE;
+ while (ob) {
+ if (ob->data==spk) {
+ if (ob->id.lib) is_lib= TRUE;
else is_local= TRUE;
}
ob= ob->id.next;
}
- if(is_local && is_lib == FALSE) {
+ if (is_local && is_lib == FALSE) {
id_clear_lib_data(bmain, &spk->id);
}
- else if(is_local && is_lib) {
+ else if (is_local && is_lib) {
Speaker *spk_new= copy_speaker(spk);
spk_new->id.us= 0;
@@ -113,10 +113,10 @@ void make_local_speaker(Speaker *spk)
BKE_id_lib_local_paths(bmain, spk->id.lib, &spk_new->id);
ob= bmain->object.first;
- while(ob) {
- if(ob->data==spk) {
+ while (ob) {
+ if (ob->data==spk) {
- if(ob->id.lib==NULL) {
+ if (ob->id.lib==NULL) {
ob->data= spk_new;
spk_new->id.us++;
spk->id.us--;
@@ -129,7 +129,7 @@ void make_local_speaker(Speaker *spk)
void free_speaker(Speaker *spk)
{
- if(spk->sound)
+ if (spk->sound)
spk->sound->id.us--;
BKE_free_animdata((ID *)spk);
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index 163223d1a18..7b84fc6d896 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -130,7 +130,8 @@ static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, CCGFlags fl
if (oldUseAging!=useAging) {
ccgSubSurf_free(prevSS);
- } else {
+ }
+ else {
ccgSubSurf_setSubdivisionLevels(prevSS, subdivLevels);
return prevSS;
@@ -139,7 +140,8 @@ static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, CCGFlags fl
if (useAging) {
ifc.vertUserSize = ifc.edgeUserSize = ifc.faceUserSize = 12;
- } else {
+ }
+ else {
ifc.vertUserSize = ifc.edgeUserSize = ifc.faceUserSize = 8;
}
ifc.vertDataSize = sizeof(float) * (flags & CCG_CALC_NORMALS ? 6 : 3);
@@ -154,7 +156,8 @@ static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, CCGFlags fl
allocatorIFC.release = arena_release;
ccgSS = ccgSubSurf_new(&ifc, subdivLevels, &allocatorIFC, allocator);
- } else {
+ }
+ else {
ccgSS = ccgSubSurf_new(&ifc, subdivLevels, NULL, NULL);
}
@@ -180,9 +183,11 @@ static int getEdgeIndex(CCGSubSurf *ss, CCGEdge *e, int x, int edgeSize)
if (x==0) {
return v0idx;
- } else if (x==edgeSize-1) {
+ }
+ else if (x==edgeSize-1) {
return v1idx;
- } else {
+ }
+ else {
return edgeBase + x-1;
}
}
@@ -195,32 +200,40 @@ static int getFaceIndex(CCGSubSurf *ss, CCGFace *f, int S, int x, int y, int edg
if (x==gridSize-1 && y==gridSize-1) {
CCGVert *v = ccgSubSurf_getFaceVert(f, S);
return *((int*) ccgSubSurf_getVertUserData(ss, v));
- } else if (x==gridSize-1) {
+ }
+ else if (x==gridSize-1) {
CCGVert *v = ccgSubSurf_getFaceVert(f, S);
CCGEdge *e = ccgSubSurf_getFaceEdge(f, S);
int edgeBase = *((int*) ccgSubSurf_getEdgeUserData(ss, e));
if (v==ccgSubSurf_getEdgeVert0(e)) {
return edgeBase + (gridSize-1-y)-1;
- } else {
+ }
+ else {
return edgeBase + (edgeSize-2-1)-((gridSize-1-y)-1);
}
- } else if (y==gridSize-1) {
+ }
+ else if (y==gridSize-1) {
CCGVert *v = ccgSubSurf_getFaceVert(f, S);
CCGEdge *e = ccgSubSurf_getFaceEdge(f, (S+numVerts-1)%numVerts);
int edgeBase = *((int*) ccgSubSurf_getEdgeUserData(ss, e));
if (v==ccgSubSurf_getEdgeVert0(e)) {
return edgeBase + (gridSize-1-x)-1;
- } else {
+ }
+ else {
return edgeBase + (edgeSize-2-1)-((gridSize-1-x)-1);
}
- } else if (x==0 && y==0) {
+ }
+ else if (x==0 && y==0) {
return faceBase;
- } else if (x==0) {
+ }
+ else if (x==0) {
S = (S+numVerts-1)%numVerts;
return faceBase + 1 + (gridSize-2)*S + (y-1);
- } else if (y==0) {
+ }
+ else if (y==0) {
return faceBase + 1 + (gridSize-2)*S + (x-1);
- } else {
+ }
+ else {
return faceBase + 1 + (gridSize-2)*numVerts + S*(gridSize-2)*(gridSize-2) + (y-1)*(gridSize-2) + (x-1);
}
}
@@ -364,13 +377,13 @@ static void set_subsurf_uv(CCGSubSurf *ss, DerivedMesh *dm, DerivedMesh *result,
MTFace *tface = CustomData_get_layer_n(&result->faceData, CD_MTFACE, n);
MLoopUV *mloopuv = CustomData_get_layer_n(&result->loopData, CD_MLOOPUV, n);
- if(!dmloopuv || (!tface && !mloopuv))
+ if (!dmloopuv || (!tface && !mloopuv))
return;
/* create a CCGSubSurf from uv's */
uvss = _getSubSurf(NULL, ccgSubSurf_getSubdivisionLevels(ss), CCG_USE_ARENA);
- if(!ss_sync_from_uv(uvss, ss, dm, dmloopuv)) {
+ if (!ss_sync_from_uv(uvss, ss, dm, dmloopuv)) {
ccgSubSurf_free(uvss);
return;
}
@@ -385,7 +398,7 @@ static void set_subsurf_uv(CCGSubSurf *ss, DerivedMesh *dm, DerivedMesh *result,
faceMap = MEM_mallocN(totface*sizeof(*faceMap), "facemapuv");
fi = ccgSubSurf_getFaceIterator(uvss);
- for(; !ccgFaceIterator_isStopped(fi); ccgFaceIterator_next(fi)) {
+ for (; !ccgFaceIterator_isStopped(fi); ccgFaceIterator_next(fi)) {
CCGFace *f = ccgFaceIterator_getCurrent(fi);
faceMap[GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(f))] = f;
}
@@ -395,15 +408,15 @@ static void set_subsurf_uv(CCGSubSurf *ss, DerivedMesh *dm, DerivedMesh *result,
tf= tface;
mluv= mloopuv;
- for(index = 0; index < totface; index++) {
+ for (index = 0; index < totface; index++) {
CCGFace *f = faceMap[index];
int numVerts = ccgSubSurf_getFaceNumVerts(f);
for (S=0; S<numVerts; S++) {
float (*faceGridData)[3]= ccgSubSurf_getFaceGridDataArray(uvss, f, S);
- for(y = 0; y < gridFaces; y++) {
- for(x = 0; x < gridFaces; x++) {
+ for (y = 0; y < gridFaces; y++) {
+ for (x = 0; x < gridFaces; x++) {
float *a = faceGridData[(y + 0)*gridSize + x + 0];
float *b = faceGridData[(y + 0)*gridSize + x + 1];
float *c = faceGridData[(y + 1)*gridSize + x + 1];
@@ -535,12 +548,13 @@ static void ss_sync_from_derivedmesh(CCGSubSurf *ss, DerivedMesh *dm,
mv = mvert;
index = (int *)dm->getVertDataArray(dm, CD_ORIGINDEX);
- for(i = 0; i < totvert; i++, mv++) {
+ for (i = 0; i < totvert; i++, mv++) {
CCGVert *v;
- if(vertexCos) {
+ if (vertexCos) {
ccgSubSurf_syncVert(ss, SET_INT_IN_POINTER(i), vertexCos[i], 0, &v);
- } else {
+ }
+ else {
ccgSubSurf_syncVert(ss, SET_INT_IN_POINTER(i), mv->co, 0, &v);
}
@@ -549,7 +563,7 @@ static void ss_sync_from_derivedmesh(CCGSubSurf *ss, DerivedMesh *dm,
me = medge;
index = (int *)dm->getEdgeDataArray(dm, CD_ORIGINDEX);
- for(i = 0; i < totedge; i++, me++) {
+ for (i = 0; i < totedge; i++, me++) {
CCGEdge *e;
float crease;
@@ -579,11 +593,11 @@ static void ss_sync_from_derivedmesh(CCGSubSurf *ss, DerivedMesh *dm,
* it is not really possible to continue without modifying
* other parts of code significantly to handle missing faces.
* since this really shouldn't even be possible we just bail.*/
- if(ccgSubSurf_syncFace(ss, SET_INT_IN_POINTER(i), mp->totloop,
+ if (ccgSubSurf_syncFace(ss, SET_INT_IN_POINTER(i), mp->totloop,
fVerts, &f) == eCCGError_InvalidValue) {
static int hasGivenError = 0;
- if(!hasGivenError) {
+ if (!hasGivenError) {
//XXX error("Unrecoverable error in SubSurf calculation,"
// " mesh is inconsistent.");
@@ -702,7 +716,7 @@ static void ccgDM_getFinalVert(DerivedMesh *dm, int vertNum, MVert *mv)
memset(mv, 0, sizeof(*mv));
- if((vertNum < ccgdm->edgeMap[0].startVert) && (ccgSubSurf_getNumFaces(ss) > 0)) {
+ if ((vertNum < ccgdm->edgeMap[0].startVert) && (ccgSubSurf_getNumFaces(ss) > 0)) {
/* this vert comes from face data */
int lastface = ccgSubSurf_getNumFaces(ss) - 1;
CCGFace *f;
@@ -715,7 +729,7 @@ static void ccgDM_getFinalVert(DerivedMesh *dm, int vertNum, MVert *mv)
int gridInternalEnd;
i = 0;
- while(i < lastface && vertNum >= ccgdm->faceMap[i + 1].startVert)
+ while (i < lastface && vertNum >= ccgdm->faceMap[i + 1].startVert)
++i;
f = ccgdm->faceMap[i].face;
@@ -728,18 +742,20 @@ static void ccgDM_getFinalVert(DerivedMesh *dm, int vertNum, MVert *mv)
gridInternalEnd = gridSideEnd + numVerts * gridInternalVerts;
offset = vertNum - ccgdm->faceMap[i].startVert;
- if(offset < 1) {
+ if (offset < 1) {
vd = ccgSubSurf_getFaceCenterData(f);
copy_v3_v3(mv->co, vd->co);
normal_float_to_short_v3(mv->no, vd->no);
- } else if(offset < gridSideEnd) {
+ }
+ else if (offset < gridSideEnd) {
offset -= 1;
grid = offset / gridSideVerts;
x = offset % gridSideVerts + 1;
vd = ccgSubSurf_getFaceGridEdgeData(ss, f, grid, x);
copy_v3_v3(mv->co, vd->co);
normal_float_to_short_v3(mv->no, vd->no);
- } else if(offset < gridInternalEnd) {
+ }
+ else if (offset < gridInternalEnd) {
offset -= gridSideEnd;
grid = offset / gridInternalVerts;
offset %= gridInternalVerts;
@@ -749,14 +765,15 @@ static void ccgDM_getFinalVert(DerivedMesh *dm, int vertNum, MVert *mv)
copy_v3_v3(mv->co, vd->co);
normal_float_to_short_v3(mv->no, vd->no);
}
- } else if((vertNum < ccgdm->vertMap[0].startVert) && (ccgSubSurf_getNumEdges(ss) > 0)) {
+ }
+ else if ((vertNum < ccgdm->vertMap[0].startVert) && (ccgSubSurf_getNumEdges(ss) > 0)) {
/* this vert comes from edge data */
CCGEdge *e;
int lastedge = ccgSubSurf_getNumEdges(ss) - 1;
int x;
i = 0;
- while(i < lastedge && vertNum >= ccgdm->edgeMap[i + 1].startVert)
+ while (i < lastedge && vertNum >= ccgdm->edgeMap[i + 1].startVert)
++i;
e = ccgdm->edgeMap[i].edge;
@@ -765,7 +782,8 @@ static void ccgDM_getFinalVert(DerivedMesh *dm, int vertNum, MVert *mv)
vd = ccgSubSurf_getEdgeData(ss, e, x);
copy_v3_v3(mv->co, vd->co);
normal_float_to_short_v3(mv->no, vd->no);
- } else {
+ }
+ else {
/* this vert comes from vert data */
CCGVert *v;
i = vertNum - ccgdm->vertMap[0].startVert;
@@ -801,7 +819,7 @@ static void ccgDM_getFinalEdge(DerivedMesh *dm, int edgeNum, MEdge *med)
memset(med, 0, sizeof(*med));
- if(edgeNum < ccgdm->edgeMap[0].startEdge) {
+ if (edgeNum < ccgdm->edgeMap[0].startEdge) {
/* this edge comes from face data */
int lastface = ccgSubSurf_getNumFaces(ss) - 1;
CCGFace *f;
@@ -821,9 +839,11 @@ static void ccgDM_getFinalEdge(DerivedMesh *dm, int edgeNum, MEdge *med)
previ = i;
if (ccgdm->faceMap[i].startEdge >= edgeNum) {
i -= fabsf(i-lasti)/2.0f;
- } else if (ccgdm->faceMap[i].startEdge < edgeNum) {
+ }
+ else if (ccgdm->faceMap[i].startEdge < edgeNum) {
i += fabsf(i-lasti)/2.0f;
- } else {
+ }
+ else {
break;
}
@@ -848,7 +868,7 @@ static void ccgDM_getFinalEdge(DerivedMesh *dm, int edgeNum, MEdge *med)
#endif
i = 0;
- while(i < lastface && edgeNum >= ccgdm->faceMap[i + 1].startEdge)
+ while (i < lastface && edgeNum >= ccgdm->faceMap[i + 1].startEdge)
++i;
f = ccgdm->faceMap[i].face;
@@ -861,23 +881,26 @@ static void ccgDM_getFinalEdge(DerivedMesh *dm, int edgeNum, MEdge *med)
grid = offset / (gridSideEdges + gridInternalEdges);
offset %= (gridSideEdges + gridInternalEdges);
- if(offset < gridSideEdges) {
+ if (offset < gridSideEdges) {
x = offset;
med->v1 = getFaceIndex(ss, f, grid, x, 0, edgeSize, gridSize);
med->v2 = getFaceIndex(ss, f, grid, x+1, 0, edgeSize, gridSize);
- } else {
+ }
+ else {
offset -= gridSideEdges;
x = (offset / 2) / gridSideEdges + 1;
y = (offset / 2) % gridSideEdges;
- if(offset % 2 == 0) {
+ if (offset % 2 == 0) {
med->v1 = getFaceIndex(ss, f, grid, x, y, edgeSize, gridSize);
med->v2 = getFaceIndex(ss, f, grid, x, y+1, edgeSize, gridSize);
- } else {
+ }
+ else {
med->v1 = getFaceIndex(ss, f, grid, y, x, edgeSize, gridSize);
med->v2 = getFaceIndex(ss, f, grid, y+1, x, edgeSize, gridSize);
}
}
- } else {
+ }
+ else {
/* this vert comes from edge data */
CCGEdge *e;
int edgeSize = ccgSubSurf_getEdgeSize(ss);
@@ -889,7 +912,7 @@ static void ccgDM_getFinalEdge(DerivedMesh *dm, int edgeNum, MEdge *med)
e = ccgdm->edgeMap[i].edge;
- if(!ccgSubSurf_getEdgeNumFaces(e)) flags |= ME_LOOSEEDGE;
+ if (!ccgSubSurf_getEdgeNumFaces(e)) flags |= ME_LOOSEEDGE;
x = edgeNum - ccgdm->edgeMap[i].startEdge;
@@ -897,7 +920,7 @@ static void ccgDM_getFinalEdge(DerivedMesh *dm, int edgeNum, MEdge *med)
med->v2 = getEdgeIndex(ss, e, x+1, edgeSize);
edgeFlag = (ccgdm->edgeFlags)? &ccgdm->edgeFlags[i]: NULL;
- if(edgeFlag)
+ if (edgeFlag)
flags |= (*edgeFlag & (ME_SEAM | ME_SHARP))
| ME_EDGEDRAW | ME_EDGERENDER;
else
@@ -944,7 +967,7 @@ static void ccgDM_getFinalFace(DerivedMesh *dm, int faceNum, MFace *mf)
mf->v3 = getFaceIndex(ss, f, grid, x+1, y+1, edgeSize, gridSize);
mf->v4 = getFaceIndex(ss, f, grid, x+1, y+0, edgeSize, gridSize);
- if(faceFlags) {
+ if (faceFlags) {
mf->flag = faceFlags[i].flag;
mf->mat_nr = faceFlags[i].mat_nr;
}
@@ -964,24 +987,24 @@ void subsurf_copy_grid_hidden(DerivedMesh *dm, const MPoly *mpoly,
int totface = ccgSubSurf_getNumFaces(ss);
int i, j, x, y;
- for(i = 0; i < totface; i++) {
+ for (i = 0; i < totface; i++) {
CCGFace *f = ccgdm->faceMap[i].face;
- for(j = 0; j < mpoly[i].totloop; j++) {
+ for (j = 0; j < mpoly[i].totloop; j++) {
const MDisps *md = &mdisps[mpoly[i].loopstart + j];
int hidden_gridsize = ccg_gridsize(md->level);
int factor = ccg_factor(level, md->level);
- if(!md->hidden)
+ if (!md->hidden)
continue;
- for(y = 0; y < gridSize; y++) {
- for(x = 0; x < gridSize; x++) {
+ for (y = 0; y < gridSize; y++) {
+ for (x = 0; x < gridSize; x++) {
int vndx, offset;
vndx = getFaceIndex(ss, f, j, x, y, edgeSize, gridSize);
offset = (y*factor) * hidden_gridsize + (x*factor);
- if(BLI_BITMAP_GET(md->hidden, offset))
+ if (BLI_BITMAP_GET(md->hidden, offset))
mvert[vndx].flag |= ME_HIDE;
}
}
@@ -1001,7 +1024,7 @@ static void ccgDM_copyFinalVertArray(DerivedMesh *dm, MVert *mvert)
int i = 0;
totface = ccgSubSurf_getNumFaces(ss);
- for(index = 0; index < totface; index++) {
+ for (index = 0; index < totface; index++) {
CCGFace *f = ccgdm->faceMap[index].face;
int x, y, S, numVerts = ccgSubSurf_getFaceNumVerts(f);
@@ -1010,17 +1033,17 @@ static void ccgDM_copyFinalVertArray(DerivedMesh *dm, MVert *mvert)
normal_float_to_short_v3(mvert[i].no, vd->no);
i++;
- for(S = 0; S < numVerts; S++) {
- for(x = 1; x < gridSize - 1; x++, i++) {
+ for (S = 0; S < numVerts; S++) {
+ for (x = 1; x < gridSize - 1; x++, i++) {
vd= ccgSubSurf_getFaceGridEdgeData(ss, f, S, x);
copy_v3_v3(mvert[i].co, vd->co);
normal_float_to_short_v3(mvert[i].no, vd->no);
}
}
- for(S = 0; S < numVerts; S++) {
- for(y = 1; y < gridSize - 1; y++) {
- for(x = 1; x < gridSize - 1; x++, i++) {
+ for (S = 0; S < numVerts; S++) {
+ for (y = 1; y < gridSize - 1; y++) {
+ for (x = 1; x < gridSize - 1; x++, i++) {
vd= ccgSubSurf_getFaceGridData(ss, f, S, x, y);
copy_v3_v3(mvert[i].co, vd->co);
normal_float_to_short_v3(mvert[i].no, vd->no);
@@ -1030,11 +1053,11 @@ static void ccgDM_copyFinalVertArray(DerivedMesh *dm, MVert *mvert)
}
totedge = ccgSubSurf_getNumEdges(ss);
- for(index = 0; index < totedge; index++) {
+ for (index = 0; index < totedge; index++) {
CCGEdge *e = ccgdm->edgeMap[index].edge;
int x;
- for(x = 1; x < edgeSize - 1; x++, i++) {
+ for (x = 1; x < edgeSize - 1; x++, i++) {
vd= ccgSubSurf_getEdgeData(ss, e, x);
copy_v3_v3(mvert[i].co, vd->co);
/* This gives errors with -debug-fpe
@@ -1047,7 +1070,7 @@ static void ccgDM_copyFinalVertArray(DerivedMesh *dm, MVert *mvert)
}
totvert = ccgSubSurf_getNumVerts(ss);
- for(index = 0; index < totvert; index++) {
+ for (index = 0; index < totvert; index++) {
CCGVert *v = ccgdm->vertMap[index].vert;
vd= ccgSubSurf_getVertData(ss, v);
@@ -1069,27 +1092,27 @@ static void ccgDM_copyFinalEdgeArray(DerivedMesh *dm, MEdge *medge)
short *edgeFlags = ccgdm->edgeFlags;
totface = ccgSubSurf_getNumFaces(ss);
- for(index = 0; index < totface; index++) {
+ for (index = 0; index < totface; index++) {
CCGFace *f = ccgdm->faceMap[index].face;
int x, y, S, numVerts = ccgSubSurf_getFaceNumVerts(f);
- for(S = 0; S < numVerts; S++) {
- for(x = 0; x < gridSize - 1; x++) {
+ for (S = 0; S < numVerts; S++) {
+ for (x = 0; x < gridSize - 1; x++) {
MEdge *med = &medge[i];
- if(ccgdm->drawInteriorEdges)
+ if (ccgdm->drawInteriorEdges)
med->flag = ME_EDGEDRAW | ME_EDGERENDER;
med->v1 = getFaceIndex(ss, f, S, x, 0, edgeSize, gridSize);
med->v2 = getFaceIndex(ss, f, S, x + 1, 0, edgeSize, gridSize);
i++;
}
- for(x = 1; x < gridSize - 1; x++) {
- for(y = 0; y < gridSize - 1; y++) {
+ for (x = 1; x < gridSize - 1; x++) {
+ for (y = 0; y < gridSize - 1; y++) {
MEdge *med;
med = &medge[i];
- if(ccgdm->drawInteriorEdges)
+ if (ccgdm->drawInteriorEdges)
med->flag = ME_EDGEDRAW | ME_EDGERENDER;
med->v1 = getFaceIndex(ss, f, S, x, y,
edgeSize, gridSize);
@@ -1098,7 +1121,7 @@ static void ccgDM_copyFinalEdgeArray(DerivedMesh *dm, MEdge *medge)
i++;
med = &medge[i];
- if(ccgdm->drawInteriorEdges)
+ if (ccgdm->drawInteriorEdges)
med->flag = ME_EDGEDRAW | ME_EDGERENDER;
med->v1 = getFaceIndex(ss, f, S, y, x,
edgeSize, gridSize);
@@ -1111,24 +1134,25 @@ static void ccgDM_copyFinalEdgeArray(DerivedMesh *dm, MEdge *medge)
}
totedge = ccgSubSurf_getNumEdges(ss);
- for(index = 0; index < totedge; index++) {
+ for (index = 0; index < totedge; index++) {
CCGEdge *e = ccgdm->edgeMap[index].edge;
unsigned int flags = 0;
int x;
int edgeIdx = GET_INT_FROM_POINTER(ccgSubSurf_getEdgeEdgeHandle(e));
- if(!ccgSubSurf_getEdgeNumFaces(e)) flags |= ME_LOOSEEDGE;
+ if (!ccgSubSurf_getEdgeNumFaces(e)) flags |= ME_LOOSEEDGE;
- if(edgeFlags) {
- if(edgeIdx != -1) {
+ if (edgeFlags) {
+ if (edgeIdx != -1) {
flags |= (edgeFlags[index] & (ME_SEAM | ME_SHARP))
| ME_EDGEDRAW | ME_EDGERENDER;
}
- } else {
+ }
+ else {
flags |= ME_EDGEDRAW | ME_EDGERENDER;
}
- for(x = 0; x < edgeSize - 1; x++) {
+ for (x = 0; x < edgeSize - 1; x++) {
MEdge *med = &medge[i];
med->v1 = getEdgeIndex(ss, e, x, edgeSize);
med->v2 = getEdgeIndex(ss, e, x + 1, edgeSize);
@@ -1150,16 +1174,16 @@ static void ccgDM_copyFinalFaceArray(DerivedMesh *dm, MFace *mface)
DMFlagMat *faceFlags = ccgdm->faceFlags;
totface = ccgSubSurf_getNumFaces(ss);
- for(index = 0; index < totface; index++) {
+ for (index = 0; index < totface; index++) {
CCGFace *f = ccgdm->faceMap[index].face;
int x, y, S, numVerts = ccgSubSurf_getFaceNumVerts(f);
/* keep types in sync with MFace, avoid many conversions */
char flag = (faceFlags)? faceFlags[index].flag: ME_SMOOTH;
short mat_nr = (faceFlags)? faceFlags[index].mat_nr: 0;
- for(S = 0; S < numVerts; S++) {
- for(y = 0; y < gridSize - 1; y++) {
- for(x = 0; x < gridSize - 1; x++) {
+ for (S = 0; S < numVerts; S++) {
+ for (y = 0; y < gridSize - 1; y++) {
+ for (x = 0; x < gridSize - 1; x++) {
MFace *mf = &mface[i];
mf->v1 = getFaceIndex(ss, f, S, x + 0, y + 0,
edgeSize, gridSize);
@@ -1204,15 +1228,15 @@ static void ccgDM_copyFinalLoopArray(DerivedMesh *dm, MLoop *mloop)
totface = ccgSubSurf_getNumFaces(ss);
mv = mloop;
- for(index = 0; index < totface; index++) {
+ for (index = 0; index < totface; index++) {
CCGFace *f = ccgdm->faceMap[index].face;
int x, y, S, numVerts = ccgSubSurf_getFaceNumVerts(f);
/* int flag = (faceFlags)? faceFlags[index*2]: ME_SMOOTH; */ /* UNUSED */
/* int mat_nr = (faceFlags)? faceFlags[index*2+1]: 0; */ /* UNUSED */
- for(S = 0; S < numVerts; S++) {
- for(y = 0; y < gridSize - 1; y++) {
- for(x = 0; x < gridSize - 1; x++) {
+ for (S = 0; S < numVerts; S++) {
+ for (y = 0; y < gridSize - 1; y++) {
+ for (x = 0; x < gridSize - 1; x++) {
int v1, v2, v3, v4;
v1 = getFaceIndex(ss, f, S, x + 0, y + 0,
@@ -1258,15 +1282,15 @@ static void ccgDM_copyFinalPolyArray(DerivedMesh *dm, MPoly *mface)
DMFlagMat *faceFlags = ccgdm->faceFlags;
totface = ccgSubSurf_getNumFaces(ss);
- for(index = 0; index < totface; index++) {
+ for (index = 0; index < totface; index++) {
CCGFace *f = ccgdm->faceMap[index].face;
int x, y, S, numVerts = ccgSubSurf_getFaceNumVerts(f);
int flag = (faceFlags)? faceFlags[index].flag: ME_SMOOTH;
int mat_nr = (faceFlags)? faceFlags[index].mat_nr: 0;
- for(S = 0; S < numVerts; S++) {
- for(y = 0; y < gridSize - 1; y++) {
- for(x = 0; x < gridSize - 1; x++) {
+ for (S = 0; S < numVerts; S++) {
+ for (y = 0; y < gridSize - 1; y++) {
+ for (x = 0; x < gridSize - 1; x++) {
MPoly *mf = &mface[i];
mf->mat_nr = mat_nr;
@@ -1453,12 +1477,12 @@ static void ccgDM_drawVerts(DerivedMesh *dm)
static void ccgdm_pbvh_update(CCGDerivedMesh *ccgdm)
{
- if(ccgdm->pbvh && ccgDM_use_grid_pbvh(ccgdm)) {
+ if (ccgdm->pbvh && ccgDM_use_grid_pbvh(ccgdm)) {
CCGFace **faces;
int totface;
BLI_pbvh_get_grid_updates(ccgdm->pbvh, 1, (void***)&faces, &totface);
- if(totface) {
+ if (totface) {
ccgSubSurf_updateFromFaces(ccgdm->ss, 0, faces, totface);
ccgSubSurf_updateNormals(ccgdm->ss, faces, totface);
MEM_freeN(faces);
@@ -1486,7 +1510,7 @@ static void ccgDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int UNUSED(draw
if (!drawLooseEdges && !ccgSubSurf_getEdgeNumFaces(e))
continue;
- if(ccgdm->edgeFlags && !(ccgdm->edgeFlags[j] & ME_EDGEDRAW))
+ if (ccgdm->edgeFlags && !(ccgdm->edgeFlags[j] & ME_EDGEDRAW))
continue;
if (useAging && !(G.f&G_BACKBUFSEL)) {
@@ -1509,7 +1533,7 @@ static void ccgDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int UNUSED(draw
if (ccgdm->drawInteriorEdges) {
int totface = ccgSubSurf_getNumFaces(ss);
- for(j = 0; j < totface; j++) {
+ for (j = 0; j < totface; j++) {
CCGFace *f = ccgdm->faceMap[j].face;
int S, x, y, numVerts = ccgSubSurf_getFaceNumVerts(f);
@@ -1586,8 +1610,8 @@ static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes)
ccgdm_pbvh_update(ccgdm);
- if(ccgdm->pbvh && ccgdm->multires.mmd && !fast) {
- if(dm->numTessFaceData) {
+ if (ccgdm->pbvh && ccgdm->multires.mmd && !fast) {
+ if (dm->numTessFaceData) {
BLI_pbvh_draw(ccgdm->pbvh, partial_redraw_planes, NULL, setMaterial);
glShadeModel(GL_FLAT);
}
@@ -1595,13 +1619,13 @@ static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes)
return;
}
- for(i = 0; i < totface; i++) {
+ for (i = 0; i < totface; i++) {
CCGFace *f = ccgdm->faceMap[i].face;
int S, x, y, numVerts = ccgSubSurf_getFaceNumVerts(f);
int index = GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(f));
int new_matnr, new_shademodel;
- if(faceFlags) {
+ if (faceFlags) {
new_shademodel = (faceFlags[index].flag & ME_SMOOTH)? GL_SMOOTH: GL_FLAT;
new_matnr= faceFlags[index].mat_nr;
}
@@ -1610,7 +1634,7 @@ static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes)
new_matnr= 0;
}
- if(shademodel != new_shademodel || matnr != new_matnr) {
+ if (shademodel != new_shademodel || matnr != new_matnr) {
matnr= new_matnr;
shademodel= new_shademodel;
@@ -1619,7 +1643,7 @@ static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes)
glShadeModel(shademodel);
}
- if(!drawcurrent)
+ if (!drawcurrent)
continue;
for (S=0; S<numVerts; S++) {
@@ -1639,7 +1663,8 @@ static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes)
}
glEnd();
}
- } else {
+ }
+ else {
glBegin(GL_QUADS);
for (y=0; y<gridSize-1; y+=step) {
for (x=0; x<gridSize-1; x+=step) {
@@ -1685,28 +1710,28 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm,
matnr = -1;
#define PASSATTRIB(dx, dy, vert) { \
- if(attribs.totorco) { \
+ if (attribs.totorco) { \
index = getFaceIndex(ss, f, S, x+dx, y+dy, edgeSize, gridSize); \
glVertexAttrib3fvARB(attribs.orco.glIndex, attribs.orco.array[index]); \
} \
- for(b = 0; b < attribs.tottface; b++) { \
+ for (b = 0; b < attribs.tottface; b++) { \
MTFace *tf = &attribs.tface[b].array[a]; \
glVertexAttrib2fvARB(attribs.tface[b].glIndex, tf->uv[vert]); \
} \
- for(b = 0; b < attribs.totmcol; b++) { \
+ for (b = 0; b < attribs.totmcol; b++) { \
MCol *cp = &attribs.mcol[b].array[a*4 + vert]; \
GLubyte col[4]; \
col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a; \
glVertexAttrib4ubvARB(attribs.mcol[b].glIndex, col); \
} \
- if(attribs.tottang) { \
+ if (attribs.tottang) { \
float *tang = attribs.tang.array[a*4 + vert]; \
glVertexAttrib4fvARB(attribs.tang.glIndex, tang); \
} \
}
totface = ccgSubSurf_getNumFaces(ss);
- for(a = 0, i = 0; i < totface; i++) {
+ for (a = 0, i = 0; i < totface; i++) {
CCGFace *f = ccgdm->faceMap[i].face;
int S, x, y, drawSmooth;
int index = GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(f));
@@ -1714,7 +1739,7 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm,
numVerts = ccgSubSurf_getFaceNumVerts(f);
- if(faceFlags) {
+ if (faceFlags) {
drawSmooth = (faceFlags[index].flag & ME_SMOOTH);
new_matnr= faceFlags[index].mat_nr + 1;
}
@@ -1723,13 +1748,13 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm,
new_matnr= 1;
}
- if(new_matnr != matnr) {
+ if (new_matnr != matnr) {
doDraw = setMaterial(matnr = new_matnr, &gattribs);
- if(doDraw)
+ if (doDraw)
DM_vertex_attributes_from_gpu(dm, &gattribs, &attribs);
}
- if(!doDraw || (setDrawOptions && (origIndex != ORIGINDEX_NONE) &&
+ if (!doDraw || (setDrawOptions && (origIndex != ORIGINDEX_NONE) &&
(setDrawOptions(userData, origIndex) == DM_DRAW_OPTION_SKIP))) {
a += gridFaces*gridFaces*numVerts;
continue;
@@ -1755,7 +1780,7 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm,
glNormal3fv(vdb->no);
glVertex3fv(vdb->co);
- if(x != gridFaces-1)
+ if (x != gridFaces-1)
a++;
}
@@ -1774,7 +1799,8 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm,
a++;
}
- } else {
+ }
+ else {
glBegin(GL_QUADS);
for (y=0; y<gridFaces; y++) {
for (x=0; x<gridFaces; x++) {
@@ -1828,34 +1854,34 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, void (*setMaterial)(void *
matnr = -1;
#define PASSATTRIB(dx, dy, vert) { \
- if(attribs.totorco) { \
+ if (attribs.totorco) { \
index = getFaceIndex(ss, f, S, x+dx, y+dy, edgeSize, gridSize); \
- if(attribs.orco.glTexco) \
+ if (attribs.orco.glTexco) \
glTexCoord3fv(attribs.orco.array[index]); \
else \
glVertexAttrib3fvARB(attribs.orco.glIndex, attribs.orco.array[index]); \
} \
- for(b = 0; b < attribs.tottface; b++) { \
+ for (b = 0; b < attribs.tottface; b++) { \
MTFace *tf = &attribs.tface[b].array[a]; \
- if(attribs.tface[b].glTexco) \
+ if (attribs.tface[b].glTexco) \
glTexCoord2fv(tf->uv[vert]); \
else \
glVertexAttrib2fvARB(attribs.tface[b].glIndex, tf->uv[vert]); \
} \
- for(b = 0; b < attribs.totmcol; b++) { \
+ for (b = 0; b < attribs.totmcol; b++) { \
MCol *cp = &attribs.mcol[b].array[a*4 + vert]; \
GLubyte col[4]; \
col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a; \
glVertexAttrib4ubvARB(attribs.mcol[b].glIndex, col); \
} \
- if(attribs.tottang) { \
+ if (attribs.tottang) { \
float *tang = attribs.tang.array[a*4 + vert]; \
glVertexAttrib4fvARB(attribs.tang.glIndex, tang); \
} \
}
totface = ccgSubSurf_getNumFaces(ss);
- for(a = 0, i = 0; i < totface; i++) {
+ for (a = 0, i = 0; i < totface; i++) {
CCGFace *f = ccgdm->faceMap[i].face;
int S, x, y, drawSmooth;
int index = GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(f));
@@ -1864,7 +1890,7 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, void (*setMaterial)(void *
numVerts = ccgSubSurf_getFaceNumVerts(f);
/* get flags */
- if(faceFlags) {
+ if (faceFlags) {
drawSmooth = (faceFlags[index].flag & ME_SMOOTH);
new_matnr= faceFlags[index].mat_nr + 1;
}
@@ -1874,13 +1900,13 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, void (*setMaterial)(void *
}
/* material */
- if(new_matnr != matnr) {
+ if (new_matnr != matnr) {
setMaterial(userData, matnr = new_matnr, &gattribs);
DM_vertex_attributes_from_gpu(dm, &gattribs, &attribs);
}
/* face hiding */
- if((setFace && (origIndex != ORIGINDEX_NONE) && !setFace(userData, origIndex))) {
+ if ((setFace && (origIndex != ORIGINDEX_NONE) && !setFace(userData, origIndex))) {
a += gridFaces*gridFaces*numVerts;
continue;
}
@@ -1906,7 +1932,7 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, void (*setMaterial)(void *
glNormal3fv(vdb->no);
glVertex3fv(vdb->co);
- if(x != gridFaces-1)
+ if (x != gridFaces-1)
a++;
}
@@ -1925,7 +1951,8 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, void (*setMaterial)(void *
a++;
}
- } else {
+ }
+ else {
glBegin(GL_QUADS);
for (y=0; y<gridFaces; y++) {
for (x=0; x<gridFaces; x++) {
@@ -1975,14 +2002,14 @@ static void ccgDM_drawFacesTex_common(DerivedMesh *dm,
ccgdm_pbvh_update(ccgdm);
- if(!mcol)
+ if (!mcol)
mcol = dm->getTessFaceDataArray(dm, CD_MCOL);
- if(!mcol)
+ if (!mcol)
mcol = dm->getTessFaceDataArray(dm, CD_TEXTURE_MCOL);
totface = ccgSubSurf_getNumFaces(ss);
- for(i = 0; i < totface; i++) {
+ for (i = 0; i < totface; i++) {
CCGFace *f = ccgdm->faceMap[i].face;
int S, x, y, numVerts = ccgSubSurf_getFaceNumVerts(f);
int drawSmooth, index = ccgDM_getFaceMapIndex(ss, f);
@@ -1990,7 +2017,7 @@ static void ccgDM_drawFacesTex_common(DerivedMesh *dm,
unsigned char *cp= NULL;
int mat_nr;
- if(faceFlags) {
+ if (faceFlags) {
drawSmooth = (faceFlags[origIndex].flag & ME_SMOOTH);
mat_nr= faceFlags[origIndex].mat_nr;
}
@@ -1999,7 +2026,7 @@ static void ccgDM_drawFacesTex_common(DerivedMesh *dm,
mat_nr= 0;
}
- if(drawParams)
+ if (drawParams)
draw_option = drawParams(tf, (mcol != NULL), mat_nr);
else if (index != ORIGINDEX_NONE)
draw_option= (drawParamsMapped)? drawParamsMapped(userData, index): DM_DRAW_OPTION_NORMAL;
@@ -2008,14 +2035,14 @@ static void ccgDM_drawFacesTex_common(DerivedMesh *dm,
if (draw_option == DM_DRAW_OPTION_SKIP) {
- if(tf) tf += gridFaces*gridFaces*numVerts;
- if(mcol) mcol += gridFaces*gridFaces*numVerts*4;
+ if (tf) tf += gridFaces*gridFaces*numVerts;
+ if (mcol) mcol += gridFaces*gridFaces*numVerts*4;
continue;
}
/* flag 1 == use vertex colors */
- if(mcol) {
- if(draw_option != DM_DRAW_OPTION_NO_MCOL)
+ if (mcol) {
+ if (draw_option != DM_DRAW_OPTION_NO_MCOL)
cp= (unsigned char*)mcol;
mcol += gridFaces*gridFaces*numVerts*4;
}
@@ -2032,41 +2059,42 @@ static void ccgDM_drawFacesTex_common(DerivedMesh *dm,
a = &faceGridData[(y+0)*gridSize + x];
b = &faceGridData[(y+1)*gridSize + x];
- if(tf) glTexCoord2fv(tf->uv[0]);
- if(cp) glColor3ub(cp[3], cp[2], cp[1]);
+ if (tf) glTexCoord2fv(tf->uv[0]);
+ if (cp) glColor3ub(cp[3], cp[2], cp[1]);
glNormal3fv(a->no);
glVertex3fv(a->co);
- if(tf) glTexCoord2fv(tf->uv[1]);
- if(cp) glColor3ub(cp[7], cp[6], cp[5]);
+ if (tf) glTexCoord2fv(tf->uv[1]);
+ if (cp) glColor3ub(cp[7], cp[6], cp[5]);
glNormal3fv(b->no);
glVertex3fv(b->co);
- if(x != gridFaces-1) {
- if(tf) tf++;
- if(cp) cp += 16;
+ if (x != gridFaces-1) {
+ if (tf) tf++;
+ if (cp) cp += 16;
}
}
a = &faceGridData[(y+0)*gridSize + x];
b = &faceGridData[(y+1)*gridSize + x];
- if(tf) glTexCoord2fv(tf->uv[3]);
- if(cp) glColor3ub(cp[15], cp[14], cp[13]);
+ if (tf) glTexCoord2fv(tf->uv[3]);
+ if (cp) glColor3ub(cp[15], cp[14], cp[13]);
glNormal3fv(a->no);
glVertex3fv(a->co);
- if(tf) glTexCoord2fv(tf->uv[2]);
- if(cp) glColor3ub(cp[11], cp[10], cp[9]);
+ if (tf) glTexCoord2fv(tf->uv[2]);
+ if (cp) glColor3ub(cp[11], cp[10], cp[9]);
glNormal3fv(b->no);
glVertex3fv(b->co);
- if(tf) tf++;
- if(cp) cp += 16;
+ if (tf) tf++;
+ if (cp) cp += 16;
glEnd();
}
- } else {
+ }
+ else {
glShadeModel(GL_FLAT);
glBegin(GL_QUADS);
for (y=0; y<gridFaces; y++) {
@@ -2078,24 +2106,24 @@ static void ccgDM_drawFacesTex_common(DerivedMesh *dm,
ccgDM_glNormalFast(a_co, b_co, c_co, d_co);
- if(tf) glTexCoord2fv(tf->uv[1]);
- if(cp) glColor3ub(cp[7], cp[6], cp[5]);
+ if (tf) glTexCoord2fv(tf->uv[1]);
+ if (cp) glColor3ub(cp[7], cp[6], cp[5]);
glVertex3fv(d_co);
- if(tf) glTexCoord2fv(tf->uv[2]);
- if(cp) glColor3ub(cp[11], cp[10], cp[9]);
+ if (tf) glTexCoord2fv(tf->uv[2]);
+ if (cp) glColor3ub(cp[11], cp[10], cp[9]);
glVertex3fv(c_co);
- if(tf) glTexCoord2fv(tf->uv[3]);
- if(cp) glColor3ub(cp[15], cp[14], cp[13]);
+ if (tf) glTexCoord2fv(tf->uv[3]);
+ if (cp) glColor3ub(cp[15], cp[14], cp[13]);
glVertex3fv(b_co);
- if(tf) glTexCoord2fv(tf->uv[0]);
- if(cp) glColor3ub(cp[3], cp[2], cp[1]);
+ if (tf) glTexCoord2fv(tf->uv[0]);
+ if (cp) glColor3ub(cp[3], cp[2], cp[1]);
glVertex3fv(a_co);
- if(tf) tf++;
- if(cp) cp += 16;
+ if (tf) tf++;
+ if (cp) cp += 16;
}
}
glEnd();
@@ -2129,18 +2157,19 @@ static void ccgDM_drawUVEdges(DerivedMesh *dm)
if (tf) {
glBegin(GL_LINES);
- for(i = 0; i < dm->numTessFaceData; i++, mf++, tf++) {
- if(!(mf->flag&ME_HIDE)) {
+ for (i = 0; i < dm->numTessFaceData; i++, mf++, tf++) {
+ if (!(mf->flag&ME_HIDE)) {
glVertex2fv(tf->uv[0]);
glVertex2fv(tf->uv[1]);
glVertex2fv(tf->uv[1]);
glVertex2fv(tf->uv[2]);
- if(!mf->v4) {
+ if (!mf->v4) {
glVertex2fv(tf->uv[2]);
glVertex2fv(tf->uv[0]);
- } else {
+ }
+ else {
glVertex2fv(tf->uv[2]);
glVertex2fv(tf->uv[3]);
@@ -2170,14 +2199,14 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm,
/* currently unused -- each original face is handled separately */
(void)compareDrawOptions;
- if(useColors) {
+ if (useColors) {
mcol = dm->getTessFaceDataArray(dm, CD_PREVIEW_MCOL);
- if(!mcol)
+ if (!mcol)
mcol = dm->getTessFaceDataArray(dm, CD_MCOL);
}
totface = ccgSubSurf_getNumFaces(ss);
- for(i = 0; i < totface; i++) {
+ for (i = 0; i < totface; i++) {
CCGFace *f = ccgdm->faceMap[i].face;
int S, x, y, numVerts = ccgSubSurf_getFaceNumVerts(f);
int drawSmooth, index = ccgDM_getFaceMapIndex(ss, f);
@@ -2186,11 +2215,11 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm,
origIndex = GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(f));
- if(flag & DM_DRAW_ALWAYS_SMOOTH) drawSmooth = 1;
- else if(faceFlags) drawSmooth = (faceFlags[origIndex].flag & ME_SMOOTH);
+ if (flag & DM_DRAW_ALWAYS_SMOOTH) drawSmooth = 1;
+ else if (faceFlags) drawSmooth = (faceFlags[origIndex].flag & ME_SMOOTH);
else drawSmooth = 1;
- if(mcol) {
+ if (mcol) {
cp= (unsigned char*)mcol;
mcol += gridFaces*gridFaces*numVerts*4;
}
@@ -2198,7 +2227,7 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm,
{
DMDrawOption draw_option= DM_DRAW_OPTION_NORMAL;
- if(index == ORIGINDEX_NONE)
+ if (index == ORIGINDEX_NONE)
draw_option= setMaterial(faceFlags ? faceFlags[origIndex].mat_nr + 1: 1, NULL); /* XXX, no faceFlags no material */
else if (setDrawOptions)
draw_option= setDrawOptions(userData, index);
@@ -2223,33 +2252,34 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm,
a = &faceGridData[(y+0)*gridSize + x];
b = &faceGridData[(y+1)*gridSize + x];
- if(cp) glColor3ub(cp[3], cp[2], cp[1]);
+ if (cp) glColor3ub(cp[3], cp[2], cp[1]);
glNormal3fv(a->no);
glVertex3fv(a->co);
- if(cp) glColor3ub(cp[7], cp[6], cp[5]);
+ if (cp) glColor3ub(cp[7], cp[6], cp[5]);
glNormal3fv(b->no);
glVertex3fv(b->co);
- if(x != gridFaces-1) {
- if(cp) cp += 16;
+ if (x != gridFaces-1) {
+ if (cp) cp += 16;
}
}
a = &faceGridData[(y+0)*gridSize + x];
b = &faceGridData[(y+1)*gridSize + x];
- if(cp) glColor3ub(cp[15], cp[14], cp[13]);
+ if (cp) glColor3ub(cp[15], cp[14], cp[13]);
glNormal3fv(a->no);
glVertex3fv(a->co);
- if(cp) glColor3ub(cp[11], cp[10], cp[9]);
+ if (cp) glColor3ub(cp[11], cp[10], cp[9]);
glNormal3fv(b->no);
glVertex3fv(b->co);
- if(cp) cp += 16;
+ if (cp) cp += 16;
glEnd();
}
- } else {
+ }
+ else {
glBegin(GL_QUADS);
for (y=0; y<gridFaces; y++) {
for (x=0; x<gridFaces; x++) {
@@ -2260,16 +2290,16 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm,
ccgDM_glNormalFast(a, b, c, d);
- if(cp) glColor3ub(cp[7], cp[6], cp[5]);
+ if (cp) glColor3ub(cp[7], cp[6], cp[5]);
glVertex3fv(d);
- if(cp) glColor3ub(cp[11], cp[10], cp[9]);
+ if (cp) glColor3ub(cp[11], cp[10], cp[9]);
glVertex3fv(c);
- if(cp) glColor3ub(cp[15], cp[14], cp[13]);
+ if (cp) glColor3ub(cp[15], cp[14], cp[13]);
glVertex3fv(b);
- if(cp) glColor3ub(cp[3], cp[2], cp[1]);
+ if (cp) glColor3ub(cp[3], cp[2], cp[1]);
glVertex3fv(a);
- if(cp) cp += 16;
+ if (cp) cp += 16;
}
}
glEnd();
@@ -2379,16 +2409,16 @@ static void ccgDM_release(DerivedMesh *dm)
if (DM_release(dm)) {
/* Before freeing, need to update the displacement map */
- if(ccgdm->multires.modified_flags) {
+ if (ccgdm->multires.modified_flags) {
/* Check that mmd still exists */
- if(!ccgdm->multires.local_mmd &&
+ if (!ccgdm->multires.local_mmd &&
BLI_findindex(&ccgdm->multires.ob->modifiers, ccgdm->multires.mmd) < 0)
ccgdm->multires.mmd = NULL;
- if(ccgdm->multires.mmd) {
- if(ccgdm->multires.modified_flags & MULTIRES_COORDS_MODIFIED)
+ if (ccgdm->multires.mmd) {
+ if (ccgdm->multires.modified_flags & MULTIRES_COORDS_MODIFIED)
multires_modifier_update_mdisps(dm);
- if(ccgdm->multires.modified_flags & MULTIRES_HIDDEN_MODIFIED)
+ if (ccgdm->multires.modified_flags & MULTIRES_HIDDEN_MODIFIED)
multires_modifier_update_hidden(dm);
}
}
@@ -2396,23 +2426,23 @@ static void ccgDM_release(DerivedMesh *dm)
if (ccgdm->ehash)
BLI_edgehash_free(ccgdm->ehash, NULL);
- if(ccgdm->reverseFaceMap) MEM_freeN(ccgdm->reverseFaceMap);
- if(ccgdm->gridFaces) MEM_freeN(ccgdm->gridFaces);
- if(ccgdm->gridData) MEM_freeN(ccgdm->gridData);
- if(ccgdm->gridAdjacency) MEM_freeN(ccgdm->gridAdjacency);
- if(ccgdm->gridOffset) MEM_freeN(ccgdm->gridOffset);
- if(ccgdm->gridFlagMats) MEM_freeN(ccgdm->gridFlagMats);
- if(ccgdm->gridHidden) {
+ if (ccgdm->reverseFaceMap) MEM_freeN(ccgdm->reverseFaceMap);
+ if (ccgdm->gridFaces) MEM_freeN(ccgdm->gridFaces);
+ if (ccgdm->gridData) MEM_freeN(ccgdm->gridData);
+ if (ccgdm->gridAdjacency) MEM_freeN(ccgdm->gridAdjacency);
+ if (ccgdm->gridOffset) MEM_freeN(ccgdm->gridOffset);
+ if (ccgdm->gridFlagMats) MEM_freeN(ccgdm->gridFlagMats);
+ if (ccgdm->gridHidden) {
int i, numGrids = dm->getNumGrids(dm);
- for(i = 0; i < numGrids; i++) {
- if(ccgdm->gridHidden[i])
+ for (i = 0; i < numGrids; i++) {
+ if (ccgdm->gridHidden[i])
MEM_freeN(ccgdm->gridHidden[i]);
}
MEM_freeN(ccgdm->gridHidden);
}
- if(ccgdm->freeSS) ccgSubSurf_free(ccgdm->ss);
- if(ccgdm->pmap) MEM_freeN(ccgdm->pmap);
- if(ccgdm->pmap_mem) MEM_freeN(ccgdm->pmap_mem);
+ if (ccgdm->freeSS) ccgSubSurf_free(ccgdm->ss);
+ if (ccgdm->pmap) MEM_freeN(ccgdm->pmap);
+ if (ccgdm->pmap_mem) MEM_freeN(ccgdm->pmap_mem);
MEM_freeN(ccgdm->edgeFlags);
MEM_freeN(ccgdm->faceFlags);
MEM_freeN(ccgdm->vertMap);
@@ -2433,7 +2463,7 @@ static void ccg_loops_to_corners(CustomData *fdata, CustomData *ldata,
MLoopUV *mloopuv;
int i, j;
- for(i=0; i < numTex; i++) {
+ for (i=0; i < numTex; i++) {
texface = CustomData_get_n(fdata, CD_MTFACE, findex, i);
texpoly = CustomData_get_n(pdata, CD_MTEXPOLY, polyindex, i);
@@ -2445,7 +2475,7 @@ static void ccg_loops_to_corners(CustomData *fdata, CustomData *ldata,
}
}
- for(i=0; i < numCol; i++) {
+ for (i=0; i < numCol; i++) {
mloopcol = CustomData_get_n(ldata, CD_MLOOPCOL, loopstart, i);
mcol = CustomData_get_n(fdata, CD_MCOL, findex, i);
@@ -2476,7 +2506,7 @@ static void ccg_loops_to_corners(CustomData *fdata, CustomData *ldata,
static void *ccgDM_get_vert_data_layer(DerivedMesh *dm, int type)
{
- if(type == CD_ORIGINDEX) {
+ if (type == CD_ORIGINDEX) {
/* create origindex on demand to save memory */
CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm;
CCGSubSurf *ss= ccgdm->ss;
@@ -2496,10 +2526,10 @@ static void *ccgDM_get_vert_data_layer(DerivedMesh *dm, int type)
totnone= dm->numVertData - totorig;
/* original vertices are at the end */
- for(a=0; a<totnone; a++)
+ for (a=0; a<totnone; a++)
origindex[a]= ORIGINDEX_NONE;
- for(index=0; index<totorig; index++, a++) {
+ for (index=0; index<totorig; index++, a++) {
CCGVert *v = ccgdm->vertMap[index].vert;
origindex[a] = ccgDM_getVertMapIndex(ccgdm->ss, v);
}
@@ -2512,7 +2542,7 @@ static void *ccgDM_get_vert_data_layer(DerivedMesh *dm, int type)
static void *ccgDM_get_edge_data_layer(DerivedMesh *dm, int type)
{
- if(type == CD_ORIGINDEX) {
+ if (type == CD_ORIGINDEX) {
/* create origindex on demand to save memory */
CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm;
CCGSubSurf *ss= ccgdm->ss;
@@ -2534,14 +2564,14 @@ static void *ccgDM_get_edge_data_layer(DerivedMesh *dm, int type)
totnone= dm->numEdgeData - totorig;
/* original edges are at the end */
- for(a=0; a<totnone; a++)
+ for (a=0; a<totnone; a++)
origindex[a]= ORIGINDEX_NONE;
- for(index=0; index<totedge; index++) {
+ for (index=0; index<totedge; index++) {
CCGEdge *e= ccgdm->edgeMap[index].edge;
int mapIndex= ccgDM_getEdgeMapIndex(ss, e);
- for(i = 0; i < edgeSize - 1; i++, a++)
+ for (i = 0; i < edgeSize - 1; i++, a++)
origindex[a]= mapIndex;
}
@@ -2553,7 +2583,7 @@ static void *ccgDM_get_edge_data_layer(DerivedMesh *dm, int type)
static void *ccgDM_get_tessface_data_layer(DerivedMesh *dm, int type)
{
- if(type == CD_ORIGINDEX) {
+ if (type == CD_ORIGINDEX) {
/* create origindex on demand to save memory */
CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm;
CCGSubSurf *ss= ccgdm->ss;
@@ -2572,12 +2602,12 @@ static void *ccgDM_get_tessface_data_layer(DerivedMesh *dm, int type)
totface= ccgSubSurf_getNumFaces(ss);
- for(a=0, index=0; index<totface; index++) {
+ for (a=0, index=0; index<totface; index++) {
CCGFace *f = ccgdm->faceMap[index].face;
int numVerts = ccgSubSurf_getFaceNumVerts(f);
int mapIndex = ccgDM_getFaceMapIndex(ss, f);
- for(i=0; i<gridFaces*gridFaces*numVerts; i++, a++)
+ for (i=0; i<gridFaces*gridFaces*numVerts; i++, a++)
origindex[a]= mapIndex;
}
@@ -2625,7 +2655,7 @@ static int ccgDM_getNumGrids(DerivedMesh *dm)
numFaces= ccgSubSurf_getNumFaces(ccgdm->ss);
numGrids= 0;
- for(index=0; index<numFaces; index++) {
+ for (index=0; index<numFaces; index++) {
CCGFace *f = ccgdm->faceMap[index].face;
numGrids += ccgSubSurf_getFaceNumVerts(f);
}
@@ -2648,24 +2678,24 @@ static int ccgdm_adjacent_grid(int *gridOffset, CCGFace *f, int S, int offset)
e = ccgSubSurf_getFaceEdge(f, S);
numFaces = ccgSubSurf_getEdgeNumFaces(e);
- if(numFaces != 2)
+ if (numFaces != 2)
return -1;
- for(i = 0; i < numFaces; i++) {
+ for (i = 0; i < numFaces; i++) {
adjf = ccgSubSurf_getEdgeFace(e, i);
- if(adjf != f) {
+ if (adjf != f) {
numEdges = ccgSubSurf_getFaceNumVerts(adjf);
- for(j = 0; j < numEdges; j++)
- if(ccgSubSurf_getFaceEdge(adjf, j) == e)
+ for (j = 0; j < numEdges; j++)
+ if (ccgSubSurf_getFaceEdge(adjf, j) == e)
break;
- if(j != numEdges)
+ if (j != numEdges)
break;
}
}
- if(numEdges == 0)
+ if (numEdges == 0)
return -1;
fIndex = GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(adjf));
@@ -2684,7 +2714,7 @@ static void ccgdm_create_grids(DerivedMesh *dm)
int *gridOffset;
int index, numFaces, numGrids, S, gIndex /*, gridSize*/;
- if(ccgdm->gridData)
+ if (ccgdm->gridData)
return;
numGrids = ccgDM_getNumGrids(dm);
@@ -2694,7 +2724,7 @@ static void ccgdm_create_grids(DerivedMesh *dm)
/* compute offset into grid array for each face */
gridOffset = MEM_mallocN(sizeof(int)*numFaces, "ccgdm.gridOffset");
- for(gIndex = 0, index = 0; index < numFaces; index++) {
+ for (gIndex = 0, index = 0; index < numFaces; index++) {
CCGFace *f = ccgdm->faceMap[index].face;
int numVerts = ccgSubSurf_getFaceNumVerts(f);
@@ -2710,11 +2740,11 @@ static void ccgdm_create_grids(DerivedMesh *dm)
ccgdm->gridHidden = MEM_callocN(sizeof(BLI_bitmap)*numGrids, "ccgdm.gridHidden");
- for(gIndex = 0, index = 0; index < numFaces; index++) {
+ for (gIndex = 0, index = 0; index < numFaces; index++) {
CCGFace *f = ccgdm->faceMap[index].face;
int numVerts = ccgSubSurf_getFaceNumVerts(f);
- for(S = 0; S < numVerts; S++, gIndex++) {
+ for (S = 0; S < numVerts; S++, gIndex++) {
int prevS = (S - 1 + numVerts) % numVerts;
int nextS = (S + 1 + numVerts) % numVerts;
@@ -2786,7 +2816,7 @@ static const MeshElemMap *ccgDM_getPolyMap(Object *ob, DerivedMesh *dm)
{
CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm;
- if(!ccgdm->multires.mmd && !ccgdm->pmap && ob->type == OB_MESH) {
+ if (!ccgdm->multires.mmd && !ccgdm->pmap && ob->type == OB_MESH) {
Mesh *me= ob->data;
create_vert_poly_map(&ccgdm->pmap, &ccgdm->pmap_mem,
@@ -2803,7 +2833,7 @@ static int ccgDM_use_grid_pbvh(CCGDerivedMesh *ccgdm)
/* both of multires and subsurf modifiers are CCG, but
* grids should only be used when sculpting on multires */
- if(!mmd)
+ if (!mmd)
return 0;
return 1;
@@ -2814,18 +2844,18 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm)
CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm;
int gridSize, numGrids, grid_pbvh;
- if(!ob) {
+ if (!ob) {
ccgdm->pbvh= NULL;
return NULL;
}
- if(!ob->sculpt)
+ if (!ob->sculpt)
return NULL;
grid_pbvh= ccgDM_use_grid_pbvh(ccgdm);
- if(ob->sculpt->pbvh) {
- if(grid_pbvh) {
+ if (ob->sculpt->pbvh) {
+ if (grid_pbvh) {
/* pbvh's grids, gridadj and gridfaces points to data inside ccgdm
* but this can be freed on ccgdm release, this updates the pointers
* when the ccgdm gets remade, the assumption is that the topology
@@ -2837,13 +2867,13 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm)
ccgdm->pbvh = ob->sculpt->pbvh;
}
- if(ccgdm->pbvh)
+ if (ccgdm->pbvh)
return ccgdm->pbvh;
/* no pbvh exists yet, we need to create one. only in case of multires
* we build a pbvh over the modified mesh, in other cases the base mesh
* is being sculpted, so we build a pbvh from that. */
- if(grid_pbvh) {
+ if (grid_pbvh) {
ccgdm_create_grids(dm);
gridSize = ccgDM_getGridSize(dm);
@@ -2852,7 +2882,8 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm)
ob->sculpt->pbvh= ccgdm->pbvh = BLI_pbvh_new();
BLI_pbvh_build_grids(ccgdm->pbvh, ccgdm->gridData, ccgdm->gridAdjacency,
numGrids, gridSize, (void**)ccgdm->gridFaces, ccgdm->gridFlagMats, ccgdm->gridHidden);
- } else if(ob->type == OB_MESH) {
+ }
+ else if (ob->type == OB_MESH) {
Mesh *me= ob->data;
ob->sculpt->pbvh= ccgdm->pbvh = BLI_pbvh_new();
BLI_assert(!(me->mface == NULL && me->mpoly != NULL)); /* BMESH ONLY complain if mpoly is valid but not mface */
@@ -3010,7 +3041,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
totvert = ccgSubSurf_getNumVerts(ss);
ccgdm->vertMap = MEM_mallocN(totvert * sizeof(*ccgdm->vertMap), "vertMap");
vi = ccgSubSurf_getVertIterator(ss);
- for(; !ccgVertIterator_isStopped(vi); ccgVertIterator_next(vi)) {
+ for (; !ccgVertIterator_isStopped(vi); ccgVertIterator_next(vi)) {
CCGVert *v = ccgVertIterator_getCurrent(vi);
ccgdm->vertMap[GET_INT_FROM_POINTER(ccgSubSurf_getVertVertHandle(v))].vert = v;
@@ -3020,7 +3051,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
totedge = ccgSubSurf_getNumEdges(ss);
ccgdm->edgeMap = MEM_mallocN(totedge * sizeof(*ccgdm->edgeMap), "edgeMap");
ei = ccgSubSurf_getEdgeIterator(ss);
- for(; !ccgEdgeIterator_isStopped(ei); ccgEdgeIterator_next(ei)) {
+ for (; !ccgEdgeIterator_isStopped(ei); ccgEdgeIterator_next(ei)) {
CCGEdge *e = ccgEdgeIterator_getCurrent(ei);
ccgdm->edgeMap[GET_INT_FROM_POINTER(ccgSubSurf_getEdgeEdgeHandle(e))].edge = e;
@@ -3029,7 +3060,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
totface = ccgSubSurf_getNumFaces(ss);
ccgdm->faceMap = MEM_mallocN(totface * sizeof(*ccgdm->faceMap), "faceMap");
fi = ccgSubSurf_getFaceIterator(ss);
- for(; !ccgFaceIterator_isStopped(fi); ccgFaceIterator_next(fi)) {
+ for (; !ccgFaceIterator_isStopped(fi); ccgFaceIterator_next(fi)) {
CCGFace *f = ccgFaceIterator_getCurrent(fi);
ccgdm->faceMap[GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(f))].face = f;
@@ -3129,8 +3160,8 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
++vertNum;
/*interpolate per-vert data*/
- for(s = 0; s < numVerts; s++) {
- for(x = 1; x < gridFaces; x++) {
+ for (s = 0; s < numVerts; s++) {
+ for (x = 1; x < gridFaces; x++) {
w2 = w + s*numVerts*g2_wid*g2_wid + x*numVerts;
DM_interp_vert_data(dm, &ccgdm->dm, vertidx, w2,
numVerts, vertNum);
@@ -3145,9 +3176,9 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
}
/*interpolate per-vert data*/
- for(s = 0; s < numVerts; s++) {
- for(y = 1; y < gridFaces; y++) {
- for(x = 1; x < gridFaces; x++) {
+ for (s = 0; s < numVerts; s++) {
+ for (y = 1; y < gridFaces; y++) {
+ for (x = 1; x < gridFaces; x++) {
w2 = w + s*numVerts*g2_wid*g2_wid + (y*g2_wid+x)*numVerts;
DM_interp_vert_data(dm, &ccgdm->dm, vertidx, w2,
numVerts, vertNum);
@@ -3163,7 +3194,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
}
if (has_edge_origindex) {
- for(i = 0; i < numFinalEdges; ++i)
+ for (i = 0; i < numFinalEdges; ++i)
*(int *)DM_get_edge_data(&ccgdm->dm, edgeNum + i,
CD_ORIGINDEX) = ORIGINDEX_NONE;
}
@@ -3223,7 +3254,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
edgeNum += numFinalEdges;
}
- for(index = 0; index < totedge; ++index) {
+ for (index = 0; index < totedge; ++index) {
CCGEdge *e = ccgdm->edgeMap[index].edge;
int numFinalEdges = edgeSize - 1;
int mapIndex = ccgDM_getEdgeMapIndex(ss, e);
@@ -3240,13 +3271,13 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
ccgdm->edgeMap[index].startVert = vertNum;
ccgdm->edgeMap[index].startEdge = edgeNum;
- if(edgeIdx >= 0 && edgeFlags)
+ if (edgeIdx >= 0 && edgeFlags)
edgeFlags[edgeIdx] = medge[edgeIdx].flag;
/* set the edge base vert */
*((int*)ccgSubSurf_getEdgeUserData(ss, e)) = vertNum;
- for(x = 1; x < edgeSize - 1; x++) {
+ for (x = 1; x < edgeSize - 1; x++) {
float w[2];
w[1] = (float) x / (edgeSize - 1);
w[0] = 1 - w[1];
@@ -3258,7 +3289,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
++vertNum;
}
- for(i = 0; i < numFinalEdges; ++i) {
+ for (i = 0; i < numFinalEdges; ++i) {
if (has_edge_origindex) {
*(int *)DM_get_edge_data(&ccgdm->dm, edgeNum + i,
CD_ORIGINDEX) = mapIndex;
@@ -3268,7 +3299,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
edgeNum += numFinalEdges;
}
- if(useSubsurfUv) {
+ if (useSubsurfUv) {
CustomData *ldata = &ccgdm->dm.loopData;
CustomData *dmldata = &dm->loopData;
int numlayer = CustomData_number_of_layers(ldata, CD_MLOOPUV);
@@ -3278,7 +3309,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
set_subsurf_uv(ss, dm, &ccgdm->dm, i);
}
- for(index = 0; index < totvert; ++index) {
+ for (index = 0; index < totvert; ++index) {
CCGVert *v = ccgdm->vertMap[index].vert;
int mapIndex = ccgDM_getVertMapIndex(ccgdm->ss, v);
int vertIdx;
@@ -3329,7 +3360,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived(
int drawInteriorEdges = !(smd->flags & eSubsurfModifierFlag_ControlEdges);
CCGDerivedMesh *result;
- if(forEditMode) {
+ if (forEditMode) {
int levels= (smd->modifier.scene)? get_render_subsurf_level(&smd->modifier.scene->r, smd->levels): smd->levels;
smd->emCache = _getSubSurf(smd->emCache, levels, useAging|CCG_CALC_NORMALS);
@@ -3338,12 +3369,13 @@ struct DerivedMesh *subsurf_make_derived_from_derived(
result = getCCGDerivedMesh(smd->emCache,
drawInteriorEdges,
useSubsurfUv, dm);
- } else if(useRenderParams) {
+ }
+ else if (useRenderParams) {
/* Do not use cache in render mode. */
CCGSubSurf *ss;
int levels= (smd->modifier.scene)? get_render_subsurf_level(&smd->modifier.scene->r, smd->renderLevels): smd->renderLevels;
- if(levels == 0)
+ if (levels == 0)
return dm;
ss = _getSubSurf(NULL, levels, CCG_USE_ARENA|CCG_CALC_NORMALS);
@@ -3354,7 +3386,8 @@ struct DerivedMesh *subsurf_make_derived_from_derived(
drawInteriorEdges, useSubsurfUv, dm);
result->freeSS = 1;
- } else {
+ }
+ else {
int useIncremental = (smd->flags & eSubsurfModifierFlag_Incremental);
int levels= (smd->modifier.scene)? get_render_subsurf_level(&smd->modifier.scene->r, smd->levels): smd->levels;
CCGSubSurf *ss;
@@ -3370,12 +3403,12 @@ struct DerivedMesh *subsurf_make_derived_from_derived(
* Addendum: we can't really ensure that this is never called in edit
* mode, so now we have a parameter to verify it. - brecht
*/
- if(!inEditMode && smd->emCache) {
+ if (!inEditMode && smd->emCache) {
ccgSubSurf_free(smd->emCache);
smd->emCache = NULL;
}
- if(useIncremental && isFinalCalc) {
+ if (useIncremental && isFinalCalc) {
smd->mCache = ss = _getSubSurf(smd->mCache, levels, useAging|CCG_CALC_NORMALS);
ss_sync_from_derivedmesh(ss, dm, vertCos, useSimple);
@@ -3383,7 +3416,8 @@ struct DerivedMesh *subsurf_make_derived_from_derived(
result = getCCGDerivedMesh(smd->mCache,
drawInteriorEdges,
useSubsurfUv, dm);
- } else {
+ }
+ else {
if (smd->mCache && isFinalCalc) {
ccgSubSurf_free(smd->mCache);
smd->mCache = NULL;
@@ -3394,7 +3428,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived(
result = getCCGDerivedMesh(ss, drawInteriorEdges, useSubsurfUv, dm);
- if(isFinalCalc)
+ if (isFinalCalc)
smd->mCache = ss;
else
result->freeSS = 1;
@@ -3441,7 +3475,7 @@ void subsurf_calculate_limit_positions(Mesh *me, float (*positions_r)[3])
/* ad-hoc correction for boundary vertices, to at least avoid them
* moving completely out of place (brecht) */
- if(numFaces && numFaces != N)
+ if (numFaces && numFaces != N)
mul_v3_fl(face_sum, (float)N/(float)numFaces);
co = ccgSubSurf_getVertData(ss, v);
diff --git a/source/blender/blenkernel/intern/suggestions.c b/source/blender/blenkernel/intern/suggestions.c
index e1e872c42b6..8b3138066d3 100644
--- a/source/blender/blenkernel/intern/suggestions.c
+++ b/source/blender/blenkernel/intern/suggestions.c
@@ -132,7 +132,8 @@ void texttool_suggest_add(const char *name, char type)
/* Perform simple linear search for ordered storage */
if (!suggestions.first || !suggestions.last) {
suggestions.first = suggestions.last = newitem;
- } else {
+ }
+ else {
cmp = -1;
for (item=suggestions.last; item; item=item->prev) {
cmp = txttl_cmp(name, item->name, len);
@@ -182,7 +183,8 @@ void texttool_suggest_prefix(const char *prefix)
first = match;
suggestions.top = top;
}
- } else if (cmp<0) {
+ }
+ else if (cmp<0) {
if (!last) {
last = match->prev;
break;
@@ -195,7 +197,8 @@ void texttool_suggest_prefix(const char *prefix)
suggestions.firstmatch = first;
suggestions.lastmatch = last;
suggestions.selected = first;
- } else {
+ }
+ else {
suggestions.firstmatch = NULL;
suggestions.lastmatch = NULL;
suggestions.selected = NULL;
@@ -255,7 +258,8 @@ void texttool_docs_show(const char *docs)
documentation = MEM_mallocN(len+2, "Documentation");
strncpy(documentation, docs, len);
documentation[len++] = '\n';
- } else {
+ }
+ else {
documentation = MEM_mallocN(len+1, "Documentation");
strncpy(documentation, docs, len);
}
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index 66759edde65..9715058c51f 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -173,7 +173,7 @@ void free_text(Text *text)
BLI_freelistN(&text->lines);
BLI_freelistN(&text->markers);
- if(text->name) MEM_freeN(text->name);
+ if (text->name) MEM_freeN(text->name);
MEM_freeN(text->undo_buf);
#ifdef WITH_PYTHON
if (text->compiled) BPY_text_free_code(text);
@@ -195,7 +195,7 @@ Text *add_empty_text(const char *name)
ta->nlines=1;
ta->flags= TXT_ISDIRTY | TXT_ISMEM;
- if((U.flag & USER_TXT_TABSTOSPACES_DISABLE)==0)
+ if ((U.flag & USER_TXT_TABSTOSPACES_DISABLE)==0)
ta->flags |= TXT_TABSTOSPACES;
ta->lines.first= ta->lines.last= NULL;
@@ -229,7 +229,7 @@ int txt_extended_ascii_as_utf8(char **str)
int length = strlen(*str);
while ((*str)[i]) {
- if((bad_char= BLI_utf8_invalid_byte(*str+i, length-i)) == -1)
+ if ((bad_char= BLI_utf8_invalid_byte(*str+i, length-i)) == -1)
break;
added++;
@@ -242,7 +242,7 @@ int txt_extended_ascii_as_utf8(char **str)
i= 0;
while ((*str)[i]) {
- if((bad_char= BLI_utf8_invalid_byte((*str)+i, length-i)) == -1) {
+ if ((bad_char= BLI_utf8_invalid_byte((*str)+i, length-i)) == -1) {
memcpy(newstr+mi, (*str)+i, length - i + 1);
break;
}
@@ -293,7 +293,7 @@ int reopen_text(Text *text)
BLI_path_abs(str, G.main->name);
fp= BLI_fopen(str, "r");
- if(fp==NULL) return 0;
+ if (fp==NULL) return 0;
/* free memory: */
@@ -329,13 +329,13 @@ int reopen_text(Text *text)
text->nlines=0;
llen=0;
- for(i=0; i<len; i++) {
+ for (i=0; i<len; i++) {
if (buffer[i]=='\n') {
tmp= (TextLine*) MEM_mallocN(sizeof(TextLine), "textline");
tmp->line= (char*) MEM_mallocN(llen+1, "textline_string");
tmp->format= NULL;
- if(llen) memcpy(tmp->line, &buffer[i-llen], llen);
+ if (llen) memcpy(tmp->line, &buffer[i-llen], llen);
tmp->line[llen]=0;
tmp->len= llen;
@@ -355,7 +355,7 @@ int reopen_text(Text *text)
tmp->line= (char*) MEM_mallocN(llen+1, "textline_string");
tmp->format= NULL;
- if(llen) memcpy(tmp->line, &buffer[i-llen], llen);
+ if (llen) memcpy(tmp->line, &buffer[i-llen], llen);
tmp->line[llen]=0;
tmp->len= llen;
@@ -389,7 +389,7 @@ Text *add_text(const char *file, const char *relpath)
BLI_path_abs(str, relpath);
fp= BLI_fopen(str, "r");
- if(fp==NULL) return NULL;
+ if (fp==NULL) return NULL;
ta= alloc_libblock(&bmain->text, ID_TXT, BLI_path_basename(str));
ta->id.us= 1;
@@ -398,7 +398,7 @@ Text *add_text(const char *file, const char *relpath)
ta->markers.first= ta->markers.last= NULL;
ta->curl= ta->sell= NULL;
- if((U.flag & USER_TXT_TABSTOSPACES_DISABLE)==0)
+ if ((U.flag & USER_TXT_TABSTOSPACES_DISABLE)==0)
ta->flags= TXT_TABSTOSPACES;
fseek(fp, 0L, SEEK_END);
@@ -422,13 +422,13 @@ Text *add_text(const char *file, const char *relpath)
ta->nlines=0;
llen=0;
- for(i=0; i<len; i++) {
+ for (i=0; i<len; i++) {
if (buffer[i]=='\n') {
tmp= (TextLine*) MEM_mallocN(sizeof(TextLine), "textline");
tmp->line= (char*) MEM_mallocN(llen+1, "textline_string");
tmp->format= NULL;
- if(llen) memcpy(tmp->line, &buffer[i-llen], llen);
+ if (llen) memcpy(tmp->line, &buffer[i-llen], llen);
tmp->line[llen]=0;
tmp->len= llen;
@@ -454,7 +454,7 @@ Text *add_text(const char *file, const char *relpath)
tmp->line= (char*) MEM_mallocN(llen+1, "textline_string");
tmp->format= NULL;
- if(llen) memcpy(tmp->line, &buffer[i-llen], llen);
+ if (llen) memcpy(tmp->line, &buffer[i-llen], llen);
tmp->line[llen]=0;
tmp->len= llen;
@@ -481,7 +481,7 @@ Text *copy_text(Text *ta)
tan= copy_libblock(&ta->id);
/* file name can be NULL */
- if(ta->name) {
+ if (ta->name) {
tan->name= MEM_mallocN(strlen(ta->name)+1, "text_name");
strcpy(tan->name, ta->name);
}
@@ -531,25 +531,25 @@ void unlink_text(Main *bmain, Text *text)
bConstraint *con;
short update;
- for(ob=bmain->object.first; ob; ob=ob->id.next) {
+ for (ob=bmain->object.first; ob; ob=ob->id.next) {
/* game controllers */
- for(cont=ob->controllers.first; cont; cont=cont->next) {
- if(cont->type==CONT_PYTHON) {
+ for (cont=ob->controllers.first; cont; cont=cont->next) {
+ if (cont->type==CONT_PYTHON) {
bPythonCont *pc;
pc= cont->data;
- if(pc->text==text) pc->text= NULL;
+ if (pc->text==text) pc->text= NULL;
}
}
/* pyconstraints */
update = 0;
- if(ob->type==OB_ARMATURE && ob->pose) {
+ if (ob->type==OB_ARMATURE && ob->pose) {
bPoseChannel *pchan;
- for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
- for(con = pchan->constraints.first; con; con=con->next) {
- if(con->type==CONSTRAINT_TYPE_PYTHON) {
+ for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
+ for (con = pchan->constraints.first; con; con=con->next) {
+ if (con->type==CONSTRAINT_TYPE_PYTHON) {
bPythonConstraint *data = con->data;
if (data->text==text) data->text = NULL;
update = 1;
@@ -559,15 +559,15 @@ void unlink_text(Main *bmain, Text *text)
}
}
- for(con = ob->constraints.first; con; con=con->next) {
- if(con->type==CONSTRAINT_TYPE_PYTHON) {
+ for (con = ob->constraints.first; con; con=con->next) {
+ if (con->type==CONSTRAINT_TYPE_PYTHON) {
bPythonConstraint *data = con->data;
if (data->text==text) data->text = NULL;
update = 1;
}
}
- if(update)
+ if (update)
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
}
@@ -575,13 +575,13 @@ void unlink_text(Main *bmain, Text *text)
// XXX nodeDynamicUnlinkText(&text->id);
/* text space */
- for(scr= bmain->screen.first; scr; scr= scr->id.next) {
- for(area= scr->areabase.first; area; area= area->next) {
- for(sl= area->spacedata.first; sl; sl= sl->next) {
- if(sl->spacetype==SPACE_TEXT) {
+ for (scr= bmain->screen.first; scr; scr= scr->id.next) {
+ for (area= scr->areabase.first; area; area= area->next) {
+ for (sl= area->spacedata.first; sl; sl= sl->next) {
+ if (sl->spacetype==SPACE_TEXT) {
SpaceText *st= (SpaceText*) sl;
- if(st->text==text) {
+ if (st->text==text) {
st->text= NULL;
st->top= 0;
}
@@ -636,7 +636,7 @@ static TextLine *txt_new_line(const char *str)
{
TextLine *tmp;
- if(!str) str= "";
+ if (!str) str= "";
tmp= (TextLine *) MEM_mallocN(sizeof(TextLine), "textline");
tmp->line= MEM_mallocN(strlen(str)+1, "textline_string");
@@ -685,13 +685,13 @@ void txt_clean_text (Text *text)
while ((*top)->prev) *top= (*top)->prev;
while ((*bot)->next) *bot= (*bot)->next;
- if(!text->curl) {
- if(text->sell) text->curl= text->sell;
+ if (!text->curl) {
+ if (text->sell) text->curl= text->sell;
else text->curl= text->lines.first;
text->curc= 0;
}
- if(!text->sell) {
+ if (!text->sell) {
text->sell= text->curl;
text->selc= 0;
}
@@ -716,12 +716,12 @@ int txt_get_span (TextLine *from, TextLine *to)
if (!tmp) {
tmp= from;
ret=0;
- while(tmp) {
+ while (tmp) {
if (tmp == to) break;
ret--;
tmp= tmp->prev;
}
- if(!tmp) ret=0;
+ if (!tmp) ret=0;
}
return ret;
@@ -755,10 +755,12 @@ static void txt_curs_first (Text *text, TextLine **linep, int *charp)
*linep= text->curl;
if (text->curc<text->selc) *charp= text->curc;
else *charp= text->selc;
- } else if (txt_get_span(text->lines.first, text->curl)<txt_get_span(text->lines.first, text->sell)) {
+ }
+ else if (txt_get_span(text->lines.first, text->curl)<txt_get_span(text->lines.first, text->sell)) {
*linep= text->curl;
*charp= text->curc;
- } else {
+ }
+ else {
*linep= text->sell;
*charp= text->selc;
}
@@ -808,24 +810,25 @@ void txt_move_up(Text *text, short sel)
/* int old; */ /* UNUSED */
if (!text) return;
- if(sel) txt_curs_sel(text, &linep, &charp);
+ if (sel) txt_curs_sel(text, &linep, &charp);
else { txt_pop_first(text); txt_curs_cur(text, &linep, &charp); }
if (!*linep) return;
/* old= *charp; */ /* UNUSED */
- if((*linep)->prev) {
+ if ((*linep)->prev) {
int index = txt_utf8_offset_to_index((*linep)->line, *charp);
*linep= (*linep)->prev;
if (index > txt_utf8_len((*linep)->line)) *charp= (*linep)->len;
else *charp= txt_utf8_index_to_offset((*linep)->line, index);
- if(!undoing)
+ if (!undoing)
txt_undo_add_op(text, sel?UNDO_SUP:UNDO_CUP);
- } else {
+ }
+ else {
txt_move_bol(text, sel);
}
- if(!sel) txt_pop_sel(text);
+ if (!sel) txt_pop_sel(text);
}
void txt_move_down(Text *text, short sel)
@@ -835,24 +838,25 @@ void txt_move_down(Text *text, short sel)
/* int old; */ /* UNUSED */
if (!text) return;
- if(sel) txt_curs_sel(text, &linep, &charp);
+ if (sel) txt_curs_sel(text, &linep, &charp);
else { txt_pop_last(text); txt_curs_cur(text, &linep, &charp); }
if (!*linep) return;
/* old= *charp; */ /* UNUSED */
- if((*linep)->next) {
+ if ((*linep)->next) {
int index = txt_utf8_offset_to_index((*linep)->line, *charp);
*linep= (*linep)->next;
if (index > txt_utf8_len((*linep)->line)) *charp= (*linep)->len;
else *charp= txt_utf8_index_to_offset((*linep)->line, index);
- if(!undoing)
+ if (!undoing)
txt_undo_add_op(text, sel?UNDO_SDOWN:UNDO_CDOWN);
- } else {
+ }
+ else {
txt_move_eol(text, sel);
}
- if(!sel) txt_pop_sel(text);
+ if (!sel) txt_pop_sel(text);
}
void txt_move_left(Text *text, short sel)
@@ -862,7 +866,7 @@ void txt_move_left(Text *text, short sel)
int tabsize= 0, i= 0;
if (!text) return;
- if(sel) txt_curs_sel(text, &linep, &charp);
+ if (sel) txt_curs_sel(text, &linep, &charp);
else { txt_pop_first(text); txt_curs_cur(text, &linep, &charp); }
if (!*linep) return;
@@ -900,9 +904,9 @@ void txt_move_left(Text *text, short sel)
}
undoing= oundoing;
- if(!undoing) txt_undo_add_op(text, sel?UNDO_SLEFT:UNDO_CLEFT);
+ if (!undoing) txt_undo_add_op(text, sel?UNDO_SLEFT:UNDO_CLEFT);
- if(!sel) txt_pop_sel(text);
+ if (!sel) txt_pop_sel(text);
}
void txt_move_right(Text *text, short sel)
@@ -911,7 +915,7 @@ void txt_move_right(Text *text, short sel)
int *charp, oundoing= undoing, do_tab= 0, i;
if (!text) return;
- if(sel) txt_curs_sel(text, &linep, &charp);
+ if (sel) txt_curs_sel(text, &linep, &charp);
else { txt_pop_last(text); txt_curs_cur(text, &linep, &charp); }
if (!*linep) return;
@@ -945,9 +949,9 @@ void txt_move_right(Text *text, short sel)
}
undoing= oundoing;
- if(!undoing) txt_undo_add_op(text, sel?UNDO_SRIGHT:UNDO_CRIGHT);
+ if (!undoing) txt_undo_add_op(text, sel?UNDO_SRIGHT:UNDO_CRIGHT);
- if(!sel) txt_pop_sel(text);
+ if (!sel) txt_pop_sel(text);
}
void txt_jump_left(Text *text, short sel)
@@ -958,7 +962,7 @@ void txt_jump_left(Text *text, short sel)
int pos;
if (!text) return;
- if(sel) txt_curs_sel(text, &linep, &charp);
+ if (sel) txt_curs_sel(text, &linep, &charp);
else { txt_pop_first(text); txt_curs_cur(text, &linep, &charp); }
if (!*linep) return;
@@ -981,7 +985,7 @@ void txt_jump_left(Text *text, short sel)
text->flags = oldflags;
undoing= oldu;
- if(!undoing) txt_undo_add_toop(text, sel?UNDO_STO:UNDO_CTO, txt_get_span(text->lines.first, oldl), oldc, txt_get_span(text->lines.first, *linep), (unsigned short)*charp);
+ if (!undoing) txt_undo_add_toop(text, sel?UNDO_STO:UNDO_CTO, txt_get_span(text->lines.first, oldl), oldc, txt_get_span(text->lines.first, *linep), (unsigned short)*charp);
}
void txt_jump_right(Text *text, short sel)
@@ -992,7 +996,7 @@ void txt_jump_right(Text *text, short sel)
int pos;
if (!text) return;
- if(sel) txt_curs_sel(text, &linep, &charp);
+ if (sel) txt_curs_sel(text, &linep, &charp);
else { txt_pop_last(text); txt_curs_cur(text, &linep, &charp); }
if (!*linep) return;
@@ -1015,7 +1019,7 @@ void txt_jump_right(Text *text, short sel)
text->flags = oldflags;
undoing= oldu;
- if(!undoing) txt_undo_add_toop(text, sel?UNDO_STO:UNDO_CTO, txt_get_span(text->lines.first, oldl), oldc, txt_get_span(text->lines.first, *linep), (unsigned short)*charp);
+ if (!undoing) txt_undo_add_toop(text, sel?UNDO_STO:UNDO_CTO, txt_get_span(text->lines.first, oldl), oldc, txt_get_span(text->lines.first, *linep), (unsigned short)*charp);
}
void txt_move_bol (Text *text, short sel)
@@ -1024,15 +1028,15 @@ void txt_move_bol (Text *text, short sel)
int *charp, old;
if (!text) return;
- if(sel) txt_curs_sel(text, &linep, &charp);
+ if (sel) txt_curs_sel(text, &linep, &charp);
else txt_curs_cur(text, &linep, &charp);
if (!*linep) return;
old= *charp;
*charp= 0;
- if(!sel) txt_pop_sel(text);
- if(!undoing) txt_undo_add_toop(text, sel?UNDO_STO:UNDO_CTO, txt_get_span(text->lines.first, *linep), old, txt_get_span(text->lines.first, *linep), (unsigned short)*charp);
+ if (!sel) txt_pop_sel(text);
+ if (!undoing) txt_undo_add_toop(text, sel?UNDO_STO:UNDO_CTO, txt_get_span(text->lines.first, *linep), old, txt_get_span(text->lines.first, *linep), (unsigned short)*charp);
}
void txt_move_eol (Text *text, short sel)
@@ -1041,15 +1045,15 @@ void txt_move_eol (Text *text, short sel)
int *charp, old;
if (!text) return;
- if(sel) txt_curs_sel(text, &linep, &charp);
+ if (sel) txt_curs_sel(text, &linep, &charp);
else txt_curs_cur(text, &linep, &charp);
if (!*linep) return;
old= *charp;
*charp= (*linep)->len;
- if(!sel) txt_pop_sel(text);
- if(!undoing) txt_undo_add_toop(text, sel?UNDO_STO:UNDO_CTO, txt_get_span(text->lines.first, *linep), old, txt_get_span(text->lines.first, *linep), (unsigned short)*charp);
+ if (!sel) txt_pop_sel(text);
+ if (!undoing) txt_undo_add_toop(text, sel?UNDO_STO:UNDO_CTO, txt_get_span(text->lines.first, *linep), old, txt_get_span(text->lines.first, *linep), (unsigned short)*charp);
}
void txt_move_bof (Text *text, short sel)
@@ -1058,7 +1062,7 @@ void txt_move_bof (Text *text, short sel)
int *charp, old;
if (!text) return;
- if(sel) txt_curs_sel(text, &linep, &charp);
+ if (sel) txt_curs_sel(text, &linep, &charp);
else txt_curs_cur(text, &linep, &charp);
if (!*linep) return;
old= *charp;
@@ -1066,8 +1070,8 @@ void txt_move_bof (Text *text, short sel)
*linep= text->lines.first;
*charp= 0;
- if(!sel) txt_pop_sel(text);
- if(!undoing) txt_undo_add_toop(text, sel?UNDO_STO:UNDO_CTO, txt_get_span(text->lines.first, *linep), old, txt_get_span(text->lines.first, *linep), (unsigned short)*charp);
+ if (!sel) txt_pop_sel(text);
+ if (!undoing) txt_undo_add_toop(text, sel?UNDO_STO:UNDO_CTO, txt_get_span(text->lines.first, *linep), old, txt_get_span(text->lines.first, *linep), (unsigned short)*charp);
}
void txt_move_eof (Text *text, short sel)
@@ -1076,7 +1080,7 @@ void txt_move_eof (Text *text, short sel)
int *charp, old;
if (!text) return;
- if(sel) txt_curs_sel(text, &linep, &charp);
+ if (sel) txt_curs_sel(text, &linep, &charp);
else txt_curs_cur(text, &linep, &charp);
if (!*linep) return;
old= *charp;
@@ -1084,8 +1088,8 @@ void txt_move_eof (Text *text, short sel)
*linep= text->lines.last;
*charp= (*linep)->len;
- if(!sel) txt_pop_sel(text);
- if(!undoing) txt_undo_add_toop(text, sel?UNDO_STO:UNDO_CTO, txt_get_span(text->lines.first, *linep), old, txt_get_span(text->lines.first, *linep), (unsigned short)*charp);
+ if (!sel) txt_pop_sel(text);
+ if (!undoing) txt_undo_add_toop(text, sel?UNDO_STO:UNDO_CTO, txt_get_span(text->lines.first, *linep), old, txt_get_span(text->lines.first, *linep), (unsigned short)*charp);
}
void txt_move_toline (Text *text, unsigned int line, short sel)
@@ -1101,7 +1105,7 @@ void txt_move_to (Text *text, unsigned int line, unsigned int ch, short sel)
unsigned int i;
if (!text) return;
- if(sel) txt_curs_sel(text, &linep, &charp);
+ if (sel) txt_curs_sel(text, &linep, &charp);
else txt_curs_cur(text, &linep, &charp);
if (!*linep) return;
oldc= *charp;
@@ -1116,8 +1120,8 @@ void txt_move_to (Text *text, unsigned int line, unsigned int ch, short sel)
ch= (unsigned int)((*linep)->len);
*charp= ch;
- if(!sel) txt_pop_sel(text);
- if(!undoing) txt_undo_add_toop(text, sel?UNDO_STO:UNDO_CTO, txt_get_span(text->lines.first, oldl), oldc, txt_get_span(text->lines.first, *linep), (unsigned short)*charp);
+ if (!sel) txt_pop_sel(text);
+ if (!undoing) txt_undo_add_toop(text, sel?UNDO_STO:UNDO_CTO, txt_get_span(text->lines.first, oldl), oldc, txt_get_span(text->lines.first, *linep), (unsigned short)*charp);
}
/****************************/
@@ -1137,7 +1141,7 @@ static void txt_curs_swap (Text *text)
text->curc= text->selc;
text->selc= tmpc;
- if(!undoing) txt_undo_add_op(text, UNDO_SWAP);
+ if (!undoing) txt_undo_add_op(text, UNDO_SWAP);
}
static void txt_pop_first (Text *text)
@@ -1148,7 +1152,7 @@ static void txt_pop_first (Text *text)
txt_curs_swap(text);
}
- if(!undoing) txt_undo_add_toop(text, UNDO_STO,
+ if (!undoing) txt_undo_add_toop(text, UNDO_STO,
txt_get_span(text->lines.first, text->sell),
text->selc,
txt_get_span(text->lines.first, text->curl),
@@ -1164,7 +1168,7 @@ static void txt_pop_last (Text *text)
txt_curs_swap(text);
}
- if(!undoing) txt_undo_add_toop(text, UNDO_STO,
+ if (!undoing) txt_undo_add_toop(text, UNDO_STO,
txt_get_span(text->lines.first, text->sell),
text->selc,
txt_get_span(text->lines.first, text->curl),
@@ -1214,7 +1218,7 @@ static void txt_delete_sel (Text *text)
txt_order_cursors(text);
- if(!undoing) {
+ if (!undoing) {
buf= txt_sel_to_buf(text);
txt_undo_add_block(text, UNDO_DBLOCK, buf);
MEM_freeN(buf);
@@ -1225,7 +1229,8 @@ static void txt_delete_sel (Text *text)
if (text->curl != text->sell) {
txt_clear_marker_region(text, text->curl, text->curc, text->curl->len, 0, 0);
move= txt_get_span(text->curl, text->sell);
- } else {
+ }
+ else {
mrk= txt_find_marker_region(text, text->curl, text->curc, text->selc, 0, 0);
if (mrk && (mrk->start > text->curc || mrk->end < text->selc))
txt_clear_marker_region(text, text->curl, text->curc, text->selc, 0, 0);
@@ -1311,7 +1316,8 @@ char *txt_to_buf (Text *text)
BLI_strncpy(buf, linef->line + charf, length+1);
buf[length]=0;
- } else {
+ }
+ else {
length= linef->len - charf;
length+= charl;
length+= 2; /* For the 2 '\n' */
@@ -1360,7 +1366,7 @@ int txt_find_string(Text *text, const char *findstr, int wrap, int match_case)
tl= startl= text->sell;
- if(match_case) s= strstr(&tl->line[text->selc], findstr);
+ if (match_case) s= strstr(&tl->line[text->selc], findstr);
else s= BLI_strcasestr(&tl->line[text->selc], findstr);
while (!s) {
tl= tl->next;
@@ -1371,7 +1377,7 @@ int txt_find_string(Text *text, const char *findstr, int wrap, int match_case)
break;
}
- if(match_case) s= strstr(tl->line, findstr);
+ if (match_case) s= strstr(tl->line, findstr);
else s= BLI_strcasestr(tl->line, findstr);
if (tl==startl)
break;
@@ -1383,7 +1389,8 @@ int txt_find_string(Text *text, const char *findstr, int wrap, int match_case)
txt_move_to(text, newl, newc, 0);
txt_move_to(text, newl, newc + strlen(findstr), 1);
return 1;
- } else
+ }
+ else
return 0;
}
@@ -1404,17 +1411,20 @@ char *txt_sel_to_buf (Text *text)
if (text->curc < text->selc) {
charf= text->curc;
charl= text->selc;
- } else{
+ }
+ else {
charf= text->selc;
charl= text->curc;
}
- } else if (txt_get_span(text->curl, text->sell)<0) {
+ }
+ else if (txt_get_span(text->curl, text->sell)<0) {
linef= text->sell;
linel= text->curl;
charf= text->selc;
charl= text->curc;
- } else {
+ }
+ else {
linef= text->curl;
linel= text->sell;
@@ -1428,7 +1438,8 @@ char *txt_sel_to_buf (Text *text)
buf= MEM_mallocN(length+1, "sel buffer");
BLI_strncpy(buf, linef->line + charf, length+1);
- } else {
+ }
+ else {
length+= linef->len - charf;
length+= charl;
length++; /* For the '\n' */
@@ -1490,7 +1501,7 @@ void txt_insert_buf(Text *text, const char *in_buffer)
buffer= BLI_strdupn(in_buffer, len);
len+= txt_extended_ascii_as_utf8(&buffer);
- if(!undoing) txt_undo_add_block(text, UNDO_IBLOCK, buffer);
+ if (!undoing) txt_undo_add_block(text, UNDO_IBLOCK, buffer);
u= undoing;
undoing= 1;
@@ -1513,13 +1524,14 @@ void txt_insert_buf(Text *text, const char *in_buffer)
i++; l++;
}
- if(buffer[i]=='\n') {
+ if (buffer[i]=='\n') {
add= txt_new_linen(buffer +(i-l), l);
BLI_insertlinkbefore(&text->lines, text->curl, add);
i++;
count++;
- } else {
- if(count) {
+ }
+ else {
+ if (count) {
txt_shift_markers(text, lineno, count);
count= 0;
}
@@ -1532,7 +1544,7 @@ void txt_insert_buf(Text *text, const char *in_buffer)
MEM_freeN(buffer);
- if(count) {
+ if (count) {
txt_shift_markers(text, lineno, count);
}
@@ -1546,12 +1558,13 @@ void txt_insert_buf(Text *text, const char *in_buffer)
static int max_undo_test(Text *text, int x)
{
while (text->undo_pos+x >= text->undo_len) {
- if(text->undo_len*2 > TXT_MAX_UNDO) {
+ if (text->undo_len*2 > TXT_MAX_UNDO) {
/* XXX error("Undo limit reached, buffer cleared\n"); */
MEM_freeN(text->undo_buf);
init_undo_text(text);
return 0;
- } else {
+ }
+ else {
void *tmp= text->undo_buf;
text->undo_buf= MEM_callocN(text->undo_len*2, "undo buf");
memcpy(text->undo_buf, tmp, text->undo_len);
@@ -1588,63 +1601,92 @@ void txt_print_undo(Text *text)
if (op==UNDO_CLEFT) {
ops= "Cursor left";
- } else if (op==UNDO_CRIGHT) {
+ }
+ else if (op==UNDO_CRIGHT) {
ops= "Cursor right";
- } else if (op==UNDO_CUP) {
+ }
+ else if (op==UNDO_CUP) {
ops= "Cursor up";
- } else if (op==UNDO_CDOWN) {
+ }
+ else if (op==UNDO_CDOWN) {
ops= "Cursor down";
- } else if (op==UNDO_SLEFT) {
+ }
+ else if (op==UNDO_SLEFT) {
ops= "Selection left";
- } else if (op==UNDO_SRIGHT) {
+ }
+ else if (op==UNDO_SRIGHT) {
ops= "Selection right";
- } else if (op==UNDO_SUP) {
+ }
+ else if (op==UNDO_SUP) {
ops= "Selection up";
- } else if (op==UNDO_SDOWN) {
+ }
+ else if (op==UNDO_SDOWN) {
ops= "Selection down";
- } else if (op==UNDO_STO) {
+ }
+ else if (op==UNDO_STO) {
ops= "Selection ";
- } else if (op==UNDO_CTO) {
+ }
+ else if (op==UNDO_CTO) {
ops= "Cursor ";
- } else if (op==UNDO_INSERT_1) {
+ }
+ else if (op==UNDO_INSERT_1) {
ops= "Insert ascii ";
- } else if (op==UNDO_INSERT_2) {
+ }
+ else if (op==UNDO_INSERT_2) {
ops= "Insert 2 bytes ";
- } else if (op==UNDO_INSERT_3) {
+ }
+ else if (op==UNDO_INSERT_3) {
ops= "Insert 3 bytes ";
- } else if (op==UNDO_INSERT_4) {
+ }
+ else if (op==UNDO_INSERT_4) {
ops= "Insert unicode ";
- } else if (op==UNDO_BS_1) {
+ }
+ else if (op==UNDO_BS_1) {
ops= "Backspace for ascii ";
- } else if (op==UNDO_BS_2) {
+ }
+ else if (op==UNDO_BS_2) {
ops= "Backspace for 2 bytes ";
- } else if (op==UNDO_BS_3) {
+ }
+ else if (op==UNDO_BS_3) {
ops= "Backspace for 3 bytes ";
- } else if (op==UNDO_BS_4) {
+ }
+ else if (op==UNDO_BS_4) {
ops= "Backspace for unicode ";
- } else if (op==UNDO_DEL_1) {
+ }
+ else if (op==UNDO_DEL_1) {
ops= "Delete ascii ";
- } else if (op==UNDO_DEL_2) {
+ }
+ else if (op==UNDO_DEL_2) {
ops= "Delete 2 bytes ";
- } else if (op==UNDO_DEL_3) {
+ }
+ else if (op==UNDO_DEL_3) {
ops= "Delete 3 bytes ";
- } else if (op==UNDO_DEL_4) {
+ }
+ else if (op==UNDO_DEL_4) {
ops= "Delete unicode ";
- } else if (op==UNDO_SWAP) {
+ }
+ else if (op==UNDO_SWAP) {
ops= "Cursor swap";
- } else if (op==UNDO_DBLOCK) {
+ }
+ else if (op==UNDO_DBLOCK) {
ops= "Delete text block";
- } else if (op==UNDO_IBLOCK) {
+ }
+ else if (op==UNDO_IBLOCK) {
ops= "Insert text block";
- } else if (op==UNDO_INDENT) {
+ }
+ else if (op==UNDO_INDENT) {
ops= "Indent ";
- } else if (op==UNDO_UNINDENT) {
+ }
+ else if (op==UNDO_UNINDENT) {
ops= "Unindent ";
- } else if (op==UNDO_COMMENT) {
+ }
+ else if (op==UNDO_COMMENT) {
ops= "Comment ";
- } else if (op==UNDO_UNCOMMENT) {
+ }
+ else if (op==UNDO_UNCOMMENT) {
ops= "Uncomment ";
- } else {
+ }
+ else {
ops= "Unknown";
}
@@ -1678,7 +1720,8 @@ void txt_print_undo(Text *text)
puts(c);
}
}
- } else if (op==UNDO_STO || op==UNDO_CTO) {
+ }
+ else if (op==UNDO_STO || op==UNDO_CTO) {
i++;
charp= text->undo_buf[i]; i++;
@@ -1700,7 +1743,8 @@ void txt_print_undo(Text *text)
linep= linep+(text->undo_buf[i]<<24); i++;
printf ("from <%d, %d>", linep, charp);
- } else if (op==UNDO_DBLOCK || op==UNDO_IBLOCK) {
+ }
+ else if (op==UNDO_DBLOCK || op==UNDO_IBLOCK) {
i++;
linep= text->undo_buf[i]; i++;
@@ -1720,7 +1764,8 @@ void txt_print_undo(Text *text)
linep= linep+(text->undo_buf[i]<<16); i++;
linep= linep+(text->undo_buf[i]<<24); i++;
printf ("> (%d)", linep);
- } else if (op==UNDO_INDENT || op==UNDO_UNINDENT) {
+ }
+ else if (op==UNDO_INDENT || op==UNDO_UNINDENT) {
i++;
charp= text->undo_buf[i]; i++;
@@ -1751,7 +1796,7 @@ void txt_print_undo(Text *text)
static void txt_undo_add_op(Text *text, int op)
{
- if(!max_undo_test(text, 2))
+ if (!max_undo_test(text, 2))
return;
text->undo_pos++;
@@ -1783,7 +1828,7 @@ static void txt_undo_add_block(Text *text, int op, const char *buf)
{
unsigned int length= strlen(buf);
- if(!max_undo_test(text, length+11))
+ if (!max_undo_test(text, length+11))
return;
text->undo_pos++;
@@ -1803,7 +1848,7 @@ static void txt_undo_add_block(Text *text, int op, const char *buf)
void txt_undo_add_toop(Text *text, int op, unsigned int froml, unsigned short fromc, unsigned int tol, unsigned short toc)
{
- if(!max_undo_test(text, 15))
+ if (!max_undo_test(text, 15))
return;
if (froml==tol && fromc==toc) return;
@@ -1828,7 +1873,7 @@ static void txt_undo_add_charop(Text *text, int op_start, unsigned int c)
char utf8[BLI_UTF8_MAX];
size_t i, utf8_size = BLI_str_utf8_from_unicode(c, utf8);
- if(!max_undo_test(text, 3 + utf8_size))
+ if (!max_undo_test(text, 3 + utf8_size))
return;
text->undo_pos++;
@@ -1843,7 +1888,8 @@ static void txt_undo_add_charop(Text *text, int op_start, unsigned int c)
}
text->undo_buf[text->undo_pos]= op_start + utf8_size - 1;
- } else {
+ }
+ else {
text->undo_buf[text->undo_pos]= op_start + 3;
text->undo_pos++;
txt_undo_store_uint32(text->undo_buf, &text->undo_pos, c);
@@ -2022,7 +2068,8 @@ void txt_do_undo(Text *text)
txt_move_toline(text, linep, 0);
text->curc= charp;
txt_pop_sel(text);
- } else {
+ }
+ else {
txt_move_toline(text, linep, 1);
text->selc= charp;
}
@@ -2071,7 +2118,7 @@ void txt_do_undo(Text *text)
text->curl= text->lines.first;
while (holdln>0) {
- if(text->curl->next)
+ if (text->curl->next)
text->curl= text->curl->next;
holdln--;
@@ -2145,11 +2192,14 @@ void txt_do_undo(Text *text)
if (op==UNDO_INDENT) {
txt_unindent(text);
- } else if (op== UNDO_UNINDENT) {
+ }
+ else if (op== UNDO_UNINDENT) {
txt_indent(text);
- } else if (op == UNDO_COMMENT) {
+ }
+ else if (op == UNDO_COMMENT) {
txt_uncomment(text);
- } else if (op == UNDO_UNCOMMENT) {
+ }
+ else if (op == UNDO_UNCOMMENT) {
txt_comment(text);
}
@@ -2270,7 +2320,8 @@ void txt_do_redo(Text *text)
txt_move_toline(text, linep, 0);
text->curc= charp;
txt_pop_sel(text);
- } else {
+ }
+ else {
txt_move_toline(text, linep, 1);
text->selc= charp;
}
@@ -2340,11 +2391,14 @@ void txt_do_redo(Text *text)
if (op==UNDO_INDENT) {
txt_indent(text);
- } else if (op== UNDO_UNINDENT) {
+ }
+ else if (op== UNDO_UNINDENT) {
txt_unindent(text);
- } else if (op == UNDO_COMMENT) {
+ }
+ else if (op == UNDO_COMMENT) {
txt_comment(text);
- } else if (op == UNDO_UNCOMMENT) {
+ }
+ else if (op == UNDO_UNCOMMENT) {
txt_uncomment(text);
}
break;
@@ -2383,7 +2437,8 @@ void txt_split_curline (Text *text)
mrk->lineno++;
mrk->start -= text->curc;
mrk->end -= text->curc;
- } else if (mrk->lineno > lineno) {
+ }
+ else if (mrk->lineno > lineno) {
mrk->lineno++;
}
mrk= mrk->next;
@@ -2420,7 +2475,7 @@ void txt_split_curline (Text *text)
txt_clean_text(text);
txt_pop_sel(text);
- if(!undoing) txt_undo_add_charop(text, UNDO_INSERT_1, '\n');
+ if (!undoing) txt_undo_add_charop(text, UNDO_INSERT_1, '\n');
}
static void txt_delete_line (Text *text, TextLine *line)
@@ -2461,7 +2516,7 @@ static void txt_combine_lines (Text *text, TextLine *linea, TextLine *lineb)
if (!text) return;
- if(!linea || !lineb) return;
+ if (!linea || !lineb) return;
mrk= txt_find_marker_region(text, lineb, 0, lineb->len, 0, 0);
if (mrk) {
@@ -2505,7 +2560,8 @@ void txt_delete_char(Text *text)
txt_combine_lines(text, text->curl, text->curl->next);
txt_pop_sel(text);
}
- } else { /* Just deleting a char */
+ }
+ else { /* Just deleting a char */
size_t c_len = 0;
TextMarker *mrk;
c= BLI_str_utf8_as_unicode_and_size(text->curl->line + text->curc, &c_len);
@@ -2516,7 +2572,8 @@ void txt_delete_char(Text *text)
if (mrk->end==text->curc) {
if ((mrk->flags & TMARK_TEMP) && !(mrk->flags & TMARK_EDITALL)) {
txt_clear_markers(text, mrk->group, TMARK_TEMP);
- } else {
+ }
+ else {
BLI_freelinkN(&text->markers, mrk);
}
return;
@@ -2538,7 +2595,7 @@ void txt_delete_char(Text *text)
txt_make_dirty(text);
txt_clean_text(text);
- if(!undoing) txt_undo_add_charop(text, UNDO_DEL_1, c);
+ if (!undoing) txt_undo_add_charop(text, UNDO_DEL_1, c);
}
void txt_delete_word (Text *text)
@@ -2580,7 +2637,8 @@ void txt_backspace_char (Text *text)
if (mrk->start==text->curc) {
if ((mrk->flags & TMARK_TEMP) && !(mrk->flags & TMARK_EDITALL)) {
txt_clear_markers(text, mrk->group, TMARK_TEMP);
- } else {
+ }
+ else {
BLI_freelinkN(&text->markers, mrk);
}
return;
@@ -2603,7 +2661,7 @@ void txt_backspace_char (Text *text)
txt_make_dirty(text);
txt_clean_text(text);
- if(!undoing) txt_undo_add_charop(text, UNDO_BS_1, c);
+ if (!undoing) txt_undo_add_charop(text, UNDO_BS_1, c);
}
void txt_backspace_word (Text *text)
@@ -2676,7 +2734,7 @@ static int txt_add_char_intern (Text *text, unsigned int add, int replace_tabs)
txt_make_dirty(text);
txt_clean_text(text);
- if(!undoing) txt_undo_add_charop(text, UNDO_INSERT_1, add);
+ if (!undoing) txt_undo_add_charop(text, UNDO_INSERT_1, add);
return 1;
}
@@ -2722,7 +2780,8 @@ int txt_replace_char (Text *text, unsigned int add)
memcpy(tmp+text->curc+add_size, text->curl->line+text->curc+del_size, text->curl->len-text->curc-del_size+1);
MEM_freeN(text->curl->line);
text->curl->line = tmp;
- } else if (add_size < del_size) {
+ }
+ else if (add_size < del_size) {
char *tmp= text->curl->line;
memmove(tmp+text->curc+add_size, tmp+text->curc+del_size, text->curl->len-text->curc-del_size+1);
}
@@ -2735,7 +2794,7 @@ int txt_replace_char (Text *text, unsigned int add)
txt_clean_text(text);
/* Should probably create a new op for this */
- if(!undoing) {
+ if (!undoing) {
txt_undo_add_charop(text, UNDO_DEL_1, del);
txt_undo_add_charop(text, UNDO_INSERT_1, add);
}
@@ -2773,11 +2832,11 @@ void txt_indent(Text *text)
tmp= MEM_mallocN(text->curl->len+indentlen+1, "textline_string");
text->curc = 0;
- if(text->curc) memcpy(tmp, text->curl->line, text->curc); /* XXX never true, check prev line */
+ if (text->curc) memcpy(tmp, text->curl->line, text->curc); /* XXX never true, check prev line */
memcpy(tmp+text->curc, add, indentlen);
len= text->curl->len - text->curc;
- if(len>0) memcpy(tmp+text->curc+indentlen, text->curl->line+text->curc, len);
+ if (len>0) memcpy(tmp+text->curc+indentlen, text->curl->line+text->curc, len);
tmp[text->curl->len+indentlen]= 0;
make_new_line(text->curl, tmp);
@@ -2787,23 +2846,24 @@ void txt_indent(Text *text)
txt_make_dirty(text);
txt_clean_text(text);
- if(text->curl == text->sell)
+ if (text->curl == text->sell)
{
text->selc = text->sell->len;
break;
- } else {
+ }
+ else {
text->curl = text->curl->next;
num++;
}
}
text->curc = 0;
- while( num > 0 )
+ while ( num > 0 )
{
text->curl = text->curl->prev;
num--;
}
- if(!undoing)
+ if (!undoing)
{
txt_undo_add_toop(text, UNDO_INDENT, txt_get_span(text->lines.first, text->curl), text->curc, txt_get_span(text->lines.first, text->sell), text->selc);
}
@@ -2828,13 +2888,13 @@ void txt_unindent(Text *text)
indent = spaceslen;
}
- while(TRUE)
+ while (TRUE)
{
int i = 0;
if (BLI_strncasecmp(text->curl->line, remove, indent) == 0)
{
- while(i< text->curl->len) {
+ while (i< text->curl->len) {
text->curl->line[i]= text->curl->line[i+indent];
i++;
}
@@ -2844,24 +2904,25 @@ void txt_unindent(Text *text)
txt_make_dirty(text);
txt_clean_text(text);
- if(text->curl == text->sell)
+ if (text->curl == text->sell)
{
text->selc = text->sell->len;
break;
- } else {
+ }
+ else {
text->curl = text->curl->next;
num++;
}
}
text->curc = 0;
- while( num > 0 )
+ while ( num > 0 )
{
text->curl = text->curl->prev;
num--;
}
- if(!undoing)
+ if (!undoing)
{
txt_undo_add_toop(text, UNDO_UNINDENT, txt_get_span(text->lines.first, text->curl), text->curc, txt_get_span(text->lines.first, text->sell), text->selc);
}
@@ -2883,11 +2944,11 @@ void txt_comment(Text *text)
tmp= MEM_mallocN(text->curl->len+2, "textline_string");
text->curc = 0;
- if(text->curc) memcpy(tmp, text->curl->line, text->curc);
+ if (text->curc) memcpy(tmp, text->curl->line, text->curc);
tmp[text->curc]= add;
len= text->curl->len - text->curc;
- if(len>0) memcpy(tmp+text->curc+1, text->curl->line+text->curc, len);
+ if (len>0) memcpy(tmp+text->curc+1, text->curl->line+text->curc, len);
tmp[text->curl->len+1]=0;
make_new_line(text->curl, tmp);
@@ -2897,23 +2958,24 @@ void txt_comment(Text *text)
txt_make_dirty(text);
txt_clean_text(text);
- if(text->curl == text->sell)
+ if (text->curl == text->sell)
{
text->selc = text->sell->len;
break;
- } else {
+ }
+ else {
text->curl = text->curl->next;
num++;
}
}
text->curc = 0;
- while( num > 0 )
+ while ( num > 0 )
{
text->curl = text->curl->prev;
num--;
}
- if(!undoing)
+ if (!undoing)
{
txt_undo_add_toop(text, UNDO_COMMENT, txt_get_span(text->lines.first, text->curl), text->curc, txt_get_span(text->lines.first, text->sell), text->selc);
}
@@ -2928,13 +2990,13 @@ void txt_uncomment(Text *text)
if (!text->curl) return;
if (!text->sell) return;
- while(TRUE)
+ while (TRUE)
{
int i = 0;
if (text->curl->line[i] == remove)
{
- while(i< text->curl->len) {
+ while (i< text->curl->len) {
text->curl->line[i]= text->curl->line[i+1];
i++;
}
@@ -2945,24 +3007,25 @@ void txt_uncomment(Text *text)
txt_make_dirty(text);
txt_clean_text(text);
- if(text->curl == text->sell)
+ if (text->curl == text->sell)
{
text->selc = text->sell->len;
break;
- } else {
+ }
+ else {
text->curl = text->curl->next;
num++;
}
}
text->curc = 0;
- while( num > 0 )
+ while ( num > 0 )
{
text->curl = text->curl->prev;
num--;
}
- if(!undoing)
+ if (!undoing)
{
txt_undo_add_toop(text, UNDO_UNCOMMENT, txt_get_span(text->lines.first, text->curl), text->curc, txt_get_span(text->lines.first, text->sell), text->selc);
}
@@ -2985,11 +3048,12 @@ int setcurr_tab_spaces (Text *text, int space)
if (i == text->curc)
{
return i;
- } else {
+ }
+ else {
i++;
}
}
- if(strstr(text->curl->line, word))
+ if (strstr(text->curl->line, word))
{
/* if we find a ':' on this line, then add a tab but not if it is:
* 1) in a comment
@@ -2997,14 +3061,16 @@ int setcurr_tab_spaces (Text *text, int space)
* 3) after the cursor (text->curc), i.e. when creating space before a function def [#25414]
*/
int a, is_indent = 0;
- for(a=0; (a < text->curc) && (text->curl->line[a] != '\0'); a++)
+ for (a=0; (a < text->curc) && (text->curl->line[a] != '\0'); a++)
{
char ch= text->curl->line[a];
if (ch=='#') {
break;
- } else if (ch==':') {
+ }
+ else if (ch==':') {
is_indent = 1;
- } else if (ch!=' ' && ch!='\t') {
+ }
+ else if (ch!=' ' && ch!='\t') {
is_indent = 0;
}
}
@@ -3013,12 +3079,12 @@ int setcurr_tab_spaces (Text *text, int space)
}
}
- for(test=0; back_words[test]; test++)
+ for (test=0; back_words[test]; test++)
{
/* if there are these key words then remove a tab because we are done with the block */
- if(strstr(text->curl->line, back_words[test]) && i > 0)
+ if (strstr(text->curl->line, back_words[test]) && i > 0)
{
- if(strcspn(text->curl->line, back_words[test]) < strcspn(text->curl->line, comm))
+ if (strcspn(text->curl->line, back_words[test]) < strcspn(text->curl->line, comm))
{
i -= space;
}
@@ -3184,10 +3250,10 @@ int text_check_bracket(char ch)
char opens[] = "([{";
char close[] = ")]}";
- for(a=0; a<(sizeof(opens)-1); a++) {
- if(ch==opens[a])
+ for (a=0; a<(sizeof(opens)-1); a++) {
+ if (ch==opens[a])
return a+1;
- else if(ch==close[a])
+ else if (ch==close[a])
return -(a+1);
}
return 0;
@@ -3198,8 +3264,8 @@ int text_check_delim(char ch)
int a;
char delims[] = "():\"\' ~!%^&*-+=[]{};/<>|.#\t,";
- for(a=0; a<(sizeof(delims)-1); a++) {
- if(ch==delims[a])
+ for (a=0; a<(sizeof(delims)-1); a++) {
+ if (ch==delims[a])
return 1;
}
return 0;
@@ -3207,25 +3273,25 @@ int text_check_delim(char ch)
int text_check_digit(char ch)
{
- if(ch < '0') return 0;
- if(ch <= '9') return 1;
+ if (ch < '0') return 0;
+ if (ch <= '9') return 1;
return 0;
}
int text_check_identifier(char ch)
{
- if(ch < '0') return 0;
- if(ch <= '9') return 1;
- if(ch < 'A') return 0;
- if(ch <= 'Z' || ch == '_') return 1;
- if(ch < 'a') return 0;
- if(ch <= 'z') return 1;
+ if (ch < '0') return 0;
+ if (ch <= '9') return 1;
+ if (ch < 'A') return 0;
+ if (ch <= 'Z' || ch == '_') return 1;
+ if (ch < 'a') return 0;
+ if (ch <= 'z') return 1;
return 0;
}
int text_check_whitespace(char ch)
{
- if(ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n')
+ if (ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n')
return 1;
return 0;
}
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index 23a30b6522b..cd1b05971f5 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -81,7 +81,7 @@ int test_dlerr(const char *name, const char *symbol)
char *err;
err= BLI_dynlib_get_error_as_string(NULL);
- if(err) {
+ if (err) {
printf("var1: %s, var2: %s, var3: %s\n", name, symbol, err);
return 1;
}
@@ -114,7 +114,7 @@ void open_plugin_tex(PluginTex *pit)
/* open the needed object */
pit->handle= BLI_dynlib_open(pit->name);
- if(test_dlerr(pit->name, pit->name)) return;
+ if (test_dlerr(pit->name, pit->name)) return;
if (pit->handle != NULL) {
/* find the address of the version function */
@@ -123,7 +123,7 @@ void open_plugin_tex(PluginTex *pit)
if (version != NULL) {
pit->version= version();
- if( pit->version >= 2 && pit->version <=6) {
+ if ( pit->version >= 2 && pit->version <=6) {
int (*info_func)(PluginInfo *);
PluginInfo *info= (PluginInfo*) MEM_mallocN(sizeof(PluginInfo), "plugin_info");
@@ -146,7 +146,8 @@ void open_plugin_tex(PluginTex *pit)
if (info->init) info->init();
}
MEM_freeN(info);
- } else {
+ }
+ else {
printf ("Plugin returned unrecognized version number\n");
return;
}
@@ -171,18 +172,18 @@ PluginTex *add_plugin_tex(char *str)
BLI_strncpy(pit->name, str, sizeof(pit->name));
open_plugin_tex(pit);
- if(pit->doit==NULL) {
- if(pit->handle==NULL) {;} //XXX error("no plugin: %s", str);
+ if (pit->doit==NULL) {
+ if (pit->handle==NULL) {;} //XXX error("no plugin: %s", str);
else {;} //XXX error("in plugin: %s", str);
MEM_freeN(pit);
return NULL;
}
varstr= pit->varstr;
- for(a=0; a<pit->vars; a++, varstr++) {
- if( (varstr->type & FLO)==FLO)
+ for (a=0; a<pit->vars; a++, varstr++) {
+ if ( (varstr->type & FLO)==FLO)
pit->data[a]= varstr->def;
- else if( (varstr->type & INT)==INT)
+ else if ( (varstr->type & INT)==INT)
*((int *)(pit->data+a))= (int) varstr->def;
}
@@ -196,7 +197,7 @@ PluginTex *add_plugin_tex(char *str)
void free_plugin_tex(PluginTex *pit)
{
- if(pit==NULL) return;
+ if (pit==NULL) return;
/* no BLI_dynlib_close: same plugin can be opened multiple times, 1 handle */
MEM_freeN(pit);
@@ -231,7 +232,7 @@ void init_tex_mapping(TexMapping *texmap)
{
float smat[3][3], rmat[3][3], mat[3][3], proj[3][3];
- if(texmap->projx == PROJ_X && texmap->projy == PROJ_Y && texmap->projz == PROJ_Z &&
+ if (texmap->projx == PROJ_X && texmap->projy == PROJ_Y && texmap->projz == PROJ_Z &&
is_zero_v3(texmap->loc) && is_zero_v3(texmap->rot) && is_one_v3(texmap->size)) {
unit_m4(texmap->mat);
@@ -241,11 +242,11 @@ void init_tex_mapping(TexMapping *texmap)
/* axis projection */
zero_m3(proj);
- if(texmap->projx != PROJ_N)
+ if (texmap->projx != PROJ_N)
proj[texmap->projx-1][0]= 1.0f;
- if(texmap->projy != PROJ_N)
+ if (texmap->projy != PROJ_N)
proj[texmap->projy-1][1]= 1.0f;
- if(texmap->projz != PROJ_N)
+ if (texmap->projz != PROJ_N)
proj[texmap->projz-1][2]= 1.0f;
/* scale */
@@ -302,7 +303,7 @@ void init_colorband(ColorBand *coba, int rangetype)
coba->data[0].pos= 0.0;
coba->data[1].pos= 1.0;
- if(rangetype==0) {
+ if (rangetype==0) {
coba->data[0].r= 0.0;
coba->data[0].g= 0.0;
coba->data[0].b= 0.0;
@@ -325,7 +326,7 @@ void init_colorband(ColorBand *coba, int rangetype)
coba->data[1].a= 1.0;
}
- for(a=2; a<MAXCOLORBAND; a++) {
+ for (a=2; a<MAXCOLORBAND; a++) {
coba->data[a].r= 0.5;
coba->data[a].g= 0.5;
coba->data[a].b= 0.5;
@@ -355,17 +356,17 @@ int do_colorband(const ColorBand *coba, float in, float out[4])
float fac, mfac, t[4];
int a;
- if(coba==NULL || coba->tot==0) return 0;
+ if (coba==NULL || coba->tot==0) return 0;
cbd1= coba->data;
- if(coba->tot==1) {
+ if (coba->tot==1) {
out[0]= cbd1->r;
out[1]= cbd1->g;
out[2]= cbd1->b;
out[3]= cbd1->a;
}
else {
- if(in <= cbd1->pos && coba->ipotype<2) {
+ if (in <= cbd1->pos && coba->ipotype<2) {
out[0]= cbd1->r;
out[1]= cbd1->g;
out[2]= cbd1->b;
@@ -375,22 +376,22 @@ int do_colorband(const ColorBand *coba, float in, float out[4])
CBData left, right;
/* we're looking for first pos > in */
- for(a=0; a<coba->tot; a++, cbd1++) if(cbd1->pos > in) break;
+ for (a=0; a<coba->tot; a++, cbd1++) if(cbd1->pos > in) break;
- if(a==coba->tot) {
+ if (a==coba->tot) {
cbd2= cbd1-1;
right= *cbd2;
right.pos= 1.0f;
cbd1= &right;
}
- else if(a==0) {
+ else if (a==0) {
left= *cbd1;
left.pos= 0.0f;
cbd2= &left;
}
else cbd2= cbd1-1;
- if(in >= cbd1->pos && coba->ipotype<2) {
+ if (in >= cbd1->pos && coba->ipotype<2) {
out[0]= cbd1->r;
out[1]= cbd1->g;
out[2]= cbd1->b;
@@ -398,7 +399,7 @@ int do_colorband(const ColorBand *coba, float in, float out[4])
}
else {
- if(cbd2->pos!=cbd1->pos)
+ if (cbd2->pos!=cbd1->pos)
fac= (in-cbd1->pos)/(cbd2->pos-cbd1->pos);
else {
/* was setting to 0.0 in 2.56 & previous, but this
@@ -415,17 +416,17 @@ int do_colorband(const ColorBand *coba, float in, float out[4])
return 1;
}
- if(coba->ipotype>=2) {
+ if (coba->ipotype>=2) {
/* ipo from right to left: 3 2 1 0 */
- if(a>=coba->tot-1) cbd0= cbd1;
+ if (a>=coba->tot-1) cbd0= cbd1;
else cbd0= cbd1+1;
- if(a<2) cbd3= cbd2;
+ if (a<2) cbd3= cbd2;
else cbd3= cbd2-1;
CLAMP(fac, 0.0f, 1.0f);
- if(coba->ipotype==3)
+ if (coba->ipotype==3)
key_curve_position_weights(fac, t, KEY_CARDINAL);
else
key_curve_position_weights(fac, t, KEY_BSPLINE);
@@ -441,7 +442,7 @@ int do_colorband(const ColorBand *coba, float in, float out[4])
}
else {
- if(coba->ipotype==1) { /* EASE */
+ if (coba->ipotype==1) { /* EASE */
mfac= fac*fac;
fac= 3.0f*mfac-2.0f*mfac*fac;
}
@@ -465,7 +466,7 @@ void colorband_table_RGBA(ColorBand *coba, float **array, int *size)
*size = CM_TABLE+1;
*array = MEM_callocN(sizeof(float)*(*size)*4, "ColorBand");
- for(a=0; a<*size; a++)
+ for (a=0; a<*size; a++)
do_colorband(coba, (float)a/(float)CM_TABLE, &(*array)[a*4]);
}
@@ -473,8 +474,8 @@ int vergcband(const void *a1, const void *a2)
{
const CBData *x1=a1, *x2=a2;
- if( x1->pos > x2->pos ) return 1;
- else if( x1->pos < x2->pos) return -1;
+ if ( x1->pos > x2->pos ) return 1;
+ else if ( x1->pos < x2->pos) return -1;
return 0;
}
@@ -482,16 +483,16 @@ void colorband_update_sort(ColorBand *coba)
{
int a;
- if(coba->tot<2)
+ if (coba->tot<2)
return;
- for(a=0; a<coba->tot; a++)
+ for (a=0; a<coba->tot; a++)
coba->data[a].cur= a;
qsort(coba->data, coba->tot, sizeof(CBData), vergcband);
- for(a=0; a<coba->tot; a++) {
- if(coba->data[a].cur==coba->cur) {
+ for (a=0; a<coba->tot; a++) {
+ if (coba->data[a].cur==coba->cur) {
coba->cur= a;
break;
}
@@ -500,10 +501,10 @@ void colorband_update_sort(ColorBand *coba)
CBData *colorband_element_add(struct ColorBand *coba, float position)
{
- if(coba->tot==MAXCOLORBAND) {
+ if (coba->tot==MAXCOLORBAND) {
return NULL;
}
- else if(coba->tot > 0) {
+ else if (coba->tot > 0) {
CBData *xnew;
float col[4];
@@ -530,16 +531,16 @@ int colorband_element_remove(struct ColorBand *coba, int index)
{
int a;
- if(coba->tot < 2)
+ if (coba->tot < 2)
return 0;
- if(index < 0 || index >= coba->tot)
+ if (index < 0 || index >= coba->tot)
return 0;
- for(a = index; a < coba->tot; a++) {
+ for (a = index; a < coba->tot; a++) {
coba->data[a] = coba->data[a + 1];
}
- if(coba->cur) coba->cur--;
+ if (coba->cur) coba->cur--;
coba->tot--;
return 1;
}
@@ -550,18 +551,18 @@ void free_texture(Tex *tex)
{
free_plugin_tex(tex->plugin);
- if(tex->coba) MEM_freeN(tex->coba);
- if(tex->env) BKE_free_envmap(tex->env);
- if(tex->pd) BKE_free_pointdensity(tex->pd);
- if(tex->vd) BKE_free_voxeldata(tex->vd);
- if(tex->ot) BKE_free_oceantex(tex->ot);
+ if (tex->coba) MEM_freeN(tex->coba);
+ if (tex->env) BKE_free_envmap(tex->env);
+ if (tex->pd) BKE_free_pointdensity(tex->pd);
+ if (tex->vd) BKE_free_voxeldata(tex->vd);
+ if (tex->ot) BKE_free_oceantex(tex->ot);
BKE_free_animdata((struct ID *)tex);
BKE_previewimg_free(&tex->preview);
BKE_icon_delete((struct ID*)tex);
tex->id.icon_id = 0;
- if(tex->nodetree) {
+ if (tex->nodetree) {
ntreeFreeTree(tex->nodetree);
MEM_freeN(tex->nodetree);
}
@@ -645,8 +646,8 @@ void default_tex(Tex *tex)
pit = tex->plugin;
if (pit) {
varstr= pit->varstr;
- if(varstr) {
- for(a=0; a<pit->vars; a++, varstr++) {
+ if (varstr) {
+ for (a=0; a<pit->vars; a++, varstr++) {
pit->data[a] = varstr->def;
}
}
@@ -786,11 +787,11 @@ MTex *add_mtex_id(ID *id, int slot)
give_active_mtex(id, &mtex_ar, &act);
- if(mtex_ar==NULL) {
+ if (mtex_ar==NULL) {
return NULL;
}
- if(slot==-1) {
+ if (slot==-1) {
/* find first free */
int i;
for (i= 0; i < MAX_MTEX; i++) {
@@ -799,13 +800,13 @@ MTex *add_mtex_id(ID *id, int slot)
break;
}
}
- if(slot == -1) {
+ if (slot == -1) {
return NULL;
}
}
else {
/* make sure slot is valid */
- if(slot < 0 || slot >= MAX_MTEX) {
+ if (slot < 0 || slot >= MAX_MTEX) {
return NULL;
}
}
@@ -828,22 +829,22 @@ Tex *copy_texture(Tex *tex)
Tex *texn;
texn= copy_libblock(&tex->id);
- if(texn->type==TEX_IMAGE) id_us_plus((ID *)texn->ima);
+ if (texn->type==TEX_IMAGE) id_us_plus((ID *)texn->ima);
else texn->ima= NULL;
- if(texn->plugin) {
+ if (texn->plugin) {
texn->plugin= MEM_dupallocN(texn->plugin);
open_plugin_tex(texn->plugin);
}
- if(texn->coba) texn->coba= MEM_dupallocN(texn->coba);
- if(texn->env) texn->env= BKE_copy_envmap(texn->env);
- if(texn->pd) texn->pd= BKE_copy_pointdensity(texn->pd);
- if(texn->vd) texn->vd= MEM_dupallocN(texn->vd);
- if(texn->ot) texn->ot= BKE_copy_oceantex(texn->ot);
- if(tex->preview) texn->preview = BKE_previewimg_copy(tex->preview);
+ if (texn->coba) texn->coba= MEM_dupallocN(texn->coba);
+ if (texn->env) texn->env= BKE_copy_envmap(texn->env);
+ if (texn->pd) texn->pd= BKE_copy_pointdensity(texn->pd);
+ if (texn->vd) texn->vd= MEM_dupallocN(texn->vd);
+ if (texn->ot) texn->ot= BKE_copy_oceantex(texn->ot);
+ if (tex->preview) texn->preview = BKE_previewimg_copy(tex->preview);
- if(tex->nodetree) {
+ if (tex->nodetree) {
if (tex->nodetree->execdata) {
ntreeTexEndExecTree(tex->nodetree->execdata, 1);
}
@@ -863,29 +864,29 @@ Tex *localize_texture(Tex *tex)
/* image texture: free_texture also doesn't decrease */
- if(texn->plugin) {
+ if (texn->plugin) {
texn->plugin= MEM_dupallocN(texn->plugin);
open_plugin_tex(texn->plugin);
}
- if(texn->coba) texn->coba= MEM_dupallocN(texn->coba);
- if(texn->env) {
+ if (texn->coba) texn->coba= MEM_dupallocN(texn->coba);
+ if (texn->env) {
texn->env= BKE_copy_envmap(texn->env);
id_us_min(&texn->env->ima->id);
}
- if(texn->pd) texn->pd= BKE_copy_pointdensity(texn->pd);
- if(texn->vd) {
+ if (texn->pd) texn->pd= BKE_copy_pointdensity(texn->pd);
+ if (texn->vd) {
texn->vd= MEM_dupallocN(texn->vd);
- if(texn->vd->dataset)
+ if (texn->vd->dataset)
texn->vd->dataset= MEM_dupallocN(texn->vd->dataset);
}
- if(texn->ot) {
+ if (texn->ot) {
texn->ot= BKE_copy_oceantex(tex->ot);
}
texn->preview = NULL;
- if(tex->nodetree) {
+ if (tex->nodetree) {
texn->nodetree= ntreeLocalize(tex->nodetree);
}
@@ -915,68 +916,68 @@ void make_local_texture(Tex *tex)
* - mixed: make copy
*/
- if(tex->id.lib==NULL) return;
+ if (tex->id.lib==NULL) return;
- if(tex->id.us==1) {
+ if (tex->id.us==1) {
id_clear_lib_data(bmain, &tex->id);
extern_local_texture(tex);
return;
}
ma= bmain->mat.first;
- while(ma) {
- for(a=0; a<MAX_MTEX; a++) {
- if(ma->mtex[a] && ma->mtex[a]->tex==tex) {
- if(ma->id.lib) is_lib= TRUE;
+ while (ma) {
+ for (a=0; a<MAX_MTEX; a++) {
+ if (ma->mtex[a] && ma->mtex[a]->tex==tex) {
+ if (ma->id.lib) is_lib= TRUE;
else is_local= TRUE;
}
}
ma= ma->id.next;
}
la= bmain->lamp.first;
- while(la) {
- for(a=0; a<MAX_MTEX; a++) {
- if(la->mtex[a] && la->mtex[a]->tex==tex) {
- if(la->id.lib) is_lib= TRUE;
+ while (la) {
+ for (a=0; a<MAX_MTEX; a++) {
+ if (la->mtex[a] && la->mtex[a]->tex==tex) {
+ if (la->id.lib) is_lib= TRUE;
else is_local= TRUE;
}
}
la= la->id.next;
}
wrld= bmain->world.first;
- while(wrld) {
- for(a=0; a<MAX_MTEX; a++) {
- if(wrld->mtex[a] && wrld->mtex[a]->tex==tex) {
- if(wrld->id.lib) is_lib= TRUE;
+ while (wrld) {
+ for (a=0; a<MAX_MTEX; a++) {
+ if (wrld->mtex[a] && wrld->mtex[a]->tex==tex) {
+ if (wrld->id.lib) is_lib= TRUE;
else is_local= TRUE;
}
}
wrld= wrld->id.next;
}
br= bmain->brush.first;
- while(br) {
- if(br->mtex.tex==tex) {
- if(br->id.lib) is_lib= TRUE;
+ while (br) {
+ if (br->mtex.tex==tex) {
+ if (br->id.lib) is_lib= TRUE;
else is_local= TRUE;
}
br= br->id.next;
}
pa= bmain->particle.first;
- while(pa) {
- for(a=0; a<MAX_MTEX; a++) {
- if(pa->mtex[a] && pa->mtex[a]->tex==tex) {
- if(pa->id.lib) is_lib= TRUE;
+ while (pa) {
+ for (a=0; a<MAX_MTEX; a++) {
+ if (pa->mtex[a] && pa->mtex[a]->tex==tex) {
+ if (pa->id.lib) is_lib= TRUE;
else is_local= TRUE;
}
}
pa= pa->id.next;
}
- if(is_local && is_lib == FALSE) {
+ if (is_local && is_lib == FALSE) {
id_clear_lib_data(bmain, &tex->id);
extern_local_texture(tex);
}
- else if(is_local && is_lib) {
+ else if (is_local && is_lib) {
Tex *tex_new= copy_texture(tex);
tex_new->id.us= 0;
@@ -985,10 +986,10 @@ void make_local_texture(Tex *tex)
BKE_id_lib_local_paths(bmain, tex->id.lib, &tex_new->id);
ma= bmain->mat.first;
- while(ma) {
- for(a=0; a<MAX_MTEX; a++) {
- if(ma->mtex[a] && ma->mtex[a]->tex==tex) {
- if(ma->id.lib==NULL) {
+ while (ma) {
+ for (a=0; a<MAX_MTEX; a++) {
+ if (ma->mtex[a] && ma->mtex[a]->tex==tex) {
+ if (ma->id.lib==NULL) {
ma->mtex[a]->tex= tex_new;
tex_new->id.us++;
tex->id.us--;
@@ -998,10 +999,10 @@ void make_local_texture(Tex *tex)
ma= ma->id.next;
}
la= bmain->lamp.first;
- while(la) {
- for(a=0; a<MAX_MTEX; a++) {
- if(la->mtex[a] && la->mtex[a]->tex==tex) {
- if(la->id.lib==NULL) {
+ while (la) {
+ for (a=0; a<MAX_MTEX; a++) {
+ if (la->mtex[a] && la->mtex[a]->tex==tex) {
+ if (la->id.lib==NULL) {
la->mtex[a]->tex= tex_new;
tex_new->id.us++;
tex->id.us--;
@@ -1011,10 +1012,10 @@ void make_local_texture(Tex *tex)
la= la->id.next;
}
wrld= bmain->world.first;
- while(wrld) {
- for(a=0; a<MAX_MTEX; a++) {
- if(wrld->mtex[a] && wrld->mtex[a]->tex==tex) {
- if(wrld->id.lib==NULL) {
+ while (wrld) {
+ for (a=0; a<MAX_MTEX; a++) {
+ if (wrld->mtex[a] && wrld->mtex[a]->tex==tex) {
+ if (wrld->id.lib==NULL) {
wrld->mtex[a]->tex= tex_new;
tex_new->id.us++;
tex->id.us--;
@@ -1024,9 +1025,9 @@ void make_local_texture(Tex *tex)
wrld= wrld->id.next;
}
br= bmain->brush.first;
- while(br) {
- if(br->mtex.tex==tex) {
- if(br->id.lib==NULL) {
+ while (br) {
+ if (br->mtex.tex==tex) {
+ if (br->id.lib==NULL) {
br->mtex.tex= tex_new;
tex_new->id.us++;
tex->id.us--;
@@ -1035,10 +1036,10 @@ void make_local_texture(Tex *tex)
br= br->id.next;
}
pa= bmain->particle.first;
- while(pa) {
- for(a=0; a<MAX_MTEX; a++) {
- if(pa->mtex[a] && pa->mtex[a]->tex==tex) {
- if(pa->id.lib==NULL) {
+ while (pa) {
+ for (a=0; a<MAX_MTEX; a++) {
+ if (pa->mtex[a] && pa->mtex[a]->tex==tex) {
+ if (pa->id.lib==NULL) {
pa->mtex[a]->tex= tex_new;
tex_new->id.us++;
tex->id.us--;
@@ -1061,14 +1062,14 @@ void autotexname(Tex *tex)
Image *ima;
char di[FILE_MAXDIR], fi[FILE_MAXFILE];
- if(tex) {
- if(tex->use_nodes) {
+ if (tex) {
+ if (tex->use_nodes) {
new_id(&bmain->tex, (ID *)tex, "Noddy");
}
else
- if(tex->type==TEX_IMAGE) {
+ if (tex->type==TEX_IMAGE) {
ima= tex->ima;
- if(ima) {
+ if (ima) {
BLI_strncpy(di, ima->name, sizeof(di));
BLI_splitdirstring(di, fi);
strcpy(di, "I.");
@@ -1077,7 +1078,7 @@ void autotexname(Tex *tex)
}
else new_id(&bmain->tex, (ID *)tex, texstr[tex->type]);
}
- else if(tex->type==TEX_PLUGIN && tex->plugin) new_id(&bmain->tex, (ID *)tex, tex->plugin->pname);
+ else if (tex->type==TEX_PLUGIN && tex->plugin) new_id(&bmain->tex, (ID *)tex, tex->plugin->pname);
else new_id(&bmain->tex, (ID *)tex, texstr[tex->type]);
}
}
@@ -1089,15 +1090,16 @@ Tex *give_current_object_texture(Object *ob)
Material *ma, *node_ma;
Tex *tex= NULL;
- if(ob==NULL) return NULL;
- if(ob->totcol==0 && !(ob->type==OB_LAMP)) return NULL;
+ if (ob==NULL) return NULL;
+ if (ob->totcol==0 && !(ob->type==OB_LAMP)) return NULL;
- if(ob->type==OB_LAMP) {
+ if (ob->type==OB_LAMP) {
tex= give_current_lamp_texture(ob->data);
- } else {
+ }
+ else {
ma= give_current_material(ob, ob->actcol);
- if((node_ma=give_node_material(ma)))
+ if ((node_ma=give_node_material(ma)))
ma= node_ma;
tex= give_current_material_texture(ma);
@@ -1111,9 +1113,9 @@ Tex *give_current_lamp_texture(Lamp *la)
MTex *mtex= NULL;
Tex *tex= NULL;
- if(la) {
+ if (la) {
mtex= la->mtex[(int)(la->texact)];
- if(mtex) tex= mtex->tex;
+ if (mtex) tex= mtex->tex;
}
return tex;
@@ -1123,11 +1125,11 @@ void set_current_lamp_texture(Lamp *la, Tex *newtex)
{
int act= la->texact;
- if(la->mtex[act] && la->mtex[act]->tex)
+ if (la->mtex[act] && la->mtex[act]->tex)
id_us_min(&la->mtex[act]->tex->id);
- if(newtex) {
- if(!la->mtex[act]) {
+ if (newtex) {
+ if (!la->mtex[act]) {
la->mtex[act]= add_mtex();
la->mtex[act]->texco= TEXCO_GLOB;
}
@@ -1135,7 +1137,7 @@ void set_current_lamp_texture(Lamp *la, Tex *newtex)
la->mtex[act]->tex= newtex;
id_us_plus(&newtex->id);
}
- else if(la->mtex[act]) {
+ else if (la->mtex[act]) {
MEM_freeN(la->mtex[act]);
la->mtex[act]= NULL;
}
@@ -1143,7 +1145,7 @@ void set_current_lamp_texture(Lamp *la, Tex *newtex)
bNode *give_current_material_texture_node(Material *ma)
{
- if(ma && ma->use_nodes && ma->nodetree)
+ if (ma && ma->use_nodes && ma->nodetree)
return nodeGetActiveID(ma->nodetree, ID_TE);
return NULL;
@@ -1155,21 +1157,21 @@ Tex *give_current_material_texture(Material *ma)
Tex *tex= NULL;
bNode *node;
- if(ma && ma->use_nodes && ma->nodetree) {
+ if (ma && ma->use_nodes && ma->nodetree) {
/* first check texture, then material, this works together
* with a hack that clears the active ID flag for textures on
* making a material node active */
node= nodeGetActiveID(ma->nodetree, ID_TE);
- if(node) {
+ if (node) {
tex= (Tex *)node->id;
ma= NULL;
}
}
- if(ma) {
+ if (ma) {
mtex= ma->mtex[(int)(ma->texact)];
- if(mtex) tex= mtex->tex;
+ if (mtex) tex= mtex->tex;
}
return tex;
@@ -1180,23 +1182,23 @@ int give_active_mtex(ID *id, MTex ***mtex_ar, short *act)
switch(GS(id->name)) {
case ID_MA:
*mtex_ar= ((Material *)id)->mtex;
- if(act) *act= (((Material *)id)->texact);
+ if (act) *act= (((Material *)id)->texact);
break;
case ID_WO:
*mtex_ar= ((World *)id)->mtex;
- if(act) *act= (((World *)id)->texact);
+ if (act) *act= (((World *)id)->texact);
break;
case ID_LA:
*mtex_ar= ((Lamp *)id)->mtex;
- if(act) *act= (((Lamp *)id)->texact);
+ if (act) *act= (((Lamp *)id)->texact);
break;
case ID_PA:
*mtex_ar= ((ParticleSettings *)id)->mtex;
- if(act) *act= (((ParticleSettings *)id)->texact);
+ if (act) *act= (((ParticleSettings *)id)->texact);
break;
default:
*mtex_ar = NULL;
- if(act) *act= 0;
+ if (act) *act= 0;
return FALSE;
}
@@ -1205,8 +1207,8 @@ int give_active_mtex(ID *id, MTex ***mtex_ar, short *act)
void set_active_mtex(ID *id, short act)
{
- if(act<0) act= 0;
- else if(act>=MAX_MTEX) act= MAX_MTEX-1;
+ if (act<0) act= 0;
+ else if (act>=MAX_MTEX) act= MAX_MTEX-1;
switch(GS(id->name)) {
case ID_MA:
@@ -1229,10 +1231,10 @@ void set_current_material_texture(Material *ma, Tex *newtex)
Tex *tex= NULL;
bNode *node;
- if(ma && ma->use_nodes && ma->nodetree) {
+ if (ma && ma->use_nodes && ma->nodetree) {
node= nodeGetActiveID(ma->nodetree, ID_TE);
- if(node) {
+ if (node) {
tex= (Tex *)node->id;
id_us_min(&tex->id);
node->id= &newtex->id;
@@ -1240,20 +1242,20 @@ void set_current_material_texture(Material *ma, Tex *newtex)
ma= NULL;
}
}
- if(ma) {
+ if (ma) {
int act= (int)ma->texact;
tex= (ma->mtex[act])? ma->mtex[act]->tex: NULL;
id_us_min(&tex->id);
- if(newtex) {
- if(!ma->mtex[act])
+ if (newtex) {
+ if (!ma->mtex[act])
ma->mtex[act]= add_mtex();
ma->mtex[act]->tex= newtex;
id_us_plus(&newtex->id);
}
- else if(ma->mtex[act]) {
+ else if (ma->mtex[act]) {
MEM_freeN(ma->mtex[act]);
ma->mtex[act]= NULL;
}
@@ -1264,10 +1266,10 @@ int has_current_material_texture(Material *ma)
{
bNode *node;
- if(ma && ma->use_nodes && ma->nodetree) {
+ if (ma && ma->use_nodes && ma->nodetree) {
node= nodeGetActiveID(ma->nodetree, ID_TE);
- if(node)
+ if (node)
return 1;
}
@@ -1279,10 +1281,10 @@ Tex *give_current_world_texture(World *world)
MTex *mtex= NULL;
Tex *tex= NULL;
- if(!world) return NULL;
+ if (!world) return NULL;
mtex= world->mtex[(int)(world->texact)];
- if(mtex) tex= mtex->tex;
+ if (mtex) tex= mtex->tex;
return tex;
}
@@ -1291,11 +1293,11 @@ void set_current_world_texture(World *wo, Tex *newtex)
{
int act= wo->texact;
- if(wo->mtex[act] && wo->mtex[act]->tex)
+ if (wo->mtex[act] && wo->mtex[act]->tex)
id_us_min(&wo->mtex[act]->tex->id);
- if(newtex) {
- if(!wo->mtex[act]) {
+ if (newtex) {
+ if (!wo->mtex[act]) {
wo->mtex[act]= add_mtex();
wo->mtex[act]->texco= TEXCO_VIEW;
}
@@ -1303,7 +1305,7 @@ void set_current_world_texture(World *wo, Tex *newtex)
wo->mtex[act]->tex= newtex;
id_us_plus(&newtex->id);
}
- else if(wo->mtex[act]) {
+ else if (wo->mtex[act]) {
MEM_freeN(wo->mtex[act]);
wo->mtex[act]= NULL;
}
@@ -1316,10 +1318,10 @@ Tex *give_current_brush_texture(Brush *br)
void set_current_brush_texture(Brush *br, Tex *newtex)
{
- if(br->mtex.tex)
+ if (br->mtex.tex)
id_us_min(&br->mtex.tex->id);
- if(newtex) {
+ if (newtex) {
br->mtex.tex= newtex;
id_us_plus(&newtex->id);
}
@@ -1330,10 +1332,10 @@ Tex *give_current_particle_texture(ParticleSettings *part)
MTex *mtex= NULL;
Tex *tex= NULL;
- if(!part) return NULL;
+ if (!part) return NULL;
mtex= part->mtex[(int)(part->texact)];
- if(mtex) tex= mtex->tex;
+ if (mtex) tex= mtex->tex;
return tex;
}
@@ -1342,11 +1344,11 @@ void set_current_particle_texture(ParticleSettings *part, Tex *newtex)
{
int act= part->texact;
- if(part->mtex[act] && part->mtex[act]->tex)
+ if (part->mtex[act] && part->mtex[act]->tex)
id_us_min(&part->mtex[act]->tex->id);
- if(newtex) {
- if(!part->mtex[act]) {
+ if (newtex) {
+ if (!part->mtex[act]) {
part->mtex[act]= add_mtex();
part->mtex[act]->texco= TEXCO_ORCO;
part->mtex[act]->blendtype= MTEX_MUL;
@@ -1355,7 +1357,7 @@ void set_current_particle_texture(ParticleSettings *part, Tex *newtex)
part->mtex[act]->tex= newtex;
id_us_plus(&newtex->id);
}
- else if(part->mtex[act]) {
+ else if (part->mtex[act]) {
MEM_freeN(part->mtex[act]);
part->mtex[act]= NULL;
}
@@ -1387,8 +1389,8 @@ EnvMap *BKE_copy_envmap(EnvMap *env)
envn= MEM_dupallocN(env);
envn->ok= 0;
- for(a=0; a<6; a++) envn->cube[a]= NULL;
- if(envn->ima) id_us_plus((ID *)envn->ima);
+ for (a=0; a<6; a++) envn->cube[a]= NULL;
+ if (envn->ima) id_us_plus((ID *)envn->ima);
return envn;
}
@@ -1399,8 +1401,8 @@ void BKE_free_envmapdata(EnvMap *env)
{
unsigned int part;
- for(part=0; part<6; part++) {
- if(env->cube[part])
+ for (part=0; part<6; part++) {
+ if (env->cube[part])
IMB_freeImBuf(env->cube[part]);
env->cube[part]= NULL;
}
@@ -1458,7 +1460,7 @@ PointDensity *BKE_copy_pointdensity(PointDensity *pd)
pdn= MEM_dupallocN(pd);
pdn->point_tree = NULL;
pdn->point_data = NULL;
- if(pdn->coba) pdn->coba= MEM_dupallocN(pdn->coba);
+ if (pdn->coba) pdn->coba= MEM_dupallocN(pdn->coba);
pdn->falloff_curve = curvemapping_copy(pdn->falloff_curve); /* can be NULL */
return pdn;
}
@@ -1473,7 +1475,7 @@ void BKE_free_pointdensitydata(PointDensity *pd)
MEM_freeN(pd->point_data);
pd->point_data = NULL;
}
- if(pd->coba) {
+ if (pd->coba) {
MEM_freeN(pd->coba);
pd->coba = NULL;
}
@@ -1561,19 +1563,19 @@ void BKE_free_oceantex(struct OceanTex *ot)
/* ------------------------------------------------------------------------- */
int BKE_texture_dependsOnTime(const struct Tex *texture)
{
- if(texture->plugin) {
+ if (texture->plugin) {
// assume all plugins depend on time
return 1;
}
- else if( texture->ima &&
+ else if ( texture->ima &&
ELEM(texture->ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) {
return 1;
}
- else if(texture->adt) {
+ else if (texture->adt) {
// assume anything in adt means the texture is animated
return 1;
}
- else if(texture->type == TEX_NOISE) {
+ else if (texture->type == TEX_NOISE) {
// noise always varies with time
return 1;
}
diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c
index e9f0fecbe18..24087d625f0 100644
--- a/source/blender/blenkernel/intern/tracking.c
+++ b/source/blender/blenkernel/intern/tracking.c
@@ -112,68 +112,68 @@ void BKE_tracking_clamp_track(MovieTrackingTrack *track, int event)
}
/* sort */
- for(a= 0; a<2; a++) {
- if(track->pat_min[a]>track->pat_max[a])
+ for (a= 0; a<2; a++) {
+ if (track->pat_min[a]>track->pat_max[a])
SWAP(float, track->pat_min[a], track->pat_max[a]);
- if(track->search_min[a]>track->search_max[a])
+ if (track->search_min[a]>track->search_max[a])
SWAP(float, track->search_min[a], track->search_max[a]);
}
/* compute the effective pattern size, which differs from the fine resolution
* pattern size for the pyramid KLT tracker */
- for(a= 0; a<2; a++) {
+ for (a= 0; a<2; a++) {
pat_min[a] = max_pyramid_level_factor * track->pat_min[a];
pat_max[a] = max_pyramid_level_factor * track->pat_max[a];
}
- if(event==CLAMP_PAT_DIM) {
- for(a= 0; a<2; a++) {
+ if (event==CLAMP_PAT_DIM) {
+ for (a= 0; a<2; a++) {
/* search shouldn't be resized smaller than pattern */
track->search_min[a]= MIN2(pat_min[a], track->search_min[a]);
track->search_max[a]= MAX2(pat_max[a], track->search_max[a]);
}
}
- else if(event==CLAMP_PAT_POS) {
+ else if (event==CLAMP_PAT_POS) {
float dim[2];
sub_v2_v2v2(dim, track->pat_max, track->pat_min);
- for(a= 0; a<2; a++) {
+ for (a= 0; a<2; a++) {
/* pattern shouldn't be moved outside of search */
- if(pat_min[a] < track->search_min[a]) {
+ if (pat_min[a] < track->search_min[a]) {
track->pat_min[a]= track->search_min[a] - (pat_min[a] - track->pat_min[a]);
track->pat_max[a]= track->pat_min[a] + dim[a];
}
- if(track->pat_max[a] > track->search_max[a]) {
+ if (track->pat_max[a] > track->search_max[a]) {
track->pat_max[a]= track->search_max[a] - (pat_max[a] - track->pat_max[a]);
track->pat_min[a]= track->pat_max[a] - dim[a];
}
}
}
- else if(event==CLAMP_SEARCH_DIM) {
- for(a= 0; a<2; a++) {
+ else if (event==CLAMP_SEARCH_DIM) {
+ for (a= 0; a<2; a++) {
/* search shouldn't be resized smaller than pattern */
track->search_min[a]= MIN2(pat_min[a], track->search_min[a]);
track->search_max[a]= MAX2(pat_max[a], track->search_max[a]);
}
}
- else if(event==CLAMP_SEARCH_POS) {
+ else if (event==CLAMP_SEARCH_POS) {
float dim[2];
sub_v2_v2v2(dim, track->search_max, track->search_min);
- for(a= 0; a<2; a++) {
+ for (a= 0; a<2; a++) {
/* search shouldn't be moved inside pattern */
- if(track->search_min[a] > pat_min[a]) {
+ if (track->search_min[a] > pat_min[a]) {
track->search_min[a]= pat_min[a];
track->search_max[a]= track->search_min[a]+dim[a];
}
- if(track->search_max[a] < pat_max[a]) {
+ if (track->search_max[a] < pat_max[a]) {
track->search_max[a]= pat_max[a];
track->search_min[a]= track->search_max[a]-dim[a];
}
}
}
- else if(event==CLAMP_PYRAMID_LEVELS || (event==CLAMP_SEARCH_DIM && track->tracker == TRACKER_KLT)) {
+ else if (event==CLAMP_PYRAMID_LEVELS || (event==CLAMP_SEARCH_DIM && track->tracker == TRACKER_KLT)) {
float dim[2];
sub_v2_v2v2(dim, track->pat_max, track->pat_min);
{
@@ -181,7 +181,7 @@ void BKE_tracking_clamp_track(MovieTrackingTrack *track, int event)
/* resize the search area to something sensible based
* on the number of pyramid levels */
- for(a= 0; a<2; a++) {
+ for (a= 0; a<2; a++) {
track->search_min[a]= search_ratio * track->pat_min[a];
track->search_max[a]= search_ratio * track->pat_max[a];
}
@@ -189,11 +189,11 @@ void BKE_tracking_clamp_track(MovieTrackingTrack *track, int event)
}
/* marker's center should be in center of pattern */
- if(event==CLAMP_PAT_DIM || event==CLAMP_PAT_POS) {
+ if (event==CLAMP_PAT_DIM || event==CLAMP_PAT_POS) {
float dim[2];
sub_v2_v2v2(dim, track->pat_max, track->pat_min);
- for(a= 0; a<2; a++) {
+ for (a= 0; a<2; a++) {
track->pat_min[a]= -dim[a]/2.0f;
track->pat_max[a]= dim[a]/2.0f;
}
@@ -202,17 +202,18 @@ void BKE_tracking_clamp_track(MovieTrackingTrack *track, int event)
void BKE_tracking_track_flag(MovieTrackingTrack *track, int area, int flag, int clear)
{
- if(area==TRACK_AREA_NONE)
+ if (area==TRACK_AREA_NONE)
return;
- if(clear) {
- if(area&TRACK_AREA_POINT) track->flag&= ~flag;
- if(area&TRACK_AREA_PAT) track->pat_flag&= ~flag;
- if(area&TRACK_AREA_SEARCH) track->search_flag&= ~flag;
- } else {
- if(area&TRACK_AREA_POINT) track->flag|= flag;
- if(area&TRACK_AREA_PAT) track->pat_flag|= flag;
- if(area&TRACK_AREA_SEARCH) track->search_flag|= flag;
+ if (clear) {
+ if (area&TRACK_AREA_POINT) track->flag&= ~flag;
+ if (area&TRACK_AREA_PAT) track->pat_flag&= ~flag;
+ if (area&TRACK_AREA_SEARCH) track->search_flag&= ~flag;
+ }
+ else {
+ if (area&TRACK_AREA_POINT) track->flag|= flag;
+ if (area&TRACK_AREA_PAT) track->pat_flag|= flag;
+ if (area&TRACK_AREA_SEARCH) track->search_flag|= flag;
}
}
@@ -257,7 +258,7 @@ MovieTrackingTrack *BKE_tracking_add_track(MovieTracking *tracking, ListBase *tr
BKE_tracking_insert_marker(track, &marker);
- if(track->tracker == TRACKER_KLT)
+ if (track->tracker == TRACKER_KLT)
BKE_tracking_clamp_track(track, CLAMP_PYRAMID_LEVELS);
BLI_addtail(tracksbase, track);
@@ -270,24 +271,25 @@ MovieTrackingMarker *BKE_tracking_insert_marker(MovieTrackingTrack *track, Movie
{
MovieTrackingMarker *old_marker= NULL;
- if(track->markersnr)
+ if (track->markersnr)
old_marker= BKE_tracking_exact_marker(track, marker->framenr);
- if(old_marker) {
+ if (old_marker) {
*old_marker= *marker;
return old_marker;
- } else {
+ }
+ else {
int a= track->markersnr;
- while(a--) {
- if(track->markers[a].framenr<marker->framenr)
+ while (a--) {
+ if (track->markers[a].framenr<marker->framenr)
break;
}
track->markersnr++;
- if(track->markers) track->markers= MEM_reallocN(track->markers, sizeof(MovieTrackingMarker)*track->markersnr);
+ if (track->markers) track->markers= MEM_reallocN(track->markers, sizeof(MovieTrackingMarker)*track->markersnr);
else track->markers= MEM_callocN(sizeof(MovieTrackingMarker), "MovieTracking markers");
memmove(track->markers+a+2, track->markers+a+1, (track->markersnr-a-2)*sizeof(MovieTrackingMarker));
@@ -303,13 +305,14 @@ void BKE_tracking_delete_marker(MovieTrackingTrack *track, int framenr)
{
int a= 0;
- while(a<track->markersnr) {
- if(track->markers[a].framenr==framenr) {
- if(track->markersnr>1) {
+ while (a<track->markersnr) {
+ if (track->markers[a].framenr==framenr) {
+ if (track->markersnr>1) {
memmove(track->markers+a, track->markers+a+1, (track->markersnr-a-1)*sizeof(MovieTrackingMarker));
track->markersnr--;
track->markers= MEM_reallocN(track->markers, sizeof(MovieTrackingMarker)*track->markersnr);
- } else {
+ }
+ else {
MEM_freeN(track->markers);
track->markers= NULL;
track->markersnr= 0;
@@ -326,19 +329,19 @@ MovieTrackingMarker *BKE_tracking_get_marker(MovieTrackingTrack *track, int fram
{
int a= track->markersnr-1;
- if(!track->markersnr)
+ if (!track->markersnr)
return NULL;
/* approximate pre-first framenr marker with first marker */
- if(framenr<track->markers[0].framenr)
+ if (framenr<track->markers[0].framenr)
return &track->markers[0];
- if(track->last_marker<track->markersnr)
+ if (track->last_marker<track->markersnr)
a= track->last_marker;
- if(track->markers[a].framenr<=framenr) {
- while(a<track->markersnr && track->markers[a].framenr<=framenr) {
- if(track->markers[a].framenr==framenr) {
+ if (track->markers[a].framenr<=framenr) {
+ while (a<track->markersnr && track->markers[a].framenr<=framenr) {
+ if (track->markers[a].framenr==framenr) {
track->last_marker= a;
return &track->markers[a];
}
@@ -347,9 +350,10 @@ MovieTrackingMarker *BKE_tracking_get_marker(MovieTrackingTrack *track, int fram
/* if there's no marker for exact position, use nearest marker from left side */
return &track->markers[a-1];
- } else {
- while(a>=0 && track->markers[a].framenr>=framenr) {
- if(track->markers[a].framenr==framenr) {
+ }
+ else {
+ while (a>=0 && track->markers[a].framenr>=framenr) {
+ if (track->markers[a].framenr==framenr) {
track->last_marker= a;
return &track->markers[a];
}
@@ -368,7 +372,7 @@ MovieTrackingMarker *BKE_tracking_ensure_marker(MovieTrackingTrack *track, int f
{
MovieTrackingMarker *marker= BKE_tracking_get_marker(track, framenr);
- if(marker->framenr!=framenr) {
+ if (marker->framenr!=framenr) {
MovieTrackingMarker marker_new;
marker_new= *marker;
@@ -385,7 +389,7 @@ MovieTrackingMarker *BKE_tracking_exact_marker(MovieTrackingTrack *track, int fr
{
MovieTrackingMarker *marker= BKE_tracking_get_marker(track, framenr);
- if(marker->framenr!=framenr)
+ if (marker->framenr!=framenr)
return NULL;
return marker;
@@ -405,7 +409,7 @@ int BKE_tracking_has_enabled_marker(MovieTrackingTrack *track, int framenr)
void BKE_tracking_free_track(MovieTrackingTrack *track)
{
- if(track->markers) MEM_freeN(track->markers);
+ if (track->markers) MEM_freeN(track->markers);
}
static void put_disabled_marker(MovieTrackingTrack *track, MovieTrackingMarker *ref_marker, int before, int overwrite)
@@ -416,10 +420,10 @@ static void put_disabled_marker(MovieTrackingTrack *track, MovieTrackingMarker *
marker_new.flag&= ~MARKER_TRACKED;
marker_new.flag|= MARKER_DISABLED;
- if(before) marker_new.framenr--;
+ if (before) marker_new.framenr--;
else marker_new.framenr++;
- if(!BKE_tracking_has_marker(track, marker_new.framenr) || overwrite)
+ if (!BKE_tracking_has_marker(track, marker_new.framenr) || overwrite)
BKE_tracking_insert_marker(track, &marker_new);
}
@@ -427,10 +431,10 @@ void BKE_tracking_clear_path(MovieTrackingTrack *track, int ref_frame, int actio
{
int a;
- if(action==TRACK_CLEAR_REMAINED) {
+ if (action==TRACK_CLEAR_REMAINED) {
a= 1;
- while(a<track->markersnr) {
- if(track->markers[a].framenr>ref_frame) {
+ while (a<track->markersnr) {
+ if (track->markers[a].framenr>ref_frame) {
track->markersnr= a;
track->markers= MEM_reallocN(track->markers, sizeof(MovieTrackingMarker)*track->markersnr);
@@ -440,12 +444,13 @@ void BKE_tracking_clear_path(MovieTrackingTrack *track, int ref_frame, int actio
a++;
}
- if(track->markersnr)
+ if (track->markersnr)
put_disabled_marker(track, &track->markers[track->markersnr-1], 0, 1);
- } else if(action==TRACK_CLEAR_UPTO) {
+ }
+ else if (action==TRACK_CLEAR_UPTO) {
a= track->markersnr-1;
- while(a>=0) {
- if(track->markers[a].framenr<=ref_frame) {
+ while (a>=0) {
+ if (track->markers[a].framenr<=ref_frame) {
memmove(track->markers, track->markers+a, (track->markersnr-a)*sizeof(MovieTrackingMarker));
track->markersnr= track->markersnr-a;
@@ -457,9 +462,10 @@ void BKE_tracking_clear_path(MovieTrackingTrack *track, int ref_frame, int actio
a--;
}
- if(track->markersnr)
+ if (track->markersnr)
put_disabled_marker(track, &track->markers[0], 1, 1);
- } else if(action==TRACK_CLEAR_ALL) {
+ }
+ else if (action==TRACK_CLEAR_ALL) {
MovieTrackingMarker *marker, marker_new;
marker= BKE_tracking_get_marker(track, ref_frame);
@@ -484,19 +490,21 @@ void BKE_tracking_join_tracks(MovieTrackingTrack *dst_track, MovieTrackingTrack
markers= MEM_callocN((dst_track->markersnr+src_track->markersnr)*sizeof(MovieTrackingMarker), "tmp tracking joined tracks");
while (a < src_track->markersnr || b < dst_track->markersnr) {
- if(b>=dst_track->markersnr) {
+ if (b>=dst_track->markersnr) {
markers[i]= src_track->markers[a++];
}
- else if(a>=src_track->markersnr) {
+ else if (a>=src_track->markersnr) {
markers[i]= dst_track->markers[b++];
}
- else if(src_track->markers[a].framenr<dst_track->markers[b].framenr) {
+ else if (src_track->markers[a].framenr<dst_track->markers[b].framenr) {
markers[i]= src_track->markers[a++];
- } else if(src_track->markers[a].framenr>dst_track->markers[b].framenr) {
+ }
+ else if (src_track->markers[a].framenr>dst_track->markers[b].framenr) {
markers[i]= dst_track->markers[b++];
- } else {
- if((src_track->markers[a].flag&MARKER_DISABLED)==0) {
- if((dst_track->markers[b].flag&MARKER_DISABLED)==0) {
+ }
+ else {
+ if ((src_track->markers[a].flag&MARKER_DISABLED)==0) {
+ if ((dst_track->markers[b].flag&MARKER_DISABLED)==0) {
/* both tracks are enabled on this frame, so find the whole segment
* on which tracks are intersecting and blend tracks using linear
* interpolation to prevent jumps */
@@ -575,7 +583,7 @@ static void tracking_tracks_free(ListBase *tracks)
{
MovieTrackingTrack *track;
- for(track= tracks->first; track; track= track->next) {
+ for (track= tracks->first; track; track= track->next) {
BKE_tracking_free_track(track);
}
@@ -584,7 +592,7 @@ static void tracking_tracks_free(ListBase *tracks)
static void tracking_reconstruction_free(MovieTrackingReconstruction *reconstruction)
{
- if(reconstruction->cameras)
+ if (reconstruction->cameras)
MEM_freeN(reconstruction->cameras);
}
@@ -598,7 +606,7 @@ static void tracking_objects_free(ListBase *objects)
{
MovieTrackingObject *object;
- for(object= objects->first; object; object= object->next)
+ for (object= objects->first; object; object= object->next)
tracking_object_free(object);
BLI_freelistN(objects);
@@ -610,10 +618,10 @@ void BKE_tracking_free(MovieTracking *tracking)
tracking_reconstruction_free(&tracking->reconstruction);
tracking_objects_free(&tracking->objects);
- if(tracking->stabilization.scaleibuf)
+ if (tracking->stabilization.scaleibuf)
IMB_freeImBuf(tracking->stabilization.scaleibuf);
- if(tracking->camera.intrinsics)
+ if (tracking->camera.intrinsics)
BKE_tracking_distortion_destroy(tracking->camera.intrinsics);
}
@@ -712,7 +720,7 @@ static TracksMap *tracks_map_new(const char *object_name, int is_camera, int num
map->tracks= MEM_callocN(sizeof(MovieTrackingTrack)*num_tracks, "TrackingsMap tracks");
- if(customdata_size)
+ if (customdata_size)
map->customdata= MEM_callocN(customdata_size*num_tracks, "TracksMap customdata");
map->hash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "TracksMap hash");
@@ -729,7 +737,7 @@ static void tracks_map_get(TracksMap *map, int index, MovieTrackingTrack **track
{
*track= &map->tracks[index];
- if(map->customdata)
+ if (map->customdata)
*customdata= &map->customdata[index*map->customdata_size];
}
@@ -741,7 +749,7 @@ static void tracks_map_insert(TracksMap *map, MovieTrackingTrack *track, void *c
map->tracks[map->ptr]= new_track;
- if(customdata)
+ if (customdata)
memcpy(&map->customdata[map->ptr*map->customdata_size], customdata, map->customdata_size);
BLI_ghash_insert(map->hash, &map->tracks[map->ptr], track);
@@ -758,12 +766,13 @@ static void tracks_map_merge(TracksMap *map, MovieTracking *tracking)
ListBase *old_tracks;
int a;
- if(map->is_camera) {
+ if (map->is_camera) {
old_tracks= &tracking->tracks;
- } else {
+ }
+ else {
MovieTrackingObject *object= BKE_tracking_named_object(tracking, map->object_name);
- if(!object) {
+ if (!object) {
/* object was deleted by user, create new one */
object= BKE_tracking_new_object(tracking, map->object_name);
}
@@ -774,7 +783,7 @@ static void tracks_map_merge(TracksMap *map, MovieTracking *tracking)
/* duplicate currently operating tracks to temporary list.
* this is needed to keep names in unique state and it's faster to change names
* of currently operating tracks (if needed) */
- for(a= 0; a<map->num_tracks; a++) {
+ for (a= 0; a<map->num_tracks; a++) {
int replace_sel= 0, replace_rot= 0;
MovieTrackingTrack *new_track, *old;
@@ -782,21 +791,21 @@ static void tracks_map_merge(TracksMap *map, MovieTracking *tracking)
/* find original of operating track in list of previously displayed tracks */
old= BLI_ghash_lookup(map->hash, track);
- if(old) {
+ if (old) {
MovieTrackingTrack *cur= old_tracks->first;
- while(cur) {
- if(cur==old)
+ while (cur) {
+ if (cur==old)
break;
cur= cur->next;
}
/* original track was found, re-use flags and remove this track */
- if(cur) {
- if(cur==act_track)
+ if (cur) {
+ if (cur==act_track)
replace_sel= 1;
- if(cur==rot_track)
+ if (cur==rot_track)
replace_rot= 1;
track->flag= cur->flag;
@@ -813,10 +822,10 @@ static void tracks_map_merge(TracksMap *map, MovieTracking *tracking)
BLI_ghash_remove(map->hash, track, NULL, NULL); /* XXX: are we actually need this */
BLI_ghash_insert(map->hash, track, new_track);
- if(replace_sel) /* update current selection in clip */
+ if (replace_sel) /* update current selection in clip */
tracking->act_track= new_track;
- if(replace_rot) /* update track used for rotation stabilization */
+ if (replace_rot) /* update track used for rotation stabilization */
tracking->stabilization.rot_track= new_track;
BLI_addtail(&tracks, new_track);
@@ -824,7 +833,7 @@ static void tracks_map_merge(TracksMap *map, MovieTracking *tracking)
/* move all tracks, which aren't operating */
track= old_tracks->first;
- while(track) {
+ while (track) {
MovieTrackingTrack *next= track->next;
track->next= track->prev= NULL;
@@ -835,7 +844,7 @@ static void tracks_map_merge(TracksMap *map, MovieTracking *tracking)
/* now move all tracks which are currently operating and keep their names unique */
track= tracks.first;
- while(track) {
+ while (track) {
MovieTrackingTrack *next= track->next;
BLI_remlink(&tracks, track);
@@ -857,14 +866,14 @@ static void tracks_map_free(TracksMap *map, void (*customdata_free) (void *custo
BLI_ghash_free(map->hash, NULL, NULL);
- for(i= 0; i<map->num_tracks; i++) {
- if(map->customdata && customdata_free)
+ for (i= 0; i<map->num_tracks; i++) {
+ if (map->customdata && customdata_free)
customdata_free(&map->customdata[i*map->customdata_size]);
BKE_tracking_free_track(&map->tracks[i]);
}
- if(map->customdata)
+ if (map->customdata)
MEM_freeN(map->customdata);
MEM_freeN(map->tracks);
@@ -922,18 +931,18 @@ MovieTrackingContext *BKE_tracking_context_new(MovieClip *clip, MovieClipUser *u
/* count */
track= tracksbase->first;
- while(track) {
- if(TRACK_SELECTED(track) && (track->flag & (TRACK_LOCKED | TRACK_HIDDEN))==0) {
+ while (track) {
+ if (TRACK_SELECTED(track) && (track->flag & (TRACK_LOCKED | TRACK_HIDDEN))==0) {
MovieTrackingMarker *marker= BKE_tracking_get_marker(track, user->framenr);
- if((marker->flag&MARKER_DISABLED)==0)
+ if ((marker->flag&MARKER_DISABLED)==0)
num_tracks++;
}
track= track->next;
}
- if(num_tracks) {
+ if (num_tracks) {
int width, height;
context->tracks_map= tracks_map_new(object->name, object->flag & TRACKING_OBJECT_CAMERA,
@@ -943,11 +952,11 @@ MovieTrackingContext *BKE_tracking_context_new(MovieClip *clip, MovieClipUser *u
/* create tracking data */
track= tracksbase->first;
- while(track) {
- if(TRACK_SELECTED(track) && (track->flag & (TRACK_HIDDEN | TRACK_LOCKED))==0) {
+ while (track) {
+ if (TRACK_SELECTED(track) && (track->flag & (TRACK_HIDDEN | TRACK_LOCKED))==0) {
MovieTrackingMarker *marker= BKE_tracking_get_marker(track, user->framenr);
- if((marker->flag&MARKER_DISABLED)==0) {
+ if ((marker->flag&MARKER_DISABLED)==0) {
TrackContext track_context;
memset(&track_context, 0, sizeof(TrackContext));
@@ -958,7 +967,7 @@ MovieTrackingContext *BKE_tracking_context_new(MovieClip *clip, MovieClipUser *u
patx= (int)((track->pat_max[0]-track->pat_min[0])*width);
paty= (int)((track->pat_max[1]-track->pat_min[1])*height);
- if(ELEM(track->tracker, TRACKER_KLT, TRACKER_HYBRID)) {
+ if (ELEM(track->tracker, TRACKER_KLT, TRACKER_HYBRID)) {
float search_size_x= (track->search_max[0]-track->search_min[0])*width;
float search_size_y= (track->search_max[1]-track->search_min[1])*height;
float pattern_size_x= (track->pat_max[0]-track->pat_min[0])*width;
@@ -976,12 +985,12 @@ MovieTrackingContext *BKE_tracking_context_new(MovieClip *clip, MovieClipUser *u
* than the search size */
int level= MIN2(track->pyramid_levels, max_pyramid_levels);
- if(track->tracker==TRACKER_KLT)
+ if (track->tracker==TRACKER_KLT)
track_context.region_tracker= libmv_pyramidRegionTrackerNew(100, level, MAX2(wndx, wndy), track->minimum_correlation);
else
track_context.region_tracker= libmv_hybridRegionTrackerNew(100, MAX2(wndx, wndy), track->minimum_correlation);
}
- else if(track->tracker==TRACKER_SAD) {
+ else if (track->tracker==TRACKER_SAD) {
track_context.pattern_size= MAX2(patx, paty);
}
}
@@ -1011,7 +1020,7 @@ MovieTrackingContext *BKE_tracking_context_new(MovieClip *clip, MovieClipUser *u
context->user.render_size= MCLIP_PROXY_RENDER_SIZE_FULL;
context->user.render_flag= 0;
- if(!sequence)
+ if (!sequence)
BLI_begin_threaded_malloc();
return context;
@@ -1022,16 +1031,16 @@ static void track_context_free(void *customdata)
TrackContext *track_context= (TrackContext *)customdata;
#if WITH_LIBMV
- if(track_context->region_tracker)
+ if (track_context->region_tracker)
libmv_regionTrackerDestroy(track_context->region_tracker);
- if(track_context->patch)
+ if (track_context->patch)
MEM_freeN(track_context->patch);
- if(track_context->pattern)
+ if (track_context->pattern)
MEM_freeN(track_context->pattern);
- if(track_context->warped)
+ if (track_context->warped)
MEM_freeN(track_context->warped);
#else
(void) track_context;
@@ -1040,7 +1049,7 @@ static void track_context_free(void *customdata)
void BKE_tracking_context_free(MovieTrackingContext *context)
{
- if(!context->sequence)
+ if (!context->sequence)
BLI_end_threaded_malloc();
tracks_map_free(context->tracks_map, track_context_free);
@@ -1056,7 +1065,7 @@ void BKE_tracking_disable_imbuf_channels(ImBuf *ibuf, int disable_red, int disab
int x, y;
float scale;
- if(!disable_red && !disable_green && !disable_blue && !grayscale)
+ if (!disable_red && !disable_green && !disable_blue && !grayscale)
return;
/* If only some components are selected, it's important to rescale the result
@@ -1065,11 +1074,11 @@ void BKE_tracking_disable_imbuf_channels(ImBuf *ibuf, int disable_red, int disab
(disable_green ? 0.0f : 0.7152f) +
(disable_blue ? 0.0f : 0.0722f);
- for(y= 0; y<ibuf->y; y++) {
+ for (y= 0; y<ibuf->y; y++) {
for (x= 0; x<ibuf->x; x++) {
int pixel= ibuf->x*y + x;
- if(ibuf->rect_float) {
+ if (ibuf->rect_float) {
float *rrgbf= ibuf->rect_float + pixel*4;
float r = disable_red ? 0.0f : rrgbf[0];
float g = disable_green ? 0.0f : rrgbf[1];
@@ -1077,12 +1086,14 @@ void BKE_tracking_disable_imbuf_channels(ImBuf *ibuf, int disable_red, int disab
if (grayscale) {
float gray = (0.2126f*r + 0.7152f*g + 0.0722f*b) / scale;
rrgbf[0] = rrgbf[1] = rrgbf[2] = gray;
- } else {
+ }
+ else {
rrgbf[0] = r;
rrgbf[1] = g;
rrgbf[2] = b;
}
- } else {
+ }
+ else {
char *rrgb= (char*)ibuf->rect + pixel*4;
char r = disable_red ? 0 : rrgb[0];
char g = disable_green ? 0 : rrgb[1];
@@ -1090,7 +1101,8 @@ void BKE_tracking_disable_imbuf_channels(ImBuf *ibuf, int disable_red, int disab
if (grayscale) {
float gray = (0.2126f*r + 0.7152f*g + 0.0722f*b) / scale;
rrgb[0] = rrgb[1] = rrgb[2] = gray;
- } else {
+ }
+ else {
rrgb[0] = r;
rrgb[1] = g;
rrgb[2] = b;
@@ -1115,10 +1127,10 @@ static ImBuf *get_area_imbuf(ImBuf *ibuf, MovieTrackingTrack *track, MovieTracki
float mpos[2];
copy_v2_v2(mpos, marker->pos);
- if(anchored)
+ if (anchored)
add_v2_v2(mpos, track->offset);
- if(pos)
+ if (pos)
zero_v2(pos);
x= mpos[0]*ibuf->x;
@@ -1137,17 +1149,17 @@ static ImBuf *get_area_imbuf(ImBuf *ibuf, MovieTrackingTrack *track, MovieTracki
tmpibuf= IMB_allocImBuf(w+margin*2, h+margin*2, 32, IB_rect);
IMB_rectcpy(tmpibuf, ibuf, 0, 0, x1-margin, y1-margin, w+margin*2, h+margin*2);
- if(pos != NULL) {
+ if (pos != NULL) {
pos[0]= mpos[0]*ibuf->x-x1+margin;
pos[1]= mpos[1]*ibuf->y-y1+margin;
}
- if(origin != NULL) {
+ if (origin != NULL) {
origin[0]= x1-margin;
origin[1]= y1-margin;
}
- if((track->flag & TRACK_PREVIEW_GRAYSCALE) ||
+ if ((track->flag & TRACK_PREVIEW_GRAYSCALE) ||
(track->flag & TRACK_DISABLE_RED) ||
(track->flag & TRACK_DISABLE_GREEN) ||
(track->flag & TRACK_DISABLE_BLUE))
@@ -1188,14 +1200,15 @@ static float *get_search_floatbuf(ImBuf *ibuf, MovieTrackingTrack *track, MovieT
*height_r= height;
fp= pixels= MEM_callocN(width*height*sizeof(float), "tracking floatBuf");
- for(y= 0; y<(int)height; y++) {
+ for (y= 0; y<(int)height; y++) {
for (x= 0; x<(int)width; x++) {
int pixel= tmpibuf->x*y + x;
- if(tmpibuf->rect_float) {
+ if (tmpibuf->rect_float) {
float *rrgbf= tmpibuf->rect_float + pixel*4;
*fp= 0.2126*rrgbf[0] + 0.7152*rrgbf[1] + 0.0722*rrgbf[2];
- } else {
+ }
+ else {
unsigned char *rrgb= (unsigned char*)tmpibuf->rect + pixel*4;
*fp= (0.2126*rrgb[0] + 0.7152*rrgb[1] + 0.0722*rrgb[2])/255.0f;
}
@@ -1214,15 +1227,16 @@ static unsigned char *get_ucharbuf(ImBuf *ibuf)
unsigned char *pixels, *cp;
cp= pixels= MEM_callocN(ibuf->x*ibuf->y*sizeof(unsigned char), "tracking ucharBuf");
- for(y= 0; y<ibuf->y; y++) {
+ for (y= 0; y<ibuf->y; y++) {
for (x= 0; x<ibuf->x; x++) {
int pixel= ibuf->x*y + x;
- if(ibuf->rect_float) {
+ if (ibuf->rect_float) {
const float *rrgbf= ibuf->rect_float + pixel*4;
const float grey_f= 0.2126f*rrgbf[0] + 0.7152f*rrgbf[1] + 0.0722f*rrgbf[2];
*cp= FTOCHAR(grey_f);
- } else {
+ }
+ else {
const unsigned char *rrgb= (unsigned char*)ibuf->rect + pixel*4;
*cp= 0.2126f*rrgb[0] + 0.7152f*rrgb[1] + 0.0722f*rrgb[2];
}
@@ -1272,22 +1286,22 @@ static ImBuf *get_keyframed_ibuf(MovieTrackingContext *context, MovieTrackingTra
*marker_keyed= marker;
- while(a>=0 && a<track->markersnr) {
+ while (a>=0 && a<track->markersnr) {
int next= (context->backwards) ? a+1 : a-1;
int is_keyframed= 0;
MovieTrackingMarker *cur_marker= &track->markers[a];
MovieTrackingMarker *next_marker= NULL;
- if(next>=0 && next<track->markersnr)
+ if (next>=0 && next<track->markersnr)
next_marker= &track->markers[next];
/* if next mrker is disabled, stop searching keyframe and use current frame as keyframe */
- if(next_marker && next_marker->flag&MARKER_DISABLED)
+ if (next_marker && next_marker->flag&MARKER_DISABLED)
is_keyframed= 1;
is_keyframed|= (cur_marker->flag&MARKER_TRACKED)==0;
- if(is_keyframed) {
+ if (is_keyframed) {
framenr= cur_marker->framenr;
*marker_keyed= cur_marker;
break;
@@ -1304,9 +1318,10 @@ static ImBuf *get_adjust_ibuf(MovieTrackingContext *context, MovieTrackingTrack
{
ImBuf *ibuf= NULL;
- if(track->pattern_match == TRACK_MATCH_KEYFRAME) {
+ if (track->pattern_match == TRACK_MATCH_KEYFRAME) {
ibuf= get_keyframed_ibuf(context, track, marker, marker_keyed);
- } else {
+ }
+ else {
ibuf= get_frame_ibuf(context, curfra);
/* use current marker as keyframed position */
@@ -1320,8 +1335,8 @@ static void get_warped(TrackContext *track_context, int x, int y, int width, uns
{
int i, j;
- for(i=0; i<track_context->pattern_size; i++) {
- for(j=0; j<track_context->pattern_size; j++) {
+ for (i=0; i<track_context->pattern_size; i++) {
+ for (j=0; j<track_context->pattern_size; j++) {
track_context->warped[i*track_context->pattern_size+j]=
image[(y+i-track_context->pattern_size/2)*width+x+j-track_context->pattern_size/2];
}
@@ -1337,7 +1352,7 @@ void BKE_tracking_sync(MovieTrackingContext *context)
tracks_map_merge(context->tracks_map, tracking);
- if(context->backwards) newframe= context->user.framenr+1;
+ if (context->backwards) newframe= context->user.framenr+1;
else newframe= context->user.framenr-1;
context->sync_frame= newframe;
@@ -1357,18 +1372,18 @@ int BKE_tracking_next(MovieTrackingContext *context)
map_size= tracks_map_size(context->tracks_map);
/* nothing to track, avoid unneeded frames reading to save time and memory */
- if(!map_size)
+ if (!map_size)
return 0;
- if(context->backwards) context->user.framenr--;
+ if (context->backwards) context->user.framenr--;
else context->user.framenr++;
ibuf_new= BKE_movieclip_get_ibuf_flag(context->clip, &context->user, context->clip_flag, MOVIECLIP_CACHE_SKIP);
- if(!ibuf_new)
+ if (!ibuf_new)
return 0;
#pragma omp parallel for private(a) shared(ibuf_new, ok) if(map_size>1)
- for(a= 0; a<map_size; a++) {
+ for (a= 0; a<map_size; a++) {
TrackContext *track_context = NULL;
MovieTrackingTrack *track;
MovieTrackingMarker *marker;
@@ -1377,7 +1392,7 @@ int BKE_tracking_next(MovieTrackingContext *context)
marker= BKE_tracking_exact_marker(track, curfra);
- if(marker && (marker->flag&MARKER_DISABLED)==0) {
+ if (marker && (marker->flag&MARKER_DISABLED)==0) {
#ifdef WITH_LIBMV
int width, height, origin[2], tracked= 0, need_readjust= 0;
float pos[2], margin[2], dim[2];
@@ -1386,12 +1401,12 @@ int BKE_tracking_next(MovieTrackingContext *context)
MovieTrackingMarker marker_new, *marker_keyed;
int onbound= 0, nextfra;
- if(track->pattern_match==TRACK_MATCH_KEYFRAME)
+ if (track->pattern_match==TRACK_MATCH_KEYFRAME)
need_readjust= context->first_time;
else
need_readjust= 1;
- if(context->backwards) nextfra= curfra-1;
+ if (context->backwards) nextfra= curfra-1;
else nextfra= curfra+1;
/* margin from frame boundaries */
@@ -1402,18 +1417,18 @@ int BKE_tracking_next(MovieTrackingContext *context)
margin[1]= MAX2(margin[1], (float)track->margin / ibuf_new->y);
/* do not track markers which are too close to boundary */
- if(marker->pos[0]<margin[0] || marker->pos[0]>1.0f-margin[0] ||
+ if (marker->pos[0]<margin[0] || marker->pos[0]>1.0f-margin[0] ||
marker->pos[1]<margin[1] || marker->pos[1]>1.0f-margin[1]) {
onbound= 1;
}
- else if(ELEM(track->tracker, TRACKER_KLT, TRACKER_HYBRID)) {
+ else if (ELEM(track->tracker, TRACKER_KLT, TRACKER_HYBRID)) {
float *patch_new;
- if(need_readjust) {
+ if (need_readjust) {
/* calculate patch for keyframed position */
ibuf= get_adjust_ibuf(context, track, marker, curfra, &marker_keyed);
- if(track_context->patch)
+ if (track_context->patch)
MEM_freeN(track_context->patch);
track_context->patch= get_search_floatbuf(ibuf, track, marker_keyed, &width, &height, track_context->keyframed_pos, origin);
@@ -1434,12 +1449,12 @@ int BKE_tracking_next(MovieTrackingContext *context)
MEM_freeN(patch_new);
}
- else if(track->tracker==TRACKER_SAD) {
+ else if (track->tracker==TRACKER_SAD) {
unsigned char *image_new;
float correlation;
float warp[3][2]={{0}};
- if(need_readjust) {
+ if (need_readjust) {
unsigned char *image;
/* calculate pattern for keyframed position */
@@ -1453,7 +1468,7 @@ int BKE_tracking_next(MovieTrackingContext *context)
warp[2][0]= pos[0];
warp[2][1]= pos[1];
- if(!track_context->pattern) {
+ if (!track_context->pattern) {
int square= track_context->pattern_size*track_context->pattern_size;
track_context->pattern= MEM_callocN(sizeof(unsigned char)*square, "trackking pattern");
}
@@ -1466,12 +1481,12 @@ int BKE_tracking_next(MovieTrackingContext *context)
image_new= get_search_bytebuf(ibuf_new, track, marker, &width, &height, pos, origin);
- if(track_context->warped==NULL) {
+ if (track_context->warped==NULL) {
unsigned char *image_old;
ibuf= get_frame_ibuf(context, curfra);
- if(track_context->warped==NULL) {
+ if (track_context->warped==NULL) {
int square= track_context->pattern_size*track_context->pattern_size;
track_context->warped= MEM_callocN(sizeof(unsigned char)*square, "trackking warped");
}
@@ -1496,14 +1511,14 @@ int BKE_tracking_next(MovieTrackingContext *context)
tracked= track->minimum_correlation < correlation;
- if(tracked)
+ if (tracked)
get_warped(track_context, x2, y2, width, image_new);
MEM_freeN(image_new);
}
- if(tracked && !onbound && finite(x2) && finite(y2)) {
- if(context->first_time) {
+ if (tracked && !onbound && finite(x2) && finite(y2)) {
+ if (context->first_time) {
#pragma omp critical
{
/* check if there's no keyframe/tracked markers before tracking marker.
@@ -1514,10 +1529,11 @@ int BKE_tracking_next(MovieTrackingContext *context)
memset(&marker_new, 0, sizeof(marker_new));
- if(!onbound) {
+ if (!onbound) {
marker_new.pos[0]= (origin[0]+x2)/ibuf_new->x;
marker_new.pos[1]= (origin[1]+y2)/ibuf_new->y;
- } else {
+ }
+ else {
copy_v2_v2(marker_new.pos, marker->pos);
}
@@ -1534,7 +1550,8 @@ int BKE_tracking_next(MovieTrackingContext *context)
{
put_disabled_marker(track, &marker_new, context->backwards, 0);
}
- } else {
+ }
+ else {
marker_new= *marker;
marker_new.framenr= nextfra;
@@ -1599,13 +1616,13 @@ static struct libmv_Tracks *create_libmv_tracks(ListBase *tracksbase, int width,
struct libmv_Tracks *tracks= libmv_tracksNew();
track= tracksbase->first;
- while(track) {
+ while (track) {
int a= 0;
- for(a= 0; a<track->markersnr; a++) {
+ for (a= 0; a<track->markersnr; a++) {
MovieTrackingMarker *marker= &track->markers[a];
- if((marker->flag&MARKER_DISABLED)==0)
+ if ((marker->flag&MARKER_DISABLED)==0)
libmv_tracksInsert(tracks, marker->framenr, tracknr,
marker->pos[0]*width, marker->pos[1]*height);
}
@@ -1650,7 +1667,7 @@ static int retrieve_libmv_reconstruct_tracks(MovieReconstructContext *context, M
int sfra= context->sfra, efra= context->efra;
float imat[4][4];
- if(context->is_camera) {
+ if (context->is_camera) {
tracksbase= &tracking->tracks;
reconstruction= &tracking->reconstruction;
}
@@ -1664,17 +1681,18 @@ static int retrieve_libmv_reconstruct_tracks(MovieReconstructContext *context, M
unit_m4(imat);
track= tracksbase->first;
- while(track) {
+ while (track) {
double pos[3];
- if(libmv_reporojectionPointForTrack(libmv_reconstruction, tracknr, pos)) {
+ if (libmv_reporojectionPointForTrack(libmv_reconstruction, tracknr, pos)) {
track->bundle_pos[0]= pos[0];
track->bundle_pos[1]= pos[1];
track->bundle_pos[2]= pos[2];
track->flag|= TRACK_HAS_BUNDLE;
track->error= libmv_reporojectionErrorForTrack(libmv_reconstruction, tracknr);
- } else {
+ }
+ else {
track->flag&= ~TRACK_HAS_BUNDLE;
ok= 0;
@@ -1685,53 +1703,54 @@ static int retrieve_libmv_reconstruct_tracks(MovieReconstructContext *context, M
tracknr++;
}
- if(reconstruction->cameras)
+ if (reconstruction->cameras)
MEM_freeN(reconstruction->cameras);
reconstruction->camnr= 0;
reconstruction->cameras= NULL;
reconstructed= MEM_callocN((efra-sfra+1)*sizeof(MovieReconstructedCamera), "temp reconstructed camera");
- for(a= sfra; a<=efra; a++) {
+ for (a= sfra; a<=efra; a++) {
double matd[4][4];
- if(libmv_reporojectionCameraForImage(libmv_reconstruction, a, matd)) {
+ if (libmv_reporojectionCameraForImage(libmv_reconstruction, a, matd)) {
int i, j;
float mat[4][4];
float error= libmv_reporojectionErrorForImage(libmv_reconstruction, a);
- for(i=0; i<4; i++)
- for(j= 0; j<4; j++)
+ for (i=0; i<4; i++)
+ for (j= 0; j<4; j++)
mat[i][j]= matd[i][j];
- if(!origin_set) {
+ if (!origin_set) {
copy_m4_m4(imat, mat);
invert_m4(imat);
origin_set= 1;
}
- if(origin_set)
+ if (origin_set)
mult_m4_m4m4(mat, imat, mat);
copy_m4_m4(reconstructed[reconstruction->camnr].mat, mat);
reconstructed[reconstruction->camnr].framenr= a;
reconstructed[reconstruction->camnr].error= error;
reconstruction->camnr++;
- } else {
+ }
+ else {
ok= 0;
printf("No camera for frame %d\n", a);
}
}
- if(reconstruction->camnr) {
+ if (reconstruction->camnr) {
reconstruction->cameras= MEM_callocN(reconstruction->camnr*sizeof(MovieReconstructedCamera), "reconstructed camera");
memcpy(reconstruction->cameras, reconstructed, reconstruction->camnr*sizeof(MovieReconstructedCamera));
}
- if(origin_set) {
+ if (origin_set) {
track= tracksbase->first;
- while(track) {
- if(track->flag&TRACK_HAS_BUNDLE)
+ while (track) {
+ if (track->flag&TRACK_HAS_BUNDLE)
mul_v3_m4v3(track->bundle_pos, imat, track->bundle_pos);
track= track->next;
@@ -1756,19 +1775,19 @@ static int get_refine_intrinsics_flags(MovieTracking *tracking, MovieTrackingObj
int refine= tracking->settings.refine_camera_intrinsics;
int flags= 0;
- if((object->flag&TRACKING_OBJECT_CAMERA)==0)
+ if ((object->flag&TRACKING_OBJECT_CAMERA)==0)
return 0;
- if(refine&REFINE_FOCAL_LENGTH)
+ if (refine&REFINE_FOCAL_LENGTH)
flags|= LIBMV_REFINE_FOCAL_LENGTH;
- if(refine&REFINE_PRINCIPAL_POINT)
+ if (refine&REFINE_PRINCIPAL_POINT)
flags|= LIBMV_REFINE_PRINCIPAL_POINT;
- if(refine&REFINE_RADIAL_DISTORTION_K1)
+ if (refine&REFINE_RADIAL_DISTORTION_K1)
flags|= REFINE_RADIAL_DISTORTION_K1;
- if(refine&REFINE_RADIAL_DISTORTION_K2)
+ if (refine&REFINE_RADIAL_DISTORTION_K2)
flags|= REFINE_RADIAL_DISTORTION_K2;
return flags;
@@ -1781,9 +1800,9 @@ static int count_tracks_on_both_keyframes(MovieTracking *tracking, ListBase *tra
MovieTrackingTrack *track;
track= tracksbase->first;
- while(track) {
- if(BKE_tracking_has_enabled_marker(track, frame1))
- if(BKE_tracking_has_enabled_marker(track, frame2))
+ while (track) {
+ if (BKE_tracking_has_enabled_marker(track, frame1))
+ if (BKE_tracking_has_enabled_marker(track, frame2))
tot++;
track= track->next;
@@ -1798,7 +1817,7 @@ int BKE_tracking_can_reconstruct(MovieTracking *tracking, MovieTrackingObject *o
#if WITH_LIBMV
ListBase *tracksbase= BKE_tracking_object_tracks(tracking, object);
- if(count_tracks_on_both_keyframes(tracking, tracksbase)<8) {
+ if (count_tracks_on_both_keyframes(tracking, tracksbase)<8) {
BLI_strncpy(error_msg, "At least 8 common tracks on both of keyframes are needed for reconstruction", error_size);
return 0;
}
@@ -1830,27 +1849,27 @@ MovieReconstructContext* BKE_tracking_reconstruction_context_new(MovieTracking *
context->tracks_map= tracks_map_new(context->object_name, context->is_camera, num_tracks, 0);
track= tracksbase->first;
- while(track) {
+ while (track) {
int first= 0, last= track->markersnr-1;
MovieTrackingMarker *first_marker= &track->markers[0];
MovieTrackingMarker *last_marker= &track->markers[track->markersnr-1];
/* find first not-disabled marker */
- while(first<=track->markersnr-1 && first_marker->flag&MARKER_DISABLED) {
+ while (first<=track->markersnr-1 && first_marker->flag&MARKER_DISABLED) {
first++;
first_marker++;
}
/* find last not-disabled marker */
- while(last>=0 && last_marker->flag&MARKER_DISABLED) {
+ while (last>=0 && last_marker->flag&MARKER_DISABLED) {
last--;
last_marker--;
}
- if(first<track->markersnr-1)
+ if (first<track->markersnr-1)
sfra= MIN2(sfra, first_marker->framenr);
- if(last>=0)
+ if (last>=0)
efra= MAX2(efra, last_marker->framenr);
tracks_map_insert(context->tracks_map, track, NULL);
@@ -1887,7 +1906,7 @@ MovieReconstructContext* BKE_tracking_reconstruction_context_new(MovieTracking *
void BKE_tracking_reconstruction_context_free(MovieReconstructContext *context)
{
#ifdef WITH_LIBMV
- if(context->reconstruction)
+ if (context->reconstruction)
libmv_destroyReconstruction(context->reconstruction);
libmv_tracksDestroy(context->tracks);
@@ -1903,7 +1922,7 @@ static void solve_reconstruction_update_cb(void *customdata, double progress, co
{
ReconstructProgressData *progressdata= customdata;
- if(progressdata->progress) {
+ if (progressdata->progress) {
*progressdata->progress= progress;
*progressdata->do_update= 1;
}
@@ -1918,7 +1937,7 @@ static int solve_reconstruction_testbreak_cb(void *customdata)
{
ReconstructProgressData *progressdata= customdata;
- if(progressdata->stop && *progressdata->stop)
+ if (progressdata->stop && *progressdata->stop)
return 1;
return G.afbreek;
@@ -1966,7 +1985,7 @@ int BKE_tracking_finish_reconstruction(MovieReconstructContext *context, MovieTr
tracks_map_merge(context->tracks_map, tracking);
- if(context->is_camera) {
+ if (context->is_camera) {
reconstruction= &tracking->reconstruction;
}
else {
@@ -1980,7 +1999,7 @@ int BKE_tracking_finish_reconstruction(MovieReconstructContext *context, MovieTr
reconstruction->flag|= TRACKING_RECONSTRUCTED;
#ifdef WITH_LIBMV
- if(!retrieve_libmv_reconstruct(context, tracking))
+ if (!retrieve_libmv_reconstruct(context, tracking))
return 0;
#endif
@@ -1997,8 +2016,8 @@ MovieTrackingTrack *BKE_tracking_named_track(MovieTracking *tracking, MovieTrack
ListBase *tracksbase= BKE_tracking_object_tracks(tracking, object);
MovieTrackingTrack *track= tracksbase->first;
- while(track) {
- if(!strcmp(track->name, name))
+ while (track) {
+ if (!strcmp(track->name, name))
return track;
track= track->next;
@@ -2012,43 +2031,43 @@ static int reconstruction_camera_index(MovieTrackingReconstruction *reconstructi
MovieReconstructedCamera *cameras= reconstruction->cameras;
int a= 0, d= 1;
- if(!reconstruction->camnr)
+ if (!reconstruction->camnr)
return -1;
- if(framenr<cameras[0].framenr) {
- if(nearest) return 0;
+ if (framenr<cameras[0].framenr) {
+ if (nearest) return 0;
else return -1;
}
- if(framenr>cameras[reconstruction->camnr-1].framenr) {
- if(nearest) return reconstruction->camnr-1;
+ if (framenr>cameras[reconstruction->camnr-1].framenr) {
+ if (nearest) return reconstruction->camnr-1;
else return -1;
}
- if(reconstruction->last_camera<reconstruction->camnr)
+ if (reconstruction->last_camera<reconstruction->camnr)
a= reconstruction->last_camera;
- if(cameras[a].framenr>=framenr)
+ if (cameras[a].framenr>=framenr)
d= -1;
- while(a>=0 && a<reconstruction->camnr) {
+ while (a>=0 && a<reconstruction->camnr) {
int cfra= cameras[a].framenr;
/* check if needed framenr was "skipped" -- no data for requested frame */
- if(d>0 && cfra>framenr) {
+ if (d>0 && cfra>framenr) {
/* interpolate with previous position */
- if(nearest) return a-1;
+ if (nearest) return a-1;
else break;
}
- if(d<0 && cfra<framenr) {
+ if (d<0 && cfra<framenr) {
/* interpolate with next position */
- if(nearest) return a;
+ if (nearest) return a;
else break;
}
- if(cfra==framenr) {
+ if (cfra==framenr) {
reconstruction->last_camera= a;
return a;
@@ -2062,7 +2081,7 @@ static int reconstruction_camera_index(MovieTrackingReconstruction *reconstructi
static void scale_reconstructed_camera(MovieTrackingObject *object, float mat[4][4])
{
- if((object->flag&TRACKING_OBJECT_CAMERA)==0) {
+ if ((object->flag&TRACKING_OBJECT_CAMERA)==0) {
float smat[4][4];
scale_m4_fl(smat, 1.0f/object->scale);
@@ -2079,7 +2098,7 @@ MovieReconstructedCamera *BKE_tracking_get_reconstructed_camera(MovieTracking *t
reconstruction= BKE_tracking_object_reconstruction(tracking, object);
a= reconstruction_camera_index(reconstruction, framenr, 0);
- if(a==-1)
+ if (a==-1)
return NULL;
return &reconstruction->cameras[a];
@@ -2096,16 +2115,17 @@ void BKE_tracking_get_interpolated_camera(MovieTracking *tracking, MovieTracking
cameras= reconstruction->cameras;
a= reconstruction_camera_index(reconstruction, framenr, 1);
- if(a==-1) {
+ if (a==-1) {
unit_m4(mat);
return;
}
- if(cameras[a].framenr!=framenr && a>0 && a<reconstruction->camnr-1) {
+ if (cameras[a].framenr!=framenr && a>0 && a<reconstruction->camnr-1) {
float t= ((float)framenr-cameras[a].framenr) / (cameras[a+1].framenr-cameras[a].framenr);
blend_m4_m4m4(mat, cameras[a].mat, cameras[a+1].mat, t);
- } else {
+ }
+ else {
copy_m4_m4(mat, cameras[a].mat);
}
@@ -2114,12 +2134,12 @@ void BKE_tracking_get_interpolated_camera(MovieTracking *tracking, MovieTracking
void BKE_get_tracking_mat(Scene *scene, Object *ob, float mat[4][4])
{
- if(!ob) {
- if(scene->camera) ob= scene->camera;
+ if (!ob) {
+ if (scene->camera) ob= scene->camera;
else ob= scene_find_camera(scene);
}
- if(ob)
+ if (ob)
where_is_object_mat(scene, ob, mat);
else
unit_m4(mat);
@@ -2163,7 +2183,7 @@ void BKE_tracking_projection_matrix(MovieTracking *tracking, MovieTrackingObject
clipsta= 0.1f;
clipend= 1000.0f;
- if(winx >= winy)
+ if (winx >= winy)
viewfac= (lens*winx)/tracking->camera.sensor_width;
else
viewfac= (ycor*lens*winy)/tracking->camera.sensor_width;
@@ -2184,19 +2204,20 @@ void BKE_tracking_projection_matrix(MovieTracking *tracking, MovieTrackingObject
camera= BKE_tracking_get_reconstructed_camera(tracking, object, framenr);
- if(camera) {
+ if (camera) {
float imat[4][4];
invert_m4_m4(imat, camera->mat);
mult_m4_m4m4(mat, winmat, imat);
- } else copy_m4_m4(mat, winmat);
+ }
+ else copy_m4_m4(mat, winmat);
}
ListBase *BKE_tracking_get_tracks(MovieTracking *tracking)
{
MovieTrackingObject *object= BKE_tracking_active_object(tracking);
- if(object && (object->flag & TRACKING_OBJECT_CAMERA) == 0) {
+ if (object && (object->flag & TRACKING_OBJECT_CAMERA) == 0) {
return &object->tracks;
}
@@ -2207,13 +2228,13 @@ MovieTrackingTrack *BKE_tracking_active_track(MovieTracking *tracking)
{
ListBase *tracksbase;
- if(!tracking->act_track)
+ if (!tracking->act_track)
return NULL;
tracksbase= BKE_tracking_get_tracks(tracking);
/* check that active track is in current tracks list */
- if(BLI_findindex(tracksbase, tracking->act_track) >= 0)
+ if (BLI_findindex(tracksbase, tracking->act_track) >= 0)
return tracking->act_track;
return NULL;
@@ -2228,8 +2249,8 @@ MovieTrackingObject *BKE_tracking_get_camera_object(MovieTracking *tracking)
{
MovieTrackingObject *object= tracking->objects.first;
- while(object) {
- if(object->flag & TRACKING_OBJECT_CAMERA)
+ while (object) {
+ if (object->flag & TRACKING_OBJECT_CAMERA)
return object;
object= object->next;
@@ -2240,7 +2261,7 @@ MovieTrackingObject *BKE_tracking_get_camera_object(MovieTracking *tracking)
ListBase *BKE_tracking_object_tracks(MovieTracking *tracking, MovieTrackingObject *object)
{
- if(object->flag & TRACKING_OBJECT_CAMERA) {
+ if (object->flag & TRACKING_OBJECT_CAMERA) {
return &tracking->tracks;
}
@@ -2249,7 +2270,7 @@ ListBase *BKE_tracking_object_tracks(MovieTracking *tracking, MovieTrackingObjec
MovieTrackingReconstruction *BKE_tracking_object_reconstruction(MovieTracking *tracking, MovieTrackingObject *object)
{
- if(object->flag & TRACKING_OBJECT_CAMERA) {
+ if (object->flag & TRACKING_OBJECT_CAMERA) {
return &tracking->reconstruction;
}
@@ -2317,8 +2338,8 @@ static int point_in_stroke(bGPDstroke *stroke, float x, float y)
prev= stroke->totpoints-1;
- for(i= 0; i<stroke->totpoints; i++) {
- if((points[i].y<y && points[prev].y>=y) || (points[prev].y<y && points[i].y>=y)) {
+ for (i= 0; i<stroke->totpoints; i++) {
+ if ((points[i].y<y && points[prev].y>=y) || (points[prev].y<y && points[i].y>=y)) {
float fac= (y-points[i].y)/(points[prev].y-points[i].y);
if (points[i].x+fac*(points[prev].x-points[i].x)<x)
@@ -2335,10 +2356,10 @@ static int point_in_layer(bGPDlayer *layer, float x, float y)
{
bGPDframe *frame= layer->frames.first;
- while(frame) {
+ while (frame) {
bGPDstroke *stroke= frame->strokes.first;
- while(stroke) {
- if(point_in_stroke(stroke, x, y))
+ while (stroke) {
+ if (point_in_stroke(stroke, x, y))
return 1;
stroke= stroke->next;
@@ -2356,7 +2377,7 @@ static void retrieve_libmv_features(MovieTracking *tracking, ListBase *tracksbas
int a;
a= libmv_countFeatures(features);
- while(a--) {
+ while (a--) {
MovieTrackingTrack *track;
double x, y, size, score;
int ok= 1;
@@ -2367,10 +2388,10 @@ static void retrieve_libmv_features(MovieTracking *tracking, ListBase *tracksbas
xu= x/width;
yu= y/height;
- if(layer)
+ if (layer)
ok= point_in_layer(layer, xu, yu)!=place_outside_layer;
- if(ok) {
+ if (ok) {
track= BKE_tracking_add_track(tracking, tracksbase, xu, yu, framenr, width, height);
track->flag|= SELECT;
track->pat_flag|= SELECT;
@@ -2416,13 +2437,13 @@ MovieTrackingTrack *BKE_tracking_indexed_track(MovieTracking *tracking, int trac
int cur= 1;
object= tracking->objects.first;
- while(object) {
+ while (object) {
ListBase *tracksbase= BKE_tracking_object_tracks(tracking, object);
MovieTrackingTrack *track= tracksbase->first;
- while(track) {
- if(track->flag&TRACK_HAS_BUNDLE) {
- if(cur==tracknr) {
+ while (track) {
+ if (track->flag&TRACK_HAS_BUNDLE) {
+ if (cur==tracknr) {
*tracksbase_r= tracksbase;
return track;
}
@@ -2452,8 +2473,8 @@ static int stabilization_median_point(MovieTracking *tracking, int framenr, floa
(void) tracking;
track= tracking->tracks.first;
- while(track) {
- if(track->flag&TRACK_USE_2D_STAB) {
+ while (track) {
+ if (track->flag&TRACK_USE_2D_STAB) {
MovieTrackingMarker *marker= BKE_tracking_get_marker(track, framenr);
DO_MINMAX2(marker->pos, min, max);
@@ -2483,7 +2504,7 @@ static void calculate_stabdata(MovieTracking *tracking, int framenr, float width
mul_v2_fl(loc, stab->locinf);
- if((stab->flag&TRACKING_STABILIZE_ROTATION) && stab->rot_track && stab->rotinf) {
+ if ((stab->flag&TRACKING_STABILIZE_ROTATION) && stab->rot_track && stab->rotinf) {
MovieTrackingMarker *marker;
float a[2], b[2];
float x0= (float)width/2.0f, y0= (float)height/2.0f;
@@ -2514,10 +2535,10 @@ static float stabilization_auto_scale_factor(MovieTracking *tracking, int width,
MovieTrackingStabilization *stab= &tracking->stabilization;
float aspect= tracking->camera.pixel_aspect;
- if(stab->ok)
+ if (stab->ok)
return stab->scale;
- if(stabilization_median_point(tracking, 1, firstmedian)) {
+ if (stabilization_median_point(tracking, 1, firstmedian)) {
int sfra= INT_MAX, efra= INT_MIN, cfra;
float scale= 1.0f;
MovieTrackingTrack *track;
@@ -2525,8 +2546,8 @@ static float stabilization_auto_scale_factor(MovieTracking *tracking, int width,
stab->scale= 1.0f;
track= tracking->tracks.first;
- while(track) {
- if(track->flag&TRACK_USE_2D_STAB ||
+ while (track) {
+ if (track->flag&TRACK_USE_2D_STAB ||
((stab->flag&TRACKING_STABILIZE_ROTATION) && track==stab->rot_track)) {
sfra= MIN2(sfra, track->markers[0].framenr);
efra= MAX2(efra, track->markers[track->markersnr-1].framenr);
@@ -2535,7 +2556,7 @@ static float stabilization_auto_scale_factor(MovieTracking *tracking, int width,
track= track->next;
}
- for(cfra=sfra; cfra<=efra; cfra++) {
+ for (cfra=sfra; cfra<=efra; cfra++) {
float median[2];
float loc[2], angle, tmp_scale;
int i;
@@ -2552,7 +2573,7 @@ static float stabilization_auto_scale_factor(MovieTracking *tracking, int width,
si = sin(angle);
co = cos(angle);
- for(i= 0; i<4; i++) {
+ for (i= 0; i<4; i++) {
int j;
float a[3]= {0.0f, 0.0f, 0.0f}, b[3]= {0.0f, 0.0f, 0.0f};
@@ -2562,14 +2583,14 @@ static float stabilization_auto_scale_factor(MovieTracking *tracking, int width,
mul_m4_v3(mat, a);
mul_m4_v3(mat, b);
- for(j= 0; j<4; j++) {
+ for (j= 0; j<4; j++) {
float point[3]= {points[j][0], points[j][1], 0.0f};
float v1[3], v2[3];
sub_v3_v3v3(v1, b, a);
sub_v3_v3v3(v2, point, a);
- if(cross_v2v2(v1, v2) >= 0.0f) {
+ if (cross_v2v2(v1, v2) >= 0.0f) {
const float rotDx[4][2] = {{1.0f, 0.0f}, {0.0f, -1.0f}, {-1.0f, 0.0f}, {0.0f, 1.0f}};
const float rotDy[4][2] = {{0.0f, 1.0f}, {1.0f, 0.0f}, {0.0f, -1.0f}, {-1.0f, 0.0f}};
@@ -2578,7 +2599,7 @@ static float stabilization_auto_scale_factor(MovieTracking *tracking, int width,
float w, h, E, F, G, H, I, J, K, S;
- if(j % 2) {
+ if (j % 2) {
w = (float)height / 2.0f;
h = (float)width / 2.0f;
}
@@ -2613,9 +2634,10 @@ static float stabilization_auto_scale_factor(MovieTracking *tracking, int width,
stab->scale= scale;
- if(stab->maxscale>0.0f)
+ if (stab->maxscale>0.0f)
stab->scale= MIN2(stab->scale, stab->maxscale);
- } else {
+ }
+ else {
stab->scale= 1.0f;
}
@@ -2628,18 +2650,18 @@ static ImBuf* stabilize_alloc_ibuf(ImBuf *cacheibuf, ImBuf *srcibuf, int fill)
{
int flags;
- if(cacheibuf && (cacheibuf->x != srcibuf->x || cacheibuf->y != srcibuf->y)) {
+ if (cacheibuf && (cacheibuf->x != srcibuf->x || cacheibuf->y != srcibuf->y)) {
IMB_freeImBuf(cacheibuf);
cacheibuf= NULL;
}
flags= IB_rect;
- if(srcibuf->rect_float)
+ if (srcibuf->rect_float)
flags|= IB_rectfloat;
- if(cacheibuf) {
- if(fill) {
+ if (cacheibuf) {
+ if (fill) {
float col[4]= {0.0f, 0.0f, 0.0f, 0.0f};
IMB_rectfill(cacheibuf, col);
}
@@ -2657,7 +2679,7 @@ void BKE_tracking_stabilization_data(MovieTracking *tracking, int framenr, int w
float firstmedian[2], median[2];
MovieTrackingStabilization *stab= &tracking->stabilization;
- if((stab->flag&TRACKING_2D_STABILIZATION)==0) {
+ if ((stab->flag&TRACKING_2D_STABILIZATION)==0) {
zero_v2(loc);
*scale= 1.0f;
*angle= 0.0f;
@@ -2665,23 +2687,25 @@ void BKE_tracking_stabilization_data(MovieTracking *tracking, int framenr, int w
return;
}
- if(stabilization_median_point(tracking, 1, firstmedian)) {
+ if (stabilization_median_point(tracking, 1, firstmedian)) {
stabilization_median_point(tracking, framenr, median);
- if((stab->flag&TRACKING_AUTOSCALE)==0)
+ if ((stab->flag&TRACKING_AUTOSCALE)==0)
stab->scale= 1.0f;
- if(!stab->ok) {
- if(stab->flag&TRACKING_AUTOSCALE)
+ if (!stab->ok) {
+ if (stab->flag&TRACKING_AUTOSCALE)
stabilization_auto_scale_factor(tracking, width, height);
calculate_stabdata(tracking, framenr, width, height, firstmedian, median, loc, scale, angle);
stab->ok= 1;
- } else {
+ }
+ else {
calculate_stabdata(tracking, framenr, width, height, firstmedian, median, loc, scale, angle);
}
- } else {
+ }
+ else {
zero_v2(loc);
*scale= 1.0f;
*angle= 0.0f;
@@ -2696,12 +2720,12 @@ ImBuf *BKE_tracking_stabilize(MovieTracking *tracking, int framenr, ImBuf *ibuf,
float width= ibuf->x, height= ibuf->y;
float aspect= tracking->camera.pixel_aspect;
- if(loc) copy_v2_v2(tloc, loc);
- if(scale) tscale= *scale;
+ if (loc) copy_v2_v2(tloc, loc);
+ if (scale) tscale= *scale;
- if((stab->flag&TRACKING_2D_STABILIZATION)==0) {
- if(loc) zero_v2(loc);
- if(scale) *scale= 1.0f;
+ if ((stab->flag&TRACKING_2D_STABILIZATION)==0) {
+ if (loc) zero_v2(loc);
+ if (scale) *scale= 1.0f;
return ibuf;
}
@@ -2711,7 +2735,7 @@ ImBuf *BKE_tracking_stabilize(MovieTracking *tracking, int framenr, ImBuf *ibuf,
tmpibuf= stabilize_alloc_ibuf(NULL, ibuf, 1);
/* scale would be handled by matrix transformation when angle is non-zero */
- if(tscale!=1.0f && tangle==0.0f) {
+ if (tscale!=1.0f && tangle==0.0f) {
ImBuf *scaleibuf;
stabilization_auto_scale_factor(tracking, width, height);
@@ -2725,11 +2749,12 @@ ImBuf *BKE_tracking_stabilize(MovieTracking *tracking, int framenr, ImBuf *ibuf,
ibuf= scaleibuf;
}
- if(tangle==0.0f) {
+ if (tangle==0.0f) {
/* if angle is zero, then it's much faster to use rect copy
* but could be issues with subpixel precisions */
IMB_rectcpy(tmpibuf, ibuf, tloc[0]-(tscale-1.0f)*width/2.0f, tloc[1]-(tscale-1.0f)*height/2.0f, 0, 0, ibuf->x, ibuf->y);
- } else {
+ }
+ else {
float mat[4][4];
int i, j, filter= tracking->stabilization.filter;
void (*interpolation) (struct ImBuf*, struct ImBuf*, float, float, int, int) = NULL;
@@ -2737,18 +2762,18 @@ ImBuf *BKE_tracking_stabilize(MovieTracking *tracking, int framenr, ImBuf *ibuf,
BKE_tracking_stabdata_to_mat4(ibuf->x, ibuf->y, aspect, tloc, tscale, tangle, mat);
invert_m4(mat);
- if(filter == TRACKING_FILTER_NEAREAST)
+ if (filter == TRACKING_FILTER_NEAREAST)
interpolation = neareast_interpolation;
- else if(filter == TRACKING_FILTER_BILINEAR)
+ else if (filter == TRACKING_FILTER_BILINEAR)
interpolation = bilinear_interpolation;
- else if(filter == TRACKING_FILTER_BICUBIC)
+ else if (filter == TRACKING_FILTER_BICUBIC)
interpolation = bicubic_interpolation;
else
/* fallback to default interpolation method */
interpolation = neareast_interpolation;
- for(j=0; j<tmpibuf->y; j++) {
- for(i=0; i<tmpibuf->x;i++) {
+ for (j=0; j<tmpibuf->y; j++) {
+ for (i=0; i<tmpibuf->x;i++) {
float vec[3]= {i, j, 0};
mul_v3_m4v3(vec, mat, vec);
@@ -2760,12 +2785,12 @@ ImBuf *BKE_tracking_stabilize(MovieTracking *tracking, int framenr, ImBuf *ibuf,
tmpibuf->userflags|= IB_MIPMAP_INVALID;
- if(tmpibuf->rect_float)
+ if (tmpibuf->rect_float)
tmpibuf->userflags|= IB_RECT_INVALID;
- if(loc) copy_v2_v2(loc, tloc);
- if(scale) *scale= tscale;
- if(angle) *angle= tangle;
+ if (loc) copy_v2_v2(loc, tloc);
+ if (scale) *scale= tscale;
+ if (angle) *angle= tangle;
return tmpibuf;
}
@@ -2828,11 +2853,12 @@ void BKE_tracking_distortion_update(MovieDistortion *distortion, MovieTracking *
float aspy= 1.0f/tracking->camera.pixel_aspect;
#ifdef WITH_LIBMV
- if(!distortion->intrinsics) {
+ if (!distortion->intrinsics) {
distortion->intrinsics= libmv_CameraIntrinsicsNew(camera->focal,
camera->principal[0], camera->principal[1] * aspy,
camera->k1, camera->k2, camera->k3, width, height * aspy);
- } else {
+ }
+ else {
libmv_CameraIntrinsicsUpdate(distortion->intrinsics, camera->focal,
camera->principal[0], camera->principal[1] * aspy,
camera->k1, camera->k2, camera->k3, width, height * aspy);
@@ -2855,13 +2881,14 @@ ImBuf *BKE_tracking_distortion_exec(MovieDistortion *distortion, MovieTracking *
resibuf= IMB_dupImBuf(ibuf);
- if(ibuf->rect_float) {
+ if (ibuf->rect_float) {
#ifdef WITH_LIBMV
- if(undistort) {
+ if (undistort) {
libmv_CameraIntrinsicsUndistortFloat(distortion->intrinsics,
ibuf->rect_float, resibuf->rect_float,
ibuf->x, ibuf->y, overscan, ibuf->channels);
- } else {
+ }
+ else {
libmv_CameraIntrinsicsDistortFloat(distortion->intrinsics,
ibuf->rect_float, resibuf->rect_float,
ibuf->x, ibuf->y, overscan, ibuf->channels);
@@ -2869,13 +2896,15 @@ ImBuf *BKE_tracking_distortion_exec(MovieDistortion *distortion, MovieTracking *
#endif
ibuf->userflags|= IB_RECT_INVALID;
- } else {
+ }
+ else {
#ifdef WITH_LIBMV
- if(undistort) {
+ if (undistort) {
libmv_CameraIntrinsicsUndistortByte(distortion->intrinsics,
(unsigned char*)ibuf->rect, (unsigned char*)resibuf->rect,
ibuf->x, ibuf->y, overscan, ibuf->channels);
- } else {
+ }
+ else {
libmv_CameraIntrinsicsDistortByte(distortion->intrinsics,
(unsigned char*)ibuf->rect, (unsigned char*)resibuf->rect,
ibuf->x, ibuf->y, overscan, ibuf->channels);
@@ -2904,7 +2933,7 @@ ImBuf *BKE_tracking_undistort(MovieTracking *tracking, ImBuf *ibuf, int width, i
{
MovieTrackingCamera *camera= &tracking->camera;
- if(camera->intrinsics == NULL)
+ if (camera->intrinsics == NULL)
camera->intrinsics= BKE_tracking_distortion_create();
return BKE_tracking_distortion_exec(camera->intrinsics, tracking, ibuf, width, height, overscan, 1);
@@ -2914,7 +2943,7 @@ ImBuf *BKE_tracking_distort(MovieTracking *tracking, ImBuf *ibuf, int width, int
{
MovieTrackingCamera *camera= &tracking->camera;
- if(camera->intrinsics == NULL)
+ if (camera->intrinsics == NULL)
camera->intrinsics= BKE_tracking_distortion_create();
return BKE_tracking_distortion_exec(camera->intrinsics, tracking, ibuf, width, height, overscan, 0);
@@ -2923,14 +2952,15 @@ ImBuf *BKE_tracking_distort(MovieTracking *tracking, ImBuf *ibuf, int width, int
/* area - which part of marker should be selected. see TRACK_AREA_* constants */
void BKE_tracking_select_track(ListBase *tracksbase, MovieTrackingTrack *track, int area, int extend)
{
- if(extend) {
+ if (extend) {
BKE_tracking_track_flag(track, area, SELECT, 0);
- } else {
+ }
+ else {
MovieTrackingTrack *cur= tracksbase->first;
- while(cur) {
+ while (cur) {
if ((cur->flag & TRACK_HIDDEN) == 0) {
- if(cur==track) {
+ if (cur==track) {
BKE_tracking_track_flag(cur, TRACK_AREA_ALL, SELECT, 1);
BKE_tracking_track_flag(cur, area, SELECT, 0);
}
@@ -2953,7 +2983,7 @@ MovieTrackingObject *BKE_tracking_new_object(MovieTracking *tracking, const char
{
MovieTrackingObject *object= MEM_callocN(sizeof(MovieTrackingObject), "tracking object");
- if(tracking->tot_object==0) {
+ if (tracking->tot_object==0) {
/* first object is always camera */
BLI_strncpy(object->name, "Camera", sizeof(object->name));
@@ -2980,17 +3010,17 @@ void BKE_tracking_remove_object(MovieTracking *tracking, MovieTrackingObject *ob
MovieTrackingTrack *track;
int index= BLI_findindex(&tracking->objects, object);
- if(index<0)
+ if (index<0)
return;
- if(object->flag & TRACKING_OBJECT_CAMERA) {
+ if (object->flag & TRACKING_OBJECT_CAMERA) {
/* object used for camera solving can't be deleted */
return;
}
track= object->tracks.first;
- while(track) {
- if(track==tracking->act_track)
+ while (track) {
+ if (track==tracking->act_track)
tracking->act_track= NULL;
track= track->next;
@@ -3001,7 +3031,7 @@ void BKE_tracking_remove_object(MovieTracking *tracking, MovieTrackingObject *ob
tracking->tot_object--;
- if(index>0)
+ if (index>0)
tracking->objectnr= index-1;
else
tracking->objectnr= 0;
@@ -3016,8 +3046,8 @@ MovieTrackingObject *BKE_tracking_named_object(MovieTracking *tracking, const ch
{
MovieTrackingObject *object= tracking->objects.first;
- while(object) {
- if(!strcmp(object->name, name))
+ while (object) {
+ if (!strcmp(object->name, name))
return object;
object= object->next;
diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c
index a4fc4c7bfe3..07a83da3d8c 100644
--- a/source/blender/blenkernel/intern/world.c
+++ b/source/blender/blenkernel/intern/world.c
@@ -56,17 +56,17 @@ void free_world(World *wrld)
MTex *mtex;
int a;
- for(a=0; a<MAX_MTEX; a++) {
+ for (a=0; a<MAX_MTEX; a++) {
mtex= wrld->mtex[a];
- if(mtex && mtex->tex) mtex->tex->id.us--;
- if(mtex) MEM_freeN(mtex);
+ if (mtex && mtex->tex) mtex->tex->id.us--;
+ if (mtex) MEM_freeN(mtex);
}
BKE_previewimg_free(&wrld->preview);
BKE_free_animdata((ID *)wrld);
/* is no lib link block, but world extension */
- if(wrld->nodetree) {
+ if (wrld->nodetree) {
ntreeFreeTree(wrld->nodetree);
MEM_freeN(wrld->nodetree);
}
@@ -120,18 +120,18 @@ World *copy_world(World *wrld)
wrldn= copy_libblock(&wrld->id);
- for(a=0; a<MAX_MTEX; a++) {
- if(wrld->mtex[a]) {
+ for (a=0; a<MAX_MTEX; a++) {
+ if (wrld->mtex[a]) {
wrldn->mtex[a]= MEM_mallocN(sizeof(MTex), "copy_world");
memcpy(wrldn->mtex[a], wrld->mtex[a], sizeof(MTex));
id_us_plus((ID *)wrldn->mtex[a]->tex);
}
}
- if(wrld->nodetree)
+ if (wrld->nodetree)
wrldn->nodetree= ntreeCopyTree(wrld->nodetree);
- if(wrld->preview)
+ if (wrld->preview)
wrldn->preview = BKE_previewimg_copy(wrld->preview);
return wrldn;
@@ -145,8 +145,8 @@ World *localize_world(World *wrld)
wrldn= copy_libblock(&wrld->id);
BLI_remlink(&G.main->world, wrldn);
- for(a=0; a<MAX_MTEX; a++) {
- if(wrld->mtex[a]) {
+ for (a=0; a<MAX_MTEX; a++) {
+ if (wrld->mtex[a]) {
wrldn->mtex[a]= MEM_mallocN(sizeof(MTex), "localize_world");
memcpy(wrldn->mtex[a], wrld->mtex[a], sizeof(MTex));
/* free world decrements */
@@ -154,7 +154,7 @@ World *localize_world(World *wrld)
}
}
- if(wrld->nodetree)
+ if (wrld->nodetree)
wrldn->nodetree= ntreeLocalize(wrld->nodetree);
wrldn->preview= NULL;
@@ -173,32 +173,32 @@ void make_local_world(World *wrld)
* - mixed: make copy
*/
- if(wrld->id.lib==NULL) return;
- if(wrld->id.us==1) {
+ if (wrld->id.lib==NULL) return;
+ if (wrld->id.us==1) {
id_clear_lib_data(bmain, &wrld->id);
return;
}
- for(sce= bmain->scene.first; sce && ELEM(FALSE, is_lib, is_local); sce= sce->id.next) {
- if(sce->world == wrld) {
- if(sce->id.lib) is_lib= TRUE;
+ for (sce= bmain->scene.first; sce && ELEM(FALSE, is_lib, is_local); sce= sce->id.next) {
+ if (sce->world == wrld) {
+ if (sce->id.lib) is_lib= TRUE;
else is_local= TRUE;
}
}
- if(is_local && is_lib==FALSE) {
+ if (is_local && is_lib==FALSE) {
id_clear_lib_data(bmain, &wrld->id);
}
- else if(is_local && is_lib) {
+ else if (is_local && is_lib) {
World *wrld_new= copy_world(wrld);
wrld_new->id.us= 0;
/* Remap paths of new ID using old library as base. */
BKE_id_lib_local_paths(bmain, wrld->id.lib, &wrld_new->id);
- for(sce= bmain->scene.first; sce; sce= sce->id.next) {
- if(sce->world == wrld) {
- if(sce->id.lib==NULL) {
+ for (sce= bmain->scene.first; sce; sce= sce->id.next) {
+ if (sce->world == wrld) {
+ if (sce->id.lib==NULL) {
sce->world= wrld_new;
wrld_new->id.us++;
wrld->id.us--;
diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c
index 50212522d3a..ba8a46256c5 100644
--- a/source/blender/blenkernel/intern/writeavi.c
+++ b/source/blender/blenkernel/intern/writeavi.c
@@ -201,7 +201,7 @@ static int append_avi(RenderData *UNUSED(rd), int start_frame, int frame, int *p
memcpy (rt1, rt2, rectx*sizeof(int));
cp= (char *)rt1;
- for(x= rectx; x>0; x--) {
+ for (x= rectx; x>0; x--) {
rt= cp[0];
cp[0]= cp[3];
cp[3]= rt;
@@ -231,7 +231,7 @@ static void end_avi(void)
void BKE_makeanimstring(char *string, RenderData *rd)
{
bMovieHandle *mh= BKE_get_movie_handle(rd->im_format.imtype);
- if(mh->get_movie_path)
+ if (mh->get_movie_path)
mh->get_movie_path(string, rd);
else
string[0]= '\0';
diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c
index bca7f6ff7bb..740deb5c7db 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -123,7 +123,7 @@ static int write_audio_frame(void)
audio_outbuf_size,
(short*) audio_input_buffer);
- if(pkt.size < 0)
+ if (pkt.size < 0)
{
// XXX error("Error writing audio packet");
return -1;
@@ -131,7 +131,7 @@ static int write_audio_frame(void)
pkt.data = audio_output_buffer;
- if(c->coded_frame && c->coded_frame->pts != AV_NOPTS_VALUE)
+ if (c->coded_frame && c->coded_frame->pts != AV_NOPTS_VALUE)
{
pkt.pts = av_rescale_q(c->coded_frame->pts,
c->time_base, audio_stream->time_base);
@@ -262,7 +262,8 @@ static int write_video_frame(RenderData *rd, int cfra, AVFrame* frame, ReportLis
c->time_base,
video_stream->time_base);
fprintf(stderr, "Video Frame PTS: %d\n", (int)packet.pts);
- } else {
+ }
+ else {
fprintf(stderr, "Video Frame PTS: not set\n");
}
if (c->coded_frame->key_frame)
@@ -272,7 +273,8 @@ static int write_video_frame(RenderData *rd, int cfra, AVFrame* frame, ReportLis
packet.size = outsize;
ret = av_interleaved_write_frame(outfile, &packet);
success = (ret == 0);
- } else if (outsize < 0) {
+ }
+ else if (outsize < 0) {
success = 0;
}
@@ -298,7 +300,8 @@ static AVFrame* generate_video_frame(uint8_t* pixels, ReportList *reports)
BKE_report(reports, RPT_ERROR, "Couldn't allocate temporary frame.");
return NULL;
}
- } else {
+ }
+ else {
rgb_frame = current_frame;
}
@@ -324,7 +327,8 @@ static AVFrame* generate_video_frame(uint8_t* pixels, ReportList *reports)
src += 4;
}
}
- } else {
+ }
+ else {
int y;
for (y = 0; y < height; y++) {
uint8_t* target = rgb_frame->data[0]
@@ -383,10 +387,12 @@ static void set_ffmpeg_property_option(AVCodecContext* c, IDProperty * prop)
if (param) {
if (IDP_Int(prop)) {
av_set_string3(c, name, param, 1, &rv);
- } else {
+ }
+ else {
return;
}
- } else {
+ }
+ else {
rv = av_set_int(c, prop->name, IDP_Int(prop));
}
break;
@@ -402,8 +408,8 @@ static int ffmpeg_proprty_valid(AVCodecContext *c, const char *prop_name, IDProp
{
int valid= 1;
- if(strcmp(prop_name, "video")==0) {
- if(strcmp(curr->name, "bf")==0) {
+ if (strcmp(prop_name, "video")==0) {
+ if (strcmp(curr->name, "bf")==0) {
/* flash codec doesn't support b frames */
valid&= c->codec_id!=CODEC_ID_FLV1;
}
@@ -430,7 +436,7 @@ static void set_ffmpeg_properties(RenderData *rd, AVCodecContext *c, const char
iter = IDP_GetGroupIterator(prop);
while ((curr = IDP_GroupIterNext(iter)) != NULL) {
- if(ffmpeg_proprty_valid(c, prop_name, curr))
+ if (ffmpeg_proprty_valid(c, prop_name, curr))
set_ffmpeg_property_option(c, curr);
}
}
@@ -462,11 +468,13 @@ static AVStream* alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex
if (ffmpeg_type == FFMPEG_DV && rd->frs_sec != 25) {
c->time_base.den = 2997;
c->time_base.num = 100;
- } else if ((double) ((int) rd->frs_sec_base) ==
+ }
+ else if ((double) ((int) rd->frs_sec_base) ==
rd->frs_sec_base) {
c->time_base.den = rd->frs_sec;
c->time_base.num = (int) rd->frs_sec_base;
- } else {
+ }
+ else {
c->time_base.den = rd->frs_sec * 100000;
c->time_base.num = ((double) rd->frs_sec_base) * 100000;
}
@@ -488,7 +496,8 @@ static AVStream* alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex
if (codec->pix_fmts) {
c->pix_fmt = codec->pix_fmts[0];
- } else {
+ }
+ else {
/* makes HuffYUV happy ... */
c->pix_fmt = PIX_FMT_YUV422P;
}
@@ -625,11 +634,11 @@ static AVStream* alloc_audio_stream(RenderData *rd, int codec_id, AVFormatContex
audio_outbuf_size = FF_MIN_BUFFER_SIZE;
- if((c->codec_id >= CODEC_ID_PCM_S16LE) && (c->codec_id <= CODEC_ID_PCM_DVD))
+ if ((c->codec_id >= CODEC_ID_PCM_S16LE) && (c->codec_id <= CODEC_ID_PCM_DVD))
audio_input_samples = audio_outbuf_size * 8 / c->bits_per_coded_sample / c->channels;
else {
audio_input_samples = c->frame_size;
- if(c->frame_size * c->channels * sizeof(int16_t) * 4 > audio_outbuf_size)
+ if (c->frame_size * c->channels * sizeof(int16_t) * 4 > audio_outbuf_size)
audio_outbuf_size = c->frame_size * c->channels * sizeof(int16_t) * 4;
}
@@ -696,7 +705,8 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report
of->packet_size= rd->ffcodecdata.mux_packet_size;
if (ffmpeg_audio_codec != CODEC_ID_NONE) {
of->mux_rate = rd->ffcodecdata.mux_rate;
- } else {
+ }
+ else {
of->mux_rate = 0;
}
@@ -846,7 +856,8 @@ void flush_ffmpeg(void)
c->time_base,
video_stream->time_base);
fprintf(stderr, "Video Frame PTS: %d\n", (int)packet.pts);
- } else {
+ }
+ else {
fprintf(stderr, "Video Frame PTS: not set\n");
}
if (c->coded_frame->key_frame) {
@@ -902,7 +913,8 @@ void filepath_ffmpeg(char* string, RenderData* rd)
BLI_path_frame_range(string, rd->sfra, rd->efra, 4);
strcat(string, *exts);
- } else {
+ }
+ else {
*(string + strlen(string) - strlen(*fe)) = 0;
strcat(string, autosplit);
strcat(string, *fe);
@@ -917,7 +929,7 @@ int start_ffmpeg(struct Scene *scene, RenderData *rd, int rectx, int recty, Repo
success = start_ffmpeg_impl(rd, rectx, recty, reports);
#ifdef WITH_AUDASPACE
- if(audio_stream)
+ if (audio_stream)
{
AVCodecContext* c = audio_stream->codec;
AUD_DeviceSpecs specs;
@@ -942,7 +954,7 @@ static void write_audio_frames(double to_pts)
int finished = 0;
while (audio_stream && !finished) {
- if((audio_time >= to_pts) ||
+ if ((audio_time >= to_pts) ||
(write_audio_frame())) {
finished = 1;
}
@@ -962,7 +974,7 @@ int append_ffmpeg(RenderData *rd, int start_frame, int frame, int *pixels, int r
// why is this done before writing the video frame and again at end_ffmpeg?
// write_audio_frames(frame / (((double)rd->frs_sec) / rd->frs_sec_base));
- if(video_stream)
+ if (video_stream)
{
avframe= generate_video_frame((unsigned char*) pixels, reports);
success= (avframe && write_video_frame(rd, frame - start_frame, avframe, reports));
@@ -1109,7 +1121,8 @@ IDProperty *ffmpeg_property_add(RenderData *rd, const char *type, int opt_index,
if (parent_index) {
BLI_snprintf(name, sizeof(name), "%s:%s", parent->name, o->name);
- } else {
+ }
+ else {
BLI_strncpy(name, o->name, sizeof(name));
}
@@ -1158,8 +1171,8 @@ static const AVOption *my_av_find_opt(void *v, const char *name,
AVClass *c= *(AVClass**)v;
const AVOption *o= c->option;
- for(;o && o->name; o++) {
- if(!strcmp(o->name, name) &&
+ for (;o && o->name; o++) {
+ if (!strcmp(o->name, name) &&
(!unit || (o->unit && !strcmp(o->unit, unit))) &&
(o->flags & mask) == flags )
return o;
@@ -1206,7 +1219,8 @@ int ffmpeg_property_add_string(RenderData *rd, const char * type, const char * s
prop = ffmpeg_property_add(rd,
(char*) type, p - c.av_class->option,
o - c.av_class->option);
- } else {
+ }
+ else {
prop = ffmpeg_property_add(rd,
(char*) type, o - c.av_class->option, 0);
}
@@ -1236,10 +1250,10 @@ static void ffmpeg_set_expert_options(RenderData *rd)
{
int codec_id = rd->ffcodecdata.codec;
- if(rd->ffcodecdata.properties)
+ if (rd->ffcodecdata.properties)
IDP_FreeProperty(rd->ffcodecdata.properties);
- if(codec_id == CODEC_ID_H264) {
+ if (codec_id == CODEC_ID_H264) {
/*
* All options here are for x264, but must be set via ffmpeg.
* The names are therefore different - Search for "x264 to FFmpeg option mapping"
@@ -1279,12 +1293,12 @@ static void ffmpeg_set_expert_options(RenderData *rd)
ffmpeg_property_add_string(rd, "video", "flags2:fastpskip");
ffmpeg_property_add_string(rd, "video", "wpredp:2");
- if(rd->ffcodecdata.flags & FFMPEG_LOSSLESS_OUTPUT)
+ if (rd->ffcodecdata.flags & FFMPEG_LOSSLESS_OUTPUT)
ffmpeg_property_add_string(rd, "video", "cqp:0");
}
#if 0 /* disabled for after release */
- else if(codec_id == CODEC_ID_DNXHD) {
- if(rd->ffcodecdata.flags & FFMPEG_LOSSLESS_OUTPUT)
+ else if (codec_id == CODEC_ID_DNXHD) {
+ if (rd->ffcodecdata.flags & FFMPEG_LOSSLESS_OUTPUT)
ffmpeg_property_add_string(rd, "video", "mbd:rd");
}
#endif
@@ -1294,7 +1308,7 @@ void ffmpeg_set_preset(RenderData *rd, int preset)
{
int isntsc = (rd->frs_sec != 25);
- if(rd->ffcodecdata.properties)
+ if (rd->ffcodecdata.properties)
IDP_FreeProperty(rd->ffcodecdata.properties);
switch (preset) {
@@ -1361,11 +1375,11 @@ void ffmpeg_set_preset(RenderData *rd, int preset)
case FFMPEG_PRESET_THEORA:
case FFMPEG_PRESET_XVID:
- if(preset == FFMPEG_PRESET_XVID) {
+ if (preset == FFMPEG_PRESET_XVID) {
rd->ffcodecdata.type = FFMPEG_AVI;
rd->ffcodecdata.codec = CODEC_ID_MPEG4;
}
- else if(preset == FFMPEG_PRESET_THEORA) {
+ else if (preset == FFMPEG_PRESET_THEORA) {
rd->ffcodecdata.type = FFMPEG_OGG; // XXX broken
rd->ffcodecdata.codec = CODEC_ID_THEORA;
}
@@ -1388,8 +1402,8 @@ void ffmpeg_verify_image_type(RenderData *rd, ImageFormatData *imf)
{
int audio= 0;
- if(imf->imtype == R_IMF_IMTYPE_FFMPEG) {
- if(rd->ffcodecdata.type <= 0 ||
+ if (imf->imtype == R_IMF_IMTYPE_FFMPEG) {
+ if (rd->ffcodecdata.type <= 0 ||
rd->ffcodecdata.codec <= 0 ||
rd->ffcodecdata.audio_codec <= 0 ||
rd->ffcodecdata.video_bitrate <= 1) {
@@ -1398,32 +1412,32 @@ void ffmpeg_verify_image_type(RenderData *rd, ImageFormatData *imf)
ffmpeg_set_preset(rd, FFMPEG_PRESET_DVD);
}
- if(rd->ffcodecdata.type == FFMPEG_OGG) {
+ if (rd->ffcodecdata.type == FFMPEG_OGG) {
rd->ffcodecdata.type = FFMPEG_MPEG2;
}
audio= 1;
}
- else if(imf->imtype == R_IMF_IMTYPE_H264) {
- if(rd->ffcodecdata.codec != CODEC_ID_H264) {
+ else if (imf->imtype == R_IMF_IMTYPE_H264) {
+ if (rd->ffcodecdata.codec != CODEC_ID_H264) {
ffmpeg_set_preset(rd, FFMPEG_PRESET_H264);
audio= 1;
}
}
- else if(imf->imtype == R_IMF_IMTYPE_XVID) {
- if(rd->ffcodecdata.codec != CODEC_ID_MPEG4) {
+ else if (imf->imtype == R_IMF_IMTYPE_XVID) {
+ if (rd->ffcodecdata.codec != CODEC_ID_MPEG4) {
ffmpeg_set_preset(rd, FFMPEG_PRESET_XVID);
audio= 1;
}
}
- else if(imf->imtype == R_IMF_IMTYPE_THEORA) {
- if(rd->ffcodecdata.codec != CODEC_ID_THEORA) {
+ else if (imf->imtype == R_IMF_IMTYPE_THEORA) {
+ if (rd->ffcodecdata.codec != CODEC_ID_THEORA) {
ffmpeg_set_preset(rd, FFMPEG_PRESET_THEORA);
audio= 1;
}
}
- if(audio && rd->ffcodecdata.audio_codec < 0) {
+ if (audio && rd->ffcodecdata.audio_codec < 0) {
rd->ffcodecdata.audio_codec = CODEC_ID_NONE;
rd->ffcodecdata.audio_bitrate = 128;
}
diff --git a/source/blender/blenkernel/intern/writeframeserver.c b/source/blender/blenkernel/intern/writeframeserver.c
index c163155c8fb..4bb9c497980 100644
--- a/source/blender/blenkernel/intern/writeframeserver.c
+++ b/source/blender/blenkernel/intern/writeframeserver.c
@@ -301,9 +301,11 @@ int frameserver_loop(RenderData *rd, ReportList *UNUSED(reports))
rval = select(connsock + 1, &readfds, NULL, NULL, &tv);
if (rval > 0) {
break;
- } else if (rval == 0) {
+ }
+ else if (rval == 0) {
return -1;
- } else if (rval < 0) {
+ }
+ else if (rval < 0) {
if (!select_was_interrupted_by_signal()) {
return -1;
}