From f9d9b4635da01c5a27ef9adbd3d3171f5ceeb47d Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 14 Apr 2012 12:02:47 +0000 Subject: Camera tracking: support of tripod motion solving Expose option into interface to use modal solver which currently supports only tripod motion. This solver requires two tracks at least to reconstruct motion. Using more tracks aren't improving solution in general, just adds instability into solution and slows down things a lot. Refirement of camera intrinsics is supported by this solver. To use this solver just activate "Tripod Motion" checkbox in solver panel. --- source/blender/blenkernel/intern/tracking.c | 34 +++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 9 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index 7654c361d14..9e3bc2648a5 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -1523,6 +1523,7 @@ typedef struct MovieReconstructContext { #endif char object_name[MAX_NAME]; int is_camera; + short motion_flag; float focal_length; float principal_point[2]; @@ -1752,7 +1753,11 @@ 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 (tracking->settings.motion_flag & TRACKING_MOTION_MODAL) { + /* TODO: check for number of tracks? */ + return TRUE; + } + else 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 FALSE; @@ -1781,7 +1786,8 @@ MovieReconstructContext* BKE_tracking_reconstruction_context_new(MovieTracking * MovieTrackingTrack *track; BLI_strncpy(context->object_name, object->name, sizeof(context->object_name)); - context->is_camera = object->flag&TRACKING_OBJECT_CAMERA; + context->is_camera = object->flag & TRACKING_OBJECT_CAMERA; + context->motion_flag = tracking->settings.motion_flag; context->tracks_map = tracks_map_new(context->object_name, context->is_camera, num_tracks, 0); @@ -1894,13 +1900,23 @@ void BKE_tracking_solve_reconstruction(MovieReconstructContext *context, short * progressdata.stats_message = stats_message; progressdata.message_size = message_size; - context->reconstruction = libmv_solveReconstruction(context->tracks, - context->keyframe1, context->keyframe2, - context->refine_flags, - context->focal_length, - context->principal_point[0], context->principal_point[1], - context->k1, context->k2, context->k3, - solve_reconstruction_update_cb, &progressdata); + if (context->motion_flag & TRACKING_MOTION_MODAL) { + context->reconstruction = libmv_solveModal(context->tracks, + context->refine_flags, + context->focal_length, + context->principal_point[0], context->principal_point[1], + context->k1, context->k2, context->k3, + solve_reconstruction_update_cb, &progressdata); + } + else { + context->reconstruction = libmv_solveReconstruction(context->tracks, + context->keyframe1, context->keyframe2, + context->refine_flags, + context->focal_length, + context->principal_point[0], context->principal_point[1], + context->k1, context->k2, context->k3, + solve_reconstruction_update_cb, &progressdata); + } error = libmv_reprojectionError(context->reconstruction); -- cgit v1.2.3 From 339efd5e0158706f3e0cd6251ee65c7446fc96ed Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 14 Apr 2012 12:02:54 +0000 Subject: Camera tracking: if there's no image for current frame display default grid and allow to interact with tracks for operators which doesn't require image. --- source/blender/blenkernel/intern/movieclip.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index 9a640bcb8eb..9f8585675e3 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -925,8 +925,8 @@ void BKE_movieclip_get_size(MovieClip *clip, MovieClipUser *user, int *width, in real_ibuf_size(clip, user, ibuf, width, height); } else { - *width = 0; - *height = 0; + *width = clip->lastsize[0]; + *height = clip->lastsize[1]; } if (ibuf) -- cgit v1.2.3 From 6701933f5ce4598d2fc98bd27a5b8a4e58ca06e2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 21 Apr 2012 12:51:47 +0000 Subject: style cleanup --- source/blender/blenkernel/intern/DerivedMesh.c | 4 ++-- source/blender/blenkernel/intern/action.c | 2 +- source/blender/blenkernel/intern/anim.c | 2 +- source/blender/blenkernel/intern/boids.c | 2 +- source/blender/blenkernel/intern/cdderivedmesh.c | 2 +- source/blender/blenkernel/intern/depsgraph.c | 2 +- source/blender/blenkernel/intern/dynamicpaint.c | 2 +- source/blender/blenkernel/intern/editderivedmesh.c | 2 +- source/blender/blenkernel/intern/effect.c | 2 +- source/blender/blenkernel/intern/particle.c | 4 ++-- source/blender/blenkernel/intern/particle_system.c | 4 ++-- source/blender/blenkernel/intern/sequencer.c | 7 ++++--- source/blender/blenkernel/intern/softbody.c | 6 +++--- 13 files changed, 21 insertions(+), 20 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 94aed7c7a01..92eb696087d 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -2769,7 +2769,7 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs, for (b = 0; b < gattribs->totlayer; b++) { if (gattribs->layer[b].type == CD_MTFACE) { /* uv coordinates */ - if(dm->type == DM_TYPE_EDITBMESH) { + if (dm->type == DM_TYPE_EDITBMESH) { /* exception .. */ CustomData *ldata = dm->getLoopDataLayout(dm); @@ -2806,7 +2806,7 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs, } } else if (gattribs->layer[b].type == CD_MCOL) { - if(dm->type == DM_TYPE_EDITBMESH) { + if (dm->type == DM_TYPE_EDITBMESH) { /* exception .. */ CustomData *ldata = dm->getLoopDataLayout(dm); diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index c77e384a264..93401a528ab 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -1561,7 +1561,7 @@ static void do_nla(Scene *scene, Object *ob, int blocktype) } } /* To handle repeat, we add 0.1 frame extra to make sure the last frame is included */ - else { + else { /* Mod to repeat */ if (strip->repeat!=1.0f) { diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index b547fedebb5..1ec9f7d8a10 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -635,7 +635,7 @@ int where_on_path(Object *ob, float ctime, float vec[4], float dir[3], float qua p3= pp + s3; /* note, commented out for follow constraint */ - //if(cu->flag & CU_FOLLOW) { + //if (cu->flag & CU_FOLLOW) { key_curve_tangent_weights(1.0f-fac, data, KEY_BSPLINE); diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index a14988d78b1..a556c99dc7d 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -1254,7 +1254,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) madd_v3_v3fl(pa->state.vel, acc, dtime); - //if(bpa->data.mode != eBoidMode_InAir) + //if (bpa->data.mode != eBoidMode_InAir) bpa->ground = boid_find_ground(bbd, pa, ground_co, ground_nor); /* change modes, constrain movement & keep track of down vector */ diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 2d764142d26..ee18c93b943 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -700,7 +700,7 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, GPU_normal_setup( dm ); GPU_uv_setup( dm ); if ( col != NULL ) { - /*if( realcol && dm->drawObject->colType == CD_TEXTURE_MCOL ) { + /*if ( realcol && dm->drawObject->colType == CD_TEXTURE_MCOL ) { col = 0; } else if ( mcol && dm->drawObject->colType == CD_MCOL ) { diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 366e808d32c..ccaa03ad9d9 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -1803,7 +1803,7 @@ void DAG_scene_sort(Main *bmain, Scene *sce) while (base) { BLI_remlink(&sce->base,base); BLI_addhead(&tempbase,base); - //if(G.debug & G_DEBUG) + //if (G.debug & G_DEBUG) printf("cyclic %s\n", base->object->id.name); base = sce->base.first; } diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 872f678d456..6aad98d293e 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -3337,7 +3337,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, else if (brush->ray_dir == MOD_DPAINT_RAY_BRUSH_AVG) { copy_v3_v3(proj_ray, avg_brushNor); } - else { /* MOD_DPAINT_RAY_ZPLUS */ + else { /* MOD_DPAINT_RAY_ZPLUS */ proj_ray[2] = 1.0f; } hit.index = -1; diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c index b6aebcddd4c..857f6e75e2c 100644 --- a/source/blender/blenkernel/intern/editderivedmesh.c +++ b/source/blender/blenkernel/intern/editderivedmesh.c @@ -1320,7 +1320,7 @@ static void emDM_getVert(DerivedMesh *dm, int index, MVert *vert_r) ev = BM_vert_at_index(bmdm->tc->bm, index); /* warning, does list loop, _not_ ideal */ bmvert_to_mvert(bmdm->tc->bm, ev, vert_r); - if(bmdm->vertexCos) + if (bmdm->vertexCos) copy_v3_v3(vert_r->co, bmdm->vertexCos[index]); } diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index cb8220c8fb3..4f320b41184 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -622,7 +622,7 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin ret = psys_get_particle_state(&sim, *efd->index, &state, 0); /* TODO */ - //if(eff->pd->forcefiled == PFIELD_HARMONIC && ret==0) { + //if (eff->pd->forcefiled == PFIELD_HARMONIC && ret==0) { // if (pa->dietime < eff->psys->cfra) // eff->flag |= PE_VELOCITY_TO_IMPULSE; //} diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index a851c440230..2eff664bc1a 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -1695,7 +1695,7 @@ static int psys_map_index_on_dm(DerivedMesh *dm, int from, int index, int index_ *mapindex = index; } - else { /* FROM_FACE/FROM_VOLUME */ + else { /* FROM_FACE/FROM_VOLUME */ if (index >= dm->getNumTessFaces(dm)) return 0; @@ -1713,7 +1713,7 @@ static int psys_map_index_on_dm(DerivedMesh *dm, int from, int index, int index_ *mapindex = index_dmcache; } - else { /* FROM_FACE/FROM_VOLUME */ + else { /* FROM_FACE/FROM_VOLUME */ /* find a face on the derived mesh that uses this face */ MFace *mface; OrigSpaceFace *osface; diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index aadd9d675b0..b08c1e1edf3 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -1479,7 +1479,7 @@ void psys_threads_free(ParticleThread *threads) 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); + //if (ctx->vertpart) MEM_freeN(ctx->vertpart); BLI_kdtree_free(ctx->tree); /* threads */ @@ -4125,7 +4125,7 @@ static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra)) pa->dietime = sim->scene->r.efra + 1; 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 ); + //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 { // skip... diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 99fc2242f9f..e27ff4ddeda 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1352,7 +1352,8 @@ static void seq_proxy_build_frame(SeqRenderData context, IMB_freeImBuf(ibuf); } -struct SeqIndexBuildContext *seq_proxy_rebuild_context(Main *bmain, Scene *scene, Sequence *seq){ +struct SeqIndexBuildContext *seq_proxy_rebuild_context(Main *bmain, Scene *scene, Sequence *seq) +{ SeqIndexBuildContext *context; Sequence *nseq; @@ -3778,7 +3779,7 @@ Sequence *sequencer_add_sound_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo sound = sound_new_file(CTX_data_main(C), seq_load->path); /* handles relative paths */ if (sound == NULL || sound->playback_handle == NULL) { - //if(op) + //if (op) // BKE_report(op->reports, RPT_ERROR, "Unsupported audio format"); return NULL; } @@ -3787,7 +3788,7 @@ Sequence *sequencer_add_sound_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo if (info.specs.channels == AUD_CHANNELS_INVALID) { sound_delete(bmain, sound); - //if(op) + //if (op) // BKE_report(op->reports, RPT_ERROR, "Unsupported audio format"); return NULL; } diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index dc7a211a3c1..6e4f4db129b 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -1358,7 +1358,7 @@ static void scan_for_ext_face_forces(Object *ob,float timenow) /*---edges intruding*/ /*+++ close vertices*/ - if (( bf->flag & BFF_INTERSECT)==0) { + if (( bf->flag & BFF_INTERSECT)==0) { bf->flag &= ~BFF_CLOSEVERT; tune = -1.0f; feedback[0]=feedback[1]=feedback[2]=0.0f; @@ -2190,7 +2190,7 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo } /* debugerin */ - if (sb->totpoint < ifirst) { + if (sb->totpoint < ifirst) { printf("Aye 998"); return (998); } @@ -2960,7 +2960,7 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float * /* the freezer coming sooner or later */ /* - if ((dot_v3v3(dx,dx)force,bp->force)force,bp->force)frozen /=2; } else { -- cgit v1.2.3 From 7e7d28e3ad433285c205c4f44218b5b4c862c9ef Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 21 Apr 2012 13:08:26 +0000 Subject: fix [#31048] converting curve object to mesh makes object disapper from 3D view --- source/blender/blenkernel/intern/cdderivedmesh.c | 5 +++-- source/blender/blenkernel/intern/mesh.c | 19 ++++++++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index ee18c93b943..2dc95effdd7 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -412,8 +412,9 @@ static void cdDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdges 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)) - && (drawLooseEdges || !(medge->flag&ME_LOOSEEDGE))) { + if ((drawAllEdges || (medge->flag & ME_EDGEDRAW)) && + (drawLooseEdges || !(medge->flag & ME_LOOSEEDGE))) + { glVertex3fv(mvert[medge->v1].co); glVertex3fv(mvert[medge->v2].co); } diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index b7b9f6b21f4..b80b15e57f3 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1224,7 +1224,10 @@ int nurbs_to_mdata(Object *ob, MVert **allvert, int *totvert, int *totloop, int *totpoly) { return nurbs_to_mdata_customdb(ob, &ob->disp, - allvert, totvert, alledge, totedge, allloop, allpoly, totloop, totpoly); + allvert, totvert, + alledge, totedge, + allloop, allpoly, + totloop, totpoly); } /* BMESH: this doesn't calculate all edges from polygons, @@ -1232,9 +1235,11 @@ int nurbs_to_mdata(Object *ob, MVert **allvert, int *totvert, /* Initialize mverts, medges and, faces for converting nurbs to mesh and derived mesh */ /* use specified dispbase */ -int nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, MVert **allvert, int *_totvert, - MEdge **alledge, int *_totedge, MLoop **allloop, MPoly **allpoly, - int *_totloop, int *_totpoly) +int nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, + MVert **allvert, int *_totvert, + MEdge **alledge, int *_totedge, + MLoop **allloop, MPoly **allpoly, + int *_totloop, int *_totpoly) { DispList *dl; Curve *cu; @@ -1316,7 +1321,7 @@ int nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, MVert **allvert, int for (b=1; bnr; b++) { medge->v1= startvert+ofs+b-1; medge->v2= startvert+ofs+b; - medge->flag = ME_LOOSEEDGE|ME_EDGERENDER; + medge->flag = ME_LOOSEEDGE | ME_EDGERENDER | ME_EDGEDRAW; medge++; } @@ -1341,7 +1346,7 @@ int nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, MVert **allvert, int medge->v1= startvert+ofs+b; if (b==dl->nr-1) medge->v2= startvert+ofs; else medge->v2= startvert+ofs+b+1; - medge->flag = ME_LOOSEEDGE|ME_EDGERENDER; + medge->flag = ME_LOOSEEDGE | ME_EDGERENDER | ME_EDGEDRAW; medge++; } } @@ -1466,7 +1471,7 @@ void nurbs_to_mesh(Object *ob) cu= ob->data; if (dm == NULL) { - if (nurbs_to_mdata (ob, &allvert, &totvert, &alledge, &totedge, &allloop, &allpoly, &totloop, &totpoly) != 0) { + if (nurbs_to_mdata(ob, &allvert, &totvert, &alledge, &totedge, &allloop, &allpoly, &totloop, &totpoly) != 0) { /* Error initializing */ return; } -- cgit v1.2.3 From 1615b46963f79e90621c155a5d85925a4b5171a3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 21 Apr 2012 13:37:26 +0000 Subject: style cleanup --- source/blender/blenkernel/intern/DerivedMesh.c | 2 +- source/blender/blenkernel/intern/customdata.c | 2 +- source/blender/blenkernel/intern/particle_system.c | 3 ++- source/blender/blenkernel/intern/softbody.c | 14 +++++++------- 4 files changed, 11 insertions(+), 10 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 92eb696087d..294518458bf 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -274,7 +274,7 @@ void DM_init_funcs(DerivedMesh *dm) } void DM_init(DerivedMesh *dm, DerivedMeshType type, int numVerts, int numEdges, - int numTessFaces, int numLoops, int numPolys) + int numTessFaces, int numLoops, int numPolys) { dm->type = type; dm->numVertData = numVerts; diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 536d4d9c823..29eea3bb576 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -2056,7 +2056,7 @@ void CustomData_set(const CustomData *data, int index, int type, void *source) /*Bmesh functions*/ /*needed to convert to/from different face reps*/ void CustomData_to_bmeshpoly(CustomData *fdata, CustomData *pdata, CustomData *ldata, - int totloop, int totpoly) + int totloop, int totpoly) { int i; for (i=0; i < fdata->totlayer; i++) { diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index b08c1e1edf3..ee19b38e02b 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -2375,6 +2375,7 @@ typedef struct SPHRangeData float massfac; int use_size; } SPHRangeData; + typedef struct SPHData { ParticleSystem *psys[10]; ParticleData *pa; @@ -2390,7 +2391,7 @@ typedef struct SPHData { /* Integrator callbacks. This allows different SPH implementations. */ void (*force_cb) (void *sphdata_v, ParticleKey *state, float *force, float *impulse); void (*density_cb) (void *rangedata_v, int index, float squared_dist); -}SPHData; +} SPHData; static void sph_density_accum_cb(void *userdata, int index, float squared_dist) { diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 6e4f4db129b..01930cc28da 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -113,7 +113,7 @@ typedef struct ReferenceVert { typedef struct ReferenceState { float com[3]; /* center of mass*/ ReferenceVert *ivert; /* list of intial values */ -}ReferenceState; +} ReferenceState; /*private scratch pad for caching and other data only needed when alive*/ @@ -125,7 +125,7 @@ typedef struct SBScratch { int totface; float aabbmin[3],aabbmax[3]; ReferenceState Ref; -}SBScratch; +} SBScratch; typedef struct SB_thread_context { Scene *scene; @@ -140,7 +140,7 @@ typedef struct SB_thread_context { float windfactor; int nr; int tot; -}SB_thread_context; +} SB_thread_context; #define NLF_BUILD 1 #define NLF_SOLVE 2 @@ -267,9 +267,9 @@ float operations still */ static const int CCD_SAVETY = 190561; -typedef struct ccdf_minmax{ -float minx,miny,minz,maxx,maxy,maxz; -}ccdf_minmax; +typedef struct ccdf_minmax { + float minx, miny, minz, maxx, maxy, maxz; +} ccdf_minmax; @@ -283,7 +283,7 @@ typedef struct ccd_Mesh { /* Axis Aligned Bounding Box AABB */ float bbmin[3]; float bbmax[3]; -}ccd_Mesh; +} ccd_Mesh; -- cgit v1.2.3 From 8765dfccf725770007e3b4e6b24199fe8377df71 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 21 Apr 2012 14:14:58 +0000 Subject: style cleanup: correct typos --- source/blender/blenkernel/intern/mesh_validate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c index c5c2060d5c0..aebbcd4208d 100644 --- a/source/blender/blenkernel/intern/mesh_validate.c +++ b/source/blender/blenkernel/intern/mesh_validate.c @@ -309,7 +309,7 @@ int BKE_mesh_validate_arrays(Mesh *mesh, prev_v = v; } } - if (v - prev_v > 1) { /* Don’t forget final verts! */ + if (v - prev_v > 1) { /* Don't forget final verts! */ PRINT(" poly %u is invalid, it multi-uses vertex %u (%u times)\n", sp->index, *prev_v, (int)(v - prev_v)); sp->invalid = TRUE; @@ -420,7 +420,7 @@ int BKE_mesh_validate_arrays(Mesh *mesh, /* DO NOT REMOVE ITS LOOPS!!! * As already invalid polys are at the end of the SortPoly list, the loops they * were the only users have already been tagged as "to remove" during previous - * iterations, and we don’t want to remove some loops that may be used by + * iterations, and we don't want to remove some loops that may be used by * another valid poly! */ } } -- cgit v1.2.3 From b56aabf815dd60827da81574501ea1d12ce3a38b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 21 Apr 2012 15:11:03 +0000 Subject: style cleanup: multi-line if statements. --- source/blender/blenkernel/intern/cdderivedmesh.c | 16 ++++++------- source/blender/blenkernel/intern/cloth.c | 10 ++++----- source/blender/blenkernel/intern/collision.c | 4 ++-- source/blender/blenkernel/intern/customdata.c | 20 ++++++++--------- source/blender/blenkernel/intern/dynamicpaint.c | 6 ++--- source/blender/blenkernel/intern/image.c | 5 +++-- source/blender/blenkernel/intern/implicit.c | 4 ++-- source/blender/blenkernel/intern/modifier.c | 2 +- source/blender/blenkernel/intern/object.c | 12 ++++++---- source/blender/blenkernel/intern/particle.c | 18 ++++++++++----- source/blender/blenkernel/intern/particle_system.c | 26 +++++++++++++--------- source/blender/blenkernel/intern/pointcache.c | 9 +++++--- source/blender/blenkernel/intern/seqeffects.c | 5 +++-- source/blender/blenkernel/intern/sequencer.c | 8 +++---- source/blender/blenkernel/intern/shrinkwrap.c | 4 ++-- .../blender/blenkernel/intern/writeframeserver.c | 3 +-- 16 files changed, 85 insertions(+), 67 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 2dc95effdd7..4a852bb0233 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -424,17 +424,18 @@ static void cdDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdges else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */ int prevstart = 0; int prevdraw = 1; - int draw = 1; + int draw = TRUE; GPU_edge_setup(dm); - if ( !GPU_buffer_legacy(dm) ) { + 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; + if ((drawAllEdges || (medge->flag & ME_EDGEDRAW)) && + (drawLooseEdges || !(medge->flag & ME_LOOSEEDGE))) + { + draw = TRUE; } else { - draw = 0; + draw = FALSE; } if ( prevdraw != draw ) { if ( prevdraw > 0 && (i-prevstart) > 0 ) { @@ -539,8 +540,7 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm, new_matnr = mface->mat_nr + 1; new_shademodel = (mface->flag & ME_SMOOTH)?GL_SMOOTH:GL_FLAT; - if (new_glmode != glmode || new_matnr != matnr - || new_shademodel != shademodel) { + if (new_glmode != glmode || new_matnr != matnr || new_shademodel != shademodel) { glEnd(); drawCurrentMat = setMaterial(matnr = new_matnr, NULL); diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index 7dedd71b2e0..a0c273cf962 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -446,9 +446,9 @@ void clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, Derived BKE_ptcache_id_time(&pid, scene, framenr, &startframe, &endframe, ×cale); clmd->sim_parms->timescale= timescale; - if (clmd->sim_parms->reset - || (framenr == (startframe - clmd->sim_parms->preroll) && clmd->sim_parms->preroll != 0) - || (clmd->clothObject && dm->getNumVerts(dm) != clmd->clothObject->numverts)) + if (clmd->sim_parms->reset || + (framenr == (startframe - clmd->sim_parms->preroll) && clmd->sim_parms->preroll != 0) || + (clmd->clothObject && dm->getNumVerts(dm) != clmd->clothObject->numverts)) { clmd->sim_parms->reset = 0; cache->flag |= PTCACHE_OUTDATED; @@ -1176,8 +1176,8 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) // check for existing spring // check also if startpoint is equal to endpoint - if ( !BLI_edgehash_haskey ( edgehash, MIN2(tspring2->ij, index2), MAX2(tspring2->ij, index2) ) - && ( index2!=tspring2->ij ) ) + if (!BLI_edgehash_haskey(edgehash, MIN2(tspring2->ij, index2), MAX2(tspring2->ij, index2)) && + (index2 != tspring2->ij)) { spring = ( ClothSpring * ) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" ); diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index f6a6ef068d6..7195fb9c425 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -2502,8 +2502,8 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl if ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL ) { - if ( ( cloth->verts [i].flags & CLOTH_VERT_FLAG_PINNED ) - && ( cloth->verts [j].flags & CLOTH_VERT_FLAG_PINNED ) ) + if ( ( cloth->verts [i].flags & CLOTH_VERT_FLAG_PINNED ) && + ( cloth->verts [j].flags & CLOTH_VERT_FLAG_PINNED ) ) { continue; } diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 29eea3bb576..7cc7a82df66 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -1810,9 +1810,9 @@ void CustomData_copy_data(const CustomData *source, CustomData *dest, /* find the first dest layer with type >= the source type * (this should work because layers are ordered by type) */ - while (dest_i < dest->totlayer - && dest->layers[dest_i].type < source->layers[src_i].type) + 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; @@ -1901,9 +1901,9 @@ void CustomData_interp(const CustomData *source, CustomData *dest, /* find the first dest layer with type >= the source type * (this should work because layers are ordered by type) */ - while (dest_i < dest->totlayer - && dest->layers[dest_i].type < source->layers[src_i].type) + 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; @@ -2272,9 +2272,9 @@ void CustomData_bmesh_copy_data(const CustomData *source, CustomData *dest, /* find the first dest layer with type >= the source type * (this should work because layers are ordered by type) */ - while (dest_i < dest->totlayer - && dest->layers[dest_i].type < source->layers[src_i].type) + 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; @@ -2504,9 +2504,9 @@ void CustomData_to_bmesh_block(const CustomData *source, CustomData *dest, /* find the first dest layer with type >= the source type * (this should work because layers are ordered by type) */ - while (dest_i < dest->totlayer - && dest->layers[dest_i].type < source->layers[src_i].type) + 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; @@ -2547,9 +2547,9 @@ void CustomData_from_bmesh_block(const CustomData *source, CustomData *dest, /* find the first dest layer with type >= the source type * (this should work because layers are ordered by type) */ - while (dest_i < dest->totlayer - && dest->layers[dest_i].type < source->layers[src_i].type) + 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; diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 6aad98d293e..943c8a20990 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -1844,8 +1844,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); cache->flag &= ~PTCACHE_REDO_NEEDED; @@ -1856,8 +1855,7 @@ static void dynamicPaint_frameUpdate(DynamicPaintModifierData *pmd, Scene *scene BKE_ptcache_validate(cache, (int)scene->r.cfra); } /* if read failed and we're on surface range do recalculate */ - else if ((int)scene->r.cfra == current_frame - && !(cache->flag & PTCACHE_BAKED)) { + else if ((int)scene->r.cfra == current_frame && !(cache->flag & PTCACHE_BAKED)) { /* calculate surface frame */ canvas->flags |= MOD_DPAINT_BAKING; dynamicPaint_calculateFrame(surface, scene, ob, current_frame); diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 3b91afbc126..27779ef8107 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1148,8 +1148,9 @@ int BKE_add_image_extension(char *string, const char imtype) 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) - || (G.have_quicktime && BLI_testextensie_array(string, imb_ext_image_qt))) { + 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); } else { diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index 23aa03b0331..0bb9426730e 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -1260,8 +1260,8 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s, /* if (length>L) { - if ((clmd->sim_parms->flags & CSIMSETT_FLAG_TEARING_ENABLED) - && ((((length-L)*100.0f/L) > clmd->sim_parms->maxspringlen))) // cut spring! + 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; return; diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 6c855b8f242..12aa6232cb0 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -76,7 +76,7 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type) types_init= 0; } - /* type unsigned, no need to chech < 0 */ + /* type unsigned, no need to check < 0 */ if (type < NUM_MODIFIER_TYPES && types[type]->name[0] != '\0') { return types[type]; } diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 3271a623584..bc9411b7e02 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2631,9 +2631,11 @@ void object_handle_update(Scene *scene, Object *ob) if (psys_check_enabled(ob, psys)) { /* check use of dupli objects here */ if (psys->part && (psys->part->draw_as == PART_DRAW_REND || G.rendering) && - ((psys->part->ren_as == PART_DRAW_OB && psys->part->dup_ob) - || (psys->part->ren_as == PART_DRAW_GR && psys->part->dup_group))) + ((psys->part->ren_as == PART_DRAW_OB && psys->part->dup_ob) || + (psys->part->ren_as == PART_DRAW_GR && psys->part->dup_group))) + { ob->transflag |= OB_DUPLIPARTS; + } particle_system_update(scene, ob, psys); psys= psys->next; @@ -2664,9 +2666,11 @@ void object_handle_update(Scene *scene, Object *ob) BKE_ptcache_ids_from_object(&pidlist, ob, scene, MAX_DUPLI_RECUR); for (pid=pidlist.first; pid; pid=pid->next) { - if ((pid->cache->flag & PTCACHE_BAKED) - || (pid->cache->flag & PTCACHE_QUICK_CACHE)==0) + if ((pid->cache->flag & PTCACHE_BAKED) || + (pid->cache->flag & PTCACHE_QUICK_CACHE) == 0) + { continue; + } if (pid->cache->flag & PTCACHE_OUTDATED || (pid->cache->flag & PTCACHE_SIMULATION_VALID)==0) { scene->physics_settings.quick_cache_step = diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 2eff664bc1a..414677bfc6e 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -4276,10 +4276,13 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta state->time = psys_get_child_time(psys, cpa, cfra, NULL, NULL); - if (!always) - if ((state->time < 0.0f && !(part->flag & PART_UNBORN)) - || (state->time > 1.0f && !(part->flag & PART_DIED))) + if (!always) { + if ((state->time < 0.0f && !(part->flag & PART_UNBORN)) || + (state->time > 1.0f && !(part->flag & PART_DIED))) + { return 0; + } + } state->time= (cfra - (part->sta + (part->end - part->sta) * PSYS_FRAND(p + 23))) / (part->lifetime * PSYS_FRAND(p + 24)); @@ -4296,10 +4299,13 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta } if (pa) { - if (!always) - if ((cfra < pa->time && (part->flag & PART_UNBORN)==0) - || (cfra > pa->dietime && (part->flag & PART_DIED)==0)) + 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); } diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index ee19b38e02b..4ce24953c89 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -126,10 +126,12 @@ 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 */ - || (part->child_nbr && part->childtype) /* display percentage applies to children */ - || (psys->pointcache->flag & PTCACHE_BAKING)) /* baking is always done with full amount */ + 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; + } return psys->part->disp; } @@ -1862,9 +1864,11 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, /* 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) - && sim->scene->physics_settings.gravity[2]!=0.0f) + 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]; + } bpa->data.health = part->boids->health; bpa->data.mode = eBoidMode_InAir; @@ -2683,9 +2687,10 @@ 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)) { + (part->type != PART_HAIR || part->effector_weights->flag & EFF_WEIGHT_DO_HAIR)) + { zero_v3(gr); madd_v3_v3fl(gr, sim->scene->physics_settings.gravity, part->effector_weights->global_gravity * efdata.ptex.gravity); gravity = gr; @@ -3892,11 +3897,12 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) } /* only reset unborn particles if they're shown or if the particle is born soon*/ - if (pa->alive==PARS_UNBORN - && (part->flag & PART_UNBORN || cfra + psys->pointcache->step > pa->time)) + 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))) pa->state.time = -1.f; diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 100bd485c36..dbcef9ad4c8 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -821,9 +821,12 @@ void BKE_ptcache_id_from_particles(PTCacheID *pid, Object *ob, ParticleSystem *p if (psys->part->flag & PART_ROTATIONS) { pid->data_types|= (1<part->rotmode!=PART_ROT_VEL - || psys->part->avemode==PART_AVE_RAND || psys->part->avefac!=0.0f) - pid->data_types|= (1<part->rotmode != PART_ROT_VEL || + psys->part->avemode == PART_AVE_RAND || + psys->part->avefac != 0.0f) + { + pid->data_types |= (1 << BPHYS_DATA_AVELOCITY); + } } pid->info_types= (1<flag & SEQ_USE_EFFECT_DEFAULT_FADE) { - if (seq->seq1->enddisp != seq->seq1->start - && seq->seq1->len != 0) { + if ((seq->seq1->enddisp != seq->seq1->start) && + (seq->seq1->len != 0)) + { fallback_fac = (float) seq->seq1->len / (float) (seq->seq1->enddisp - seq->seq1->start); flags = SEQ_SPEED_INTEGRATE; diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index e27ff4ddeda..97edba7d9ef 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -3067,10 +3067,10 @@ void seq_tx_set_final_right(Sequence *seq, int val) * since they work a bit differently to normal image seq's (during transform) */ int seq_single_check(Sequence *seq) { - return (seq->len == 1 && ( - seq->type == SEQ_IMAGE - || ((seq->type & SEQ_EFFECT) && - get_sequence_effect_num_inputs(seq->type) == 0))); + return ((seq->len == 1) && + (seq->type == SEQ_IMAGE || + ((seq->type & SEQ_EFFECT) && + get_sequence_effect_num_inputs(seq->type) == 0))); } /* check if the selected seq's reference unselected seq's */ diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index 6513399c962..4006837efd6 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -325,8 +325,8 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc) } //After sucessufuly build the trees, start projection vertexs - if ( bvhtree_from_mesh_faces(&treeData, calc->target, 0.0, 4, 6) - && (auxMesh == NULL || bvhtree_from_mesh_faces(&auxData, auxMesh, 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__ diff --git a/source/blender/blenkernel/intern/writeframeserver.c b/source/blender/blenkernel/intern/writeframeserver.c index 4bb9c497980..62e921f3311 100644 --- a/source/blender/blenkernel/intern/writeframeserver.c +++ b/source/blender/blenkernel/intern/writeframeserver.c @@ -206,8 +206,7 @@ static int handle_request(RenderData *rd, char * req) *p = 0; - if (strcmp(path, "/index.html") == 0 - || strcmp(path, "/") == 0) { + if (strcmp(path, "/index.html") == 0 || strcmp(path, "/") == 0) { safe_puts(index_page); return -1; } -- cgit v1.2.3 From 126f766b4cefd360e5f760875af34a0827dc2b4b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 22 Apr 2012 00:20:58 +0000 Subject: style cleanup --- source/blender/blenkernel/intern/CCGSubSurf.c | 559 ++++++------ source/blender/blenkernel/intern/subsurf_ccg.c | 1135 ++++++++++++------------ 2 files changed, 848 insertions(+), 846 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c index 9b55785d1a4..07cedc50bce 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.c +++ b/source/blender/blenkernel/intern/CCGSubSurf.c @@ -27,7 +27,7 @@ /***/ -typedef unsigned char byte; +typedef unsigned char byte; /***/ @@ -50,10 +50,13 @@ typedef struct _EHash { CCGAllocatorHDL allocator; } EHash; -#define EHASH_alloc(eh, nb) ((eh)->allocatorIFC.alloc((eh)->allocator, nb)) -#define EHASH_free(eh, ptr) ((eh)->allocatorIFC.free((eh)->allocator, ptr)) +#define EHASH_alloc(eh, nb) ((eh)->allocatorIFC.alloc((eh)->allocator, nb)) +#define EHASH_free(eh, ptr) ((eh)->allocatorIFC.free((eh)->allocator, ptr)) -#define EHASH_hash(eh, item) (((uintptr_t) (item))%((unsigned int) (eh)->curSize)) +#define EHASH_hash(eh, item) (((uintptr_t) (item)) % ((unsigned int) (eh)->curSize)) + +static void ccgSubSurf__sync(CCGSubSurf *ss); +static int _edge_isBoundary(const CCGEdge *e); static EHash *_ehash_new(int estimatedNumEntries, CCGAllocatorIFC *allocatorIFC, CCGAllocatorHDL allocator) { @@ -107,7 +110,7 @@ static void _ehash_insert(EHash *eh, EHEntry *entry) memset(eh->buckets, 0, eh->curSize * sizeof(*eh->buckets)); while (numBuckets--) { - for (entry = oldBuckets[numBuckets]; entry;) { + for (entry = oldBuckets[numBuckets]; entry; ) { EHEntry *next = entry->next; hash = EHASH_hash(eh, entry->key); @@ -125,12 +128,12 @@ static void _ehash_insert(EHash *eh, EHEntry *entry) static void *_ehash_lookupWithPrev(EHash *eh, void *key, void ***prevp_r) { int hash = EHASH_hash(eh, key); - void **prevp = (void**) &eh->buckets[hash]; + void **prevp = (void **) &eh->buckets[hash]; EHEntry *entry; - for (; (entry = *prevp); prevp = (void**) &entry->next) { + for (; (entry = *prevp); prevp = (void **) &entry->next) { if (entry->key == key) { - *prevp_r = (void**) prevp; + *prevp_r = (void **) prevp; return entry; } } @@ -279,7 +282,7 @@ static int VertDataEqual(const float *a, const float *b) #define VertDataCopy(av, bv) { float *_a = (float *)av, *_b = (float *) bv; _a[0] = _b[0]; _a[1] = _b[1]; _a[2] = _b[2]; } #define VertDataAdd(av, bv) { float *_a = (float *)av, *_b = (float *) bv; _a[0] += _b[0]; _a[1] += _b[1]; _a[2] += _b[2]; } #define VertDataSub(av, bv) { float *_a = (float *)av, *_b = (float *) bv; _a[0] -= _b[0]; _a[1] -= _b[1]; _a[2] -= _b[2]; } -#define VertDataMulN(av, n) { float *_a = (float *)av; _a[0]*=n; _a[1]*=n; _a[2] *=n; } +#define VertDataMulN(av, n) { float *_a = (float *)av; _a[0] *= n; _a[1] *= n; _a[2] *= n; } #define VertDataAvg4(tv, av, bv, cv, dv) \ { \ float *_t = (float *) tv, *_a = (float *) av, *_b = (float *) bv, *_c = (float *) cv, *_d = (float *) dv; \ @@ -291,9 +294,6 @@ static int VertDataEqual(const float *a, const float *b) #define NormCopy(av, bv) { float *_a = (float *) av, *_b = (float *) bv; _a[0] = _b[0]; _a[1] = _b[1]; _a[2] = _b[2]; } #define NormAdd(av, bv) { float *_a = (float *) av, *_b = (float *) bv; _a[0] += _b[0]; _a[1] += _b[1]; _a[2] += _b[2]; } - -static int _edge_isBoundary(const CCGEdge *e); - /***/ enum { @@ -309,8 +309,8 @@ enum { } /*FaceFlags*/; struct CCGVert { - CCGVert *next; /* EHData.next */ - CCGVertHDL vHDL; /* EHData.key */ + CCGVert *next; /* EHData.next */ + CCGVertHDL vHDL; /* EHData.key */ short numEdges, numFaces, flags, pad; @@ -322,17 +322,17 @@ struct CCGVert { static CCG_INLINE byte *VERT_getLevelData(CCGVert *v) { - return (byte*)(&(v)[1]); + return (byte *)(&(v)[1]); } struct CCGEdge { - CCGEdge *next; /* EHData.next */ - CCGEdgeHDL eHDL; /* EHData.key */ + CCGEdge *next; /* EHData.next */ + CCGEdgeHDL eHDL; /* EHData.key */ short numFaces, flags; float crease; - CCGVert *v0,*v1; + CCGVert *v0, *v1; CCGFace **faces; // byte *levelData; @@ -341,12 +341,12 @@ struct CCGEdge { static CCG_INLINE byte *EDGE_getLevelData(CCGEdge *e) { - return (byte*)(&(e)[1]); + return (byte *)(&(e)[1]); } struct CCGFace { - CCGFace *next; /* EHData.next */ - CCGFaceHDL fHDL; /* EHData.key */ + CCGFace *next; /* EHData.next */ + CCGFaceHDL fHDL; /* EHData.key */ short numVerts, flags, pad1, pad2; @@ -359,17 +359,17 @@ struct CCGFace { static CCG_INLINE CCGVert **FACE_getVerts(CCGFace *f) { - return (CCGVert**)(&f[1]); + return (CCGVert **)(&f[1]); } static CCG_INLINE CCGEdge **FACE_getEdges(CCGFace *f) { - return (CCGEdge**)(&(FACE_getVerts(f)[f->numVerts])); + return (CCGEdge **)(&(FACE_getVerts(f)[f->numVerts])); } static CCG_INLINE byte *FACE_getCenterData(CCGFace *f) { - return (byte*)(&(FACE_getEdges(f)[(f)->numVerts])); + return (byte *)(&(FACE_getEdges(f)[(f)->numVerts])); } typedef enum { @@ -381,9 +381,9 @@ typedef enum { } SyncState; struct CCGSubSurf { - EHash *vMap; /* map of CCGVertHDL -> Vert */ - EHash *eMap; /* map of CCGEdgeHDL -> Edge */ - EHash *fMap; /* map of CCGFaceHDL -> Face */ + EHash *vMap; /* map of CCGVertHDL -> Vert */ + EHash *eMap; /* map of CCGEdgeHDL -> Edge */ + EHash *fMap; /* map of CCGFaceHDL -> Face */ CCGMeshIFC meshIFC; @@ -398,18 +398,18 @@ struct CCGSubSurf { void *q, *r; - // data for calc vert normals + /* data for calc vert normals */ int calcVertNormals; int normalDataOffset; - // data for age'ing (to debug sync) + /* data for age'ing (to debug sync) */ int currentAge; int useAgeCounts; int vertUserAgeOffset; int edgeUserAgeOffset; int faceUserAgeOffset; - // data used during syncing + /* data used during syncing */ SyncState syncState; EHash *oldVMap, *oldEMap, *oldFMap; @@ -418,9 +418,9 @@ struct CCGSubSurf { CCGEdge **tempEdges; }; -#define CCGSUBSURF_alloc(ss, nb) ((ss)->allocatorIFC.alloc((ss)->allocator, nb)) -#define CCGSUBSURF_realloc(ss, ptr, nb, ob) ((ss)->allocatorIFC.realloc((ss)->allocator, ptr, nb, ob)) -#define CCGSUBSURF_free(ss, ptr) ((ss)->allocatorIFC.free((ss)->allocator, ptr)) +#define CCGSUBSURF_alloc(ss, nb) ((ss)->allocatorIFC.alloc((ss)->allocator, nb)) +#define CCGSUBSURF_realloc(ss, ptr, nb, ob) ((ss)->allocatorIFC.realloc((ss)->allocator, ptr, nb, ob)) +#define CCGSUBSURF_free(ss, ptr) ((ss)->allocatorIFC.free((ss)->allocator, ptr)) /***/ @@ -428,9 +428,9 @@ static CCGVert *_vert_new(CCGVertHDL vHDL, CCGSubSurf *ss) { int num_vert_data = ss->subdivLevels + 1; CCGVert *v = CCGSUBSURF_alloc(ss, - sizeof(CCGVert) + - ss->meshIFC.vertDataSize * num_vert_data + - ss->meshIFC.vertUserSize); + sizeof(CCGVert) + + ss->meshIFC.vertDataSize * num_vert_data + + ss->meshIFC.vertUserSize); byte *userData; v->vHDL = vHDL; @@ -441,7 +441,7 @@ static CCGVert *_vert_new(CCGVertHDL vHDL, CCGSubSurf *ss) userData = ccgSubSurf_getVertUserData(ss, v); memset(userData, 0, ss->meshIFC.vertUserSize); - if (ss->useAgeCounts) *((int*) &userData[ss->vertUserAgeOffset]) = ss->currentAge; + if (ss->useAgeCounts) *((int *) &userData[ss->vertUserAgeOffset]) = ss->currentAge; return v; } @@ -541,7 +541,7 @@ static CCGEdge *_edge_new(CCGEdgeHDL eHDL, CCGVert *v0, CCGVert *v1, float creas userData = ccgSubSurf_getEdgeUserData(ss, e); memset(userData, 0, ss->meshIFC.edgeUserSize); - if (ss->useAgeCounts) *((int*) &userData[ss->edgeUserAgeOffset]) = ss->currentAge; + if (ss->useAgeCounts) *((int *) &userData[ss->edgeUserAgeOffset]) = ss->currentAge; return e; } @@ -562,7 +562,7 @@ static void _edge_addFace(CCGEdge *e, CCGFace *f, CCGSubSurf *ss) } static int _edge_isBoundary(const CCGEdge *e) { - return e->numFaces<2; + return e->numFaces < 2; } static CCGVert *_edge_getOtherVert(CCGEdge *e, CCGVert *vQ) @@ -626,11 +626,11 @@ static CCGFace *_face_new(CCGFaceHDL fHDL, CCGVert **verts, CCGEdge **edges, int { int maxGridSize = ccg_gridsize(ss->subdivLevels); int num_face_data = (numVerts * maxGridSize + - numVerts * maxGridSize * maxGridSize + 1); + numVerts * maxGridSize * maxGridSize + 1); CCGFace *f = CCGSUBSURF_alloc(ss, sizeof(CCGFace) + - sizeof(CCGVert*) * numVerts + - sizeof(CCGEdge*) * numVerts + + sizeof(CCGVert *) * numVerts + + sizeof(CCGEdge *) * numVerts + ss->meshIFC.vertDataSize * num_face_data + ss->meshIFC.faceUserSize); byte *userData; @@ -649,7 +649,7 @@ static CCGFace *_face_new(CCGFaceHDL fHDL, CCGVert **verts, CCGEdge **edges, int userData = ccgSubSurf_getFaceUserData(ss, f); memset(userData, 0, ss->meshIFC.faceUserSize); - if (ss->useAgeCounts) *((int*) &userData[ss->faceUserAgeOffset]) = ss->currentAge; + if (ss->useAgeCounts) *((int *) &userData[ss->faceUserAgeOffset]) = ss->currentAge; return f; } @@ -702,12 +702,12 @@ static CCG_INLINE void *_face_getIFCoEdge(CCGFace *f, CCGEdge *e, int lvl, int e eX = eX * spacing; eY = eY * spacing; - if (e->v0!=FACE_getVerts(f)[S]) { + if (e->v0 != FACE_getVerts(f)[S]) { eX = (maxGridSize * 2 - 1) - 1 - eX; } y = maxGridSize - 1 - eX; x = maxGridSize - 1 - eY; - if (x<0) { + if (x < 0) { S = (S + f->numVerts - 1) % f->numVerts; cx = y; cy = -x; @@ -733,8 +733,8 @@ static void _face_calcIFNo(CCGFace *f, int lvl, int S, int x, int y, float *no, float *b = _face_getIFCo(f, lvl, S, x + 1, y + 0, levels, dataSize); float *c = _face_getIFCo(f, lvl, S, x + 1, y + 1, levels, dataSize); float *d = _face_getIFCo(f, lvl, S, x + 0, y + 1, levels, dataSize); - float a_cX = c[0]-a[0], a_cY = c[1]-a[1], a_cZ = c[2]-a[2]; - float b_dX = d[0]-b[0], b_dY = d[1]-b[1], b_dZ = d[2]-b[2]; + float a_cX = c[0] - a[0], a_cY = c[1] - a[1], a_cZ = c[2] - a[2]; + float b_dX = d[0] - b[0], b_dY = d[1] - b[1], b_dZ = d[2] - b[2]; float length; no[0] = b_dY * a_cZ - b_dZ * a_cY; @@ -779,7 +779,7 @@ CCGSubSurf *ccgSubSurf_new(CCGMeshIFC *ifc, int subdivLevels, CCGAllocatorIFC *a allocator = NULL; } - if (subdivLevels<1) { + if (subdivLevels < 1) { return NULL; } else { @@ -881,10 +881,10 @@ void ccgSubSurf_getAllowEdgeCreation(CCGSubSurf *ss, int *allowEdgeCreation_r, f CCGError ccgSubSurf_setSubdivisionLevels(CCGSubSurf *ss, int subdivisionLevels) { - if (subdivisionLevels<=0) { + if (subdivisionLevels <= 0) { return eCCGError_InvalidValue; } - else if (subdivisionLevels!=ss->subdivLevels) { + else if (subdivisionLevels != ss->subdivLevels) { ss->numGrids = 0; ss->subdivLevels = subdivisionLevels; _ehash_free(ss->vMap, (EHEntryFreeFP) _vert_free, ss); @@ -934,7 +934,7 @@ CCGError ccgSubSurf_setUseAgeCounts(CCGSubSurf *ss, int useAgeCounts, int vertUs CCGError ccgSubSurf_setCalcVertexNormals(CCGSubSurf *ss, int useVertNormals, int normalDataOffset) { if (useVertNormals) { - if (normalDataOffset<0 || normalDataOffset + 12>ss->meshIFC.vertDataSize) { + if (normalDataOffset < 0 || normalDataOffset + 12 > ss->meshIFC.vertDataSize) { return eCCGError_InvalidValue; } else { @@ -954,7 +954,7 @@ CCGError ccgSubSurf_setCalcVertexNormals(CCGSubSurf *ss, int useVertNormals, int CCGError ccgSubSurf_initFullSync(CCGSubSurf *ss) { - if (ss->syncState!=eSyncState_None) { + if (ss->syncState != eSyncState_None) { return eCCGError_InvalidSyncState; } @@ -981,7 +981,7 @@ CCGError ccgSubSurf_initFullSync(CCGSubSurf *ss) CCGError ccgSubSurf_initPartialSync(CCGSubSurf *ss) { - if (ss->syncState!=eSyncState_None) { + if (ss->syncState != eSyncState_None) { return eCCGError_InvalidSyncState; } @@ -994,7 +994,7 @@ CCGError ccgSubSurf_initPartialSync(CCGSubSurf *ss) CCGError ccgSubSurf_syncVertDel(CCGSubSurf *ss, CCGVertHDL vHDL) { - if (ss->syncState!=eSyncState_Partial) { + if (ss->syncState != eSyncState_Partial) { return eCCGError_InvalidSyncState; } else { @@ -1015,7 +1015,7 @@ CCGError ccgSubSurf_syncVertDel(CCGSubSurf *ss, CCGVertHDL vHDL) CCGError ccgSubSurf_syncEdgeDel(CCGSubSurf *ss, CCGEdgeHDL eHDL) { - if (ss->syncState!=eSyncState_Partial) { + if (ss->syncState != eSyncState_Partial) { return eCCGError_InvalidSyncState; } else { @@ -1036,7 +1036,7 @@ CCGError ccgSubSurf_syncEdgeDel(CCGSubSurf *ss, CCGEdgeHDL eHDL) CCGError ccgSubSurf_syncFaceDel(CCGSubSurf *ss, CCGFaceHDL fHDL) { - if (ss->syncState!=eSyncState_Partial) { + if (ss->syncState != eSyncState_Partial) { return eCCGError_InvalidSyncState; } else { @@ -1059,21 +1059,21 @@ CCGError ccgSubSurf_syncVert(CCGSubSurf *ss, CCGVertHDL vHDL, const void *vertDa { void **prevp; CCGVert *v = NULL; - short seamflag = (seam)? Vert_eSeam: 0; + short seamflag = (seam) ? Vert_eSeam : 0; if (ss->syncState == eSyncState_Partial) { v = _ehash_lookupWithPrev(ss->vMap, vHDL, &prevp); if (!v) { v = _vert_new(vHDL, ss); - VertDataCopy(_vert_getCo(v,0,ss->meshIFC.vertDataSize), vertData); - _ehash_insert(ss->vMap, (EHEntry*) v); - v->flags = Vert_eEffected|seamflag; + VertDataCopy(_vert_getCo(v, 0, ss->meshIFC.vertDataSize), vertData); + _ehash_insert(ss->vMap, (EHEntry *) v); + v->flags = Vert_eEffected | seamflag; } else if (!VertDataEqual(vertData, _vert_getCo(v, 0, ss->meshIFC.vertDataSize)) || ((v->flags & Vert_eSeam) != seamflag)) { int i, j; - VertDataCopy(_vert_getCo(v,0,ss->meshIFC.vertDataSize), vertData); - v->flags = Vert_eEffected|seamflag; + VertDataCopy(_vert_getCo(v, 0, ss->meshIFC.vertDataSize), vertData); + v->flags = Vert_eEffected | seamflag; for (i = 0; i < v->numEdges; i++) { CCGEdge *e = v->edges[i]; @@ -1089,26 +1089,26 @@ CCGError ccgSubSurf_syncVert(CCGSubSurf *ss, CCGVertHDL vHDL, const void *vertDa } } else { - if (ss->syncState!=eSyncState_Vert) { + if (ss->syncState != eSyncState_Vert) { return eCCGError_InvalidSyncState; } v = _ehash_lookupWithPrev(ss->oldVMap, vHDL, &prevp); if (!v) { v = _vert_new(vHDL, ss); - VertDataCopy(_vert_getCo(v,0,ss->meshIFC.vertDataSize), vertData); - _ehash_insert(ss->vMap, (EHEntry*) v); - v->flags = Vert_eEffected|seamflag; + VertDataCopy(_vert_getCo(v, 0, ss->meshIFC.vertDataSize), vertData); + _ehash_insert(ss->vMap, (EHEntry *) v); + v->flags = Vert_eEffected | seamflag; } else if (!VertDataEqual(vertData, _vert_getCo(v, 0, ss->meshIFC.vertDataSize)) || ((v->flags & Vert_eSeam) != seamflag)) { *prevp = v->next; - _ehash_insert(ss->vMap, (EHEntry*) v); - VertDataCopy(_vert_getCo(v,0,ss->meshIFC.vertDataSize), vertData); - v->flags = Vert_eEffected|Vert_eChanged|seamflag; + _ehash_insert(ss->vMap, (EHEntry *) v); + VertDataCopy(_vert_getCo(v, 0, ss->meshIFC.vertDataSize), vertData); + v->flags = Vert_eEffected | Vert_eChanged | seamflag; } else { *prevp = v->next; - _ehash_insert(ss->vMap, (EHEntry*) v); + _ehash_insert(ss->vMap, (EHEntry *) v); v->flags = 0; } } @@ -1124,7 +1124,7 @@ CCGError ccgSubSurf_syncEdge(CCGSubSurf *ss, CCGEdgeHDL eHDL, CCGVertHDL e_vHDL0 if (ss->syncState == eSyncState_Partial) { e = _ehash_lookupWithPrev(ss->eMap, eHDL, &prevp); - if (!e || e->v0->vHDL!=e_vHDL0 || e->v1->vHDL!=e_vHDL1 || crease!=e->crease) { + if (!e || e->v0->vHDL != e_vHDL0 || e->v1->vHDL != e_vHDL1 || crease != e->crease) { CCGVert *v0 = _ehash_lookup(ss->vMap, e_vHDL0); CCGVert *v1 = _ehash_lookup(ss->vMap, e_vHDL1); @@ -1137,7 +1137,7 @@ CCGError ccgSubSurf_syncEdge(CCGSubSurf *ss, CCGEdgeHDL eHDL, CCGVertHDL e_vHDL0 _edge_unlinkMarkAndFree(e, ss); } else { - _ehash_insert(ss->eMap, (EHEntry*) eNew); + _ehash_insert(ss->eMap, (EHEntry *) eNew); } eNew->v0->flags |= Vert_eEffected; @@ -1148,24 +1148,24 @@ CCGError ccgSubSurf_syncEdge(CCGSubSurf *ss, CCGEdgeHDL eHDL, CCGVertHDL e_vHDL0 if (ss->syncState == eSyncState_Vert) { ss->syncState = eSyncState_Edge; } - else if (ss->syncState!=eSyncState_Edge) { + else if (ss->syncState != eSyncState_Edge) { return eCCGError_InvalidSyncState; } e = _ehash_lookupWithPrev(ss->oldEMap, eHDL, &prevp); - if (!e || e->v0->vHDL!=e_vHDL0 || e->v1->vHDL!=e_vHDL1|| e->crease!=crease) { + if (!e || e->v0->vHDL != e_vHDL0 || e->v1->vHDL != e_vHDL1 || e->crease != crease) { CCGVert *v0 = _ehash_lookup(ss->vMap, e_vHDL0); CCGVert *v1 = _ehash_lookup(ss->vMap, e_vHDL1); e = _edge_new(eHDL, v0, v1, crease, ss); - _ehash_insert(ss->eMap, (EHEntry*) e); + _ehash_insert(ss->eMap, (EHEntry *) e); e->v0->flags |= Vert_eEffected; e->v1->flags |= Vert_eEffected; } else { *prevp = e->next; - _ehash_insert(ss->eMap, (EHEntry*) e); + _ehash_insert(ss->eMap, (EHEntry *) e); e->flags = 0; - if ((e->v0->flags|e->v1->flags)&Vert_eChanged) { + if ((e->v0->flags | e->v1->flags) & Vert_eChanged) { e->v0->flags |= Vert_eEffected; e->v1->flags |= Vert_eEffected; } @@ -1199,10 +1199,12 @@ CCGError ccgSubSurf_syncFace(CCGSubSurf *ss, CCGFaceHDL fHDL, int numVerts, CCGV } if (f) { - if ( f->numVerts!=numVerts || - memcmp(FACE_getVerts(f), ss->tempVerts, sizeof(*ss->tempVerts) * numVerts) || - memcmp(FACE_getEdges(f), ss->tempEdges, sizeof(*ss->tempEdges) * numVerts)) + if (f->numVerts != numVerts || + memcmp(FACE_getVerts(f), ss->tempVerts, sizeof(*ss->tempVerts) * numVerts) || + memcmp(FACE_getEdges(f), ss->tempEdges, sizeof(*ss->tempEdges) * numVerts)) + { topologyChanged = 1; + } } if (!f || topologyChanged) { @@ -1218,7 +1220,7 @@ CCGError ccgSubSurf_syncFace(CCGSubSurf *ss, CCGFaceHDL fHDL, int numVerts, CCGV } else { ss->numGrids += numVerts; - _ehash_insert(ss->fMap, (EHEntry*) fNew); + _ehash_insert(ss->fMap, (EHEntry *) fNew); } for (k = 0; k < numVerts; k++) @@ -1229,7 +1231,7 @@ CCGError ccgSubSurf_syncFace(CCGSubSurf *ss, CCGFaceHDL fHDL, int numVerts, CCGV if (ss->syncState == eSyncState_Vert || ss->syncState == eSyncState_Edge) { ss->syncState = eSyncState_Face; } - else if (ss->syncState!=eSyncState_Face) { + else if (ss->syncState != eSyncState_Face) { return eCCGError_InvalidSyncState; } @@ -1246,8 +1248,8 @@ CCGError ccgSubSurf_syncFace(CCGSubSurf *ss, CCGFaceHDL fHDL, int numVerts, CCGV if (!ss->tempEdges[k]) { if (ss->allowEdgeCreation) { - CCGEdge *e = ss->tempEdges[k] = _edge_new((CCGEdgeHDL) -1, ss->tempVerts[k], ss->tempVerts[(k + 1) % numVerts], ss->defaultCreaseValue, ss); - _ehash_insert(ss->eMap, (EHEntry*) e); + CCGEdge *e = ss->tempEdges[k] = _edge_new((CCGEdgeHDL) - 1, ss->tempVerts[k], ss->tempVerts[(k + 1) % numVerts], ss->defaultCreaseValue, ss); + _ehash_insert(ss->eMap, (EHEntry *) e); e->v0->flags |= Vert_eEffected; e->v1->flags |= Vert_eEffected; if (ss->meshIFC.edgeUserSize) { @@ -1261,15 +1263,15 @@ CCGError ccgSubSurf_syncFace(CCGSubSurf *ss, CCGFaceHDL fHDL, int numVerts, CCGV } if (f) { - if ( f->numVerts!=numVerts || - memcmp(FACE_getVerts(f), ss->tempVerts, sizeof(*ss->tempVerts) * numVerts) || - memcmp(FACE_getEdges(f), ss->tempEdges, sizeof(*ss->tempEdges) * numVerts)) + if (f->numVerts != numVerts || + memcmp(FACE_getVerts(f), ss->tempVerts, sizeof(*ss->tempVerts) * numVerts) || + memcmp(FACE_getEdges(f), ss->tempEdges, sizeof(*ss->tempEdges) * numVerts)) topologyChanged = 1; } if (!f || topologyChanged) { f = _face_new(fHDL, ss->tempVerts, ss->tempEdges, numVerts, ss); - _ehash_insert(ss->fMap, (EHEntry*) f); + _ehash_insert(ss->fMap, (EHEntry *) f); ss->numGrids += numVerts; for (k = 0; k < numVerts; k++) @@ -1277,7 +1279,7 @@ CCGError ccgSubSurf_syncFace(CCGSubSurf *ss, CCGFaceHDL fHDL, int numVerts, CCGV } else { *prevp = f->next; - _ehash_insert(ss->fMap, (EHEntry*) f); + _ehash_insert(ss->fMap, (EHEntry *) f); f->flags = 0; ss->numGrids += f->numVerts; @@ -1295,7 +1297,6 @@ CCGError ccgSubSurf_syncFace(CCGSubSurf *ss, CCGFaceHDL fHDL, int numVerts, CCGV return eCCGError_None; } -static void ccgSubSurf__sync(CCGSubSurf *ss); CCGError ccgSubSurf_processSync(CCGSubSurf *ss) { if (ss->syncState == eSyncState_Partial) { @@ -1327,15 +1328,17 @@ CCGError ccgSubSurf_processSync(CCGSubSurf *ss) return eCCGError_None; } -#define VERT_getNo(e, lvl) _vert_getNo(e, lvl, vertDataSize, normalDataOffset) -#define EDGE_getNo(e, lvl, x) _edge_getNo(e, lvl, x, vertDataSize, normalDataOffset) -#define FACE_getIFNo(f, lvl, S, x, y) _face_getIFNo(f, lvl, S, x, y, subdivLevels, vertDataSize, normalDataOffset) -#define FACE_calcIFNo(f, lvl, S, x, y, no) _face_calcIFNo(f, lvl, S, x, y, no, subdivLevels, vertDataSize) -#define FACE_getIENo(f, lvl, S, x) _face_getIENo(f, lvl, S, x, subdivLevels, vertDataSize, normalDataOffset) +#define VERT_getNo(e, lvl) _vert_getNo(e, lvl, vertDataSize, normalDataOffset) +#define EDGE_getNo(e, lvl, x) _edge_getNo(e, lvl, x, vertDataSize, normalDataOffset) +#define FACE_getIFNo(f, lvl, S, x, y) _face_getIFNo(f, lvl, S, x, y, subdivLevels, vertDataSize, normalDataOffset) +#define FACE_calcIFNo(f, lvl, S, x, y, no) _face_calcIFNo(f, lvl, S, x, y, no, subdivLevels, vertDataSize) +#define FACE_getIENo(f, lvl, S, x) _face_getIENo(f, lvl, S, x, subdivLevels, vertDataSize, normalDataOffset) + static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss, - CCGVert **effectedV, CCGEdge **effectedE, CCGFace **effectedF, - int numEffectedV, int numEffectedE, int numEffectedF) { - int i,ptrIdx; + CCGVert **effectedV, CCGEdge **effectedE, CCGFace **effectedF, + int numEffectedV, int numEffectedE, int numEffectedF) +{ + int i, ptrIdx; int subdivLevels = ss->subdivLevels; int lvl = ss->subdivLevels; int edgeSize = ccg_edgesize(lvl); @@ -1345,7 +1348,7 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss, #pragma omp parallel for private(ptrIdx) if (numEffectedF * edgeSize * edgeSize * 4 >= CCG_OMP_LIMIT) for (ptrIdx = 0; ptrIdx < numEffectedF; ptrIdx++) { - CCGFace *f = (CCGFace*) effectedF[ptrIdx]; + CCGFace *f = (CCGFace *) effectedF[ptrIdx]; int S, x, y; float no[3]; @@ -1354,19 +1357,19 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss, for (x = 0; x < gridSize - 1; x++) NormZero(FACE_getIFNo(f, lvl, S, x, y)); - if (FACE_getEdges(f)[(S - 1+f->numVerts)%f->numVerts]->flags&Edge_eEffected) + if (FACE_getEdges(f)[(S - 1 + f->numVerts) % f->numVerts]->flags & Edge_eEffected) for (x = 0; x < gridSize - 1; x++) NormZero(FACE_getIFNo(f, lvl, S, x, gridSize - 1)); - if (FACE_getEdges(f)[S]->flags&Edge_eEffected) + if (FACE_getEdges(f)[S]->flags & Edge_eEffected) for (y = 0; y < gridSize - 1; y++) NormZero(FACE_getIFNo(f, lvl, S, gridSize - 1, y)); - if (FACE_getVerts(f)[S]->flags&Vert_eEffected) + if (FACE_getVerts(f)[S]->flags & Vert_eEffected) NormZero(FACE_getIFNo(f, lvl, S, gridSize - 1, gridSize - 1)); } for (S = 0; S < f->numVerts; S++) { int yLimit = !(FACE_getEdges(f)[(S - 1 + f->numVerts) % f->numVerts]->flags & Edge_eEffected); - int xLimit = !(FACE_getEdges(f)[S]->flags&Edge_eEffected); + int xLimit = !(FACE_getEdges(f)[S]->flags & Edge_eEffected); int yLimitNext = xLimit; int xLimitPrev = yLimit; @@ -1391,13 +1394,13 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss, if (x == 0 && y == 0) { int K; - if (!yLimitNext || 1numVerts, 0, 1), no); - if (!xLimitPrev || 1numVerts) % f->numVerts, 1, 0), no); for (K = 0; K < f->numVerts; K++) { - if (K!=S) { + if (K != S) { NormAdd(FACE_getIFNo(f, lvl, K, 0, 0), no); } } @@ -1416,22 +1419,22 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss, } } } - // XXX can I reduce the number of normalisations here? + /* XXX can I reduce the number of normalisations here? */ for (ptrIdx = 0; ptrIdx < numEffectedV; ptrIdx++) { - CCGVert *v = (CCGVert*) effectedV[ptrIdx]; + CCGVert *v = (CCGVert *) effectedV[ptrIdx]; float length, *no = _vert_getNo(v, lvl, vertDataSize, normalDataOffset); NormZero(no); for (i = 0; i < v->numFaces; i++) { CCGFace *f = v->faces[i]; - NormAdd(no, FACE_getIFNo(f, lvl, _face_getVertIndex(f,v), gridSize - 1, gridSize - 1)); + NormAdd(no, FACE_getIFNo(f, lvl, _face_getVertIndex(f, v), gridSize - 1, gridSize - 1)); } length = sqrtf(no[0] * no[0] + no[1] * no[1] + no[2] * no[2]); if (length > EPSILON) { - float invLength = 1.0f/length; + float invLength = 1.0f / length; no[0] *= invLength; no[1] *= invLength; no[2] *= invLength; @@ -1442,11 +1445,11 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss, for (i = 0; i < v->numFaces; i++) { CCGFace *f = v->faces[i]; - NormCopy(FACE_getIFNo(f, lvl, _face_getVertIndex(f,v), gridSize - 1, gridSize - 1), no); + NormCopy(FACE_getIFNo(f, lvl, _face_getVertIndex(f, v), gridSize - 1, gridSize - 1), no); } } for (ptrIdx = 0; ptrIdx < numEffectedE; ptrIdx++) { - CCGEdge *e = (CCGEdge*) effectedE[ptrIdx]; + CCGEdge *e = (CCGEdge *) effectedE[ptrIdx]; if (e->numFaces) { CCGFace *fLast = e->faces[e->numFaces - 1]; @@ -1457,7 +1460,7 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss, for (x = 1; x < edgeSize - 1; x++) { NormAdd(_face_getIFNoEdge(fLast, e, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset), - _face_getIFNoEdge(f, e, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset)); + _face_getIFNoEdge(f, e, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset)); } } @@ -1466,7 +1469,7 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss, for (x = 1; x < edgeSize - 1; x++) { NormCopy(_face_getIFNoEdge(f, e, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset), - _face_getIFNoEdge(fLast, e, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset)); + _face_getIFNoEdge(fLast, e, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset)); } } } @@ -1474,7 +1477,7 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss, #pragma omp parallel for private(ptrIdx) if (numEffectedF * edgeSize * edgeSize * 4 >= CCG_OMP_LIMIT) for (ptrIdx = 0; ptrIdx < numEffectedF; ptrIdx++) { - CCGFace *f = (CCGFace*) effectedF[ptrIdx]; + CCGFace *f = (CCGFace *) effectedF[ptrIdx]; int S, x, y; for (S = 0; S < f->numVerts; S++) { @@ -1489,7 +1492,7 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss, float length = sqrtf(no[0] * no[0] + no[1] * no[1] + no[2] * no[2]); if (length > EPSILON) { - float invLength = 1.0f/length; + float invLength = 1.0f / length; no[0] *= invLength; no[1] *= invLength; no[2] *= invLength; @@ -1501,16 +1504,16 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss, } VertDataCopy((float *)((byte *)FACE_getCenterData(f) + normalDataOffset), - FACE_getIFNo(f, lvl, S, 0, 0)); + FACE_getIFNo(f, lvl, S, 0, 0)); for (x = 1; x < gridSize - 1; x++) NormCopy(FACE_getIENo(f, lvl, S, x), - FACE_getIFNo(f, lvl, S, x, 0)); + FACE_getIFNo(f, lvl, S, x, 0)); } } for (ptrIdx = 0; ptrIdx < numEffectedE; ptrIdx++) { - CCGEdge *e = (CCGEdge*) effectedE[ptrIdx]; + CCGEdge *e = (CCGEdge *) effectedE[ptrIdx]; if (e->numFaces) { CCGFace *f = e->faces[0]; @@ -1518,7 +1521,7 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss, for (x = 0; x < edgeSize; x++) NormCopy(EDGE_getNo(e, lvl, x), - _face_getIFNoEdge(f, e, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset)); + _face_getIFNoEdge(f, e, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset)); } else { /* set to zero here otherwise the normals are uninitialized memory @@ -1535,10 +1538,10 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss, } #undef FACE_getIFNo -#define VERT_getCo(v, lvl) _vert_getCo(v, lvl, vertDataSize) -#define EDGE_getCo(e, lvl, x) _edge_getCo(e, lvl, x, vertDataSize) -#define FACE_getIECo(f, lvl, S, x) _face_getIECo(f, lvl, S, x, subdivLevels, vertDataSize) -#define FACE_getIFCo(f, lvl, S, x, y) _face_getIFCo(f, lvl, S, x, y, subdivLevels, vertDataSize) +#define VERT_getCo(v, lvl) _vert_getCo(v, lvl, vertDataSize) +#define EDGE_getCo(e, lvl, x) _edge_getCo(e, lvl, x, vertDataSize) +#define FACE_getIECo(f, lvl, S, x) _face_getIECo(f, lvl, S, x, subdivLevels, vertDataSize) +#define FACE_getIFCo(f, lvl, S, x, y) _face_getIFCo(f, lvl, S, x, y, subdivLevels, vertDataSize) static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, CCGVert **effectedV, CCGEdge **effectedE, CCGFace **effectedF, @@ -1554,17 +1557,17 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, #pragma omp parallel for private(ptrIdx) if (numEffectedF * edgeSize * edgeSize * 4 >= CCG_OMP_LIMIT) for (ptrIdx = 0; ptrIdx < numEffectedF; ptrIdx++) { - CCGFace *f = (CCGFace*) effectedF[ptrIdx]; + CCGFace *f = (CCGFace *) effectedF[ptrIdx]; int S, x, y; - /* interior face midpoints - * o old interior face points - */ + /* interior face midpoints + * - old interior face points + */ for (S = 0; S < f->numVerts; S++) { for (y = 0; y < gridSize - 1; y++) { for (x = 0; x < gridSize - 1; x++) { - int fx = 1 + 2*x; - int fy = 1 + 2*y; + int fx = 1 + 2 * x; + int fy = 1 + 2 * y; void *co0 = FACE_getIFCo(f, curLvl, S, x + 0, y + 0); void *co1 = FACE_getIFCo(f, curLvl, S, x + 1, y + 0); void *co2 = FACE_getIFCo(f, curLvl, S, x + 1, y + 1); @@ -1576,10 +1579,10 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, } } - /* interior edge midpoints - * o old interior edge points - * o new interior face midpoints - */ + /* interior edge midpoints + * - old interior edge points + * - new interior face midpoints + */ for (S = 0; S < f->numVerts; S++) { for (x = 0; x < gridSize - 1; x++) { int fx = x * 2 + 1; @@ -1592,12 +1595,12 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, VertDataAvg4(co, co0, co1, co2, co3); } - /* interior face interior edge midpoints - * o old interior face points - * o new interior face midpoints - */ + /* interior face interior edge midpoints + * - old interior face points + * - new interior face midpoints + */ - /* vertical */ + /* vertical */ for (x = 1; x < gridSize - 1; x++) { for (y = 0; y < gridSize - 1; y++) { int fx = x * 2; @@ -1612,7 +1615,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, } } - /* horizontal */ + /* horizontal */ for (y = 1; y < gridSize - 1; y++) { for (x = 0; x < gridSize - 1; x++) { int fx = x * 2 + 1; @@ -1629,12 +1632,12 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, } } - /* exterior edge midpoints - * o old exterior edge points - * o new interior face midpoints - */ + /* exterior edge midpoints + * - old exterior edge points + * - new interior face midpoints + */ for (ptrIdx = 0; ptrIdx < numEffectedE; ptrIdx++) { - CCGEdge *e = (CCGEdge*) effectedE[ptrIdx]; + CCGEdge *e = (CCGEdge *) effectedE[ptrIdx]; float sharpness = EDGE_getSharpness(e, curLvl); int x, j; @@ -1681,13 +1684,13 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, } } - /* exterior vertex shift - * o old vertex points (shifting) - * o old exterior edge points - * o new interior face midpoints - */ + /* exterior vertex shift + * - old vertex points (shifting) + * - old exterior edge points + * - new interior face midpoints + */ for (ptrIdx = 0; ptrIdx < numEffectedV; ptrIdx++) { - CCGVert *v = (CCGVert*) effectedV[ptrIdx]; + CCGVert *v = (CCGVert *) effectedV[ptrIdx]; void *co = VERT_getCo(v, curLvl); void *nCo = VERT_getCo(v, nextLvl); int sharpCount = 0, allSharp = 1; @@ -1701,7 +1704,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, if (seam && _edge_isBoundary(e)) seamEdges++; - if (sharpness!=0.0f) { + if (sharpness != 0.0f) { sharpCount++; avgSharpness += sharpness; } @@ -1737,7 +1740,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, VertDataCopy(nCo, co); VertDataMulN(nCo, 0.75f); - VertDataMulN(r, 0.25f/numBoundary); + VertDataMulN(r, 0.25f / numBoundary); VertDataAdd(nCo, r); } else { @@ -1747,26 +1750,26 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, VertDataZero(q); for (j = 0; j < v->numFaces; j++) { CCGFace *f = v->faces[j]; - VertDataAdd(q, FACE_getIFCo(f, nextLvl, _face_getVertIndex(f,v), cornerIdx, cornerIdx)); + VertDataAdd(q, FACE_getIFCo(f, nextLvl, _face_getVertIndex(f, v), cornerIdx, cornerIdx)); numFaces++; } - VertDataMulN(q, 1.0f/numFaces); + VertDataMulN(q, 1.0f / numFaces); VertDataZero(r); for (j = 0; j < v->numEdges; j++) { CCGEdge *e = v->edges[j]; - VertDataAdd(r, _edge_getCoVert(e, v, curLvl, 1,vertDataSize)); + VertDataAdd(r, _edge_getCoVert(e, v, curLvl, 1, vertDataSize)); numEdges++; } - VertDataMulN(r, 1.0f/numEdges); + VertDataMulN(r, 1.0f / numEdges); VertDataCopy(nCo, co); VertDataMulN(nCo, numEdges - 2.0f); VertDataAdd(nCo, q); VertDataAdd(nCo, r); - VertDataMulN(nCo, 1.0f/numEdges); + VertDataMulN(nCo, 1.0f / numEdges); } - if ((sharpCount>1 && v->numFaces) || seam) { + if ((sharpCount > 1 && v->numFaces) || seam) { VertDataZero(q); if (seam) { @@ -1788,42 +1791,42 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, } } - VertDataMulN(q, (float) 1/sharpCount); + VertDataMulN(q, (float) 1 / sharpCount); - if (sharpCount!=2 || allSharp) { - // q = q + (co-q) * avgSharpness + if (sharpCount != 2 || allSharp) { + /* q = q + (co - q) * avgSharpness */ VertDataCopy(r, co); VertDataSub(r, q); VertDataMulN(r, avgSharpness); VertDataAdd(q, r); } - // r = co*.75 + q*.25 + /* r = co * 0.75 + q * 0.25 */ VertDataCopy(r, co); VertDataMulN(r, .75f); VertDataMulN(q, .25f); VertDataAdd(r, q); - // nCo = nCo + (r-nCo) * avgSharpness + /* nCo = nCo + (r - nCo) * avgSharpness */ VertDataSub(r, nCo); VertDataMulN(r, avgSharpness); VertDataAdd(nCo, r); } } - /* exterior edge interior shift - * o old exterior edge midpoints (shifting) - * o old exterior edge midpoints - * o new interior face midpoints - */ + /* exterior edge interior shift + * - old exterior edge midpoints (shifting) + * - old exterior edge midpoints + * - new interior face midpoints + */ for (ptrIdx = 0; ptrIdx < numEffectedE; ptrIdx++) { - CCGEdge *e = (CCGEdge*) effectedE[ptrIdx]; + CCGEdge *e = (CCGEdge *) effectedE[ptrIdx]; float sharpness = EDGE_getSharpness(e, curLvl); int sharpCount = 0; float avgSharpness = 0.0; int x, j; - if (sharpness!=0.0f) { + if (sharpness != 0.0f) { sharpCount = 2; avgSharpness += sharpness; @@ -1836,7 +1839,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, avgSharpness = 0; } - if (_edge_isBoundary(e) && (!e->numFaces || sharpCount<2)) { + if (_edge_isBoundary(e) && (!e->numFaces || sharpCount < 2)) { for (x = 1; x < edgeSize - 1; x++) { int fx = x * 2; void *co = EDGE_getCo(e, curLvl, x); @@ -1883,7 +1886,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, VertDataMulN(q, 6.0f); VertDataAdd(q, EDGE_getCo(e, curLvl, x - 1)); VertDataAdd(q, EDGE_getCo(e, curLvl, x + 1)); - VertDataMulN(q, 1/8.0f); + VertDataMulN(q, 1 / 8.0f); VertDataSub(q, nCo); VertDataMulN(q, avgSharpness); @@ -1905,36 +1908,36 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, #pragma omp for schedule(static) for (ptrIdx = 0; ptrIdx < numEffectedF; ptrIdx++) { - CCGFace *f = (CCGFace*) effectedF[ptrIdx]; + CCGFace *f = (CCGFace *) effectedF[ptrIdx]; int S, x, y; - /* interior center point shift - * o old face center point (shifting) - * o old interior edge points - * o new interior face midpoints - */ + /* interior center point shift + * - old face center point (shifting) + * - old interior edge points + * - new interior face midpoints + */ VertDataZero(q); for (S = 0; S < f->numVerts; S++) { VertDataAdd(q, FACE_getIFCo(f, nextLvl, S, 1, 1)); } - VertDataMulN(q, 1.0f/f->numVerts); + VertDataMulN(q, 1.0f / f->numVerts); VertDataZero(r); for (S = 0; S < f->numVerts; S++) { VertDataAdd(r, FACE_getIECo(f, curLvl, S, 1)); } - VertDataMulN(r, 1.0f/f->numVerts); + VertDataMulN(r, 1.0f / f->numVerts); VertDataMulN(FACE_getCenterData(f), f->numVerts - 2.0f); VertDataAdd(FACE_getCenterData(f), q); VertDataAdd(FACE_getCenterData(f), r); - VertDataMulN(FACE_getCenterData(f), 1.0f/f->numVerts); + VertDataMulN(FACE_getCenterData(f), 1.0f / f->numVerts); for (S = 0; S < f->numVerts; S++) { - /* interior face shift - * o old interior face point (shifting) - * o new interior edge midpoints - * o new interior face midpoints - */ + /* interior face shift + * - old interior face point (shifting) + * - new interior edge midpoints + * - new interior face midpoints + */ for (x = 1; x < gridSize - 1; x++) { for (y = 1; y < gridSize - 1; y++) { int fx = x * 2; @@ -1961,11 +1964,11 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, } } - /* interior edge interior shift - * o old interior edge point (shifting) - * o new interior edge midpoints - * o new interior face midpoints - */ + /* interior edge interior shift + * - old interior edge point (shifting) + * - new interior edge midpoints + * - new interior face midpoints + */ for (x = 1; x < gridSize - 1; x++) { int fx = x * 2; void *co = FACE_getIECo(f, curLvl, S, x); @@ -1974,8 +1977,8 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, VertDataAvg4(q, FACE_getIFCo(f, nextLvl, (S + 1) % f->numVerts, 1, fx - 1), FACE_getIFCo(f, nextLvl, (S + 1) % f->numVerts, 1, fx + 1), - FACE_getIFCo(f, nextLvl, S, fx + 1, + 1), - FACE_getIFCo(f, nextLvl, S, fx - 1, + 1)); + FACE_getIFCo(f, nextLvl, S, fx + 1, +1), + FACE_getIFCo(f, nextLvl, S, fx - 1, +1)); VertDataAvg4(r, FACE_getIECo(f, nextLvl, S, fx - 1), @@ -1998,7 +2001,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, } } - /* copy down */ + /* copy down */ edgeSize = ccg_edgesize(nextLvl); gridSize = ccg_gridsize(nextLvl); cornerIdx = gridSize - 1; @@ -2030,8 +2033,8 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, } for (x = 0; x < gridSize - 1; x++) { int eI = gridSize - 1 - x; - VertDataCopy(FACE_getIFCo(f, nextLvl, S, cornerIdx, x), _edge_getCoVert(e, FACE_getVerts(f)[S], nextLvl, eI,vertDataSize)); - VertDataCopy(FACE_getIFCo(f, nextLvl, S, x, cornerIdx), _edge_getCoVert(prevE, FACE_getVerts(f)[S], nextLvl, eI,vertDataSize)); + VertDataCopy(FACE_getIFCo(f, nextLvl, S, cornerIdx, x), _edge_getCoVert(e, FACE_getVerts(f)[S], nextLvl, eI, vertDataSize)); + VertDataCopy(FACE_getIFCo(f, nextLvl, S, x, cornerIdx), _edge_getCoVert(prevE, FACE_getVerts(f)[S], nextLvl, eI, vertDataSize)); } } } @@ -2055,14 +2058,14 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) effectedF = MEM_mallocN(sizeof(*effectedF) * ss->fMap->numEntries, "CCGSubsurf effectedF"); numEffectedV = numEffectedE = numEffectedF = 0; for (i = 0; i < ss->vMap->curSize; i++) { - CCGVert *v = (CCGVert*) ss->vMap->buckets[i]; + CCGVert *v = (CCGVert *) ss->vMap->buckets[i]; for (; v; v = v->next) { - if (v->flags&Vert_eEffected) { + if (v->flags & Vert_eEffected) { effectedV[numEffectedV++] = v; for (j = 0; j < v->numEdges; j++) { CCGEdge *e = v->edges[j]; - if (!(e->flags&Edge_eEffected)) { + if (!(e->flags & Edge_eEffected)) { effectedE[numEffectedE++] = e; e->flags |= Edge_eEffected; } @@ -2070,7 +2073,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) for (j = 0; j < v->numFaces; j++) { CCGFace *f = v->faces[j]; - if (!(f->flags&Face_eEffected)) { + if (!(f->flags & Face_eEffected)) { effectedF[numEffectedF++] = f; f->flags |= Face_eEffected; } @@ -2089,7 +2092,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) for (i = 0; i < f->numVerts; i++) { VertDataAdd(co, VERT_getCo(FACE_getVerts(f)[i], curLvl)); } - VertDataMulN(co, 1.0f/f->numVerts); + VertDataMulN(co, 1.0f / f->numVerts); f->flags = 0; } @@ -2141,7 +2144,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) if (seam && _edge_isBoundary(e)) seamEdges++; - if (sharpness!=0.0f) { + if (sharpness != 0.0f) { sharpCount++; avgSharpness += sharpness; } @@ -2176,7 +2179,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) } VertDataCopy(nCo, co); VertDataMulN(nCo, 0.75f); - VertDataMulN(r, 0.25f/numBoundary); + VertDataMulN(r, 0.25f / numBoundary); VertDataAdd(nCo, r); } else { @@ -2188,23 +2191,23 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) VertDataAdd(q, FACE_getCenterData(f)); numFaces++; } - VertDataMulN(q, 1.0f/numFaces); + VertDataMulN(q, 1.0f / numFaces); VertDataZero(r); for (i = 0; i < v->numEdges; i++) { CCGEdge *e = v->edges[i]; VertDataAdd(r, VERT_getCo(_edge_getOtherVert(e, v), curLvl)); numEdges++; } - VertDataMulN(r, 1.0f/numEdges); + VertDataMulN(r, 1.0f / numEdges); VertDataCopy(nCo, co); VertDataMulN(nCo, numEdges - 2.0f); VertDataAdd(nCo, q); VertDataAdd(nCo, r); - VertDataMulN(nCo, 1.0f/numEdges); + VertDataMulN(nCo, 1.0f / numEdges); } - if (sharpCount>1 || seam) { + if (sharpCount > 1 || seam) { VertDataZero(q); if (seam) { @@ -2229,23 +2232,23 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) } } - VertDataMulN(q, (float) 1/sharpCount); + VertDataMulN(q, (float) 1 / sharpCount); - if (sharpCount!=2 || allSharp) { - // q = q + (co-q) * avgSharpness + if (sharpCount != 2 || allSharp) { + /* q = q + (co - q) * avgSharpness */ VertDataCopy(r, co); VertDataSub(r, q); VertDataMulN(r, avgSharpness); VertDataAdd(q, r); } - // r = co*.75 + q*.25 + /* r = co * 0.75 + q * 0.25 */ VertDataCopy(r, co); VertDataMulN(r, 0.75f); VertDataMulN(q, 0.25f); VertDataAdd(r, q); - // nCo = nCo + (r-nCo) * avgSharpness + /* nCo = nCo + (r - nCo) * avgSharpness */ VertDataSub(r, nCo); VertDataMulN(r, avgSharpness); VertDataAdd(nCo, r); @@ -2258,19 +2261,19 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) for (i = 0; i < numEffectedV; i++) { CCGVert *v = effectedV[i]; byte *userData = ccgSubSurf_getVertUserData(ss, v); - *((int*) &userData[ss->vertUserAgeOffset]) = ss->currentAge; + *((int *) &userData[ss->vertUserAgeOffset]) = ss->currentAge; } for (i = 0; i < numEffectedE; i++) { CCGEdge *e = effectedE[i]; byte *userData = ccgSubSurf_getEdgeUserData(ss, e); - *((int*) &userData[ss->edgeUserAgeOffset]) = ss->currentAge; + *((int *) &userData[ss->edgeUserAgeOffset]) = ss->currentAge; } for (i = 0; i < numEffectedF; i++) { CCGFace *f = effectedF[i]; byte *userData = ccgSubSurf_getFaceUserData(ss, f); - *((int*) &userData[ss->faceUserAgeOffset]) = ss->currentAge; + *((int *) &userData[ss->faceUserAgeOffset]) = ss->currentAge; } } @@ -2297,14 +2300,14 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) for (curLvl = 1; curLvl < subdivLevels; curLvl++) { ccgSubSurf__calcSubdivLevel(ss, - effectedV, effectedE, effectedF, - numEffectedV, numEffectedE, numEffectedF, curLvl); + effectedV, effectedE, effectedF, + numEffectedV, numEffectedE, numEffectedF, curLvl); } if (ss->calcVertNormals) ccgSubSurf__calcVertNormals(ss, - effectedV, effectedE, effectedF, - numEffectedV, numEffectedE, numEffectedF); + effectedV, effectedE, effectedF, + numEffectedV, numEffectedE, numEffectedF); for (ptrIdx = 0; ptrIdx < numEffectedV; ptrIdx++) { CCGVert *v = effectedV[ptrIdx]; @@ -2329,7 +2332,7 @@ static void ccgSubSurf__allFaces(CCGSubSurf *ss, CCGFace ***faces, int *numFaces array = MEM_mallocN(sizeof(*array) * ss->fMap->numEntries, "CCGSubsurf allFaces"); num = 0; for (i = 0; i < ss->fMap->curSize; i++) { - CCGFace *f = (CCGFace*) ss->fMap->buckets[i]; + CCGFace *f = (CCGFace *) ss->fMap->buckets[i]; for (; f; f = f->next) array[num++] = f; @@ -2360,7 +2363,7 @@ static void ccgSubSurf__effectedFaceNeighbours(CCGSubSurf *ss, CCGFace **faces, } for (i = 0; i < ss->vMap->curSize; i++) { - CCGVert *v = (CCGVert*) ss->vMap->buckets[i]; + CCGVert *v = (CCGVert *) ss->vMap->buckets[i]; for (; v; v = v->next) { for (j = 0; j < v->numFaces; j++) @@ -2375,7 +2378,7 @@ static void ccgSubSurf__effectedFaceNeighbours(CCGSubSurf *ss, CCGFace **faces, } for (i = 0; i < ss->eMap->curSize; i++) { - CCGEdge *e = (CCGEdge*) ss->eMap->buckets[i]; + CCGEdge *e = (CCGEdge *) ss->eMap->buckets[i]; for (; e; e = e->next) { for (j = 0; j < e->numFaces; j++) @@ -2402,7 +2405,7 @@ CCGError ccgSubSurf_updateFromFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF int vertDataSize = ss->meshIFC.vertDataSize, freeF; subdivLevels = ss->subdivLevels; - lvl = (lvl)? lvl: subdivLevels; + lvl = (lvl) ? lvl : subdivLevels; gridSize = ccg_gridsize(lvl); cornerIdx = gridSize - 1; @@ -2423,8 +2426,8 @@ CCGError ccgSubSurf_updateFromFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF for (x = 0; x < gridSize; x++) { int eI = gridSize - 1 - x; - VertDataCopy(_edge_getCoVert(e, FACE_getVerts(f)[S], lvl, eI,vertDataSize), FACE_getIFCo(f, lvl, S, cornerIdx, x)); - VertDataCopy(_edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI,vertDataSize), FACE_getIFCo(f, lvl, S, x, cornerIdx)); + VertDataCopy(_edge_getCoVert(e, FACE_getVerts(f)[S], lvl, eI, vertDataSize), FACE_getIFCo(f, lvl, S, cornerIdx, x)); + VertDataCopy(_edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI, vertDataSize), FACE_getIFCo(f, lvl, S, x, cornerIdx)); } } } @@ -2441,7 +2444,7 @@ CCGError ccgSubSurf_updateToFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, int vertDataSize = ss->meshIFC.vertDataSize, freeF; subdivLevels = ss->subdivLevels; - lvl = (lvl)? lvl: subdivLevels; + lvl = (lvl) ? lvl : subdivLevels; gridSize = ccg_gridsize(lvl); cornerIdx = gridSize - 1; @@ -2457,8 +2460,8 @@ CCGError ccgSubSurf_updateToFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, for (x = 0; x < gridSize; x++) { int eI = gridSize - 1 - x; - VertDataCopy(FACE_getIFCo(f, lvl, S, cornerIdx, x), _edge_getCoVert(e, FACE_getVerts(f)[S], lvl, eI,vertDataSize)); - VertDataCopy(FACE_getIFCo(f, lvl, S, x, cornerIdx), _edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI,vertDataSize)); + VertDataCopy(FACE_getIFCo(f, lvl, S, cornerIdx, x), _edge_getCoVert(e, FACE_getVerts(f)[S], lvl, eI, vertDataSize)); + VertDataCopy(FACE_getIFCo(f, lvl, S, x, cornerIdx), _edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI, vertDataSize)); } for (x = 1; x < gridSize - 1; x++) { @@ -2487,14 +2490,14 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in int vertDataSize = ss->meshIFC.vertDataSize; subdivLevels = ss->subdivLevels; - lvl = (lvl)? lvl: subdivLevels; + lvl = (lvl) ? lvl : subdivLevels; gridSize = ccg_gridsize(lvl); edgeSize = ccg_edgesize(lvl); cornerIdx = gridSize - 1; ccgSubSurf__allFaces(ss, &effectedF, &numEffectedF, &freeF); ccgSubSurf__effectedFaceNeighbours(ss, effectedF, numEffectedF, - &effectedV, &numEffectedV, &effectedE, &numEffectedE); + &effectedV, &numEffectedV, &effectedE, &numEffectedE); /* zero */ for (i = 0; i < numEffectedV; i++) { @@ -2527,7 +2530,7 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in CCGEdge *prevE = FACE_getEdges(f)[prevS]; VertDataAdd(FACE_getCenterData(f), FACE_getIFCo(f, lvl, S, 0, 0)); - if (FACE_getVerts(f)[S]->flags&Vert_eEffected) + if (FACE_getVerts(f)[S]->flags & Vert_eEffected) VertDataAdd(VERT_getCo(FACE_getVerts(f)[S], lvl), FACE_getIFCo(f, lvl, S, cornerIdx, cornerIdx)); for (x = 1; x < gridSize - 1; x++) { @@ -2537,11 +2540,11 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in for (x = 0; x < gridSize - 1; x++) { int eI = gridSize - 1 - x; - if (FACE_getEdges(f)[S]->flags&Edge_eEffected) - VertDataAdd(_edge_getCoVert(e, FACE_getVerts(f)[S], lvl, eI,vertDataSize), FACE_getIFCo(f, lvl, S, cornerIdx, x)); - if (FACE_getEdges(f)[prevS]->flags&Edge_eEffected) + if (FACE_getEdges(f)[S]->flags & Edge_eEffected) + VertDataAdd(_edge_getCoVert(e, FACE_getVerts(f)[S], lvl, eI, vertDataSize), FACE_getIFCo(f, lvl, S, cornerIdx, x)); + if (FACE_getEdges(f)[prevS]->flags & Edge_eEffected) if (x != 0) - VertDataAdd(_edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI,vertDataSize), FACE_getIFCo(f, lvl, S, x, cornerIdx)); + VertDataAdd(_edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI, vertDataSize), FACE_getIFCo(f, lvl, S, x, cornerIdx)); } } } @@ -2550,7 +2553,7 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in for (i = 0; i < numEffectedV; i++) { CCGVert *v = effectedV[i]; if (v->numFaces) - VertDataMulN(VERT_getCo(v, lvl), 1.0f/v->numFaces); + VertDataMulN(VERT_getCo(v, lvl), 1.0f / v->numFaces); } for (i = 0; i < numEffectedE; i++) { @@ -2561,14 +2564,14 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in if (e->numFaces) for (x = 1; x < edgeSize - 1; x++) - VertDataMulN(EDGE_getCo(e, lvl, x), 1.0f/e->numFaces); + VertDataMulN(EDGE_getCo(e, lvl, x), 1.0f / e->numFaces); } /* copy */ for (i = 0; i < numEffectedF; i++) { CCGFace *f = effectedF[i]; - VertDataMulN(FACE_getCenterData(f), 1.0f/f->numVerts); + VertDataMulN(FACE_getCenterData(f), 1.0f / f->numVerts); for (S = 0; S < f->numVerts; S++) for (x = 1; x < gridSize - 1; x++) @@ -2589,8 +2592,8 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in for (x = 0; x < gridSize - 1; x++) { int eI = gridSize - 1 - x; - VertDataCopy(FACE_getIFCo(f, lvl, S, cornerIdx, x), _edge_getCoVert(e, FACE_getVerts(f)[S], lvl, eI,vertDataSize)); - VertDataCopy(FACE_getIFCo(f, lvl, S, x, cornerIdx), _edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI,vertDataSize)); + VertDataCopy(FACE_getIFCo(f, lvl, S, cornerIdx, x), _edge_getCoVert(e, FACE_getVerts(f)[S], lvl, eI, vertDataSize)); + VertDataCopy(FACE_getIFCo(f, lvl, S, x, cornerIdx), _edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI, vertDataSize)); } VertDataCopy(FACE_getIECo(f, lvl, S, 0), FACE_getCenterData(f)); @@ -2621,12 +2624,12 @@ CCGError ccgSubSurf_updateNormals(CCGSubSurf *ss, CCGFace **effectedF, int numEf ccgSubSurf__allFaces(ss, &effectedF, &numEffectedF, &freeF); ccgSubSurf__effectedFaceNeighbours(ss, effectedF, numEffectedF, - &effectedV, &numEffectedV, &effectedE, &numEffectedE); + &effectedV, &numEffectedV, &effectedE, &numEffectedE); if (ss->calcVertNormals) ccgSubSurf__calcVertNormals(ss, - effectedV, effectedE, effectedF, - numEffectedV, numEffectedE, numEffectedF); + effectedV, effectedE, effectedF, + numEffectedV, numEffectedE, numEffectedF); for (i = 0; i < numEffectedV; i++) effectedV[i]->flags = 0; @@ -2654,12 +2657,12 @@ CCGError ccgSubSurf_updateLevels(CCGSubSurf *ss, int lvl, CCGFace **effectedF, i ccgSubSurf__allFaces(ss, &effectedF, &numEffectedF, &freeF); ccgSubSurf__effectedFaceNeighbours(ss, effectedF, numEffectedF, - &effectedV, &numEffectedV, &effectedE, &numEffectedE); + &effectedV, &numEffectedV, &effectedE, &numEffectedE); for (curLvl = lvl; curLvl < subdivLevels; curLvl++) { ccgSubSurf__calcSubdivLevel(ss, - effectedV, effectedE, effectedF, - numEffectedV, numEffectedE, numEffectedF, curLvl); + effectedV, effectedE, effectedF, + numEffectedV, numEffectedE, numEffectedF, curLvl); } for (i = 0; i < numEffectedV; i++) @@ -2698,15 +2701,15 @@ int ccgSubSurf_getNumFaces(const CCGSubSurf *ss) CCGVert *ccgSubSurf_getVert(CCGSubSurf *ss, CCGVertHDL v) { - return (CCGVert*) _ehash_lookup(ss->vMap, v); + return (CCGVert *) _ehash_lookup(ss->vMap, v); } CCGEdge *ccgSubSurf_getEdge(CCGSubSurf *ss, CCGEdgeHDL e) { - return (CCGEdge*) _ehash_lookup(ss->eMap, e); + return (CCGEdge *) _ehash_lookup(ss->eMap, e); } CCGFace *ccgSubSurf_getFace(CCGSubSurf *ss, CCGFaceHDL f) { - return (CCGFace*) _ehash_lookup(ss->fMap, f); + return (CCGFace *) _ehash_lookup(ss->fMap, f); } int ccgSubSurf_getSubdivisionLevels(const CCGSubSurf *ss) @@ -2719,7 +2722,7 @@ int ccgSubSurf_getEdgeSize(const CCGSubSurf *ss) } int ccgSubSurf_getEdgeLevelSize(const CCGSubSurf *ss, int level) { - if (level<1 || level > ss->subdivLevels) { + if (level < 1 || level > ss->subdivLevels) { return -1; } else { @@ -2732,7 +2735,7 @@ int ccgSubSurf_getGridSize(const CCGSubSurf *ss) } int ccgSubSurf_getGridLevelSize(const CCGSubSurf *ss, int level) { - if (level<1 || level > ss->subdivLevels) { + if (level < 1 || level > ss->subdivLevels) { return -1; } else { @@ -2750,7 +2753,7 @@ int ccgSubSurf_getVertAge(CCGSubSurf *ss, CCGVert *v) { if (ss->useAgeCounts) { byte *userData = ccgSubSurf_getVertUserData(ss, v); - return ss->currentAge - *((int*) &userData[ss->vertUserAgeOffset]); + return ss->currentAge - *((int *) &userData[ss->vertUserAgeOffset]); } else { return 0; @@ -2766,7 +2769,7 @@ int ccgSubSurf_getVertNumFaces(CCGVert *v) } CCGFace *ccgSubSurf_getVertFace(CCGVert *v, int index) { - if (index<0 || index>=v->numFaces) { + if (index < 0 || index >= v->numFaces) { return NULL; } else { @@ -2779,7 +2782,7 @@ int ccgSubSurf_getVertNumEdges(CCGVert *v) } CCGEdge *ccgSubSurf_getVertEdge(CCGVert *v, int index) { - if (index<0 || index>=v->numEdges) { + if (index < 0 || index >= v->numEdges) { return NULL; } else { @@ -2792,7 +2795,7 @@ void *ccgSubSurf_getVertData(CCGSubSurf *ss, CCGVert *v) } void *ccgSubSurf_getVertLevelData(CCGSubSurf *ss, CCGVert *v, int level) { - if (level<0 || level > ss->subdivLevels) { + if (level < 0 || level > ss->subdivLevels) { return NULL; } else { @@ -2810,7 +2813,7 @@ int ccgSubSurf_getEdgeAge(CCGSubSurf *ss, CCGEdge *e) { if (ss->useAgeCounts) { byte *userData = ccgSubSurf_getEdgeUserData(ss, e); - return ss->currentAge - *((int*) &userData[ss->edgeUserAgeOffset]); + return ss->currentAge - *((int *) &userData[ss->edgeUserAgeOffset]); } else { return 0; @@ -2819,7 +2822,7 @@ int ccgSubSurf_getEdgeAge(CCGSubSurf *ss, CCGEdge *e) void *ccgSubSurf_getEdgeUserData(CCGSubSurf *ss, CCGEdge *e) { return (EDGE_getLevelData(e) + - ss->meshIFC.vertDataSize * ccg_edgebase(ss->subdivLevels + 1)); + ss->meshIFC.vertDataSize * ccg_edgebase(ss->subdivLevels + 1)); } int ccgSubSurf_getEdgeNumFaces(CCGEdge *e) { @@ -2827,7 +2830,7 @@ int ccgSubSurf_getEdgeNumFaces(CCGEdge *e) } CCGFace *ccgSubSurf_getEdgeFace(CCGEdge *e, int index) { - if (index<0 || index>=e->numFaces) { + if (index < 0 || index >= e->numFaces) { return NULL; } else { @@ -2852,7 +2855,7 @@ void *ccgSubSurf_getEdgeData(CCGSubSurf *ss, CCGEdge *e, int x) } void *ccgSubSurf_getEdgeLevelData(CCGSubSurf *ss, CCGEdge *e, int x, int level) { - if (level<0 || level > ss->subdivLevels) { + if (level < 0 || level > ss->subdivLevels) { return NULL; } else { @@ -2874,7 +2877,7 @@ int ccgSubSurf_getFaceAge(CCGSubSurf *ss, CCGFace *f) { if (ss->useAgeCounts) { byte *userData = ccgSubSurf_getFaceUserData(ss, f); - return ss->currentAge - *((int*) &userData[ss->faceUserAgeOffset]); + return ss->currentAge - *((int *) &userData[ss->faceUserAgeOffset]); } else { return 0; @@ -2891,7 +2894,7 @@ int ccgSubSurf_getFaceNumVerts(CCGFace *f) } CCGVert *ccgSubSurf_getFaceVert(CCGFace *f, int index) { - if (index<0 || index>=f->numVerts) { + if (index < 0 || index >= f->numVerts) { return NULL; } else { @@ -2900,7 +2903,7 @@ CCGVert *ccgSubSurf_getFaceVert(CCGFace *f, int index) } CCGEdge *ccgSubSurf_getFaceEdge(CCGFace *f, int index) { - if (index<0 || index>=f->numVerts) { + if (index < 0 || index >= f->numVerts) { return NULL; } else { @@ -2943,66 +2946,66 @@ void *ccgSubSurf_getFaceGridData(CCGSubSurf *ss, CCGFace *f, int gridIndex, int CCGVertIterator *ccgSubSurf_getVertIterator(CCGSubSurf *ss) { - return (CCGVertIterator*) _ehashIterator_new(ss->vMap); + return (CCGVertIterator *) _ehashIterator_new(ss->vMap); } CCGEdgeIterator *ccgSubSurf_getEdgeIterator(CCGSubSurf *ss) { - return (CCGEdgeIterator*) _ehashIterator_new(ss->eMap); + return (CCGEdgeIterator *) _ehashIterator_new(ss->eMap); } CCGFaceIterator *ccgSubSurf_getFaceIterator(CCGSubSurf *ss) { - return (CCGFaceIterator*) _ehashIterator_new(ss->fMap); + return (CCGFaceIterator *) _ehashIterator_new(ss->fMap); } CCGVert *ccgVertIterator_getCurrent(CCGVertIterator *vi) { - return (CCGVert*) _ehashIterator_getCurrent((EHashIterator*) vi); + return (CCGVert *) _ehashIterator_getCurrent((EHashIterator *) vi); } int ccgVertIterator_isStopped(CCGVertIterator *vi) { - return _ehashIterator_isStopped((EHashIterator*) vi); + return _ehashIterator_isStopped((EHashIterator *) vi); } void ccgVertIterator_next(CCGVertIterator *vi) { - _ehashIterator_next((EHashIterator*) vi); + _ehashIterator_next((EHashIterator *) vi); } void ccgVertIterator_free(CCGVertIterator *vi) { - _ehashIterator_free((EHashIterator*) vi); + _ehashIterator_free((EHashIterator *) vi); } CCGEdge *ccgEdgeIterator_getCurrent(CCGEdgeIterator *vi) { - return (CCGEdge*) _ehashIterator_getCurrent((EHashIterator*) vi); + return (CCGEdge *) _ehashIterator_getCurrent((EHashIterator *) vi); } int ccgEdgeIterator_isStopped(CCGEdgeIterator *vi) { - return _ehashIterator_isStopped((EHashIterator*) vi); + return _ehashIterator_isStopped((EHashIterator *) vi); } void ccgEdgeIterator_next(CCGEdgeIterator *vi) { - _ehashIterator_next((EHashIterator*) vi); + _ehashIterator_next((EHashIterator *) vi); } void ccgEdgeIterator_free(CCGEdgeIterator *vi) { - _ehashIterator_free((EHashIterator*) vi); + _ehashIterator_free((EHashIterator *) vi); } CCGFace *ccgFaceIterator_getCurrent(CCGFaceIterator *vi) { - return (CCGFace*) _ehashIterator_getCurrent((EHashIterator*) vi); + return (CCGFace *) _ehashIterator_getCurrent((EHashIterator *) vi); } int ccgFaceIterator_isStopped(CCGFaceIterator *vi) { - return _ehashIterator_isStopped((EHashIterator*) vi); + return _ehashIterator_isStopped((EHashIterator *) vi); } void ccgFaceIterator_next(CCGFaceIterator *vi) { - _ehashIterator_next((EHashIterator*) vi); + _ehashIterator_next((EHashIterator *) vi); } void ccgFaceIterator_free(CCGFaceIterator *vi) { - _ehashIterator_free((EHashIterator*) vi); + _ehashIterator_free((EHashIterator *) vi); } /*** Extern API final vert/edge/face interface ***/ diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index fdbc45ebfb4..a4f7a9697bf 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -120,7 +120,7 @@ static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, CCGFlags fl int useAging = !!(flags & CCG_USE_AGING); int useArena = flags & CCG_USE_ARENA; - /* subdivLevels==0 is not allowed */ + /* subdivLevels==0 is not allowed */ subdivLevels = MAX2(subdivLevels, 1); if (prevSS) { @@ -128,7 +128,7 @@ static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, CCGFlags fl ccgSubSurf_getUseAgeCounts(prevSS, &oldUseAging, NULL, NULL, NULL); - if (oldUseAging!=useAging) { + if (oldUseAging != useAging) { ccgSubSurf_free(prevSS); } else { @@ -148,7 +148,7 @@ static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, CCGFlags fl if (useArena) { CCGAllocatorIFC allocatorIFC; - CCGAllocatorHDL allocator = BLI_memarena_new((1<<16), "subsurf arena"); + CCGAllocatorHDL allocator = BLI_memarena_new((1 << 16), "subsurf arena"); allocatorIFC.alloc = arena_alloc; allocatorIFC.realloc = arena_realloc; @@ -177,81 +177,81 @@ static int getEdgeIndex(CCGSubSurf *ss, CCGEdge *e, int x, int edgeSize) { CCGVert *v0 = ccgSubSurf_getEdgeVert0(e); CCGVert *v1 = ccgSubSurf_getEdgeVert1(e); - int v0idx = *((int*) ccgSubSurf_getVertUserData(ss, v0)); - int v1idx = *((int*) ccgSubSurf_getVertUserData(ss, v1)); - int edgeBase = *((int*) ccgSubSurf_getEdgeUserData(ss, e)); + int v0idx = *((int *) ccgSubSurf_getVertUserData(ss, v0)); + int v1idx = *((int *) ccgSubSurf_getVertUserData(ss, v1)); + int edgeBase = *((int *) ccgSubSurf_getEdgeUserData(ss, e)); - if (x==0) { + if (x == 0) { return v0idx; } - else if (x==edgeSize-1) { + else if (x == edgeSize - 1) { return v1idx; } else { - return edgeBase + x-1; + return edgeBase + x - 1; } } static int getFaceIndex(CCGSubSurf *ss, CCGFace *f, int S, int x, int y, int edgeSize, int gridSize) { - int faceBase = *((int*) ccgSubSurf_getFaceUserData(ss, f)); + int faceBase = *((int *) ccgSubSurf_getFaceUserData(ss, f)); int numVerts = ccgSubSurf_getFaceNumVerts(f); - if (x==gridSize-1 && y==gridSize-1) { + if (x == gridSize - 1 && y == gridSize - 1) { CCGVert *v = ccgSubSurf_getFaceVert(f, S); - return *((int*) ccgSubSurf_getVertUserData(ss, v)); + 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; + int edgeBase = *((int *) ccgSubSurf_getEdgeUserData(ss, e)); + if (v == ccgSubSurf_getEdgeVert0(e)) { + return edgeBase + (gridSize - 1 - y) - 1; } else { - return edgeBase + (edgeSize-2-1)-((gridSize-1-y)-1); + 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; + 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 { - return edgeBase + (edgeSize-2-1)-((gridSize-1-x)-1); + 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) { - S = (S+numVerts-1)%numVerts; - return faceBase + 1 + (gridSize-2)*S + (y-1); + else if (x == 0) { + S = (S + numVerts - 1) % numVerts; + return faceBase + 1 + (gridSize - 2) * S + (y - 1); } - else if (y==0) { - return faceBase + 1 + (gridSize-2)*S + (x-1); + else if (y == 0) { + return faceBase + 1 + (gridSize - 2) * S + (x - 1); } else { - return faceBase + 1 + (gridSize-2)*numVerts + S*(gridSize-2)*(gridSize-2) + (y-1)*(gridSize-2) + (x-1); + return faceBase + 1 + (gridSize - 2) * numVerts + S * (gridSize - 2) * (gridSize - 2) + (y - 1) * (gridSize - 2) + (x - 1); } } static void get_face_uv_map_vert(UvVertMap *vmap, struct MPoly *mpoly, struct MLoop *ml, int fi, CCGVertHDL *fverts) { UvMapVert *v, *nv; - int j, nverts= mpoly[fi].totloop; + int j, nverts = mpoly[fi].totloop; - for (j=0; jnext) { + for (j = 0; j < nverts; j++) { + for (nv = v = get_uv_map_vert(vmap, ml[j].v); v; v = v->next) { if (v->separate) - nv= v; + nv = v; if (v->f == fi) break; } - fverts[j]= SET_INT_IN_POINTER(mpoly[nv->f].loopstart + nv->tfindex); + fverts[j] = SET_INT_IN_POINTER(mpoly[nv->f].loopstart + nv->tfindex); } } @@ -266,31 +266,31 @@ static int ss_sync_from_uv(CCGSubSurf *ss, CCGSubSurf *origss, DerivedMesh *dm, UvMapVert *v; UvVertMap *vmap; float limit[2]; - CCGVertHDL *fverts= NULL; + CCGVertHDL *fverts = NULL; BLI_array_declare(fverts); EdgeHash *ehash; float creaseFactor = (float)ccgSubSurf_getSubdivisionLevels(ss); - float uv[3]= {0.0f, 0.0f, 0.0f}; /* only first 2 values are written into */ + float uv[3] = {0.0f, 0.0f, 0.0f}; /* only first 2 values are written into */ - limit[0]= limit[1]= STD_UV_CONNECT_LIMIT; - vmap= make_uv_vert_map(mpoly, mloop, mloopuv, totface, totvert, 0, limit); + limit[0] = limit[1] = STD_UV_CONNECT_LIMIT; + vmap = make_uv_vert_map(mpoly, mloop, mloopuv, totface, totvert, 0, limit); if (!vmap) return 0; ccgSubSurf_initFullSync(ss); /* create vertices */ - for (i=0; inext; v; v=v->next) + for (v = get_uv_map_vert(vmap, i)->next; v; v = v->next) if (v->separate) break; - seam = (v != NULL) || ((mvert+i)->flag & ME_VERT_MERGED); + seam = (v != NULL) || ((mvert + i)->flag & ME_VERT_MERGED); - for (v=get_uv_map_vert(vmap, i); v; v=v->next) { + for (v = get_uv_map_vert(vmap, i); v; v = v->next) { if (v->separate) { CCGVert *ssv; int loopid = mpoly[v->f].loopstart + v->tfindex; @@ -306,35 +306,35 @@ static int ss_sync_from_uv(CCGSubSurf *ss, CCGSubSurf *origss, DerivedMesh *dm, /* create edges */ ehash = BLI_edgehash_new(); - for (i=0; itotloop; - CCGFace *origf= ccgSubSurf_getFace(origss, SET_INT_IN_POINTER(i)); + for (i = 0; i < totface; i++) { + MPoly *mp = &((MPoly *) mpoly)[i]; + int nverts = mp->totloop; + CCGFace *origf = ccgSubSurf_getFace(origss, SET_INT_IN_POINTER(i)); /* unsigned int *fv = &mp->v1; */ - MLoop *ml= mloop + mp->loopstart; + MLoop *ml = mloop + mp->loopstart; BLI_array_empty(fverts); BLI_array_growitems(fverts, nverts); get_face_uv_map_vert(vmap, mpoly, ml, i, fverts); - for (j=0; jloopstart + j); + CCGEdge *e, *orige = ccgSubSurf_getFaceEdge(origf, j); + CCGEdgeHDL ehdl = SET_INT_IN_POINTER(mp->loopstart + j); float crease; - if ((mv0->flag&mv1->flag) & ME_VERT_MERGED) + if ((mv0->flag & mv1->flag) & ME_VERT_MERGED) crease = creaseFactor; else crease = ccgSubSurf_getEdgeCrease(orige); - ccgSubSurf_syncEdge(ss, ehdl, fverts[j], fverts[(j+1)%nverts], crease, &e); + ccgSubSurf_syncEdge(ss, ehdl, fverts[j], fverts[(j + 1) % nverts], crease, &e); BLI_edgehash_insert(ehash, v0, v1, NULL); } } @@ -343,10 +343,10 @@ static int ss_sync_from_uv(CCGSubSurf *ss, CCGSubSurf *origss, DerivedMesh *dm, BLI_edgehash_free(ehash, NULL); /* create faces */ - for (i=0; iloopstart]; - int nverts= mp->totloop; + MLoop *ml = &mloop[mp->loopstart]; + int nverts = mp->totloop; CCGFace *f; BLI_array_empty(fverts); @@ -396,7 +396,7 @@ static void set_subsurf_uv(CCGSubSurf *ss, DerivedMesh *dm, DerivedMesh *result, gridFaces = gridSize - 1; /* make a map from original faces to CCGFaces */ - faceMap = MEM_mallocN(totface*sizeof(*faceMap), "facemapuv"); + faceMap = MEM_mallocN(totface * sizeof(*faceMap), "facemapuv"); fi = ccgSubSurf_getFaceIterator(uvss); for (; !ccgFaceIterator_isStopped(fi); ccgFaceIterator_next(fi)) { @@ -406,22 +406,22 @@ static void set_subsurf_uv(CCGSubSurf *ss, DerivedMesh *dm, DerivedMesh *result, ccgFaceIterator_free(fi); /* load coordinates from uvss into tface */ - tf= tface; - mluv= mloopuv; + tf = tface; + mluv = mloopuv; for (index = 0; index < totface; index++) { CCGFace *f = faceMap[index]; int numVerts = ccgSubSurf_getFaceNumVerts(f); - for (S=0; Suv[0], a); @@ -466,41 +466,41 @@ static float *get_ss_weights(WeightTable *wtable, int gridCuts, int faceLen) float *w, w1, w2, w4, fac, fac2, fx, fy; if (wtable->len <= faceLen) { - void *tmp = MEM_callocN(sizeof(FaceVertWeightEntry)*(faceLen+1), "weight table alloc 2"); + void *tmp = MEM_callocN(sizeof(FaceVertWeightEntry) * (faceLen + 1), "weight table alloc 2"); if (wtable->len) { - memcpy(tmp, wtable->weight_table, sizeof(FaceVertWeightEntry)*wtable->len); + memcpy(tmp, wtable->weight_table, sizeof(FaceVertWeightEntry) * wtable->len); MEM_freeN(wtable->weight_table); } wtable->weight_table = tmp; - wtable->len = faceLen+1; + wtable->len = faceLen + 1; } if (!wtable->weight_table[faceLen].valid) { wtable->weight_table[faceLen].valid = 1; - wtable->weight_table[faceLen].w = w = MEM_callocN(sizeof(float)*faceLen*faceLen*(gridCuts+2)*(gridCuts+2), "weight table alloc"); + wtable->weight_table[faceLen].w = w = MEM_callocN(sizeof(float) * faceLen * faceLen * (gridCuts + 2) * (gridCuts + 2), "weight table alloc"); fac = 1.0f / (float)faceLen; - for (i=0; ilen; i++) { + for (i = 0; i < wtable->len; i++) { if (wtable->weight_table[i].valid) MEM_freeN(wtable->weight_table[i].w); } @@ -525,7 +525,7 @@ static void free_ss_weights(WeightTable *wtable) } static void ss_sync_from_derivedmesh(CCGSubSurf *ss, DerivedMesh *dm, - float (*vertexCos)[3], int useFlatSubdiv) + float (*vertexCos)[3], int useFlatSubdiv) { float creaseFactor = (float) ccgSubSurf_getSubdivisionLevels(ss); CCGVertHDL *fVerts = NULL; @@ -559,7 +559,7 @@ static void ss_sync_from_derivedmesh(CCGSubSurf *ss, DerivedMesh *dm, ccgSubSurf_syncVert(ss, SET_INT_IN_POINTER(i), mv->co, 0, &v); } - ((int*)ccgSubSurf_getVertUserData(ss, v))[1] = (index)? *index++: i; + ((int *)ccgSubSurf_getVertUserData(ss, v))[1] = (index) ? *index++ : i; } me = medge; @@ -569,24 +569,24 @@ static void ss_sync_from_derivedmesh(CCGSubSurf *ss, DerivedMesh *dm, float crease; crease = useFlatSubdiv ? creaseFactor : - me->crease * creaseFactor / 255.0f; + me->crease * creaseFactor / 255.0f; ccgSubSurf_syncEdge(ss, SET_INT_IN_POINTER(i), SET_INT_IN_POINTER(me->v1), - SET_INT_IN_POINTER(me->v2), crease, &e); + SET_INT_IN_POINTER(me->v2), crease, &e); - ((int*)ccgSubSurf_getEdgeUserData(ss, e))[1] = (index)? *index++: i; + ((int *)ccgSubSurf_getEdgeUserData(ss, e))[1] = (index) ? *index++ : i; } mp = mpoly; index = DM_get_poly_data_layer(dm, CD_ORIGINDEX); - for (i=0; inumPolyData; i++, mp++) { + for (i = 0; i < dm->numPolyData; i++, mp++) { CCGFace *f; BLI_array_empty(fVerts); BLI_array_growitems(fVerts, mp->totloop); ml = mloop + mp->loopstart; - for (j=0; jtotloop; j++, ml++) { + for (j = 0; j < mp->totloop; j++, ml++) { fVerts[j] = SET_INT_IN_POINTER(ml->v); } @@ -595,7 +595,7 @@ static void ss_sync_from_derivedmesh(CCGSubSurf *ss, DerivedMesh *dm, * 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, - fVerts, &f) == eCCGError_InvalidValue) { + fVerts, &f) == eCCGError_InvalidValue) { static int hasGivenError = 0; if (!hasGivenError) { @@ -608,7 +608,7 @@ static void ss_sync_from_derivedmesh(CCGSubSurf *ss, DerivedMesh *dm, return; } - ((int*)ccgSubSurf_getFaceUserData(ss, f))[1] = (index)? *index++: i; + ((int *)ccgSubSurf_getFaceUserData(ss, f))[1] = (index) ? *index++ : i; } ccgSubSurf_processSync(ss); @@ -620,22 +620,22 @@ static void ss_sync_from_derivedmesh(CCGSubSurf *ss, DerivedMesh *dm, static int ccgDM_getVertMapIndex(CCGSubSurf *ss, CCGVert *v) { - return ((int*) ccgSubSurf_getVertUserData(ss, v))[1]; + return ((int *) ccgSubSurf_getVertUserData(ss, v))[1]; } static int ccgDM_getEdgeMapIndex(CCGSubSurf *ss, CCGEdge *e) { - return ((int*) ccgSubSurf_getEdgeUserData(ss, e))[1]; + return ((int *) ccgSubSurf_getEdgeUserData(ss, e))[1]; } static int ccgDM_getFaceMapIndex(CCGSubSurf *ss, CCGFace *f) { - return ((int*) ccgSubSurf_getFaceUserData(ss, f))[1]; + return ((int *) ccgSubSurf_getFaceUserData(ss, f))[1]; } static void ccgDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3]) { - CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm; CCGSubSurf *ss = ccgdm->ss; CCGVertIterator *vi = ccgSubSurf_getVertIterator(ss); CCGEdgeIterator *ei = ccgSubSurf_getEdgeIterator(ss); @@ -657,7 +657,7 @@ static void ccgDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3]) CCGEdge *e = ccgEdgeIterator_getCurrent(ei); DMGridData *edgeData = ccgSubSurf_getEdgeDataArray(ss, e); - for (i=0; iss); } static int ccgDM_getNumEdges(DerivedMesh *dm) { - CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm; return ccgSubSurf_getNumFinalEdges(ccgdm->ss); } static int ccgDM_getNumTessFaces(DerivedMesh *dm) { - CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm; return ccgSubSurf_getNumFinalFaces(ccgdm->ss); } static int ccgDM_getNumLoops(DerivedMesh *dm) { - CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm; /* All subsurf faces are quads */ return 4 * ccgSubSurf_getNumFinalFaces(ccgdm->ss); @@ -710,7 +710,7 @@ static int ccgDM_getNumLoops(DerivedMesh *dm) static void ccgDM_getFinalVert(DerivedMesh *dm, int vertNum, MVert *mv) { - CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm; CCGSubSurf *ss = ccgdm->ss; DMGridData *vd; int i; @@ -814,7 +814,7 @@ static void ccgDM_getFinalVertNo(DerivedMesh *dm, int vertNum, float no_r[3]) static void ccgDM_getFinalEdge(DerivedMesh *dm, int edgeNum, MEdge *med) { - CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm; CCGSubSurf *ss = ccgdm->ss; int i; @@ -833,39 +833,39 @@ static void ccgDM_getFinalEdge(DerivedMesh *dm, int edgeNum, MEdge *med) /* code added in bmesh but works correctly without, commenting - campbell */ #if 0 - int lasti, previ; - i = lastface; - lasti = 0; - while (1) { - previ = i; - if (ccgdm->faceMap[i].startEdge >= edgeNum) { - i -= fabsf(i-lasti)/2.0f; - } - else if (ccgdm->faceMap[i].startEdge < edgeNum) { - i += fabsf(i-lasti)/2.0f; - } - else { - break; - } + int lasti, previ; + i = lastface; + lasti = 0; + while (1) { + previ = i; + if (ccgdm->faceMap[i].startEdge >= edgeNum) { + i -= fabsf(i - lasti) / 2.0f; + } + else if (ccgdm->faceMap[i].startEdge < edgeNum) { + i += fabsf(i - lasti) / 2.0f; + } + else { + break; + } - if (i < 0) { - i = 0; - break; - } + if (i < 0) { + i = 0; + break; + } - if (i > lastface) { - i = lastface; - break; + if (i > lastface) { + i = lastface; + break; - } + } - if (i == lasti) - break; + if (i == lasti) + break; - lasti = previ; - } + lasti = previ; + } - i = i > 0 ? i - 1 : i; + i = i > 0 ? i - 1 : i; #endif i = 0; @@ -885,7 +885,7 @@ static void ccgDM_getFinalEdge(DerivedMesh *dm, int edgeNum, MEdge *med) 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); + med->v2 = getFaceIndex(ss, f, grid, x + 1, 0, edgeSize, gridSize); } else { offset -= gridSideEdges; @@ -893,11 +893,11 @@ static void ccgDM_getFinalEdge(DerivedMesh *dm, int edgeNum, MEdge *med) y = (offset / 2) % gridSideEdges; 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); + med->v2 = getFaceIndex(ss, f, grid, x, y + 1, edgeSize, gridSize); } else { med->v1 = getFaceIndex(ss, f, grid, y, x, edgeSize, gridSize); - med->v2 = getFaceIndex(ss, f, grid, y+1, x, edgeSize, gridSize); + med->v2 = getFaceIndex(ss, f, grid, y + 1, x, edgeSize, gridSize); } } } @@ -918,12 +918,11 @@ static void ccgDM_getFinalEdge(DerivedMesh *dm, int edgeNum, MEdge *med) x = edgeNum - ccgdm->edgeMap[i].startEdge; med->v1 = getEdgeIndex(ss, e, x, edgeSize); - med->v2 = getEdgeIndex(ss, e, x+1, edgeSize); + med->v2 = getEdgeIndex(ss, e, x + 1, edgeSize); - edgeFlag = (ccgdm->edgeFlags)? &ccgdm->edgeFlags[i]: NULL; + edgeFlag = (ccgdm->edgeFlags) ? &ccgdm->edgeFlags[i] : NULL; if (edgeFlag) - flags |= (*edgeFlag & (ME_SEAM | ME_SHARP)) - | ME_EDGEDRAW | ME_EDGERENDER; + flags |= (*edgeFlag & (ME_SEAM | ME_SHARP)) | ME_EDGEDRAW | ME_EDGERENDER; else flags |= ME_EDGEDRAW | ME_EDGERENDER; @@ -933,7 +932,7 @@ static void ccgDM_getFinalEdge(DerivedMesh *dm, int edgeNum, MEdge *med) static void ccgDM_getFinalFace(DerivedMesh *dm, int faceNum, MFace *mf) { - CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm; CCGSubSurf *ss = ccgdm->ss; int gridSize = ccgSubSurf_getGridSize(ss); int edgeSize = ccgSubSurf_getEdgeSize(ss); @@ -963,10 +962,10 @@ static void ccgDM_getFinalFace(DerivedMesh *dm, int faceNum, MFace *mf) y = offset / gridSideEdges; x = offset % gridSideEdges; - mf->v1 = getFaceIndex(ss, f, grid, x+0, y+0, edgeSize, gridSize); - mf->v2 = getFaceIndex(ss, f, grid, x+0, y+1, edgeSize, gridSize); - mf->v3 = getFaceIndex(ss, f, grid, x+1, y+1, edgeSize, gridSize); - mf->v4 = getFaceIndex(ss, f, grid, x+1, y+0, edgeSize, gridSize); + mf->v1 = getFaceIndex(ss, f, grid, x + 0, y + 0, edgeSize, gridSize); + mf->v2 = getFaceIndex(ss, f, grid, x + 0, y + 1, edgeSize, gridSize); + 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) { mf->flag = faceFlags[i].flag; @@ -978,9 +977,9 @@ static void ccgDM_getFinalFace(DerivedMesh *dm, int faceNum, MFace *mf) /* Translate GridHidden into the ME_HIDE flag for MVerts. Assumes vertices are in the order output by ccgDM_copyFinalVertArray. */ void subsurf_copy_grid_hidden(DerivedMesh *dm, const MPoly *mpoly, - MVert *mvert, const MDisps *mdisps) + MVert *mvert, const MDisps *mdisps) { - CCGDerivedMesh *ccgdm = (CCGDerivedMesh*)dm; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm; CCGSubSurf *ss = ccgdm->ss; int level = ccgSubSurf_getSubdivisionLevels(ss); int gridSize = ccgSubSurf_getGridSize(ss); @@ -1004,7 +1003,7 @@ void subsurf_copy_grid_hidden(DerivedMesh *dm, const MPoly *mpoly, int vndx, offset; vndx = getFaceIndex(ss, f, j, x, y, edgeSize, gridSize); - offset = (y*factor) * hidden_gridsize + (x*factor); + offset = (y * factor) * hidden_gridsize + (x * factor); if (BLI_BITMAP_GET(md->hidden, offset)) mvert[vndx].flag |= ME_HIDE; } @@ -1015,7 +1014,7 @@ void subsurf_copy_grid_hidden(DerivedMesh *dm, const MPoly *mpoly, static void ccgDM_copyFinalVertArray(DerivedMesh *dm, MVert *mvert) { - CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm; CCGSubSurf *ss = ccgdm->ss; DMGridData *vd; int index; @@ -1029,14 +1028,14 @@ static void ccgDM_copyFinalVertArray(DerivedMesh *dm, MVert *mvert) CCGFace *f = ccgdm->faceMap[index].face; int x, y, S, numVerts = ccgSubSurf_getFaceNumVerts(f); - vd= ccgSubSurf_getFaceCenterData(f); + vd = ccgSubSurf_getFaceCenterData(f); copy_v3_v3(mvert[i].co, vd->co); 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++) { - vd= ccgSubSurf_getFaceGridEdgeData(ss, f, S, x); + 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); } @@ -1045,7 +1044,7 @@ static void ccgDM_copyFinalVertArray(DerivedMesh *dm, MVert *mvert) 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); + 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); } @@ -1059,7 +1058,7 @@ static void ccgDM_copyFinalVertArray(DerivedMesh *dm, MVert *mvert) int x; for (x = 1; x < edgeSize - 1; x++, i++) { - vd= ccgSubSurf_getEdgeData(ss, e, x); + vd = ccgSubSurf_getEdgeData(ss, e, x); copy_v3_v3(mvert[i].co, vd->co); /* This gives errors with -debug-fpe * the normals don't seem to be unit length. @@ -1074,7 +1073,7 @@ static void ccgDM_copyFinalVertArray(DerivedMesh *dm, MVert *mvert) for (index = 0; index < totvert; index++) { CCGVert *v = ccgdm->vertMap[index].vert; - vd= ccgSubSurf_getVertData(ss, v); + vd = ccgSubSurf_getVertData(ss, v); copy_v3_v3(mvert[i].co, vd->co); normal_float_to_short_v3(mvert[i].no, vd->no); i++; @@ -1083,7 +1082,7 @@ static void ccgDM_copyFinalVertArray(DerivedMesh *dm, MVert *mvert) static void ccgDM_copyFinalEdgeArray(DerivedMesh *dm, MEdge *medge) { - CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm; CCGSubSurf *ss = ccgdm->ss; int index; int totedge, totface; @@ -1116,18 +1115,18 @@ static void ccgDM_copyFinalEdgeArray(DerivedMesh *dm, MEdge *medge) if (ccgdm->drawInteriorEdges) med->flag = ME_EDGEDRAW | ME_EDGERENDER; med->v1 = getFaceIndex(ss, f, S, x, y, - edgeSize, gridSize); + edgeSize, gridSize); med->v2 = getFaceIndex(ss, f, S, x, y + 1, - edgeSize, gridSize); + edgeSize, gridSize); i++; med = &medge[i]; if (ccgdm->drawInteriorEdges) med->flag = ME_EDGEDRAW | ME_EDGERENDER; med->v1 = getFaceIndex(ss, f, S, y, x, - edgeSize, gridSize); + edgeSize, gridSize); med->v2 = getFaceIndex(ss, f, S, y + 1, x, - edgeSize, gridSize); + edgeSize, gridSize); i++; } } @@ -1146,7 +1145,7 @@ static void ccgDM_copyFinalEdgeArray(DerivedMesh *dm, MEdge *medge) if (edgeFlags) { if (edgeIdx != -1) { flags |= (edgeFlags[index] & (ME_SEAM | ME_SHARP)) - | ME_EDGEDRAW | ME_EDGERENDER; + | ME_EDGEDRAW | ME_EDGERENDER; } } else { @@ -1165,7 +1164,7 @@ static void ccgDM_copyFinalEdgeArray(DerivedMesh *dm, MEdge *medge) static void ccgDM_copyFinalFaceArray(DerivedMesh *dm, MFace *mface) { - CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm; CCGSubSurf *ss = ccgdm->ss; int index; int totface; @@ -1179,21 +1178,21 @@ static void ccgDM_copyFinalFaceArray(DerivedMesh *dm, MFace *mface) 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; + 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++) { MFace *mf = &mface[i]; mf->v1 = getFaceIndex(ss, f, S, x + 0, y + 0, - edgeSize, gridSize); + edgeSize, gridSize); mf->v2 = getFaceIndex(ss, f, S, x + 0, y + 1, - edgeSize, gridSize); + edgeSize, gridSize); mf->v3 = getFaceIndex(ss, f, S, x + 1, y + 1, - edgeSize, gridSize); + edgeSize, gridSize); mf->v4 = getFaceIndex(ss, f, S, x + 1, y + 0, - edgeSize, gridSize); + edgeSize, gridSize); mf->mat_nr = mat_nr; mf->flag = flag; @@ -1206,7 +1205,7 @@ static void ccgDM_copyFinalFaceArray(DerivedMesh *dm, MFace *mface) static void ccgDM_copyFinalLoopArray(DerivedMesh *dm, MLoop *mloop) { - CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm; CCGSubSurf *ss = ccgdm->ss; int index; int totface; @@ -1220,9 +1219,9 @@ static void ccgDM_copyFinalLoopArray(DerivedMesh *dm, MLoop *mloop) MEdge *medge; ccgdm->ehash = BLI_edgehash_new(); - medge = ccgdm->dm.getEdgeArray((DerivedMesh*)ccgdm); + medge = ccgdm->dm.getEdgeArray((DerivedMesh *)ccgdm); - for (i=0; idm.numEdgeData; i++) { + for (i = 0; i < ccgdm->dm.numEdgeData; i++) { BLI_edgehash_insert(ccgdm->ehash, medge[i].v1, medge[i].v2, SET_INT_IN_POINTER(i)); } } @@ -1241,14 +1240,14 @@ static void ccgDM_copyFinalLoopArray(DerivedMesh *dm, MLoop *mloop) int v1, v2, v3, v4; v1 = getFaceIndex(ss, f, S, x + 0, y + 0, - edgeSize, gridSize); + edgeSize, gridSize); v2 = getFaceIndex(ss, f, S, x + 0, y + 1, - edgeSize, gridSize); + edgeSize, gridSize); v3 = getFaceIndex(ss, f, S, x + 1, y + 1, - edgeSize, gridSize); + edgeSize, gridSize); v4 = getFaceIndex(ss, f, S, x + 1, y + 0, - edgeSize, gridSize); + edgeSize, gridSize); mv->v = v1; mv->e = GET_INT_FROM_POINTER(BLI_edgehash_lookup(ccgdm->ehash, v1, v2)); @@ -1273,7 +1272,7 @@ static void ccgDM_copyFinalLoopArray(DerivedMesh *dm, MLoop *mloop) static void ccgDM_copyFinalPolyArray(DerivedMesh *dm, MPoly *mpoly) { - CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm; CCGSubSurf *ss = ccgdm->ss; int index; int totface; @@ -1286,8 +1285,8 @@ static void ccgDM_copyFinalPolyArray(DerivedMesh *dm, MPoly *mpoly) 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; + 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++) { @@ -1309,7 +1308,7 @@ static void ccgDM_copyFinalPolyArray(DerivedMesh *dm, MPoly *mpoly) static void ccgdm_getVertCos(DerivedMesh *dm, float (*cos)[3]) { - CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm; CCGSubSurf *ss = ccgdm->ss; int edgeSize = ccgSubSurf_getEdgeSize(ss); int gridSize = ccgSubSurf_getGridSize(ss); @@ -1323,7 +1322,7 @@ static void ccgdm_getVertCos(DerivedMesh *dm, float (*cos)[3]) int index, totvert, totedge, totface; totvert = ccgSubSurf_getNumVerts(ss); - vertMap2 = MEM_mallocN(totvert*sizeof(*vertMap2), "vertmap"); + vertMap2 = MEM_mallocN(totvert * sizeof(*vertMap2), "vertmap"); vi = ccgSubSurf_getVertIterator(ss); for (; !ccgVertIterator_isStopped(vi); ccgVertIterator_next(vi)) { CCGVert *v = ccgVertIterator_getCurrent(vi); @@ -1333,16 +1332,16 @@ static void ccgdm_getVertCos(DerivedMesh *dm, float (*cos)[3]) ccgVertIterator_free(vi); totedge = ccgSubSurf_getNumEdges(ss); - edgeMap2 = MEM_mallocN(totedge*sizeof(*edgeMap2), "edgemap"); + edgeMap2 = MEM_mallocN(totedge * sizeof(*edgeMap2), "edgemap"); ei = ccgSubSurf_getEdgeIterator(ss); - for (i=0; !ccgEdgeIterator_isStopped(ei); i++,ccgEdgeIterator_next(ei)) { + for (i = 0; !ccgEdgeIterator_isStopped(ei); i++, ccgEdgeIterator_next(ei)) { CCGEdge *e = ccgEdgeIterator_getCurrent(ei); edgeMap2[GET_INT_FROM_POINTER(ccgSubSurf_getEdgeEdgeHandle(e))] = e; } totface = ccgSubSurf_getNumFaces(ss); - faceMap2 = MEM_mallocN(totface*sizeof(*faceMap2), "facemap"); + faceMap2 = MEM_mallocN(totface * sizeof(*faceMap2), "facemap"); fi = ccgSubSurf_getFaceIterator(ss); for (; !ccgFaceIterator_isStopped(fi); ccgFaceIterator_next(fi)) { CCGFace *f = ccgFaceIterator_getCurrent(fi); @@ -1352,37 +1351,37 @@ static void ccgdm_getVertCos(DerivedMesh *dm, float (*cos)[3]) ccgFaceIterator_free(fi); i = 0; - for (index=0; indexss); for (; !ccgVertIterator_isStopped(vi); ccgVertIterator_next(vi)) { @@ -1405,7 +1404,7 @@ static void ccgDM_foreachMappedVert( DMGridData *vd = ccgSubSurf_getVertData(ccgdm->ss, v); int index = ccgDM_getVertMapIndex(ccgdm->ss, v); - if (index!=-1) + if (index != -1) func(userData, index, vd->co, vd->no, NULL); } @@ -1413,11 +1412,11 @@ static void ccgDM_foreachMappedVert( } static void ccgDM_foreachMappedEdge( - DerivedMesh *dm, - void (*func)(void *userData, int index, const float v0co[3], const float v1co[3]), - void *userData) + DerivedMesh *dm, + void (*func)(void *userData, int index, const float v0co[3], const float v1co[3]), + void *userData) { - CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm; CCGSubSurf *ss = ccgdm->ss; CCGEdgeIterator *ei = ccgSubSurf_getEdgeIterator(ss); int i, edgeSize = ccgSubSurf_getEdgeSize(ss); @@ -1427,9 +1426,9 @@ static void ccgDM_foreachMappedEdge( DMGridData *edgeData = ccgSubSurf_getEdgeDataArray(ss, e); int index = ccgDM_getEdgeMapIndex(ss, e); - if (index!=-1) { - for (i=0; iss; int edgeSize = ccgSubSurf_getEdgeSize(ss); int gridSize = ccgSubSurf_getGridSize(ss); @@ -1459,7 +1458,7 @@ static void ccgDM_drawVerts(DerivedMesh *dm) CCGEdge *e = ccgEdgeIterator_getCurrent(ei); int x; - for (x=1; xpbvh, 1, (void***)&faces, &totface); + BLI_pbvh_get_grid_updates(ccgdm->pbvh, 1, (void ***)&faces, &totface); if (totface) { ccgSubSurf_updateFromFaces(ccgdm->ss, 0, faces, totface); ccgSubSurf_updateNormals(ccgdm->ss, faces, totface); @@ -1499,7 +1498,7 @@ static void ccgdm_pbvh_update(CCGDerivedMesh *ccgdm) static void ccgDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdges) { - CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm; CCGSubSurf *ss = ccgdm->ss; int i, j, edgeSize = ccgSubSurf_getEdgeSize(ss); int totedge = ccgSubSurf_getNumEdges(ss); @@ -1510,7 +1509,7 @@ static void ccgDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdge ccgSubSurf_getUseAgeCounts(ss, &useAging, NULL, NULL, NULL); - for (j=0; j< totedge; j++) { + for (j = 0; j < totedge; j++) { CCGEdge *e = ccgdm->edgeMap[j].edge; DMGridData *edgeData = ccgSubSurf_getEdgeDataArray(ss, e); @@ -1520,20 +1519,20 @@ static void ccgDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdge if (!drawAllEdges && ccgdm->edgeFlags && !(ccgdm->edgeFlags[j] & ME_EDGEDRAW)) continue; - if (useAging && !(G.f&G_BACKBUFSEL)) { - int ageCol = 255-ccgSubSurf_getEdgeAge(ss, e)*4; - glColor3ub(0, ageCol>0?ageCol:0, 0); + if (useAging && !(G.f & G_BACKBUFSEL)) { + int ageCol = 255 - ccgSubSurf_getEdgeAge(ss, e) * 4; + glColor3ub(0, ageCol > 0 ? ageCol : 0, 0); } glBegin(GL_LINE_STRIP); - for (i=0; ifaceMap[j].face; int S, x, y, numVerts = ccgSubSurf_getFaceNumVerts(f); - for (S=0; Sss; int totedge = ccgSubSurf_getNumEdges(ss); int i, j, edgeSize = ccgSubSurf_getEdgeSize(ss); - for (j=0; j< totedge; j++) { + for (j = 0; j < totedge; j++) { CCGEdge *e = ccgdm->edgeMap[j].edge; DMGridData *edgeData = ccgSubSurf_getEdgeDataArray(ss, e); if (!ccgSubSurf_getEdgeNumFaces(e)) { glBegin(GL_LINE_STRIP); - for (i=0; iss; int gridSize = ccgSubSurf_getGridSize(ss); DMFlagMat *faceFlags = ccgdm->faceFlags; - int step = (fast)? gridSize-1: 1; + int step = (fast) ? gridSize - 1 : 1; int i, totface = ccgSubSurf_getNumFaces(ss); int drawcurrent = 0, matnr = -1, shademodel = -1; @@ -1633,19 +1632,19 @@ static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes) int new_matnr, new_shademodel; if (faceFlags) { - new_shademodel = (faceFlags[index].flag & ME_SMOOTH)? GL_SMOOTH: GL_FLAT; - new_matnr= faceFlags[index].mat_nr; + new_shademodel = (faceFlags[index].flag & ME_SMOOTH) ? GL_SMOOTH : GL_FLAT; + new_matnr = faceFlags[index].mat_nr; } else { new_shademodel = GL_SMOOTH; - new_matnr= 0; + new_matnr = 0; } if (shademodel != new_shademodel || matnr != new_matnr) { - matnr= new_matnr; - shademodel= new_shademodel; + matnr = new_matnr; + shademodel = new_shademodel; - drawcurrent= setMaterial(matnr+1, NULL); + drawcurrent = setMaterial(matnr + 1, NULL); glShadeModel(shademodel); } @@ -1653,15 +1652,15 @@ static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes) if (!drawcurrent) continue; - for (S=0; Sno); glVertex3fv(a->co); @@ -1673,12 +1672,12 @@ static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes) } else { glBegin(GL_QUADS); - for (y=0; yss; GPUVertexAttribs gattribs; - DMVertexAttribs attribs= {{{NULL}}}; + DMVertexAttribs attribs = {{{NULL}}}; /* MTFace *tf = dm->getTessFaceDataArray(dm, CD_MTFACE); */ /* UNUSED */ int gridSize = ccgSubSurf_getGridSize(ss); int gridFaces = gridSize - 1; @@ -1716,25 +1715,25 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm, doDraw = 0; matnr = -1; -#define PASSATTRIB(dx, dy, vert) { \ - 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++) { \ - MTFace *tf = &attribs.tface[b].array[a]; \ - glVertexAttrib2fvARB(attribs.tface[b].glIndex, tf->uv[vert]); \ - } \ - 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) { \ - float *tang = attribs.tang.array[a*4 + vert]; \ - glVertexAttrib4fvARB(attribs.tang.glIndex, tang); \ - } \ +#define PASSATTRIB(dx, dy, vert) { \ + 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++) { \ + MTFace *tf = &attribs.tface[b].array[a]; \ + glVertexAttrib2fvARB(attribs.tface[b].glIndex, tf->uv[vert]); \ + } \ + 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) { \ + float *tang = attribs.tang.array[a * 4 + vert]; \ + glVertexAttrib4fvARB(attribs.tang.glIndex, tang); \ + } \ } totface = ccgSubSurf_getNumFaces(ss); @@ -1748,11 +1747,11 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm, if (faceFlags) { drawSmooth = (faceFlags[index].flag & ME_SMOOTH); - new_matnr= faceFlags[index].mat_nr + 1; + new_matnr = faceFlags[index].mat_nr + 1; } else { drawSmooth = 1; - new_matnr= 1; + new_matnr = 1; } if (new_matnr != matnr) { @@ -1762,22 +1761,23 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm, } if (!doDraw || (setDrawOptions && (origIndex != ORIGINDEX_NONE) && - (setDrawOptions(userData, origIndex) == DM_DRAW_OPTION_SKIP))) { - a += gridFaces*gridFaces*numVerts; + (setDrawOptions(userData, origIndex) == DM_DRAW_OPTION_SKIP))) + { + a += gridFaces * gridFaces * numVerts; continue; } - glShadeModel(drawSmooth? GL_SMOOTH: GL_FLAT); - for (S=0; Sno); @@ -1787,12 +1787,12 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm, glNormal3fv(vdb->no); glVertex3fv(vdb->co); - if (x != gridFaces-1) + if (x != gridFaces - 1) a++; } - vda = &faceGridData[(y+0)*gridSize + x]; - vdb = &faceGridData[(y+1)*gridSize + x]; + vda = &faceGridData[(y + 0) * gridSize + x]; + vdb = &faceGridData[(y + 1) * gridSize + x]; PASSATTRIB(0, 0, 3); glNormal3fv(vda->no); @@ -1809,12 +1809,12 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm, } else { glBegin(GL_QUADS); - for (y=0; ydrawMappedFacesGLSL(dm, setMaterial, NULL, NULL); } - /* Only used by non-editmesh types */ +/* Only used by non-editmesh types */ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, void (*setMaterial)(void *userData, int, void *attribs), int (*setFace)(void *userData, int index), void *userData) { - CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm; CCGSubSurf *ss = ccgdm->ss; GPUVertexAttribs gattribs; - DMVertexAttribs attribs= {{{NULL}}}; + DMVertexAttribs attribs = {{{NULL}}}; int gridSize = ccgSubSurf_getGridSize(ss); int gridFaces = gridSize - 1; int edgeSize = ccgSubSurf_getEdgeSize(ss); @@ -1860,31 +1860,31 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, void (*setMaterial)(void * matnr = -1; -#define PASSATTRIB(dx, dy, vert) { \ - if (attribs.totorco) { \ - index = getFaceIndex(ss, f, S, x+dx, y+dy, edgeSize, gridSize); \ - 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++) { \ - MTFace *tf = &attribs.tface[b].array[a]; \ - 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++) { \ - 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) { \ - float *tang = attribs.tang.array[a*4 + vert]; \ - glVertexAttrib4fvARB(attribs.tang.glIndex, tang); \ - } \ +#define PASSATTRIB(dx, dy, vert) { \ + if (attribs.totorco) { \ + index = getFaceIndex(ss, f, S, x + dx, y + dy, edgeSize, gridSize); \ + 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++) { \ + MTFace *tf = &attribs.tface[b].array[a]; \ + 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++) { \ + 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) { \ + float *tang = attribs.tang.array[a * 4 + vert]; \ + glVertexAttrib4fvARB(attribs.tang.glIndex, tang); \ + } \ } totface = ccgSubSurf_getNumFaces(ss); @@ -1899,11 +1899,11 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, void (*setMaterial)(void * /* get flags */ if (faceFlags) { drawSmooth = (faceFlags[index].flag & ME_SMOOTH); - new_matnr= faceFlags[index].mat_nr + 1; + new_matnr = faceFlags[index].mat_nr + 1; } else { drawSmooth = 1; - new_matnr= 1; + new_matnr = 1; } /* material */ @@ -1914,22 +1914,22 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, void (*setMaterial)(void * /* face hiding */ if ((setFace && (origIndex != ORIGINDEX_NONE) && !setFace(userData, origIndex))) { - a += gridFaces*gridFaces*numVerts; + a += gridFaces * gridFaces * numVerts; continue; } /* draw face*/ - glShadeModel(drawSmooth? GL_SMOOTH: GL_FLAT); - for (S=0; Sno); @@ -1939,12 +1939,12 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, void (*setMaterial)(void * glNormal3fv(vdb->no); glVertex3fv(vdb->co); - if (x != gridFaces-1) + if (x != gridFaces - 1) a++; } - vda = &faceGridData[(y+0)*gridSize + x]; - vdb = &faceGridData[(y+1)*gridSize + x]; + vda = &faceGridData[(y + 0) * gridSize + x]; + vdb = &faceGridData[(y + 1) * gridSize + x]; PASSATTRIB(0, 0, 3); glNormal3fv(vda->no); @@ -1961,12 +1961,12 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, void (*setMaterial)(void * } else { glBegin(GL_QUADS); - for (y=0; yss; MCol *mcol = dm->getTessFaceDataArray(dm, CD_PREVIEW_MCOL); MTFace *tf = DM_get_tessface_data_layer(dm, CD_MTFACE); @@ -2021,50 +2021,50 @@ static void ccgDM_drawFacesTex_common(DerivedMesh *dm, int S, x, y, numVerts = ccgSubSurf_getFaceNumVerts(f); int drawSmooth, index = ccgDM_getFaceMapIndex(ss, f); int origIndex = GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(f)); - unsigned char *cp= NULL; + unsigned char *cp = NULL; int mat_nr; if (faceFlags) { drawSmooth = (faceFlags[origIndex].flag & ME_SMOOTH); - mat_nr= faceFlags[origIndex].mat_nr; + mat_nr = faceFlags[origIndex].mat_nr; } else { drawSmooth = 1; - mat_nr= 0; + mat_nr = 0; } 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; + draw_option = (drawParamsMapped) ? drawParamsMapped(userData, index) : DM_DRAW_OPTION_NORMAL; else - draw_option= GPU_enable_material(mat_nr, NULL) ? DM_DRAW_OPTION_NORMAL : DM_DRAW_OPTION_SKIP; + draw_option = GPU_enable_material(mat_nr, NULL) ? DM_DRAW_OPTION_NORMAL : DM_DRAW_OPTION_SKIP; 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) - cp= (unsigned char*)mcol; - mcol += gridFaces*gridFaces*numVerts*4; + cp = (unsigned char *)mcol; + mcol += gridFaces * gridFaces * numVerts * 4; } - for (S=0; Suv[0]); if (cp) glColor3ub(cp[3], cp[2], cp[1]); @@ -2076,14 +2076,14 @@ static void ccgDM_drawFacesTex_common(DerivedMesh *dm, glNormal3fv(b->no); glVertex3fv(b->co); - if (x != gridFaces-1) { + if (x != gridFaces - 1) { if (tf) tf++; if (cp) cp += 16; } } - a = &faceGridData[(y+0)*gridSize + x]; - b = &faceGridData[(y+1)*gridSize + x]; + 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]); @@ -2104,12 +2104,12 @@ static void ccgDM_drawFacesTex_common(DerivedMesh *dm, else { glShadeModel(GL_FLAT); glBegin(GL_QUADS); - for (y=0; ynumTessFaceData; i++, mf++, tf++) { - if (!(mf->flag&ME_HIDE)) { + if (!(mf->flag & ME_HIDE)) { glVertex2fv(tf->uv[0]); glVertex2fv(tf->uv[1]); @@ -2190,14 +2190,14 @@ static void ccgDM_drawUVEdges(DerivedMesh *dm) } static void ccgDM_drawMappedFaces(DerivedMesh *dm, - DMSetDrawOptions setDrawOptions, - DMSetMaterial setMaterial, - DMCompareDrawOptions compareDrawOptions, - void *userData, DMDrawFlag flag) + DMSetDrawOptions setDrawOptions, + DMSetMaterial setMaterial, + DMCompareDrawOptions compareDrawOptions, + void *userData, DMDrawFlag flag) { - CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm; CCGSubSurf *ss = ccgdm->ss; - MCol *mcol= NULL; + MCol *mcol = NULL; int i, gridSize = ccgSubSurf_getGridSize(ss); DMFlagMat *faceFlags = ccgdm->faceFlags; int useColors = flag & DM_DRAW_USE_COLORS; @@ -2218,7 +2218,7 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm, int S, x, y, numVerts = ccgSubSurf_getFaceNumVerts(f); int drawSmooth, index = ccgDM_getFaceMapIndex(ss, f); int origIndex; - unsigned char *cp= NULL; + unsigned char *cp = NULL; origIndex = GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(f)); @@ -2227,37 +2227,37 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm, else drawSmooth = 1; if (mcol) { - cp= (unsigned char*)mcol; - mcol += gridFaces*gridFaces*numVerts*4; + cp = (unsigned char *)mcol; + mcol += gridFaces * gridFaces * numVerts * 4; } { - DMDrawOption draw_option= DM_DRAW_OPTION_NORMAL; + DMDrawOption draw_option = DM_DRAW_OPTION_NORMAL; if (index == ORIGINDEX_NONE) - draw_option= setMaterial(faceFlags ? faceFlags[origIndex].mat_nr + 1: 1, NULL); /* XXX, no faceFlags no material */ + draw_option = setMaterial(faceFlags ? faceFlags[origIndex].mat_nr + 1 : 1, NULL); /* XXX, no faceFlags no material */ else if (setDrawOptions) - draw_option= setDrawOptions(userData, index); + draw_option = setDrawOptions(userData, index); if (draw_option != DM_DRAW_OPTION_SKIP) { if (draw_option == DM_DRAW_OPTION_STIPPLE) { - glEnable(GL_POLYGON_STIPPLE); - glPolygonStipple(stipple_quarttone); + glEnable(GL_POLYGON_STIPPLE); + glPolygonStipple(stipple_quarttone); } /* no need to set shading mode to flat because * normals are already used to change shading */ glShadeModel(GL_SMOOTH); - for (S=0; Sno); @@ -2266,13 +2266,13 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm, glNormal3fv(b->no); glVertex3fv(b->co); - if (x != gridFaces-1) { + if (x != gridFaces - 1) { if (cp) cp += 16; } } - a = &faceGridData[(y+0)*gridSize + x]; - b = &faceGridData[(y+1)*gridSize + x]; + a = &faceGridData[(y + 0) * gridSize + x]; + b = &faceGridData[(y + 1) * gridSize + x]; if (cp) glColor3ub(cp[15], cp[14], cp[13]); glNormal3fv(a->no); @@ -2288,12 +2288,12 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm, } else { glBegin(GL_QUADS); - for (y=0; yss; CCGEdgeIterator *ei = ccgSubSurf_getEdgeIterator(ss); int i, useAging, edgeSize = ccgSubSurf_getEdgeSize(ss); @@ -2336,15 +2336,15 @@ static void ccgDM_drawMappedEdges(DerivedMesh *dm, int index = ccgDM_getEdgeMapIndex(ss, e); glBegin(GL_LINE_STRIP); - if (index!=-1 && (!setDrawOptions || (setDrawOptions(userData, index) != DM_DRAW_OPTION_SKIP))) { - if (useAging && !(G.f&G_BACKBUFSEL)) { - int ageCol = 255-ccgSubSurf_getEdgeAge(ss, e)*4; - glColor3ub(0, ageCol>0?ageCol:0, 0); + if (index != -1 && (!setDrawOptions || (setDrawOptions(userData, index) != DM_DRAW_OPTION_SKIP))) { + if (useAging && !(G.f & G_BACKBUFSEL)) { + int ageCol = 255 - ccgSubSurf_getEdgeAge(ss, e) * 4; + glColor3ub(0, ageCol > 0 ? ageCol : 0, 0); } - for (i=0; iss; CCGEdgeIterator *ei = ccgSubSurf_getEdgeIterator(ss); int i, useAging, edgeSize = ccgSubSurf_getEdgeSize(ss); @@ -2371,13 +2371,13 @@ static void ccgDM_drawMappedEdgesInterp(DerivedMesh *dm, int index = ccgDM_getEdgeMapIndex(ss, e); glBegin(GL_LINE_STRIP); - if (index!=-1 && (!setDrawOptions || (setDrawOptions(userData, index) != DM_DRAW_OPTION_SKIP))) { - for (i=0; i0?ageCol:0, 0); + if (useAging && !(G.f & G_BACKBUFSEL)) { + int ageCol = 255 - ccgSubSurf_getEdgeAge(ss, e) * 4; + glColor3ub(0, ageCol > 0 ? ageCol : 0, 0); } glVertex3fv(edgeData[i].co); @@ -2390,11 +2390,11 @@ static void ccgDM_drawMappedEdgesInterp(DerivedMesh *dm, } static void ccgDM_foreachMappedFaceCenter( - DerivedMesh *dm, - void (*func)(void *userData, int index, const float co[3], const float no[3]), - void *userData) + DerivedMesh *dm, + void (*func)(void *userData, int index, const float co[3], const float no[3]), + void *userData) { - CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm; CCGSubSurf *ss = ccgdm->ss; CCGFaceIterator *fi = ccgSubSurf_getFaceIterator(ss); @@ -2402,8 +2402,8 @@ static void ccgDM_foreachMappedFaceCenter( CCGFace *f = ccgFaceIterator_getCurrent(fi); int index = ccgDM_getFaceMapIndex(ss, f); - if (index!=-1) { - /* Face center data normal isn't updated atm. */ + if (index != -1) { + /* Face center data normal isn't updated atm. */ DMGridData *vd = ccgSubSurf_getFaceGridData(ss, f, 0, 0, 0); func(userData, index, vd->co, vd->no); @@ -2415,14 +2415,14 @@ static void ccgDM_foreachMappedFaceCenter( static void ccgDM_release(DerivedMesh *dm) { - CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm; if (DM_release(dm)) { /* Before freeing, need to update the displacement map */ if (ccgdm->multires.modified_flags) { /* Check that mmd still exists */ if (!ccgdm->multires.local_mmd && - BLI_findindex(&ccgdm->multires.ob->modifiers, ccgdm->multires.mmd) < 0) + BLI_findindex(&ccgdm->multires.ob->modifiers, ccgdm->multires.mmd) < 0) ccgdm->multires.mmd = NULL; if (ccgdm->multires.mmd) { @@ -2473,23 +2473,23 @@ 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); ME_MTEXFACE_CPY(texface, texpoly); mloopuv = CustomData_get_n(ldata, CD_MLOOPUV, loopstart, i); - for (j=0; j<4; j++, mloopuv++) { + for (j = 0; j < 4; j++, mloopuv++) { copy_v2_v2(texface->uv[j], mloopuv->uv); } } - 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); - for (j=0; j<4; j++, mloopcol++) { + for (j = 0; j < 4; j++, mloopcol++) { MESH_MLOOPCOL_TO_MCOL(mloopcol, &mcol[j]); } } @@ -2498,7 +2498,7 @@ static void ccg_loops_to_corners(CustomData *fdata, CustomData *ldata, mloopcol = CustomData_get(ldata, loopstart, CD_PREVIEW_MLOOPCOL); mcol = CustomData_get(fdata, findex, CD_PREVIEW_MCOL); - for (j=0; j<4; j++, mloopcol++) { + for (j = 0; j < 4; j++, mloopcol++) { MESH_MLOOPCOL_TO_MCOL(mloopcol, &mcol[j]); } } @@ -2508,7 +2508,7 @@ static void ccg_loops_to_corners(CustomData *fdata, CustomData *ldata, OrigSpaceLoop *lof; lof = CustomData_get(ldata, loopstart, CD_ORIGSPACE_MLOOP); - for (j=0; j<4; j++, lof++) { + for (j = 0; j < 4; j++, lof++) { copy_v2_v2(of->uv[j], lof->uv); } } @@ -2518,8 +2518,8 @@ static void *ccgDM_get_vert_data_layer(DerivedMesh *dm, int type) { if (type == CD_ORIGINDEX) { /* create origindex on demand to save memory */ - CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm; - CCGSubSurf *ss= ccgdm->ss; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm; + CCGSubSurf *ss = ccgdm->ss; int *origindex; int a, index, totnone, totorig; @@ -2530,16 +2530,16 @@ static void *ccgDM_get_vert_data_layer(DerivedMesh *dm, int type) } DM_add_vert_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL); - origindex= DM_get_vert_data_layer(dm, CD_ORIGINDEX); + origindex = DM_get_vert_data_layer(dm, CD_ORIGINDEX); totorig = ccgSubSurf_getNumVerts(ss); - totnone= dm->numVertData - totorig; + totnone = dm->numVertData - totorig; /* original vertices are at the end */ - for (a=0; avertMap[index].vert; origindex[a] = ccgDM_getVertMapIndex(ccgdm->ss, v); } @@ -2554,11 +2554,11 @@ static void *ccgDM_get_edge_data_layer(DerivedMesh *dm, int type) { if (type == CD_ORIGINDEX) { /* create origindex on demand to save memory */ - CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm; - CCGSubSurf *ss= ccgdm->ss; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm; + CCGSubSurf *ss = ccgdm->ss; int *origindex; int a, i, index, totnone, totorig, totedge; - int edgeSize= ccgSubSurf_getEdgeSize(ss); + int edgeSize = ccgSubSurf_getEdgeSize(ss); /* Avoid re-creation if the layer exists already */ origindex = DM_get_edge_data_layer(dm, CD_ORIGINDEX); @@ -2567,22 +2567,22 @@ static void *ccgDM_get_edge_data_layer(DerivedMesh *dm, int type) } DM_add_edge_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL); - origindex= DM_get_edge_data_layer(dm, CD_ORIGINDEX); + origindex = DM_get_edge_data_layer(dm, CD_ORIGINDEX); - totedge= ccgSubSurf_getNumEdges(ss); - totorig= totedge*(edgeSize - 1); - totnone= dm->numEdgeData - totorig; + totedge = ccgSubSurf_getNumEdges(ss); + totorig = totedge * (edgeSize - 1); + totnone = dm->numEdgeData - totorig; /* original edges are at the end */ - for (a=0; aedgeMap[index].edge; - int mapIndex= ccgDM_getEdgeMapIndex(ss, e); + 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++) - origindex[a]= mapIndex; + origindex[a] = mapIndex; } return origindex; @@ -2595,8 +2595,8 @@ static void *ccgDM_get_tessface_data_layer(DerivedMesh *dm, int type) { if (type == CD_ORIGINDEX) { /* create origindex on demand to save memory */ - CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm; - CCGSubSurf *ss= ccgdm->ss; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm; + CCGSubSurf *ss = ccgdm->ss; int *origindex; int a, i, index, totface; int gridFaces = ccgSubSurf_getGridSize(ss) - 1; @@ -2608,17 +2608,17 @@ static void *ccgDM_get_tessface_data_layer(DerivedMesh *dm, int type) } DM_add_tessface_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL); - origindex= DM_get_tessface_data_layer(dm, CD_ORIGINDEX); + origindex = DM_get_tessface_data_layer(dm, CD_ORIGINDEX); - totface= ccgSubSurf_getNumFaces(ss); + totface = ccgSubSurf_getNumFaces(ss); - for (a=0, index=0; indexfaceMap[index].face; int numVerts = ccgSubSurf_getFaceNumVerts(f); int mapIndex = ccgDM_getFaceMapIndex(ss, f); - for (i=0; iss); - numGrids= 0; + numFaces = ccgSubSurf_getNumFaces(ccgdm->ss); + numGrids = 0; - for (index=0; indexfaceMap[index].face; numGrids += ccgSubSurf_getFaceNumVerts(f); } @@ -2675,7 +2675,7 @@ static int ccgDM_getNumGrids(DerivedMesh *dm) static int ccgDM_getGridSize(DerivedMesh *dm) { - CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm; return ccgSubSurf_getGridSize(ccgdm->ss); } @@ -2683,7 +2683,7 @@ static int ccgdm_adjacent_grid(int *gridOffset, CCGFace *f, int S, int offset) { CCGFace *adjf; CCGEdge *e; - int i, j= 0, numFaces, fIndex, numEdges= 0; + int i, j = 0, numFaces, fIndex, numEdges = 0; e = ccgSubSurf_getFaceEdge(f, S); numFaces = ccgSubSurf_getEdgeNumFaces(e); @@ -2710,13 +2710,13 @@ static int ccgdm_adjacent_grid(int *gridOffset, CCGFace *f, int S, int offset) fIndex = GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(adjf)); - return gridOffset[fIndex] + (j + offset)%numEdges; + return gridOffset[fIndex] + (j + offset) % numEdges; } static void ccgdm_create_grids(DerivedMesh *dm) { - CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm; - CCGSubSurf *ss= ccgdm->ss; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm; + CCGSubSurf *ss = ccgdm->ss; DMGridData **gridData; DMGridAdjacency *gridAdjacency, *adj; DMFlagMat *gridFlagMats; @@ -2732,7 +2732,7 @@ static void ccgdm_create_grids(DerivedMesh *dm) /*gridSize = ccgDM_getGridSize(dm);*/ /*UNUSED*/ /* compute offset into grid array for each face */ - gridOffset = MEM_mallocN(sizeof(int)*numFaces, "ccgdm.gridOffset"); + gridOffset = MEM_mallocN(sizeof(int) * numFaces, "ccgdm.gridOffset"); for (gIndex = 0, index = 0; index < numFaces; index++) { CCGFace *f = ccgdm->faceMap[index].face; @@ -2743,12 +2743,12 @@ static void ccgdm_create_grids(DerivedMesh *dm) } /* compute grid data */ - gridData = MEM_mallocN(sizeof(DMGridData*)*numGrids, "ccgdm.gridData"); - gridAdjacency = MEM_mallocN(sizeof(DMGridAdjacency)*numGrids, "ccgdm.gridAdjacency"); - gridFaces = MEM_mallocN(sizeof(CCGFace*)*numGrids, "ccgdm.gridFaces"); - gridFlagMats = MEM_mallocN(sizeof(DMFlagMat)*numGrids, "ccgdm.gridFlagMats"); + gridData = MEM_mallocN(sizeof(DMGridData *) * numGrids, "ccgdm.gridData"); + gridAdjacency = MEM_mallocN(sizeof(DMGridAdjacency) * numGrids, "ccgdm.gridAdjacency"); + gridFaces = MEM_mallocN(sizeof(CCGFace *) * numGrids, "ccgdm.gridFaces"); + gridFlagMats = MEM_mallocN(sizeof(DMFlagMat) * numGrids, "ccgdm.gridFlagMats"); - ccgdm->gridHidden = MEM_callocN(sizeof(BLI_bitmap)*numGrids, "ccgdm.gridHidden"); + ccgdm->gridHidden = MEM_callocN(sizeof(BLI_bitmap) * numGrids, "ccgdm.gridHidden"); for (gIndex = 0, index = 0; index < numFaces; index++) { CCGFace *f = ccgdm->faceMap[index].face; @@ -2784,7 +2784,7 @@ static void ccgdm_create_grids(DerivedMesh *dm) static DMGridData **ccgDM_getGridData(DerivedMesh *dm) { - CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm; ccgdm_create_grids(dm); return ccgdm->gridData; @@ -2792,7 +2792,7 @@ static DMGridData **ccgDM_getGridData(DerivedMesh *dm) static DMGridAdjacency *ccgDM_getGridAdjacency(DerivedMesh *dm) { - CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm; ccgdm_create_grids(dm); return ccgdm->gridAdjacency; @@ -2800,7 +2800,7 @@ static DMGridAdjacency *ccgDM_getGridAdjacency(DerivedMesh *dm) static int *ccgDM_getGridOffset(DerivedMesh *dm) { - CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm; ccgdm_create_grids(dm); return ccgdm->gridOffset; @@ -2808,7 +2808,7 @@ static int *ccgDM_getGridOffset(DerivedMesh *dm) static DMFlagMat *ccgDM_getGridFlagMats(DerivedMesh *dm) { - CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm; ccgdm_create_grids(dm); return ccgdm->gridFlagMats; @@ -2816,7 +2816,7 @@ static DMFlagMat *ccgDM_getGridFlagMats(DerivedMesh *dm) static BLI_bitmap *ccgDM_getGridHidden(DerivedMesh *dm) { - CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm; ccgdm_create_grids(dm); return ccgdm->gridHidden; @@ -2824,10 +2824,10 @@ static BLI_bitmap *ccgDM_getGridHidden(DerivedMesh *dm) static const MeshElemMap *ccgDM_getPolyMap(Object *ob, DerivedMesh *dm) { - CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm; if (!ccgdm->multires.mmd && !ccgdm->pmap && ob->type == OB_MESH) { - Mesh *me= ob->data; + Mesh *me = ob->data; create_vert_poly_map(&ccgdm->pmap, &ccgdm->pmap_mem, me->mpoly, me->mloop, @@ -2839,7 +2839,7 @@ static const MeshElemMap *ccgDM_getPolyMap(Object *ob, DerivedMesh *dm) static int ccgDM_use_grid_pbvh(CCGDerivedMesh *ccgdm) { - MultiresModifierData *mmd= ccgdm->multires.mmd; + MultiresModifierData *mmd = ccgdm->multires.mmd; /* both of multires and subsurf modifiers are CCG, but * grids should only be used when sculpting on multires */ @@ -2851,18 +2851,18 @@ static int ccgDM_use_grid_pbvh(CCGDerivedMesh *ccgdm) static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm) { - CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm; int gridSize, numGrids, grid_pbvh; if (!ob) { - ccgdm->pbvh= NULL; + ccgdm->pbvh = NULL; return NULL; } if (!ob->sculpt) return NULL; - grid_pbvh= ccgDM_use_grid_pbvh(ccgdm); + grid_pbvh = ccgDM_use_grid_pbvh(ccgdm); if (ob->sculpt->pbvh) { if (grid_pbvh) { @@ -2871,7 +2871,7 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm) * when the ccgdm gets remade, the assumption is that the topology * does not change. */ ccgdm_create_grids(dm); - BLI_pbvh_grids_update(ob->sculpt->pbvh, ccgdm->gridData, ccgdm->gridAdjacency, (void**)ccgdm->gridFaces); + BLI_pbvh_grids_update(ob->sculpt->pbvh, ccgdm->gridData, ccgdm->gridAdjacency, (void **)ccgdm->gridFaces); } ccgdm->pbvh = ob->sculpt->pbvh; @@ -2889,16 +2889,16 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm) gridSize = ccgDM_getGridSize(dm); numGrids = ccgDM_getNumGrids(dm); - ob->sculpt->pbvh= ccgdm->pbvh = BLI_pbvh_new(); + 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); + numGrids, gridSize, (void **)ccgdm->gridFaces, ccgdm->gridFlagMats, ccgdm->gridHidden); } else if (ob->type == OB_MESH) { - Mesh *me= ob->data; - ob->sculpt->pbvh= ccgdm->pbvh = BLI_pbvh_new(); + 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 */ BLI_pbvh_build_mesh(ccgdm->pbvh, me->mface, me->mvert, - me->totface, me->totvert); + me->totface, me->totvert); } return ccgdm->pbvh; @@ -2915,9 +2915,9 @@ static void ccgDM_calcNormals(DerivedMesh *UNUSED(dm)) } static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, - int drawInteriorEdges, - int useSubsurfUv, - DerivedMesh *dm) + int drawInteriorEdges, + int useSubsurfUv, + DerivedMesh *dm) { CCGDerivedMesh *ccgdm = MEM_callocN(sizeof(*ccgdm), "ccgdm"); CCGVertIterator *vi; @@ -2949,14 +2949,14 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, MPoly *mpoly = NULL; DM_from_template(&ccgdm->dm, dm, DM_TYPE_CCGDM, - ccgSubSurf_getNumFinalVerts(ss), - ccgSubSurf_getNumFinalEdges(ss), - ccgSubSurf_getNumFinalFaces(ss), - ccgSubSurf_getNumFinalFaces(ss)*4, - ccgSubSurf_getNumFinalFaces(ss)); + ccgSubSurf_getNumFinalVerts(ss), + ccgSubSurf_getNumFinalEdges(ss), + ccgSubSurf_getNumFinalFaces(ss), + ccgSubSurf_getNumFinalFaces(ss) * 4, + ccgSubSurf_getNumFinalFaces(ss)); CustomData_free_layer_active(&ccgdm->dm.polyData, CD_NORMAL, - ccgdm->dm.numPolyData); + ccgdm->dm.numPolyData); numTex = CustomData_number_of_layers(&ccgdm->dm.loopData, CD_MLOOPUV); numCol = CustomData_number_of_layers(&ccgdm->dm.loopData, CD_MLOOPCOL); @@ -2964,10 +2964,10 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, hasOrigSpace = CustomData_has_layer(&ccgdm->dm.loopData, CD_ORIGSPACE_MLOOP); if ( - (numTex && CustomData_number_of_layers(&ccgdm->dm.faceData, CD_MTFACE) != numTex) || - (numCol && CustomData_number_of_layers(&ccgdm->dm.faceData, CD_MCOL) != numCol) || - (hasPCol && !CustomData_has_layer(&ccgdm->dm.faceData, CD_PREVIEW_MCOL)) || - (hasOrigSpace && !CustomData_has_layer(&ccgdm->dm.faceData, CD_ORIGSPACE)) ) + (numTex && CustomData_number_of_layers(&ccgdm->dm.faceData, CD_MTFACE) != numTex) || + (numCol && CustomData_number_of_layers(&ccgdm->dm.faceData, CD_MCOL) != numCol) || + (hasPCol && !CustomData_has_layer(&ccgdm->dm.faceData, CD_PREVIEW_MCOL)) || + (hasOrigSpace && !CustomData_has_layer(&ccgdm->dm.faceData, CD_ORIGSPACE)) ) { CustomData_from_bmeshpoly(&ccgdm->dm.faceData, &ccgdm->dm.polyData, @@ -3080,7 +3080,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, } ccgFaceIterator_free(fi); - ccgdm->reverseFaceMap = MEM_callocN(sizeof(int)*ccgSubSurf_getNumFinalFaces(ss), "reverseFaceMap"); + ccgdm->reverseFaceMap = MEM_callocN(sizeof(int) * ccgSubSurf_getNumFinalFaces(ss), "reverseFaceMap"); edgeSize = ccgSubSurf_getEdgeSize(ss); gridSize = ccgSubSurf_getGridSize(ss); @@ -3102,8 +3102,8 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, base_polyOrigIndex = CustomData_get_layer(&dm->polyData, CD_ORIGINDEX); /*CDDM hack*/ - edgeFlags = ccgdm->edgeFlags = MEM_callocN(sizeof(short)*totedge, "edgeFlags"); - faceFlags = ccgdm->faceFlags = MEM_callocN(sizeof(DMFlagMat)*totface, "faceFlags"); + edgeFlags = ccgdm->edgeFlags = MEM_callocN(sizeof(short) * totedge, "edgeFlags"); + faceFlags = ccgdm->faceFlags = MEM_callocN(sizeof(DMFlagMat) * totface, "faceFlags"); vertOrigIndex = DM_get_vert_data_layer(&ccgdm->dm, CD_ORIGINDEX); /*edgeOrigIndex = DM_get_edge_data_layer(&ccgdm->dm, CD_ORIGINDEX);*/ @@ -3128,7 +3128,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, int numVerts = ccgSubSurf_getFaceNumVerts(f); int numFinalEdges = numVerts * (gridSideEdges + gridInternalEdges); int origIndex = GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(f)); - int g2_wid = gridCuts+2; + int g2_wid = gridCuts + 2; float *w2; int s, x, y; @@ -3145,7 +3145,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, faceFlags++; /* set the face base vert */ - *((int*)ccgSubSurf_getFaceUserData(ss, f)) = vertNum; + *((int *)ccgSubSurf_getFaceUserData(ss, f)) = vertNum; BLI_array_empty(loopidx); BLI_array_growitems(loopidx, numVerts); @@ -3175,9 +3175,9 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, /*interpolate per-vert data*/ for (s = 0; s < numVerts; s++) { for (x = 1; x < gridFaces; x++) { - w2 = w + s*numVerts*g2_wid*g2_wid + x*numVerts; + w2 = w + s * numVerts * g2_wid * g2_wid + x * numVerts; DM_interp_vert_data(dm, &ccgdm->dm, vertidx, w2, - numVerts, vertNum); + numVerts, vertNum); if (vertOrigIndex) { *vertOrigIndex = ORIGINDEX_NONE; @@ -3192,9 +3192,9 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, 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; + w2 = w + s * numVerts * g2_wid * g2_wid + (y * g2_wid + x) * numVerts; DM_interp_vert_data(dm, &ccgdm->dm, vertidx, w2, - numVerts, vertNum); + numVerts, vertNum); if (vertOrigIndex) { *vertOrigIndex = ORIGINDEX_NONE; @@ -3209,29 +3209,29 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, if (has_edge_origindex) { for (i = 0; i < numFinalEdges; ++i) *(int *)DM_get_edge_data(&ccgdm->dm, edgeNum + i, - CD_ORIGINDEX) = ORIGINDEX_NONE; + CD_ORIGINDEX) = ORIGINDEX_NONE; } - for (s=0; sloopData, &ccgdm->dm.loopData, loopidx, w2, NULL, numVerts, loopindex2); loopindex2++; - w2 = w + s*numVerts*g2_wid*g2_wid + ((y+1)*g2_wid+(x))*numVerts; + w2 = w + s * numVerts * g2_wid * g2_wid + ((y + 1) * g2_wid + (x)) * numVerts; CustomData_interp(&dm->loopData, &ccgdm->dm.loopData, loopidx, w2, NULL, numVerts, loopindex2); loopindex2++; - w2 = w + s*numVerts*g2_wid*g2_wid + ((y+1)*g2_wid+(x+1))*numVerts; + w2 = w + s * numVerts * g2_wid * g2_wid + ((y + 1) * g2_wid + (x + 1)) * numVerts; CustomData_interp(&dm->loopData, &ccgdm->dm.loopData, loopidx, w2, NULL, numVerts, loopindex2); loopindex2++; - w2 = w + s*numVerts*g2_wid*g2_wid + ((y)*g2_wid+(x+1))*numVerts; + w2 = w + s * numVerts * g2_wid * g2_wid + ((y) * g2_wid + (x + 1)) * numVerts; CustomData_interp(&dm->loopData, &ccgdm->dm.loopData, loopidx, w2, NULL, numVerts, loopindex2); loopindex2++; @@ -3241,7 +3241,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, /*generate tessellated face data used for drawing*/ ccg_loops_to_corners(&ccgdm->dm.faceData, &ccgdm->dm.loopData, - &ccgdm->dm.polyData, loopindex2-4, faceNum, faceNum, + &ccgdm->dm.polyData, loopindex2 - 4, faceNum, faceNum, numTex, numCol, hasPCol, hasOrigSpace); /*set original index data*/ @@ -3288,7 +3288,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, edgeFlags[edgeIdx] = medge[edgeIdx].flag; /* set the edge base vert */ - *((int*)ccgSubSurf_getEdgeUserData(ss, e)) = vertNum; + *((int *)ccgSubSurf_getEdgeUserData(ss, e)) = vertNum; for (x = 1; x < edgeSize - 1; x++) { float w[2]; @@ -3304,8 +3304,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, for (i = 0; i < numFinalEdges; ++i) { if (has_edge_origindex) { - *(int *)DM_get_edge_data(&ccgdm->dm, edgeNum + i, - CD_ORIGINDEX) = mapIndex; + *(int *)DM_get_edge_data(&ccgdm->dm, edgeNum + i, CD_ORIGINDEX) = mapIndex; } } @@ -3318,7 +3317,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, int numlayer = CustomData_number_of_layers(ldata, CD_MLOOPUV); int dmnumlayer = CustomData_number_of_layers(dmldata, CD_MLOOPUV); - for (i=0; idm, i); } @@ -3332,7 +3331,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, ccgdm->vertMap[index].startVert = vertNum; /* set the vert base vert */ - *((int*) ccgSubSurf_getVertUserData(ss, v)) = vertNum; + *((int *) ccgSubSurf_getVertUserData(ss, v)) = vertNum; DM_copy_vert_data(dm, &ccgdm->dm, vertIdx, vertNum, 1); @@ -3362,10 +3361,10 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, /***/ struct DerivedMesh *subsurf_make_derived_from_derived( - struct DerivedMesh *dm, - struct SubsurfModifierData *smd, - int useRenderParams, float (*vertCos)[3], - int isFinalCalc, int forEditMode, int inEditMode) + struct DerivedMesh *dm, + struct SubsurfModifierData *smd, + int useRenderParams, float (*vertCos)[3], + int isFinalCalc, int forEditMode, int inEditMode) { int useSimple = smd->subdivType == ME_SIMPLE_SUBSURF; CCGFlags useAging = smd->flags & eSubsurfModifierFlag_DebugIncr ? CCG_USE_AGING : 0; @@ -3374,35 +3373,35 @@ struct DerivedMesh *subsurf_make_derived_from_derived( CCGDerivedMesh *result; if (forEditMode) { - int levels= (smd->modifier.scene)? get_render_subsurf_level(&smd->modifier.scene->r, smd->levels): smd->levels; + 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); + smd->emCache = _getSubSurf(smd->emCache, levels, useAging | CCG_CALC_NORMALS); ss_sync_from_derivedmesh(smd->emCache, dm, vertCos, useSimple); result = getCCGDerivedMesh(smd->emCache, - drawInteriorEdges, - useSubsurfUv, dm); + drawInteriorEdges, + useSubsurfUv, dm); } 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; + int levels = (smd->modifier.scene) ? get_render_subsurf_level(&smd->modifier.scene->r, smd->renderLevels) : smd->renderLevels; if (levels == 0) return dm; - ss = _getSubSurf(NULL, levels, CCG_USE_ARENA|CCG_CALC_NORMALS); + ss = _getSubSurf(NULL, levels, CCG_USE_ARENA | CCG_CALC_NORMALS); ss_sync_from_derivedmesh(ss, dm, vertCos, useSimple); result = getCCGDerivedMesh(ss, - drawInteriorEdges, useSubsurfUv, dm); + drawInteriorEdges, useSubsurfUv, dm); result->freeSS = 1; } else { int useIncremental = (smd->flags & eSubsurfModifierFlag_Incremental); - int levels= (smd->modifier.scene)? get_render_subsurf_level(&smd->modifier.scene->r, smd->levels): smd->levels; + int levels = (smd->modifier.scene) ? get_render_subsurf_level(&smd->modifier.scene->r, smd->levels) : smd->levels; CCGSubSurf *ss; /* It is quite possible there is a much better place to do this. It @@ -3422,13 +3421,13 @@ struct DerivedMesh *subsurf_make_derived_from_derived( } if (useIncremental && isFinalCalc) { - smd->mCache = ss = _getSubSurf(smd->mCache, levels, useAging|CCG_CALC_NORMALS); + smd->mCache = ss = _getSubSurf(smd->mCache, levels, useAging | CCG_CALC_NORMALS); ss_sync_from_derivedmesh(ss, dm, vertCos, useSimple); result = getCCGDerivedMesh(smd->mCache, - drawInteriorEdges, - useSubsurfUv, dm); + drawInteriorEdges, + useSubsurfUv, dm); } else { if (smd->mCache && isFinalCalc) { @@ -3436,7 +3435,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived( smd->mCache = NULL; } - ss = _getSubSurf(NULL, levels, CCG_USE_ARENA|CCG_CALC_NORMALS); + ss = _getSubSurf(NULL, levels, CCG_USE_ARENA | CCG_CALC_NORMALS); ss_sync_from_derivedmesh(ss, dm, vertCos, useSimple); result = getCCGDerivedMesh(ss, drawInteriorEdges, useSubsurfUv, dm); @@ -3448,7 +3447,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived( } } - return (DerivedMesh*)result; + return (DerivedMesh *)result; } void subsurf_calculate_limit_positions(Mesh *me, float (*positions_r)[3]) @@ -3474,14 +3473,14 @@ void subsurf_calculate_limit_positions(Mesh *me, float (*positions_r)[3]) float *co; int i; - edge_sum[0]= edge_sum[1]= edge_sum[2]= 0.0; - face_sum[0]= face_sum[1]= face_sum[2]= 0.0; + edge_sum[0] = edge_sum[1] = edge_sum[2] = 0.0; + face_sum[0] = face_sum[1] = face_sum[2] = 0.0; - for (i=0; i Date: Sun, 22 Apr 2012 00:27:38 +0000 Subject: - fix memory leak in mesh_strip_loose_polysloops(), occurred during 3ds import. - updating normals in py/api's mesh.transform() wasn't working and gave annoying print, disable this, script authors can call calc_normals explicitly if they need. --- source/blender/blenkernel/intern/mesh.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index b80b15e57f3..af24240bf4a 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1058,7 +1058,7 @@ void mesh_strip_loose_polysloops(Mesh *me) MLoop *l; int a, b; /* New loops idx! */ - int *new_idx = MEM_mallocN(sizeof(int) * me->totloop, "strip_loose_polysloops old2new idx mapping for polys."); + int *new_idx = MEM_mallocN(sizeof(int) * me->totloop, __func__); for (a = b = 0, p = me->mpoly; a < me->totpoly; a++, p++) { int invalid = FALSE; @@ -1119,6 +1119,8 @@ void mesh_strip_loose_polysloops(Mesh *me) for (a = 0, p = me->mpoly; a < me->totpoly; a++, p++) { p->loopstart = new_idx[p->loopstart]; } + + MEM_freeN(new_idx); } void mesh_strip_loose_edges(Mesh *me) -- cgit v1.2.3 From ac5058b281b859917efbf4cf028767094fab7144 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 22 Apr 2012 03:07:21 +0000 Subject: subsurf - avoid 'for' loop finding the edge index in a face multiple times when calling _face_getIFCoEdge. add asset so passing wrong value errors out in debug mode. gives small speedup to subsurf. --- source/blender/blenkernel/intern/CCGSubSurf.c | 53 +++++++++++++++++---------- 1 file changed, 33 insertions(+), 20 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c index 07cedc50bce..c76f1e6d07d 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.c +++ b/source/blender/blenkernel/intern/CCGSubSurf.c @@ -690,30 +690,36 @@ static int _face_getVertIndex(CCGFace *f, CCGVert *v) return i; return -1; } -static CCG_INLINE void *_face_getIFCoEdge(CCGFace *f, CCGEdge *e, int lvl, int eX, int eY, int levels, int dataSize) +static int _face_getEdgeIndex(CCGFace *f, CCGEdge *e) +{ + int i; + for (i = 0; i < f->numVerts; i++) + if (FACE_getEdges(f)[i] == e) + return i; + return -1; +} +static CCG_INLINE void *_face_getIFCoEdge(CCGFace *f, CCGEdge *e, int f_ed_idx, int lvl, int eX, int eY, int levels, int dataSize) { int maxGridSize = ccg_gridsize(levels); int spacing = ccg_spacing(levels, lvl); - int S, x, y, cx, cy; + int x, y, cx, cy; - for (S = 0; S < f->numVerts; S++) - if (FACE_getEdges(f)[S] == e) - break; + BLI_assert(f_ed_idx == _face_getEdgeIndex(f, e)); eX = eX * spacing; eY = eY * spacing; - if (e->v0 != FACE_getVerts(f)[S]) { + if (e->v0 != FACE_getVerts(f)[f_ed_idx]) { eX = (maxGridSize * 2 - 1) - 1 - eX; } y = maxGridSize - 1 - eX; x = maxGridSize - 1 - eY; if (x < 0) { - S = (S + f->numVerts - 1) % f->numVerts; + f_ed_idx = (f_ed_idx + f->numVerts - 1) % f->numVerts; cx = y; cy = -x; } else if (y < 0) { - S = (S + 1) % f->numVerts; + f_ed_idx = (f_ed_idx + 1) % f->numVerts; cx = -y; cy = x; } @@ -721,11 +727,11 @@ static CCG_INLINE void *_face_getIFCoEdge(CCGFace *f, CCGEdge *e, int lvl, int e cx = x; cy = y; } - return _face_getIFCo(f, levels, S, cx, cy, levels, dataSize); + return _face_getIFCo(f, levels, f_ed_idx, cx, cy, levels, dataSize); } -static float *_face_getIFNoEdge(CCGFace *f, CCGEdge *e, int lvl, int eX, int eY, int levels, int dataSize, int normalDataOffset) +static float *_face_getIFNoEdge(CCGFace *f, CCGEdge *e, int f_ed_idx, int lvl, int eX, int eY, int levels, int dataSize, int normalDataOffset) { - return (float *) ((byte *) _face_getIFCoEdge(f, e, lvl, eX, eY, levels, dataSize) + normalDataOffset); + return (float *) ((byte *) _face_getIFCoEdge(f, e, f_ed_idx, lvl, eX, eY, levels, dataSize) + normalDataOffset); } static void _face_calcIFNo(CCGFace *f, int lvl, int S, int x, int y, float *no, int levels, int dataSize) { @@ -1457,19 +1463,23 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss, for (i = 0; i < e->numFaces - 1; i++) { CCGFace *f = e->faces[i]; + const int f_ed_idx = _face_getEdgeIndex(f, e); + const int f_ed_idx_last = _face_getEdgeIndex(fLast, e); for (x = 1; x < edgeSize - 1; x++) { - NormAdd(_face_getIFNoEdge(fLast, e, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset), - _face_getIFNoEdge(f, e, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset)); + NormAdd(_face_getIFNoEdge(fLast, e, f_ed_idx_last, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset), + _face_getIFNoEdge(f, e, f_ed_idx, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset)); } } for (i = 0; i < e->numFaces - 1; i++) { CCGFace *f = e->faces[i]; + const int f_ed_idx = _face_getEdgeIndex(f, e); + const int f_ed_idx_last = _face_getEdgeIndex(fLast, e); for (x = 1; x < edgeSize - 1; x++) { - NormCopy(_face_getIFNoEdge(f, e, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset), - _face_getIFNoEdge(fLast, e, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset)); + NormCopy(_face_getIFNoEdge(f, e, f_ed_idx, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset), + _face_getIFNoEdge(fLast, e, f_ed_idx_last, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset)); } } } @@ -1518,10 +1528,11 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss, if (e->numFaces) { CCGFace *f = e->faces[0]; int x; + const int f_ed_idx = _face_getEdgeIndex(f, e); for (x = 0; x < edgeSize; x++) NormCopy(EDGE_getNo(e, lvl, x), - _face_getIFNoEdge(f, e, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset)); + _face_getIFNoEdge(f, e, f_ed_idx, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset)); } else { /* set to zero here otherwise the normals are uninitialized memory @@ -1666,7 +1677,8 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, for (j = 0; j < e->numFaces; j++) { CCGFace *f = e->faces[j]; - VertDataAdd(q, _face_getIFCoEdge(f, e, nextLvl, fx, 1, subdivLevels, vertDataSize)); + const int f_ed_idx = _face_getEdgeIndex(f, e); + VertDataAdd(q, _face_getIFCoEdge(f, e, f_ed_idx, nextLvl, fx, 1, subdivLevels, vertDataSize)); numFaces++; } @@ -1866,10 +1878,11 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, VertDataAdd(r, EDGE_getCo(e, curLvl, x + 1)); for (j = 0; j < e->numFaces; j++) { CCGFace *f = e->faces[j]; - VertDataAdd(q, _face_getIFCoEdge(f, e, nextLvl, fx - 1, 1, subdivLevels, vertDataSize)); - VertDataAdd(q, _face_getIFCoEdge(f, e, nextLvl, fx + 1, 1, subdivLevels, vertDataSize)); + int f_ed_idx = _face_getEdgeIndex(f, e); + VertDataAdd(q, _face_getIFCoEdge(f, e, f_ed_idx, nextLvl, fx - 1, 1, subdivLevels, vertDataSize)); + VertDataAdd(q, _face_getIFCoEdge(f, e, f_ed_idx, nextLvl, fx + 1, 1, subdivLevels, vertDataSize)); - VertDataAdd(r, _face_getIFCoEdge(f, e, curLvl, x, 1, subdivLevels, vertDataSize)); + VertDataAdd(r, _face_getIFCoEdge(f, e, f_ed_idx, curLvl, x, 1, subdivLevels, vertDataSize)); numFaces++; } VertDataMulN(q, 1.0f / (numFaces * 2.0f)); -- cgit v1.2.3 From cd2b142ba0bf8305efd44db22068c39f4f935cd5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 22 Apr 2012 03:25:48 +0000 Subject: small speedup to VertDataMulN(av, n), when passed expressions to 'n' they were calculated 3 times, cuts 78 instructions from resulting assembly (gcc -O2). --- source/blender/blenkernel/intern/CCGSubSurf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c index c76f1e6d07d..f5718974f9f 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.c +++ b/source/blender/blenkernel/intern/CCGSubSurf.c @@ -282,7 +282,7 @@ static int VertDataEqual(const float *a, const float *b) #define VertDataCopy(av, bv) { float *_a = (float *)av, *_b = (float *) bv; _a[0] = _b[0]; _a[1] = _b[1]; _a[2] = _b[2]; } #define VertDataAdd(av, bv) { float *_a = (float *)av, *_b = (float *) bv; _a[0] += _b[0]; _a[1] += _b[1]; _a[2] += _b[2]; } #define VertDataSub(av, bv) { float *_a = (float *)av, *_b = (float *) bv; _a[0] -= _b[0]; _a[1] -= _b[1]; _a[2] -= _b[2]; } -#define VertDataMulN(av, n) { float *_a = (float *)av; _a[0] *= n; _a[1] *= n; _a[2] *= n; } +#define VertDataMulN(av, n) { float *_a = (float *)av; float _n = n; _a[0] *= _n; _a[1] *= _n; _a[2] *= _n; } #define VertDataAvg4(tv, av, bv, cv, dv) \ { \ float *_t = (float *) tv, *_a = (float *) av, *_b = (float *) bv, *_c = (float *) cv, *_d = (float *) dv; \ -- cgit v1.2.3 From 5c891386842037910f5d522c7d3ffb1792b804db Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 22 Apr 2012 11:54:53 +0000 Subject: style cleanup: comments --- source/blender/blenkernel/intern/DerivedMesh.c | 2 +- source/blender/blenkernel/intern/cdderivedmesh.c | 9 ++++++--- source/blender/blenkernel/intern/customdata.c | 2 +- source/blender/blenkernel/intern/depsgraph.c | 6 +++--- source/blender/blenkernel/intern/implicit.c | 18 +++++++++--------- source/blender/blenkernel/intern/mesh.c | 2 +- source/blender/blenkernel/intern/multires.c | 8 ++++---- source/blender/blenkernel/intern/paint.c | 6 +++--- source/blender/blenkernel/intern/seqeffects.c | 4 ++-- source/blender/blenkernel/intern/sequencer.c | 14 +++++++------- source/blender/blenkernel/intern/subsurf_ccg.c | 2 +- source/blender/blenkernel/intern/writeffmpeg.c | 10 +++++----- 12 files changed, 43 insertions(+), 40 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 294518458bf..c28958d5b0d 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -2137,7 +2137,7 @@ static void mesh_build_data(Scene *scene, Object *ob, CustomDataMask dataMask, 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) */ + * but this avoids waiting on first stroke) */ ob->sculpt->pbvh= ob->derivedFinal->getPBVH(ob, ob->derivedFinal); } } diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 4a852bb0233..474aa84fec6 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -701,14 +701,17 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, GPU_normal_setup( dm ); GPU_uv_setup( dm ); if ( col != NULL ) { - /*if ( realcol && dm->drawObject->colType == CD_TEXTURE_MCOL ) { +#if 0 + if ( realcol && dm->drawObject->colType == CD_TEXTURE_MCOL ) { col = 0; } else if ( mcol && dm->drawObject->colType == CD_MCOL ) { col = 0; } - if ( col != 0 ) {*/ + if ( col != 0 ) +#endif + { 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++ ) { @@ -724,7 +727,7 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, dm->drawObject->colType = CD_TEXTURE_MCOL; else if (mcol) dm->drawObject->colType = CD_MCOL; - //} + } GPU_color_setup( dm ); } diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 7cc7a82df66..afb5e85ffa8 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -2167,7 +2167,7 @@ void CustomData_bmesh_merge(CustomData *source, CustomData *dest, int t; /* copy old layer description so that old data can be copied into - the new allocation */ + * the new allocation */ destold = *dest; if (destold.layers) destold.layers = MEM_dupallocN(destold.layers); diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index ccaa03ad9d9..574c2842144 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -1309,11 +1309,11 @@ DagNodeQueue * graph_dfs(void) /* is_cycle = 1; */ /* UNUSED */ } 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 */ - /*if (node->DFS_dist >= itA->node->DFS_dist) +#if 0 + if (node->DFS_dist >= itA->node->DFS_dist) itA->node->DFS_dist = node->DFS_dist + 1; fprintf(stderr,"dfs forward or cross edge :%15s %i-%i %15s %i-%i\n", @@ -1323,7 +1323,7 @@ DagNodeQueue * graph_dfs(void) ((ID *) itA->node->ob)->name, itA->node->DFS_dvtm, itA->node->DFS_fntm); - */ +#endif } else fprintf(stderr,"dfs unknown edge\n"); diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index 0bb9426730e..a4edc1e531a 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -1424,9 +1424,9 @@ typedef struct HairGridVert { #define HAIR_GRID_INDEX(vec, min, max, axis) (int)((vec[axis] - min[axis]) / (max[axis] - min[axis]) * 9.99f) /* Smoothing of hair velocities: * adapted from - Volumetric Methods for Simulation and Rendering of Hair - by Lena Petrovic, Mark Henne and John Anderson - * Pixar Technical Memo #06-08, Pixar Animation Studios + * Volumetric Methods for Simulation and Rendering of Hair + * by Lena Petrovic, Mark Henne and John Anderson + * Pixar Technical Memo #06-08, Pixar Animation Studios */ static void hair_velocity_smoothing(ClothModifierData *clmd, lfVector *lF, lfVector *lX, lfVector *lV, unsigned int numverts) { @@ -1591,8 +1591,8 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec hair_velocity_smoothing(clmd, lF, lX, lV, numverts); /* multiply lF with mass matrix - // force = mass * acceleration (in this case: gravity) - */ + * force = mass * acceleration (in this case: gravity) + */ for (i = 0; i < numverts; i++) { float temp[3]; @@ -1745,10 +1745,10 @@ static void simulate_implicit_euler(lfVector *Vnew, lfVector *UNUSED(lX), lfVect del_lfvector(dFdXmV); } -/*computes where the cloth would be if it were subject to perfectly stiff edges - (edge distance constraints) in a lagrangian solver. then add forces to help - guide the implicit solver to that state. this function is called after - collisions*/ +/* computes where the cloth would be if it were subject to perfectly stiff edges + * (edge distance constraints) in a lagrangian solver. then add forces to help + * guide the implicit solver to that state. this function is called after + * collisions*/ int cloth_calc_helper_forces(Object *UNUSED(ob), ClothModifierData * clmd, float (*initial_cos)[3], float UNUSED(step), float dt) { Cloth *cloth= clmd->clothObject; diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index af24240bf4a..ea2e634ed64 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -3038,7 +3038,7 @@ int poly_get_adj_loops_from_vert(unsigned adj_r[3], const MPoly *poly, } /* update the hide flag for edges and faces from the corresponding - flag in verts */ + * flag in verts */ void mesh_flush_hidden_from_verts(const MVert *mvert, const MLoop *mloop, MEdge *medge, int totedge, diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 2167495ef08..7580f2eee4d 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -104,7 +104,7 @@ static BLI_bitmap multires_mdisps_upsample_hidden(BLI_bitmap lo_hidden, int hi_level, /* assumed to be at hi_level (or - null) */ + * null) */ BLI_bitmap prev_hidden) { BLI_bitmap subd; @@ -144,8 +144,8 @@ static BLI_bitmap multires_mdisps_upsample_hidden(BLI_bitmap lo_hidden, if (prev_hidden) { /* If prev_hidden is available, copy it to - subd, except when the equivalent element in - lo_hidden is different */ + * subd, except when the equivalent element in + * lo_hidden is different */ if (lo_val != prev_hidden[hi_ndx]) BLI_BITMAP_MODIFY(subd, hi_ndx, lo_val); else @@ -215,7 +215,7 @@ static void multires_output_hidden_to_ccgdm(CCGDerivedMesh *ccgdm, } /* subdivide mdisps.hidden if needed (assumes that md.level reflects - the current level of md.hidden) */ + * the current level of md.hidden) */ static void multires_mdisps_subdivide_hidden(MDisps *md, int new_level) { BLI_bitmap subd; diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index 975602c2918..27f5f7d9eb1 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -151,7 +151,7 @@ void copy_paint(Paint *src, Paint *tar) } /* returns non-zero if any of the face's vertices - are hidden, zero otherwise */ + * are hidden, zero otherwise */ int paint_is_face_hidden(const MFace *f, const MVert *mvert) { return ((mvert[f->v1].flag & ME_HIDE) || @@ -161,8 +161,8 @@ int paint_is_face_hidden(const MFace *f, const MVert *mvert) } /* returns non-zero if any of the corners of the grid - face whose inner corner is at (x,y) are hidden, - zero otherwise */ + * face whose inner corner is at (x,y) are hidden, + * zero otherwise */ int paint_is_grid_face_hidden(const unsigned int *grid_hidden, int gridsize, int x, int y) { diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 52f59fb8b80..8015e53e4c9 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -1781,7 +1781,7 @@ static float check_zone(WipeZone *wipezone, int x, int y, /* BOX WIPE IS NOT WORKING YET */ /* case DO_CROSS_WIPE: */ /* BOX WIPE IS NOT WORKING YET */ - /* +#if 0 case DO_BOX_WIPE: if (invert)facf0 = 1-facf0; @@ -1843,7 +1843,7 @@ static float check_zone(WipeZone *wipezone, int x, int y, } break; -*/ +#endif case DO_IRIS_WIPE: if (xo > yo) yo = xo; else xo = yo; diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 97edba7d9ef..2d4397d16cd 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -2192,7 +2192,7 @@ static ImBuf *seq_render_strip(SeqRenderData context, Sequence *seq, float cfra) ibuf = seq_stripelem_cache_get(context, seq, cfra, SEQ_STRIPELEM_IBUF); /* currently, we cache preprocessed images in SEQ_STRIPELEM_IBUF, - * but not(!) on SEQ_STRIPELEM_IBUF_ENDSTILL and ..._STARTSTILL */ + * but not(!) on SEQ_STRIPELEM_IBUF_ENDSTILL and ..._STARTSTILL */ if (ibuf) use_preprocess = FALSE; @@ -2685,10 +2685,10 @@ static void seq_start_threads(Scene *scene) seq_last_given_monoton_cfra = monoton_cfra = 0; /* since global structures are modified during the processing - of one frame, only one render thread is currently possible... - - (but we code, in the hope, that we can remove this restriction - soon...) + * of one frame, only one render thread is currently possible... + * + * (but we code, in the hope, that we can remove this restriction + * soon...) */ fprintf(stderr, "SEQ-THREAD: seq_start_threads\n"); @@ -2942,7 +2942,7 @@ void free_imbuf_seq(Scene *scene, ListBase *seqbase, int check_mem_usage, } if (seq->type == SEQ_SCENE) { /* FIXME: recurs downwards, - but do recurs protection somehow! */ + * but do recurs protection somehow! */ } } @@ -3394,7 +3394,7 @@ static void seq_update_muting_recursive(ListBase *seqbasep, Sequence *metaseq, i int seqmute; /* for sound we go over full meta tree to update muted state, - * since sound is played outside of evaluating the imbufs, */ + * since sound is played outside of evaluating the imbufs, */ for (seq = seqbasep->first; seq; seq = seq->next) { seqmute = (mute || (seq->flag & SEQ_MUTE)); diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index a4f7a9697bf..83a24f6afdc 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -975,7 +975,7 @@ static void ccgDM_getFinalFace(DerivedMesh *dm, int faceNum, MFace *mf) } /* Translate GridHidden into the ME_HIDE flag for MVerts. Assumes - vertices are in the order output by ccgDM_copyFinalVertArray. */ + * vertices are in the order output by ccgDM_copyFinalVertArray. */ void subsurf_copy_grid_hidden(DerivedMesh *dm, const MPoly *mpoly, MVert *mvert, const MDisps *mdisps) { diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 740deb5c7db..59c38117858 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -172,7 +172,7 @@ static AVFrame* alloc_picture(int pix_fmt, int width, int height) } /* Get the correct file extensions for the requested format, - first is always desired guess_format parameter */ + * first is always desired guess_format parameter */ static const char** get_file_extensions(int format) { switch(format) { @@ -308,7 +308,7 @@ static AVFrame* generate_video_frame(uint8_t* pixels, ReportList *reports) rendered_frame = pixels; /* Do RGBA-conversion and flipping in one step depending - on CPU-Endianess */ + * on CPU-Endianess */ if (ENDIAN_ORDER == L_ENDIAN) { int y; @@ -628,7 +628,7 @@ static AVStream* alloc_audio_stream(RenderData *rd, int codec_id, AVFormatContex } /* need to prevent floating point exception when using vorbis audio codec, - initialize this value in the same way as it's done in FFmpeg iteslf (sergey) */ + * initialize this value in the same way as it's done in FFmpeg iteslf (sergey) */ st->codec->time_base.num= 1; st->codec->time_base.den= st->codec->sample_rate; @@ -876,8 +876,8 @@ void flush_ffmpeg(void) } /* ********************************************************************** - * public interface - ********************************************************************** */ + * * public interface + * ********************************************************************** */ /* Get the output filename-- similar to the other output formats */ void filepath_ffmpeg(char* string, RenderData* rd) -- cgit v1.2.3 From e26ef899c303919098faa60b1a5baaf6e78276f6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 23 Apr 2012 00:58:17 +0000 Subject: clear the FGON edge flag when updating old meshes to polygons. (we may wan't to reuse the flag later) --- source/blender/blenkernel/intern/mesh.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index ea2e634ed64..7280af18493 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -2061,8 +2061,11 @@ void BKE_mesh_convert_mfaces_to_mpolys(Mesh *mesh) /*build edge hash*/ me = mesh->medge; - for (i=0; itotedge; i++, me++) { + for (i = 0; i < mesh->totedge; i++, me++) { BLI_edgehash_insert(eh, me->v1, me->v2, SET_INT_IN_POINTER(i)); + + /* unrelated but avoid having the FGON flag enabled, so we can reuse it later for something else */ + me->flag &= ~ME_FGON; } j = 0; /*current loop index*/ @@ -2077,7 +2080,7 @@ void BKE_mesh_convert_mfaces_to_mpolys(Mesh *mesh) mp->mat_nr = mf->mat_nr; mp->flag = mf->flag; - #define ML(v1, v2) {ml->v = mf->v1; ml->e = GET_INT_FROM_POINTER(BLI_edgehash_lookup(eh, mf->v1, mf->v2)); ml++; j++;} +# define ML(v1, v2) {ml->v = mf->v1; ml->e = GET_INT_FROM_POINTER(BLI_edgehash_lookup(eh, mf->v1, mf->v2)); ml++; j++;} ML(v1, v2); ML(v2, v3); @@ -2089,7 +2092,7 @@ void BKE_mesh_convert_mfaces_to_mpolys(Mesh *mesh) ML(v3, v1); } - #undef ML +# undef ML bm_corners_to_loops(mesh, i, mp->loopstart, numTex, numCol); } -- cgit v1.2.3 From 4c4389f6a42ebfe0140de8d1892d9990aa592980 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 23 Apr 2012 02:48:05 +0000 Subject: code cleanup: remove editbutflag flag from toolsettings & related defines. --- source/blender/blenkernel/intern/scene.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index c950a6ccdb5..01ab5745256 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -418,7 +418,6 @@ Scene *add_scene(const char *name) sce->toolsettings->segments = 32; sce->toolsettings->rings = 32; sce->toolsettings->vertices = 32; - sce->toolsettings->editbutflag = 1; sce->toolsettings->uvcalc_radius = 1.0f; sce->toolsettings->uvcalc_cubesize = 1.0f; sce->toolsettings->uvcalc_mapdir = 1; -- cgit v1.2.3 From ceffa6e1fab2b4b1388458bcf7c735e2783f90d8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 23 Apr 2012 07:32:13 +0000 Subject: code cleanup: comment unused functions (removed one which isnt useful anymore). --- source/blender/blenkernel/intern/depsgraph.c | 2 ++ source/blender/blenkernel/intern/library.c | 2 ++ source/blender/blenkernel/intern/material.c | 4 ++-- source/blender/blenkernel/intern/particle.c | 4 ++++ source/blender/blenkernel/intern/texture.c | 3 ++- 5 files changed, 12 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 574c2842144..aa6d42977ca 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -1579,6 +1579,7 @@ struct DagNodeQueue *get_all_childs(struct DagForest *dag, void *ob) } /* unused */ +#if 0 short are_obs_related(struct DagForest *dag, void *ob1, void *ob2) { DagNode * node; @@ -1595,6 +1596,7 @@ short are_obs_related(struct DagForest *dag, void *ob1, void *ob2) } return DAG_NO_RELATION; } +#endif int is_acyclic( DagForest *dag) { diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 0506d606607..7e756e853b1 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1055,6 +1055,7 @@ void IDnames_to_pupstring(const char **str, const char *title, const char *extra } /* skips viewer images */ +#if 0 /* unused */ void IMAnames_to_pupstring(const char **str, const char *title, const char *extraops, ListBase *lb, ID *link, short *nr) { DynStr *pupds= BLI_dynstr_new(); @@ -1075,6 +1076,7 @@ void IMAnames_to_pupstring(const char **str, const char *title, const char *extr *str= BLI_dynstr_get_cstring(pupds); BLI_dynstr_free(pupds); } +#endif void id_sort_by_name(ListBase *lb, ID *id) { diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index f7351887b55..6d44282c60a 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -1052,7 +1052,7 @@ int material_in_material(Material *parmat, Material *mat) } /* ****************** */ - +#if 0 /* UNUSED */ static char colname_array[125][20]= { "Black","DarkRed","HalfRed","Red","Red", "DarkGreen","DarkOlive","Brown","Chocolate","OrangeRed", @@ -1098,7 +1098,7 @@ void automatname(Material *ma) new_id(&G.main->mat, (ID *)ma, colname_array[nr]); } - +#endif int object_remove_material_slot(Object *ob) { diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 414677bfc6e..a154a1f8926 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -201,6 +201,8 @@ void psys_set_current_num(Object *ob, int index) psys->flag &= ~PSYS_CURRENT; } } + +#if 0 /* UNUSED */ Object *psys_find_object(Scene *scene, ParticleSystem *psys) { Base *base; @@ -215,6 +217,8 @@ Object *psys_find_object(Scene *scene, ParticleSystem *psys) return NULL; } +#endif + Object *psys_get_lattice(ParticleSimulationData *sim) { Object *lattice=NULL; diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 3f40c2bd429..23d818369a2 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -1052,7 +1052,7 @@ void make_local_texture(Tex *tex) } /* ------------------------------------------------------------------------- */ - +#if 0 /* UNUSED */ void autotexname(Tex *tex) { Main *bmain= G.main; @@ -1082,6 +1082,7 @@ void autotexname(Tex *tex) else new_id(&bmain->tex, (ID *)tex, texstr[tex->type]); } } +#endif /* ------------------------------------------------------------------------- */ -- cgit v1.2.3 From b8c4c54ff0a0d2315b711612238192ca4c4562f5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 23 Apr 2012 16:29:13 +0000 Subject: corrected more issues from [#31069] Analyzing the Blender project with PVS-Studio --- source/blender/blenkernel/intern/dynamicpaint.c | 6 +++--- source/blender/blenkernel/intern/ipo.c | 24 +++++++++++------------- 2 files changed, 14 insertions(+), 16 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 943c8a20990..9ce4d68eeed 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -1577,14 +1577,14 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData if (pmd->canvas && !(pmd->canvas->flags & MOD_DPAINT_BAKING)) { - DynamicPaintSurface *surface = pmd->canvas->surfaces.first; + DynamicPaintSurface *surface; int update_normals = 0; /* loop through surfaces */ - for (; surface; surface=surface->next) { + for (surface = pmd->canvas->surfaces.first; surface; surface=surface->next) { PaintSurfaceData *sData = surface->data; - if (surface && surface->format != MOD_DPAINT_SURFACE_F_IMAGESEQ && sData) { + if (surface->format != MOD_DPAINT_SURFACE_F_IMAGESEQ && sData) { if (!(surface->flags & (MOD_DPAINT_ACTIVE))) continue; /* process vertex surface previews */ diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index c1b5d07de4a..2fd1d291363 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -1105,20 +1105,18 @@ static void fcurve_add_to_list (ListBase *groups, ListBase *list, FCurve *fcu, c /* get the group to use */ agrp= action_groups_find_named(&tmp_act, grpname); + /* no matching group, so add one */ if (agrp == NULL) { - /* no matching group, so add one */ - if (agrp == NULL) { - /* Add a new group, and make it active */ - agrp= MEM_callocN(sizeof(bActionGroup), "bActionGroup"); - - agrp->flag = AGRP_SELECTED; - if (muteipo) agrp->flag |= AGRP_MUTED; - - BLI_strncpy(agrp->name, grpname, sizeof(agrp->name)); - - BLI_addtail(&tmp_act.groups, agrp); - BLI_uniquename(&tmp_act.groups, agrp, "Group", '.', offsetof(bActionGroup, name), sizeof(agrp->name)); - } + /* Add a new group, and make it active */ + agrp= MEM_callocN(sizeof(bActionGroup), "bActionGroup"); + + agrp->flag = AGRP_SELECTED; + if (muteipo) agrp->flag |= AGRP_MUTED; + + BLI_strncpy(agrp->name, grpname, sizeof(agrp->name)); + + BLI_addtail(&tmp_act.groups, agrp); + BLI_uniquename(&tmp_act.groups, agrp, "Group", '.', offsetof(bActionGroup, name), sizeof(agrp->name)); } /* add F-Curve to group */ -- cgit v1.2.3 From 4ff038c4119327f3b0c472b71356d5e0cf2e0ed6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 24 Apr 2012 02:01:23 +0000 Subject: screenshot operator now adds file extension in the file selector and has its own save options rather then using the render options (works like image save a copy). --- source/blender/blenkernel/intern/image.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 27779ef8107..6e0330f5316 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1163,6 +1163,15 @@ int BKE_add_image_extension(char *string, const char imtype) } } +void BKE_imformat_defaults(ImageFormatData *im_format) +{ + memset(im_format, 0, sizeof(*im_format)); + im_format->planes = R_IMF_PLANES_RGB; + im_format->imtype = R_IMF_IMTYPE_PNG; + im_format->quality = 90; + im_format->compress = 90; +} + /* could allow access externally - 512 is for long names, 64 is for id names */ typedef struct StampData { char file[512]; -- cgit v1.2.3 From 48893dba2459580ff73f04196e44342b56c0a035 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 24 Apr 2012 22:50:49 +0000 Subject: style cleanup: no functional changes --- source/blender/blenkernel/intern/collision.c | 18 +++++++++--------- source/blender/blenkernel/intern/customdata.c | 2 +- source/blender/blenkernel/intern/mball.c | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index 7195fb9c425..5b03f73e120 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -666,8 +666,8 @@ static CollPair* cloth_edge_collision ( ModifierData *md1, ModifierData *md2, BVHTreeOverlap *overlap, CollPair *collpair, GHash *visithash, MemArena *arena) { - ClothModifierData *clmd = ( ClothModifierData * ) md1; - CollisionModifierData *collmd = ( CollisionModifierData * ) md2; + ClothModifierData *clmd = (ClothModifierData *)md1; + CollisionModifierData *collmd = (CollisionModifierData *) md2; MFace *face1=NULL, *face2 = NULL; ClothVertex *verts1 = clmd->clothObject->verts; double distance = 0; @@ -1185,8 +1185,8 @@ int cloth_point_tri_moving_v3v3_f(float v1[2][3], int i1, float v2[2][3], int i2 static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, BVHTreeOverlap *overlap, CollPair *collpair, double dt, GHash *gh, MemArena *arena) { - ClothModifierData *clmd = ( ClothModifierData * ) md1; - CollisionModifierData *collmd = ( CollisionModifierData * ) md2; + ClothModifierData *clmd = (ClothModifierData *)md1; + CollisionModifierData *collmd = (CollisionModifierData *) md2; MFace *face1=NULL, *face2 = NULL; ClothVertex *verts1 = clmd->clothObject->verts; double distance = 0; @@ -1400,8 +1400,8 @@ static void machine_epsilon_offset(Cloth *cloth) static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, BVHTreeOverlap *overlap, CollPair *collpair, float dt ) { - ClothModifierData *clmd = ( ClothModifierData * ) md1; - CollisionModifierData *collmd = ( CollisionModifierData * ) md2; + ClothModifierData *clmd = (ClothModifierData *)md1; + CollisionModifierData *collmd = (CollisionModifierData *) md2; Cloth *cloth = clmd->clothObject; MFace *face1=NULL, *face2 = NULL; #ifdef USE_BULLET @@ -2285,13 +2285,13 @@ static void cloth_bvh_objcollisions_nearcheck ( ClothModifierData * clmd, Collis for ( i = 0; i < numresult; i++ ) { - *collisions_index = cloth_collision ( ( ModifierData * ) clmd, ( ModifierData * ) collmd, + *collisions_index = cloth_collision ( (ModifierData *)clmd, (ModifierData *)collmd, overlap+i, *collisions_index, dt, tri_visithash, arena ); } for ( i = 0; i < numresult; i++ ) { - *collisions_index = cloth_edge_collision ( ( ModifierData * ) clmd, ( ModifierData * ) collmd, + *collisions_index = cloth_edge_collision ( (ModifierData *)clmd, (ModifierData *)collmd, overlap+i, *collisions_index, visithash, arena ); } BLI_ghash_free(visithash, NULL, NULL); @@ -2300,7 +2300,7 @@ static void cloth_bvh_objcollisions_nearcheck ( ClothModifierData * clmd, Collis #else /* WITH_ELTOPO */ for ( i = 0; i < numresult; i++ ) { - *collisions_index = cloth_collision ( ( ModifierData * ) clmd, ( ModifierData * ) collmd, + *collisions_index = cloth_collision ( (ModifierData *)clmd, (ModifierData *)collmd, overlap+i, *collisions_index, dt ); } #endif /* WITH_ELTOPO */ diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index afb5e85ffa8..1514716d717 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -167,7 +167,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) { - void **ptr = (void **)((char *)dest + i * size); + void **ptr = (void **)((char *)dest + i * size); *ptr = NULL; } } diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index da5e02c17f1..c06d796d562 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -525,7 +525,7 @@ Object *find_basis_mball(Scene *scene, Object *basis) void calc_mballco(MetaElem *ml, float vec[3]) { if (ml->mat) { - mul_m4_v3((float ( * )[4])ml->mat, vec); + mul_m4_v3((float (*)[4])ml->mat, vec); } } @@ -537,7 +537,7 @@ float densfunc(MetaElem *ball, float x, float y, float z) vec[0]= x; vec[1]= y; vec[2]= z; - mul_m4_v3((float ( * )[4])ball->imat, vec); + mul_m4_v3((float (*)[4])ball->imat, vec); dx= vec[0]; dy= vec[1]; dz= vec[2]; @@ -1738,7 +1738,7 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */ /* transformation of Metalem bb */ for (i=0; i<8; i++) - mul_m4_v3((float ( * )[4])mat, mainb[a]->bb->vec[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++) { -- cgit v1.2.3 From ee6aaafd31f81c6b493c7f6b83ca186ce369d104 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 25 Apr 2012 06:06:40 +0000 Subject: code cleanup: typos and set gcc attributes for string formatting. --- source/blender/blenkernel/intern/anim_sys.c | 2 +- source/blender/blenkernel/intern/cdderivedmesh.c | 2 +- source/blender/blenkernel/intern/idprop.c | 2 +- source/blender/blenkernel/intern/mesh.c | 4 ++-- source/blender/blenkernel/intern/packedFile.c | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index fc58799eb18..75b9ae59e26 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -2171,7 +2171,7 @@ static void animsys_evaluate_overrides (PointerRNA *ptr, AnimData *adt) * * Current Status: * - Currently (as of September 2009), overrides we haven't needed to (fully) implement overrides. - * However, the code fo this is relatively harmless, so is left in the code for now. + * However, the code for this is relatively harmless, so is left in the code for now. */ /* Evaluation loop for evaluation animation data diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 474aa84fec6..4de7df098c3 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -230,7 +230,7 @@ static int can_pbvh_draw(Object *ob, DerivedMesh *dm) int deformed= 0; /* active modifiers means extra deformation, which can't be handled correct - * on bith of PBVH and sculpt "layer" levels, so use PBVH only for internal brush + * on birth of PBVH and sculpt "layer" levels, so use PBVH only for internal brush * stuff and show final DerivedMesh so user would see actual object shape */ deformed|= ob->sculpt->modifiers_active; diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index 1fee5cfa359..bb51325a6ef 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -484,7 +484,7 @@ void IDP_ReplaceGroupInGroup(IDProperty *dest, IDProperty *src) } /* * replaces a property with the same name in a group, or adds - * it if the propery doesn't exist. + * it if the properly doesn't exist. */ void IDP_ReplaceInGroup(IDProperty *group, IDProperty *prop) { diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 7280af18493..514380dc980 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -327,7 +327,7 @@ static void mesh_ensure_tessellation_customdata(Mesh *me) /* TODO - add some --debug-mesh option */ if (G.debug & G_DEBUG) { - /* note: this warning may be un-called for if we are inirializing the mesh for the + /* note: this warning may be un-called for if we are initializing the mesh for the * first time from bmesh, rather then giving a warning about this we could be smarter * and check if there was any data to begin with, for now just print the warning with * some info to help troubleshoot whats going on - campbell */ @@ -1104,7 +1104,7 @@ void mesh_strip_loose_polysloops(Mesh *me) b++; } else { - /* XXX Theorically, we should be able to not do this, as no remaining poly + /* XXX Theoretically, we should be able to not do this, as no remaining poly * should use any stripped loop. But for security's sake... */ new_idx[a] = -a; } diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index 8a940e339bc..b55033b8493 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -392,7 +392,7 @@ int checkPackedFile(const char *filename, PackedFile *pf) /* unpackFile() looks at the existing files (abs_name, local_name) and a packed file. * * It returns a char *to the existing file name / new file name or NULL when - * there was an error or when the user desides to cancel the operation. + * there was an error or when the user decides to cancel the operation. */ char *unpackFile(ReportList *reports, const char *abs_name, const char *local_name, PackedFile *pf, int how) -- cgit v1.2.3 From 6cc48ec555f06ab8dbf7cfb262e06d1fcebf334c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 25 Apr 2012 07:23:20 +0000 Subject: mesh.validate() / BKE_mesh_validate() --- functions now check for duplicate vertices used within the same polygon. (which would crash otherwise) --- source/blender/blenkernel/intern/mesh_validate.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c index aebbcd4208d..446ad399e11 100644 --- a/source/blender/blenkernel/intern/mesh_validate.c +++ b/source/blender/blenkernel/intern/mesh_validate.c @@ -240,9 +240,23 @@ int BKE_mesh_validate_arrays(Mesh *mesh, PRINT(" loop %u has invalid vert reference (%u)\n", sp->loopstart + j, ml->v); sp->invalid = TRUE; } + + mverts[ml->v].flag |= ME_VERT_TMP_TAG; *v = ml->v; } + /* is the same vertex used more then once */ + if (!sp->invalid) { + v = sp->verts; + for (j = 0; j < mp->totloop; j++, v++) { + if ((mverts[*v].flag & ME_VERT_TMP_TAG) == 0) { + PRINT(" poly %u has duplicate vert reference at corner (%u)\n", i, j); + sp->invalid = TRUE; + } + mverts[*v].flag &= ~ME_VERT_TMP_TAG; + } + } + if (sp->invalid) continue; -- cgit v1.2.3 From 2f74471dd96382521c57e53fc99fb0df3974f7dc Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 26 Apr 2012 02:24:55 +0000 Subject: fix invalid memcpy() use in text editor (backspace would call memcpy with overlapping source and destination). --- source/blender/blenkernel/intern/text.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index a7e49dd7fc8..1197ec23907 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -2652,7 +2652,10 @@ void txt_backspace_char (Text *text) } while (mrk && mrk->lineno==lineno); } - memcpy(text->curl->line + text->curc - c_len, text->curl->line + text->curc, text->curl->len-text->curc+1); + /* source and destination overlap, don't use memcpy() */ + memmove(text->curl->line + text->curc - c_len, + text->curl->line + text->curc, + text->curl->len - text->curc + 1); text->curl->len-= c_len; text->curc-= c_len; -- cgit v1.2.3 From 6d2cd240108caea9c8c19b2f413f28384cf06675 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 26 Apr 2012 15:20:26 +0000 Subject: fix memory leak in validating mesh and remove unneeded knife operator settings store. --- source/blender/blenkernel/intern/mesh.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 514380dc980..b9a65403f84 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1154,6 +1154,8 @@ void mesh_strip_loose_edges(Mesh *me) for (a = 0, l = me->mloop; a < me->totloop; a++, l++) { l->e = new_idx[l->e]; } + + MEM_freeN(new_idx); } void mball_to_mesh(ListBase *lb, Mesh *me) -- cgit v1.2.3 From ef0a4c0ba9a43107b60f7af1d75066d8fabf9223 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 26 Apr 2012 15:38:16 +0000 Subject: fix for bevel modifier creating invalid geometry - simply tell BM_face_split() to check for doubles. --- source/blender/blenkernel/intern/mesh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index b9a65403f84..59dd7db43da 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1128,7 +1128,7 @@ void mesh_strip_loose_edges(Mesh *me) MEdge *e; MLoop *l; int a, b; - unsigned int *new_idx = MEM_mallocN(sizeof(int) * me->totedge, "strip_loose_edges old2new idx mapping for loops."); + unsigned int *new_idx = MEM_mallocN(sizeof(int) * me->totedge, __func__); for (a = b = 0, e = me->medge; a < me->totedge; a++, e++) { if (e->v1 != e->v2) { -- cgit v1.2.3 From bb4942c9203602550968b27fa0ad29a911ae1ff1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 27 Apr 2012 03:01:27 +0000 Subject: code cleanup: quiet msvc warnings --- source/blender/blenkernel/intern/pointcache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index dbcef9ad4c8..2812592c69a 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -2313,7 +2313,7 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra if (timescale) { time= BKE_curframe(scene); - nexttime= BKE_frame_to_ctime(scene, CFRA+1); + nexttime = BKE_frame_to_ctime(scene, CFRA + 1.0f); *timescale= MAX2(nexttime - time, 0.0f); } -- cgit v1.2.3 From 5d6f746c87db0709107a2b416e112fceb46af359 Mon Sep 17 00:00:00 2001 From: Jens Ole Wund Date: Fri, 27 Apr 2012 11:49:09 +0000 Subject: Patch by Jose Geraldo Brito Tracker 31061 It cures the stiff quad option and does not seem to harm. Nowever the stiff quads behave strange in a ngom mesh. I can imagine that other parts in the sofybody module may be broken by the ngon structure. Well ngons and softbodies are not relly friends: negon wants less edges softbodies would work better if more structural edges were possible --- source/blender/blenkernel/intern/softbody.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 01930cc28da..e3a309fc945 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -78,6 +78,7 @@ variables on the UI for now #include "BKE_DerivedMesh.h" #include "BKE_pointcache.h" #include "BKE_deform.h" +#include "BKE_mesh.h" //XXX #include "BIF_editdeform.h" //XXX #include "BIF_graphics.h" #include "PIL_time.h" @@ -3267,6 +3268,7 @@ static void mesh_to_softbody(Scene *scene, Object *ob) BodyPoint *bp; BodySpring *bs; int a, totedge; + BKE_mesh_tessface_ensure(me); if (ob->softflag & OB_SB_EDGES) totedge= me->totedge; else totedge= 0; -- cgit v1.2.3 From b340f930ec5639f24e7e2d47fab221fb752b61dd Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 28 Apr 2012 06:31:57 +0000 Subject: style cleanup: changes to brace placement / newlines - for/while/if/switch --- source/blender/blenkernel/intern/CCGSubSurf.c | 2 + source/blender/blenkernel/intern/DerivedMesh.c | 11 +- source/blender/blenkernel/intern/anim.c | 6 +- source/blender/blenkernel/intern/anim_sys.c | 16 +- source/blender/blenkernel/intern/armature.c | 2 +- source/blender/blenkernel/intern/boids.c | 6 +- source/blender/blenkernel/intern/brush.c | 2 +- source/blender/blenkernel/intern/bvhutils.c | 6 +- source/blender/blenkernel/intern/cloth.c | 176 ++++++---------- source/blender/blenkernel/intern/collision.c | 221 +++++++-------------- source/blender/blenkernel/intern/colortools.c | 11 +- source/blender/blenkernel/intern/constraint.c | 21 +- source/blender/blenkernel/intern/context.c | 2 +- source/blender/blenkernel/intern/curve.c | 4 +- source/blender/blenkernel/intern/customdata.c | 7 +- source/blender/blenkernel/intern/deform.c | 4 +- source/blender/blenkernel/intern/depsgraph.c | 4 +- source/blender/blenkernel/intern/displist.c | 2 +- source/blender/blenkernel/intern/dynamicpaint.c | 186 ++++++++--------- source/blender/blenkernel/intern/effect.c | 11 +- source/blender/blenkernel/intern/fcurve.c | 3 +- source/blender/blenkernel/intern/fmodifier.c | 3 +- source/blender/blenkernel/intern/font.c | 28 +-- source/blender/blenkernel/intern/idprop.c | 3 +- source/blender/blenkernel/intern/image.c | 23 ++- source/blender/blenkernel/intern/image_gen.c | 12 +- source/blender/blenkernel/intern/implicit.c | 221 +++++++-------------- source/blender/blenkernel/intern/library.c | 15 +- source/blender/blenkernel/intern/material.c | 6 +- source/blender/blenkernel/intern/mball.c | 9 +- source/blender/blenkernel/intern/mesh.c | 37 ++-- source/blender/blenkernel/intern/movieclip.c | 2 +- source/blender/blenkernel/intern/multires.c | 2 +- .../blender/blenkernel/intern/navmesh_conversion.c | 117 ++++------- source/blender/blenkernel/intern/nla.c | 4 +- source/blender/blenkernel/intern/object.c | 14 +- source/blender/blenkernel/intern/ocean.c | 149 +++++--------- source/blender/blenkernel/intern/packedFile.c | 2 +- source/blender/blenkernel/intern/paint.c | 2 +- source/blender/blenkernel/intern/particle.c | 10 +- source/blender/blenkernel/intern/particle_system.c | 40 ++-- source/blender/blenkernel/intern/pointcache.c | 60 +++--- source/blender/blenkernel/intern/property.c | 10 +- source/blender/blenkernel/intern/report.c | 2 +- source/blender/blenkernel/intern/sca.c | 10 +- source/blender/blenkernel/intern/seqeffects.c | 2 +- source/blender/blenkernel/intern/sequencer.c | 4 + source/blender/blenkernel/intern/shrinkwrap.c | 67 +++---- source/blender/blenkernel/intern/sketch.c | 129 ++++-------- source/blender/blenkernel/intern/softbody.c | 41 ++-- source/blender/blenkernel/intern/sound.c | 104 ++++------ source/blender/blenkernel/intern/subsurf_ccg.c | 2 + source/blender/blenkernel/intern/text.c | 93 ++++----- source/blender/blenkernel/intern/texture.c | 6 +- source/blender/blenkernel/intern/writeffmpeg.c | 30 ++- 55 files changed, 778 insertions(+), 1184 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c index f5718974f9f..53e4a973cd4 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.c +++ b/source/blender/blenkernel/intern/CCGSubSurf.c @@ -1272,7 +1272,9 @@ CCGError ccgSubSurf_syncFace(CCGSubSurf *ss, CCGFaceHDL fHDL, int numVerts, CCGV if (f->numVerts != numVerts || memcmp(FACE_getVerts(f), ss->tempVerts, sizeof(*ss->tempVerts) * numVerts) || memcmp(FACE_getEdges(f), ss->tempEdges, sizeof(*ss->tempEdges) * numVerts)) + { topologyChanged = 1; + } } if (!f || topologyChanged) { diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index c28958d5b0d..511b4603791 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -2279,8 +2279,10 @@ DerivedMesh *editbmesh_get_derived_cage_and_final(Scene *scene, Object *obedit, * the data we need, rebuild the derived mesh */ if (!em->derivedCage || - (em->lastDataMask & dataMask) != dataMask) + (em->lastDataMask & dataMask) != dataMask) + { editbmesh_build_data(scene, obedit, em, dataMask); + } *final_r = em->derivedFinal; return em->derivedCage; @@ -2292,8 +2294,10 @@ DerivedMesh *editbmesh_get_derived_cage(Scene *scene, Object *obedit, BMEditMesh * the data we need, rebuild the derived mesh */ if (!em->derivedCage || - (em->lastDataMask & dataMask) != dataMask) + (em->lastDataMask & dataMask) != dataMask) + { editbmesh_build_data(scene, obedit, em, dataMask); + } return em->derivedCage; } @@ -2701,8 +2705,7 @@ void DM_calc_auto_bump_scale(DerivedMesh *dm) if (nr_tris_to_pile==1 || nr_tris_to_pile==2) { const int indices[] = {offs+0, offs+1, offs+2, offs+0, offs+2, (offs+3)&0x3 }; int t; - for ( t=0; tpathcache[a]->steps < 0) || - (a >= totpart && psys->childcache[a-totpart]->steps < 0))) + ((a < totpart && psys->pathcache[a]->steps < 0) || + (a >= totpart && psys->childcache[a-totpart]->steps < 0))) + { continue; + } if (part->ren_as==PART_DRAW_GR) { /* prevent divide by zero below [#28336] */ diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 75b9ae59e26..be53e3ddcba 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -1250,8 +1250,7 @@ static void animsys_evaluate_fcurves (PointerRNA *ptr, ListBase *list, AnimMappe FCurve *fcu; /* calculate then execute each curve */ - for (fcu= list->first; fcu; fcu= fcu->next) - { + for (fcu= list->first; fcu; fcu= fcu->next) { /* check if this F-Curve doesn't belong to a muted group */ if ((fcu->grp == NULL) || (fcu->grp->flag & AGRP_MUTED)==0) { /* check if this curve should be skipped */ @@ -1274,8 +1273,7 @@ static void animsys_evaluate_drivers (PointerRNA *ptr, AnimData *adt, float ctim /* drivers are stored as F-Curves, but we cannot use the standard code, as we need to check if * the depsgraph requested that this driver be evaluated... */ - for (fcu= adt->drivers.first; fcu; fcu= fcu->next) - { + for (fcu= adt->drivers.first; fcu; fcu= fcu->next) { ChannelDriver *driver= fcu->driver; short ok= 0; @@ -1351,8 +1349,7 @@ void animsys_evaluate_action_group (PointerRNA *ptr, bAction *act, bActionGroup return; /* calculate then execute each curve */ - for (fcu= agrp->channels.first; (fcu) && (fcu->grp == agrp); fcu= fcu->next) - { + for (fcu= agrp->channels.first; (fcu) && (fcu->grp == agrp); fcu= fcu->next) { /* check if this curve should be skipped */ if ((fcu->flag & (FCURVE_MUTED|FCURVE_DISABLED)) == 0) { calculate_fcurve(fcu, ctime); @@ -1968,8 +1965,7 @@ void nladata_flush_channels (ListBase *channels) float value= nec->value; /* write values - see animsys_write_rna_setting() to sync the code */ - switch (RNA_property_type(prop)) - { + switch (RNA_property_type(prop)) { case PROP_BOOLEAN: if (RNA_property_array_length(ptr, prop)) RNA_property_boolean_set_index(ptr, prop, array_index, ANIMSYS_FLOAT_AS_BOOL(value)); @@ -2217,7 +2213,9 @@ void BKE_animsys_evaluate_animdata (Scene *scene, ID *id, AnimData *adt, float c * or be layered on top of existing animation data. * - Drivers should be in the appropriate order to be evaluated without problems... */ - if ((recalc & ADT_RECALC_DRIVERS) /*&& (adt->recalc & ADT_RECALC_DRIVERS)*/) // XXX for now, don't check yet, as depsgraph hasn't been updated + if ((recalc & ADT_RECALC_DRIVERS) + /* XXX for now, don't check yet, as depsgraph hasn't been updated */ + /* && (adt->recalc & ADT_RECALC_DRIVERS)*/) { animsys_evaluate_drivers(&id_ptr, adt, ctime); } diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 0f3e27a9b6e..931aa2d6242 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1372,7 +1372,7 @@ void armature_mat_pose_to_bone_ex(Object *ob, bPoseChannel *pchan, float inmat[] /* same as object_mat3_to_rot() */ void pchan_mat3_to_rot(bPoseChannel *pchan, float mat[][3], short use_compat) { - switch(pchan->rotmode) { + switch (pchan->rotmode) { case ROT_MODE_QUAT: mat3_to_quat(pchan->quat, mat); break; diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index a556c99dc7d..fbcabccd2b9 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -962,7 +962,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa) set_boid_values(&val, bbd->part->boids, pa); /* go through rules */ - switch(state->ruleset_type) { + switch (state->ruleset_type) { case eBoidRulesetType_Fuzzy: { for (rule = state->rules.first; rule; rule = rule->next) { @@ -1258,7 +1258,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) bpa->ground = boid_find_ground(bbd, pa, ground_co, ground_nor); /* change modes, constrain movement & keep track of down vector */ - switch(bpa->data.mode) { + switch (bpa->data.mode) { case eBoidMode_InAir: { float grav[3]; @@ -1437,7 +1437,7 @@ BoidRule *boid_new_rule(int type) if (type <= 0) return NULL; - switch(type) { + switch (type) { case eBoidRuleType_Goal: case eBoidRuleType_Avoid: rule = MEM_callocN(sizeof(BoidRuleGoalAvoid), "BoidRuleGoalAvoid"); diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index e7ba09d3959..3df6de2fd24 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -337,7 +337,7 @@ void brush_reset_sculpt(Brush *br) brush_set_defaults(br); brush_curve_preset(br, CURVE_PRESET_SMOOTH); - switch(br->sculpt_tool) { + switch (br->sculpt_tool) { case SCULPT_TOOL_CLAY: br->flag |= BRUSH_FRONTFACE; break; diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c index 009b7ca7f99..df80ce6e87c 100644 --- a/source/blender/blenkernel/intern/bvhutils.c +++ b/source/blender/blenkernel/intern/bvhutils.c @@ -649,8 +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); MVert *vert = mesh->getVertDataArray(mesh, CD_MVERT); @@ -675,8 +674,7 @@ BVHTree* bvhtree_from_mesh_edges(BVHTreeFromMesh *data, DerivedMesh *mesh, float } } } - else - { + else { // printf("BVHTree is already build, using cached tree\n"); } diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index a0c273cf962..97baaad430b 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -191,8 +191,7 @@ static BVHTree *bvhselftree_build_from_cloth (ClothModifierData *clmd, float eps 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); BLI_bvhtree_insert(bvhtree, i, co, 1); @@ -232,8 +231,7 @@ static BVHTree *bvhtree_build_from_cloth (ClothModifierData *clmd, float epsilon 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); @@ -266,10 +264,8 @@ void bvhtree_update_from_cloth(ClothModifierData *clmd, int moving) mfaces = cloth->mfaces; // update vertex position in bvh tree - if (verts && mfaces) - { - for (i = 0; i < cloth->numfaces; i++, mfaces++) - { + if (verts && 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); @@ -278,8 +274,7 @@ void bvhtree_update_from_cloth(ClothModifierData *clmd, int moving) 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); @@ -319,15 +314,12 @@ void bvhselftree_update_from_cloth(ClothModifierData *clmd, int moving) mfaces = cloth->mfaces; // update vertex position in bvh tree - if (verts && mfaces) - { - for (i = 0; i < cloth->numverts; i++, verts++) - { + if (verts && mfaces) { + 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); @@ -558,11 +550,9 @@ void cloth_free_modifier(ClothModifierData *clmd ) cloth = clmd->clothObject; - if ( cloth ) - { + if ( cloth ) { // If our solver provides a free function, call it - if ( solvers [clmd->sim_parms->solver_type].free ) - { + if ( solvers [clmd->sim_parms->solver_type].free ) { solvers [clmd->sim_parms->solver_type].free ( clmd ); } @@ -574,11 +564,9 @@ void cloth_free_modifier(ClothModifierData *clmd ) cloth->numverts = 0; // Free the springs. - if ( cloth->springs != NULL ) - { + if ( cloth->springs != NULL ) { LinkNode *search = cloth->springs; - while (search) - { + while (search) { ClothSpring *spring = search->link; MEM_freeN ( spring ); @@ -628,14 +616,12 @@ void cloth_free_modifier_extern ( ClothModifierData *clmd ) cloth = clmd->clothObject; - if ( cloth ) - { + if ( cloth ) { if (G.rt > 0) printf("cloth_free_modifier_extern in\n"); // If our solver provides a free function, call it - if ( solvers [clmd->sim_parms->solver_type].free ) - { + if ( solvers [clmd->sim_parms->solver_type].free ) { solvers [clmd->sim_parms->solver_type].free ( clmd ); } @@ -647,11 +633,9 @@ void cloth_free_modifier_extern ( ClothModifierData *clmd ) cloth->numverts = 0; // Free the springs. - if ( cloth->springs != NULL ) - { + if ( cloth->springs != NULL ) { LinkNode *search = cloth->springs; - while (search) - { + while (search) { ClothSpring *spring = search->link; MEM_freeN ( spring ); @@ -708,8 +692,7 @@ static void cloth_to_object (Object *ob, ClothModifierData *clmd, float (*verte /* inverse matrix is not uptodate... */ invert_m4_m4(ob->imat, ob->obmat); - for (i = 0; i < cloth->numverts; i++) - { + for (i = 0; i < cloth->numverts; i++) { copy_v3_v3 (vertexCos[i], cloth->verts[i].x); mul_m4_v3(ob->imat, vertexCos[i]); /* cloth is in global coords */ } @@ -749,17 +732,12 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm ) verts = clothObj->verts; - if (cloth_uses_vgroup(clmd)) - { - for ( i = 0; i < numverts; i++, verts++ ) - { + if (cloth_uses_vgroup(clmd)) { + for ( i = 0; i < numverts; i++, verts++ ) { dvert = dm->getVertData ( dm, i, CD_MDEFORMVERT ); - if ( dvert ) - { - for ( j = 0; j < dvert->totweight; j++ ) - { - if (( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_mass-1)) && (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL )) - { + if ( dvert ) { + for ( j = 0; j < dvert->totweight; j++ ) { + if (( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_mass-1)) && (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL )) { verts->goal = dvert->dw [j].weight; /* goalfac= 1.0f; */ /* UNUSED */ @@ -769,22 +747,18 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm ) */ verts->goal = ( float ) pow ( verts->goal , 4.0f ); - if ( verts->goal >=SOFTGOALSNAP ) - { + if ( verts->goal >=SOFTGOALSNAP ) { verts->flags |= CLOTH_VERT_FLAG_PINNED; } } - if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SCALING ) - { - if ( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_struct-1)) - { + if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SCALING ) { + 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; } } @@ -812,8 +786,7 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d float maxdist = 0; // If we have a clothObject, free it. - if ( clmd->clothObject != NULL ) - { + if ( clmd->clothObject != NULL ) { cloth_free_modifier ( clmd ); if (G.rt > 0) printf("cloth_free_modifier cloth_from_object\n"); @@ -821,8 +794,7 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d // Allocate a new cloth object. clmd->clothObject = MEM_callocN ( sizeof ( Cloth ), "cloth" ); - if ( clmd->clothObject ) - { + if ( clmd->clothObject ) { clmd->clothObject->old_solver_type = 255; // clmd->clothObject->old_collision_type = 255; cloth = clmd->clothObject; @@ -851,10 +823,8 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d verts = clmd->clothObject->verts; // set initial values - for ( i = 0; i < dm->getNumVerts(dm); i++, verts++ ) - { - if (first) - { + for ( i = 0; i < dm->getNumVerts(dm); i++, verts++ ) { + if (first) { copy_v3_v3( verts->x, mvert[i].co ); mul_m4_v3( ob->obmat, verts->x ); @@ -891,18 +861,15 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d // has to be happen before springs are build! cloth_apply_vgroup (clmd, dm); - if ( !cloth_build_springs ( clmd, dm ) ) - { + if ( !cloth_build_springs ( clmd, dm ) ) { cloth_free_modifier ( clmd ); modifier_setError(&(clmd->modifier), "%s", TIP_("Can't build springs.")); printf("cloth_free_modifier cloth_build_springs\n"); return 0; } - for ( i = 0; i < dm->getNumVerts(dm); i++) - { - if ((!(cloth->verts[i].flags & CLOTH_VERT_FLAG_PINNED)) && (cloth->verts[i].goal > ALMOST_ZERO)) - { + for ( i = 0; i < dm->getNumVerts(dm); i++) { + 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); } } @@ -917,8 +884,7 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d 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)); } @@ -937,8 +903,7 @@ static void cloth_from_mesh ( ClothModifierData *clmd, DerivedMesh *dm ) /* Allocate our vertices. */ clmd->clothObject->numverts = numverts; clmd->clothObject->verts = MEM_callocN ( sizeof ( ClothVertex ) * clmd->clothObject->numverts, "clothVertex" ); - if ( clmd->clothObject->verts == NULL ) - { + if ( clmd->clothObject->verts == NULL ) { cloth_free_modifier ( clmd ); modifier_setError(&(clmd->modifier), "%s", TIP_("Out of memory on allocating clmd->clothObject->verts.")); printf("cloth_free_modifier clmd->clothObject->verts\n"); @@ -948,8 +913,7 @@ static void cloth_from_mesh ( ClothModifierData *clmd, DerivedMesh *dm ) // save face information clmd->clothObject->numfaces = numfaces; clmd->clothObject->mfaces = MEM_callocN ( sizeof ( MFace ) * clmd->clothObject->numfaces, "clothMFaces" ); - if ( clmd->clothObject->mfaces == NULL ) - { + if ( clmd->clothObject->mfaces == NULL ) { cloth_free_modifier ( clmd ); modifier_setError(&(clmd->modifier), "%s", TIP_("Out of memory on allocating clmd->clothObject->mfaces.")); printf("cloth_free_modifier clmd->clothObject->mfaces\n"); @@ -977,8 +941,7 @@ 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" ); @@ -1006,11 +969,9 @@ static void cloth_free_errorsprings(Cloth *cloth, EdgeHash *UNUSED(edgehash), Li { unsigned int i = 0; - if ( cloth->springs != NULL ) - { + if ( cloth->springs != NULL ) { LinkNode *search = cloth->springs; - while (search) - { + while (search) { ClothSpring *spring = search->link; MEM_freeN ( spring ); @@ -1021,10 +982,8 @@ static void cloth_free_errorsprings(Cloth *cloth, EdgeHash *UNUSED(edgehash), Li cloth->springs = NULL; } - if (edgelist) - { - for ( i = 0; i < cloth->numverts; i++ ) - { + if (edgelist) { + for ( i = 0; i < cloth->numverts; i++ ) { BLI_linklist_free ( edgelist[i],NULL ); } @@ -1062,8 +1021,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) if (!edgelist) return 0; - for ( i = 0; i < numverts; i++ ) - { + for ( i = 0; i < numverts; i++ ) { edgelist[i] = NULL; } @@ -1074,12 +1032,10 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) edgehash = BLI_edgehash_new(); // structural springs - for ( i = 0; i < numedges; i++ ) - { + for ( i = 0; i < numedges; i++ ) { spring = ( ClothSpring * ) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" ); - if ( spring ) - { + if ( spring ) { spring->ij = MIN2(medge[i].v1, medge[i].v2); spring->kl = MAX2(medge[i].v2, medge[i].v1); spring->restlen = len_v3v3(cloth->verts[spring->kl].xrest, cloth->verts[spring->ij].xrest); @@ -1104,22 +1060,19 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) 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); } // shear springs - for ( i = 0; i < numfaces; i++ ) - { + for ( i = 0; i < numfaces; i++ ) { // triangle faces already have shear springs due to structural geometry if ( !mface[i].v4 ) continue; spring = ( ClothSpring *) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" ); - if (!spring) - { + if (!spring) { cloth_free_errorsprings(cloth, edgehash, edgelist); return 0; } @@ -1140,8 +1093,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; } @@ -1162,15 +1114,13 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) if (numfaces) { // bending springs search2 = cloth->springs; - for ( i = struct_springs; i < struct_springs+shear_springs; i++ ) - { + for ( i = struct_springs; i < struct_springs+shear_springs; i++ ) { if ( !search2 ) break; tspring2 = search2->link; search = edgelist[tspring2->kl]; - while ( search ) - { + while ( search ) { tspring = search->link; index2 = ( ( tspring->ij==tspring2->kl ) ? ( tspring->kl ) : ( tspring->ij ) ); @@ -1181,8 +1131,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; } @@ -1212,16 +1161,14 @@ 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) { spring = ( ClothSpring * ) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" ); - if (!spring) - { + if (!spring) { cloth_free_errorsprings(cloth, edgehash, edgelist); return 0; } @@ -1242,13 +1189,12 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) } /* insert other near springs in edgehash AFTER bending springs are calculated (for selfcolls) */ - for ( i = 0; i < numedges; i++ ) // struct springs + for (i = 0; i < numedges; i++) { /* struct springs */ BLI_edgehash_insert ( edgehash, MIN2(medge[i].v1, medge[i].v2), MAX2(medge[i].v2, medge[i].v1), NULL ); - - for ( i = 0; i < numfaces; i++ ) // edge springs - { - if (mface[i].v4) - { + } + + for (i = 0; i < numfaces; i++) { /* edge springs */ + if (mface[i].v4) { BLI_edgehash_insert ( edgehash, MIN2(mface[i].v1, mface[i].v3), MAX2(mface[i].v3, mface[i].v1), NULL ); BLI_edgehash_insert ( edgehash, MIN2(mface[i].v2, mface[i].v4), MAX2(mface[i].v2, mface[i].v4), NULL ); @@ -1258,10 +1204,8 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) cloth->numsprings = struct_springs + shear_springs + bend_springs; - if ( edgelist ) - { - for ( i = 0; i < numverts; i++ ) - { + if ( edgelist ) { + for ( i = 0; i < numverts; i++ ) { BLI_linklist_free ( edgelist[i],NULL ); } diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index 5b03f73e120..264a251c317 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -80,8 +80,7 @@ void collision_move_object(CollisionModifierData *collmd, float step, float prev float tv[3] = {0, 0, 0}; unsigned int i = 0; - for ( i = 0; i < collmd->numverts; i++ ) - { + for ( i = 0; i < collmd->numverts; i++ ) { sub_v3_v3v3 ( tv, collmd->xnew[i].co, collmd->x[i].co ); VECADDS ( collmd->current_x[i].co, collmd->x[i].co, tv, prevstep ); VECADDS ( collmd->current_xnew[i].co, collmd->x[i].co, tv, step ); @@ -101,8 +100,7 @@ BVHTree *bvhtree_build_from_mvert ( MFace *mfaces, unsigned int numfaces, MVert tree = BLI_bvhtree_new ( numfaces*2, epsilon, 4, 26 ); // fill tree - for ( i = 0; i < numfaces; i++, tface++ ) - { + for ( i = 0; i < numfaces; i++, tface++ ) { copy_v3_v3 ( &co[0*3], x[tface->v1].co ); copy_v3_v3 ( &co[1*3], x[tface->v2].co ); copy_v3_v3 ( &co[2*3], x[tface->v3].co ); @@ -128,10 +126,8 @@ void bvhtree_update_from_mvert ( BVHTree * bvhtree, MFace *faces, int numfaces, if ( !bvhtree ) return; - if ( x ) - { - for ( i = 0; i < numfaces; i++, mfaces++ ) - { + if ( x ) { + for ( i = 0; i < numfaces; i++, mfaces++ ) { copy_v3_v3 ( &co[0*3], x[mfaces->v1].co ); copy_v3_v3 ( &co[1*3], x[mfaces->v2].co ); copy_v3_v3 ( &co[2*3], x[mfaces->v3].co ); @@ -139,8 +135,7 @@ void bvhtree_update_from_mvert ( BVHTree * bvhtree, MFace *faces, int numfaces, copy_v3_v3 ( &co[3*3], x[mfaces->v4].co ); // copy new locations into array - if ( moving && xnew ) - { + if ( moving && xnew ) { // update moving positions copy_v3_v3 ( &co_moving[0*3], xnew[mfaces->v1].co ); copy_v3_v3 ( &co_moving[1*3], xnew[mfaces->v2].co ); @@ -150,8 +145,7 @@ void bvhtree_update_from_mvert ( BVHTree * bvhtree, MFace *faces, int numfaces, ret = BLI_bvhtree_update_node ( bvhtree, i, co, co_moving, ( mfaces->v4 ? 4 : 3 ) ); } - else - { + else { ret = BLI_bvhtree_update_node ( bvhtree, i, co, NULL, ( mfaces->v4 ? 4 : 3 ) ); } @@ -465,8 +459,7 @@ static void collision_compute_barycentric ( float pv[3], float p1[3], float p2[3 d = ( a * c - b * b ); - if ( ABS ( d ) < (double)ALMOST_ZERO ) - { + if ( ABS ( d ) < (double)ALMOST_ZERO ) { *w1 = *w2 = *w3 = 1.0 / 3.0; return; } @@ -504,8 +497,7 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM cloth1 = clmd->clothObject; - for ( ; collpair != collision_end; collpair++ ) - { + for ( ; collpair != collision_end; collpair++ ) { // only handle static collisions here if ( collpair->flag & COLLISION_IN_FUTURE ) continue; @@ -540,8 +532,7 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM // TODO // If v_n_mag < 0 the edges are approaching each other. - if ( magrelVel > ALMOST_ZERO ) - { + if ( magrelVel > ALMOST_ZERO ) { // Calculate Impulse magnitude to stop all motion in normal direction. float magtangent = 0, repulse = 0, d = 0; double impulse = 0.0; @@ -558,8 +549,7 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM magtangent = MIN2 ( clmd->coll_parms->friction * 0.01f * magrelVel, sqrtf( dot_v3v3( vrel_t_pre,vrel_t_pre ) ) ); // Apply friction impulse. - if ( magtangent > ALMOST_ZERO ) - { + if ( magtangent > ALMOST_ZERO ) { normalize_v3( vrel_t_pre ); impulse = magtangent / ( 1.0f + w1*w1 + w2*w2 + w3*w3 ); // 2.0 * @@ -587,8 +577,7 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM spf = (float)clmd->sim_parms->stepsPerFrame / clmd->sim_parms->timescale; d = clmd->coll_parms->epsilon*8.0f/9.0f + epsilon2*8.0f/9.0f - collpair->distance; - if ( ( magrelVel < 0.1f*d*spf ) && ( d > ALMOST_ZERO ) ) - { + if ( ( magrelVel < 0.1f*d*spf ) && ( d > ALMOST_ZERO ) ) { repulse = MIN2 ( d*1.0f/spf, 0.1f*d*spf - magrelVel ); // stay on the safe side and clamp repulse @@ -685,10 +674,8 @@ static CollPair* cloth_edge_collision ( ModifierData *md1, ModifierData *md2, face2 = & ( collmd->mfaces[overlap->indexB] ); // check all 4 possible collisions - for ( i = 0; i < 4; i++ ) - { - if ( i == 0 ) - { + for ( i = 0; i < 4; i++ ) { + if ( i == 0 ) { // fill faceA ap1 = face1->v1; ap2 = face1->v2; @@ -699,10 +686,8 @@ static CollPair* cloth_edge_collision ( ModifierData *md1, ModifierData *md2, bp2 = face2->v2; bp3 = face2->v3; } - else if ( i == 1 ) - { - if ( face1->v4 ) - { + else if ( i == 1 ) { + if ( face1->v4 ) { // fill faceA ap1 = face1->v1; ap2 = face1->v3; @@ -717,10 +702,8 @@ static CollPair* cloth_edge_collision ( ModifierData *md1, ModifierData *md2, continue; } } - if ( i == 2 ) - { - if ( face2->v4 ) - { + if ( i == 2 ) { + if ( face2->v4 ) { // fill faceA ap1 = face1->v1; ap2 = face1->v2; @@ -735,10 +718,8 @@ static CollPair* cloth_edge_collision ( ModifierData *md1, ModifierData *md2, continue; } } - else if ( i == 3 ) - { - if ( face1->v4 && face2->v4 ) - { + else if ( i == 3 ) { + if ( face1->v4 && face2->v4 ) { // fill faceA ap1 = face1->v1; ap2 = face1->v3; @@ -847,8 +828,7 @@ static int cloth_edge_collision_response_moving ( ClothModifierData *clmd, Colli cloth1 = clmd->clothObject; - for ( ; collpair != collision_end; collpair++ ) - { + for ( ; collpair != collision_end; collpair++ ) { if (!(collpair->flag & COLLISION_IS_EDGES)) continue; @@ -865,8 +845,7 @@ static int cloth_edge_collision_response_moving ( ClothModifierData *clmd, Colli magrelVel = dot_v3v3 ( relativeVelocity, collpair->normal ); // If v_n_mag < 0 the edges are approaching each other. - if ( magrelVel > ALMOST_ZERO ) - { + if ( magrelVel > ALMOST_ZERO ) { // Calculate Impulse magnitude to stop all motion in normal direction. float magtangent = 0, repulse = 0, d = 0; double impulse = 0.0; @@ -885,8 +864,7 @@ static int cloth_edge_collision_response_moving ( ClothModifierData *clmd, Colli magtangent = MIN2 ( clmd->coll_parms->friction * 0.01 * magrelVel,sqrt ( dot_v3v3 ( vrel_t_pre,vrel_t_pre ) ) ); // Apply friction impulse. - if ( magtangent > ALMOST_ZERO ) - { + if ( magtangent > ALMOST_ZERO ) { normalize_v3( vrel_t_pre ); impulse = magtangent; @@ -906,8 +884,7 @@ static int cloth_edge_collision_response_moving ( ClothModifierData *clmd, Colli spf = (float)clmd->sim_parms->stepsPerFrame / clmd->sim_parms->timescale; d = collpair->distance; - if ( ( magrelVel < 0.1*d*spf && ( d > ALMOST_ZERO ) ) ) - { + if ( ( magrelVel < 0.1*d*spf && ( d > ALMOST_ZERO ) ) ) { repulse = MIN2 ( d*1.0/spf, 0.1*d*spf - magrelVel ); // stay on the safe side and clamp repulse @@ -949,8 +926,7 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM cloth1 = clmd->clothObject; - for ( ; collpair != collision_end; collpair++ ) - { + for ( ; collpair != collision_end; collpair++ ) { if (collpair->flag & COLLISION_IS_EDGES) continue; @@ -967,8 +943,7 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM magrelVel = dot_v3v3 ( relativeVelocity, collpair->normal ); // If v_n_mag < 0 the edges are approaching each other. - if ( magrelVel > ALMOST_ZERO ) - { + if ( magrelVel > ALMOST_ZERO ) { // Calculate Impulse magnitude to stop all motion in normal direction. float magtangent = 0, repulse = 0, d = 0; double impulse = 0.0; @@ -985,8 +960,7 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM magtangent = MIN2 ( clmd->coll_parms->friction * 0.01 * magrelVel,sqrt ( dot_v3v3 ( vrel_t_pre,vrel_t_pre ) ) ); // Apply friction impulse. - if ( magtangent > ALMOST_ZERO ) - { + if ( magtangent > ALMOST_ZERO ) { normalize_v3( vrel_t_pre ); impulse = magtangent; // 2.0 * @@ -1006,8 +980,7 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM spf = (float)clmd->sim_parms->stepsPerFrame / clmd->sim_parms->timescale; d = -collpair->distance; - if ( ( magrelVel < 0.1*d*spf ) && ( d > ALMOST_ZERO ) ) - { + if ( ( magrelVel < 0.1*d*spf ) && ( d > ALMOST_ZERO ) ) { repulse = MIN2 ( d*1.0/spf, 0.1*d*spf - magrelVel ); // stay on the safe side and clamp repulse @@ -1034,8 +1007,7 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM magrelVel = dot_v3v3 ( relativeVelocity, collpair->normal ); // If v_n_mag < 0 the edges are approaching each other. - if ( magrelVel > ALMOST_ZERO ) - { + if ( magrelVel > ALMOST_ZERO ) { // Calculate Impulse magnitude to stop all motion in normal direction. float magtangent = 0, repulse = 0, d = 0; double impulse = 0.0; @@ -1052,8 +1024,7 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM magtangent = MIN2 ( clmd->coll_parms->friction * 0.01 * magrelVel,sqrt ( dot_v3v3 ( vrel_t_pre,vrel_t_pre ) ) ); // Apply friction impulse. - if ( magtangent > ALMOST_ZERO ) - { + if ( magtangent > ALMOST_ZERO ) { normalize_v3( vrel_t_pre ); impulse = magtangent; // 2.0 * @@ -1072,8 +1043,7 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM spf = (float)clmd->sim_parms->stepsPerFrame / clmd->sim_parms->timescale; d = -collpair->distance; - if ( ( magrelVel < 0.1*d*spf ) && ( d > ALMOST_ZERO ) ) - { + if ( ( magrelVel < 0.1*d*spf ) && ( d > ALMOST_ZERO ) ) { repulse = MIN2 ( d*1.0/spf, 0.1*d*spf - magrelVel ); // stay on the safe side and clamp repulse @@ -1202,10 +1172,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, BVHTree face2 = & ( collmd->mfaces[overlap->indexB] ); // check all 4 possible collisions - for ( i = 0; i < 4; i++ ) - { - if ( i == 0 ) - { + for ( i = 0; i < 4; i++ ) { + if ( i == 0 ) { // fill faceA ap1 = face1->v1; ap2 = face1->v2; @@ -1216,10 +1184,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, BVHTree bp2 = face2->v2; bp3 = face2->v3; } - else if ( i == 1 ) - { - if ( face1->v4 ) - { + else if ( i == 1 ) { + if ( face1->v4 ) { // fill faceA ap1 = face1->v1; ap2 = face1->v3; @@ -1234,10 +1200,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, BVHTree continue; } } - if ( i == 2 ) - { - if ( face2->v4 ) - { + if ( i == 2 ) { + if ( face2->v4 ) { // fill faceA ap1 = face1->v1; ap2 = face1->v2; @@ -1252,10 +1216,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, BVHTree continue; } } - else if ( i == 3 ) - { - if ( face1->v4 && face2->v4 ) - { + else if ( i == 3 ) { + if ( face1->v4 && face2->v4 ) { // fill faceA ap1 = face1->v1; ap2 = face1->v3; @@ -1417,10 +1379,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, face2 = & ( collmd->mfaces[overlap->indexB] ); // check all 4 possible collisions - for ( i = 0; i < 4; i++ ) - { - if ( i == 0 ) - { + for ( i = 0; i < 4; i++ ) { + if ( i == 0 ) { // fill faceA collpair->ap1 = face1->v1; collpair->ap2 = face1->v2; @@ -1431,10 +1391,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, collpair->bp2 = face2->v2; collpair->bp3 = face2->v3; } - else if ( i == 1 ) - { - if ( face1->v4 ) - { + else if ( i == 1 ) { + if ( face1->v4 ) { // fill faceA collpair->ap1 = face1->v1; collpair->ap2 = face1->v4; @@ -1448,10 +1406,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, else i++; } - if ( i == 2 ) - { - if ( face2->v4 ) - { + if ( i == 2 ) { + if ( face2->v4 ) { // fill faceA collpair->ap1 = face1->v1; collpair->ap2 = face1->v2; @@ -1465,10 +1421,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, else break; } - else if ( i == 3 ) - { - if ( face1->v4 && face2->v4 ) - { + else if ( i == 3 ) { + if ( face1->v4 && face2->v4 ) { // fill faceA collpair->ap1 = face1->v1; collpair->ap2 = face1->v4; @@ -1513,8 +1467,7 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, distance = 2.0 * (double)( epsilon1 + epsilon2 + ALMOST_ZERO ); #endif - if ( distance <= ( epsilon1 + epsilon2 + ALMOST_ZERO ) ) - { + if ( distance <= ( epsilon1 + epsilon2 + ALMOST_ZERO ) ) { normalize_v3_v3( collpair->normal, collpair->vector ); collpair->distance = distance; @@ -2283,14 +2236,12 @@ static void cloth_bvh_objcollisions_nearcheck ( ClothModifierData * clmd, Collis #ifdef WITH_ELTOPO machine_epsilon_offset(clmd->clothObject); - for ( i = 0; i < numresult; i++ ) - { + for ( i = 0; i < numresult; i++ ) { *collisions_index = cloth_collision ( (ModifierData *)clmd, (ModifierData *)collmd, overlap+i, *collisions_index, dt, tri_visithash, arena ); } - for ( i = 0; i < numresult; i++ ) - { + for ( i = 0; i < numresult; i++ ) { *collisions_index = cloth_edge_collision ( (ModifierData *)clmd, (ModifierData *)collmd, overlap+i, *collisions_index, visithash, arena ); } @@ -2298,8 +2249,7 @@ static void cloth_bvh_objcollisions_nearcheck ( ClothModifierData * clmd, Collis BLI_ghash_free(tri_visithash, NULL, NULL); BLI_memarena_free(arena); #else /* WITH_ELTOPO */ - for ( i = 0; i < numresult; i++ ) - { + for ( i = 0; i < numresult; i++ ) { *collisions_index = cloth_collision ( (ModifierData *)clmd, (ModifierData *)collmd, overlap+i, *collisions_index, dt ); } @@ -2323,12 +2273,10 @@ static int cloth_bvh_objcollisions_resolve ( ClothModifierData * clmd, Collision // process all collisions (calculate impulses, TODO: also repulses if distance too short) result = 1; - for ( j = 0; j < 5; j++ ) // 5 is just a value that ensures convergence - { + for ( j = 0; j < 5; j++ ) { /* 5 is just a value that ensures convergence */ result = 0; - if ( collmd->bvhtree ) - { + if ( collmd->bvhtree ) { #ifdef WITH_ELTOPO result += cloth_collision_response_moving(clmd, collmd, collisions, collisions_index); result += cloth_edge_collision_response_moving(clmd, collmd, collisions, collisions_index); @@ -2339,14 +2287,11 @@ static int cloth_bvh_objcollisions_resolve ( ClothModifierData * clmd, Collision { #else // apply impulses in parallel - if ( result ) - { + if (result) { #endif - for ( i = 0; i < numverts; i++ ) - { + for (i = 0; i < numverts; i++) { // calculate "velocities" (just xnew = xold + v; no dt in v) - if ( verts[i].impulse_count ) - { + if (verts[i].impulse_count) { VECADDMUL ( verts[i].tv, verts[i].impulse, 1.0f / verts[i].impulse_count ); copy_v3_v3 ( verts[i].impulse, tnull ); verts[i].impulse_count = 0; @@ -2402,8 +2347,7 @@ 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; @@ -2435,8 +2379,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] ); } @@ -2449,12 +2392,9 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl //////////////////////////////////////////////////////////// // verts come from clmd - for ( i = 0; i < numverts; i++ ) - { - if ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL ) - { - if ( verts [i].flags & CLOTH_VERT_FLAG_PINNED ) - { + for ( i = 0; i < numverts; i++ ) { + if ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL ) { + if ( verts [i].flags & CLOTH_VERT_FLAG_PINNED ) { continue; } } @@ -2467,10 +2407,8 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl //////////////////////////////////////////////////////////// // Test on *simple* selfcollisions //////////////////////////////////////////////////////////// - if ( clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_SELF ) - { - for (l = 0; l < (unsigned int)clmd->coll_parms->self_loop_count; l++) - { + if ( clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_SELF ) { + for (l = 0; l < (unsigned int)clmd->coll_parms->self_loop_count; l++) { // TODO: add coll quality rounds again BVHTreeOverlap *overlap = NULL; unsigned int result = 0; @@ -2483,14 +2421,12 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl verts = cloth->verts; - if ( cloth->bvhselftree ) - { - // search for overlapping collision pairs + if ( cloth->bvhselftree ) { + // search for overlapping collision pairs overlap = BLI_bvhtree_overlap ( cloth->bvhselftree, cloth->bvhselftree, &result ); // #pragma omp parallel for private(k, i, j) schedule(static) - for ( k = 0; k < result; k++ ) - { + for ( k = 0; k < result; k++ ) { float temp[3]; float length = 0; float mindistance; @@ -2500,8 +2436,7 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl mindistance = clmd->coll_parms->selfepsilon* ( cloth->verts[i].avg_spring_len + cloth->verts[j].avg_spring_len ); - if ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL ) - { + if ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL ) { if ( ( cloth->verts [i].flags & CLOTH_VERT_FLAG_PINNED ) && ( cloth->verts [j].flags & CLOTH_VERT_FLAG_PINNED ) ) { @@ -2514,29 +2449,24 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl if ( ( ABS ( temp[0] ) > mindistance ) || ( ABS ( temp[1] ) > mindistance ) || ( ABS ( temp[2] ) > mindistance ) ) continue; // check for adjacent points (i must be smaller j) - if ( BLI_edgehash_haskey ( cloth->edgehash, MIN2(i, j), MAX2(i, j) ) ) - { + if ( BLI_edgehash_haskey ( cloth->edgehash, MIN2(i, j), MAX2(i, j) ) ) { continue; } length = normalize_v3( temp ); - if ( length < mindistance ) - { + if ( length < mindistance ) { float correction = mindistance - length; - if ( cloth->verts [i].flags & CLOTH_VERT_FLAG_PINNED ) - { + if ( cloth->verts [i].flags & CLOTH_VERT_FLAG_PINNED ) { mul_v3_fl( temp, -correction ); VECADD ( verts[j].tx, verts[j].tx, temp ); } - else if ( cloth->verts [j].flags & CLOTH_VERT_FLAG_PINNED ) - { + else if ( cloth->verts [j].flags & CLOTH_VERT_FLAG_PINNED ) { mul_v3_fl( temp, correction ); VECADD ( verts[i].tx, verts[i].tx, temp ); } - else - { + else { mul_v3_fl( temp, correction * -0.5 ); VECADD ( verts[j].tx, verts[j].tx, temp ); @@ -2560,12 +2490,9 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl //////////////////////////////////////////////////////////// // SELFCOLLISIONS: update velocities //////////////////////////////////////////////////////////// - if ( ret2 ) - { - for ( i = 0; i < cloth->numverts; i++ ) - { - if ( ! ( verts [i].flags & CLOTH_VERT_FLAG_PINNED ) ) - { + if ( ret2 ) { + for ( i = 0; i < cloth->numverts; i++ ) { + if ( ! ( verts [i].flags & CLOTH_VERT_FLAG_PINNED ) ) { sub_v3_v3v3 ( verts[i].tv, verts[i].tx, verts[i].txold ); } } diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 25391a34689..2d5631509b4 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -202,7 +202,7 @@ void curvemap_reset(CurveMap *cuma, rctf *clipr, int preset, int slope) if (cuma->curve) MEM_freeN(cuma->curve); - switch(preset) { + switch (preset) { case CURVE_PRESET_LINE: cuma->totpoint= 2; break; case CURVE_PRESET_SHARP: cuma->totpoint= 4; break; case CURVE_PRESET_SMOOTH: cuma->totpoint= 4; break; @@ -214,7 +214,7 @@ void curvemap_reset(CurveMap *cuma, rctf *clipr, int preset, int slope) cuma->curve= MEM_callocN(cuma->totpoint*sizeof(CurveMapPoint), "curve points"); - switch(preset) { + switch (preset) { case CURVE_PRESET_LINE: cuma->curve[0].x= clipr->xmin; cuma->curve[0].y= clipr->ymax; @@ -252,10 +252,9 @@ void curvemap_reset(CurveMap *cuma, rctf *clipr, int preset, int slope) case CURVE_PRESET_MID9: { int i; - for (i=0; i < cuma->totpoint; i++) - { - cuma->curve[i].x= i / ((float)cuma->totpoint-1); - cuma->curve[i].y= 0.5; + for (i = 0; i < cuma->totpoint; i++) { + cuma->curve[i].x = i / ((float)cuma->totpoint - 1); + cuma->curve[i].y = 0.5; } } break; diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 0a6e8a163cc..82a908eaf57 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -3439,8 +3439,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}; float no[3] = {0.0f, 0.0f, 0.0f}; @@ -3461,12 +3460,10 @@ 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); - switch(scon->shrinkType) - { + switch (scon->shrinkType) { case MOD_SHRINKWRAP_NEAREST_SURFACE: case MOD_SHRINKWRAP_NEAREST_VERTEX: @@ -3475,8 +3472,7 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr else bvhtree_from_mesh_faces(&treeData, target, 0.0, 2, 6); - if (treeData.tree == NULL) - { + if (treeData.tree == NULL) { fail = TRUE; break; } @@ -3506,14 +3502,12 @@ 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; } @@ -3542,8 +3536,7 @@ static void shrinkwrap_evaluate (bConstraint *UNUSED(con), bConstraintOb *cob, L bConstraintTarget *ct= targets->first; /* only evaluate if there is a target */ - if (VALID_CONS_TARGET(ct)) - { + if (VALID_CONS_TARGET(ct)) { copy_v3_v3(cob->matrix[3], ct->matrix[3]); } } diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index e9dd4d01b0e..7a5b4ef9b24 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -777,7 +777,7 @@ int CTX_data_mode_enum(const bContext *C) Object *obedit= CTX_data_edit_object(C); if (obedit) { - switch(obedit->type) { + switch (obedit->type) { case OB_MESH: return CTX_MODE_EDIT_MESH; case OB_CURVE: diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 9232fe8ec04..e5b2e5f69c7 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -636,7 +636,7 @@ static void calcknots(float *knots, const short pnts, const short order, const s float k; int a; - switch(flag & (CU_NURB_ENDPOINT|CU_NURB_BEZIER)) { + switch (flag & (CU_NURB_ENDPOINT|CU_NURB_BEZIER)) { case CU_NURB_ENDPOINT: k= 0.0; for (a=1; a <= pnts_order; a++) { @@ -2038,7 +2038,7 @@ static void make_bevel_list_3D_tangent(BevList *bl) static void make_bevel_list_3D(BevList *bl, int smooth_iter, int twist_mode) { - switch(twist_mode) { + switch (twist_mode) { case CU_TWIST_TANGENT: make_bevel_list_3D_tangent(bl); break; diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 1514716d717..ee8e57d5a3e 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -2337,7 +2337,10 @@ int CustomData_layer_has_math(struct CustomData *data, int layer_n) const LayerTypeInfo *typeInfo = layerType_getInfo(data->layers[layer_n].type); if (typeInfo->equal && typeInfo->add && typeInfo->multiply && - typeInfo->initminmax && typeInfo->dominmax) return 1; + typeInfo->initminmax && typeInfo->dominmax) + { + return 1; + } return 0; } @@ -2684,7 +2687,9 @@ int CustomData_verify_versions(struct CustomData *data, int index) if (!typeInfo->defaultname && (index > 0) && data->layers[index-1].type == layer->type) + { keeplayer = 0; /* multiple layers of which we only support one */ + } } if (!keeplayer) { diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index 1232177fa10..3e0c947ff4a 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -479,7 +479,7 @@ void flip_side_name(char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_ /* first case; separator . - _ with extensions r R l L */ if (is_char_sep(name[len - 2]) ) { - switch(name[len - 1]) { + switch (name[len - 1]) { case 'l': prefix[len - 1] = 0; strcpy(replace, "r"); @@ -500,7 +500,7 @@ void flip_side_name(char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_ } /* case; beginning with r R l L , with separator after it */ else if (is_char_sep(name[1]) ) { - switch(name[0]) { + switch (name[0]) { case 'l': strcpy(replace, "r"); BLI_strncpy(suffix, name + 1, sizeof(suffix)); diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index aa6d42977ca..246c973169e 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -462,7 +462,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O if (ob->parent) { node2 = dag_get_node(dag,ob->parent); - switch(ob->partype) { + switch (ob->partype) { case PARSKEL: dag_add_relation(dag,node2,node,DAG_RL_DATA_DATA|DAG_RL_OB_OB, "Parent"); break; @@ -2245,7 +2245,7 @@ static void dag_object_time_update_flags(Object *ob) Curve *cu; Lattice *lt; - switch(ob->type) { + switch (ob->type) { case OB_MESH: me= ob->data; if (me->key) { diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 01d5d6ef2ad..fcd80698d5c 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -228,7 +228,7 @@ void count_displist(ListBase *lb, int *totvert, int *totface) dl= lb->first; while (dl) { - switch(dl->type) { + switch (dl->type) { case DL_SURF: *totvert+= dl->nr*dl->parts; *totface+= (dl->nr-1)*(dl->parts-1); diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 9ce4d68eeed..31544dd5ca0 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -231,13 +231,22 @@ static int dynamicPaint_surfaceNumOfPoints(DynamicPaintSurface *surface) /* checks whether surface's format/type has realtime preview */ int dynamicPaint_surfaceHasColorPreview(DynamicPaintSurface *surface) { - if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) return 0; + if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) { + return 0; + } else if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) { if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE || - surface->type == MOD_DPAINT_SURFACE_T_WAVE) return 0; - else return 1; + surface->type == MOD_DPAINT_SURFACE_T_WAVE) + { + return 0; + } + else { + return 1; + } + } + else { + return 1; } - else return 1; } /* get currently active surface (in user interface) */ @@ -393,11 +402,15 @@ void dynamicPaintSurface_updateType(struct DynamicPaintSurface *surface) static int surface_totalSamples(DynamicPaintSurface *surface) { if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ && - surface->flags & MOD_DPAINT_ANTIALIAS) - return (surface->data->total_points*5); + surface->flags & MOD_DPAINT_ANTIALIAS) + { + return (surface->data->total_points * 5); + } if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX && - surface->flags & MOD_DPAINT_ANTIALIAS && surface->data->adj_data) + surface->flags & MOD_DPAINT_ANTIALIAS && surface->data->adj_data) + { return (surface->data->total_points+surface->data->adj_data->total_targets); + } return surface->data->total_points; } @@ -548,8 +561,7 @@ static int surface_getBrushFlags(DynamicPaintSurface *surface, Scene *scene) else base = scene->base.first; - while (base || go) - { + while (base || go) { brushObj = NULL; /* select object */ @@ -559,8 +571,7 @@ static int surface_getBrushFlags(DynamicPaintSurface *surface, Scene *scene) else brushObj = base->object; - if (!brushObj) - { + if (!brushObj) { if (surface->brush_group) go = go->next; else base= base->next; continue; @@ -572,12 +583,10 @@ static int surface_getBrushFlags(DynamicPaintSurface *surface, Scene *scene) 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; - if (pmd2->brush) - { + if (pmd2->brush) { DynamicPaintBrushSettings *brush = pmd2->brush; if (brush->flags & MOD_DPAINT_USES_VELOCITY) @@ -888,8 +897,10 @@ void surface_freeUnusedData(DynamicPaintSurface *surface) /* free bakedata if not active or surface is baked */ if (!(surface->flags & MOD_DPAINT_ACTIVE) || - (surface->pointcache && surface->pointcache->flag & PTCACHE_BAKED)) + (surface->pointcache && surface->pointcache->flag & PTCACHE_BAKED)) + { free_bakeData(surface->data); + } } void dynamicPaint_freeSurfaceData(DynamicPaintSurface *surface) @@ -1219,9 +1230,13 @@ static int surface_usesAdjData(DynamicPaintSurface *surface) { if (surface_usesAdjDistance(surface)) return 1; if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX && - surface->flags & MOD_DPAINT_ANTIALIAS) return 1; - - return 0; + surface->flags & MOD_DPAINT_ANTIALIAS) + { + return 1; + } + else { + return 0; + } } /* initialize surface adjacency data */ @@ -1294,10 +1309,12 @@ static void dynamicPaint_initAdjacencyData(DynamicPaintSurface *surface, int for /* now check if total number of edges+faces for * each vertex is even, if not -> vertex is on mesh edge */ for (i=0; itotal_points; i++) { - if ((temp_data[i]%2) || - temp_data[i] < 4) + if ((temp_data[i] % 2) || + (temp_data[i] < 4)) + { ad->flags[i] |= ADJ_ON_MESH_EDGE; - + } + /* reset temp data */ temp_data[i] = 0; } @@ -1863,8 +1880,10 @@ static void dynamicPaint_frameUpdate(DynamicPaintModifierData *pmd, Scene *scene /* restore canvas derivedmesh if required */ if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE && - surface->flags & MOD_DPAINT_DISP_INCREMENTAL && surface->next) + surface->flags & MOD_DPAINT_DISP_INCREMENTAL && surface->next) + { canvas_copyDerivedMesh(canvas, dm); + } BKE_ptcache_validate(cache, surface->current_frame); BKE_ptcache_write(&pid, surface->current_frame); @@ -2042,9 +2061,12 @@ static int dynamicPaint_findNeighbourPixel(PaintUVPoint *tempPoints, DerivedMesh //printf("connected UV : %f,%f & %f,%f - %f,%f & %f,%f\n", s_uv1[0], s_uv1[1], s_uv2[0], s_uv2[1], t_uv1[0], t_uv1[1], t_uv2[0], t_uv2[1]); if (((s_uv1[0] == t_uv1[0] && s_uv1[1] == t_uv1[1]) && - (s_uv2[0] == t_uv2[0] && s_uv2[1] == t_uv2[1]) ) || - ((s_uv2[0] == t_uv1[0] && s_uv2[1] == t_uv1[1]) && - (s_uv1[0] == t_uv2[0] && s_uv1[1] == t_uv2[1]) )) return ((px+neighX[n_index]) + w*(py+neighY[n_index])); + (s_uv2[0] == t_uv2[0] && s_uv2[1] == t_uv2[1]) ) || + ((s_uv2[0] == t_uv1[0] && s_uv2[1] == t_uv1[1]) && + (s_uv1[0] == t_uv2[0] && s_uv1[1] == t_uv2[1]) )) + { + return ((px+neighX[n_index]) + w*(py+neighY[n_index])); + } /* * Find a point that is relatively at same edge position @@ -2185,11 +2207,9 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface) */ if (!error) { #pragma omp parallel for schedule(static) - for (ty = 0; ty < h; ty++) - { + for (ty = 0; ty < h; ty++) { int tx; - for (tx = 0; tx < w; tx++) - { + for (tx = 0; tx < w; tx++) { int i, sample; int index = tx+w*ty; PaintUVPoint *tPoint = (&tempPoints[index]); @@ -2257,8 +2277,7 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface) /* If collision wasn't found but the face is a quad * do another check for the second half */ - if ((!isInside) && mface[i].v4) - { + if ((!isInside) && mface[i].v4) { /* change d2 to test the other half */ sub_v2_v2v2(d2, tface[i].uv[3], tface[i].uv[0]); // uv3 - uv0 @@ -2330,11 +2349,9 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface) * (To avoid seams on uv island edges) */ #pragma omp parallel for schedule(static) - for (ty = 0; ty < h; ty++) - { + for (ty = 0; ty < h; ty++) { int tx; - for (tx = 0; tx < w; tx++) - { + for (tx = 0; tx < w; tx++) { int index = tx+w*ty; PaintUVPoint *tPoint = (&tempPoints[index]); @@ -2408,11 +2425,9 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface) * When base loop is over convert found neighbor indexes to real ones * Also count the final number of active surface points */ - for (ty = 0; ty < h; ty++) - { + for (ty = 0; ty < h; ty++) { int tx; - for (tx = 0; tx < w; tx++) - { + for (tx = 0; tx < w; tx++) { int index = tx+w*ty; PaintUVPoint *tPoint = (&tempPoints[index]); @@ -2440,11 +2455,9 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface) if (sData->adj_data) { PaintAdjData *ed = sData->adj_data; unsigned int n_pos = 0; - for (ty = 0; ty < h; ty++) - { + for (ty = 0; ty < h; ty++) { int tx; - for (tx = 0; tx < w; tx++) - { + for (tx = 0; tx < w; tx++) { int i, index = tx+w*ty; if (tempPoints[index].face_index != -1) { @@ -2576,8 +2589,7 @@ void dynamicPaint_outputSurfaceImage(DynamicPaintSurface *surface, char* filenam if (ibuf == NULL) {setError(surface->canvas, "Image save failed: Not enough free memory.");return;} #pragma omp parallel for schedule(static) - for (index = 0; index < sData->total_points; index++) - { + for (index = 0; index < sData->total_points; index++) { int pos=f_data->uv_p[index].pixel_index*4; /* image buffer position */ /* Set values of preferred type */ @@ -2759,8 +2771,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; hit->no[0] = (quad) ? 1.0f : 0.0f; @@ -2799,8 +2810,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; copy_v3_v3(nearest->co, nearest_tmp); @@ -3188,8 +3198,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, /* check bounding box collision */ 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)) - { + if (bvhtree_from_mesh_faces(&treeData, dm, 0.0f, 4, 8)) { int c_index; int total_cells = grid->dim[0]*grid->dim[1]*grid->dim[2]; @@ -3203,8 +3212,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, /* loop through cell points and process brush */ #pragma omp parallel for schedule(static) - for (id = 0; id < grid->s_num[c_index]; id++) - { + for (id = 0; id < grid->s_num[c_index]; id++) { int index = grid->t_index[grid->s_pos[c_index] + id]; int ss, samples = bData->s_num[index]; float total_sample = (float)samples; @@ -3220,8 +3228,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, total_sample = gaussianTotal; /* Supersampling */ - for (ss=0; sscollision == 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 */ /* For optimization sake, hit point normal isn't calculated in ray cast loop */ @@ -3277,8 +3283,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, /* If ray and hit face normal are facing same direction * hit point is inside a closed mesh. */ - if (dot>=0) - { + if (dot>=0) { float dist = hit.dist; int f_index = hit.index; @@ -3342,8 +3347,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 */ hQuad = (hit.no[0] == 1.0f); @@ -3446,8 +3450,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, /* * Process hit color and alpha */ - if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) - { + if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) { float sampleColor[3]; float alpha_factor = 1.0f; @@ -3589,8 +3592,7 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface, BLI_begin_threaded_malloc(); /* only continue if particle bb is close enough to canvas bb */ - if (boundsIntersectDist(&grid->grid_bounds, &part_bb, range)) - { + if (boundsIntersectDist(&grid->grid_bounds, &part_bb, range)) { int c_index; int total_cells = grid->dim[0]*grid->dim[1]*grid->dim[2]; @@ -3603,13 +3605,14 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface, /* check cell bounding box */ if (!grid->s_num[c_index] || - !boundsIntersectDist(&grid->bounds[c_index], &part_bb, range)) + !boundsIntersectDist(&grid->bounds[c_index], &part_bb, range)) + { continue; + } /* loop through cell points */ #pragma omp parallel for schedule(static) - for (id = 0; id < grid->s_num[c_index]; id++) - { + for (id = 0; id < grid->s_num[c_index]; id++) { int index = grid->t_index[grid->s_pos[c_index] + id]; float disp_intersect = 0.0f; float radius = 0.0f; @@ -3714,8 +3717,7 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface, } } - if (strength > 0.001f) - { + if (strength > 0.001f) { float paintColor[4] = {0.0f}; float depth = 0.0f; @@ -3781,8 +3783,7 @@ static int dynamicPaint_paintSinglePoint(DynamicPaintSurface *surface, float *po * Loop through every surface point */ #pragma omp parallel for schedule(static) - for (index = 0; index < sData->total_points; index++) - { + for (index = 0; index < sData->total_points; index++) { float distance = len_v3v3(pointCoord, bData->realCoord[bData->s_pos[index]].v); float colorband[4] = {0.0f}; float strength; @@ -3891,8 +3892,7 @@ static void dynamicPaint_prepareAdjacencyData(DynamicPaintSurface *surface, int if (!bNeighs) return; #pragma omp parallel for schedule(static) - for (index = 0; index < sData->total_points; index++) - { + for (index = 0; index < sData->total_points; index++) { int i; int numOfNeighs = adj_data->n_num[index]; @@ -3911,8 +3911,7 @@ static void dynamicPaint_prepareAdjacencyData(DynamicPaintSurface *surface, int /* calculate average values (single thread) */ bData->average_dist = 0.0f; - for (index = 0; index < sData->total_points; index++) - { + for (index = 0; index < sData->total_points; index++) { int i; int numOfNeighs = adj_data->n_num[index]; @@ -4080,8 +4079,7 @@ static int dynamicPaint_prepareEffectStep(DynamicPaintSurface *surface, Scene *s if (*force) { #pragma omp parallel for schedule(static) - for (index = 0; index < sData->total_points; index++) - { + for (index = 0; index < sData->total_points; index++) { float forc[3] = {0}; /* apply force fields */ @@ -4121,8 +4119,7 @@ static int dynamicPaint_prepareEffectStep(DynamicPaintSurface *surface, Scene *s } /* calculate average values (single thread) */ - for (index = 0; index < sData->total_points; index++) - { + for (index = 0; index < sData->total_points; index++) { average_force += (*force)[index*4+3]; } average_force /= sData->total_points; @@ -4171,8 +4168,7 @@ static void dynamicPaint_doEffectStep(DynamicPaintSurface *surface, float *force memcpy(prevPoint, sData->type_data, sData->total_points*sizeof(struct PaintPoint)); #pragma omp parallel for schedule(static) - for (index = 0; index < sData->total_points; index++) - { + for (index = 0; index < sData->total_points; index++) { int i; int numOfNeighs = sData->adj_data->n_num[index]; PaintPoint *pPoint = &((PaintPoint*)sData->type_data)[index]; @@ -4214,8 +4210,7 @@ static void dynamicPaint_doEffectStep(DynamicPaintSurface *surface, float *force memcpy(prevPoint, sData->type_data, sData->total_points*sizeof(struct PaintPoint)); #pragma omp parallel for schedule(static) - for (index = 0; index < sData->total_points; index++) - { + for (index = 0; index < sData->total_points; index++) { int i; int numOfNeighs = sData->adj_data->n_num[index]; float totalAlpha = 0.0f; @@ -4256,8 +4251,7 @@ static void dynamicPaint_doEffectStep(DynamicPaintSurface *surface, float *force /* * Drip Effect */ - if (surface->effect & MOD_DPAINT_EFFECT_DO_DRIP && force) - { + if (surface->effect & MOD_DPAINT_EFFECT_DO_DRIP && force) { float eff_scale = distance_scale*EFF_MOVEMENT_PER_FRAME*timescale/2.0f; /* Copy current surface to the previous points array to read unmodified values */ memcpy(prevPoint, sData->type_data, sData->total_points*sizeof(struct PaintPoint)); @@ -4335,8 +4329,7 @@ void dynamicPaint_doWaveStep(DynamicPaintSurface *surface, float timescale) if (!prevPoint) return; /* calculate average neigh distance (single thread) */ - for (index = 0; index < sData->total_points; index++) - { + for (index = 0; index < sData->total_points; index++) { int i; int numOfNeighs = sData->adj_data->n_num[index]; @@ -4435,8 +4428,7 @@ static void dynamicPaint_surfacePreStep(DynamicPaintSurface *surface, float time int index; #pragma omp parallel for schedule(static) - for (index=0; indextotal_points; index++) - { + for (index=0; indextotal_points; index++) { /* Do drying dissolve effects */ if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) { PaintPoint *pPoint = &((PaintPoint*)sData->type_data)[index]; @@ -4651,8 +4643,7 @@ static int dynamicPaint_generateBakeData(DynamicPaintSurface *surface, Scene *sc * Prepare each surface point for a new step */ #pragma omp parallel for schedule(static) - for (index=0; indextotal_points; index++) - { + for (index=0; indextotal_points; index++) { float prev_point[3] = {0.0f, 0.0f, 0.0f}; if (do_velocity_data && !new_bdata) { copy_v3_v3(prev_point, bData->realCoord[bData->s_pos[index]].v); @@ -4796,8 +4787,7 @@ static int dynamicPaint_doStep(Scene *scene, Object *ob, DynamicPaintSurface *su else base = scene->base.first; - while (base || go) - { + while (base || go) { brushObj = NULL; /* select object */ if (surface->brush_group) { @@ -4821,12 +4811,10 @@ static int dynamicPaint_doStep(Scene *scene, Object *ob, DynamicPaintSurface *su /* 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 */ - if (pmd2->brush) - { + if (pmd2->brush) { DynamicPaintBrushSettings *brush = pmd2->brush; BrushMaterials bMats = {0}; diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 4f320b41184..c275d4ef0ac 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -129,7 +129,7 @@ PartDeflect *object_add_collision_fields(int type) pd->f_damp = 1.0f; /* set sensible defaults based on type */ - switch(type) { + switch (type) { case PFIELD_VORTEX: pd->shape = PFIELD_SHAPE_PLANE; break; @@ -419,8 +419,7 @@ static float eff_calc_visibility(ListBase *colliders, EffectorCache *eff, Effect 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) @@ -506,7 +505,8 @@ float effector_falloff(EffectorCache *eff, EffectorData *efd, EffectedPoint *UNU falloff=0.0f; else if (eff->pd->zdir == PFIELD_Z_NEG && fac > 0.0f) falloff=0.0f; - else switch(eff->pd->falloff) { + else { + switch (eff->pd->falloff) { case PFIELD_FALL_SPHERE: falloff*= falloff_func_dist(eff->pd, efd->distance); break; @@ -529,6 +529,7 @@ float effector_falloff(EffectorCache *eff, EffectorData *efd, EffectedPoint *UNU falloff*= falloff_func_rad(eff->pd, r_fac); break; + } } return falloff; @@ -835,7 +836,7 @@ static void do_physical_effector(EffectorCache *eff, EffectorData *efd, Effected copy_v3_v3(force, efd->vec_to_point); - switch(pd->forcefield) { + switch (pd->forcefield) { case PFIELD_WIND: copy_v3_v3(force, efd->nor); mul_v3_fl(force, strength * efd->falloff); diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index bb8cfe37a88..806d795cc9d 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -1655,8 +1655,7 @@ static float evaluate_driver (ChannelDriver *driver, const float evaltime) { driver->curval= 0.0f; } - else - { + else { /* this evaluates the expression using Python,and returns its result: * - on errors it reports, then returns 0.0f */ diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index ed5cf5e7924..0b722aabd4c 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -318,8 +318,7 @@ static void fcm_fn_generator_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, floa /* get function pointer to the func to use: * WARNING: must perform special argument validation hereto guard against crashes */ - switch (data->type) - { + switch (data->type) { /* simple ones */ case FCM_GENERATOR_FN_SIN: /* sine wave */ fn= sin; diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index b2759f18e9b..cdc923600d7 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -68,8 +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; while (che->nurbsbase.first) { @@ -136,8 +135,7 @@ struct TmpFont *vfont_find_tmpfont(VFont *vfont) // Try finding the font from font list tmpfnt = ttfdata.first; - while (tmpfnt) - { + while (tmpfnt) { if (tmpfnt->vfont == vfont) break; tmpfnt = tmpfnt->next; @@ -280,7 +278,7 @@ VFont *load_vfont(Main *bmain, const char *name) static VFont *which_vfont(Curve *cu, CharInfo *info) { - switch(info->flag & (CU_CHINFO_BOLD|CU_CHINFO_ITALIC)) { + switch (info->flag & (CU_CHINFO_BOLD|CU_CHINFO_ITALIC)) { case CU_CHINFO_BOLD: if (cu->vfontb) return(cu->vfontb); else return(cu->vfont); case CU_CHINFO_ITALIC: @@ -397,8 +395,7 @@ static void buildchar(Main *bmain, Curve *cu, unsigned long character, CharInfo nu1 = che->nurbsbase.first; // Create the character - while (nu1) - { + while (nu1) { bezt1 = nu1->bezt; if (bezt1) { nu2 =(Nurb*) MEM_mallocN(sizeof(Nurb),"duplichar_nurb"); @@ -822,10 +819,15 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m } } 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') && - (mem[j]!='\r') && (chartransdata[j].dobreak==0) && (jlinenr]-linedata[ct->linenr])/linedata4[ct->linenr]; @@ -833,7 +835,7 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m } if (mem[i]=='\n' || mem[i]=='\r' || chartransdata[i].dobreak) curofs= 0; ct++; - } + } } } @@ -950,7 +952,7 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m if ((mode==FO_CURSUP || mode==FO_PAGEUP) && ct->linenr==0); else if ((mode==FO_CURSDOWN || mode==FO_PAGEDOWN) && ct->linenr==lnr); else { - switch(mode) { + switch (mode) { case FO_CURSUP: lnr= ct->linenr-1; break; case FO_CURSDOWN: lnr= ct->linenr+1; break; case FO_PAGEUP: lnr= ct->linenr-10; break; diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index bb51325a6ef..dfe73ae20db 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -581,8 +581,7 @@ void IDP_FreeIterBeforeEnd(void *vself) static void IDP_FreeGroup(IDProperty *prop) { IDProperty *loop; - for (loop=prop->data.group.first; loop; loop=loop->next) - { + for (loop=prop->data.group.first; loop; loop=loop->next) { IDP_FreeProperty(loop); } BLI_freelistN(&prop->data.group); diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 6e0330f5316..5c9c942cc6c 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -578,7 +578,7 @@ static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, const char BLI_strncpy(ibuf->name, name, sizeof(ibuf->name)); ibuf->userflags |= IB_BITMAPDIRTY; - switch(uvtestgrid) { + switch (uvtestgrid) { case 1: BKE_image_buf_fill_checker(rect, rect_float, width, height); break; @@ -929,7 +929,7 @@ char BKE_ftype_to_imtype(const int ftype) int BKE_imtype_is_movie(const char imtype) { - switch(imtype) { + switch (imtype) { case R_IMF_IMTYPE_AVIRAW: case R_IMF_IMTYPE_AVIJPEG: case R_IMF_IMTYPE_AVICODEC: @@ -946,7 +946,7 @@ int BKE_imtype_is_movie(const char imtype) int BKE_imtype_supports_zbuf(const char imtype) { - switch(imtype) { + switch (imtype) { case R_IMF_IMTYPE_IRIZ: case R_IMF_IMTYPE_OPENEXR: /* but not R_IMF_IMTYPE_MULTILAYER */ return 1; @@ -956,7 +956,7 @@ int BKE_imtype_supports_zbuf(const char imtype) int BKE_imtype_supports_compress(const char imtype) { - switch(imtype) { + switch (imtype) { case R_IMF_IMTYPE_PNG: return 1; } @@ -965,7 +965,7 @@ int BKE_imtype_supports_compress(const char imtype) int BKE_imtype_supports_quality(const char imtype) { - switch(imtype) { + switch (imtype) { case R_IMF_IMTYPE_JPEG90: case R_IMF_IMTYPE_JP2: case R_IMF_IMTYPE_AVIJPEG: @@ -979,7 +979,7 @@ char BKE_imtype_valid_channels(const char imtype) char chan_flag= IMA_CHAN_FLAG_RGB; /* assume all support rgb */ /* alpha */ - switch(imtype) { + switch (imtype) { case R_IMF_IMTYPE_TARGA: case R_IMF_IMTYPE_IRIS: case R_IMF_IMTYPE_PNG: @@ -995,7 +995,7 @@ char BKE_imtype_valid_channels(const char imtype) } /* bw */ - switch(imtype) { + switch (imtype) { case R_IMF_IMTYPE_PNG: case R_IMF_IMTYPE_JPEG90: case R_IMF_IMTYPE_TARGA: @@ -1110,8 +1110,11 @@ int BKE_add_image_extension(char *string, const char imtype) } #ifdef WITH_TIFF else if (imtype==R_IMF_IMTYPE_TIFF) { - if (!BLI_testextensie(string, ".tif") && - !BLI_testextensie(string, ".tiff")) extension= ".tif"; + if (!BLI_testextensie(string, ".tif") && + !BLI_testextensie(string, ".tiff")) + { + extension= ".tif"; + } } #endif #ifdef WITH_OPENEXR @@ -1791,7 +1794,7 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal) if (ima==NULL) return; - switch(signal) { + switch (signal) { case IMA_SIGNAL_FREE: image_free_buffers(ima); if (iuser) diff --git a/source/blender/blenkernel/intern/image_gen.c b/source/blender/blenkernel/intern/image_gen.c index 675c0771140..1441bd7b12b 100644 --- a/source/blender/blenkernel/intern/image_gen.c +++ b/source/blender/blenkernel/intern/image_gen.c @@ -169,12 +169,10 @@ static void checker_board_color_fill(unsigned char *rect, float *rect_float, int hue_step= power_of_2_max_i(width / 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); @@ -291,12 +289,10 @@ 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; pen_y = y + 44; diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index a4edc1e531a..b593419db9f 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -178,8 +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]); } } @@ -193,8 +192,7 @@ DO_INLINE lfVector *create_lfvector(unsigned int verts) /* delete long vector */ DO_INLINE void del_lfvector(float (*fLongVector)[3]) { - if (fLongVector != NULL) - { + if (fLongVector != NULL) { MEM_freeN (fLongVector); // cloth_aligned_free(&MEMORY_BASE, fLongVector); } @@ -208,8 +206,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,8 +220,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,8 +229,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); } } @@ -258,8 +253,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,8 +263,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,8 +273,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,8 +281,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,8 +291,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,15 +340,12 @@ 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 (j=0;j<3;j++) - { + for (i=0;i<3;i++) { + for (j=0;j<3;j++) { int i1=(i+1)%3; int i2=(i+2)%3; int j1=(j+1)%3; @@ -535,8 +522,7 @@ DO_INLINE fmatrix3x3 *create_bfmatrix(unsigned int verts, unsigned int springs) /* delete big matrix */ DO_INLINE void del_bfmatrix(fmatrix3x3 *matrix) { - if (matrix != NULL) - { + if (matrix != NULL) { MEM_freeN (matrix); } } @@ -554,8 +540,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,12 +552,10 @@ 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,8 +564,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,15 +583,13 @@ 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,8 +607,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,8 +618,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,8 +629,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,8 +640,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,8 +651,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,8 +662,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,8 +673,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,8 +686,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); } @@ -772,12 +744,10 @@ int implicit_init (Object *UNUSED(ob), ClothModifierData *clmd) id->dV = create_lfvector(cloth->numverts); id->z = create_lfvector(cloth->numverts); - for (i=0;inumverts;i++) - { + for (i=0;inumverts;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; pinned++; @@ -791,8 +761,7 @@ int implicit_init (Object *UNUSED(ob), ClothModifierData *clmd) // init springs search = cloth->springs; - for (i=0;inumsprings;i++) - { + for (i=0;inumsprings;i++) { spring = search->link; // dFdV_start[i].r = big_I[i].r = big_zero[i].r = @@ -810,8 +779,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,12 +791,10 @@ 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); del_bfmatrix(id->dFdX); @@ -886,12 +852,10 @@ 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; } - else - { + else { return kb * fbderiv(length, L); } } @@ -900,8 +864,7 @@ DO_INLINE void filter(lfVector *V, fmatrix3x3 *S) { unsigned int i=0; - for (i=0;istarget && 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,8 +941,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; iflags &= ~CLOTH_SPRING_FLAG_NEEDED; - if (length > ALMOST_ZERO) - { + if (length > ALMOST_ZERO) { /* if (length>L) { @@ -1270,16 +1230,13 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s, */ mul_fvector_S(dir, extent, 1.0f/length); } - else - { + else { mul_fvector_S(dir, extent, 0.0f); } // calculate force of structural + shear springs - if ((s->type & CLOTH_SPRING_TYPE_STRUCTURAL) || (s->type & CLOTH_SPRING_TYPE_SHEAR)) - { - if (length > L || no_compress) - { + if ((s->type & CLOTH_SPRING_TYPE_STRUCTURAL) || (s->type & CLOTH_SPRING_TYPE_SHEAR)) { + if (length > L || no_compress) { s->flags |= CLOTH_SPRING_FLAG_NEEDED; k = clmd->sim_parms->structural; @@ -1337,10 +1294,8 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s, // dfdx_spring(s->dfdx, dir, length, 0.0, k); // dfdv_damp(s->dfdv, dir, MIN2(1.0, (clmd->sim_parms->goalfrict/100.0))); } - else // calculate force of bending springs - { - if (length < L) - { + else { /* calculate force of bending springs */ + if (length < L) { s->flags |= CLOTH_SPRING_FLAG_NEEDED; k = clmd->sim_parms->bending; @@ -1358,10 +1313,8 @@ 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->type & CLOTH_SPRING_TYPE_BENDING)) - { + if (s->flags & CLOTH_SPRING_FLAG_NEEDED) { + 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); add_fmatrix_fmatrix(dFdV[s->matrix_index].m, dFdV[s->matrix_index].m, s->dfdv); @@ -1486,8 +1439,7 @@ 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]; @@ -1593,8 +1545,7 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec /* 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]); mul_fmatrix_fvector(lF[i], M[i].m, temp); @@ -1603,8 +1554,7 @@ 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); @@ -1612,14 +1562,12 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec 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 float tmp[3]={0,0,0}; @@ -1650,8 +1598,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)); VECADDS(lF[mfaces[i].v4], lF[mfaces[i].v4], tmp, factor); @@ -1692,8 +1639,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)) {} cloth_calc_spring_force(clmd, search->link, lF, lX, lV, dFdV, dFdX, time); @@ -1703,8 +1649,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)) cloth_apply_spring_force(clmd, search->link, lF, lX, lV, dFdV, dFdX); @@ -1836,21 +1781,17 @@ 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 */ - { - for (i = 0; i < numverts; i++) - { + if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) { /* do goal stuff */ + 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); } } } - while (step < tf) - { + while (step < tf) { // damping velocity for artistic reasons mul_lfvectorS(id->V, id->V, clmd->sim_parms->vel_damping, numverts); @@ -1864,13 +1805,10 @@ 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++) - { - if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) - { - if (verts [i].flags & CLOTH_VERT_FLAG_PINNED) - { - float tvect[3] = {.0,.0,.0}; + for (i = 0; i < numverts; i++) { + if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) { + if (verts[i].flags & CLOTH_VERT_FLAG_PINNED) { + float tvect[3] = {0.0f, 0.0f, 0.0f}; sub_v3_v3v3(tvect, verts[i].xconst, verts[i].xold); mul_fvector_S(tvect, tvect, step+dt); VECADD(tvect, tvect, verts[i].xold); @@ -1881,14 +1819,12 @@ 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]); sub_v3_v3v3(verts[i].tv, verts[i].tx, verts[i].txold); @@ -1904,8 +1840,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]); } @@ -1913,11 +1848,9 @@ 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)) continue; @@ -1933,8 +1866,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); @@ -1944,8 +1876,7 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase simulate_implicit_euler(id->Vnew, id->X, id->V, id->F, id->dFdV, id->dFdX, dt / 2.0f, id->A, id->B, id->dV, id->S, id->z, id->olddV, id->P, id->Pinv, id->M, id->bigI); } } - else - { + else { // X = Xnew; cp_lfvector(id->X, id->Xnew, numverts); } @@ -1959,16 +1890,13 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase step += dt; } - for (i = 0; i < numverts; i++) - { - if ((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) && (verts [i].flags & CLOTH_VERT_FLAG_PINNED)) - { + for (i = 0; i < numverts; i++) { + 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); copy_v3_v3(verts[i].v, id->V[i]); } - else - { + else { copy_v3_v3(verts[i].txold, id->X[i]); copy_v3_v3(verts[i].x, id->X[i]); copy_v3_v3(verts[i].v, id->V[i]); @@ -1987,8 +1915,7 @@ 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); } diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 7e756e853b1..07839b10ef1 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -182,7 +182,7 @@ int id_make_local(ID *id, int test) if (id->flag & LIB_INDIRECT) return 0; - switch(GS(id->name)) { + switch (GS(id->name)) { case ID_SCE: return 0; /* not implemented */ case ID_LI: @@ -279,7 +279,7 @@ int id_copy(ID *id, ID **newid, int test) /* conventions: * - make shallow copy, only this ID block * - id.us of the new ID is set to 1 */ - switch(GS(id->name)) { + switch (GS(id->name)) { case ID_SCE: return 0; /* can't be copied from here */ case ID_LI: @@ -368,7 +368,7 @@ int id_unlink(ID *id, int test) Main *mainlib= G.main; ListBase *lb; - switch(GS(id->name)) { + switch (GS(id->name)) { case ID_TXT: if (test) return 1; unlink_text(mainlib, (Text*)id); @@ -425,7 +425,7 @@ int id_single_user(bContext *C, ID *id, PointerRNA *ptr, PropertyRNA *prop) ListBase *which_libbase(Main *mainlib, short type) { - switch( type ) { + switch ( type ) { case ID_SCE: return &(mainlib->scene); case ID_LI: @@ -589,7 +589,7 @@ static ID *alloc_libblock_notest(short type) { ID *id= NULL; - switch( type ) { + switch ( type ) { case ID_SCE: id= MEM_callocN(sizeof(Scene), "scene"); break; @@ -796,7 +796,7 @@ void free_libblock(ListBase *lb, void *idv) BPY_id_release(id); #endif - switch( GS(id->name) ) { /* GetShort from util.h */ + switch ( GS(id->name) ) { /* GetShort from util.h */ case ID_SCE: free_scene((Scene *)id); break; @@ -1010,8 +1010,7 @@ static void IDnames_to_dyn_pupstring(DynStr *pupds, ListBase *lb, ID *link, shor BLI_dynstr_append(pupds, numstr); /* icon */ - switch(GS(id->name)) - { + switch (GS(id->name)) { case ID_MA: /* fall through */ case ID_TE: /* fall through */ case ID_IM: /* fall through */ diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 6d44282c60a..21a91b34e8d 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -493,7 +493,7 @@ short *give_totcolp(Object *ob) /* same as above but for ID's */ Material ***give_matarar_id(ID *id) { - switch(GS(id->name)) { + switch (GS(id->name)) { case ID_ME: return &(((Mesh *)id)->mat); break; @@ -509,7 +509,7 @@ Material ***give_matarar_id(ID *id) short *give_totcolp_id(ID *id) { - switch(GS(id->name)) { + switch (GS(id->name)) { case ID_ME: return &(((Mesh *)id)->totcol); break; @@ -525,7 +525,7 @@ short *give_totcolp_id(ID *id) static void data_delete_material_index_id(ID *id, short index) { - switch(GS(id->name)) { + switch (GS(id->name)) { case ID_ME: mesh_delete_material_index((Mesh *)id, index); break; diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index c06d796d562..60ccfa2a7cb 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -204,7 +204,7 @@ MetaElem *add_metaball_element(MetaBall *mb, const int type) ml->s= 2.0; ml->flag= MB_SCALE_RAD; - switch(type) { + switch (type) { case MB_BALL: ml->type = MB_BALL; ml->expx= ml->expy= ml->expz= 1.0; @@ -853,7 +853,7 @@ void docube(CUBE *cube, PROCESS *p, MetaBall *mb) count++; } if (count>2) { - switch(count) { + switch (count) { case 3: accum_mballfaces(indexar[2], indexar[1], indexar[0], 0); break; @@ -1179,10 +1179,13 @@ int getedge (EDGELIST *table[], k2=t; } q = table[HASH(i1, j1, k1)+HASH(i2, j2, k2)]; - for (; q != NULL; q = q->next) + for (; q != NULL; q = q->next) { if (q->i1 == i1 && q->j1 == j1 && q->k1 == k1 && q->i2 == i2 && q->j2 == j2 && q->k2 == k2) + { return q->vid; + } + } return -1; } diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 59dd7db43da..7509260d503 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -128,18 +128,22 @@ static int customdata_compare(CustomData *c1, CustomData *c2, Mesh *m1, Mesh *m2 CustomDataLayer *l1, *l2; int i, i1=0, i2=0, tot, j; - for (i=0; itotlayer; i++) { - if (ELEM7(c1->layers[i].type, CD_MVERT, CD_MEDGE, CD_MPOLY, - CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT)) + for (i = 0; i < c1->totlayer; i++) { + if (ELEM7(c1->layers[i].type, CD_MVERT, CD_MEDGE, CD_MPOLY, + CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT)) + { i1++; + } } - - for (i=0; itotlayer; i++) { - if (ELEM7(c2->layers[i].type, CD_MVERT, CD_MEDGE, CD_MPOLY, - CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT)) + + for (i = 0; i < c2->totlayer; i++) { + if (ELEM7(c2->layers[i].type, CD_MVERT, CD_MEDGE, CD_MPOLY, + CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT)) + { i2++; + } } - + if (i1 != i2) return MESHCMP_CDLAYERS_MISMATCH; @@ -148,12 +152,16 @@ static int customdata_compare(CustomData *c1, CustomData *c2, Mesh *m1, Mesh *m2 i1 = 0; i2 = 0; for (i=0; i < tot; i++) { while (i1 < c1->totlayer && !ELEM7(l1->type, CD_MVERT, CD_MEDGE, CD_MPOLY, - CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT)) + CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT)) + { i1++, l1++; + } - while (i2 < c2->totlayer && !ELEM7(l2->type, CD_MVERT, CD_MEDGE, CD_MPOLY, - CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT)) + while (i2 < c2->totlayer && !ELEM7(l2->type, CD_MVERT, CD_MEDGE, CD_MPOLY, + CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT)) + { i2++, l2++; + } if (l1->type == CD_MVERT) { MVert *v1 = l1->data; @@ -3054,10 +3062,13 @@ void mesh_flush_hidden_from_verts(const MVert *mvert, for (i = 0; i < totedge; i++) { MEdge *e = &medge[i]; if (mvert[e->v1].flag & ME_HIDE || - mvert[e->v2].flag & ME_HIDE) + mvert[e->v2].flag & ME_HIDE) + { e->flag |= ME_HIDE; - else + } + else { e->flag &= ~ME_HIDE; + } } for (i = 0; i < totpoly; i++) { MPoly *p = &mpoly[i]; diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index 9a640bcb8eb..f23578e07d7 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -517,7 +517,7 @@ static void real_ibuf_size(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf, in *height = ibuf->y; if (clip->flag & MCLIP_USE_PROXY) { - switch(user->render_size) { + switch (user->render_size) { case MCLIP_PROXY_RENDER_SIZE_25: (*width) *= 4; (*height) *= 4; diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 7580f2eee4d..e2142c393a5 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -1017,7 +1017,7 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm column_vectors_to_mat3(mat, tx, ty, no); - switch(op) { + switch (op) { case APPLY_DISPLACEMENTS: /* Convert displacement to object space * and add to grid points */ diff --git a/source/blender/blenkernel/intern/navmesh_conversion.c b/source/blender/blenkernel/intern/navmesh_conversion.c index 34e0be1de92..23d2f50c3f7 100644 --- a/source/blender/blenkernel/intern/navmesh_conversion.c +++ b/source/blender/blenkernel/intern/navmesh_conversion.c @@ -57,8 +57,7 @@ BLI_INLINE int left(const float* a, const float* b, const float* c) int polyNumVerts(const unsigned short* p, const int vertsPerPoly) { int i, nv = 0; - for (i=0; igetNumVerts(dm); - if (nverts>=0xffff) - { + if (nverts>=0xffff) { printf("Converting navmesh: Error! Too many vertices. Max number of vertices %d\n", 0xffff); return 0; } @@ -128,8 +125,7 @@ int buildRawVertIndicesData(DerivedMesh* dm, int *nverts_r, float **verts_r, dm->getVertCos(dm, (float(*)[3])verts); //flip coordinates - for (vi=0; vigetNumTessFaces(dm); faces = dm->getTessFaceArray(dm); ntris = nfaces; - for (fi=0; fiv4) ntris++; @@ -149,15 +144,13 @@ int buildRawVertIndicesData(DerivedMesh* dm, int *nverts_r, float **verts_r, tris = MEM_callocN(sizeof(unsigned short)*3*ntris, "buildRawVertIndicesData tris"); tri = tris; triIdx = 0; - for (fi=0; fiv1; tri[3*triIdx+1] = (unsigned short) face->v3; tri[3*triIdx+2] = (unsigned short) face->v2; trisToFacesMap[triIdx++]=fi; - if (face->v4) - { + if (face->v4) { tri[3*triIdx+0] = (unsigned short) face->v1; tri[3*triIdx+1] = (unsigned short) face->v4; tri[3*triIdx+2] = (unsigned short) face->v3; @@ -187,8 +180,7 @@ int buildPolygonsByDetailedMeshes(const int vertsPerPoly, const int npolys, unsigned short* newPoly = MEM_callocN(sizeof(unsigned short)*capacity, "buildPolygonsByDetailedMeshes newPoly"); memset(newPoly, 0xff, sizeof(unsigned short)*capacity); - for (polyidx=0; polyidx0) - { + for (i=0; i< ntris; i++) { + if (recastData[trisToFacesMap[trisMapping[i]]]>0) { validTriStart = i; break; } } - if (validTriStart<0) - { + if (validTriStart<0) { printf("Converting navmesh: Error! No valid polygons in mesh\n"); MEM_freeN(trisMapping); return 0; @@ -396,8 +367,7 @@ int buildNavMeshData(const int nverts, const float* verts, //and reserve memory for adjacency info dtris = MEM_callocN(sizeof(unsigned short)*3*2*ndtris, "buildNavMeshData dtris"); memset(dtris, 0xffff, sizeof(unsigned short)*3*2*ndtris); - for (i=0; iend = (float)ceil((double)info.length * FPS); } - else + else #endif { strip->end = 10.0f; @@ -373,7 +373,7 @@ NlaStrip *add_nla_soundstrip (Scene *scene, Speaker *speaker) strip->extendmode = NLASTRIP_EXTEND_NOTHING; /* nothing to extend... */ /* strip should be referenced as-is */ - strip->scale= 1.0f; + strip->scale = 1.0f; strip->repeat = 1.0f; /* return this strip */ diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index bc9411b7e02..6d3cce6ccfc 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1483,7 +1483,7 @@ void object_rot_to_mat3(Object *ob, float mat[][3]) void object_mat3_to_rot(Object *ob, float mat[][3], short use_compat) { - switch(ob->rotmode) { + switch (ob->rotmode) { case ROT_MODE_QUAT: { float dquat[4]; @@ -2025,7 +2025,7 @@ static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[ if (ob->partype & PARSLOW) copy_m4_m4(slowmat, obmat); - switch(ob->partype & PARTYPE) { + switch (ob->partype & PARTYPE) { case PAROBJECT: ok= 0; if (par->type==OB_CURVE) { @@ -2260,7 +2260,7 @@ void minmax_object(Object *ob, float min[3], float max[3]) int a; short change= FALSE; - switch(ob->type) { + switch (ob->type) { case OB_CURVE: case OB_FONT: case OB_SURF: @@ -2568,7 +2568,7 @@ void object_handle_update(Scene *scene, Object *ob) } /* includes all keys and modifiers */ - switch(ob->type) { + switch (ob->type) { case OB_MESH: { #if 0 // XXX, comment for 2.56a release, background wont set 'scene->customdata_mask' @@ -2784,8 +2784,7 @@ int ray_hit_boundbox(struct BoundBox *bb, float ray_start[3], float ray_normal[3 int result = 0; int i; - for (i = 0; i < 12 && result == 0; i++) - { + for (i = 0; i < 12 && result == 0; i++) { float lambda; int v1, v2, v3; v1 = triangle_indexes[i][0]; @@ -2812,8 +2811,7 @@ int object_insert_ptcache(Object *ob) BLI_sortlist(&ob->pc_ids, pc_cmp); - for (link=ob->pc_ids.first, i = 0; link; link=link->next, i++) - { + for (link=ob->pc_ids.first, i = 0; link; link=link->next, i++) { int index = GET_INT_FROM_POINTER(link->data); if (i < index) diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c index 907de7888cb..5ba1b3d86c3 100644 --- a/source/blender/blenkernel/intern/ocean.c +++ b/source/blender/blenkernel/intern/ocean.c @@ -196,15 +196,13 @@ static float Ph(struct Ocean* o, float kx,float kz ) float tmp; float k2 = kx*kx + kz*kz; - if (k2 == 0.0f) - { + if (k2 == 0.0f) { return 0.0f; // no DC component } // damp out the waves going in the direction opposite the wind tmp = (o->_wx * kx + o->_wz * kz)/sqrtf(k2); - if (tmp < 0) - { + if (tmp < 0) { tmp *= o->_damp_reflections; } @@ -421,18 +419,15 @@ void BKE_ocean_eval_uv_catrom(struct Ocean *oc, struct OceanResult *ocr, float u frac_z) { - if (oc->_do_disp_y) - { + if (oc->_do_disp_y) { ocr->disp[1] = INTERP(oc->_disp_y); } - if (oc->_do_normals) - { + if (oc->_do_normals) { ocr->normal[0] = INTERP(oc->_N_x); ocr->normal[1] = oc->_N_y/*INTERP(oc->_N_y) (MEM01)*/; ocr->normal[2] = INTERP(oc->_N_z); } - if (oc->_do_chop) - { + if (oc->_do_chop) { ocr->disp[0] = INTERP(oc->_disp_x); ocr->disp[2] = INTERP(oc->_disp_z); } @@ -441,8 +436,7 @@ void BKE_ocean_eval_uv_catrom(struct Ocean *oc, struct OceanResult *ocr, float u ocr->disp[2] = 0.0; } - if (oc->_do_jacobian) - { + if (oc->_do_jacobian) { compute_eigenstuff(ocr, INTERP(oc->_Jxx),INTERP(oc->_Jzz),INTERP(oc->_Jxz)); } } @@ -474,8 +468,7 @@ void BKE_ocean_eval_ij(struct Ocean *oc, struct OceanResult *ocr, int i,int j) ocr->disp[1] = oc->_do_disp_y ? oc->_disp_y[i*oc->_N+j] : 0.0f; - if (oc->_do_chop) - { + if (oc->_do_chop) { ocr->disp[0] = oc->_disp_x[i*oc->_N+j]; ocr->disp[2] = oc->_disp_z[i*oc->_N+j]; } @@ -484,8 +477,7 @@ void BKE_ocean_eval_ij(struct Ocean *oc, struct OceanResult *ocr, int i,int j) ocr->disp[2] = 0.0f; } - if (oc->_do_normals) - { + if (oc->_do_normals) { ocr->normal[0] = oc->_N_x[i*oc->_N+j]; ocr->normal[1] = oc->_N_y/*oc->_N_y[i*oc->_N+j] (MEM01)*/; ocr->normal[2] = oc->_N_z[i*oc->_N+j]; @@ -493,8 +485,7 @@ void BKE_ocean_eval_ij(struct Ocean *oc, struct OceanResult *ocr, int i,int j) normalize_v3(ocr->normal); } - if (oc->_do_jacobian) - { + if (oc->_do_jacobian) { compute_eigenstuff(ocr, oc->_Jxx[i*oc->_N+j],oc->_Jzz[i*oc->_N+j],oc->_Jxz[i*oc->_N+j]); } @@ -511,12 +502,10 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount // compute a new htilda #pragma omp parallel for private(i, j) - for (i = 0 ; i < o->_M ; ++i) - { + for (i = 0 ; i < o->_M ; ++i) { // note the <= _N/2 here, see the fftw doco about // the mechanics of the complex->real fft storage - for ( j = 0 ; j <= o->_N / 2 ; ++j) - { + for ( j = 0 ; j <= o->_N / 2 ; ++j) { fftw_complex exp_param1; fftw_complex exp_param2; fftw_complex conj_param; @@ -541,8 +530,7 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount #pragma omp section { - if (o->_do_disp_y) - { + if (o->_do_disp_y) { // y displacement fftw_execute(o->_disp_y_plan); } @@ -550,13 +538,10 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount #pragma omp section { - if (o->_do_chop) - { + if (o->_do_chop) { // x displacement - for ( i = 0 ; i < o->_M ; ++i) - { - for ( j = 0 ; j <= o->_N / 2 ; ++j) - { + for ( i = 0 ; i < o->_M ; ++i) { + for ( j = 0 ; j <= o->_N / 2 ; ++j) { fftw_complex mul_param; fftw_complex minus_i; @@ -575,13 +560,10 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount #pragma omp section { - if (o->_do_chop) - { + if (o->_do_chop) { // z displacement - for ( i = 0 ; i < o->_M ; ++i) - { - for ( j = 0 ; j <= o->_N / 2 ; ++j) - { + for ( i = 0 ; i < o->_M ; ++i) { + for ( j = 0 ; j <= o->_N / 2 ; ++j) { fftw_complex mul_param; fftw_complex minus_i; @@ -600,13 +582,10 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount #pragma omp section { - if (o->_do_jacobian) - { + if (o->_do_jacobian) { // Jxx - for ( i = 0 ; i < o->_M ; ++i) - { - for ( j = 0 ; j <= o->_N / 2 ; ++j) - { + for ( i = 0 ; i < o->_M ; ++i) { + for ( j = 0 ; j <= o->_N / 2 ; ++j) { fftw_complex mul_param; //init_complex(mul_param, -scale, 0); @@ -620,10 +599,8 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount } fftw_execute(o->_Jxx_plan); - for ( i = 0 ; i < o->_M ; ++i) - { - for ( j = 0 ; j < o->_N ; ++j) - { + for ( i = 0 ; i < o->_M ; ++i) { + for ( j = 0 ; j < o->_N ; ++j) { o->_Jxx[i*o->_N+j] += 1.0; } } @@ -632,13 +609,10 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount #pragma omp section { - if (o->_do_jacobian) - { + if (o->_do_jacobian) { // Jzz - for ( i = 0 ; i < o->_M ; ++i) - { - for ( j = 0 ; j <= o->_N / 2 ; ++j) - { + for ( i = 0 ; i < o->_M ; ++i) { + for ( j = 0 ; j <= o->_N / 2 ; ++j) { fftw_complex mul_param; //init_complex(mul_param, -scale, 0); @@ -651,10 +625,8 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount } } fftw_execute(o->_Jzz_plan); - for ( i = 0 ; i < o->_M ; ++i) - { - for ( j = 0 ; j < o->_N ; ++j) - { + for ( i = 0 ; i < o->_M ; ++i) { + for ( j = 0 ; j < o->_N ; ++j) { o->_Jzz[i*o->_N+j] += 1.0; } } @@ -663,13 +635,10 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount #pragma omp section { - if (o->_do_jacobian) - { + if (o->_do_jacobian) { // Jxz - for ( i = 0 ; i < o->_M ; ++i) - { - for ( j = 0 ; j <= o->_N / 2 ; ++j) - { + for ( i = 0 ; i < o->_M ; ++i) { + for ( j = 0 ; j <= o->_N / 2 ; ++j) { fftw_complex mul_param; //init_complex(mul_param, -scale, 0); @@ -688,12 +657,9 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount #pragma omp section { // fft normals - if (o->_do_normals) - { - for ( i = 0 ; i < o->_M ; ++i) - { - for ( j = 0 ; j <= o->_N / 2 ; ++j) - { + if (o->_do_normals) { + for ( i = 0 ; i < o->_M ; ++i) { + for ( j = 0 ; j <= o->_N / 2 ; ++j) { fftw_complex mul_param; init_complex(mul_param, 0.0, -1.0); @@ -709,12 +675,9 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount #pragma omp section { - if (o->_do_normals) - { - for ( i = 0 ; i < o->_M ; ++i) - { - for ( j = 0 ; j <= o->_N / 2 ; ++j) - { + if (o->_do_normals) { + for ( i = 0 ; i < o->_M ; ++i) { + for ( j = 0 ; j <= o->_N / 2 ; ++j) { fftw_complex mul_param; init_complex(mul_param, 0.0, -1.0); @@ -757,12 +720,9 @@ static void set_height_normalize_factor(struct Ocean *oc) BLI_rw_mutex_lock(&oc->oceanmutex, THREAD_LOCK_READ); - for (i = 0; i < oc->_M; ++i) - { - for (j = 0; j < oc->_N; ++j) - { - if ( max_h < fabsf(oc->_disp_y[i*oc->_N+j])) - { + for (i = 0; i < oc->_M; ++i) { + for (j = 0; j < oc->_N; ++j) { + if ( max_h < fabsf(oc->_disp_y[i*oc->_N+j])) { max_h = fabsf(oc->_disp_y[i*oc->_N+j]); } } @@ -851,10 +811,8 @@ void BKE_init_ocean(struct Ocean* o, int M,int N, float Lx, float Lz, float V, f /*srand(seed);*/ BLI_srand(seed); - for (i = 0 ; i < o->_M ; ++i) - { - for (j = 0 ; j < o->_N ; ++j) - { + for (i = 0 ; i < o->_M ; ++i) { + for (j = 0 ; j < o->_N ; ++j) { float r1 = gaussRand(); float r2 = gaussRand(); @@ -921,14 +879,12 @@ void BKE_free_ocean_data(struct Ocean *oc) BLI_rw_mutex_lock(&oc->oceanmutex, THREAD_LOCK_WRITE); - if (oc->_do_disp_y) - { + if (oc->_do_disp_y) { fftw_destroy_plan(oc->_disp_y_plan); MEM_freeN(oc->_disp_y); } - if (oc->_do_normals) - { + if (oc->_do_normals) { MEM_freeN(oc->_fft_in_nx); MEM_freeN(oc->_fft_in_nz); fftw_destroy_plan(oc->_N_x_plan); @@ -938,8 +894,7 @@ void BKE_free_ocean_data(struct Ocean *oc) MEM_freeN(oc->_N_z); } - if (oc->_do_chop) - { + if (oc->_do_chop) { MEM_freeN(oc->_fft_in_x); MEM_freeN(oc->_fft_in_z); fftw_destroy_plan(oc->_disp_x_plan); @@ -948,8 +903,7 @@ void BKE_free_ocean_data(struct Ocean *oc) MEM_freeN(oc->_disp_z); } - if (oc->_do_jacobian) - { + if (oc->_do_jacobian) { MEM_freeN(oc->_fft_in_jxx); MEM_freeN(oc->_fft_in_jzz); MEM_freeN(oc->_fft_in_jxz); @@ -1002,7 +956,7 @@ static void cache_filename(char *string, const char *path, const char *relbase, char cachepath[FILE_MAX]; const char *fname; - switch(type) { + switch (type) { case CACHE_TYPE_FOAM: fname= "foam_"; break; @@ -1043,8 +997,7 @@ void BKE_free_ocean_cache(struct OceanCache *och) if (!och) return; if (och->ibufs_disp) { - for (i=och->start, f=0; i<=och->end; i++, f++) - { + for (i=och->start, f=0; i<=och->end; i++, f++) { if (och->ibufs_disp[f]) { IMB_freeImBuf(och->ibufs_disp[f]); } @@ -1053,8 +1006,7 @@ void BKE_free_ocean_cache(struct OceanCache *och) } if (och->ibufs_foam) { - for (i=och->start, f=0; i<=och->end; i++, f++) - { + for (i=och->start, f=0; i<=och->end; i++, f++) { if (och->ibufs_foam[f]) { IMB_freeImBuf(och->ibufs_foam[f]); } @@ -1063,8 +1015,7 @@ void BKE_free_ocean_cache(struct OceanCache *och) } if (och->ibufs_norm) { - for (i=och->start, f=0; i<=och->end; i++, f++) - { + for (i=och->start, f=0; i<=och->end; i++, f++) { if (och->ibufs_norm[f]) { IMB_freeImBuf(och->ibufs_norm[f]); } diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index b55033b8493..e0c61fbcc90 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -72,7 +72,7 @@ int seekPackedFile(PackedFile *pf, int offset, int whence) if (pf) { oldseek = pf->seek; - switch(whence) { + switch (whence) { case SEEK_CUR: seek = oldseek + offset; break; diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index 27f5f7d9eb1..f417f9b79fb 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -59,7 +59,7 @@ Paint *paint_get_active(Scene *sce) ToolSettings *ts = sce->toolsettings; if (sce->basact && sce->basact->object) { - switch(sce->basact->object->mode) { + switch (sce->basact->object->mode) { case OB_MODE_SCULPT: return &ts->sculpt->paint; case OB_MODE_VERTEX_PAINT: diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index a154a1f8926..febe4277010 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -1572,7 +1572,7 @@ static float psys_interpolate_value_from_verts(DerivedMesh *dm, short from, int if (values==0 || index==-1) return 0.0; - switch(from) { + switch (from) { case PART_FROM_VERT: return values[index]; case PART_FROM_FACE: @@ -1936,7 +1936,7 @@ static void do_kink(ParticleKey *state, ParticleKey *par, float *par_rot, float copy_v3_v3(result, state->co); sub_v3_v3v3(par_vec, par->co, state->co); - switch(type) { + switch (type) { case PART_KINK_CURL: { negate_v3(par_vec); @@ -2846,7 +2846,7 @@ static void cache_key_incremental_rotation(ParticleCacheKey *key0, ParticleCache { float cosangle, angle, tangent[3], normal[3], q[4]; - switch(i) { + switch (i) { case 0: /* start from second key */ break; @@ -3778,7 +3778,7 @@ static void get_cpa_texture(DerivedMesh *dm, ParticleSystem *psys, ParticleSetti 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) { + switch (texco) { case TEXCO_GLOB: copy_v3_v3(texvec, par->state.co); break; @@ -3846,7 +3846,7 @@ void psys_get_texture(ParticleSimulationData *sim, ParticleData *pa, ParticleTex if (texco == TEXCO_UV && (ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME) == 0 || part->distr == PART_DISTR_GRID)) texco = TEXCO_GLOB; - switch(texco) { + switch (texco) { case TEXCO_GLOB: copy_v3_v3(texvec, pa->state.co); break; diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 4ce24953c89..d3644657de7 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -787,7 +787,7 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch pa->num = i = ctx->index[p]; mface = dm->getTessFaceData(dm,i,CD_MFACE); - switch(distr) { + switch (distr) { case PART_DISTR_JIT: if (ctx->jitlevel == 1) { if (mface->v4) @@ -855,13 +855,15 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch } if (intersect==0) pa->foffset=0.0; - else switch(distr) { - case PART_DISTR_JIT: - pa->foffset*= ctx->jit[p%(2*ctx->jitlevel)]; - break; - case PART_DISTR_RAND: - pa->foffset*=BLI_frand(); - break; + else { + switch (distr) { + case PART_DISTR_JIT: + pa->foffset *= ctx->jit[p % (2 * ctx->jitlevel)]; + break; + case PART_DISTR_RAND: + pa->foffset *= BLI_frand(); + break; + } } } } @@ -1575,7 +1577,7 @@ static void initialize_all_particles(ParticleSimulationData *sim) static void get_angular_velocity_vector(short avemode, ParticleKey *state, float *vec) { - switch(avemode) { + switch (avemode) { case PART_AVE_VELOCITY: copy_v3_v3(vec, state->vel); break; @@ -1779,7 +1781,7 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P if (part->rotmode) { /* create vector into which rotation is aligned */ - switch(part->rotmode) { + switch (part->rotmode) { case PART_ROT_NOR: copy_v3_v3(rot_vec, nor); break; @@ -2141,7 +2143,7 @@ static void integrate_particle(ParticleSettings *part, ParticleData *pa, float d if (pa->prev_state.time < 0.f && integrator == PART_INT_VERLET) integrator = PART_INT_EULER; - switch(integrator) { + switch (integrator) { case PART_INT_EULER: steps=1; break; @@ -2175,7 +2177,7 @@ static void integrate_particle(ParticleSettings *part, ParticleData *pa, float d /* calculate next state */ add_v3_v3(states[i].vel, impulse); - switch(integrator) { + switch (integrator) { case PART_INT_EULER: madd_v3_v3v3fl(pa->state.co, states->co, states->vel, dtime); madd_v3_v3v3fl(pa->state.vel, states->vel, acceleration, dtime); @@ -2193,7 +2195,7 @@ static void integrate_particle(ParticleSettings *part, ParticleData *pa, float d } break; case PART_INT_RK4: - switch(i) { + switch (i) { case 0: copy_v3_v3(dx[0], states->vel); mul_v3_fl(dx[0], dtime); @@ -2859,7 +2861,7 @@ static float collision_point_distance_with_normal(float p[3], ParticleCollisionE if (fac >= 0.f) collision_interpolate_element(pce, 0.f, fac, col); - switch(pce->tot) { + switch (pce->tot) { case 1: { sub_v3_v3v3(nor, p, pce->x0); @@ -2884,7 +2886,7 @@ static void collision_point_on_surface(float p[3], ParticleCollisionElement *pce { collision_interpolate_element(pce, 0.f, fac, col); - switch(pce->tot) { + switch (pce->tot) { case 1: { sub_v3_v3v3(co, p, pce->x0); @@ -3833,7 +3835,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) sim->colliders = get_collider_cache(sim->scene, sim->ob, NULL); /* initialize physics type specific stuff */ - switch(part->phystype) { + switch (part->phystype) { case PART_PHYS_BOIDS: { ParticleTarget *pt = psys->targets.first; @@ -3908,7 +3910,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) pa->state.time = -1.f; } - switch(part->phystype) { + switch (part->phystype) { case PART_PHYS_NEWTON: { LOOP_DYNAMIC_PARTICLES { @@ -4499,7 +4501,7 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys) /* setup necessary physics type dependent additional data if it doesn't yet exist */ psys_prepare_physics(&sim); - switch(part->type) { + switch (part->type) { case PART_HAIR: { /* nothing to do so bail out early */ @@ -4551,7 +4553,7 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys) } default: { - switch(part->phystype) { + switch (part->phystype) { case PART_PHYS_NO: case PART_PHYS_KEYED: { diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 2812592c69a..39293084dc0 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -433,7 +433,7 @@ static void ptcache_particle_extra_read(void *psys_v, PTCacheMem *pm, float UNUS PTCacheExtra *extra = pm->extradata.first; for (; extra; extra=extra->next) { - switch(extra->type) { + switch (extra->type) { case BPHYS_EXTRA_FLUID_SPRINGS: { if (psys->fluid_springs) @@ -690,14 +690,20 @@ static int ptcache_dynamicpaint_write(PTCacheFile *pf, void *dp_v) /* cache type */ ptcache_file_write(pf, &surface->type, 1, sizeof(int)); - if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) - in_len = sizeof(PaintPoint)*total_points; + if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) { + in_len = sizeof(PaintPoint) * total_points; + } else if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE || - surface->type == MOD_DPAINT_SURFACE_T_WEIGHT) - in_len = sizeof(float)*total_points; - else if (surface->type == MOD_DPAINT_SURFACE_T_WAVE) - in_len = sizeof(PaintWavePoint)*total_points; - else return 0; + surface->type == MOD_DPAINT_SURFACE_T_WEIGHT) + { + in_len = sizeof(float) * total_points; + } + else if (surface->type == MOD_DPAINT_SURFACE_T_WAVE) { + in_len = sizeof(PaintWavePoint) * total_points; + } + else { + return 0; + } out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len), "pointcache_lzo_buffer"); @@ -727,14 +733,20 @@ static int ptcache_dynamicpaint_read(PTCacheFile *pf, void *dp_v) return 0; /* read surface data */ - if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) + if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) { data_len = sizeof(PaintPoint); + } else if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE || - surface->type == MOD_DPAINT_SURFACE_T_WEIGHT) + surface->type == MOD_DPAINT_SURFACE_T_WEIGHT) + { data_len = sizeof(float); - else if (surface->type == MOD_DPAINT_SURFACE_T_WAVE) + } + else if (surface->type == MOD_DPAINT_SURFACE_T_WAVE) { data_len = sizeof(PaintWavePoint); - else return 0; + } + else { + return 0; + } ptcache_file_compressed_read(pf, (unsigned char*)surface->data->type_data, data_len*surface->data->total_points); @@ -989,8 +1001,7 @@ void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob, Scene *scene, int dup } 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); @@ -998,8 +1009,7 @@ void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob, Scene *scene, int dup } else if (md->type == eModifierType_DynamicPaint) { DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md; - if (pmd->canvas) - { + if (pmd->canvas) { DynamicPaintSurface *surface = pmd->canvas->surfaces.first; for (; surface; surface=surface->next) { @@ -1205,8 +1215,7 @@ static int ptcache_file_compressed_read(PTCacheFile *pf, unsigned char *result, 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 = len; ptcache_file_read(pf, &size, 1, sizeof(unsigned int)); @@ -1270,8 +1279,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)); ptcache_file_write(pf, props, size, sizeof(unsigned char)); @@ -2505,16 +2513,14 @@ int BKE_ptcache_object_reset(Scene *scene, Object *ob, int mode) } 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) { DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md; - if (pmd->canvas) - { + if (pmd->canvas) { DynamicPaintSurface *surface = pmd->canvas->surfaces.first; for (; surface; surface=surface->next) { @@ -2813,8 +2819,7 @@ void BKE_ptcache_bake(PTCacheBaker* baker) 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) - { + if (pid2->type == PTCACHE_TYPE_SMOKE_DOMAIN) { 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); @@ -3246,8 +3251,7 @@ void BKE_ptcache_update_info(PTCacheID *pid) } if (cache->flag & PTCACHE_DISK_CACHE) { - if (pid->type == PTCACHE_TYPE_SMOKE_DOMAIN) - { + if (pid->type == PTCACHE_TYPE_SMOKE_DOMAIN) { int totpoint = pid->totpoint(pid->calldata, 0); if (cache->totpoint > totpoint) diff --git a/source/blender/blenkernel/intern/property.c b/source/blender/blenkernel/intern/property.c index 066de61575d..e7247be7f51 100644 --- a/source/blender/blenkernel/intern/property.c +++ b/source/blender/blenkernel/intern/property.c @@ -99,7 +99,7 @@ void init_property(bProperty *prop) prop->data= 0; - switch(prop->type) { + switch (prop->type) { case GPROP_BOOL: case GPROP_INT: case GPROP_FLOAT: @@ -206,7 +206,7 @@ int compare_property(bProperty *prop, const char *str) // extern int Gdfra; /* sector.c */ float fvalue, ftest; - switch(prop->type) { + switch (prop->type) { case GPROP_BOOL: if (BLI_strcasecmp(str, "true")==0) { if (prop->data==1) return 0; @@ -242,7 +242,7 @@ void set_property(bProperty *prop, const char *str) { // extern int Gdfra; /* sector.c */ - switch(prop->type) { + 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; @@ -266,7 +266,7 @@ void add_property(bProperty *prop, const char *str) { // extern int Gdfra; /* sector.c */ - switch(prop->type) { + switch (prop->type) { case GPROP_BOOL: case GPROP_INT: prop->data+= atoi(str); @@ -288,7 +288,7 @@ void set_property_valstr(bProperty *prop, char *str) if (str == NULL) return; - switch(prop->type) { + switch (prop->type) { case GPROP_BOOL: case GPROP_INT: sprintf(str, "%d", prop->data); diff --git a/source/blender/blenkernel/intern/report.c b/source/blender/blenkernel/intern/report.c index b3e288dfc74..a7df6b10f06 100644 --- a/source/blender/blenkernel/intern/report.c +++ b/source/blender/blenkernel/intern/report.c @@ -43,7 +43,7 @@ static const char *report_type_str(int type) { - switch(type) { + switch (type) { case RPT_DEBUG: return "Debug"; case RPT_INFO: return "Info"; case RPT_OPERATOR: return "Operator"; diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c index 8123cbf3f0b..b5bb6b76c61 100644 --- a/source/blender/blenkernel/intern/sca.c +++ b/source/blender/blenkernel/intern/sca.c @@ -110,7 +110,7 @@ void init_sensor(bSensor *sens) sens->data= NULL; sens->pulse = 0; - switch(sens->type) { + switch (sens->type) { case SENS_ALWAYS: sens->pulse = 0; break; @@ -272,7 +272,7 @@ void init_controller(bController *cont) if (cont->data) MEM_freeN(cont->data); cont->data= NULL; - switch(cont->type) { + switch (cont->type) { case CONT_EXPRESSION: cont->data= MEM_callocN(sizeof(bExpressionCont), "expcont"); break; @@ -400,7 +400,7 @@ void init_actuator(bActuator *act) if (act->data) MEM_freeN(act->data); act->data= NULL; - switch(act->type) { + switch (act->type) { case ACT_ACTION: case ACT_SHAPEACTION: act->data= MEM_callocN(sizeof(bActionActuator), "actionact"); @@ -647,7 +647,7 @@ void sca_remove_ob_poin(Object *obt, Object *ob) sens= obt->sensors.first; while (sens) { - switch(sens->type) { + switch (sens->type) { case SENS_MESSAGE: ms= sens->data; if (ms->fromObject==ob) ms->fromObject= NULL; @@ -657,7 +657,7 @@ void sca_remove_ob_poin(Object *obt, Object *ob) act= obt->actuators.first; while (act) { - switch(act->type) { + switch (act->type) { case ACT_CAMERA: ca= act->data; if (ca->ob==ob) ca->ob= NULL; diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 8015e53e4c9..d3eade834e6 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -2112,7 +2112,7 @@ static void transform_image(int x, int y, struct ImBuf *ibuf1, struct ImBuf *out yt += (yo / 2.0f); //interpolate - switch(interpolation) { + switch (interpolation) { case 0: neareast_interpolation(ibuf1,out, xt,yt,xi,yi); break; diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 2d4397d16cd..1c06f1da018 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -3099,13 +3099,17 @@ int seqbase_isolated_sel_check(ListBase *seqbase) 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)) || (seq->seq2 && (seq->seq2->flag & SELECT)) || (seq->seq3 && (seq->seq3->flag & SELECT)) ) + { return FALSE; + } } } diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index 4006837efd6..e201209ec3f 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -146,8 +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,8 +157,7 @@ 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; inumVerts; ++i) - { + for (i = 0; inumVerts; ++i) { float *co = calc->vertexCos[i]; float tmp_co[3]; float weight = defvert_array_find_weight_safe(calc->dvert, i, calc->vgroup); @@ -189,8 +187,7 @@ 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; @@ -224,8 +221,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 ); co = tmp_co; @@ -298,8 +294,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc) //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; } else { @@ -316,8 +311,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc) return; } - if (calc->smd->auxTarget) - { + if (calc->smd->auxTarget) { auxMesh = object_get_derived_final(calc->smd->auxTarget); if (!auxMesh) return; @@ -332,16 +326,14 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc) #ifndef __APPLE__ #pragma omp parallel for private(i,hit) schedule(static) #endif - for (i = 0; inumVerts; ++i) - { + for (i = 0; inumVerts; ++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 (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 */ @@ -364,8 +356,7 @@ 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) normal_projection_project_vertex(0, tmp_co, tmp_no, &local2aux, auxData.tree, &hit, auxData.raycast_callback, &auxData); @@ -374,8 +365,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc) } //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); @@ -386,8 +376,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc) } - 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); } @@ -414,8 +403,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; } @@ -429,8 +417,7 @@ 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; inumVerts; ++i) - { + for (i = 0; inumVerts; ++i) { float *co = calc->vertexCos[i]; float tmp_co[3]; float weight = defvert_array_find_weight_safe(calc->dvert, i, calc->vgroup); @@ -458,10 +445,8 @@ 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 (calc->smd->shrinkOpts & MOD_SHRINKWRAP_KEEP_ABOVE_SURFACE) - { + if (nearest.index != -1) { + 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); } @@ -511,8 +496,7 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM } - if (smd->target) - { + if (smd->target) { calc.target = object_get_derived_final(smd->target); //TODO there might be several "bugs" on non-uniform scales matrixs @@ -528,28 +512,24 @@ 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 ssmd.levels = smd->subsurfLevels; //levels 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) - { - //TRICKY: this code assumes subsurface will have the transformed original vertices - //in their original order at the end of the vert array. + 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. */ calc.vert = calc.vert + ss_mesh->getNumVerts(ss_mesh) - dm->getNumVerts(dm); } } @@ -562,8 +542,7 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM //Projecting target defined - lets work! if (calc.target) { - switch(smd->shrinkType) - { + switch (smd->shrinkType) { case MOD_SHRINKWRAP_NEAREST_SURFACE: BENCH(shrinkwrap_calc_nearest_surface_point(&calc)); break; diff --git a/source/blender/blenkernel/intern/sketch.c b/source/blender/blenkernel/intern/sketch.c index 71ea85de716..32681c3a041 100644 --- a/source/blender/blenkernel/intern/sketch.c +++ b/source/blender/blenkernel/intern/sketch.c @@ -44,8 +44,7 @@ void freeSketch(SK_Sketch *sketch) { SK_Stroke *stk, *next; - for (stk = sketch->strokes.first; stk; stk = next) - { + for (stk = sketch->strokes.first; stk; stk = next) { next = stk->next; sk_freeStroke(stk); @@ -119,8 +118,7 @@ SK_Stroke* sk_createStroke(void) void sk_shrinkStrokeBuffer(SK_Stroke *stk) { - if (stk->nb_points < stk->buf_size) - { + if (stk->nb_points < stk->buf_size) { SK_Point *old_points = stk->points; stk->buf_size = stk->nb_points; @@ -135,8 +133,7 @@ void sk_shrinkStrokeBuffer(SK_Stroke *stk) void sk_growStrokeBuffer(SK_Stroke *stk) { - if (stk->nb_points == stk->buf_size) - { + if (stk->nb_points == stk->buf_size) { SK_Point *old_points = stk->points; stk->buf_size *= 2; @@ -151,12 +148,10 @@ void sk_growStrokeBuffer(SK_Stroke *stk) void sk_growStrokeBufferN(SK_Stroke *stk, int n) { - if (stk->nb_points + n > stk->buf_size) - { + if (stk->nb_points + n > stk->buf_size) { SK_Point *old_points = stk->points; - while (stk->nb_points + n > stk->buf_size) - { + while (stk->nb_points + n > stk->buf_size) { stk->buf_size *= 2; } @@ -202,8 +197,7 @@ void sk_insertStrokePoints(SK_Stroke *stk, SK_Point *pts, int len, int start, in sk_growStrokeBufferN(stk, len - size); - if (len != size) - { + if (len != size) { int tail_size = stk->nb_points - end + 1; memmove(stk->points + start + len, stk->points + end + 1, tail_size * sizeof(SK_Point)); @@ -218,8 +212,7 @@ void sk_trimStroke(SK_Stroke *stk, int start, int end) { int size = end - start + 1; - if (start > 0) - { + if (start > 0) { memmove(stk->points, stk->points + start, size * sizeof(SK_Point)); } @@ -253,8 +246,7 @@ void sk_straightenStroke(SK_Stroke *stk, int start, int end, float p_start[3], f sk_insertStrokePoint(stk, &pt1, start + 1); /* insert after start */ sk_insertStrokePoint(stk, &pt2, end + 1); /* insert before end (since end was pushed back already) */ - for (i = 1; i < total; i++) - { + for (i = 1; i < total; i++) { float delta = (float)i / (float)total; float *p = stk->points[start + 1 + i].p; @@ -269,30 +261,23 @@ void sk_polygonizeStroke(SK_Stroke *stk, int start, int end) int i; /* find first exact points outside of range */ - for (;start > 0; start--) - { - if (stk->points[start].type == PT_EXACT) - { + for (;start > 0; start--) { + if (stk->points[start].type == PT_EXACT) { break; } } - for (;end < stk->nb_points - 1; end++) - { - if (stk->points[end].type == PT_EXACT) - { + for (;end < stk->nb_points - 1; end++) { + if (stk->points[end].type == PT_EXACT) { break; } } offset = start + 1; - for (i = start + 1; i < end; i++) - { - if (stk->points[i].type == PT_EXACT) - { - if (offset != i) - { + for (i = start + 1; i < end; i++) { + if (stk->points[i].type == PT_EXACT) { + if (offset != i) { memcpy(stk->points + offset, stk->points + i, sizeof(SK_Point)); } @@ -301,8 +286,7 @@ void sk_polygonizeStroke(SK_Stroke *stk, int start, int end) } /* some points were removes, move end of array */ - if (offset < end) - { + if (offset < end) { int size = stk->nb_points - end; memmove(stk->points + offset, stk->points + end, size * sizeof(SK_Point)); stk->nb_points = offset + size; @@ -323,8 +307,7 @@ void sk_flattenStroke(SK_Stroke *stk, int start, int end) project_v3_v3v3(normal, distance, normal); limit = normalize_v3(normal); - for (i = 1; i < total - 1; i++) - { + for (i = 1; i < total - 1; i++) { float d = limit * i / total; float offset[3]; float *p = stk->points[start + i].p; @@ -342,8 +325,7 @@ void sk_flattenStroke(SK_Stroke *stk, int start, int end) void sk_removeStroke(SK_Sketch *sketch, SK_Stroke *stk) { - if (sketch->active_stroke == stk) - { + if (sketch->active_stroke == stk) { sketch->active_stroke = NULL; } @@ -358,8 +340,7 @@ void sk_reverseStroke(SK_Stroke *stk) sk_allocStrokeBuffer(stk); - for (i = 0; i < stk->nb_points; i++) - { + for (i = 0; i < stk->nb_points; i++) { sk_copyPoint(stk->points + i, old_points + stk->nb_points - 1 - i); } @@ -376,8 +357,7 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end) char work; int i; - if (start == -1) - { + if (start == -1) { start = 0; end = stk->nb_points - 1; } @@ -386,8 +366,7 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end) stk->nb_points = 0; /* adding points before range */ - for (i = 0; i < start; i++) - { + for (i = 0; i < start; i++) { sk_appendStrokePoint(stk, old_points + i); } @@ -398,8 +377,7 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end) work = 1; /* while still reducing */ - while (work) - { + while (work) { int ls, le; work = 0; @@ -407,15 +385,13 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end) le = start+1; /* while not over interval */ - while (ls < end) - { + while (ls < end) { int max_i = 0; short v1[2]; float max_dist = 16; /* more than 4 pixels */ /* find the next marked point */ - while (marked[le] == 0) - { + while (marked[le] == 0) { le++; } @@ -424,8 +400,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; short v2[2]; @@ -433,8 +408,7 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end) v2[0] = old_points[i].p2d[0] - old_points[ls].p2d[0]; v2[1] = old_points[i].p2d[1] - old_points[ls].p2d[1]; - if (v2[0] == 0 && v2[1] == 0) - { + if (v2[0] == 0 && v2[1] == 0) { continue; } @@ -442,15 +416,13 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end) dist = mul * mul * (v2[0]*v2[0] + v2[1]*v2[1]); - if (dist > max_dist) - { + if (dist > max_dist) { max_dist = dist; max_i = i; } } - if (max_i != 0) - { + if (max_i != 0) { work = 1; marked[max_i] = 1; } @@ -462,10 +434,8 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end) /* adding points after range */ - for (i = start; i <= end; i++) - { - if (marked[i]) - { + for (i = start; i <= end; i++) { + if (marked[i]) { sk_appendStrokePoint(stk, old_points + i); } } @@ -473,8 +443,7 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end) MEM_freeN(marked); /* adding points after range */ - for (i = end + 1; i < nb_points; i++) - { + for (i = end + 1; i < nb_points; i++) { sk_appendStrokePoint(stk, old_points + i); } @@ -490,13 +459,11 @@ void sk_filterLastContinuousStroke(SK_Stroke *stk) end = stk->nb_points -1; - for (start = end - 1; start > 0 && stk->points[start].type == PT_CONTINUOUS; start--) - { + for (start = end - 1; start > 0 && stk->points[start].type == PT_CONTINUOUS; start--) { /* nothing to do here*/ } - if (end - start > 1) - { + if (end - start > 1) { sk_filterStroke(stk, start, end); } } @@ -505,8 +472,7 @@ SK_Point *sk_lastStrokePoint(SK_Stroke *stk) { SK_Point *pt = NULL; - if (stk->nb_points > 0) - { + if (stk->nb_points > 0) { pt = stk->points + (stk->nb_points - 1); } @@ -520,8 +486,7 @@ void sk_endContinuousStroke(SK_Stroke *stk) void sk_updateNextPoint(SK_Sketch *sketch, SK_Stroke *stk) { - if (stk) - { + if (stk) { memcpy(&sketch->next_point, stk->points[stk->nb_points - 1].p, sizeof(SK_Point)); } } @@ -529,8 +494,7 @@ void sk_updateNextPoint(SK_Sketch *sketch, SK_Stroke *stk) int sk_stroke_filtermval(SK_DrawData *dd) { int retval = 0; - if (ABS(dd->mval[0] - dd->previous_mval[0]) + ABS(dd->mval[1] - dd->previous_mval[1]) > U.gp_manhattendist) - { + if (ABS(dd->mval[0] - dd->previous_mval[0]) + ABS(dd->mval[1] - dd->previous_mval[1]) > U.gp_manhattendist) { retval = 1; } @@ -551,12 +515,10 @@ void sk_deleteSelectedStrokes(SK_Sketch *sketch) { SK_Stroke *stk, *next; - for (stk = sketch->strokes.first; stk; stk = next) - { + for (stk = sketch->strokes.first; stk; stk = next) { next = stk->next; - if (stk->selected == 1) - { + if (stk->selected == 1) { sk_removeStroke(sketch, stk); } } @@ -566,31 +528,26 @@ void sk_selectAllSketch(SK_Sketch *sketch, int mode) { SK_Stroke *stk = NULL; - if (mode == -1) - { - for (stk = sketch->strokes.first; stk; stk = stk->next) - { + if (mode == -1) { + for (stk = sketch->strokes.first; stk; stk = stk->next) { stk->selected = 0; } } else if (mode == 0) { - for (stk = sketch->strokes.first; stk; stk = stk->next) - { + for (stk = sketch->strokes.first; stk; stk = stk->next) { stk->selected = 1; } } else if (mode == 1) { int selected = 1; - for (stk = sketch->strokes.first; stk; stk = stk->next) - { + for (stk = sketch->strokes.first; stk; stk = stk->next) { selected &= stk->selected; } selected ^= 1; - for (stk = sketch->strokes.first; stk; stk = stk->next) - { + for (stk = sketch->strokes.first; stk; stk = stk->next) { stk->selected = selected; } } diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index e3a309fc945..d0eca731a1a 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -402,7 +402,10 @@ static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M) if (!cmd->numverts || !cmd->numfaces) return; if ((pccd_M->totvert != cmd->numverts) || - (pccd_M->totface != cmd->numfaces)) return; + (pccd_M->totface != cmd->numfaces)) + { + return; + } pccd_M->bbmin[0]=pccd_M->bbmin[1]=pccd_M->bbmin[2]=1e30f; pccd_M->bbmax[0]=pccd_M->bbmax[1]=pccd_M->bbmax[2]=-1e30f; @@ -1388,8 +1391,7 @@ static void scan_for_ext_face_forces(Object *ob,float timenow) } bf = sb->scratch->bodyface; for (a=0; ascratch->totface; a++, bf++) { - if (( bf->flag & BFF_INTERSECT) || ( bf->flag & BFF_CLOSEVERT)) - { + if (( bf->flag & BFF_INTERSECT) || ( bf->flag & BFF_CLOSEVERT)) { sb->bpoint[bf->v1].choke2=MAX2(sb->bpoint[bf->v1].choke2,choke); sb->bpoint[bf->v2].choke2=MAX2(sb->bpoint[bf->v2].choke2,choke); sb->bpoint[bf->v3].choke2=MAX2(sb->bpoint[bf->v3].choke2,choke); @@ -1935,8 +1937,8 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], } } - if ((deflected < 2)&& (G.rt != 444)) // we did not hit a face until now - { // see if 'outer' hits an edge + if ((deflected < 2)&& (G.rt != 444)) { /* we did not hit a face until now */ + /* see if 'outer' hits an edge */ float dist; closest_to_line_segment_v3(ve, opco, nv1, nv2); @@ -2831,8 +2833,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa nlEnd(NL_MATRIX); nlEnd(NL_SYSTEM); - if ((G.rt == 32) && (nl_flags & NLF_BUILD)) - { + if ((G.rt == 32) && (nl_flags & NLF_BUILD)) { printf("####MEE#####\n"); nlPrintMatrix(); } @@ -3230,8 +3231,7 @@ static void springs_from_mesh(Object *ob) float scale =1.0f; sb= ob->soft; - if (me && sb) - { + if (me && sb) { /* using bp->origS as a container for spring calcualtions here ** will be overwritten sbObjectStep() to receive ** actual modifier stack positions @@ -3307,8 +3307,7 @@ static void mesh_to_softbody(Scene *scene, Object *ob) this enables per vertex *mass painting* */ - if (sb->namedVG_Mass[0]) - { + if (sb->namedVG_Mass[0]) { int grp= defgroup_name_index (ob,sb->namedVG_Mass); /* printf("VGN %s %d\n",sb->namedVG_Mass,grp); */ if (grp > -1) { @@ -3321,8 +3320,7 @@ static void mesh_to_softbody(Scene *scene, Object *ob) /* first set the default */ bp->springweight = 1.0f; - if (sb->namedVG_Spring_K[0]) - { + if (sb->namedVG_Spring_K[0]) { int grp= defgroup_name_index (ob,sb->namedVG_Spring_K); //printf("VGN %s %d\n",sb->namedVG_Spring_K,grp); if (grp > -1) { @@ -3639,8 +3637,7 @@ static void curve_surf_to_softbody(Scene *scene, Object *ob) } } - if (totspring) - { + if (totspring) { build_bps_springlist(ob); /* link bps to springs */ if (ob->softflag & OB_SB_SELF) {calculate_collision_balls(ob);} } @@ -3896,7 +3893,7 @@ static void softbody_reset(Object *ob, SoftBody *sb, float (*vertexCos)[3], int SB_estimate_transform(ob,NULL,NULL,NULL); SB_estimate_transform(ob,NULL,NULL,NULL); } - switch(ob->type) { + switch (ob->type) { case OB_MESH: if (ob->softflag & OB_SB_FACECOLL) mesh_faces_to_scratch(ob); break; @@ -3952,8 +3949,7 @@ static void softbody_step(Scene *scene, Object *ob, SoftBody *sb, float dtime) if (sb->solver_ID>0) mid_flags |= MID_PRESERVE; forcetime = forcetimemax; /* hope for integrating in one step */ - while ( (ABS(timedone) < ABS(dtime)) && (loops < 2000) ) - { + while ( (ABS(timedone) < ABS(dtime)) && (loops < 2000) ) { /* set goals in time */ interpolate_exciter(ob,200,(int)(200.0f*(timedone/dtime))); @@ -4021,12 +4017,11 @@ static void softbody_step(Scene *scene, Object *ob, SoftBody *sb, float dtime) } } - else if (sb->solver_ID == 2) - {/* do semi "fake" implicit euler */ + else if (sb->solver_ID == 2) { + /* do semi "fake" implicit euler */ //removed }/*SOLVER SELECT*/ - else if (sb->solver_ID == 4) - { + else if (sb->solver_ID == 4) { /* do semi "fake" implicit euler */ }/*SOLVER SELECT*/ else if (sb->solver_ID == 3) { @@ -4083,7 +4078,7 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i if (sb->bpoint == NULL || ((ob->softflag & OB_SB_EDGES) && !ob->soft->bspring && object_has_edges(ob))) { - switch(ob->type) { + switch (ob->type) { case OB_MESH: mesh_to_softbody(scene, ob); break; diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index c2dbb518837..28ce95ea8d1 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -95,8 +95,7 @@ struct bSound* sound_new_file(struct Main *bmain, const char *filename) sound_load(bmain, sound); - if (!sound->playback_handle) - { + if (!sound->playback_handle) { free_libblock(&bmain->sound, sound); sound = NULL; } @@ -106,22 +105,19 @@ struct bSound* sound_new_file(struct Main *bmain, const char *filename) void sound_free(struct bSound* sound) { - if (sound->packedfile) - { + if (sound->packedfile) { freePackedFile(sound->packedfile); sound->packedfile = NULL; } #ifdef WITH_AUDASPACE - if (sound->handle) - { + if (sound->handle) { AUD_unload(sound->handle); sound->handle = NULL; sound->playback_handle = NULL; } - if (sound->cache) - { + if (sound->cache) { AUD_unload(sound->cache); sound->cache = NULL; } @@ -141,10 +137,8 @@ static void sound_sync_callback(void* data, int mode, float time) struct Scene* scene; scene = bmain->scene.first; - while (scene) - { - if (scene->audio.flag & AUDIO_SYNC) - { + while (scene) { + if (scene->audio.flag & AUDIO_SYNC) { if (mode) sound_play_scene(scene); else @@ -282,8 +276,7 @@ struct bSound* sound_new_limiter(struct Main *bmain, struct bSound *source, floa void sound_delete(struct Main *bmain, struct bSound* sound) { - if (sound) - { + if (sound) { sound_free(sound); free_libblock(&bmain->sound, sound); @@ -312,8 +305,7 @@ void sound_cache_notifying(struct Main* main, struct bSound* sound) void sound_delete_cache(struct bSound* sound) { sound->flags &= ~SOUND_FLAGS_CACHING; - if (sound->cache) - { + if (sound->cache) { AUD_unload(sound->cache); sound->cache = NULL; sound->playback_handle = sound->handle; @@ -322,16 +314,13 @@ void sound_delete_cache(struct bSound* sound) void sound_load(struct Main *bmain, struct bSound* sound) { - if (sound) - { - if (sound->cache) - { + if (sound) { + if (sound->cache) { AUD_unload(sound->cache); sound->cache = NULL; } - if (sound->handle) - { + if (sound->handle) { AUD_unload(sound->handle); sound->handle = NULL; sound->playback_handle = NULL; @@ -341,7 +330,7 @@ void sound_load(struct Main *bmain, struct bSound* sound) // XXX unused currently #if 0 - switch(sound->type) + switch (sound->type) { case SOUND_TYPE_FILE: #endif @@ -376,15 +365,13 @@ void sound_load(struct Main *bmain, struct bSound* sound) break; } #endif - if (sound->flags & SOUND_FLAGS_MONO) - { + if (sound->flags & SOUND_FLAGS_MONO) { void* handle = AUD_monoSound(sound->handle); AUD_unload(sound->handle); sound->handle = handle; } - if (sound->flags & SOUND_FLAGS_CACHING) - { + if (sound->flags & SOUND_FLAGS_CACHING) { sound->cache = AUD_bufferSound(sound->handle); } @@ -557,14 +544,12 @@ void sound_play_scene(struct Scene *scene) if (status == AUD_STATUS_INVALID) sound_start_play_scene(scene); - if (!scene->sound_scene_handle) - { + if (!scene->sound_scene_handle) { AUD_unlock(); return; } - if (status != AUD_STATUS_PLAYING) - { + if (status != AUD_STATUS_PLAYING) { AUD_seek(scene->sound_scene_handle, CFRA / FPS); AUD_resume(scene->sound_scene_handle); } @@ -577,8 +562,7 @@ void sound_play_scene(struct Scene *scene) void sound_stop_scene(struct Scene *scene) { - if (scene->sound_scene_handle) - { + if (scene->sound_scene_handle) { AUD_pause(scene->sound_scene_handle); if (scene->audio.flag & AUDIO_SYNC) @@ -596,12 +580,10 @@ void sound_seek_scene(struct Main *bmain, struct Scene *scene) status = scene->sound_scene_handle ? AUD_getStatus(scene->sound_scene_handle) : AUD_STATUS_INVALID; - if (status == AUD_STATUS_INVALID) - { + if (status == AUD_STATUS_INVALID) { sound_start_play_scene(scene); - if (!scene->sound_scene_handle) - { + if (!scene->sound_scene_handle) { AUD_unlock(); return; } @@ -616,10 +598,8 @@ void sound_seek_scene(struct Main *bmain, struct Scene *scene) } } - if (scene->audio.flag & AUDIO_SCRUB && !animation_playing) - { - if (scene->audio.flag & AUDIO_SYNC) - { + if (scene->audio.flag & AUDIO_SCRUB && !animation_playing) { + if (scene->audio.flag & AUDIO_SYNC) { AUD_seek(scene->sound_scene_handle, CFRA / FPS); AUD_seekSequencer(scene->sound_scene_handle, CFRA / FPS); } @@ -648,8 +628,7 @@ void sound_seek_scene(struct Main *bmain, struct Scene *scene) float sound_sync_scene(struct Scene *scene) { - if (scene->sound_scene_handle) - { + if (scene->sound_scene_handle) { if (scene->audio.flag & AUDIO_SYNC) return AUD_getSequencerPosition(scene->sound_scene_handle); else @@ -668,8 +647,7 @@ int sound_scene_playing(struct Scene *scene) void sound_free_waveform(struct bSound* sound) { - if (sound->waveform) - { + if (sound->waveform) { MEM_freeN(((SoundWaveform*)sound->waveform)->data); MEM_freeN(sound->waveform); } @@ -683,8 +661,7 @@ void sound_read_waveform(struct bSound* sound) info = AUD_getInfo(sound->playback_handle); - if (info.length > 0) - { + if (info.length > 0) { SoundWaveform* waveform = MEM_mallocN(sizeof(SoundWaveform), "SoundWaveform"); int length = info.length * SOUND_WAVE_SAMPLES_PER_SECOND; @@ -709,23 +686,16 @@ void sound_update_scene(struct Scene* scene) void* handle; float quat[4]; - for (SETLOOPER(scene, sce_it, base)) - { + for (SETLOOPER(scene, sce_it, base)) { ob = base->object; - if (ob->type == OB_SPEAKER) - { - if (ob->adt) - { - for (track = ob->adt->nla_tracks.first; track; track = track->next) - { - for (strip = track->strips.first; strip; strip = strip->next) - { - if (strip->type == NLASTRIP_TYPE_SOUND) - { + if (ob->type == OB_SPEAKER) { + if (ob->adt) { + for (track = ob->adt->nla_tracks.first; track; track = track->next) { + for (strip = track->strips.first; strip; strip = strip->next) { + if (strip->type == NLASTRIP_TYPE_SOUND) { speaker = (Speaker*)ob->data; - if (AUD_removeSet(scene->speaker_handles, strip->speaker_handle)) - { + if (AUD_removeSet(scene->speaker_handles, strip->speaker_handle)) { if (speaker->sound) AUD_moveSequence(strip->speaker_handle, strip->start / FPS, -1, 0); else { @@ -734,15 +704,13 @@ void sound_update_scene(struct Scene* scene) } } else { - if (speaker->sound) - { + if (speaker->sound) { strip->speaker_handle = AUD_addSequence(scene->sound_scene, speaker->sound->playback_handle, strip->start / FPS, -1, 0); AUD_setRelativeSequence(strip->speaker_handle, 0); } } - if (strip->speaker_handle) - { + if (strip->speaker_handle) { AUD_addSet(new_set, strip->speaker_handle); AUD_updateSequenceData(strip->speaker_handle, speaker->volume_max, speaker->volume_min, speaker->distance_max, @@ -765,13 +733,11 @@ 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); } - if (scene->camera) - { + if (scene->camera) { mat4_to_quat(quat, scene->camera->obmat); AUD_setSequencerAnimData(scene->sound_scene, AUD_AP_LOCATION, CFRA, scene->camera->obmat[3], 1); AUD_setSequencerAnimData(scene->sound_scene, AUD_AP_ORIENTATION, CFRA, quat, 1); diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 83a24f6afdc..83225163ea3 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -2423,7 +2423,9 @@ static void ccgDM_release(DerivedMesh *dm) /* Check that mmd still exists */ 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) diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 1197ec23907..cb7369476c0 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -1193,9 +1193,11 @@ void txt_order_cursors(Text *text) if (!text->sell) return; /* Flip so text->curl is before text->sell */ - if (txt_get_span(text->curl, text->sell)<0 || - (text->curl==text->sell && text->curc>text->selc)) + if ((txt_get_span(text->curl, text->sell) < 0) || + (text->curl == text->sell && text->curc > text->selc)) + { txt_curs_swap(text); + } } int txt_has_sel(Text *text) @@ -2018,7 +2020,7 @@ void txt_do_undo(Text *text) undoing= 1; - switch(op) { + switch (op) { case UNDO_CLEFT: txt_move_right(text, 0); break; @@ -2245,7 +2247,7 @@ void txt_do_redo(Text *text) undoing= 1; - switch(op) { + switch (op) { case UNDO_CLEFT: txt_move_left(text, 0); break; @@ -2832,8 +2834,7 @@ void txt_indent(Text *text) } num = 0; - while (TRUE) - { + while (TRUE) { tmp= MEM_mallocN(text->curl->len+indentlen+1, "textline_string"); text->curc = 0; @@ -2851,8 +2852,7 @@ 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; } @@ -2862,14 +2862,12 @@ void txt_indent(Text *text) } } 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); } } @@ -2893,12 +2891,10 @@ void txt_unindent(Text *text) indent = spaceslen; } - while (TRUE) - { + while (TRUE) { int i = 0; - if (BLI_strncasecmp(text->curl->line, remove, indent) == 0) - { + if (BLI_strncasecmp(text->curl->line, remove, indent) == 0) { while (i< text->curl->len) { text->curl->line[i]= text->curl->line[i+indent]; i++; @@ -2909,8 +2905,7 @@ 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; } @@ -2921,14 +2916,12 @@ void txt_unindent(Text *text) } 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); } } @@ -2944,8 +2937,7 @@ void txt_comment(Text *text) if (!text->sell) return;// Need to change this need to check if only one line is selected to more then one num = 0; - while (TRUE) - { + while (TRUE) { tmp= MEM_mallocN(text->curl->len+2, "textline_string"); text->curc = 0; @@ -2963,8 +2955,7 @@ 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; } @@ -2974,14 +2965,12 @@ void txt_comment(Text *text) } } 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); } } @@ -2995,12 +2984,10 @@ 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) - { + if (text->curl->line[i] == remove) { while (i< text->curl->len) { text->curl->line[i]= text->curl->line[i+1]; i++; @@ -3012,8 +2999,7 @@ 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; } @@ -3024,14 +3010,12 @@ void txt_uncomment(Text *text) } 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); } } @@ -3047,27 +3031,23 @@ int setcurr_tab_spaces (Text *text, int space) if (!text) return 0; if (!text->curl) return 0; - while (text->curl->line[i] == indent) - { + while (text->curl->line[i] == indent) { //we only count those tabs/spaces that are before any text or before the curs; - if (i == text->curc) - { + if (i == text->curc) { return i; } 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 * 2) within an identifier * 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; @@ -3084,13 +3064,10 @@ 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 (strcspn(text->curl->line, back_words[test]) < strcspn(text->curl->line, comm)) - { + if (strstr(text->curl->line, back_words[test]) && i > 0) { + if (strcspn(text->curl->line, back_words[test]) < strcspn(text->curl->line, comm)) { i -= space; } } @@ -3139,14 +3116,16 @@ TextMarker *txt_find_marker_region(Text *text, TextLine *line, int start, int en for (marker=text->markers.first; marker; marker=next) { next= marker->next; - if (group && marker->group != group) continue; + if (group && marker->group != group) continue; else if ((marker->flags & flags) != flags) continue; - else if (marker->lineno < lineno) continue; + else if (marker->lineno < lineno) continue; else if (marker->lineno > lineno) break; if ((marker->start==marker->end && start<=marker->start && marker->start<=end) || - (marker->startend>start)) + (marker->startend>start)) + { return marker; + } } return NULL; } diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 23d818369a2..29b9505f449 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -663,7 +663,7 @@ void default_tex(Tex *tex) void tex_set_type(Tex *tex, int type) { - switch(type) { + switch (type) { case TEX_VOXELDATA: if (tex->vd == NULL) @@ -1180,7 +1180,7 @@ Tex *give_current_material_texture(Material *ma) int give_active_mtex(ID *id, MTex ***mtex_ar, short *act) { - switch(GS(id->name)) { + switch (GS(id->name)) { case ID_MA: *mtex_ar= ((Material *)id)->mtex; if (act) *act= (((Material *)id)->texact); @@ -1211,7 +1211,7 @@ void set_active_mtex(ID *id, short act) if (act<0) act= 0; else if (act>=MAX_MTEX) act= MAX_MTEX-1; - switch(GS(id->name)) { + switch (GS(id->name)) { case ID_MA: ((Material *)id)->texact= act; break; diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 59c38117858..079bde0afec 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -120,19 +120,17 @@ static int write_audio_frame(void) audio_time += (double) audio_input_samples / (double) c->sample_rate; pkt.size = avcodec_encode_audio(c, audio_output_buffer, - audio_outbuf_size, - (short*) audio_input_buffer); + audio_outbuf_size, + (short *)audio_input_buffer); - if (pkt.size < 0) - { + if (pkt.size < 0) { // XXX error("Error writing audio packet"); return -1; } 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); fprintf(stderr, "Audio Frame PTS: %d\n", (int)pkt.pts); @@ -175,7 +173,7 @@ static AVFrame* alloc_picture(int pix_fmt, int width, int height) * first is always desired guess_format parameter */ static const char** get_file_extensions(int format) { - switch(format) { + switch (format) { case FFMPEG_DV: { static const char * rv[] = { ".dv", NULL }; return rv; @@ -372,7 +370,7 @@ static void set_ffmpeg_property_option(AVCodecContext* c, IDProperty * prop) *param++ = 0; } - switch(prop->type) { + switch (prop->type) { case IDP_STRING: fprintf(stderr, "%s.\n", IDP_String(prop)); av_set_string3(c, prop->name, IDP_String(prop), 1, &rv); @@ -717,7 +715,7 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report BLI_snprintf(of->filename, sizeof(of->filename), "%s", name); /* set the codec to the user's selection */ - switch(ffmpeg_type) { + switch (ffmpeg_type) { case FFMPEG_AVI: case FFMPEG_MOV: case FFMPEG_MKV: @@ -929,8 +927,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; specs.channels = c->channels; @@ -974,8 +971,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)); @@ -1172,10 +1168,12 @@ static const AVOption *my_av_find_opt(void *v, const char *name, const AVOption *o= c->option; for (;o && o->name; o++) { - if (!strcmp(o->name, name) && - (!unit || (o->unit && !strcmp(o->unit, unit))) && - (o->flags & mask) == flags ) + if (!strcmp(o->name, name) && + (!unit || (o->unit && !strcmp(o->unit, unit))) && + (o->flags & mask) == flags) + { return o; + } } return NULL; } -- cgit v1.2.3 From f1d680d4b5406b65518df5e29ea3b62229077219 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 28 Apr 2012 07:00:53 +0000 Subject: fix for crash when multires subdividing a mesh with no faces (new bug in bmesh grr!) --- source/blender/blenkernel/intern/multires.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index e2142c393a5..d7212e5eaf9 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -835,7 +835,7 @@ static void multires_subdivide(MultiresModifierData *mmd, Object *ob, int totlvl MDisps *mdisps; int lvl= mmd->totlvl; - if (totlvl > multires_max_levels) + if ((totlvl > multires_max_levels) || (me->totpoly == 0)) return; multires_force_update(ob); -- cgit v1.2.3 From 950ed6929792952044a57cad00833bddc8d39f45 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 28 Apr 2012 08:29:20 +0000 Subject: code cleanup: - replace inline face UV center calc. - use const float[3] for mesh and uv functions. - remove unused define --- source/blender/blenkernel/intern/dynamicpaint.c | 2 +- source/blender/blenkernel/intern/lattice.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 31544dd5ca0..e6f38a3a334 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -2791,7 +2791,7 @@ static void mesh_faces_spherecast_dp(void *userdata, int index, const BVHTreeRay * To optimize brush detection speed this doesn't calculate hit normal. * If ray hit the second half of a quad, no[0] is set to 1.0f, else 0.0f */ -static void mesh_faces_nearest_point_dp(void *userdata, int index, const float *co, BVHTreeNearest *nearest) +static void mesh_faces_nearest_point_dp(void *userdata, int index, const float co[3], BVHTreeNearest *nearest) { const BVHTreeFromMesh *data = (BVHTreeFromMesh*) userdata; MVert *vert = data->vert; diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index f182d7bcb7c..12f11a9dee1 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -342,7 +342,7 @@ void init_latt_deform(Object *oblatt, Object *ob) } } -void calc_latt_deform(Object *ob, float *co, float weight) +void calc_latt_deform(Object *ob, float co[3], float weight) { Lattice *lt= ob->data; float u, v, w, tu[4], tv[4], tw[4]; -- cgit v1.2.3 From a434572654d95b2910324f3c6125580f4ee28afe Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 28 Apr 2012 10:09:58 +0000 Subject: Camera tracking: if there's no image for current frame display default grid and allow to interact with tracks for operators which doesn't require image. Merged from tomato branch: svn merge ^/branches/soc-2011-tomato -r45624:45625 --- source/blender/blenkernel/intern/movieclip.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index f23578e07d7..a3baa883a4a 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -925,8 +925,8 @@ void BKE_movieclip_get_size(MovieClip *clip, MovieClipUser *user, int *width, in real_ibuf_size(clip, user, ibuf, width, height); } else { - *width = 0; - *height = 0; + *width = clip->lastsize[0]; + *height = clip->lastsize[1]; } if (ibuf) -- cgit v1.2.3 From ef3acaedc1eb530b263e9235d83d853f8282a278 Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Sat, 28 Apr 2012 13:16:29 +0000 Subject: Audio: * Fix for [#31099] Audio in Meta-Strips Plays Beyond Strip Cut * Adding a split files option to the mixdown operator which then renders each channel into a separate file --- source/blender/blenkernel/intern/sequencer.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 1c06f1da018..470e1a1c529 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -515,8 +515,17 @@ void build_seqar_cb(ListBase *seqbase, Sequence ***seqar, int *totseq, *seqar = tseqar; } +static int metaseq_start(Sequence *metaseq) +{ + return metaseq->start + metaseq->startofs; +} -static void seq_update_sound_bounds_recursive(Scene *scene, Sequence *metaseq) +static int metaseq_end(Sequence *metaseq) +{ + return metaseq->start + metaseq->len - metaseq->endofs; +} + +static void seq_update_sound_bounds_recursive_rec(Scene *scene, Sequence *metaseq, int start, int end) { Sequence *seq; @@ -524,23 +533,28 @@ static void seq_update_sound_bounds_recursive(Scene *scene, Sequence *metaseq) * since sound is played outside of evaluating the imbufs, */ for (seq = metaseq->seqbase.first; seq; seq = seq->next) { if (seq->type == SEQ_META) { - seq_update_sound_bounds_recursive(scene, seq); + seq_update_sound_bounds_recursive_rec(scene, seq, MAX2(start, metaseq_start(seq)), MIN2(end, metaseq_end(seq))); } 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) - startofs = metaseq->start + metaseq->startofs - seq->start; + if (seq->startofs + seq->start < start) + startofs = start - seq->start; - if (seq->start + seq->len - seq->endofs > metaseq->start + metaseq->len - metaseq->endofs) - endofs = seq->start + seq->len - metaseq->start - metaseq->len + metaseq->endofs; + if (seq->start + seq->len - seq->endofs > end) + endofs = seq->start + seq->len - end; sound_move_scene_sound(scene, seq->scene_sound, seq->start + startofs, seq->start + seq->len - endofs, startofs); } } } } +static void seq_update_sound_bounds_recursive(Scene *scene, Sequence *metaseq) +{ + seq_update_sound_bounds_recursive_rec(scene, metaseq, metaseq_start(metaseq), metaseq_end(metaseq)); +} + void calc_sequence_disp(Scene *scene, Sequence *seq) { if (seq->startofs && seq->startstill) seq->startstill = 0; -- cgit v1.2.3 From ef054e165cad35715a5b2388aac3db68a65ea275 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 28 Apr 2012 15:14:16 +0000 Subject: style cleanup: format 'for' loop macros the same as for loops, some renaming to BLI_array macros. --- source/blender/blenkernel/intern/DerivedMesh.c | 2 +- source/blender/blenkernel/intern/editderivedmesh.c | 6 +++--- source/blender/blenkernel/intern/ipo.c | 2 +- source/blender/blenkernel/intern/mesh.c | 22 +++++++++++----------- source/blender/blenkernel/intern/modifiers_bmesh.c | 4 ++-- source/blender/blenkernel/intern/object.c | 7 ++++--- source/blender/blenkernel/intern/sequencer.c | 5 ++--- source/blender/blenkernel/intern/subsurf_ccg.c | 10 +++++----- 8 files changed, 29 insertions(+), 29 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 511b4603791..0fd030be39c 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -1223,7 +1223,7 @@ void DM_update_weight_mcol(Object *ob, DerivedMesh *dm, int const draw_flag, for (i=0; inumPolyData; i++, mp++) { ml = mloop + mp->loopstart; - BLI_array_growitems(wtcol_l, mp->totloop); + BLI_array_grow_items(wtcol_l, mp->totloop); for (j = 0; j < mp->totloop; j++, ml++, totloop++) { copy_v4_v4_char((char *)&wtcol_l[totloop], (char *)&wtcol_v[4 * ml->v]); diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c index 857f6e75e2c..263f89a363e 100644 --- a/source/blender/blenkernel/intern/editderivedmesh.c +++ b/source/blender/blenkernel/intern/editderivedmesh.c @@ -162,7 +162,7 @@ static void BMEdit_RecalcTessellation_intern(BMEditMesh *tm) /* no need to ensure the loop order, we know its ok */ else if (f->len == 3) { - BLI_array_growone(looptris); + BLI_array_grow_one(looptris); l = BM_iter_new(&liter, bm, BM_LOOPS_OF_FACE, f); for (j=0; l; l=BM_iter_step(&liter), j++) { looptris[i][j] = l; @@ -171,7 +171,7 @@ static void BMEdit_RecalcTessellation_intern(BMEditMesh *tm) } else if (f->len == 4) { BMLoop *ltmp[4]; - BLI_array_growitems(looptris, 2); + BLI_array_grow_items(looptris, 2); l = BM_iter_new(&liter, bm, BM_LOOPS_OF_FACE, f); for (j=0; l; l=BM_iter_step(&liter), j++) { @@ -219,7 +219,7 @@ static void BMEdit_RecalcTessellation_intern(BMEditMesh *tm) BLI_addfilledge(&sf_ctx, firstv, v); totfilltri = BLI_edgefill_ex(&sf_ctx, FALSE, f->no); - BLI_array_growitems(looptris, totfilltri); + BLI_array_grow_items(looptris, totfilltri); for (efa = sf_ctx.fillfacebase.first; efa; efa=efa->next) { BMLoop *l1= efa->v1->tmp.p; diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index 2fd1d291363..c33bb973385 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -1906,7 +1906,7 @@ void do_versions_ipos_to_animato(Main *main) AnimData *adt= BKE_id_add_animdata(id); - SEQ_BEGIN(ed, seq) { + SEQ_BEGIN (ed, seq) { IpoCurve *icu = (seq->ipo) ? seq->ipo->curve.first : NULL; short adrcode = SEQ_FAC1; diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 7509260d503..14ccd401a30 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1875,8 +1875,8 @@ void mesh_calc_normals(MVert *mverts, int numVerts, MLoop *mloop, MPoly *mpolys, BLI_array_empty(vertcos); BLI_array_empty(vertnos); - BLI_array_growitems(vertcos, mp->totloop); - BLI_array_growitems(vertnos, mp->totloop); + BLI_array_grow_items(vertcos, mp->totloop); + BLI_array_grow_items(vertnos, mp->totloop); for (j=0; j < mp->totloop; j++) { int vindex = ml[j].v; @@ -1885,7 +1885,7 @@ void mesh_calc_normals(MVert *mverts, int numVerts, MLoop *mloop, MPoly *mpolys, } BLI_array_empty(edgevecbuf); - BLI_array_growitems(edgevecbuf, mp->totloop); + BLI_array_grow_items(edgevecbuf, mp->totloop); accumulate_vertex_normals_poly(vertnos, pnors[i], vertcos, edgevecbuf, mp->totloop); } @@ -2422,8 +2422,8 @@ int mesh_recalcTessellation(CustomData *fdata, #ifdef USE_TESSFACE_SPEEDUP #define ML_TO_MF(i1, i2, i3) \ - BLI_array_growone(mface_to_poly_map); \ - BLI_array_growone(mface); \ + BLI_array_grow_one(mface_to_poly_map); \ + BLI_array_grow_one(mface); \ mface_to_poly_map[mface_index] = poly_index; \ mf= &mface[mface_index]; \ /* set loop indices, transformed to vert indices later */ \ @@ -2441,8 +2441,8 @@ int mesh_recalcTessellation(CustomData *fdata, /* ALMOST IDENTICAL TO DEFINE ABOVE (see EXCEPTION) */ #define ML_TO_MF_QUAD() \ - BLI_array_growone(mface_to_poly_map); \ - BLI_array_growone(mface); \ + BLI_array_grow_one(mface_to_poly_map); \ + BLI_array_grow_one(mface); \ mface_to_poly_map[mface_index] = poly_index; \ mf= &mface[mface_index]; \ /* set loop indices, transformed to vert indices later */ \ @@ -2500,10 +2500,10 @@ int mesh_recalcTessellation(CustomData *fdata, totfilltri = BLI_edgefill(&sf_ctx, FALSE); if (totfilltri) { - BLI_array_growitems(mface_to_poly_map, totfilltri); - BLI_array_growitems(mface, totfilltri); + BLI_array_grow_items(mface_to_poly_map, totfilltri); + BLI_array_grow_items(mface, totfilltri); if (poly_orig_index) { - BLI_array_growitems(mface_orig_index, totfilltri); + BLI_array_grow_items(mface_orig_index, totfilltri); } for (f = sf_ctx.fillfacebase.first; f; f = f->next, mf++) { @@ -2672,7 +2672,7 @@ int mesh_mpoly_to_mface(struct CustomData *fdata, struct CustomData *ldata, k = 0; for (i = 0; itotloop, 3, 4)) { - BLI_array_growone(mface); + BLI_array_grow_one(mface); mf = &mface[k]; mf->mat_nr = mp->mat_nr; diff --git a/source/blender/blenkernel/intern/modifiers_bmesh.c b/source/blender/blenkernel/intern/modifiers_bmesh.c index 573b8a725b3..99bb3468320 100644 --- a/source/blender/blenkernel/intern/modifiers_bmesh.c +++ b/source/blender/blenkernel/intern/modifiers_bmesh.c @@ -117,8 +117,8 @@ void DM_to_bmesh_ex(DerivedMesh *dm, BMesh *bm) BLI_array_empty(verts); BLI_array_empty(edges); - BLI_array_growitems(verts, mp->totloop); - BLI_array_growitems(edges, mp->totloop); + BLI_array_grow_items(verts, mp->totloop); + BLI_array_grow_items(edges, mp->totloop); ml = mloop + mp->loopstart; for (j = 0; j < mp->totloop; j++, ml++) { diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 6d3cce6ccfc..6b44ba976d5 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -625,10 +625,11 @@ void unlink_object(Object *ob) #endif if (sce->ed) { Sequence *seq; - SEQ_BEGIN(sce->ed, seq) - if (seq->scene_camera==ob) { - seq->scene_camera= NULL; + SEQ_BEGIN (sce->ed, seq) { + if (seq->scene_camera == ob) { + seq->scene_camera = NULL; } + } SEQ_END } } diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 470e1a1c529..9291cb90dff 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -259,8 +259,7 @@ void seq_free_editing(Scene *scene) if (ed == NULL) return; - SEQ_BEGIN(ed, seq) - { + SEQ_BEGIN (ed, seq) { seq_free_sequence(scene, seq); } SEQ_END @@ -363,7 +362,7 @@ unsigned int seq_hash_render_data(const SeqRenderData *a) /* ************************* iterator ************************** */ /* *************** (replaces old WHILE_SEQ) ********************* */ -/* **************** use now SEQ_BEGIN() SEQ_END ***************** */ +/* **************** use now SEQ_BEGIN () SEQ_END ***************** */ /* sequence strip iterator: * - builds a full array, recursively into meta strips */ diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 83225163ea3..129d3a3f698 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -314,7 +314,7 @@ static int ss_sync_from_uv(CCGSubSurf *ss, CCGSubSurf *origss, DerivedMesh *dm, MLoop *ml = mloop + mp->loopstart; BLI_array_empty(fverts); - BLI_array_growitems(fverts, nverts); + BLI_array_grow_items(fverts, nverts); get_face_uv_map_vert(vmap, mpoly, ml, i, fverts); @@ -350,7 +350,7 @@ static int ss_sync_from_uv(CCGSubSurf *ss, CCGSubSurf *origss, DerivedMesh *dm, CCGFace *f; BLI_array_empty(fverts); - BLI_array_growitems(fverts, nverts); + BLI_array_grow_items(fverts, nverts); get_face_uv_map_vert(vmap, mpoly, ml, i, fverts); ccgSubSurf_syncFace(ss, SET_INT_IN_POINTER(i), nverts, fverts, &f); @@ -583,7 +583,7 @@ static void ss_sync_from_derivedmesh(CCGSubSurf *ss, DerivedMesh *dm, CCGFace *f; BLI_array_empty(fVerts); - BLI_array_growitems(fVerts, mp->totloop); + BLI_array_grow_items(fVerts, mp->totloop); ml = mloop + mp->loopstart; for (j = 0; j < mp->totloop; j++, ml++) { @@ -3150,13 +3150,13 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, *((int *)ccgSubSurf_getFaceUserData(ss, f)) = vertNum; BLI_array_empty(loopidx); - BLI_array_growitems(loopidx, numVerts); + BLI_array_grow_items(loopidx, numVerts); for (s = 0; s < numVerts; s++) { loopidx[s] = loopindex++; } BLI_array_empty(vertidx); - BLI_array_growitems(vertidx, numVerts); + BLI_array_grow_items(vertidx, numVerts); for (s = 0; s < numVerts; s++) { CCGVert *v = ccgSubSurf_getFaceVert(f, s); vertidx[s] = GET_INT_FROM_POINTER(ccgSubSurf_getVertVertHandle(v)); -- cgit v1.2.3 From f88cfd9168c2977fc4acc414d8709da6484e23e7 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 28 Apr 2012 16:49:00 +0000 Subject: Code and style cleanup in own modules in BKE and also mball module - Make sure functions are named in way BKE__ (same way as RNA callbacks) - Make functions which are used by mball.c only static and remove their prototypes from public header file. Further cleanup is coming. --- source/blender/blenkernel/intern/anim.c | 2 +- source/blender/blenkernel/intern/armature.c | 8 +- source/blender/blenkernel/intern/colortools.c | 4 +- source/blender/blenkernel/intern/curve.c | 180 ++++++++++++------------ source/blender/blenkernel/intern/depsgraph.c | 2 +- source/blender/blenkernel/intern/displist.c | 51 +++---- source/blender/blenkernel/intern/fcurve.c | 2 +- source/blender/blenkernel/intern/font.c | 2 +- source/blender/blenkernel/intern/key.c | 8 +- source/blender/blenkernel/intern/library.c | 14 +- source/blender/blenkernel/intern/material.c | 2 +- source/blender/blenkernel/intern/mball.c | 190 ++++++++++++++++++++------ source/blender/blenkernel/intern/mesh.c | 2 +- source/blender/blenkernel/intern/movieclip.c | 6 +- source/blender/blenkernel/intern/object.c | 22 +-- source/blender/blenkernel/intern/softbody.c | 2 +- 16 files changed, 299 insertions(+), 198 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 05171a5d9f5..38c73ba72b9 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -482,7 +482,7 @@ void calc_curvepath(Object *ob) if (ob==NULL || ob->type != OB_CURVE) return; cu= ob->data; - nurbs= BKE_curve_nurbs(cu); + nurbs= BKE_curve_nurbs_get(cu); nu= nurbs->first; if (cu->path) free_path(cu->path); diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 931aa2d6242..d1d6833e903 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -566,13 +566,13 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest) if (bone->segments > MAX_BBONE_SUBDIV) bone->segments = MAX_BBONE_SUBDIV; - forward_diff_bezier(0.0, h1[0], h2[0], 0.0, data[0], + BKE_curve_forward_diff_bezier(0.0, h1[0], h2[0], 0.0, data[0], MAX_BBONE_SUBDIV, 4*sizeof(float)); - forward_diff_bezier(0.0, h1[1], length + h2[1], length, data[0]+1, + BKE_curve_forward_diff_bezier(0.0, h1[1], length + h2[1], length, data[0]+1, MAX_BBONE_SUBDIV, 4*sizeof(float)); - forward_diff_bezier(0.0, h1[2], h2[2], 0.0, data[0]+2, + BKE_curve_forward_diff_bezier(0.0, h1[2], h2[2], 0.0, data[0]+2, MAX_BBONE_SUBDIV, 4*sizeof(float)); - forward_diff_bezier(roll1, roll1 + 0.390464f*(roll2-roll1), roll2 - 0.390464f*(roll2-roll1), roll2, data[0]+3, + BKE_curve_forward_diff_bezier(roll1, roll1 + 0.390464f*(roll2-roll1), roll2 - 0.390464f*(roll2-roll1), roll2, data[0]+3, MAX_BBONE_SUBDIV, 4*sizeof(float)); equalize_bezier(data[0], bone->segments); /* note: does stride 4! */ diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 2d5631509b4..6dc1b2a4b00 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -499,8 +499,8 @@ static void curvemap_make_table(CurveMap *cuma, rctf *clipr) for (a=0; atotpoint-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)); + BKE_curve_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)); + BKE_curve_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)); } /* store first and last handle for extrapolation, unit length */ diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index e5b2e5f69c7..e0cadac586b 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -70,7 +70,7 @@ static int cu_isectLL(const float v1[3], const float v2[3], const float v3[3], c short cox, short coy, float *labda, float *mu, float vec[3]); -void unlink_curve(Curve *cu) +void BKE_curve_unlink(Curve *cu) { int a; @@ -95,7 +95,7 @@ void unlink_curve(Curve *cu) } /* frees editcurve entirely */ -void BKE_free_editfont(Curve *cu) +void BKE_curve_editfont_free(Curve *cu) { if (cu->editfont) { EditFont *ef= cu->editfont; @@ -112,7 +112,7 @@ void BKE_free_editfont(Curve *cu) } } -void free_curve_editNurb_keyIndex(EditNurb *editnurb) +void BKE_curve_editNurb_keyIndex_free(EditNurb *editnurb) { if (!editnurb->keyindex) { return; @@ -121,26 +121,26 @@ void free_curve_editNurb_keyIndex(EditNurb *editnurb) editnurb->keyindex= NULL; } -void free_curve_editNurb (Curve *cu) +void BKE_curve_editNurb_free (Curve *cu) { if (cu->editnurb) { - freeNurblist(&cu->editnurb->nurbs); - free_curve_editNurb_keyIndex(cu->editnurb); + BKE_nurbList_free(&cu->editnurb->nurbs); + BKE_curve_editNurb_keyIndex_free(cu->editnurb); MEM_freeN(cu->editnurb); cu->editnurb= NULL; } } /* don't free curve itself */ -void free_curve(Curve *cu) +void BKE_curve_free(Curve *cu) { - freeNurblist(&cu->nurb); + BKE_nurbList_free(&cu->nurb); BLI_freelistN(&cu->bev); freedisplist(&cu->disp); - BKE_free_editfont(cu); + BKE_curve_editfont_free(cu); - free_curve_editNurb(cu); - unlink_curve(cu); + BKE_curve_editNurb_free(cu); + BKE_curve_unlink(cu); BKE_free_animdata((ID *)cu); if (cu->mat) MEM_freeN(cu->mat); @@ -151,7 +151,7 @@ void free_curve(Curve *cu) if (cu->tb) MEM_freeN(cu->tb); } -Curve *add_curve(const char *name, int type) +Curve *BKE_curve_add(const char *name, int type) { Curve *cu; @@ -187,14 +187,14 @@ Curve *add_curve(const char *name, int type) return cu; } -Curve *copy_curve(Curve *cu) +Curve *BKE_curve_copy(Curve *cu) { Curve *cun; int a; cun= copy_libblock(&cu->id); cun->nurb.first= cun->nurb.last= NULL; - duplicateNurblist( &(cun->nurb), &(cu->nurb)); + BKE_nurbList_duplicate( &(cun->nurb), &(cu->nurb)); cun->mat= MEM_dupallocN(cu->mat); for (a=0; atotcol; a++) { @@ -242,7 +242,7 @@ static void extern_local_curve(Curve *cu) } } -void make_local_curve(Curve *cu) +void BKE_curve_make_local(Curve *cu) { Main *bmain= G.main; Object *ob; @@ -273,7 +273,7 @@ void make_local_curve(Curve *cu) extern_local_curve(cu); } else if (is_local && is_lib) { - Curve *cu_new= copy_curve(cu); + Curve *cu_new= BKE_curve_copy(cu); cu_new->id.us= 0; BKE_id_lib_local_paths(bmain, cu->id.lib, &cu_new->id); @@ -291,7 +291,7 @@ void make_local_curve(Curve *cu) } /* Get list of nurbs from editnurbs structure */ -ListBase *curve_editnurbs(Curve *cu) +ListBase *BKE_curve_editNurbs_get(Curve *cu) { if (cu->editnurb) { return &cu->editnurb->nurbs; @@ -300,7 +300,7 @@ ListBase *curve_editnurbs(Curve *cu) return NULL; } -short curve_type(Curve *cu) +short BKE_curve_type_get(Curve *cu) { Nurb *nu; int type= cu->type; @@ -322,9 +322,9 @@ short curve_type(Curve *cu) return type; } -void update_curve_dimension(Curve *cu) +void BKE_curve_curve_dimension_update(Curve *cu) { - ListBase *nurbs= BKE_curve_nurbs(cu); + ListBase *nurbs= BKE_curve_nurbs_get(cu); Nurb *nu= nurbs->first; if (cu->flag&CU_3D) { @@ -335,24 +335,24 @@ void update_curve_dimension(Curve *cu) else { for ( ; nu; nu= nu->next) { nu->flag |= CU_2D; - test2DNurb(nu); + BKE_nurb_test2D(nu); /* since the handles are moved they need to be auto-located again */ if (nu->type == CU_BEZIER) - calchandlesNurb(nu); + BKE_nurb_handles_calc(nu); } } } -void test_curve_type(Object *ob) +void BKE_curve_type_test(Object *ob) { - ob->type= curve_type(ob->data); + ob->type= BKE_curve_type_get(ob->data); if (ob->type==OB_CURVE) - update_curve_dimension((Curve *)ob->data); + BKE_curve_curve_dimension_update((Curve *)ob->data); } -void tex_space_curve(Curve *cu) +void BKE_curve_tex_space_calc(Curve *cu) { DispList *dl; BoundBox *bb; @@ -408,7 +408,7 @@ void tex_space_curve(Curve *cu) } } -int count_curveverts(ListBase *nurb) +int BKE_nurbList_verts_count(ListBase *nurb) { Nurb *nu; int tot=0; @@ -423,7 +423,7 @@ int count_curveverts(ListBase *nurb) return tot; } -int count_curveverts_without_handles(ListBase *nurb) +int BKE_nurbList_verts_count_without_handles(ListBase *nurb) { Nurb *nu; int tot=0; @@ -440,7 +440,7 @@ int count_curveverts_without_handles(ListBase *nurb) /* **************** NURBS ROUTINES ******************** */ -void freeNurb(Nurb *nu) +void BKE_nurb_free(Nurb *nu) { if (nu==NULL) return; @@ -460,7 +460,7 @@ void freeNurb(Nurb *nu) } -void freeNurblist(ListBase *lb) +void BKE_nurbList_free(ListBase *lb) { Nurb *nu, *next; @@ -469,13 +469,13 @@ void freeNurblist(ListBase *lb) nu= lb->first; while (nu) { next= nu->next; - freeNurb(nu); + BKE_nurb_free(nu); nu= next; } lb->first= lb->last= NULL; } -Nurb *duplicateNurb(Nurb *nu) +Nurb *BKE_nurb_duplicate(Nurb *nu) { Nurb *newnu; int len; @@ -515,22 +515,22 @@ Nurb *duplicateNurb(Nurb *nu) return newnu; } -void duplicateNurblist(ListBase *lb1, ListBase *lb2) +void BKE_nurbList_duplicate(ListBase *lb1, ListBase *lb2) { Nurb *nu, *nun; - freeNurblist(lb1); + BKE_nurbList_free(lb1); nu= lb2->first; while (nu) { - nun= duplicateNurb(nu); + nun= BKE_nurb_duplicate(nu); BLI_addtail(lb1, nun); nu= nu->next; } } -void test2DNurb(Nurb *nu) +void BKE_nurb_test2D(Nurb *nu) { BezTriple *bezt; BPoint *bp; @@ -559,7 +559,7 @@ void test2DNurb(Nurb *nu) } } -void minmaxNurb(Nurb *nu, float *min, float *max) +void BKE_nurb_minmax(Nurb *nu, float *min, float *max) { BezTriple *bezt; BPoint *bp; @@ -586,7 +586,7 @@ void minmaxNurb(Nurb *nu, float *min, float *max) } /* be sure to call makeknots after this */ -void addNurbPoints(Nurb *nu, int number) +void BKE_nurb_points_add(Nurb *nu, int number) { BPoint *tmp= nu->bp; int i; @@ -606,7 +606,7 @@ void addNurbPoints(Nurb *nu, int number) nu->pntsu += number; } -void addNurbPointsBezier(Nurb *nu, int number) +void BKE_nurb_bezierPoints_add(Nurb *nu, int number) { BezTriple *tmp= nu->bezt; int i; @@ -706,7 +706,7 @@ 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 (BKE_nurb_check_valid_u(nu)) { nu->knotsu= MEM_callocN(4+sizeof(float)*KNOTSU(nu), "makeknots"); if (nu->flagu & CU_NURB_CYCLIC) { calcknots(nu->knotsu, nu->pntsu, nu->orderu, 0); /* cyclic should be uniform */ @@ -721,7 +721,7 @@ static void makeknots(Nurb *nu, short uv) } else if (uv == 2) { if (nu->knotsv) MEM_freeN(nu->knotsv); - if (check_valid_nurb_v(nu)) { + if (BKE_nurb_check_valid_v(nu)) { nu->knotsv= MEM_callocN(4+sizeof(float)*KNOTSV(nu), "makeknots"); if (nu->flagv & CU_NURB_CYCLIC) { calcknots(nu->knotsv, nu->pntsv, nu->orderv, 0); /* cyclic should be uniform */ @@ -736,12 +736,12 @@ static void makeknots(Nurb *nu, short uv) } } -void nurbs_knot_calc_u(Nurb *nu) +void BKE_nurb_knot_calc_u(Nurb *nu) { makeknots(nu, 1); } -void nurbs_knot_calc_v(Nurb *nu) +void BKE_nurb_knot_calc_v(Nurb *nu) { makeknots(nu, 2); } @@ -809,7 +809,7 @@ static void basisNurb(float t, short order, short pnts, float *knots, float *bas } -void makeNurbfaces(Nurb *nu, float *coord_array, int rowstride, int resolu, int resolv) +void BKE_nurb_makeFaces(Nurb *nu, float *coord_array, int rowstride, int resolu, int resolv) /* coord_array has to be 3*4*resolu*resolv in size, and zero-ed */ { BPoint *bp; @@ -972,7 +972,7 @@ void makeNurbfaces(Nurb *nu, float *coord_array, int rowstride, int resolu, int MEM_freeN(jend); } -void makeNurbcurve(Nurb *nu, float *coord_array, float *tilt_array, float *radius_array, float *weight_array, int resolu, int stride) +void BKE_nurb_makeCurve(Nurb *nu, float *coord_array, float *tilt_array, float *radius_array, float *weight_array, int resolu, int stride) /* coord_array has to be 3*4*pntsu*resolu in size and zero-ed * tilt_array and radius_array will be written to if valid */ { @@ -1074,7 +1074,7 @@ void makeNurbcurve(Nurb *nu, float *coord_array, float *tilt_array, float *radiu } /* forward differencing method for bezier curve */ -void forward_diff_bezier(float q0, float q1, float q2, float q3, float *p, int it, int stride) +void BKE_curve_forward_diff_bezier(float q0, float q1, float q2, float q3, float *p, int it, int stride) { float rt0,rt1,rt2,rt3,f; int a; @@ -1122,7 +1122,7 @@ static void forward_diff_bezier_cotangent(float *p0, float *p1, float *p2, float /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -float *make_orco_surf(Object *ob) +float *BKE_curve_surf_make_orco(Object *ob) { /* Note: this function is used in convertblender only atm, so * suppose nonzero curve's render resolution should always be used */ @@ -1190,7 +1190,7 @@ float *make_orco_surf(Object *ob) float *_tdata= MEM_callocN((nu->pntsu*resolu) * (nu->pntsv*resolv) *3*sizeof(float), "temp data"); float *tdata= _tdata; - makeNurbfaces(nu, tdata, 0, resolu, resolv); + BKE_nurb_makeFaces(nu, tdata, 0, resolu, resolv); for (b=0; bdata; DispList *dl; @@ -1312,7 +1312,7 @@ float *make_orco_curve(Scene *scene, Object *ob) /* ***************** BEVEL ****************** */ -void makebevelcurve(Scene *scene, Object *ob, ListBase *disp, int forRender) +void BKE_curve_bevel_make(Scene *scene, Object *ob, ListBase *disp, int forRender) { DispList *dl, *dlnew; Curve *bevcu, *cu; @@ -2083,7 +2083,7 @@ static void make_bevel_list_segment_3D(BevList *bl) -void makeBevelList(Object *ob) +void BKE_curve_bevelList_make(Object *ob) { /* * - convert all curves to polys, with indication of resol and flags for double-vertices @@ -2112,7 +2112,7 @@ void makeBevelList(Object *ob) BLI_freelistN(&(cu->bev)); if (cu->editnurb && ob->type!=OB_FONT) { - ListBase *nurbs= curve_editnurbs(cu); + ListBase *nurbs= BKE_curve_editNurbs_get(cu); nu = nurbs->first; } else { @@ -2128,7 +2128,7 @@ 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 (!BKE_nurb_check_valid_u(nu)) { bl= MEM_callocN(sizeof(BevList)+1*sizeof(BevPoint), "makeBevelList1"); BLI_addtail(&(cu->bev), bl); bl->nr= 0; @@ -2201,7 +2201,7 @@ void makeBevelList(Object *ob) /* BevPoint must stay aligned to 4 so sizeof(BevPoint)/sizeof(float) works */ for (j=0; j<3; j++) { - forward_diff_bezier( prevbezt->vec[1][j], prevbezt->vec[2][j], + BKE_curve_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)); } @@ -2256,7 +2256,7 @@ void makeBevelList(Object *ob) else bl->poly= -1; bevp= (BevPoint *)(bl+1); - makeNurbcurve( nu, &bevp->vec[0], + BKE_nurb_makeCurve( nu, &bevp->vec[0], do_tilt ? &bevp->alfa : NULL, do_radius ? &bevp->radius : NULL, do_weight ? &bevp->weight : NULL, @@ -2719,18 +2719,18 @@ static void calchandlesNurb_intern(Nurb *nu, int skip_align) } } -void calchandleNurb(BezTriple *bezt, BezTriple *prev, BezTriple *next, int mode) +void BKE_nurb_handle_calc(BezTriple *bezt, BezTriple *prev, BezTriple *next, int mode) { calchandleNurb_intern(bezt, prev, next, mode, FALSE); } -void calchandlesNurb(Nurb *nu) /* first, if needed, set handle flags */ +void BKE_nurb_handles_calc(Nurb *nu) /* first, if needed, set handle flags */ { calchandlesNurb_intern(nu, FALSE); } -void testhandlesNurb(Nurb *nu) +void BKE_nurb_handles_test(Nurb *nu) { /* use when something has changed with handles. * it treats all BezTriples with the following rules: @@ -2770,10 +2770,10 @@ void testhandlesNurb(Nurb *nu) bezt++; } - calchandlesNurb(nu); + BKE_nurb_handles_calc(nu); } -void autocalchandlesNurb(Nurb *nu, int flag) +void BKE_nurb_handles_autocalc(Nurb *nu, int flag) { /* checks handle coordinates and calculates type */ @@ -2841,21 +2841,21 @@ void autocalchandlesNurb(Nurb *nu, int flag) bezt2++; } - calchandlesNurb(nu); + BKE_nurb_handles_calc(nu); } -void autocalchandlesNurb_all(ListBase *editnurb, int flag) +void BKE_nurbList_handles_autocalc(ListBase *editnurb, int flag) { Nurb *nu; nu= editnurb->first; while (nu) { - autocalchandlesNurb(nu, flag); + BKE_nurb_handles_autocalc(nu, flag); nu= nu->next; } } -void sethandlesNurb(ListBase *editnurb, short code) +void BKE_nurbList_handles_set(ListBase *editnurb, short code) { /* code==1: set autohandle */ /* code==2: set vectorhandle */ @@ -2884,7 +2884,7 @@ void sethandlesNurb(ListBase *editnurb, short code) } bezt++; } - calchandlesNurb(nu); + BKE_nurb_handles_calc(nu); } nu= nu->next; } @@ -2928,7 +2928,7 @@ void sethandlesNurb(ListBase *editnurb, short code) bezt++; } - calchandlesNurb(nu); + BKE_nurb_handles_calc(nu); } nu= nu->next; } @@ -2958,7 +2958,7 @@ static void swapdata(void *adr1, void *adr2, int len) } } -void switchdirectionNurb(Nurb *nu) +void BKE_nurb_direction_switch(Nurb *nu) { BezTriple *bezt1, *bezt2; BPoint *bp1, *bp2; @@ -3064,9 +3064,9 @@ void switchdirectionNurb(Nurb *nu) } -float (*curve_getVertexCos(Curve *UNUSED(cu), ListBase *lb, int *numVerts_r))[3] +float (*BKE_curve_vertexCos_get(Curve *UNUSED(cu), ListBase *lb, int *numVerts_r))[3] { - int i, numVerts = *numVerts_r = count_curveverts(lb); + int i, numVerts = *numVerts_r = BKE_nurbList_verts_count(lb); float *co, (*cos)[3] = MEM_mallocN(sizeof(*cos)*numVerts, "cu_vcos"); Nurb *nu; @@ -3093,7 +3093,7 @@ float (*curve_getVertexCos(Curve *UNUSED(cu), ListBase *lb, int *numVerts_r))[3] return cos; } -void curve_applyVertexCos(Curve *UNUSED(cu), ListBase *lb, float (*vertexCos)[3]) +void BK_curve_vertexCos_apply(Curve *UNUSED(cu), ListBase *lb, float (*vertexCos)[3]) { float *co = vertexCos[0]; Nurb *nu; @@ -3121,9 +3121,9 @@ void curve_applyVertexCos(Curve *UNUSED(cu), ListBase *lb, float (*vertexCos)[3] } } -float (*curve_getKeyVertexCos(Curve *UNUSED(cu), ListBase *lb, float *key))[3] +float (*BKE_curve_keyVertexCos_get(Curve *UNUSED(cu), ListBase *lb, float *key))[3] { - int i, numVerts = count_curveverts(lb); + int i, numVerts = BKE_nurbList_verts_count(lb); float *co, (*cos)[3] = MEM_mallocN(sizeof(*cos)*numVerts, "cu_vcos"); Nurb *nu; @@ -3152,7 +3152,7 @@ float (*curve_getKeyVertexCos(Curve *UNUSED(cu), ListBase *lb, float *key))[3] return cos; } -void curve_applyKeyVertexTilts(Curve *UNUSED(cu), ListBase *lb, float *key) +void BKE_curve_keyVertexTilts_apply(Curve *UNUSED(cu), ListBase *lb, float *key) { Nurb *nu; int i; @@ -3179,7 +3179,7 @@ void curve_applyKeyVertexTilts(Curve *UNUSED(cu), ListBase *lb, float *key) } } -int check_valid_nurb_u( struct Nurb *nu ) +int BKE_nurb_check_valid_u( struct Nurb *nu ) { if (nu==NULL) return 0; if (nu->pntsu <= 1) return 0; @@ -3194,7 +3194,7 @@ int check_valid_nurb_u( struct Nurb *nu ) } return 1; } -int check_valid_nurb_v( struct Nurb *nu) +int BKE_nurb_check_valid_v( struct Nurb *nu) { if (nu==NULL) return 0; if (nu->pntsv <= 1) return 0; @@ -3210,7 +3210,7 @@ int check_valid_nurb_v( struct Nurb *nu) return 1; } -int clamp_nurb_order_u( struct Nurb *nu ) +int BKE_nurb_order_clamp_u( struct Nurb *nu ) { int change = 0; if (nu->pntsuorderu) { @@ -3224,7 +3224,7 @@ int clamp_nurb_order_u( struct Nurb *nu ) return change; } -int clamp_nurb_order_v( struct Nurb *nu) +int BKE_nurb_order_clamp_v( struct Nurb *nu) { int change = 0; if (nu->pntsvorderv) { @@ -3239,10 +3239,10 @@ int clamp_nurb_order_v( struct Nurb *nu) } /* Get edit nurbs or normal nurbs list */ -ListBase *BKE_curve_nurbs(Curve *cu) +ListBase *BKE_curve_nurbs_get(Curve *cu) { if (cu->editnurb) { - return curve_editnurbs(cu); + return BKE_curve_editNurbs_get(cu); } return &cu->nurb; @@ -3250,20 +3250,20 @@ ListBase *BKE_curve_nurbs(Curve *cu) /* basic vertex data functions */ -int minmax_curve(Curve *cu, float min[3], float max[3]) +int BKE_curve_minmax(Curve *cu, float min[3], float max[3]) { - ListBase *nurb_lb= BKE_curve_nurbs(cu); + ListBase *nurb_lb= BKE_curve_nurbs_get(cu); Nurb *nu; for (nu= nurb_lb->first; nu; nu= nu->next) - minmaxNurb(nu, min, max); + BKE_nurb_minmax(nu, min, max); return (nurb_lb->first != NULL); } -int curve_center_median(Curve *cu, float cent[3]) +int BKE_curve_center_median(Curve *cu, float cent[3]) { - ListBase *nurb_lb= BKE_curve_nurbs(cu); + ListBase *nurb_lb= BKE_curve_nurbs_get(cu); Nurb *nu; int total= 0; @@ -3297,11 +3297,11 @@ int curve_center_median(Curve *cu, float cent[3]) return (total != 0); } -int curve_center_bounds(Curve *cu, float cent[3]) +int BKE_curve_center_bounds(Curve *cu, float cent[3]) { float min[3], max[3]; INIT_MINMAX(min, max); - if (minmax_curve(cu, min, max)) { + if (BKE_curve_minmax(cu, min, max)) { mid_v3_v3v3(cent, min, max); return 1; } @@ -3309,9 +3309,9 @@ int curve_center_bounds(Curve *cu, float cent[3]) return 0; } -void curve_translate(Curve *cu, float offset[3], int do_keys) +void BKE_curve_translate(Curve *cu, float offset[3], int do_keys) { - ListBase *nurb_lb= BKE_curve_nurbs(cu); + ListBase *nurb_lb= BKE_curve_nurbs_get(cu); Nurb *nu; int i; @@ -3346,9 +3346,9 @@ void curve_translate(Curve *cu, float offset[3], int do_keys) } } -void curve_delete_material_index(Curve *cu, int index) +void BKE_curve_delete_material_index(Curve *cu, int index) { - const int curvetype= curve_type(cu); + const int curvetype= BKE_curve_type_get(cu); if (curvetype == OB_FONT) { struct CharInfo *info= cu->strinfo; diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 246c973169e..045d85242f1 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -539,7 +539,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O break; case OB_MBALL: { - Object *mom= find_basis_mball(scene, ob); + Object *mom= BKE_metaball_basis_find(scene, ob); if (mom!=ob) { node2 = dag_get_node(dag, mom); diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index fcd80698d5c..3d79386e19a 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -1,4 +1,5 @@ /* + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -296,7 +297,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, i else resolu= nu->resolu; - if (!check_valid_nurb_u(nu)); + if (!BKE_nurb_check_valid_u(nu)); else if (nu->type == CU_BEZIER) { /* count */ @@ -351,7 +352,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, i else { int j; for (j=0; j<3; j++) { - forward_diff_bezier( prevbezt->vec[1][j], + BKE_curve_forward_diff_bezier( prevbezt->vec[1][j], prevbezt->vec[2][j], bezt->vec[0][j], bezt->vec[1][j], @@ -384,7 +385,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, i data= dl->verts; 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)); + BKE_nurb_makeCurve(nu, data, NULL, NULL, NULL, resolu, 3*sizeof(float)); } else if (nu->type == CU_POLY) { len= nu->pntsu; @@ -672,9 +673,9 @@ void makeDispListMBall(Scene *scene, Object *ob) freedisplist(&(ob->disp)); if (ob->type==OB_MBALL) { - if (ob==find_basis_mball(scene, ob)) { - metaball_polygonize(scene, ob, &ob->disp); - tex_space_mball(ob); + if (ob==BKE_metaball_basis_find(scene, ob)) { + BKE_metaball_polygonize(scene, ob, &ob->disp); + BKE_metaball_tex_space_calc(ob); object_deform_mball(ob, &ob->disp); } @@ -685,8 +686,8 @@ void makeDispListMBall(Scene *scene, Object *ob) void makeDispListMBall_forRender(Scene *scene, Object *ob, ListBase *dispbase) { - metaball_polygonize(scene, ob, dispbase); - tex_space_mball(ob); + BKE_metaball_polygonize(scene, ob, dispbase); + BKE_metaball_tex_space_calc(ob); object_deform_mball(ob, dispbase); } @@ -730,7 +731,7 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, fl ModifierData *md = modifiers_getVirtualModifierList(ob); ModifierData *pretessellatePoint; Curve *cu= ob->data; - ListBase *nurb= BKE_curve_nurbs(cu); + ListBase *nurb= BKE_curve_nurbs_get(cu); int numVerts = 0; int editmode = (!forRender && cu->editnurb); float (*originalVerts)[3] = NULL; @@ -753,9 +754,9 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, fl * tilts, which is passed through in the modifier stack. * this is also the reason curves do not use a virtual * shape key modifier yet. */ - deformedVerts= curve_getKeyVertexCos(cu, nurb, keyVerts); + deformedVerts= BKE_curve_keyVertexCos_get(cu, nurb, keyVerts); originalVerts= MEM_dupallocN(deformedVerts); - numVerts = count_curveverts_without_handles(nurb); + numVerts = BKE_nurbList_verts_count_without_handles(nurb); } } @@ -770,7 +771,7 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, fl if (mti->type!=eModifierTypeType_OnlyDeform) continue; if (!deformedVerts) { - deformedVerts = curve_getVertexCos(cu, nurb, &numVerts); + deformedVerts = BKE_curve_vertexCos_get(cu, nurb, &numVerts); originalVerts = MEM_dupallocN(deformedVerts); } @@ -782,9 +783,9 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, fl } if (deformedVerts) - curve_applyVertexCos(cu, nurb, deformedVerts); + BK_curve_vertexCos_apply(cu, nurb, deformedVerts); if (keyVerts) /* these are not passed through modifier stack */ - curve_applyKeyVertexTilts(cu, nurb, keyVerts); + BKE_curve_keyVertexTilts_apply(cu, nurb, keyVerts); if (keyVerts) MEM_freeN(keyVerts); @@ -834,7 +835,7 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba ModifierData *md = modifiers_getVirtualModifierList(ob); ModifierData *pretessellatePoint; Curve *cu= ob->data; - ListBase *nurb= BKE_curve_nurbs(cu); + ListBase *nurb= BKE_curve_nurbs_get(cu); int required_mode = 0, totvert = 0; int editmode = (!forRender && cu->editnurb); DerivedMesh *dm= NULL, *ndm; @@ -956,7 +957,7 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba } if (deformedVerts) { - curve_applyVertexCos(ob->data, nurb, originalVerts); + BK_curve_vertexCos_apply(ob->data, nurb, originalVerts); MEM_freeN(originalVerts); MEM_freeN(deformedVerts); } @@ -1023,7 +1024,7 @@ static void add_orco_dm(Scene *scene, Object *ob, DerivedMesh *dm, DerivedMesh * dm->getVertCos(dm, orco); } else { - orco= (float(*)[3])make_orco_curve(scene, ob); + orco= (float(*)[3])BKE_curve_make_orco(scene, ob); } for (a=0; aeditnurb) - nubase= curve_editnurbs(cu); + nubase= BKE_curve_editNurbs_get(cu); else nubase= &cu->nurb; @@ -1144,7 +1145,7 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase, 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)); + BKE_nurb_makeCurve(nu, data, NULL, NULL, NULL, resolu, 3*sizeof(float)); } else { len= (nu->pntsu*resolu) * (nu->pntsv*resolv); @@ -1168,7 +1169,7 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase, 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); + BKE_nurb_makeFaces(nu, data, 0, resolu, resolv); /* gl array drawing: using indices */ displist_surf_indices(dl); @@ -1182,7 +1183,7 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase, copy_displist(&cu->disp, dispbase); if (!forRender) { - tex_space_curve(cu); + BKE_curve_tex_space_calc(cu); } if (!forOrco) @@ -1262,7 +1263,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba float (*deformedVerts)[3]; int numVerts; - nubase= BKE_curve_nurbs(cu); + nubase= BKE_curve_nurbs_get(cu); BLI_freelistN(&(cu->bev)); @@ -1273,10 +1274,10 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba if (!forOrco) curve_calc_modifiers_pre(scene, ob, forRender, &originalVerts, &deformedVerts, &numVerts); - makeBevelList(ob); + BKE_curve_bevelList_make(ob); /* If curve has no bevel will return nothing */ - makebevelcurve(scene, ob, &dlbev, forRender); + BKE_curve_bevel_make(scene, ob, &dlbev, forRender); /* no bevel or extrude, and no width correction? */ if (!dlbev.first && cu->width==1.0f) { @@ -1410,7 +1411,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba copy_displist(&cu->disp, dispbase); if (!forRender) { - tex_space_curve(cu); + BKE_curve_tex_space_calc(cu); } if (!forOrco) curve_calc_modifiers_post(scene, ob, dispbase, derivedFinal, forRender, originalVerts, deformedVerts); diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 806d795cc9d..e85432581d5 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -800,7 +800,7 @@ void calchandles_fcurve (FCurve *fcu) if (bezt->vec[2][0] < bezt->vec[1][0]) bezt->vec[2][0]= bezt->vec[1][0]; /* calculate auto-handles */ - calchandleNurb(bezt, prev, next, 1); /* 1==special autohandle */ + BKE_nurb_handle_calc(bezt, prev, next, 1); /* 1==special autohandle */ /* for automatic ease in and out */ if (ELEM(bezt->h1,HD_AUTO,HD_AUTO_ANIM) && ELEM(bezt->h2,HD_AUTO,HD_AUTO_ANIM)) { diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index cdc923600d7..5d7960a9823 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -1011,7 +1011,7 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m if (mode == FO_EDIT) { /* make nurbdata */ - freeNurblist(&cu->nurb); + BKE_nurbList_free(&cu->nurb); ct= chartransdata; if (cu->sepchar==0) { diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index 0a1c0467244..54a2613991a 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -1594,7 +1594,7 @@ void curve_to_key(Curve *cu, KeyBlock *kb, ListBase *nurb) int a, tot; /* count */ - tot = count_curveverts(nurb); + tot = BKE_nurbList_verts_count(nurb); if (tot == 0) return; if (kb->data) MEM_freeN(kb->data); @@ -1647,7 +1647,7 @@ void key_to_curve(KeyBlock *kb, Curve *UNUSED(cu), ListBase *nurb) nu = nurb->first; fp = kb->data; - tot = count_curveverts(nurb); + tot = BKE_nurbList_verts_count(nurb); tot = MIN2(kb->totelem, tot); @@ -1742,7 +1742,7 @@ float (*key_to_vertcos(Object * ob, KeyBlock * kb))[3] } else if (ELEM(ob->type, OB_CURVE, OB_SURF)) { Curve *cu = (Curve *)ob->data; - tot = count_curveverts(&cu->nurb); + tot = BKE_nurbList_verts_count(&cu->nurb); } if (tot == 0) return NULL; @@ -1822,7 +1822,7 @@ void vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3]) else if (ELEM(ob->type, OB_CURVE, OB_SURF)) { Curve *cu = (Curve *)ob->data; elemsize = cu->key->elemsize; - tot = count_curveverts(&cu->nurb); + tot = BKE_nurbList_verts_count(&cu->nurb); } if (tot == 0) { diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 07839b10ef1..71266275fbd 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -198,12 +198,12 @@ int id_make_local(ID *id, int test) return 1; case ID_CU: if (!test) { - make_local_curve((Curve*)id); + BKE_curve_make_local((Curve*)id); make_local_key(((Curve*)id)->key); } return 1; case ID_MB: - if (!test) make_local_mball((MetaBall*)id); + if (!test) BKE_metaball_make_local((MetaBall*)id); return 1; case ID_MA: if (!test) make_local_material((Material*)id); @@ -291,10 +291,10 @@ int id_copy(ID *id, ID **newid, int test) 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*)BKE_curve_copy((Curve*)id); return 1; case ID_MB: - if (!test) *newid= (ID*)copy_mball((MetaBall*)id); + if (!test) *newid= (ID*)BKE_metaball_copy((MetaBall*)id); return 1; case ID_MA: if (!test) *newid= (ID*)copy_material((Material*)id); @@ -810,10 +810,10 @@ void free_libblock(ListBase *lb, void *idv) free_mesh((Mesh *)id, 1); break; case ID_CU: - free_curve((Curve *)id); + BKE_curve_free((Curve *)id); break; case ID_MB: - free_mball((MetaBall *)id); + BKE_metaball_free((MetaBall *)id); break; case ID_MA: free_material((Material *)id); @@ -886,7 +886,7 @@ void free_libblock(ListBase *lb, void *idv) free_gpencil_data((bGPdata *)id); break; case ID_MC: - free_movieclip((MovieClip *)id); + BKE_movieclip_free((MovieClip *)id); break; } diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 21a91b34e8d..2dfd41f299a 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -530,7 +530,7 @@ static void data_delete_material_index_id(ID *id, short index) mesh_delete_material_index((Mesh *)id, index); break; case ID_CU: - curve_delete_material_index((Curve *)id, index); + BKE_curve_delete_material_index((Curve *)id, index); break; case ID_MB: /* meta-elems don't have materials atm */ diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 60ccfa2a7cb..73e3576b57f 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -65,6 +65,106 @@ #include "BKE_object.h" #include "BKE_material.h" +/* Data types */ + +typedef struct point { /* a three-dimensional point */ + float x, y, z; /* its coordinates */ +} MB_POINT; + +typedef struct vertex { /* surface vertex */ + MB_POINT position, normal; /* position and surface normal */ +} VERTEX; + +typedef struct vertices { /* list of vertices in polygonization */ + int count, max; /* # vertices, max # allowed */ + VERTEX *ptr; /* dynamically allocated */ +} VERTICES; + +typedef struct corner { /* corner of a cube */ + int i, j, k; /* (i, j, k) is index within lattice */ + float x, y, z, value; /* location and function value */ + struct corner *next; +} CORNER; + +typedef struct cube { /* partitioning cell (cube) */ + int i, j, k; /* lattice location of cube */ + CORNER *corners[8]; /* eight corners */ +} CUBE; + +typedef struct cubes { /* linked list of cubes acting as stack */ + CUBE cube; /* a single cube */ + struct cubes *next; /* remaining elements */ +} CUBES; + +typedef struct centerlist { /* list of cube locations */ + int i, j, k; /* cube location */ + struct centerlist *next; /* remaining elements */ +} CENTERLIST; + +typedef struct edgelist { /* list of edges */ + int i1, j1, k1, i2, j2, k2; /* edge corner ids */ + int vid; /* vertex id */ + struct edgelist *next; /* remaining elements */ +} EDGELIST; + +typedef struct intlist { /* list of integers */ + int i; /* an integer */ + struct intlist *next; /* remaining elements */ +} INTLIST; + +typedef struct intlists { /* list of list of integers */ + INTLIST *list; /* a list of integers */ + struct intlists *next; /* remaining elements */ +} INTLISTS; + +typedef struct process { /* parameters, function, storage */ + /* what happens here? floats, I think. */ + /* float (*function)(void); */ /* implicit surface function */ + float (*function)(float, float, float); + float size, delta; /* cube size, normal delta */ + int bounds; /* cube range within lattice */ + CUBES *cubes; /* active cubes */ + VERTICES vertices; /* surface vertices */ + CENTERLIST **centers; /* cube center hash table */ + CORNER **corners; /* corner value hash table */ + EDGELIST **edges; /* edge and vertex id hash table */ +} PROCESS; + +/* dividing scene using octal tree makes polygonisation faster */ +typedef struct ml_pointer { + struct ml_pointer *next, *prev; + struct MetaElem *ml; +} ml_pointer; + +typedef struct octal_node { + struct octal_node *nodes[8]; /* children of current node */ + struct octal_node *parent; /* parent of current node */ + struct ListBase elems; /* ListBase of MetaElem pointers (ml_pointer) */ + float x_min, y_min, z_min; /* 1st border point */ + float x_max, y_max, z_max; /* 7th border point */ + float x,y,z; /* center of node */ + int pos, neg; /* number of positive and negative MetaElements in the node */ + int count; /* number of MetaElems, which belongs to the node */ +} octal_node; + +typedef struct octal_tree { + struct octal_node *first; /* first node */ + int pos, neg; /* number of positive and negative MetaElements in the scene */ + short depth; /* number of scene subdivision */ +} octal_tree; + +struct pgn_elements { + struct pgn_elements *next, *prev; + char *data; +}; + +/* Forward declarations */ +static int vertid(CORNER *c1, CORNER *c2, PROCESS *p, MetaBall *mb); +static int setcenter(CENTERLIST *table[], int i, int j, int k); +static CORNER *setcorner(PROCESS* p, int i, int j, int k); +static void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2, + float (*function)(float, float, float), MB_POINT *p, MetaBall *mb, int f); + /* Global variables */ static float thresh= 0.6f; @@ -73,7 +173,7 @@ static MetaElem **mainb; static octal_tree *metaball_tree = NULL; /* Functions */ -void unlink_mball(MetaBall *mb) +void BKE_metaball_unlink(MetaBall *mb) { int a; @@ -85,9 +185,9 @@ void unlink_mball(MetaBall *mb) /* do not free mball itself */ -void free_mball(MetaBall *mb) +void BKE_metaball_free(MetaBall *mb) { - unlink_mball(mb); + BKE_metaball_unlink(mb); if (mb->adt) { BKE_free_animdata((ID *)mb); @@ -99,7 +199,7 @@ void free_mball(MetaBall *mb) if (mb->disp.first) freedisplist(&mb->disp); } -MetaBall *add_mball(const char *name) +MetaBall *BKE_metaball_add(const char *name) { MetaBall *mb; @@ -115,7 +215,7 @@ MetaBall *add_mball(const char *name) return mb; } -MetaBall *copy_mball(MetaBall *mb) +MetaBall *BKE_metaball_copy(MetaBall *mb) { MetaBall *mbn; int a; @@ -143,7 +243,7 @@ static void extern_local_mball(MetaBall *mb) } } -void make_local_mball(MetaBall *mb) +void BKE_metaball_make_local(MetaBall *mb) { Main *bmain= G.main; Object *ob; @@ -174,7 +274,7 @@ void make_local_mball(MetaBall *mb) extern_local_mball(mb); } else if (is_local && is_lib) { - MetaBall *mb_new= copy_mball(mb); + MetaBall *mb_new= BKE_metaball_copy(mb); mb_new->id.us= 0; /* Remap paths of new ID using old library as base. */ @@ -194,7 +294,7 @@ void make_local_mball(MetaBall *mb) /* most simple meta-element adding function * don't do context manipulation here (rna uses) */ -MetaElem *add_metaball_element(MetaBall *mb, const int type) +MetaElem *BKE_metaball_element_add(MetaBall *mb, const int type) { MetaElem *ml= MEM_callocN(sizeof(MetaElem), "metaelem"); @@ -246,7 +346,7 @@ MetaElem *add_metaball_element(MetaBall *mb, const int type) * basic MetaBall (usually with name Meta). All other MetaBalls (with * names Meta.001, Meta.002, etc) are included in this Bounding Box. */ -void tex_space_mball(Object *ob) +void BKE_metaball_tex_space_calc(Object *ob) { DispList *dl; BoundBox *bb; @@ -290,7 +390,7 @@ void tex_space_mball(Object *ob) boundbox_set_from_min_max(bb, min, max); } -float *make_orco_mball(Object *ob, ListBase *dispbase) +float *BKE_metaball_make_orco(Object *ob, ListBase *dispbase) { BoundBox *bb; DispList *dl; @@ -342,7 +442,7 @@ float *make_orco_mball(Object *ob, ListBase *dispbase) * It test last character of Object ID name. If last character * is digit it return 0, else it return 1. */ -int is_basis_mball(Object *ob) +int BKE_metaball_is_basis(Object *ob) { int len; @@ -353,7 +453,7 @@ int is_basis_mball(Object *ob) } /* return nonzero if ob1 is a basis mball for ob */ -int is_mball_basis_for (Object *ob1, Object *ob2) +int BKE_metaball_is_basis_for (Object *ob1, Object *ob2) { int basis1nr, basis2nr; char basis1name[MAX_ID_NAME], basis2name[MAX_ID_NAME]; @@ -361,7 +461,7 @@ int is_mball_basis_for (Object *ob1, Object *ob2) BLI_split_name_num(basis1name, &basis1nr, ob1->id.name+2, '.'); BLI_split_name_num(basis2name, &basis2nr, ob2->id.name+2, '.'); - if (!strcmp(basis1name, basis2name)) return is_basis_mball(ob1); + if (!strcmp(basis1name, basis2name)) return BKE_metaball_is_basis(ob1); else return 0; } @@ -371,7 +471,7 @@ int is_mball_basis_for (Object *ob1, Object *ob2) * are copied to all metaballs in same "group" (metaballs with same base name: MBall, * MBall.001, MBall.002, etc). The most important is to copy properties to the base metaball, * because this metaball influence polygonisation of metaballs. */ -void copy_mball_properties(Scene *scene, Object *active_object) +void BKE_metaball_properties_copy(Scene *scene, Object *active_object) { Scene *sce_iter= scene; Base *base; @@ -416,7 +516,7 @@ void copy_mball_properties(Scene *scene, Object *active_object) * * warning!, is_basis_mball() can fail on returned object, see long note above. */ -Object *find_basis_mball(Scene *scene, Object *basis) +Object *BKE_metaball_basis_find(Scene *scene, Object *basis) { Scene *sce_iter= scene; Base *base; @@ -522,14 +622,14 @@ Object *find_basis_mball(Scene *scene, Object *basis) /* **************** POLYGONIZATION ************************ */ -void calc_mballco(MetaElem *ml, float vec[3]) +static void calc_mballco(MetaElem *ml, float vec[3]) { if (ml->mat) { mul_m4_v3((float (*)[4])ml->mat, vec); } } -float densfunc(MetaElem *ball, float x, float y, float z) +static float densfunc(MetaElem *ball, float x, float y, float z) { float dist2 = 0.0, dx, dy, dz; float vec[3]; @@ -605,7 +705,7 @@ float densfunc(MetaElem *ball, float x, float y, float z) } } -octal_node* find_metaball_octal_node(octal_node *node, float x, float y, float z, short depth) +static octal_node* find_metaball_octal_node(octal_node *node, float x, float y, float z, short depth) { if (!depth) return node; @@ -673,7 +773,7 @@ octal_node* find_metaball_octal_node(octal_node *node, float x, float y, float z return node; } -float metaball(float x, float y, float z) +static float metaball(float x, float y, float z) /* float x, y, z; */ { struct octal_node *node; @@ -713,7 +813,7 @@ static int *indices=NULL; static int totindex, curindex; -void accum_mballfaces(int i1, int i2, int i3, int i4) +static void accum_mballfaces(int i1, int i2, int i3, int i4) { int *newi, *cur; /* static int i=0; I would like to delete altogether, but I don't dare to, yet */ @@ -746,7 +846,7 @@ void accum_mballfaces(int i1, int i2, int i3, int i4) } /* ******************* MEMORY MANAGEMENT *********************** */ -void *new_pgn_element(int size) +static void *new_pgn_element(int size) { /* during polygonize 1000s of elements are allocated * and never freed in between. Freeing only done at the end. @@ -789,7 +889,7 @@ void *new_pgn_element(int size) return cur->data; } -void freepolygonize(PROCESS *p) +static void freepolygonize(PROCESS *p) { MEM_freeN(p->corners); MEM_freeN(p->edges); @@ -832,7 +932,7 @@ static int rightface[12] = { /* docube: triangulate the cube directly, without decomposition */ -void docube(CUBE *cube, PROCESS *p, MetaBall *mb) +static void docube(CUBE *cube, PROCESS *p, MetaBall *mb) { INTLISTS *polys; CORNER *c1, *c2; @@ -900,7 +1000,7 @@ void docube(CUBE *cube, PROCESS *p, MetaBall *mb) * if surface crosses face, compute other four corners of adjacent cube * and add new cube to cube stack */ -void testface(int i, int j, int k, CUBE* old, int bit, int c1, int c2, int c3, int c4, PROCESS *p) +static void testface(int i, int j, int k, CUBE* old, int bit, int c1, int c2, int c3, int c4, PROCESS *p) { CUBE newc; CUBES *oldcubes = p->cubes; @@ -951,7 +1051,7 @@ void testface(int i, int j, int k, CUBE* old, int bit, int c1, int c2, int c3, i /* setcorner: return corner with the given lattice location * set (and cache) its function value */ -CORNER *setcorner (PROCESS* p, int i, int j, int k) +static CORNER *setcorner (PROCESS* p, int i, int j, int k) { /* for speed, do corner value caching here */ CORNER *c; @@ -986,7 +1086,7 @@ CORNER *setcorner (PROCESS* p, int i, int j, int k) /* nextcwedge: return next clockwise edge from given edge around given face */ -int nextcwedge (int edge, int face) +static int nextcwedge (int edge, int face) { switch (edge) { case LB: @@ -1020,7 +1120,7 @@ int nextcwedge (int edge, int face) /* otherface: return face adjoining edge that is not the given face */ -int otherface (int edge, int face) +static int otherface (int edge, int face) { int other = leftface[edge]; return face == other? rightface[edge] : other; @@ -1029,7 +1129,7 @@ int otherface (int edge, int face) /* makecubetable: create the 256 entry table for cubical polygonization */ -void makecubetable (void) +static void makecubetable (void) { static int isdone= 0; int i, e, c, done[12], pos[8]; @@ -1070,7 +1170,7 @@ void makecubetable (void) } } -void BKE_freecubetable(void) +void BKE_metaball_cubeTable_free(void) { int i; INTLISTS *lists, *nlists; @@ -1100,7 +1200,7 @@ void BKE_freecubetable(void) /* setcenter: set (i,j,k) entry of table[] * return 1 if already set; otherwise, set and return 0 */ -int setcenter(CENTERLIST *table[], int i, int j, int k) +static int setcenter(CENTERLIST *table[], int i, int j, int k) { int index; CENTERLIST *newc, *l, *q; @@ -1125,7 +1225,7 @@ int setcenter(CENTERLIST *table[], int i, int j, int k) /* setedge: set vertex id for edge */ -void setedge (EDGELIST *table[], +static void setedge (EDGELIST *table[], int i1, int j1, int k1, int i2, int j2, int k2, @@ -1161,7 +1261,7 @@ void setedge (EDGELIST *table[], /* getedge: return vertex id for edge; return -1 if not set */ -int getedge (EDGELIST *table[], +static int getedge (EDGELIST *table[], int i1, int j1, int k1, int i2, int j2, int k2) { @@ -1202,7 +1302,7 @@ int getedge (EDGELIST *table[], /* addtovertices: add v to sequence of vertices */ -void addtovertices (VERTICES *vertices, VERTEX v) +static void addtovertices (VERTICES *vertices, VERTEX v) { if (vertices->count == vertices->max) { int i; @@ -1220,7 +1320,7 @@ void addtovertices (VERTICES *vertices, VERTEX v) /* vnormal: compute unit length surface normal at point */ -void vnormal (MB_POINT *point, PROCESS *p, MB_POINT *v) +static void vnormal (MB_POINT *point, PROCESS *p, MB_POINT *v) { float delta= 0.2f*p->delta; float f = p->function(point->x, point->y, point->z); @@ -1270,7 +1370,7 @@ void vnormal (MB_POINT *point, PROCESS *p, MB_POINT *v) } -int vertid (CORNER *c1, CORNER *c2, PROCESS *p, MetaBall *mb) +static int vertid (CORNER *c1, CORNER *c2, PROCESS *p, MetaBall *mb) { VERTEX v; MB_POINT a, b; @@ -1299,7 +1399,7 @@ int vertid (CORNER *c1, CORNER *c2, PROCESS *p, MetaBall *mb) /* converge: from two points of differing sign, converge to zero crossing */ /* watch it: p1 and p2 are used to calculate */ -void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2, +static void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2, float (*function)(float, float, float), MB_POINT *p, MetaBall *mb, int f) { int i = 0; @@ -1399,7 +1499,7 @@ void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2, } /* ************************************** */ -void add_cube(PROCESS *mbproc, int i, int j, int k, int count) +static void add_cube(PROCESS *mbproc, int i, int j, int k, int count) { CUBES *ncube; int n; @@ -1429,7 +1529,7 @@ void add_cube(PROCESS *mbproc, int i, int j, int k, int count) } -void find_first_points(PROCESS *mbproc, MetaBall *mb, int a) +static void find_first_points(PROCESS *mbproc, MetaBall *mb, int a) { MB_POINT IN, in, OUT, out; /*point;*/ MetaElem *ml; @@ -1549,7 +1649,7 @@ void find_first_points(PROCESS *mbproc, MetaBall *mb, int a) } } -void polygonize(PROCESS *mbproc, MetaBall *mb) +static void polygonize(PROCESS *mbproc, MetaBall *mb) { CUBE c; int a; @@ -1589,7 +1689,7 @@ void polygonize(PROCESS *mbproc, MetaBall *mb) } } -float init_meta(Scene *scene, Object *ob) /* return totsize */ +static float init_meta(Scene *scene, Object *ob) /* return totsize */ { Scene *sce_iter= scene; Base *base; @@ -1815,7 +1915,7 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */ /* if MetaElem lies in node, then node includes MetaElem pointer (ml_p) * pointing at MetaElem (ml) */ -void fill_metaball_octal_node(octal_node *node, MetaElem *ml, short i) +static void fill_metaball_octal_node(octal_node *node, MetaElem *ml, short i) { ml_pointer *ml_p; @@ -1847,7 +1947,7 @@ void fill_metaball_octal_node(octal_node *node, MetaElem *ml, short i) * +------+------+ * */ -void subdivide_metaball_octal_node(octal_node *node, float size_x, float size_y, float size_z, short depth) +static void subdivide_metaball_octal_node(octal_node *node, float size_x, float size_y, float size_z, short depth) { MetaElem *ml; ml_pointer *ml_p; @@ -2104,7 +2204,7 @@ void subdivide_metaball_octal_node(octal_node *node, float size_x, float size_y, } /* free all octal nodes recursively */ -void free_metaball_octal_node(octal_node *node) +static void free_metaball_octal_node(octal_node *node) { int a; for (a=0;a<8;a++) { @@ -2115,7 +2215,7 @@ void free_metaball_octal_node(octal_node *node) } /* If scene include more then one MetaElem, then octree is used */ -void init_metaball_octal_tree(int depth) +static void init_metaball_octal_tree(int depth) { struct octal_node *node; ml_pointer *ml_p; @@ -2173,7 +2273,7 @@ void init_metaball_octal_tree(int depth) subdivide_metaball_octal_node(node, size[0], size[1], size[2], metaball_tree->depth); } -void metaball_polygonize(Scene *scene, Object *ob, ListBase *dispbase) +void BKE_metaball_polygonize(Scene *scene, Object *ob, ListBase *dispbase) { PROCESS mbproc; MetaBall *mb; diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 14ccd401a30..c7f6bf93831 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1616,7 +1616,7 @@ void mesh_to_curve(Scene *scene, Object *ob) BLI_edgehash_free(eh, NULL); if (edges.first) { - Curve *cu = add_curve(ob->id.name+2, OB_CURVE); + Curve *cu = BKE_curve_add(ob->id.name+2, OB_CURVE); cu->flag |= CU_3D; while (edges.first) { diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index a3baa883a4a..d548d7589bb 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -450,7 +450,7 @@ static MovieClip *movieclip_alloc(const char *name) * otherwise creates new. * does not load ibuf itself * pass on optional frame for #name images */ -MovieClip *BKE_add_movieclip_file(const char *name) +MovieClip *BKE_movieclip_file_add(const char *name) { MovieClip *clip; MovieClipUser user; @@ -1149,14 +1149,14 @@ void BKE_movieclip_build_proxy_frame(MovieClip *clip, int clip_flag, struct Movi } } -void free_movieclip(MovieClip *clip) +void BKE_movieclip_free(MovieClip *clip) { free_buffers(clip); BKE_tracking_free(&clip->tracking); } -void unlink_movieclip(Main *bmain, MovieClip *clip) +void BKE_movieclip_unlink(Main *bmain, MovieClip *clip) { bScreen *scr; ScrArea *area; diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 6b44ba976d5..3ffd8115914 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -319,8 +319,8 @@ void free_object(Object *ob) id->us--; if (id->us==0) { if (ob->type==OB_MESH) unlink_mesh(ob->data); - else if (ob->type==OB_CURVE) unlink_curve(ob->data); - else if (ob->type==OB_MBALL) unlink_mball(ob->data); + else if (ob->type==OB_CURVE) BKE_curve_unlink(ob->data); + else if (ob->type==OB_MBALL) BKE_metaball_unlink(ob->data); } ob->data= NULL; } @@ -459,7 +459,7 @@ void unlink_object(Object *ob) } } else if (ELEM(OB_MBALL, ob->type, obt->type)) { - if (is_mball_basis_for (obt, ob)) + if (BKE_metaball_is_basis_for (obt, ob)) obt->recalc|= OB_RECALC_DATA; } @@ -749,10 +749,10 @@ static void *add_obdata_from_type(int type) { switch (type) { case OB_MESH: return add_mesh("Mesh"); - case OB_CURVE: return add_curve("Curve", OB_CURVE); - case OB_SURF: return add_curve("Surf", OB_SURF); - case OB_FONT: return add_curve("Text", OB_FONT); - case OB_MBALL: return add_mball("Meta"); + case OB_CURVE: return BKE_curve_add("Curve", OB_CURVE); + case OB_SURF: return BKE_curve_add("Surf", OB_SURF); + case OB_FONT: return BKE_curve_add("Text", OB_FONT); + case OB_MBALL: return BKE_metaball_add("Meta"); case OB_CAMERA: return add_camera("Camera"); case OB_LAMP: return add_lamp("Lamp"); case OB_LATTICE: return add_lattice("Lattice"); @@ -1822,7 +1822,7 @@ static void give_parvert(Object *par, int nr, float vec[3]) ListBase *nurbs; cu= par->data; - nurbs= BKE_curve_nurbs(cu); + nurbs= BKE_curve_nurbs_get(cu); nu= nurbs->first; count= 0; @@ -2268,7 +2268,7 @@ void minmax_object(Object *ob, float min[3], float max[3]) { Curve *cu= ob->data; - if (cu->bb==NULL) tex_space_curve(cu); + if (cu->bb==NULL) BKE_curve_tex_space_calc(cu); bb= *(cu->bb); for (a=0; a<8; a++) { @@ -2930,7 +2930,7 @@ static KeyBlock *insert_curvekey(Scene *scene, Object *ob, const char *name, int Curve *cu= ob->data; Key *key= cu->key; KeyBlock *kb; - ListBase *lb= BKE_curve_nurbs(cu); + ListBase *lb= BKE_curve_nurbs_get(cu); int newkey= 0; if (key==NULL) { @@ -2957,7 +2957,7 @@ static KeyBlock *insert_curvekey(Scene *scene, Object *ob, const char *name, int /* create new block with prepared data */ kb = add_keyblock_ctime(key, name, FALSE); - kb->totelem= count_curveverts(lb); + kb->totelem= BKE_nurbList_verts_count(lb); kb->data= data; } diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index d0eca731a1a..5d8a4955e58 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -3559,7 +3559,7 @@ static void curve_surf_to_softbody(Scene *scene, Object *ob) int a, curindex=0; int totvert, totspring = 0, setgoal=0; - totvert= count_curveverts(&cu->nurb); + totvert= BKE_nurbList_verts_count(&cu->nurb); if (ob->softflag & OB_SB_EDGES) { if (ob->type==OB_CURVE) { -- cgit v1.2.3