diff options
author | Daniel Genrich <daniel.genrich@gmx.net> | 2012-05-20 23:35:49 +0400 |
---|---|---|
committer | Daniel Genrich <daniel.genrich@gmx.net> | 2012-05-20 23:35:49 +0400 |
commit | 5413fee77e80157931545946c6bc3fa0ac6d686a (patch) | |
tree | 1b085775dc5cf42bd9ff99927bb18025fffec11f /source/blender/blenkernel/intern | |
parent | 37ed2e4f46d43c6011ee756c3e6b0062816bdac6 (diff) |
Merge from trunk r46614-r46814
Diffstat (limited to 'source/blender/blenkernel/intern')
41 files changed, 673 insertions, 2109 deletions
diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c index 9bdb575bd49..6f768a147f7 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.c +++ b/source/blender/blenkernel/intern/CCGSubSurf.c @@ -2406,7 +2406,7 @@ static void ccgSubSurf__allFaces(CCGSubSurf *ss, CCGFace ***faces, int *numFaces CCGFace **array; int i, num; - if (!*faces) { + if (*faces == NULL) { array = MEM_mallocN(sizeof(*array) * ss->fMap->numEntries, "CCGSubsurf allFaces"); num = 0; for (i = 0; i < ss->fMap->curSize; i++) { @@ -3127,7 +3127,7 @@ void CCG_key(CCGKey *key, const CCGSubSurf *ss, int level) key->num_layers = ss->meshIFC.numLayers; /* if normals are present, always the last three floats of an - element */ + * element */ if (key->has_normals) key->normal_offset = key->elem_size - sizeof(float) * 3; else diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 9e46d03a3ab..233647c9ec6 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -247,7 +247,7 @@ void set_active_action_group(bAction *act, bActionGroup *agrp, short select) for (grp = act->groups.first; grp; grp = grp->next) { if ((grp == agrp) && (select)) grp->flag |= AGRP_ACTIVE; - else + else grp->flag &= ~AGRP_ACTIVE; } } @@ -574,7 +574,7 @@ void BKE_pose_channels_hash_make(bPose *pose) if (!pose->chanhash) { bPoseChannel *pchan; - pose->chanhash = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "make_pose_chan gh"); + pose->chanhash = BLI_ghash_str_new("make_pose_chan gh"); for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) BLI_ghash_insert(pose->chanhash, pchan->name, pchan); } @@ -958,7 +958,7 @@ short action_get_item_transforms(bAction *act, Object *ob, bPoseChannel *pchan, RNA_pointer_create((ID *)ob, &RNA_PoseBone, pchan, &ptr); else if (ob) RNA_id_pointer_create((ID *)ob, &ptr); - else + else return 0; /* get the basic path to the properties of interest */ diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 67c49e052d6..de45917de43 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -452,7 +452,7 @@ void animviz_calc_motionpaths(Scene *scene, ListBase *targets) /* get pointer to animviz settings for each target */ if (mpt->pchan) avs = &mpt->ob->pose->avs; - else + else avs = &mpt->ob->avs; /* clear the flag requesting recalculation of targets */ @@ -751,14 +751,14 @@ static void group_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, i dob = new_dupli_object(lb, go->ob, mat, ob->lay, 0, OB_DUPLIGROUP, animated); /* check the group instance and object layers match, also that the object visible flags are ok. */ - if ( (dob->origlay & group->layer) == 0 || - (G.rendering == 0 && dob->ob->restrictflag & OB_RESTRICT_VIEW) || - (G.rendering && dob->ob->restrictflag & OB_RESTRICT_RENDER) - ) { - dob->no_draw = 1; + if ((dob->origlay & group->layer) == 0 || + (G.rendering == 0 && dob->ob->restrictflag & OB_RESTRICT_VIEW) || + (G.rendering && dob->ob->restrictflag & OB_RESTRICT_RENDER)) + { + dob->no_draw = TRUE; } else { - dob->no_draw = 0; + dob->no_draw = FALSE; } if (go->ob->transflag & OB_DUPLI) { diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index fe95d15f82e..752036c6b9f 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -437,7 +437,7 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest) float h1[3], h2[3], scale[3], length, hlength1, hlength2, roll1 = 0.0f, roll2; float mat3[3][3], imat[4][4], posemat[4][4], scalemat[4][4], iscalemat[4][4]; float data[MAX_BBONE_SUBDIV + 1][4], *fp; - int a, doscale = 0; + int a, do_scale = 0; length = bone->length; @@ -455,7 +455,7 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest) invert_m4_m4(iscalemat, scalemat); length *= scale[1]; - doscale = 1; + do_scale = 1; } } @@ -476,7 +476,7 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest) if (rest) { invert_m4_m4(imat, pchan->bone->arm_mat); } - else if (doscale) { + else if (do_scale) { copy_m4_m4(posemat, pchan->pose_mat); normalize_m4(posemat); invert_m4_m4(imat, posemat); @@ -581,7 +581,7 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest) copy_m4_m3(result_array[a].mat, mat3); copy_v3_v3(result_array[a].mat[3], fp); - if (doscale) { + if (do_scale) { /* correct for scaling when this matrix is used in scaled space */ mul_serie_m4(result_array[a].mat, iscalemat, result_array[a].mat, scalemat, NULL, NULL, NULL, NULL, NULL); } @@ -835,7 +835,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, float const short invert_vgroup = deformflag & ARM_DEF_INVERT_VGROUP; int defbase_tot = 0; /* safety for vertexgroup index overflow */ int i, target_totvert = 0; /* safety for vertexgroup overflow */ - int use_dverts = 0; + int use_dverts = FALSE; int armature_def_nr; int totchan; @@ -895,11 +895,12 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, float if (deformflag & ARM_DEF_VGROUP) { if (ELEM(target->type, OB_MESH, OB_LATTICE)) { /* if we have a DerivedMesh, only use dverts if it has them */ - if (dm) - if (dm->getVertData(dm, 0, CD_MDEFORMVERT)) - use_dverts = 1; - else use_dverts = 0; - else if (dverts) use_dverts = 1; + if (dm) { + use_dverts = (dm->getVertData(dm, 0, CD_MDEFORMVERT) != NULL); + } + else if (dverts) { + use_dverts = TRUE; + } if (use_dverts) { defnrToPC = MEM_callocN(sizeof(*defnrToPC) * defbase_tot, "defnrToBone"); @@ -2245,13 +2246,13 @@ static void do_strip_modifiers(Scene *scene, Object *armob, Bone *bone, bPoseCha int do_modif; for (strip = armob->nlastrips.first; strip; strip = strip->next) { - do_modif = 0; + do_modif = FALSE; if (scene_cfra >= strip->start && scene_cfra <= strip->end) - do_modif = 1; + do_modif = TRUE; if ((scene_cfra > strip->end) && (strip->flag & ACTSTRIP_HOLDLASTFRAME)) { - do_modif = 1; + do_modif = TRUE; /* if there are any other strips active, ignore modifiers for this strip - * 'hold' option should only hold action modifiers if there are @@ -2261,7 +2262,7 @@ static void do_strip_modifiers(Scene *scene, Object *armob, Bone *bone, bPoseCha if (scene_cfra >= strip2->start && scene_cfra <= strip2->end) { if (!(strip2->flag & ACTSTRIP_MUTE)) - do_modif = 0; + do_modif = FALSE; } } @@ -2270,7 +2271,7 @@ static void do_strip_modifiers(Scene *scene, Object *armob, Bone *bone, bPoseCha for (strip2 = strip->next; strip2; strip2 = strip2->next) { if (scene_cfra < strip2->start) continue; if ((strip2->flag & ACTSTRIP_HOLDLASTFRAME) && !(strip2->flag & ACTSTRIP_MUTE)) { - do_modif = 0; + do_modif = FALSE; } } } diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index afbabd8d3e5..65294e3e5f5 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -522,7 +522,7 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm, glNormal3sv(no); \ } \ glVertex3fv(mvert[index].co); \ -} +} (void)0 if (cddm->pbvh && cddm->pbvh_draw) { if (dm->numTessFaceData) { @@ -636,9 +636,9 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, else { if (index) { orig = *index++; - if (orig == ORIGINDEX_NONE) { if (nors) nors += 3; continue; } - if (drawParamsMapped) draw_option = drawParamsMapped(userData, orig); - else { if (nors) nors += 3; continue; } + if (orig == ORIGINDEX_NONE) { if (nors) nors += 3; continue; } + if (drawParamsMapped) { draw_option = drawParamsMapped(userData, orig); } + else { if (nors) nors += 3; continue; } } else if (drawParamsMapped) draw_option = drawParamsMapped(userData, i); @@ -1039,13 +1039,13 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, MFace *mface = cddm->mface; /* MTFace *tf = dm->getTessFaceDataArray(dm, CD_MTFACE); */ /* UNUSED */ float (*nors)[3] = dm->getTessFaceDataArray(dm, CD_NORMAL); - int a, b, dodraw, matnr, new_matnr; + int a, b, do_draw, matnr, new_matnr; int orig, *index = dm->getTessFaceDataArray(dm, CD_ORIGINDEX); cdDM_update_normals_from_pbvh(dm); matnr = -1; - dodraw = 0; + do_draw = FALSE; glShadeModel(GL_SMOOTH); @@ -1062,14 +1062,14 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, if (new_matnr != matnr) { glEnd(); - dodraw = setMaterial(matnr = new_matnr, &gattribs); - if (dodraw) + do_draw = setMaterial(matnr = new_matnr, &gattribs); + if (do_draw) DM_vertex_attributes_from_gpu(dm, &gattribs, &attribs); glBegin(GL_QUADS); } - if (!dodraw) { + if (!do_draw) { continue; } else if (setDrawOptions) { @@ -1139,7 +1139,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, numfaces = curface - start; if (numfaces > 0) { - if (dodraw) { + if (do_draw) { if (numdata != 0) { @@ -1161,9 +1161,9 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, } numdata = 0; start = curface; - /* prevdraw = dodraw; */ /* UNUSED */ - dodraw = setMaterial(matnr = new_matnr, &gattribs); - if (dodraw) { + /* prevdraw = do_draw; */ /* UNUSED */ + do_draw = setMaterial(matnr = new_matnr, &gattribs); + if (do_draw) { DM_vertex_attributes_from_gpu(dm, &gattribs, &attribs); if (attribs.totorco) { @@ -1215,7 +1215,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, } } - if (dodraw && numdata != 0) { + if (do_draw && numdata != 0) { offset = 0; if (attribs.totorco) { copy_v3_v3((float *)&varray[elementsize * curface * 3], (float *)attribs.orco.array[mface->v1]); @@ -1257,7 +1257,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, } curface++; if (mface->v4) { - if (dodraw && numdata != 0) { + if (do_draw && numdata != 0) { offset = 0; if (attribs.totorco) { copy_v3_v3((float *)&varray[elementsize * curface * 3], (float *)attribs.orco.array[mface->v3]); @@ -1302,7 +1302,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, } numfaces = curface - start; if (numfaces > 0) { - if (dodraw) { + if (do_draw) { if (numdata != 0) { GPU_buffer_unlock(buffer); GPU_interleaved_attrib_setup(buffer, datatypes, numdata); diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index b521285c626..b38f0f78cdb 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -92,7 +92,7 @@ static CM_SOLVER_DEF solvers [] = /* ********** cloth engine ******* */ /* Prototypes for internal functions. -*/ + */ static void cloth_to_object (Object *ob, ClothModifierData *clmd, float (*vertexCos)[3]); static void cloth_from_mesh ( ClothModifierData *clmd, DerivedMesh *dm ); static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *dm, float framenr, int first); @@ -101,10 +101,10 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm ); /****************************************************************************** -* -* External interface called by modifier.c clothModifier functions. -* -******************************************************************************/ + * + * External interface called by modifier.c clothModifier functions. + * + ******************************************************************************/ /** * cloth_init - creates a new cloth simulation. * @@ -145,8 +145,8 @@ void cloth_init(ClothModifierData *clmd ) clmd->coll_parms->selfepsilon = 0.75; /* These defaults are copied from softbody.c's - * softbody_calc_forces() function. - */ + * softbody_calc_forces() function. + */ clmd->sim_parms->eff_force_scale = 1000.0; clmd->sim_parms->eff_wind_scale = 250.0; @@ -419,9 +419,64 @@ static int do_step_cloth(Object *ob, ClothModifierData *clmd, DerivedMesh *resul return ret; } +#if 0 +static DerivedMesh *cloth_to_triangles(DerivedMesh *dm) +{ + DerivedMesh *result = NULL; + unsigned int i = 0, j = 0; + unsigned int quads = 0, numfaces = dm->getNumTessFaces(dm); + MFace *mface = dm->getTessFaceArray(dm); + MFace *mface2 = NULL; + + /* calc faces */ + for(i = 0; i < numfaces; i++) + { + if(mface[i].v4) + quads++; + } + + result = CDDM_from_template(dm, dm->getNumVerts(dm), 0, numfaces + quads, 0, 0); + + DM_copy_vert_data(dm, result, 0, 0, dm->getNumVerts(dm)); + DM_copy_tessface_data(dm, result, 0, 0, numfaces); + + DM_ensure_tessface(result); + mface2 = result->getTessFaceArray(result); + + for(i = 0, j = numfaces; i < numfaces; i++) + { + // DG TODO: is this necessary? + mface2[i].v1 = mface[i].v1; + mface2[i].v2 = mface[i].v2; + mface2[i].v3 = mface[i].v3; + + mface2[i].v4 = 0; + //test_index_face(&mface2[i], &result->faceData, i, 3); + + if(mface[i].v4) + { + DM_copy_tessface_data(dm, result, i, j, 1); + + mface2[j].v1 = mface[i].v1; + mface2[j].v2 = mface[i].v3; + mface2[j].v3 = mface[i].v4; + mface2[j].v4 = 0; + //test_index_face(&mface2[j], &result->faceData, j, 3); + + j++; + } + } + + CDDM_calc_edges_tessface(result); + CDDM_tessfaces_to_faces(result); /* builds ngon faces from tess (mface) faces */ + + return result; +} +#endif + /************************************************ * clothModifier_do - main simulation function -************************************************/ + ************************************************/ void clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, DerivedMesh *dm, float (*vertexCos)[3]) { PointCache *cache; @@ -674,10 +729,10 @@ void cloth_free_modifier_extern(ClothModifierData *clmd ) } /****************************************************************************** -* -* Internal functions. -* -******************************************************************************/ + * + * Internal functions. + * + ******************************************************************************/ /** * cloth_to_object - copies the deformed vertices to the object. @@ -923,16 +978,16 @@ static void cloth_from_mesh ( ClothModifierData *clmd, DerivedMesh *dm ) memcpy ( &clmd->clothObject->mfaces[i], &mface[i], sizeof ( MFace ) ); /* Free the springs since they can't be correct if the vertices - * changed. - */ + * changed. + */ if ( clmd->clothObject->springs != NULL ) MEM_freeN ( clmd->clothObject->springs ); } /*************************************************************************************** -* SPRING NETWORK BUILDING IMPLEMENTATION BEGIN -***************************************************************************************/ + * SPRING NETWORK BUILDING IMPLEMENTATION BEGIN + ***************************************************************************************/ // be careful: implicit solver has to be resettet when using this one! // --> only for implicit handling of this spring! @@ -1221,6 +1276,6 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) } /* cloth_build_springs */ /*************************************************************************************** -* SPRING NETWORK BUILDING IMPLEMENTATION END -***************************************************************************************/ + * SPRING NETWORK BUILDING IMPLEMENTATION END + ***************************************************************************************/ diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index 609b2d3496c..a93653537c7 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -161,284 +161,7 @@ void bvhtree_update_from_mvert(BVHTree * bvhtree, MFace *faces, int numfaces, MV /*********************************** Collision modifier code end ***********************************/ - -/** -* gsl_poly_solve_cubic - -* -* copied from SOLVE_CUBIC.C --> GSL -*/ - #define mySWAP(a, b) do { double tmp = b ; b = a ; a = tmp ; } while (0) -#if 0 /* UNUSED */ -static int -gsl_poly_solve_cubic (double a, double b, double c, - double *x0, double *x1, double *x2) -{ - double q = (a * a - 3 * b); - double r = (2 * a * a * a - 9 * a * b + 27 * c); - - double Q = q / 9; - double R = r / 54; - - double Q3 = Q * Q * Q; - double R2 = R * R; - - double CR2 = 729 * r * r; - double CQ3 = 2916 * q * q * q; - - if (R == 0 && Q == 0) - { - *x0 = - a / 3; - *x1 = - a / 3; - *x2 = - a / 3; - return 3; - } - else if (CR2 == CQ3) - { - /* this test is actually R2 == Q3, written in a form suitable - for exact computation with integers */ - - /* Due to finite precision some double roots may be missed, and - considered to be a pair of complex roots z = x +/- epsilon i - close to the real axis. */ - - double sqrtQ = sqrt (Q); - - if (R > 0) - { - *x0 = -2 * sqrtQ - a / 3; - *x1 = sqrtQ - a / 3; - *x2 = sqrtQ - a / 3; - } - else - { - *x0 = - sqrtQ - a / 3; - *x1 = - sqrtQ - a / 3; - *x2 = 2 * sqrtQ - a / 3; - } - return 3; - } - else if (CR2 < CQ3) /* equivalent to R2 < Q3 */ - { - double sqrtQ = sqrt (Q); - double sqrtQ3 = sqrtQ * sqrtQ * sqrtQ; - double theta = acos (R / sqrtQ3); - double norm = -2 * sqrtQ; - *x0 = norm * cos (theta / 3) - a / 3; - *x1 = norm * cos ((theta + 2.0 * M_PI) / 3) - a / 3; - *x2 = norm * cos ((theta - 2.0 * M_PI) / 3) - a / 3; - - /* Sort *x0, *x1, *x2 into increasing order */ - - if (*x0 > *x1) - mySWAP(*x0, *x1); - - if (*x1 > *x2) - { - mySWAP(*x1, *x2); - - if (*x0 > *x1) - mySWAP(*x0, *x1); - } - - return 3; - } - else - { - double sgnR = (R >= 0 ? 1 : -1); - double A = -sgnR * pow (fabs (R) + sqrt (R2 - Q3), 1.0/3.0); - double B = Q / A; - *x0 = A + B - a / 3; - return 1; - } -} - - - -/** -* gsl_poly_solve_quadratic -* -* copied from GSL -*/ -static int -gsl_poly_solve_quadratic (double a, double b, double c, - double *x0, double *x1) -{ - double disc = b * b - 4 * a * c; - - if (a == 0) /* Handle linear case */ - { - if (b == 0) - { - return 0; - } - else - { - *x0 = -c / b; - return 1; - }; - } - - if (disc > 0) - { - if (b == 0) - { - double r = fabs (0.5 * sqrt (disc) / a); - *x0 = -r; - *x1 = r; - } - else - { - double sgnb = (b > 0 ? 1 : -1); - double temp = -0.5 * (b + sgnb * sqrt (disc)); - double r1 = temp / a; - double r2 = c / temp; - - if (r1 < r2) - { - *x0 = r1; - *x1 = r2; - } - else - { - *x0 = r2; - *x1 = r1; - } - } - return 2; - } - else if (disc == 0) - { - *x0 = -0.5 * b / a; - *x1 = -0.5 * b / a; - return 2; - } - else - { - return 0; - } -} -#endif /* UNUSED */ - - - -/* -* See Bridson et al. "Robust Treatment of Collision, Contact and Friction for Cloth Animation" -* page 4, left column -*/ -#if 0 -static int cloth_get_collision_time ( double a[3], double b[3], double c[3], double d[3], double e[3], double f[3], double solution[3] ) -{ - int num_sols = 0; - - // x^0 - checked - double g = a[0] * c[1] * e[2] - a[0] * c[2] * e[1] + - a[1] * c[2] * e[0] - a[1] * c[0] * e[2] + - a[2] * c[0] * e[1] - a[2] * c[1] * e[0]; - - // x^1 - double h = -b[2] * c[1] * e[0] + b[1] * c[2] * e[0] - a[2] * d[1] * e[0] + - a[1] * d[2] * e[0] + b[2] * c[0] * e[1] - b[0] * c[2] * e[1] + - a[2] * d[0] * e[1] - a[0] * d[2] * e[1] - b[1] * c[0] * e[2] + - b[0] * c[1] * e[2] - a[1] * d[0] * e[2] + a[0] * d[1] * e[2] - - a[2] * c[1] * f[0] + a[1] * c[2] * f[0] + a[2] * c[0] * f[1] - - a[0] * c[2] * f[1] - a[1] * c[0] * f[2] + a[0] * c[1] * f[2]; - - // x^2 - double i = -b[2] * d[1] * e[0] + b[1] * d[2] * e[0] + - b[2] * d[0] * e[1] - b[0] * d[2] * e[1] - - b[1] * d[0] * e[2] + b[0] * d[1] * e[2] - - b[2] * c[1] * f[0] + b[1] * c[2] * f[0] - - a[2] * d[1] * f[0] + a[1] * d[2] * f[0] + - b[2] * c[0] * f[1] - b[0] * c[2] * f[1] + - a[2] * d[0] * f[1] - a[0] * d[2] * f[1] - - b[1] * c[0] * f[2] + b[0] * c[1] * f[2] - - a[1] * d[0] * f[2] + a[0] * d[1] * f[2]; - - // x^3 - checked - double j = -b[2] * d[1] * f[0] + b[1] * d[2] * f[0] + - b[2] * d[0] * f[1] - b[0] * d[2] * f[1] - - b[1] * d[0] * f[2] + b[0] * d[1] * f[2]; - - /* - printf("r1: %lf\n", a[0] * c[1] * e[2] - a[0] * c[2] * e[1]); - printf("r2: %lf\n", a[1] * c[2] * e[0] - a[1] * c[0] * e[2]); - printf("r3: %lf\n", a[2] * c[0] * e[1] - a[2] * c[1] * e[0]); - - printf("x1 x: %f, y: %f, z: %f\n", a[0], a[1], a[2]); - printf("x2 x: %f, y: %f, z: %f\n", c[0], c[1], c[2]); - printf("x3 x: %f, y: %f, z: %f\n", e[0], e[1], e[2]); - - printf("v1 x: %f, y: %f, z: %f\n", b[0], b[1], b[2]); - printf("v2 x: %f, y: %f, z: %f\n", d[0], d[1], d[2]); - printf("v3 x: %f, y: %f, z: %f\n", f[0], f[1], f[2]); - - printf("t^3: %lf, t^2: %lf, t^1: %lf, t^0: %lf\n", j, i, h, g); - -*/ - // Solve cubic equation to determine times t1, t2, t3, when the collision will occur. - if ( ABS ( j ) > DBL_EPSILON ) - { - i /= j; - h /= j; - g /= j; - num_sols = gsl_poly_solve_cubic ( i, h, g, &solution[0], &solution[1], &solution[2] ); - } - else - { - num_sols = gsl_poly_solve_quadratic ( i, h, g, &solution[0], &solution[1] ); - solution[2] = -1.0; - } - - // printf("num_sols: %d, sol1: %lf, sol2: %lf, sol3: %lf\n", num_sols, solution[0], solution[1], solution[2]); - - // Discard negative solutions - if ( ( num_sols >= 1 ) && ( solution[0] < DBL_EPSILON ) ) - { - --num_sols; - solution[0] = solution[num_sols]; - } - if ( ( num_sols >= 2 ) && ( solution[1] < DBL_EPSILON ) ) - { - --num_sols; - solution[1] = solution[num_sols]; - } - if ( ( num_sols == 3 ) && ( solution[2] < DBL_EPSILON ) ) - { - --num_sols; - } - - // Sort - if ( num_sols == 2 ) - { - if ( solution[0] > solution[1] ) - { - double tmp = solution[0]; - solution[0] = solution[1]; - solution[1] = tmp; - } - } - else if ( num_sols == 3 ) - { - - // Bubblesort - if ( solution[0] > solution[1] ) - { - double tmp = solution[0]; solution[0] = solution[1]; solution[1] = tmp; - } - if ( solution[1] > solution[2] ) - { - double tmp = solution[1]; solution[1] = solution[2]; solution[2] = tmp; - } - if ( solution[0] > solution[1] ) - { - double tmp = solution[0]; solution[0] = solution[1]; solution[1] = tmp; - } - } - - return num_sols; -} -#endif // w3 is not perfect @@ -485,7 +208,6 @@ DO_INLINE void collision_interpolateOnTriangle ( float to[3], float v1[3], float VECADDMUL(to, v3, w3); } -#ifndef WITH_ELTOPO static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionModifierData *collmd, CollPair *collpair, CollPair *collision_end ) { int result = 0; @@ -498,6 +220,12 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM cloth1 = clmd->clothObject; for ( ; collpair != collision_end; collpair++ ) { + float i1[3], i2[3], i3[3]; + + zero_v3(i1); + zero_v3(i2); + zero_v3(i3); + // only handle static collisions here if ( collpair->flag & COLLISION_IN_FUTURE ) continue; @@ -553,9 +281,9 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM normalize_v3(vrel_t_pre); impulse = magtangent / ( 1.0f + w1*w1 + w2*w2 + w3*w3 ); // 2.0 * - VECADDMUL ( cloth1->verts[collpair->ap1].impulse, vrel_t_pre, w1 * impulse ); - VECADDMUL ( cloth1->verts[collpair->ap2].impulse, vrel_t_pre, w2 * impulse ); - VECADDMUL ( cloth1->verts[collpair->ap3].impulse, vrel_t_pre, w3 * impulse ); + VECADDMUL ( i1, vrel_t_pre, w1 * impulse ); + VECADDMUL ( i2, vrel_t_pre, w2 * impulse ); + VECADDMUL ( i3, vrel_t_pre, w3 * impulse ); } // Apply velocity stopping impulse @@ -563,13 +291,13 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM // no 2.0 * magrelVel normally, but looks nicer DG impulse = magrelVel / ( 1.0 + w1*w1 + w2*w2 + w3*w3 ); - VECADDMUL ( cloth1->verts[collpair->ap1].impulse, collpair->normal, w1 * impulse ); + VECADDMUL ( i1, collpair->normal, w1 * impulse ); cloth1->verts[collpair->ap1].impulse_count++; - VECADDMUL ( cloth1->verts[collpair->ap2].impulse, collpair->normal, w2 * impulse ); + VECADDMUL ( i2, collpair->normal, w2 * impulse ); cloth1->verts[collpair->ap2].impulse_count++; - VECADDMUL ( cloth1->verts[collpair->ap3].impulse, collpair->normal, w3 * impulse ); + VECADDMUL ( i3, collpair->normal, w3 * impulse ); cloth1->verts[collpair->ap3].impulse_count++; // Apply repulse impulse if distance too short @@ -586,785 +314,64 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM repulse = MAX2 ( impulse, repulse ); impulse = repulse / ( 1.0f + w1*w1 + w2*w2 + w3*w3 ); // original 2.0 / 0.25 - VECADDMUL ( cloth1->verts[collpair->ap1].impulse, collpair->normal, impulse ); - VECADDMUL ( cloth1->verts[collpair->ap2].impulse, collpair->normal, impulse ); - VECADDMUL ( cloth1->verts[collpair->ap3].impulse, collpair->normal, impulse ); + VECADDMUL ( i1, collpair->normal, impulse ); + VECADDMUL ( i2, collpair->normal, impulse ); + VECADDMUL ( i3, collpair->normal, impulse ); } result = 1; } - } - return result; -} -#endif /* !WITH_ELTOPO */ - -#ifdef WITH_ELTOPO -typedef struct edgepairkey { - int a1, a2, b1, b2; -} edgepairkey; - -unsigned int edgepair_hash(void *vkey) -{ - edgepairkey *key = vkey; - int keys[4] = {key->a1, key->a2, key->b1, key->b2}; - int i, j; - - for (i=0; i<4; i++) { - for (j=0; j<3; j++) { - if (keys[j] >= keys[j+1]) { - SWAP(int, keys[j], keys[j+1]); - } - } - } - - return keys[0]*101 + keys[1]*72 + keys[2]*53 + keys[3]*34; -} - -int edgepair_cmp(const void *va, const void *vb) -{ - edgepairkey *a = va, *b = vb; - int keysa[4] = {a->a1, a->a2, a->b1, a->b2}; - int keysb[4] = {b->a1, b->a2, b->b1, b->b2}; - int i; - - for (i=0; i<4; i++) { - int j, ok=0; - for (j=0; j<4; j++) { - if (keysa[i] == keysa[j]) { - ok = 1; - break; - } - } - if (!ok) - return -1; - } - - return 0; -} - -static void get_edgepairkey(edgepairkey *key, int a1, int a2, int b1, int b2) -{ - key->a1 = a1; - key->a2 = a2; - key->b1 = b1; - key->b2 = b2; -} - -/*an immense amount of duplication goes on here. . .a major performance hit, I'm sure*/ -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; - MFace *face1=NULL, *face2 = NULL; - ClothVertex *verts1 = clmd->clothObject->verts; - double distance = 0; - edgepairkey *key, tstkey; - float epsilon1 = clmd->coll_parms->epsilon; - float epsilon2 = BLI_bvhtree_getepsilon ( collmd->bvhtree ); - float no[3], uv[3], t, relnor; - int i, i1, i2, i3, i4, i5, i6; - Cloth *cloth = clmd->clothObject; - float n1[3], n2[3], off[3], v1[2][3], v2[2][3], v3[2][3], v4[2][3], v5[2][3], v6[2][3]; - void **verts[] = {v1, v2, v3, v4, v5, v6}; - int j, ret, bp1, bp2, bp3, ap1, ap2, ap3, table[6]; - - face1 = & ( clmd->clothObject->mfaces[overlap->indexA] ); - face2 = & ( collmd->mfaces[overlap->indexB] ); - - // check all 4 possible collisions - for ( i = 0; i < 4; i++ ) { - if ( i == 0 ) { - // fill faceA - ap1 = face1->v1; - ap2 = face1->v2; - ap3 = face1->v3; - - // fill faceB - bp1 = face2->v1; - bp2 = face2->v2; - bp3 = face2->v3; - } - else if ( i == 1 ) { - if ( face1->v4 ) { - // fill faceA - ap1 = face1->v1; - ap2 = face1->v3; - ap3 = face1->v4; - - // fill faceB - bp1 = face2->v1; - bp2 = face2->v2; - bp3 = face2->v3; - } - else { - continue; - } - } - if ( i == 2 ) { - if ( face2->v4 ) { - // fill faceA - ap1 = face1->v1; - ap2 = face1->v2; - ap3 = face1->v3; - - // fill faceB - bp1 = face2->v1; - bp2 = face2->v3; - bp3 = face2->v4; - } - else { - continue; - } - } - else if ( i == 3 ) { - if ( face1->v4 && face2->v4 ) { - // fill faceA - ap1 = face1->v1; - ap2 = face1->v3; - ap3 = face1->v4; - - // fill faceB - bp1 = face2->v1; - bp2 = face2->v3; - bp3 = face2->v4; - } - else { - continue; - } - } - - copy_v3_v3(v1[0], cloth->verts[ap1].txold); - copy_v3_v3(v1[1], cloth->verts[ap1].tx); - copy_v3_v3(v2[0], cloth->verts[ap2].txold); - copy_v3_v3(v2[1], cloth->verts[ap2].tx); - copy_v3_v3(v3[0], cloth->verts[ap3].txold); - copy_v3_v3(v3[1], cloth->verts[ap3].tx); - - copy_v3_v3(v4[0], collmd->current_x[bp1].co); - copy_v3_v3(v4[1], collmd->current_xnew[bp1].co); - copy_v3_v3(v5[0], collmd->current_x[bp2].co); - copy_v3_v3(v5[1], collmd->current_xnew[bp2].co); - copy_v3_v3(v6[0], collmd->current_x[bp3].co); - copy_v3_v3(v6[1], collmd->current_xnew[bp3].co); - - normal_tri_v3(n2, v4[1], v5[1], v6[1]); - - /*offset new positions a bit, to account for margins*/ - i1 = ap1; i2 = ap2; i3 = ap3; - i4 = bp1; i5 = bp2; i6 = bp3; - - for (j=0; j<3; j++) { - int collp1, collp2, k, j2 = (j+1)%3; - - table[0] = ap1; table[1] = ap2; table[2] = ap3; - table[3] = bp1; table[4] = bp2; table[5] = bp3; - for (k=0; k<3; k++) { - float p1[3], p2[3]; - int k2 = (k+1)%3; - - get_edgepairkey(&tstkey, table[j], table[j2], table[k+3], table[k2+3]); - //if (BLI_ghash_haskey(visithash, &tstkey)) - // continue; - - key = BLI_memarena_alloc(arena, sizeof(edgepairkey)); - *key = tstkey; - BLI_ghash_insert(visithash, key, NULL); - - sub_v3_v3v3(p1, verts[j], verts[j2]); - sub_v3_v3v3(p2, verts[k+3], verts[k2+3]); - - cross_v3_v3v3(off, p1, p2); - normalize_v3(off); - - if (dot_v3v3(n2, off) < 0.0) - negate_v3(off); - - mul_v3_fl(off, epsilon1 + epsilon2 + ALMOST_ZERO); - copy_v3_v3(p1, verts[k+3]); - copy_v3_v3(p2, verts[k2+3]); - add_v3_v3(p1, off); - add_v3_v3(p2, off); - - ret = eltopo_line_line_moving_isect_v3v3_f(verts[j], table[j], verts[j2], table[j2], - p1, table[k+3], p2, table[k2+3], - no, uv, &t, &relnor); - /*cloth vert versus coll face*/ - if (ret) { - collpair->ap1 = table[j]; collpair->ap2 = table[j2]; - collpair->bp1 = table[k+3]; collpair->bp2 = table[k2+3]; - - /*I'm not sure if this is correct, but hopefully it's - better then simply ignoring back edges*/ - if (dot_v3v3(n2, no) < 0.0) { - negate_v3(no); - } - - copy_v3_v3(collpair->normal, no); - mul_v3_v3fl(collpair->vector, collpair->normal, relnor); - collpair->distance = relnor; - collpair->time = t; - - copy_v2_v2(collpair->bary, uv); - - collpair->flag = COLLISION_IS_EDGES; - collpair++; - } - } - } - } - - return collpair; -} - -static int cloth_edge_collision_response_moving ( ClothModifierData *clmd, CollisionModifierData *collmd, CollPair *collpair, CollPair *collision_end ) -{ - int result = 0; - Cloth *cloth1; - float w1, w2; - float v1[3], v2[3], relativeVelocity[3]; - float magrelVel, pimpulse[3]; - - cloth1 = clmd->clothObject; - - for ( ; collpair != collision_end; collpair++ ) { - if (!(collpair->flag & COLLISION_IS_EDGES)) - continue; - - // was: txold - w1 = collpair->bary[0]; w2 = collpair->bary[1]; - - // Calculate relative "velocity". - VECADDFAC(v1, cloth1->verts[collpair->ap1].tv, cloth1->verts[collpair->ap2].tv, w1); - VECADDFAC(v2, collmd->current_v[collpair->bp1].co, collmd->current_v[collpair->bp2].co, w2); - - sub_v3_v3v3(relativeVelocity, v2, v1); - - // Calculate the normal component of the relative velocity (actually only the magnitude - the direction is stored in 'normal'). - magrelVel = dot_v3v3 ( relativeVelocity, collpair->normal ); - - // If v_n_mag < 0 the edges are approaching each other. - 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; - float vrel_t_pre[3]; - float temp[3], spf; - - zero_v3(pimpulse); - - // calculate tangential velocity - copy_v3_v3 ( temp, collpair->normal ); - mul_v3_fl(temp, magrelVel); - sub_v3_v3v3(vrel_t_pre, relativeVelocity, temp); - - // Decrease in magnitude of relative tangential velocity due to coulomb friction - // in original formula "magrelVel" should be the "change of relative velocity in normal direction" - 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 ) { - normalize_v3(vrel_t_pre); - - impulse = magtangent; - VECADDMUL ( pimpulse, vrel_t_pre, impulse); - } - - // Apply velocity stopping impulse - // I_c = m * v_N / 2.0 - // no 2.0 * magrelVel normally, but looks nicer DG - impulse = magrelVel; - - mul_v3_fl(collpair->normal, 0.5); - VECADDMUL ( pimpulse, collpair->normal, impulse); - + else + { // Apply repulse impulse if distance too short // I_r = -min(dt*kd, m(0, 1d/dt - v_n)) - spf = (float)clmd->sim_parms->stepsPerFrame / clmd->sim_parms->timescale; - - d = collpair->distance; - if ( ( magrelVel < 0.1*d*spf && ( d > ALMOST_ZERO ) ) ) { - repulse = MIN2 ( d*1.0/spf, 0.1*d*spf - magrelVel ); + float spf = (float)clmd->sim_parms->stepsPerFrame / clmd->sim_parms->timescale; + float d = clmd->coll_parms->epsilon*8.0f/9.0f + epsilon2*8.0f/9.0f - collpair->distance; + if ( d > ALMOST_ZERO) { // stay on the safe side and clamp repulse - if ( impulse > ALMOST_ZERO ) - repulse = MIN2 ( repulse, 5.0*impulse ); - repulse = MAX2 ( impulse, repulse ); + float repulse = d*1.0f/spf; - impulse = repulse / ( 5.0 ); // original 2.0 / 0.25 - VECADDMUL ( pimpulse, collpair->normal, impulse); - } - - w2 = 1.0f-w1; - if (w1 < 0.5) - w1 *= 2.0; - else - w2 *= 2.0; - - VECADDFAC(cloth1->verts[collpair->ap1].impulse, cloth1->verts[collpair->ap1].impulse, pimpulse, w1*2.0); - VECADDFAC(cloth1->verts[collpair->ap2].impulse, cloth1->verts[collpair->ap2].impulse, pimpulse, w2*2.0); - - cloth1->verts[collpair->ap1].impulse_count++; - cloth1->verts[collpair->ap2].impulse_count++; - - result = 1; - } - } - - return result; -} + float impulse = repulse / ( 1.0f + w1*w1 + w2*w2 + w3*w3 ); // original 2.0 / 0.25 + VECADDMUL ( i1, collpair->normal, impulse ); + VECADDMUL ( i2, collpair->normal, impulse ); + VECADDMUL ( i3, collpair->normal, impulse ); -static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionModifierData *collmd, CollPair *collpair, CollPair *collision_end ) -{ - int result = 0; - Cloth *cloth1; - float w1, w2, w3, u1, u2, u3; - float v1[3], v2[3], relativeVelocity[3]; - float magrelVel; - float epsilon2 = BLI_bvhtree_getepsilon ( collmd->bvhtree ); - - cloth1 = clmd->clothObject; - - for ( ; collpair != collision_end; collpair++ ) { - if (collpair->flag & COLLISION_IS_EDGES) - continue; - - if ( collpair->flag & COLLISION_USE_COLLFACE ) { - // was: txold - w1 = collpair->bary[0]; w2 = collpair->bary[1]; w3 = collpair->bary[2]; - - // Calculate relative "velocity". - collision_interpolateOnTriangle ( v1, collmd->current_v[collpair->bp1].co, collmd->current_v[collpair->bp2].co, collmd->current_v[collpair->bp3].co, w1, w2, w3); - - sub_v3_v3v3(relativeVelocity, v1, cloth1->verts[collpair->collp].tv); - - // Calculate the normal component of the relative velocity (actually only the magnitude - the direction is stored in 'normal'). - magrelVel = dot_v3v3 ( relativeVelocity, collpair->normal ); - - // If v_n_mag < 0 the edges are approaching each other. - 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; - float vrel_t_pre[3]; - float temp[3], spf; - - // calculate tangential velocity - copy_v3_v3 ( temp, collpair->normal ); - mul_v3_fl(temp, magrelVel); - sub_v3_v3v3(vrel_t_pre, relativeVelocity, temp); - - // Decrease in magnitude of relative tangential velocity due to coulomb friction - // in original formula "magrelVel" should be the "change of relative velocity in normal direction" - 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 ) { - normalize_v3(vrel_t_pre); - - impulse = magtangent; // 2.0 * - VECADDMUL ( cloth1->verts[collpair->collp].impulse, vrel_t_pre, impulse); - } - - // Apply velocity stopping impulse - // I_c = m * v_N / 2.0 - // no 2.0 * magrelVel normally, but looks nicer DG - impulse = magrelVel/2.0; - - VECADDMUL ( cloth1->verts[collpair->collp].impulse, collpair->normal, impulse); - cloth1->verts[collpair->collp].impulse_count++; - - // Apply repulse impulse if distance too short - // I_r = -min(dt*kd, m(0, 1d/dt - v_n)) - spf = (float)clmd->sim_parms->stepsPerFrame / clmd->sim_parms->timescale; - - d = -collpair->distance; - 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 - if ( impulse > ALMOST_ZERO ) - repulse = MIN2 ( repulse, 5.0*impulse ); - repulse = MAX2 ( impulse, repulse ); - - impulse = repulse / ( 5.0 ); // original 2.0 / 0.25 - VECADDMUL ( cloth1->verts[collpair->collp].impulse, collpair->normal, impulse); - } - - result = 1; - } - } - else { - w1 = collpair->bary[0]; w2 = collpair->bary[1]; w3 = collpair->bary[2]; - - // Calculate relative "velocity". - collision_interpolateOnTriangle ( v1, cloth1->verts[collpair->ap1].tv, cloth1->verts[collpair->ap2].tv, cloth1->verts[collpair->ap3].tv, w1, w2, w3 ); - - sub_v3_v3v3(relativeVelocity, collmd->current_v[collpair->collp].co, v1); - - // Calculate the normal component of the relative velocity (actually only the magnitude - the direction is stored in 'normal'). - magrelVel = dot_v3v3 ( relativeVelocity, collpair->normal ); - - // If v_n_mag < 0 the edges are approaching each other. - 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; - float vrel_t_pre[3], pimpulse[3] = {0.0f, 0.0f, 0.0f}; - float temp[3], spf; - - // calculate tangential velocity - copy_v3_v3 ( temp, collpair->normal ); - mul_v3_fl(temp, magrelVel); - sub_v3_v3v3(vrel_t_pre, relativeVelocity, temp); - - // Decrease in magnitude of relative tangential velocity due to coulomb friction - // in original formula "magrelVel" should be the "change of relative velocity in normal direction" - 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 ) { - normalize_v3(vrel_t_pre); - - impulse = magtangent; // 2.0 * - VECADDMUL ( pimpulse, vrel_t_pre, impulse); - } - - // Apply velocity stopping impulse - // I_c = m * v_N / 2.0 - // no 2.0 * magrelVel normally, but looks nicer DG - impulse = magrelVel/2.0; - - VECADDMUL ( pimpulse, collpair->normal, impulse); - - // Apply repulse impulse if distance too short - // I_r = -min(dt*kd, m(0, 1d/dt - v_n)) - spf = (float)clmd->sim_parms->stepsPerFrame / clmd->sim_parms->timescale; - - d = -collpair->distance; - 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 - if ( impulse > ALMOST_ZERO ) - repulse = MIN2 ( repulse, 5.0*impulse ); - repulse = MAX2 ( impulse, repulse ); - - impulse = repulse / ( 2.0 ); // original 2.0 / 0.25 - VECADDMUL ( pimpulse, collpair->normal, impulse); - } - - if (w1 < 0.5) w1 *= 2.0; - if (w2 < 0.5) w2 *= 2.0; - if (w3 < 0.5) w3 *= 2.0; - - VECADDMUL(cloth1->verts[collpair->ap1].impulse, pimpulse, w1*2.0); - VECADDMUL(cloth1->verts[collpair->ap2].impulse, pimpulse, w2*2.0); - VECADDMUL(cloth1->verts[collpair->ap3].impulse, pimpulse, w3*2.0); cloth1->verts[collpair->ap1].impulse_count++; cloth1->verts[collpair->ap2].impulse_count++; cloth1->verts[collpair->ap3].impulse_count++; - - result = 1; - } - } - } - - return result; -} - - -typedef struct tripairkey { - int p, a1, a2, a3; -} tripairkey; - -unsigned int tripair_hash(void *vkey) -{ - tripairkey *key = vkey; - int keys[4] = {key->p, key->a1, key->a2, key->a3}; - int i, j; - - for (i=0; i<4; i++) { - for (j=0; j<3; j++) { - if (keys[j] >= keys[j+1]) { - SWAP(int, keys[j], keys[j+1]); - } - } - } - - return keys[0]*101 + keys[1]*72 + keys[2]*53 + keys[3]*34; -} - -int tripair_cmp(const void *va, const void *vb) -{ - tripairkey *a = va, *b = vb; - int keysa[4] = {a->p, a->a1, a->a2, a->a3}; - int keysb[4] = {b->p, b->a1, b->a2, b->a3}; - int i; - - for (i=0; i<4; i++) { - int j, ok=0; - for (j=0; j<4; j++) { - if (keysa[i] == keysa[j]) { - ok = 1; - break; - } - } - if (!ok) - return -1; - } - - return 0; -} - -static void get_tripairkey(tripairkey *key, int p, int a1, int a2, int a3) -{ - key->a1 = a1; - key->a2 = a2; - key->a3 = a3; - key->p = p; -} - -static int checkvisit(MemArena *arena, GHash *gh, int p, int a1, int a2, int a3) -{ - tripairkey key, *key2; - - get_tripairkey(&key, p, a1, a2, a3); - if (BLI_ghash_haskey(gh, &key)) - return 1; - - key2 = BLI_memarena_alloc(arena, sizeof(*key2)); - *key2 = key; - BLI_ghash_insert(gh, key2, NULL); - - return 0; -} - -int cloth_point_tri_moving_v3v3_f(float v1[2][3], int i1, float v2[2][3], int i2, - float v3[2][3], int i3, float v4[2][3], int i4, - float normal[3], float bary[3], float *t, - float *relnor, GHash *gh, MemArena *arena) -{ - if (checkvisit(arena, gh, i1, i2, i3, i4)) - return 0; - - return eltopo_point_tri_moving_v3v3_f(v1, i1, v2, i2, v3, i3, v4, i4, normal, bary, t, relnor); -} -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; - MFace *face1=NULL, *face2 = NULL; - ClothVertex *verts1 = clmd->clothObject->verts; - double distance = 0; - float epsilon1 = clmd->coll_parms->epsilon; - float epsilon2 = BLI_bvhtree_getepsilon ( collmd->bvhtree ); - float no[3], uv[3], t, relnor; - int i, i1, i2, i3, i4, i5, i6; - Cloth *cloth = clmd->clothObject; - float n1[3], sdis, p[3], l, n2[3], off[3], v1[2][3], v2[2][3], v3[2][3], v4[2][3], v5[2][3], v6[2][3]; - int j, ret, bp1, bp2, bp3, ap1, ap2, ap3; - - face1 = & ( clmd->clothObject->mfaces[overlap->indexA] ); - face2 = & ( collmd->mfaces[overlap->indexB] ); - - // check all 4 possible collisions - for ( i = 0; i < 4; i++ ) { - if ( i == 0 ) { - // fill faceA - ap1 = face1->v1; - ap2 = face1->v2; - ap3 = face1->v3; - - // fill faceB - bp1 = face2->v1; - bp2 = face2->v2; - bp3 = face2->v3; - } - else if ( i == 1 ) { - if ( face1->v4 ) { - // fill faceA - ap1 = face1->v1; - ap2 = face1->v3; - ap3 = face1->v4; - - // fill faceB - bp1 = face2->v1; - bp2 = face2->v2; - bp3 = face2->v3; - } - else { - continue; - } - } - if ( i == 2 ) { - if ( face2->v4 ) { - // fill faceA - ap1 = face1->v1; - ap2 = face1->v2; - ap3 = face1->v3; - - // fill faceB - bp1 = face2->v1; - bp2 = face2->v3; - bp3 = face2->v4; - } - else { - continue; + result = 1; } } - else if ( i == 3 ) { - if ( face1->v4 && face2->v4 ) { - // fill faceA - ap1 = face1->v1; - ap2 = face1->v3; - ap3 = face1->v4; - // fill faceB - bp1 = face2->v1; - bp2 = face2->v3; - bp3 = face2->v4; - } - else { - continue; - } - } - - copy_v3_v3(v1[0], cloth->verts[ap1].txold); - copy_v3_v3(v1[1], cloth->verts[ap1].tx); - copy_v3_v3(v2[0], cloth->verts[ap2].txold); - copy_v3_v3(v2[1], cloth->verts[ap2].tx); - copy_v3_v3(v3[0], cloth->verts[ap3].txold); - copy_v3_v3(v3[1], cloth->verts[ap3].tx); - - copy_v3_v3(v4[0], collmd->current_x[bp1].co); - copy_v3_v3(v4[1], collmd->current_xnew[bp1].co); - copy_v3_v3(v5[0], collmd->current_x[bp2].co); - copy_v3_v3(v5[1], collmd->current_xnew[bp2].co); - copy_v3_v3(v6[0], collmd->current_x[bp3].co); - copy_v3_v3(v6[1], collmd->current_xnew[bp3].co); - - normal_tri_v3(n2, v4[1], v5[1], v6[1]); - - sdis = clmd->coll_parms->distance_repel + epsilon2 + FLT_EPSILON; - - /*apply a repulsion force, to help the solver along*/ - copy_v3_v3(off, n2); - negate_v3(off); - if (isect_ray_plane_v3(v1[1], off, v4[1], v5[1], v6[1], &l, 0)) { - if (l >= 0.0 && l < sdis) { - mul_v3_fl(off, (l-sdis)*cloth->verts[ap1].mass*dt*clmd->coll_parms->repel_force*0.1); - - add_v3_v3(cloth->verts[ap1].tv, off); - add_v3_v3(cloth->verts[ap2].tv, off); - add_v3_v3(cloth->verts[ap3].tv, off); - } - } + if(result) + { + int i = 0; - /*offset new positions a bit, to account for margins*/ - copy_v3_v3(off, n2); - mul_v3_fl(off, epsilon1 + epsilon2 + ALMOST_ZERO); - add_v3_v3(v4[1], off); add_v3_v3(v5[1], off); add_v3_v3(v6[1], off); - - i1 = ap1; i2 = ap2; i3 = ap3; - i4 = bp1+cloth->numverts; i5 = bp2+cloth->numverts; i6 = bp3+cloth->numverts; - - for (j=0; j<6; j++) { - int collp; + for(i = 0; i < 3; i++) + { + if(cloth1->verts[collpair->ap1].impulse_count > 0 && ABS(cloth1->verts[collpair->ap1].impulse[i]) < ABS(i1[i])) + cloth1->verts[collpair->ap1].impulse[i] = i1[i]; - switch (j) { - case 0: - ret = cloth_point_tri_moving_v3v3_f(v1, i1, v4, i4, v5, i5, v6, i6, no, uv, &t, &relnor, gh, arena); - collp = ap1; - break; - case 1: - collp = ap2; - ret = cloth_point_tri_moving_v3v3_f(v2, i2, v4, i4, v5, i5, v6, i6, no, uv, &t, &relnor, gh, arena); - break; - case 2: - collp = ap3; - ret = cloth_point_tri_moving_v3v3_f(v3, i3, v4, i4, v5, i5, v6, i6, no, uv, &t, &relnor, gh, arena); - break; - case 3: - collp = bp1; - ret = cloth_point_tri_moving_v3v3_f(v4, i4, v1, i1, v2, i2, v3, i3, no, uv, &t, &relnor, gh, arena); - break; - case 4: - collp = bp2; - ret = cloth_point_tri_moving_v3v3_f(v5, i5, v1, i1, v2, i2, v3, i3, no, uv, &t, &relnor, gh, arena); - break; - case 5: - collp = bp3; - ret = cloth_point_tri_moving_v3v3_f(v6, i6, v1, i1, v2, i2, v3, i3, no, uv, &t, &relnor, gh, arena); - break; - } - - /*cloth vert versus coll face*/ - if (ret && j < 3) { - collpair->bp1 = bp1; collpair->bp2 = bp2; collpair->bp3 = bp3; - collpair->collp = collp; - - copy_v3_v3(collpair->normal, no); - mul_v3_v3fl(collpair->vector, collpair->normal, relnor); - collpair->distance = relnor; - collpair->time = t; - - copy_v3_v3(collpair->bary, uv); - - collpair->flag = COLLISION_USE_COLLFACE; - collpair++; - } - else if (ret && j >= 3) { /*coll vert versus cloth face*/ - collpair->ap1 = ap1; collpair->ap2 = ap2; collpair->ap3 = ap3; - collpair->collp = collp; - - copy_v3_v3(collpair->normal, no); - mul_v3_v3fl(collpair->vector, collpair->normal, relnor); - collpair->distance = relnor; - collpair->time = t; - - copy_v3_v3(collpair->bary, uv); + if(cloth1->verts[collpair->ap2].impulse_count > 0 && ABS(cloth1->verts[collpair->ap2].impulse[i]) < ABS(i2[i])) + cloth1->verts[collpair->ap2].impulse[i] = i2[i]; - collpair->flag = 0; - collpair++; + if(cloth1->verts[collpair->ap3].impulse_count > 0 && ABS(cloth1->verts[collpair->ap3].impulse[i]) < ABS(i3[i])) + cloth1->verts[collpair->ap3].impulse[i] = i3[i]; } } } - - return collpair; -} - -static void machine_epsilon_offset(Cloth *cloth) -{ - ClothVertex *cv; - int i, j; - - cv = cloth->verts; - for (i=0; i<cloth->numverts; i++, cv++) { - /*aggrevatingly enough, it's necessary to offset the coordinates - by a multiple of the 32-bit floating point epsilon when switching - into doubles*/ - #define RNDSIGN (float)(-1*(BLI_rand()%2==0)|1) - for (j=0; j<3; j++) { - cv->tx[j] += FLT_EPSILON*30.0f*RNDSIGN; - cv->txold[j] += FLT_EPSILON*30.0f*RNDSIGN; - cv->tv[j] += FLT_EPSILON*30.0f*RNDSIGN; - } - } + return result; } -#else /* !WITH_ELTOPO */ - //Determines collisions on overlap, collisions are written to collpair[i] and collision+number_collision_found is returned -static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, - BVHTreeOverlap *overlap, CollPair *collpair, float dt ) +static CollPair* cloth_collision(ModifierData *md1, ModifierData *md2, + BVHTreeOverlap *overlap, CollPair *collpair, float UNUSED(dt)) { ClothModifierData *clmd = (ClothModifierData *)md1; CollisionModifierData *collmd = (CollisionModifierData *) md2; - Cloth *cloth = clmd->clothObject; + /* Cloth *cloth = clmd->clothObject; */ /* UNUSED */ MFace *face1=NULL, *face2 = NULL; #ifdef USE_BULLET ClothVertex *verts1 = clmd->clothObject->verts; @@ -1372,7 +379,6 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, double distance = 0; float epsilon1 = clmd->coll_parms->epsilon; float epsilon2 = BLI_bvhtree_getepsilon ( collmd->bvhtree ); - float n2[3], sdis, l; int i; face1 = & ( clmd->clothObject->mfaces[overlap->indexA] ); @@ -1395,8 +401,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, if ( face1->v4 ) { // fill faceA collpair->ap1 = face1->v1; - collpair->ap2 = face1->v4; - collpair->ap3 = face1->v3; + collpair->ap2 = face1->v3; + collpair->ap3 = face1->v4; // fill faceB collpair->bp1 = face2->v1; @@ -1425,39 +431,18 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, if ( face1->v4 && face2->v4 ) { // fill faceA collpair->ap1 = face1->v1; - collpair->ap2 = face1->v4; - collpair->ap3 = face1->v3; + collpair->ap2 = face1->v3; + collpair->ap3 = face1->v4; // fill faceB collpair->bp1 = face2->v1; - collpair->bp2 = face2->v4; - collpair->bp3 = face2->v3; + collpair->bp2 = face2->v3; + collpair->bp3 = face2->v4; } else break; } - normal_tri_v3(n2, collmd->current_xnew[collpair->bp1].co, - collmd->current_xnew[collpair->bp2].co, - collmd->current_xnew[collpair->bp3].co); - - sdis = clmd->coll_parms->distance_repel + epsilon2 + FLT_EPSILON; - - /* apply a repulsion force, to help the solver along. - * this is kindof crude, it only tests one vert of the triangle */ - if (isect_ray_plane_v3(cloth->verts[collpair->ap1].tx, n2, collmd->current_xnew[collpair->bp1].co, - collmd->current_xnew[collpair->bp2].co, - collmd->current_xnew[collpair->bp3].co, &l, 0)) - { - if (l >= 0.0f && l < sdis) { - mul_v3_fl(n2, (l-sdis)*cloth->verts[collpair->ap1].mass*dt*clmd->coll_parms->repel_force*0.1f); - - add_v3_v3(cloth->verts[collpair->ap1].tv, n2); - add_v3_v3(cloth->verts[collpair->ap2].tv, n2); - add_v3_v3(cloth->verts[collpair->ap3].tv, n2); - } - } - #ifdef USE_BULLET // calc distance + normal distance = plNearestPoints ( @@ -1512,579 +497,6 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, } return collpair; } -#endif /* WITH_ELTOPO */ - - -#if 0 -static int cloth_collision_response_moving( ClothModifierData *clmd, CollisionModifierData *collmd, CollPair *collpair, CollPair *collision_end ) -{ - int result = 0; - Cloth *cloth1; - float w1, w2, w3, u1, u2, u3; - float v1[3], v2[3], relativeVelocity[3]; - float magrelVel; - - cloth1 = clmd->clothObject; - - for ( ; collpair != collision_end; collpair++ ) - { - // compute barycentric coordinates for both collision points - collision_compute_barycentric ( collpair->pa, - cloth1->verts[collpair->ap1].txold, - cloth1->verts[collpair->ap2].txold, - cloth1->verts[collpair->ap3].txold, - &w1, &w2, &w3 ); - - // was: txold - collision_compute_barycentric ( collpair->pb, - collmd->current_x[collpair->bp1].co, - collmd->current_x[collpair->bp2].co, - collmd->current_x[collpair->bp3].co, - &u1, &u2, &u3 ); - - // Calculate relative "velocity". - collision_interpolateOnTriangle ( v1, cloth1->verts[collpair->ap1].tv, cloth1->verts[collpair->ap2].tv, cloth1->verts[collpair->ap3].tv, w1, w2, w3 ); - - collision_interpolateOnTriangle ( v2, collmd->current_v[collpair->bp1].co, collmd->current_v[collpair->bp2].co, collmd->current_v[collpair->bp3].co, u1, u2, u3 ); - - sub_v3_v3v3(relativeVelocity, v2, v1); - - // Calculate the normal component of the relative velocity (actually only the magnitude - the direction is stored in 'normal'). - magrelVel = dot_v3v3 ( relativeVelocity, collpair->normal ); - - // printf("magrelVel: %f\n", magrelVel); - - // Calculate masses of points. - // TODO - - // If v_n_mag < 0 the edges are approaching each other. - if ( magrelVel > ALMOST_ZERO ) - { - // Calculate Impulse magnitude to stop all motion in normal direction. - float magtangent = 0; - double impulse = 0.0; - float vrel_t_pre[3]; - float temp[3]; - - // calculate tangential velocity - copy_v3_v3 ( temp, collpair->normal ); - mul_v3_fl(temp, magrelVel); - sub_v3_v3v3(vrel_t_pre, relativeVelocity, temp); - - // Decrease in magnitude of relative tangential velocity due to coulomb friction - // in original formula "magrelVel" should be the "change of relative velocity in normal direction" - 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 ) - { - normalize_v3(vrel_t_pre); - - impulse = 2.0 * magtangent / ( 1.0 + w1*w1 + w2*w2 + w3*w3 ); - VECADDMUL ( cloth1->verts[collpair->ap1].impulse, vrel_t_pre, w1 * impulse ); - VECADDMUL ( cloth1->verts[collpair->ap2].impulse, vrel_t_pre, w2 * impulse ); - VECADDMUL ( cloth1->verts[collpair->ap3].impulse, vrel_t_pre, w3 * impulse ); - } - - // Apply velocity stopping impulse - // I_c = m * v_N / 2.0 - // no 2.0 * magrelVel normally, but looks nicer DG - impulse = magrelVel / ( 1.0 + w1*w1 + w2*w2 + w3*w3 ); - - VECADDMUL ( cloth1->verts[collpair->ap1].impulse, collpair->normal, w1 * impulse ); - cloth1->verts[collpair->ap1].impulse_count++; - - VECADDMUL ( cloth1->verts[collpair->ap2].impulse, collpair->normal, w2 * impulse ); - cloth1->verts[collpair->ap2].impulse_count++; - - VECADDMUL ( cloth1->verts[collpair->ap3].impulse, collpair->normal, w3 * impulse ); - cloth1->verts[collpair->ap3].impulse_count++; - - // Apply repulse impulse if distance too short - // I_r = -min(dt*kd, m(0, 1d/dt - v_n)) - /* - d = clmd->coll_parms->epsilon*8.0/9.0 + epsilon2*8.0/9.0 - collpair->distance; - if ( ( magrelVel < 0.1*d*clmd->sim_parms->stepsPerFrame ) && ( d > ALMOST_ZERO ) ) - { - repulse = MIN2 ( d*1.0/clmd->sim_parms->stepsPerFrame, 0.1*d*clmd->sim_parms->stepsPerFrame - magrelVel ); - - // stay on the safe side and clamp repulse - if ( impulse > ALMOST_ZERO ) - repulse = MIN2 ( repulse, 5.0*impulse ); - repulse = MAX2 ( impulse, repulse ); - - impulse = repulse / ( 1.0 + w1*w1 + w2*w2 + w3*w3 ); // original 2.0 / 0.25 - VECADDMUL ( cloth1->verts[collpair->ap1].impulse, collpair->normal, impulse ); - VECADDMUL ( cloth1->verts[collpair->ap2].impulse, collpair->normal, impulse ); - VECADDMUL ( cloth1->verts[collpair->ap3].impulse, collpair->normal, impulse ); - } - */ - result = 1; - } - } - return result; -} -#endif - -#if 0 -static float projectPointOntoLine(float *p, float *a, float *b) -{ - float ba[3], pa[3]; - sub_v3_v3v3(ba, b, a); - sub_v3_v3v3(pa, p, a); - return dot_v3v3(pa, ba) / dot_v3v3(ba, ba); -} - -static void calculateEENormal(float *np1, float *np2, float *np3, float *np4, float *out_normal) -{ - float line1[3], line2[3]; - float length; - - sub_v3_v3v3(line1, np2, np1); - sub_v3_v3v3(line2, np3, np1); - - // printf("l1: %f, l1: %f, l2: %f, l2: %f\n", line1[0], line1[1], line2[0], line2[1]); - - cross_v3_v3v3(out_normal, line1, line2); - - - - length = normalize_v3(out_normal); - if (length <= FLT_EPSILON) - { // lines are collinear - sub_v3_v3v3(out_normal, np2, np1); - normalize_v3(out_normal); - } -} - -static void findClosestPointsEE(float *x1, float *x2, float *x3, float *x4, float *w1, float *w2) -{ - float temp[3], temp2[3]; - - double a, b, c, e, f; - - sub_v3_v3v3(temp, x2, x1); - a = dot_v3v3(temp, temp); - - sub_v3_v3v3(temp2, x4, x3); - b = -dot_v3v3(temp, temp2); - - c = dot_v3v3(temp2, temp2); - - sub_v3_v3v3(temp2, x3, x1); - e = dot_v3v3(temp, temp2); - - sub_v3_v3v3(temp, x4, x3); - f = -dot_v3v3(temp, temp2); - - *w1 = (e * c - b * f) / (a * c - b * b); - *w2 = (f - b * *w1) / c; - -} - -// calculates the distance of 2 edges -static float edgedge_distance(float np11[3], float np12[3], float np21[3], float np22[3], float *out_a1, float *out_a2, float *out_normal) -{ - float line1[3], line2[3], cross[3]; - float length; - float temp[3], temp2[3]; - float dist_a1, dist_a2; - - sub_v3_v3v3(line1, np12, np11); - sub_v3_v3v3(line2, np22, np21); - - cross_v3_v3v3(cross, line1, line2); - length = dot_v3v3(cross, cross); - - if (length < FLT_EPSILON) - { - *out_a2 = projectPointOntoLine(np11, np21, np22); - if ((*out_a2 >= -FLT_EPSILON) && (*out_a2 <= 1.0 + FLT_EPSILON)) - { - *out_a1 = 0; - calculateEENormal(np11, np12, np21, np22, out_normal); - sub_v3_v3v3(temp, np22, np21); - mul_v3_fl(temp, *out_a2); - VECADD(temp2, temp, np21); - VECADD(temp2, temp2, np11); - return dot_v3v3(temp2, temp2); - } - - CLAMP(*out_a2, 0.0, 1.0); - if (*out_a2 > .5) - { // == 1.0 - *out_a1 = projectPointOntoLine(np22, np11, np12); - if ((*out_a1 >= -FLT_EPSILON) && (*out_a1 <= 1.0 + FLT_EPSILON)) - { - calculateEENormal(np11, np12, np21, np22, out_normal); - - // return (np22 - (np11 + (np12 - np11) * out_a1)).lengthSquared(); - sub_v3_v3v3(temp, np12, np11); - mul_v3_fl(temp, *out_a1); - VECADD(temp2, temp, np11); - sub_v3_v3v3(temp2, np22, temp2); - return dot_v3v3(temp2, temp2); - } - } - else - { // == 0.0 - *out_a1 = projectPointOntoLine(np21, np11, np12); - if ((*out_a1 >= -FLT_EPSILON) && (*out_a1 <= 1.0 + FLT_EPSILON)) - { - calculateEENormal(np11, np11, np21, np22, out_normal); - - // return (np21 - (np11 + (np12 - np11) * out_a1)).lengthSquared(); - sub_v3_v3v3(temp, np12, np11); - mul_v3_fl(temp, *out_a1); - VECADD(temp2, temp, np11); - sub_v3_v3v3(temp2, np21, temp2); - return dot_v3v3(temp2, temp2); - } - } - - CLAMP(*out_a1, 0.0, 1.0); - calculateEENormal(np11, np12, np21, np22, out_normal); - if (*out_a1 > .5) - { - if (*out_a2 > .5) - { - sub_v3_v3v3(temp, np12, np22); - } - else - { - sub_v3_v3v3(temp, np12, np21); - } - } - else - { - if (*out_a2 > .5) - { - sub_v3_v3v3(temp, np11, np22); - } - else - { - sub_v3_v3v3(temp, np11, np21); - } - } - - return dot_v3v3(temp, temp); - } - else - { - - // If the lines aren't parallel (but coplanar) they have to intersect - - findClosestPointsEE(np11, np12, np21, np22, out_a1, out_a2); - - // If both points are on the finite edges, we're done. - if (*out_a1 >= 0.0 && *out_a1 <= 1.0 && *out_a2 >= 0.0 && *out_a2 <= 1.0) - { - float p1[3], p2[3]; - - // p1= np11 + (np12 - np11) * out_a1; - sub_v3_v3v3(temp, np12, np11); - mul_v3_fl(temp, *out_a1); - VECADD(p1, np11, temp); - - // p2 = np21 + (np22 - np21) * out_a2; - sub_v3_v3v3(temp, np22, np21); - mul_v3_fl(temp, *out_a2); - VECADD(p2, np21, temp); - - calculateEENormal(np11, np12, np21, np22, out_normal); - sub_v3_v3v3(temp, p1, p2); - return dot_v3v3(temp, temp); - } - - - /* - * Clamp both points to the finite edges. - * The one that moves most during clamping is one part of the solution. - */ - dist_a1 = *out_a1; - CLAMP(dist_a1, 0.0, 1.0); - dist_a2 = *out_a2; - CLAMP(dist_a2, 0.0, 1.0); - - // Now project the "most clamped" point on the other line. - if (dist_a1 > dist_a2) - { - /* keep out_a1 */ - float p1[3]; - - // p1 = np11 + (np12 - np11) * out_a1; - sub_v3_v3v3(temp, np12, np11); - mul_v3_fl(temp, *out_a1); - VECADD(p1, np11, temp); - - *out_a2 = projectPointOntoLine(p1, np21, np22); - CLAMP(*out_a2, 0.0, 1.0); - - calculateEENormal(np11, np12, np21, np22, out_normal); - - // return (p1 - (np21 + (np22 - np21) * out_a2)).lengthSquared(); - sub_v3_v3v3(temp, np22, np21); - mul_v3_fl(temp, *out_a2); - VECADD(temp, temp, np21); - sub_v3_v3v3(temp, p1, temp); - return dot_v3v3(temp, temp); - } - else - { - /* keep out_a2 */ - float p2[3]; - - // p2 = np21 + (np22 - np21) * out_a2; - sub_v3_v3v3(temp, np22, np21); - mul_v3_fl(temp, *out_a2); - VECADD(p2, np21, temp); - - *out_a1 = projectPointOntoLine(p2, np11, np12); - CLAMP(*out_a1, 0.0, 1.0); - - calculateEENormal(np11, np12, np21, np22, out_normal); - - // return ((np11 + (np12 - np11) * out_a1) - p2).lengthSquared(); - sub_v3_v3v3(temp, np12, np11); - mul_v3_fl(temp, *out_a1); - VECADD(temp, temp, np11); - sub_v3_v3v3(temp, temp, p2); - return dot_v3v3(temp, temp); - } - } - - printf("Error in edgedge_distance: end of function\n"); - return 0; -} - -static int cloth_collision_moving_edges ( ClothModifierData *clmd, CollisionModifierData *collmd, CollPair *collpair ) -{ - EdgeCollPair edgecollpair; - Cloth *cloth1=NULL; - ClothVertex *verts1=NULL; - unsigned int i = 0, k = 0; - int numsolutions = 0; - double x1[3], v1[3], x2[3], v2[3], x3[3], v3[3]; - double solution[3], solution2[3]; - MVert *verts2 = collmd->current_x; // old x - MVert *velocity2 = collmd->current_v; // velocity - float distance = 0; - float triA[3][3], triB[3][3]; - int result = 0; - - cloth1 = clmd->clothObject; - verts1 = cloth1->verts; - - for (i = 0; i < 9; i++) - { - // 9 edge - edge possibilities - - if (i == 0) // cloth edge: 1-2; coll edge: 1-2 - { - edgecollpair.p11 = collpair->ap1; - edgecollpair.p12 = collpair->ap2; - - edgecollpair.p21 = collpair->bp1; - edgecollpair.p22 = collpair->bp2; - } - else if (i == 1) // cloth edge: 1-2; coll edge: 2-3 - { - edgecollpair.p11 = collpair->ap1; - edgecollpair.p12 = collpair->ap2; - - edgecollpair.p21 = collpair->bp2; - edgecollpair.p22 = collpair->bp3; - } - else if (i == 2) // cloth edge: 1-2; coll edge: 1-3 - { - edgecollpair.p11 = collpair->ap1; - edgecollpair.p12 = collpair->ap2; - - edgecollpair.p21 = collpair->bp1; - edgecollpair.p22 = collpair->bp3; - } - else if (i == 3) // cloth edge: 2-3; coll edge: 1-2 - { - edgecollpair.p11 = collpair->ap2; - edgecollpair.p12 = collpair->ap3; - - edgecollpair.p21 = collpair->bp1; - edgecollpair.p22 = collpair->bp2; - } - else if (i == 4) // cloth edge: 2-3; coll edge: 2-3 - { - edgecollpair.p11 = collpair->ap2; - edgecollpair.p12 = collpair->ap3; - - edgecollpair.p21 = collpair->bp2; - edgecollpair.p22 = collpair->bp3; - } - else if (i == 5) // cloth edge: 2-3; coll edge: 1-3 - { - edgecollpair.p11 = collpair->ap2; - edgecollpair.p12 = collpair->ap3; - - edgecollpair.p21 = collpair->bp1; - edgecollpair.p22 = collpair->bp3; - } - else if (i ==6) // cloth edge: 1-3; coll edge: 1-2 - { - edgecollpair.p11 = collpair->ap1; - edgecollpair.p12 = collpair->ap3; - - edgecollpair.p21 = collpair->bp1; - edgecollpair.p22 = collpair->bp2; - } - else if (i ==7) // cloth edge: 1-3; coll edge: 2-3 - { - edgecollpair.p11 = collpair->ap1; - edgecollpair.p12 = collpair->ap3; - - edgecollpair.p21 = collpair->bp2; - edgecollpair.p22 = collpair->bp3; - } - else if (i == 8) // cloth edge: 1-3; coll edge: 1-3 - { - edgecollpair.p11 = collpair->ap1; - edgecollpair.p12 = collpair->ap3; - - edgecollpair.p21 = collpair->bp1; - edgecollpair.p22 = collpair->bp3; - } - /* - if ((edgecollpair.p11 == 3) && (edgecollpair.p12 == 16)) - printf("Ahier!\n"); - if ((edgecollpair.p11 == 16) && (edgecollpair.p12 == 3)) - printf("Ahier!\n"); - */ - - // if ( !cloth_are_edges_adjacent ( clmd, collmd, &edgecollpair ) ) - { - // always put coll points in p21/p22 - sub_v3_v3v3(x1, verts1[edgecollpair.p12].txold, verts1[edgecollpair.p11].txold); - sub_v3_v3v3(v1, verts1[edgecollpair.p12].tv, verts1[edgecollpair.p11].tv); - - sub_v3_v3v3(x2, verts2[edgecollpair.p21].co, verts1[edgecollpair.p11].txold); - sub_v3_v3v3(v2, velocity2[edgecollpair.p21].co, verts1[edgecollpair.p11].tv); - - sub_v3_v3v3(x3, verts2[edgecollpair.p22].co, verts1[edgecollpair.p11].txold); - sub_v3_v3v3(v3, velocity2[edgecollpair.p22].co, verts1[edgecollpair.p11].tv); - - numsolutions = cloth_get_collision_time ( x1, v1, x2, v2, x3, v3, solution ); - - if ((edgecollpair.p11 == 3 && edgecollpair.p12==16)|| (edgecollpair.p11==16 && edgecollpair.p12==3)) - { - if (edgecollpair.p21==6 || edgecollpair.p22 == 6) - { - printf("dist: %f, sol[k]: %f, sol2[k]: %f\n", distance, solution[k], solution2[k]); - printf("a1: %f, a2: %f, b1: %f, b2: %f\n", x1[0], x2[0], x3[0], v1[0]); - printf("b21: %d, b22: %d\n", edgecollpair.p21, edgecollpair.p22); - } - } - - for ( k = 0; k < numsolutions; k++ ) - { - // printf("sol %d: %lf\n", k, solution[k]); - if ( ( solution[k] >= ALMOST_ZERO ) && ( solution[k] <= 1.0 ) && ( solution[k] > ALMOST_ZERO)) - { - float a, b; - float out_normal[3]; - float distance; - float impulse = 0; - float I_mag; - - // move verts - VECADDS(triA[0], verts1[edgecollpair.p11].txold, verts1[edgecollpair.p11].tv, solution[k]); - VECADDS(triA[1], verts1[edgecollpair.p12].txold, verts1[edgecollpair.p12].tv, solution[k]); - - VECADDS(triB[0], collmd->current_x[edgecollpair.p21].co, collmd->current_v[edgecollpair.p21].co, solution[k]); - VECADDS(triB[1], collmd->current_x[edgecollpair.p22].co, collmd->current_v[edgecollpair.p22].co, solution[k]); - - // TODO: check for collisions - distance = edgedge_distance(triA[0], triA[1], triB[0], triB[1], &a, &b, out_normal); - - if ((distance <= clmd->coll_parms->epsilon + BLI_bvhtree_getepsilon ( collmd->bvhtree ) + ALMOST_ZERO) && (dot_v3v3(out_normal, out_normal) > 0)) - { - float vrel_1_to_2[3], temp[3], temp2[3], out_normalVelocity; - float desiredVn; - - copy_v3_v3(vrel_1_to_2, verts1[edgecollpair.p11].tv); - mul_v3_fl(vrel_1_to_2, 1.0 - a); - copy_v3_v3(temp, verts1[edgecollpair.p12].tv); - mul_v3_fl(temp, a); - - VECADD(vrel_1_to_2, vrel_1_to_2, temp); - - copy_v3_v3(temp, verts1[edgecollpair.p21].tv); - mul_v3_fl(temp, 1.0 - b); - copy_v3_v3(temp2, verts1[edgecollpair.p22].tv); - mul_v3_fl(temp2, b); - VECADD(temp, temp, temp2); - - sub_v3_v3v3(vrel_1_to_2, vrel_1_to_2, temp); - - out_normalVelocity = dot_v3v3(vrel_1_to_2, out_normal); -/* - // this correction results in wrong normals sometimes? - if (out_normalVelocity < 0.0) - { - out_normalVelocity*= -1.0; - negate_v3(out_normal); - } -*/ - /* Inelastic repulsion impulse. */ - - // Calculate which normal velocity we need. - desiredVn = (out_normalVelocity * (float)solution[k] - (.1 * (clmd->coll_parms->epsilon + BLI_bvhtree_getepsilon ( collmd->bvhtree )) - sqrt(distance)) - ALMOST_ZERO); - - // Now calculate what impulse we need to reach that velocity. - I_mag = (out_normalVelocity - desiredVn) / 2.0; // / (1/m1 + 1/m2); - - // Finally apply that impulse. - impulse = (2.0 * -I_mag) / (a*a + (1.0-a)*(1.0-a) + b*b + (1.0-b)*(1.0-b)); - - VECADDMUL ( verts1[edgecollpair.p11].impulse, out_normal, (1.0-a) * impulse ); - verts1[edgecollpair.p11].impulse_count++; - - VECADDMUL ( verts1[edgecollpair.p12].impulse, out_normal, a * impulse ); - verts1[edgecollpair.p12].impulse_count++; - - // return true; - result = 1; - break; - } - else - { - // missing from collision.hpp - } - // mintime = MIN2(mintime, (float)solution[k]); - - break; - } - } - } - } - return result; -} - -static int cloth_collision_moving ( ClothModifierData *clmd, CollisionModifierData *collmd, CollPair *collpair, CollPair *collision_end ) -{ - Cloth *cloth1; - cloth1 = clmd->clothObject; - - for ( ; collpair != collision_end; collpair++ ) - { - // only handle moving collisions here - if (!( collpair->flag & COLLISION_IN_FUTURE )) - continue; - - cloth_collision_moving_edges ( clmd, collmd, collpair); - // cloth_collision_moving_tris ( clmd, collmd, collpair); - } - - return 1; -} -#endif static void add_collision_object(Object ***objs, unsigned int *numobj, unsigned int *maxobj, Object *ob, Object *self, int level, unsigned int modifier_type) { @@ -2224,37 +636,14 @@ static void cloth_bvh_objcollisions_nearcheck ( ClothModifierData * clmd, Collis CollPair **collisions, CollPair **collisions_index, int numresult, BVHTreeOverlap *overlap, double dt) { int i; -#ifdef WITH_ELTOPO - GHash *visithash = BLI_ghash_new(edgepair_hash, edgepair_cmp, "visthash, collision.c"); - GHash *tri_visithash = BLI_ghash_new(tripair_hash, tripair_cmp, "tri_visthash, collision.c"); - MemArena *arena = BLI_memarena_new(1<<16, "edge hash arena, collision.c"); -#endif *collisions = ( CollPair* ) MEM_mallocN ( sizeof ( CollPair ) * numresult * 64, "collision array" ); //*4 since cloth_collision_static can return more than 1 collision *collisions_index = *collisions; - -#ifdef WITH_ELTOPO - machine_epsilon_offset(clmd->clothObject); - - 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++ ) { - *collisions_index = cloth_edge_collision ( (ModifierData *)clmd, (ModifierData *)collmd, - overlap+i, *collisions_index, visithash, arena ); - } - BLI_ghash_free(visithash, NULL, NULL); - BLI_ghash_free(tri_visithash, NULL, NULL); - BLI_memarena_free(arena); -#else /* WITH_ELTOPO */ - for ( i = 0; i < numresult; i++ ) { *collisions_index = cloth_collision ( (ModifierData *)clmd, (ModifierData *)collmd, overlap+i, *collisions_index, dt ); } -#endif /* WITH_ELTOPO */ - } static int cloth_bvh_objcollisions_resolve ( ClothModifierData * clmd, CollisionModifierData *collmd, CollPair *collisions, CollPair *collisions_index) @@ -2264,36 +653,26 @@ static int cloth_bvh_objcollisions_resolve ( ClothModifierData * clmd, Collision ClothVertex *verts = NULL; int ret = 0; int result = 0; - float tnull[3] = {0, 0, 0}; - /*numfaces = clmd->clothObject->numfaces;*/ /*UNUSED*/ numverts = clmd->clothObject->numverts; - verts = cloth->verts; // 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 < 2; j++ ) { /* 5 is just a value that ensures convergence */ result = 0; 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); -#else result += cloth_collision_response_static ( clmd, collmd, collisions, collisions_index ); -#endif -#ifdef WITH_ELTOPO - { -#else + // apply impulses in parallel if (result) { -#endif for (i = 0; i < numverts; i++) { // calculate "velocities" (just xnew = xold + v; no dt in v) 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 ); + // VECADDMUL ( verts[i].tv, verts[i].impulse, 1.0f / verts[i].impulse_count ); + VECADD ( verts[i].tv, verts[i].tv, verts[i].impulse); + zero_v3(verts[i].impulse); verts[i].impulse_count = 0; ret++; @@ -2301,6 +680,9 @@ static int cloth_bvh_objcollisions_resolve ( ClothModifierData * clmd, Collision } } } + + if(!result) + break; } return ret; } @@ -2337,6 +719,18 @@ int cloth_bvh_objcollision(Object *ob, ClothModifierData * clmd, float step, flo if (!collobjs) return 0; + /* move object to position (step) in time */ + for (i = 0; i < numcollobj; i++) { + Object *collob= collobjs[i]; + CollisionModifierData *collmd = (CollisionModifierData*)modifiers_findByType(collob, eModifierType_Collision); + + if (!collmd->bvhtree) + continue; + + /* move object to position (step) in time */ + collision_move_object ( collmd, step + dt, step ); + } + do { CollPair **collisions, **collisions_index; @@ -2356,10 +750,6 @@ int cloth_bvh_objcollision(Object *ob, ClothModifierData * clmd, float step, flo if (!collmd->bvhtree) continue; - /* move object to position (step) in time */ - - collision_move_object ( collmd, step + dt, step ); - /* search for overlapping collision pairs */ overlap = BLI_bvhtree_overlap ( cloth_bvh, collmd->bvhtree, &result ); diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 7ba117861bb..d15f678f1c5 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -146,6 +146,32 @@ void curvemapping_set_black_white(CurveMapping *cumap, const float black[3], con /* ***************** operations on single curve ************* */ /* ********** NOTE: requires curvemapping_changed() call after ******** */ +/* remove specified point */ +void curvemap_remove_point(CurveMap *cuma, CurveMapPoint *point) +{ + CurveMapPoint *cmp; + int a, b, removed = 0; + + /* must have 2 points minimum */ + if (cuma->totpoint <= 2) + return; + + cmp = MEM_mallocN((cuma->totpoint) * sizeof(CurveMapPoint), "curve points"); + + /* well, lets keep the two outer points! */ + for (a = 0, b = 0; a < cuma->totpoint; a++) { + if (&cuma->curve[a] != point) { + cmp[b] = cuma->curve[a]; + b++; + } + else removed++; + } + + MEM_freeN(cuma->curve); + cuma->curve = cmp; + cuma->totpoint -= removed; +} + /* removes with flag set */ void curvemap_remove(CurveMap *cuma, int flag) { @@ -168,9 +194,10 @@ void curvemap_remove(CurveMap *cuma, int flag) cuma->totpoint -= removed; } -void curvemap_insert(CurveMap *cuma, float x, float y) +CurveMapPoint *curvemap_insert(CurveMap *cuma, float x, float y) { CurveMapPoint *cmp = MEM_callocN((cuma->totpoint + 1) * sizeof(CurveMapPoint), "curve points"); + CurveMapPoint *newcmp = NULL; int a, b, foundloc = 0; /* insert fragments of the old one and the new point to the new curve */ @@ -181,6 +208,7 @@ void curvemap_insert(CurveMap *cuma, float x, float y) cmp[a].y = y; cmp[a].flag = CUMA_SELECT; foundloc = 1; + newcmp = &cmp[a]; } else { cmp[a].x = cuma->curve[b].x; @@ -195,6 +223,8 @@ void curvemap_insert(CurveMap *cuma, float x, float y) /* free old curve and replace it with new one */ MEM_freeN(cuma->curve); cuma->curve = cmp; + + return newcmp; } void curvemap_reset(CurveMap *cuma, rctf *clipr, int preset, int slope) @@ -670,6 +700,20 @@ void curvemapping_changed(CurveMapping *cumap, int rem_doubles) curvemap_make_table(cuma, clipr); } +void curvemapping_changed_all(CurveMapping *cumap) +{ + int a, cur = cumap->cur; + + for (a = 0; a < CM_TOT; a++) { + if (cumap->cm[a].curve) { + cumap->cur = a; + curvemapping_changed(cumap, 0); + } + } + + cumap->cur = cur; +} + /* table should be verified */ float curvemap_evaluateF(CurveMap *cuma, float value) { diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index d736309f605..4cdb4e1b66e 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -44,6 +44,7 @@ #include "BLI_listbase.h" #include "BLI_string.h" +#include "BLI_utildefines.h" #include "BKE_context.h" #include "BKE_main.h" @@ -251,7 +252,7 @@ static int ctx_data_get(bContext *C, const char *member, bContextDataResult *res bScreen *sc; ScrArea *sa; ARegion *ar; - int done = 0, recursion = C->data.recursion; + int done = FALSE, recursion = C->data.recursion; int ret = 0; memset(result, 0, sizeof(bContextDataResult)); @@ -279,7 +280,7 @@ static int ctx_data_get(bContext *C, const char *member, bContextDataResult *res entry = BLI_rfindstring(&C->wm.store->entries, member, offsetof(bContextStoreEntry, name)); if (entry) { result->ptr = entry->ptr; - done = 1; + done = TRUE; } } if (done != 1 && recursion < 2 && (ar = CTX_wm_region(C))) { diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 54bc4c742fb..ce62b9c10dc 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -378,7 +378,7 @@ void BKE_curve_texspace_calc(Curve *cu) DispList *dl; BoundBox *bb; float *fp, min[3], max[3]; - int tot, doit = 0; + int tot, do_it = FALSE; if (cu->bb == NULL) cu->bb = MEM_callocN(sizeof(BoundBox), "boundbox"); @@ -390,7 +390,7 @@ void BKE_curve_texspace_calc(Curve *cu) while (dl) { tot = ELEM(dl->type, DL_INDEX3, DL_INDEX4) ? dl->nr : dl->nr * dl->parts; - if (tot) doit = 1; + if (tot) do_it = TRUE; fp = dl->verts; while (tot--) { minmax_v3v3_v3(min, max, fp); @@ -399,7 +399,7 @@ void BKE_curve_texspace_calc(Curve *cu) dl = dl->next; } - if (!doit) { + if (do_it == FALSE) { min[0] = min[1] = min[2] = -1.0f; max[0] = max[1] = max[2] = 1.0f; } @@ -1272,12 +1272,12 @@ float *BKE_curve_surf_make_orco(Object *ob) for (b = 0; b < sizeu; b++) { int use_b = b; if (b == sizeu - 1 && (nu->flagu & CU_NURB_CYCLIC)) - use_b = 0; + use_b = FALSE; for (a = 0; a < sizev; a++) { int use_a = a; if (a == sizev - 1 && (nu->flagv & CU_NURB_CYCLIC)) - use_a = 0; + use_a = FALSE; tdata = _tdata + 3 * (use_b * (nu->pntsv * resolv) + use_a); @@ -2047,7 +2047,7 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl) normalize_v3(vec_2); /* align the vector, can avoid this and it looks 98% OK but - * better to align the angle quat roll's before comparing */ + * better to align the angle quat roll's before comparing */ { cross_v3_v3v3(cross_tmp, bevp_last->dir, bevp_first->dir); angle = angle_normalized_v3v3(bevp_first->dir, bevp_last->dir); @@ -2216,7 +2216,7 @@ void BKE_curve_bevelList_make(Object *ob) /* check if we will calculate tilt data */ do_tilt = CU_DO_TILT(cu, nu); do_radius = CU_DO_RADIUS(cu, nu); /* normal display uses the radius, better just to calculate them */ - do_weight = 1; + do_weight = TRUE; /* 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 */ diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index 19e7eb9dce1..0396733760f 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -275,8 +275,8 @@ void defvert_flip_merged(MDeformVert *dvert, const int *flip_map, const int flip dw = &dvert->dw[i]; /* in case array got realloced */ /* distribute weights: if only one of the vertex groups was - * assigned this will halve the weights, otherwise it gets - * evened out. this keeps it proportional to other groups */ + * assigned this will halve the weights, otherwise it gets + * evened out. this keeps it proportional to other groups */ weight = 0.5f * (dw_cpy->weight + dw->weight); dw_cpy->weight = weight; dw->weight = weight; diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index c6f46a7309b..2b08c085417 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -718,7 +718,8 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O dag_add_relation(dag, scenenode, node, DAG_RL_SCENE, "Scene Relation"); } -struct DagForest *build_dag(Main *bmain, Scene *sce, short mask){ +DagForest *build_dag(Main *bmain, Scene *sce, short mask) +{ Base *base; Object *ob; Group *group; @@ -867,7 +868,7 @@ DagNode *dag_add_node(DagForest *forest, void *fob) } if (!forest->nodeHash) - forest->nodeHash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "dag_add_node gh"); + forest->nodeHash = BLI_ghash_ptr_new("dag_add_node gh"); BLI_ghash_insert(forest->nodeHash, fob, node); } @@ -1253,7 +1254,7 @@ DagNodeQueue *graph_dfs(void) int maxpos = 0; /* int is_cycle = 0; */ /* UNUSED */ /* - *fprintf(stderr, "starting DFS\n ------------\n"); + *fprintf(stderr, "starting DFS\n ------------\n"); */ nqueue = queue_create(DAGQUEUEALLOC); retqueue = queue_create(MainDag->numNodes); @@ -1458,7 +1459,8 @@ int pre_and_post_source_DFS(DagForest *dag, short mask, DagNode *source, graph_a // used to get the obs owning a datablock -struct DagNodeQueue *get_obparents(struct DagForest *dag, void *ob){ +DagNodeQueue *get_obparents(struct DagForest *dag, void *ob) +{ DagNode *node, *node1; DagNodeQueue *nqueue; DagAdjList *itA; @@ -1491,7 +1493,8 @@ struct DagNodeQueue *get_obparents(struct DagForest *dag, void *ob){ return nqueue; } -struct DagNodeQueue *get_first_ancestors(struct DagForest *dag, void *ob){ +DagNodeQueue *get_first_ancestors(struct DagForest *dag, void *ob) +{ DagNode *node, *node1; DagNodeQueue *nqueue; DagAdjList *itA; @@ -1519,7 +1522,8 @@ struct DagNodeQueue *get_first_ancestors(struct DagForest *dag, void *ob){ } // standard DFS list -struct DagNodeQueue *get_all_childs(struct DagForest *dag, void *ob){ +DagNodeQueue *get_all_childs(struct DagForest *dag, void *ob) +{ DagNode *node; DagNodeQueue *nqueue; DagNodeQueue *retqueue; @@ -2627,7 +2631,7 @@ void DAG_ids_flush_tagged(Main *bmain) ListBase *lbarray[MAX_LIBARRAY]; Scene *sce; unsigned int lay; - int a, do_flush = 0; + int a, do_flush = FALSE; dag_current_scene_layers(bmain, &sce, &lay); @@ -2647,7 +2651,7 @@ void DAG_ids_flush_tagged(Main *bmain) for (; id; id = id->next) { if (id->flag & (LIB_ID_RECALC | LIB_ID_RECALC_DATA)) { dag_id_flush_update(sce, id); - do_flush = 1; + do_flush = TRUE; } } } diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 9e4144f14d4..1926217f4af 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -752,7 +752,7 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, fl Curve *cu = ob->data; ListBase *nurb = BKE_curve_nurbs_get(cu); int numVerts = 0; - const int editmode = (!forRender && cu->editnurb); + const int editmode = (!forRender && (cu->editnurb || cu->editfont)); ModifierApplyFlag app_flag = 0; float (*originalVerts)[3] = NULL; float (*deformedVerts)[3] = NULL; @@ -793,9 +793,7 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, fl md->scene = scene; - if ((md->mode & required_mode) != required_mode) - continue; - if (mti->isDisabled && mti->isDisabled(md, forRender)) + if (!modifier_isEnabled(scene, md, required_mode)) continue; if (mti->type != eModifierTypeType_OnlyDeform) continue; @@ -867,7 +865,7 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba Curve *cu = ob->data; ListBase *nurb = BKE_curve_nurbs_get(cu); int required_mode = 0, totvert = 0; - int editmode = (!forRender && cu->editnurb); + int editmode = (!forRender && (cu->editnurb || cu->editfont)); DerivedMesh *dm = NULL, *ndm; float (*vertCos)[3] = NULL; int useCache = !forRender; @@ -899,9 +897,7 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba md->scene = scene; - if ((md->mode & required_mode) != required_mode) - continue; - if (mti->isDisabled && mti->isDisabled(md, forRender)) + if (!modifier_isEnabled(scene, md, required_mode)) continue; if (mti->type == eModifierTypeType_OnlyDeform || @@ -1095,7 +1091,7 @@ static void curve_calc_orcodm(Scene *scene, Object *ob, DerivedMesh *derivedFina ModifierData *pretessellatePoint; Curve *cu = ob->data; int required_mode; - int editmode = (!forRender && cu->editnurb); + int editmode = (!forRender && (cu->editnurb || cu->editfont)); DerivedMesh *ndm, *orcodm = NULL; const ModifierApplyFlag app_flag = forRender ? MOD_APPLY_RENDER : 0; @@ -1118,9 +1114,7 @@ static void curve_calc_orcodm(Scene *scene, Object *ob, DerivedMesh *derivedFina md->scene = scene; - if ((md->mode & required_mode) != required_mode) - continue; - if (mti->isDisabled && mti->isDisabled(md, forRender)) + if (!modifier_isEnabled(scene, md, required_mode)) continue; if (mti->type != eModifierTypeType_Constructive) continue; diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index bbd57a5478b..f8b8efdf7eb 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -140,7 +140,7 @@ typedef struct VolumeGrid { int *s_pos; /* (x*y*z) t_index begin id */ int *s_num; /* (x*y*z) number of t_index points */ int *t_index; /* actual surface point index, - access: (s_pos+s_num) */ + * access: (s_pos+s_num) */ } VolumeGrid; typedef struct Vec3f { @@ -192,7 +192,7 @@ typedef struct PaintUVPoint { unsigned int v1, v2, v3; /* vertex indexes */ unsigned int neighbour_pixel; /* If this pixel isn't uv mapped to any face, - but it's neighboring pixel is */ + * but it's neighboring pixel is */ short quad; } PaintUVPoint; @@ -205,9 +205,9 @@ typedef struct ImgSeqFormatData { #define ADJ_ON_MESH_EDGE (1 << 0) typedef struct PaintAdjData { - int *n_target; /* array of neighboring point indexes, - for single sample use (n_index+neigh_num) */ - int *n_index; /* index to start reading n_target for each point */ + int *n_target; /* array of neighboring point indexes, + * for single sample use (n_index + neigh_num) */ + int *n_index; /* index to start reading n_target for each point */ int *n_num; /* num of neighs for each point */ int *flags; /* vertex adjacency flags */ int total_targets; /* size of n_target */ @@ -259,7 +259,8 @@ int dynamicPaint_surfaceHasColorPreview(DynamicPaintSurface *surface) } /* get currently active surface (in user interface) */ -struct DynamicPaintSurface *get_activeSurface(DynamicPaintCanvasSettings *canvas){ +DynamicPaintSurface *get_activeSurface(DynamicPaintCanvasSettings *canvas) +{ DynamicPaintSurface *surface = canvas->surfaces.first; int i; @@ -275,12 +276,12 @@ struct DynamicPaintSurface *get_activeSurface(DynamicPaintCanvasSettings *canvas void dynamicPaint_resetPreview(DynamicPaintCanvasSettings *canvas) { DynamicPaintSurface *surface = canvas->surfaces.first; - int done = 0; + int done = FALSE; for (; surface; surface = surface->next) { if (!done && dynamicPaint_surfaceHasColorPreview(surface)) { surface->flags |= MOD_DPAINT_PREVIEW; - done = 1; + done = TRUE; } else surface->flags &= ~MOD_DPAINT_PREVIEW; @@ -574,16 +575,16 @@ static int surface_getBrushFlags(DynamicPaintSurface *surface, Scene *scene) brushObj = NULL; /* select object */ - if (surface->brush_group) { + if (surface->brush_group) { if (go->ob) brushObj = go->ob; - } - else + } + else brushObj = base->object; if (!brushObj) { if (surface->brush_group) go = go->next; else base = base->next; - continue; + continue; } if (surface->brush_group) @@ -993,7 +994,8 @@ void dynamicPaint_Modifier_free(struct DynamicPaintModifierData *pmd) * If scene is null, frame range of 1-250 is used * A pointer to this surface is returned */ -struct DynamicPaintSurface *dynamicPaint_createNewSurface(DynamicPaintCanvasSettings *canvas, Scene *scene){ +DynamicPaintSurface *dynamicPaint_createNewSurface(DynamicPaintCanvasSettings *canvas, Scene *scene) +{ DynamicPaintSurface *surface = MEM_callocN(sizeof(DynamicPaintSurface), "DynamicPaintSurface"); if (!surface) return NULL; @@ -1594,9 +1596,10 @@ static void dynamicPaint_applySurfaceDisplace(DynamicPaintSurface *surface, Deri /* * Apply canvas data to the object derived mesh */ -static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, - Object *ob, - DerivedMesh *dm){ +struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, + Object *ob, + DerivedMesh *dm) +{ DerivedMesh *result = CDDM_copy(dm); if (pmd->canvas && !(pmd->canvas->flags & MOD_DPAINT_BAKING)) { @@ -1901,7 +1904,8 @@ static void dynamicPaint_frameUpdate(DynamicPaintModifierData *pmd, Scene *scene } /* Modifier call. Processes dynamic paint modifier step. */ -struct DerivedMesh *dynamicPaint_Modifier_do(DynamicPaintModifierData *pmd, Scene *scene, Object *ob, DerivedMesh *dm){ +DerivedMesh *dynamicPaint_Modifier_do(DynamicPaintModifierData *pmd, Scene *scene, Object *ob, DerivedMesh *dm) +{ /* For now generate tessfaces in every case * XXX - move/remove when most of dpaint functions are converted to use bmesh types */ DM_ensure_tessface(dm); @@ -2540,8 +2544,8 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface) #if 0 /* ----------------------------------------------------------------- - * For debug, output pixel statuses to the color map - * -----------------------------------------------------------------*/ + * For debug, output pixel statuses to the color map + * -----------------------------------------------------------------*/ #pragma omp parallel for schedule(static) for (index = 0; index < sData->total_points; index++) { @@ -3293,7 +3297,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, int f_index = hit.index; /* Also cast a ray in opposite direction to make sure - * point is at least surrounded by two brush faces */ + * point is at least surrounded by two brush faces */ negate_v3(ray_dir); hit.index = -1; hit.dist = 9999; @@ -3565,7 +3569,7 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface, tree = BLI_kdtree_new(psys->totpart); /* loop through particles and insert valid ones to the tree */ - for (p = 0, pa = psys->particles; p < psys->totpart; p++, pa++) { + for (p = 0, pa = psys->particles; p < psys->totpart; p++, pa++) { /* Proceed only if particle is active */ if (pa->alive == PARS_UNBORN && (part->flag & PART_UNBORN) == 0) continue; @@ -4801,17 +4805,17 @@ static int dynamicPaint_doStep(Scene *scene, Object *ob, DynamicPaintSurface *su while (base || go) { brushObj = NULL; /* select object */ - if (surface->brush_group) { + if (surface->brush_group) { if (go->ob) brushObj = go->ob; - } - else + } + else brushObj = base->object; - if (!brushObj) { + if (!brushObj) { /* skip item */ if (surface->brush_group) go = go->next; else base = base->next; - continue; + continue; } /* next item */ diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c index 9606abbd7c0..f1000a95e95 100644 --- a/source/blender/blenkernel/intern/editderivedmesh.c +++ b/source/blender/blenkernel/intern/editderivedmesh.c @@ -980,9 +980,9 @@ static void emDM_drawMappedFacesGLSL(DerivedMesh *dm, DMVertexAttribs attribs; GPUVertexAttribs gattribs; - int i, b, matnr, new_matnr, dodraw; + int i, b, matnr, new_matnr, do_draw; - dodraw = 0; + do_draw = FALSE; matnr = -1; memset(&attribs, 0, sizeof(attribs)); @@ -1012,7 +1012,7 @@ static void emDM_drawMappedFacesGLSL(DerivedMesh *dm, float *tang = attribs.tang.array[i * 4 + vert]; \ glVertexAttrib3fvARB(attribs.tang.gl_index, tang); \ } \ -} + } (void)0 for (i = 0, ltri = em->looptris[0]; i < em->tottri; i++, ltri += 3) { @@ -1026,12 +1026,12 @@ static void emDM_drawMappedFacesGLSL(DerivedMesh *dm, new_matnr = efa->mat_nr + 1; if (new_matnr != matnr) { - dodraw = setMaterial(matnr = new_matnr, &gattribs); - if (dodraw) + do_draw = setMaterial(matnr = new_matnr, &gattribs); + if (do_draw) DM_vertex_attributes_from_gpu(dm, &gattribs, &attribs); } - if (dodraw) { + if (do_draw) { glBegin(GL_TRIANGLES); if (!drawSmooth) { if (vertexCos) glNormal3fv(bmdm->polyNos[BM_elem_index_get(efa)]); @@ -1141,7 +1141,7 @@ static void emDM_drawMappedFacesMat(DerivedMesh *dm, float *tang = attribs.tang.array[i * 4 + vert]; \ glVertexAttrib4fvARB(attribs.tang.gl_index, tang); \ } \ -} + } (void)0 for (i = 0, ltri = em->looptris[0]; i < em->tottri; i++, ltri += 3) { int drawSmooth; diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 9d878cd185f..2a0f49262bc 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -505,7 +505,7 @@ void calc_fcurve_bounds(FCurve *fcu, float *xmin, float *xmax, float *ymin, floa BezTriple *bezt; for (bezt = fcu->bezt, i = 0; i < fcu->totvert; bezt++, i++) { - if ((do_sel_only == 0) || BEZSELECTED(bezt)) { + if ((do_sel_only == FALSE) || BEZSELECTED(bezt)) { if (bezt->vec[1][1] < yminv) yminv = bezt->vec[1][1]; if (bezt->vec[1][1] > ymaxv) @@ -1241,7 +1241,7 @@ static float dvar_eval_transChan(ChannelDriver *driver, DriverVar *dvar) bPoseChannel *pchan; float mat[4][4]; float oldEul[3] = {0.0f, 0.0f, 0.0f}; - short useEulers = 0, rotOrder = ROT_MODE_EUL; + short use_eulers = FALSE, rot_order = ROT_MODE_EUL; /* check if this target has valid data */ if ((ob == NULL) || (GS(ob->id.name) != ID_OB)) { @@ -1263,8 +1263,8 @@ static float dvar_eval_transChan(ChannelDriver *driver, DriverVar *dvar) /* bone */ if (pchan->rotmode > 0) { copy_v3_v3(oldEul, pchan->eul); - rotOrder = pchan->rotmode; - useEulers = 1; + rot_order = pchan->rotmode; + use_eulers = TRUE; } if (dtar->flag & DTAR_FLAG_LOCALSPACE) { @@ -1290,8 +1290,8 @@ static float dvar_eval_transChan(ChannelDriver *driver, DriverVar *dvar) /* object */ if (ob->rotmode > 0) { copy_v3_v3(oldEul, ob->rot); - rotOrder = ob->rotmode; - useEulers = 1; + rot_order = ob->rotmode; + use_eulers = TRUE; } if (dtar->flag & DTAR_FLAG_LOCALSPACE) { @@ -1334,9 +1334,9 @@ static float dvar_eval_transChan(ChannelDriver *driver, DriverVar *dvar) */ float eul[3]; - mat4_to_eulO(eul, rotOrder, mat); + mat4_to_eulO(eul, rot_order, mat); - if (useEulers) { + if (use_eulers) { compatible_eul(eul, oldEul); } diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index fda078f5c42..87e35bc2747 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -520,7 +520,8 @@ static float char_width(Curve *cu, VChar *che, CharInfo *info) } } -struct chartrans *BKE_vfont_to_curve(Main *bmain, Scene *scene, Object *ob, int mode){ +struct chartrans *BKE_vfont_to_curve(Main *bmain, Scene *scene, Object *ob, int mode) +{ VFont *vfont, *oldvfont; VFontData *vfd = NULL; Curve *cu; @@ -633,7 +634,7 @@ makebreak: * But if the font is FO_BUILTIN_NAME then do not try loading since * whole font is in the memory already */ - if (che == NULL && strcmp(vfont->name, FO_BUILTIN_NAME)) { + if (che == NULL && strcmp(vfont->name, FO_BUILTIN_NAME)) { BLI_vfontchar_from_freetypefont(vfont, ascii); } diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c index bfbd89870df..fbaca6677d7 100644 --- a/source/blender/blenkernel/intern/group.c +++ b/source/blender/blenkernel/intern/group.c @@ -300,7 +300,7 @@ static void group_replaces_nla(Object *parent, Object *target, char mode) { static ListBase nlastrips = {NULL, NULL}; static bAction *action = NULL; - static int done = 0; + static int done = FALSE; bActionStrip *strip, *nstrip; if (mode == 's') { @@ -314,7 +314,7 @@ static void group_replaces_nla(Object *parent, Object *target, char mode) action = target->action; target->action = NULL; target->nlaflag |= OB_NLA_OVERRIDE; - done = 1; + done = TRUE; } nstrip = MEM_dupallocN(strip); BLI_addtail(&target->nlastrips, nstrip); @@ -329,7 +329,7 @@ static void group_replaces_nla(Object *parent, Object *target, char mode) nlastrips.first = nlastrips.last = NULL; /* not needed, but yah... :) */ action = NULL; - done = 0; + done = FALSE; } } } diff --git a/source/blender/blenkernel/intern/icons.c b/source/blender/blenkernel/intern/icons.c index edde21ed7c8..8a49cba7649 100644 --- a/source/blender/blenkernel/intern/icons.c +++ b/source/blender/blenkernel/intern/icons.c @@ -51,11 +51,9 @@ #include "BLO_sys_types.h" // for intptr_t support -#define GS(a) (*((short *)(a))) - /* GLOBALS */ -static GHash* gIcons = NULL; +static GHash *gIcons = NULL; static int gNextIconId = 1; @@ -64,7 +62,7 @@ static int gFirstIconId = 1; static void icon_free(void *val) { - Icon* icon = val; + Icon *icon = val; if (icon) { if (icon->drawinfo_free) { @@ -84,15 +82,15 @@ static int get_next_free_id(void) int startId = gFirstIconId; /* if we haven't used up the int number range, we just return the next int */ - if (gNextIconId>=gFirstIconId) + if (gNextIconId >= gFirstIconId) return gNextIconId++; /* now we try to find the smallest icon id not stored in the gIcons hash */ - while (BLI_ghash_lookup(gIcons, SET_INT_IN_POINTER(startId)) && startId>=gFirstIconId) + while (BLI_ghash_lookup(gIcons, SET_INT_IN_POINTER(startId)) && startId >= gFirstIconId) startId++; /* if we found a suitable one that isn't used yet, return it */ - if (startId>=gFirstIconId) + if (startId >= gFirstIconId) return startId; /* fail */ @@ -105,7 +103,7 @@ void BKE_icons_init(int first_dyn_id) gFirstIconId = first_dyn_id; if (!gIcons) - gIcons = BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "icons_init gh"); + gIcons = BLI_ghash_int_new("icons_init gh"); } void BKE_icons_free(void) @@ -115,14 +113,14 @@ void BKE_icons_free(void) gIcons = NULL; } -struct PreviewImage* BKE_previewimg_create(void) +PreviewImage *BKE_previewimg_create(void) { - PreviewImage* prv_img = NULL; + PreviewImage *prv_img = NULL; int i; prv_img = MEM_callocN(sizeof(PreviewImage), "img_prv"); - for (i=0; i<NUM_ICON_SIZES; ++i) { + for (i = 0; i < NUM_ICON_SIZES; ++i) { prv_img->changed[i] = 1; prv_img->changed_timestamp[i] = 0; } @@ -135,7 +133,7 @@ void BKE_previewimg_freefunc(void *link) if (prv) { int i; - for (i=0; i<NUM_ICON_SIZES;++i) { + for (i = 0; i < NUM_ICON_SIZES; ++i) { if (prv->rect[i]) { MEM_freeN(prv->rect[i]); prv->rect[i] = NULL; @@ -153,14 +151,14 @@ void BKE_previewimg_free(PreviewImage **prv) } } -struct PreviewImage* BKE_previewimg_copy(PreviewImage *prv) +PreviewImage *BKE_previewimg_copy(PreviewImage *prv) { - PreviewImage* prv_img = NULL; + PreviewImage *prv_img = NULL; int i; if (prv) { prv_img = MEM_dupallocN(prv); - for (i=0; i < NUM_ICON_SIZES; ++i) { + for (i = 0; i < NUM_ICON_SIZES; ++i) { if (prv->rect[i]) { prv_img->rect[i] = MEM_dupallocN(prv->rect[i]); } @@ -175,62 +173,62 @@ struct PreviewImage* BKE_previewimg_copy(PreviewImage *prv) void BKE_previewimg_free_id(ID *id) { if (GS(id->name) == ID_MA) { - Material *mat = (Material*)id; + Material *mat = (Material *)id; BKE_previewimg_free(&mat->preview); } else if (GS(id->name) == ID_TE) { - Tex *tex = (Tex*)id; + Tex *tex = (Tex *)id; BKE_previewimg_free(&tex->preview); } else if (GS(id->name) == ID_WO) { - World *wo = (World*)id; + World *wo = (World *)id; BKE_previewimg_free(&wo->preview); } else if (GS(id->name) == ID_LA) { - Lamp *la = (Lamp*)id; + Lamp *la = (Lamp *)id; BKE_previewimg_free(&la->preview); } else if (GS(id->name) == ID_IM) { - Image *img = (Image*)id; + Image *img = (Image *)id; BKE_previewimg_free(&img->preview); } else if (GS(id->name) == ID_BR) { - Brush *br = (Brush*)id; + Brush *br = (Brush *)id; BKE_previewimg_free(&br->preview); } } -PreviewImage* BKE_previewimg_get(ID *id) +PreviewImage *BKE_previewimg_get(ID *id) { - PreviewImage* prv_img = NULL; + PreviewImage *prv_img = NULL; if (GS(id->name) == ID_MA) { - Material *mat = (Material*)id; + Material *mat = (Material *)id; if (!mat->preview) mat->preview = BKE_previewimg_create(); prv_img = mat->preview; } else if (GS(id->name) == ID_TE) { - Tex *tex = (Tex*)id; + Tex *tex = (Tex *)id; if (!tex->preview) tex->preview = BKE_previewimg_create(); prv_img = tex->preview; } else if (GS(id->name) == ID_WO) { - World *wo = (World*)id; + World *wo = (World *)id; if (!wo->preview) wo->preview = BKE_previewimg_create(); prv_img = wo->preview; } else if (GS(id->name) == ID_LA) { - Lamp *la = (Lamp*)id; + Lamp *la = (Lamp *)id; if (!la->preview) la->preview = BKE_previewimg_create(); prv_img = la->preview; } else if (GS(id->name) == ID_IM) { - Image *img = (Image*)id; + Image *img = (Image *)id; if (!img->preview) img->preview = BKE_previewimg_create(); prv_img = img->preview; } else if (GS(id->name) == ID_BR) { - Brush *br = (Brush*)id; + Brush *br = (Brush *)id; if (!br->preview) br->preview = BKE_previewimg_create(); prv_img = br->preview; } @@ -240,19 +238,19 @@ PreviewImage* BKE_previewimg_get(ID *id) void BKE_icon_changed(int id) { - Icon* icon = NULL; + Icon *icon = NULL; if (!id || G.background) return; icon = BLI_ghash_lookup(gIcons, SET_INT_IN_POINTER(id)); if (icon) { - PreviewImage *prv = BKE_previewimg_get((ID*)icon->obj); + PreviewImage *prv = BKE_previewimg_get((ID *)icon->obj); /* all previews changed */ if (prv) { int i; - for (i=0; i<NUM_ICON_SIZES; ++i) { + for (i = 0; i < NUM_ICON_SIZES; ++i) { prv->changed[i] = 1; prv->changed_timestamp[i]++; } @@ -260,9 +258,9 @@ void BKE_icon_changed(int id) } } -int BKE_icon_getid(struct ID* id) +int BKE_icon_getid(struct ID *id) { - Icon* new_icon = NULL; + Icon *new_icon = NULL; if (!id || G.background) return 0; @@ -291,9 +289,9 @@ int BKE_icon_getid(struct ID* id) return id->icon_id; } -Icon* BKE_icon_get(int icon_id) +Icon *BKE_icon_get(int icon_id) { - Icon* icon = NULL; + Icon *icon = NULL; icon = BLI_ghash_lookup(gIcons, SET_INT_IN_POINTER(icon_id)); @@ -305,9 +303,9 @@ Icon* BKE_icon_get(int icon_id) return icon; } -void BKE_icon_set(int icon_id, struct Icon* icon) +void BKE_icon_set(int icon_id, struct Icon *icon) { - Icon* old_icon = NULL; + Icon *old_icon = NULL; old_icon = BLI_ghash_lookup(gIcons, SET_INT_IN_POINTER(icon_id)); @@ -319,10 +317,10 @@ void BKE_icon_set(int icon_id, struct Icon* icon) BLI_ghash_insert(gIcons, SET_INT_IN_POINTER(icon_id), icon); } -void BKE_icon_delete(struct ID* id) +void BKE_icon_delete(struct ID *id) { - if (!id->icon_id) return; /* no icon defined for library object */ + if (!id->icon_id) return; /* no icon defined for library object */ BLI_ghash_remove(gIcons, SET_INT_IN_POINTER(id->icon_id), NULL, icon_free); id->icon_id = 0; diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index e3735cfd374..42c7869a365 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -299,7 +299,8 @@ static IDProperty *IDP_CopyArray(IDProperty *prop) s_i = p_i[0]; p_i[0] = p_i[7]; p_i[7] = s_i; \ s_i = p_i[1]; p_i[1] = p_i[6]; p_i[6] = s_i; \ s_i = p_i[2]; p_i[2] = p_i[5]; p_i[5] = s_i; \ - s_i = p_i[3]; p_i[3] = p_i[4]; p_i[4] = s_i; } + s_i = p_i[3]; p_i[3] = p_i[4]; p_i[4] = s_i; \ + } (void)0 diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 1a88c50fdbf..c1c1c5d9682 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -505,6 +505,20 @@ void BKE_image_merge(Image *dest, Image *source) } } +/* note, we could be clever and scale all imbuf's but since some are mipmaps its not so simple */ +void BKE_image_scale(Image *image, int width, int height) +{ + ImBuf *ibuf; + void *lock; + + ibuf = BKE_image_acquire_ibuf(image, NULL, &lock); + + IMB_scaleImBuf(ibuf, width, height); + ibuf->userflags |= IB_BITMAPDIRTY; + + BKE_image_release_ibuf(image, lock); +} + Image *BKE_image_load(const char *filepath) { Image *ima; @@ -1729,7 +1743,8 @@ void BKE_makepicstring(char *string, const char *base, const char *relbase, int } /* used by sequencer too */ -struct anim *openanim(const char *name, int flags, int streamindex){ +struct anim *openanim(const char *name, int flags, int streamindex) +{ struct anim *anim; struct ImBuf *ibuf; @@ -2177,7 +2192,8 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra) flag = IB_rect | IB_multilayer; if (ima->flag & IMA_DO_PREMUL) flag |= IB_premul; - ibuf = IMB_ibImageFromMemory((unsigned char *)ima->packedfile->data, ima->packedfile->size, flag, "<packed data>"); + ibuf = IMB_ibImageFromMemory((unsigned char *)ima->packedfile->data, + ima->packedfile->size, flag, "<packed data>"); } else { flag = IB_rect | IB_multilayer | IB_metadata; diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 6a69ffb474a..025ea40e82b 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -658,13 +658,15 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target, */ if (target && target->type == OB_MESH) { /* if there's derived data without deformverts, don't use vgroups */ - if (dm && !dm->getVertData(dm, 0, CD_MDEFORMVERT)) - use_vgroups = 0; - else - use_vgroups = 1; + if (dm) { + use_vgroups = (dm->getVertData(dm, 0, CD_MDEFORMVERT) != NULL); + } + else { + use_vgroups = FALSE; + } } else { - use_vgroups = 0; + use_vgroups = FALSE; } if (vgroup && vgroup[0] && use_vgroups) { @@ -801,13 +803,15 @@ void lattice_deform_verts(Object *laOb, Object *target, DerivedMesh *dm, */ if (target && target->type == OB_MESH) { /* if there's derived data without deformverts, don't use vgroups */ - if (dm && !dm->getVertData(dm, 0, CD_MDEFORMVERT)) - use_vgroups = 0; - else - use_vgroups = 1; + if (dm) { + use_vgroups = (dm->getVertData(dm, 0, CD_MDEFORMVERT) != NULL); + } + else { + use_vgroups = FALSE; + } } else { - use_vgroups = 0; + use_vgroups = FALSE; } if (vgroup && vgroup[0] && use_vgroups) { diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 7da0661fef6..bef5f2e18a3 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -351,7 +351,7 @@ void BKE_mball_texspace_calc(Object *ob) DispList *dl; BoundBox *bb; float *data, min[3], max[3] /*, loc[3], size[3] */; - int tot, doit = 0; + int tot, do_it = FALSE; if (ob->bb == NULL) ob->bb = MEM_callocN(sizeof(BoundBox), "mb boundbox"); bb = ob->bb; @@ -364,7 +364,7 @@ void BKE_mball_texspace_calc(Object *ob) dl = ob->disp.first; while (dl) { tot = dl->nr; - if (tot) doit = 1; + if (tot) do_it = TRUE; data = dl->verts; while (tot--) { /* Also weird... but longer. From utildefines. */ @@ -374,7 +374,7 @@ void BKE_mball_texspace_calc(Object *ob) dl = dl->next; } - if (!doit) { + if (!do_it) { min[0] = min[1] = min[2] = -1.0f; max[0] = max[1] = max[2] = 1.0f; } @@ -1135,11 +1135,11 @@ static int otherface(int edge, int face) static void makecubetable(void) { - static int isdone = 0; + static int is_done = FALSE; int i, e, c, done[12], pos[8]; - if (isdone) return; - isdone = 1; + if (is_done) return; + is_done = TRUE; for (i = 0; i < 256; i++) { for (e = 0; e < 12; e++) done[e] = 0; diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index e6e67fe7a16..573e2443dc0 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -2092,8 +2092,9 @@ 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++; \ + } (void)0 ML(v1, v2); ML(v2, v3); @@ -2287,21 +2288,39 @@ void create_vert_poly_map(MeshElemMap **map, int **mem, /* Generates a map where the key is the vertex and the value is a list * of edges that use that vertex as an endpoint. The lists are allocated * from one memory pool. */ -void create_vert_edge_map(ListBase **map, IndexNode **mem, const MEdge *medge, const int totvert, const int totedge) +void create_vert_edge_map(MeshElemMap **map, int **mem, + const MEdge *medge, int totvert, int totedge) { - int i, j; - IndexNode *node = NULL; - - (*map) = MEM_callocN(sizeof(ListBase) * totvert, "vert edge map"); - (*mem) = MEM_callocN(sizeof(IndexNode) * totedge * 2, "vert edge map mem"); - node = *mem; + int i, *indices; + + (*map) = MEM_callocN(sizeof(MeshElemMap) * totvert, "vert-edge map"); + (*mem) = MEM_mallocN(sizeof(int) * totedge * 2, "vert-edge map mem"); + + /* Count number of edges for each vertex */ + for (i = 0; i < totedge; i++) { + (*map)[medge[i].v1].count++; + (*map)[medge[i].v2].count++; + } + + /* Assign indices mem */ + indices = (*mem); + for (i = 0; i < totvert; i++) { + (*map)[i].indices = indices; + indices += (*map)[i].count; + /* Reset 'count' for use as index in last loop */ + (*map)[i].count = 0; + } + /* Find the users */ - for (i = 0; i < totedge; ++i) { - for (j = 0; j < 2; ++j, ++node) { - node->index = i; - BLI_addtail(&(*map)[((unsigned int *)(&medge[i].v1))[j]], node); - } + for (i = 0; i < totedge; i++) { + const int v[2] = {medge[i].v1, medge[i].v2}; + + (*map)[v[0]].indices[(*map)[v[0]].count] = i; + (*map)[v[1]].indices[(*map)[v[1]].count] = i; + + (*map)[v[0]].count++; + (*map)[v[1]].count++; } } diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 2159837c9a0..b4c30203000 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -250,8 +250,7 @@ int modifier_couldBeCage(struct Scene *scene, ModifierData *md) int modifier_sameTopology(ModifierData *md) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); - return ELEM3(mti->type, eModifierTypeType_OnlyDeform, eModifierTypeType_Nonconstructive, - eModifierTypeType_NonGeometrical); + return ELEM(mti->type, eModifierTypeType_OnlyDeform, eModifierTypeType_NonGeometrical); } int modifier_nonGeometrical(ModifierData *md) diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 724d80afdd9..4e8b67bd55b 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -600,7 +600,7 @@ static void multires_copy_dm_grid(CCGElem *gridA, CCGElem *gridB, CCGKey *keyA, } /* Reallocate gpm->data at a lower resolution and copy values over - from the original high-resolution data */ + * from the original high-resolution data */ static void multires_grid_paint_mask_downsample(GridPaintMask *gpm, int level) { if (level < gpm->level) { @@ -1056,12 +1056,10 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm dispgrid = mdisp->disps; /* if needed, reallocate multires paint mask */ - if (gpm && op == CALC_DISPLACEMENTS) { - if (gpm->level < key.level) { - gpm->level = key.level; - MEM_freeN(gpm->data); - gpm->data = MEM_callocN(sizeof(float) * key.grid_area, "gpm.data"); - } + if (gpm && gpm->level < key.level) { + gpm->level = key.level; + MEM_freeN(gpm->data); + gpm->data = MEM_callocN(sizeof(float) * key.grid_area, "gpm.data"); } for (y = 0; y < gridSize; y++) { @@ -1094,7 +1092,7 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm break; case CALC_DISPLACEMENTS: /* Calculate displacement between new and old - * grid points and convert to tangent space */ + * grid points and convert to tangent space */ sub_v3_v3v3(disp, co, sco); invert_m3(mat); mul_v3_m3v3(data, mat, disp); @@ -1483,7 +1481,7 @@ DerivedMesh *multires_make_derived_from_derived(DerivedMesh *dm, } /**** Old Multires code **** -***************************/ + ***************************/ /* Adapted from sculptmode.c */ void old_mdisps_bilinear(float out[3], float (*disps)[3], const int st, float u, float v) diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 02d44badc65..2b4fe72e8bb 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -1304,7 +1304,7 @@ void BKE_nlastrip_validate_name(AnimData *adt, NlaStrip *strip) * - this is easier than iterating over all the tracks+strips hierarchy everytime * (and probably faster) */ - gh = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "nlastrip_validate_name gh"); + gh = BLI_ghash_str_new("nlastrip_validate_name gh"); for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) { for (tstrip = nlt->strips.first; tstrip; tstrip = tstrip->next) { diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index a25cd0d3b38..8771e8de67e 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -1392,7 +1392,7 @@ static int node_get_deplist_recurs(bNode *node, bNode ***nsort) bNodeSocket *sock; int level = 0xFFF; - node->done= 1; + node->done = TRUE; /* check linked nodes */ for (sock= node->inputs.first; sock; sock= sock->next) { @@ -1431,7 +1431,7 @@ void ntreeGetDependencyList(struct bNodeTree *ntree, struct bNode ***deplist, in /* first clear data */ for (node= ntree->nodes.first; node; node= node->next) { - node->done= 0; + node->done = FALSE; (*totnodes)++; } if (*totnodes==0) { @@ -1456,7 +1456,7 @@ static void ntree_update_node_level(bNodeTree *ntree) /* first clear tag */ for (node= ntree->nodes.first; node; node= node->next) { - node->done= 0; + node->done = FALSE; } /* recursive check */ @@ -1930,6 +1930,13 @@ static void registerCompositNodes(bNodeTreeType *ttype) register_node_type_cmp_transform(ttype); register_node_type_cmp_stabilize2d(ttype); register_node_type_cmp_moviedistortion(ttype); + + register_node_type_cmp_colorcorrection(ttype); + register_node_type_cmp_boxmask(ttype); + register_node_type_cmp_ellipsemask(ttype); + register_node_type_cmp_bokehimage(ttype); + register_node_type_cmp_bokehblur(ttype); + register_node_type_cmp_switch(ttype); } static void registerShaderNodes(bNodeTreeType *ttype) diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 2ea832eebaa..9000019ca2a 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -3020,6 +3020,19 @@ int BKE_object_is_deform_modified(Scene *scene, Object *ob) return flag; } +/* See if an object is using an animated modifier */ +int BKE_object_is_animated(Scene *scene, Object *ob) +{ + ModifierData *md; + + for (md = modifiers_getVirtualModifierList(ob); md; md = md->next) + if(modifier_dependsOnTime(md) && + (modifier_isEnabled(scene, md, eModifierMode_Realtime) || + modifier_isEnabled(scene, md, eModifierMode_Render))) + return 1; + return 0; +} + static void copy_object__forwardModifierLinks(void *UNUSED(userData), Object *UNUSED(ob), ID **idpoin) { /* this is copied from ID_NEW; it might be better to have a macro */ diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c index b2096ca97d4..e76cde652c8 100644 --- a/source/blender/blenkernel/intern/ocean.c +++ b/source/blender/blenkernel/intern/ocean.c @@ -735,7 +735,8 @@ static void set_height_normalize_factor(struct Ocean *oc) oc->normalize_factor = res; } -struct Ocean *BKE_add_ocean(void){ +struct Ocean *BKE_add_ocean(void) +{ Ocean *oc = MEM_callocN(sizeof(Ocean), "ocean sim data"); BLI_rw_mutex_init(&oc->oceanmutex); @@ -1079,7 +1080,8 @@ void BKE_ocean_cache_eval_ij(struct OceanCache *och, struct OceanResult *ocr, in struct OceanCache *BKE_init_ocean_cache(const char *bakepath, const char *relbase, int start, int end, float wave_scale, - float chop_amount, float foam_coverage, float foam_fade, int resolution){ + float chop_amount, float foam_coverage, float foam_fade, int resolution) +{ OceanCache *och = MEM_callocN(sizeof(OceanCache), "ocean cache data"); och->bakepath = bakepath; @@ -1360,9 +1362,10 @@ void BKE_ocean_cache_eval_ij(struct OceanCache *UNUSED(och), struct OceanResult { } -struct OceanCache *BKE_init_ocean_cache(const char *UNUSED(bakepath), const char *UNUSED(relbase), +OceanCache *BKE_init_ocean_cache(const char *UNUSED(bakepath), const char *UNUSED(relbase), int UNUSED(start), int UNUSED(end), float UNUSED(wave_scale), - float UNUSED(chop_amount), float UNUSED(foam_coverage), float UNUSED(foam_fade), int UNUSED(resolution)){ + float UNUSED(chop_amount), float UNUSED(foam_coverage), float UNUSED(foam_fade), int UNUSED(resolution)) +{ OceanCache *och = MEM_callocN(sizeof(OceanCache), "ocean cache data"); return och; diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 8676a3e75a0..4ca9f9c281b 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -614,7 +614,7 @@ typedef struct ParticleRenderData { float viewmat[4][4], winmat[4][4]; int winx, winy; - int dosimplify; + int do_simplify; int timeoffset; ParticleRenderElem *elems; int *origindex; @@ -821,7 +821,7 @@ int psys_render_simplify_distribution(ParticleThreadContext *ctx, int tot) if (data->elems) MEM_freeN(data->elems); - data->dosimplify = 1; + data->do_simplify = TRUE; data->elems = elems; data->origindex = origindex; @@ -960,7 +960,7 @@ int psys_render_simplify_params(ParticleSystem *psys, ChildParticle *cpa, float return 0; data = psys->renderdata; - if (!data->dosimplify) + if (!data->do_simplify) return 0; b = (data->origindex) ? data->origindex[cpa->num] : cpa->num; diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index cd1561734cc..5397b1729f9 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -241,10 +241,10 @@ static void realloc_particles(ParticleSimulationData *sim, int new_totpart) } if (psys->particles) { - totsaved=MIN2(psys->totpart, totpart); + totsaved=MIN2(psys->totpart,totpart); /*save old pars*/ if (totsaved) { - memcpy(newpars, psys->particles, totsaved*sizeof(ParticleData)); + memcpy(newpars,psys->particles,totsaved*sizeof(ParticleData)); if (psys->particles->boid) memcpy(newboids, psys->particles->boid, totsaved*sizeof(BoidParticle)); @@ -418,7 +418,7 @@ static void distribute_simple_children(Scene *scene, Object *ob, DerivedMesh *fi cpa = psys->child; for (i=0; i<child_nbr; i++) { - for (p=0; p<psys->totpart; p++, cpa++) { + for (p=0; p<psys->totpart; p++,cpa++) { float length=2.0; cpa->parent=p; @@ -440,7 +440,7 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys) { ParticleData *pa=NULL; float min[3], max[3], delta[3], d; - MVert *mv, *mvert = dm->getVertDataArray(dm, 0); + MVert *mv, *mvert = dm->getVertDataArray(dm,0); int totvert=dm->getNumVerts(dm), from=psys->part->from; int i, j, k, p, res=psys->part->grid_res, size[3], axis; @@ -452,13 +452,13 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys) mv++; for (i=1; i<totvert; i++, mv++) { - min[0]=MIN2(min[0], mv->co[0]); - min[1]=MIN2(min[1], mv->co[1]); - min[2]=MIN2(min[2], mv->co[2]); + min[0]=MIN2(min[0],mv->co[0]); + min[1]=MIN2(min[1],mv->co[1]); + min[2]=MIN2(min[2],mv->co[2]); - max[0]=MAX2(max[0], mv->co[0]); - max[1]=MAX2(max[1], mv->co[1]); - max[2]=MAX2(max[2], mv->co[2]); + max[0]=MAX2(max[0],mv->co[0]); + max[1]=MAX2(max[1],mv->co[1]); + max[2]=MAX2(max[2],mv->co[2]); } sub_v3_v3v3(delta, max, min); @@ -473,8 +473,8 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys) size[(axis+2)%3] = (int)ceil(delta[(axis+2)%3]/d); /* float errors grrr.. */ - size[(axis+1)%3] = MIN2(size[(axis+1)%3], res); - size[(axis+2)%3] = MIN2(size[(axis+2)%3], res); + size[(axis+1)%3] = MIN2(size[(axis+1)%3],res); + size[(axis+2)%3] = MIN2(size[(axis+2)%3],res); size[0] = MAX2(size[0], 1); size[1] = MAX2(size[1], 1); @@ -485,9 +485,9 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys) min[1]+= d < delta[1] ? d/2.f : delta[1]/2.f; min[2]+= d < delta[2] ? d/2.f : delta[2]/2.f; - for (i=0, p=0, pa=psys->particles; i<res; i++) { + for (i=0,p=0,pa=psys->particles; i<res; i++) { for (j=0; j<res; j++) { - for (k=0; k<res; k++, p++, pa++) { + for (k=0; k<res; k++,p++,pa++) { pa->fuv[0] = min[0] + (float)i*d; pa->fuv[1] = min[1] + (float)j*d; pa->fuv[2] = min[2] + (float)k*d; @@ -507,8 +507,8 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys) min[1] -= d/2.0f; min[2] -= d/2.0f; - for (i=0, mv=mvert; i<totvert; i++, mv++) { - sub_v3_v3v3(vec, mv->co, min); + for (i=0,mv=mvert; i<totvert; i++,mv++) { + sub_v3_v3v3(vec,mv->co,min); vec[0]/=delta[0]; vec[1]/=delta[1]; vec[2]/=delta[2]; @@ -517,7 +517,7 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys) (int)(vec[2] * (size[2] - 1)))->flag &= ~PARS_UNEXIST; } } - else if (ELEM(from, PART_FROM_FACE, PART_FROM_VOLUME)) { + else if (ELEM(from,PART_FROM_FACE,PART_FROM_VOLUME)) { float co1[3], co2[3]; MFace *mface= NULL, *mface_array; @@ -526,7 +526,7 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys) int amax= from==PART_FROM_FACE ? 3 : 1; totface=dm->getNumTessFaces(dm); - mface=mface_array=dm->getTessFaceDataArray(dm, CD_MFACE); + mface=mface_array=dm->getTessFaceDataArray(dm,CD_MFACE); for (a=0; a<amax; a++) { if (a==0) { a0mul=res*res; a1mul=res; a2mul=1; } @@ -545,7 +545,7 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys) co1[a] -= 0.001f*d; /* lets intersect the faces */ - for (i=0; i<totface; i++, mface++) { + for (i=0; i<totface; i++,mface++) { copy_v3_v3(v1, mvert[mface->v1].co); copy_v3_v3(v2, mvert[mface->v2].co); copy_v3_v3(v3, mvert[mface->v3].co); @@ -586,9 +586,9 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys) } if (psys->part->flag & PART_GRID_HEXAGONAL) { - for (i=0, p=0, pa=psys->particles; i<res; i++) { + for (i=0,p=0,pa=psys->particles; i<res; i++) { for (j=0; j<res; j++) { - for (k=0; k<res; k++, p++, pa++) { + for (k=0; k<res; k++,p++,pa++) { if (j%2) pa->fuv[0] += d/2.f; @@ -614,7 +614,7 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys) if (psys->part->grid_rand > 0.f) { float rfac = d * psys->part->grid_rand; - for (p=0, pa=psys->particles; p<psys->totpart; p++, pa++) { + for (p=0,pa=psys->particles; p<psys->totpart; p++,pa++) { if (pa->flag & PARS_UNEXIST) continue; @@ -708,10 +708,10 @@ static void psys_uv_to_w(float u, float v, int quad, float *w) if (quad) { vert[3][0]= 0.0f; vert[3][1]= 1.0f; vert[3][2]= 0.0f; - interp_weights_poly_v3(w, vert, 4, co); + interp_weights_poly_v3( w,vert, 4, co); } else { - interp_weights_poly_v3(w, vert, 3, co); + interp_weights_poly_v3( w,vert, 3, co); w[3]= 0.0f; } } @@ -771,9 +771,9 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch KDTreeNearest ptn[3]; int w, maxw; - psys_particle_on_dm(ctx->dm, from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, co1, 0, 0, 0, orco1, 0); + psys_particle_on_dm(ctx->dm,from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,co1,0,0,0,orco1,0); BKE_mesh_orco_verts_transform((Mesh*)ob->data, &orco1, 1, 1); - maxw = BLI_kdtree_find_n_nearest(ctx->tree, 3, orco1, NULL, ptn); + maxw = BLI_kdtree_find_n_nearest(ctx->tree,3,orco1,NULL,ptn); for (w=0; w<maxw; w++) { pa->verts[w]=ptn->num; @@ -785,7 +785,7 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch MFace *mface; pa->num = i = ctx->index[p]; - mface = dm->getTessFaceData(dm, i, CD_MFACE); + mface = dm->getTessFaceData(dm,i,CD_MFACE); switch (distr) { case PART_DISTR_JIT: @@ -796,7 +796,7 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch psys_uv_to_w(0.33333f, 0.33333f, mface->v4, pa->fuv); } else { - ctx->jitoff[i] = fmod(ctx->jitoff[i], (float)ctx->jitlevel); + ctx->jitoff[i] = fmod(ctx->jitoff[i],(float)ctx->jitlevel); psys_uv_to_w(ctx->jit[2*(int)ctx->jitoff[i]], ctx->jit[2*(int)ctx->jitoff[i]+1], mface->v4, pa->fuv); ctx->jitoff[i]++; } @@ -813,21 +813,21 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch /* experimental */ if (from==PART_FROM_VOLUME) { - MVert *mvert=dm->getVertDataArray(dm, CD_MVERT); + MVert *mvert=dm->getVertDataArray(dm,CD_MVERT); tot=dm->getNumTessFaces(dm); - psys_interpolate_face(mvert, mface, 0, 0, pa->fuv, co1, nor, 0, 0, 0, 0); + psys_interpolate_face(mvert,mface,0,0,pa->fuv,co1,nor,0,0,0,0); normalize_v3(nor); - mul_v3_fl(nor, -100.0); + mul_v3_fl(nor,-100.0); - add_v3_v3v3(co2, co1, nor); + add_v3_v3v3(co2,co1,nor); min_d=2.0; intersect=0; - for (i=0, mface=dm->getTessFaceDataArray(dm, CD_MFACE); i<tot; i++, mface++) { + for (i=0,mface=dm->getTessFaceDataArray(dm,CD_MFACE); i<tot; i++,mface++) { if (i==pa->num) continue; v1=mvert[mface->v1].co; @@ -889,14 +889,14 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch if (ctx->tree) { KDTreeNearest ptn[10]; - int w, maxw;//, do_seams; - float maxd /*, mind, dd */, totw= 0.0f; + int w,maxw;//, do_seams; + float maxd /*, mind,dd */, totw= 0.0f; int parent[10]; float pweight[10]; - psys_particle_on_dm(dm, cfrom, cpa->num, DMCACHE_ISCHILD, cpa->fuv, cpa->foffset, co1, nor1, NULL, NULL, orco1, NULL); + psys_particle_on_dm(dm,cfrom,cpa->num,DMCACHE_ISCHILD,cpa->fuv,cpa->foffset,co1,nor1,NULL,NULL,orco1,NULL); BKE_mesh_orco_verts_transform((Mesh*)ob->data, &orco1, 1, 1); - maxw = BLI_kdtree_find_n_nearest(ctx->tree, 4, orco1, NULL, ptn); + maxw = BLI_kdtree_find_n_nearest(ctx->tree,4,orco1,NULL,ptn); maxd=ptn[maxw-1].dist; /* mind=ptn[0].dist; */ /* UNUSED */ @@ -904,14 +904,14 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch /* the weights here could be done better */ for (w=0; w<maxw; w++) { parent[w]=ptn[w].index; - pweight[w]=(float)pow(2.0, (double)(-6.0f*ptn[w].dist/maxd)); + pweight[w]=(float)pow(2.0,(double)(-6.0f*ptn[w].dist/maxd)); } for (;w<10; w++) { parent[w]=-1; pweight[w]=0.0f; } - for (w=0, i=0; w<maxw && i<4; w++) { + for (w=0,i=0; w<maxw && i<4; w++) { if (parent[w]>=0) { cpa->pa[i]=parent[w]; cpa->w[i]=pweight[w]; @@ -997,7 +997,7 @@ static void distribute_invalid(Scene *scene, ParticleSystem *psys, int from) int p, totchild = get_psys_tot_child(scene, psys); if (psys->child && totchild) { - for (p=0, cpa=psys->child; p<totchild; p++, cpa++) { + for (p=0,cpa=psys->child; p<totchild; p++,cpa++) { cpa->fuv[0]=cpa->fuv[1]=cpa->fuv[2]=cpa->fuv[3]= 0.0; cpa->foffset= 0.0f; cpa->parent=0; @@ -1033,7 +1033,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D int cfrom=0; int totelem=0, totpart, *particle_element=0, children=0, totseam=0; int jitlevel= 1, distr; - float *element_weight=NULL, *element_sum=NULL, *jitter_offset=NULL, *vweight=NULL; + float *element_weight=NULL,*element_sum=NULL,*jitter_offset=NULL, *vweight=NULL; float cur, maxweight=0.0, tweight, totweight, inv_totweight, co[3], nor[3], orco[3], ornor[3]; if (ELEM3(NULL, ob, psys, psys->part)) @@ -1065,7 +1065,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D BLI_srandom(31415926 + psys->seed); dm= CDDM_from_mesh((Mesh*)ob->data, ob); DM_ensure_tessface(dm); - distribute_grid(dm, psys); + distribute_grid(dm,psys); dm->release(dm); return 0; } @@ -1084,8 +1084,8 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D tree=BLI_kdtree_new(totpart); - for (p=0, pa=psys->particles; p<totpart; p++, pa++) { - psys_particle_on_dm(dm, part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, co, nor, 0, 0, orco, ornor); + for (p=0,pa=psys->particles; p<totpart; p++,pa++) { + psys_particle_on_dm(dm,part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,co,nor,0,0,orco,ornor); BKE_mesh_orco_verts_transform((Mesh*)ob->data, &orco, 1, 1); BLI_kdtree_insert(tree, p, orco, ornor); } @@ -1118,12 +1118,12 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D for (p=0; p<totvert; p++) { if (orcodata) { - copy_v3_v3(co, orcodata[p]); + copy_v3_v3(co,orcodata[p]); BKE_mesh_orco_verts_transform((Mesh*)ob->data, &co, 1, 1); } else - copy_v3_v3(co, mv[p].co); - BLI_kdtree_insert(tree, p, co, NULL); + copy_v3_v3(co,mv[p].co); + BLI_kdtree_insert(tree,p,co,NULL); } BLI_kdtree_balance(tree); @@ -1137,7 +1137,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D distribute_invalid(scene, psys, children ? PART_FROM_CHILD : 0); if (G.debug & G_DEBUG) - fprintf(stderr, "Particle distribution error: Nothing to emit from!\n"); + fprintf(stderr,"Particle distribution error: Nothing to emit from!\n"); if (dm != finaldm) dm->release(dm); @@ -1160,7 +1160,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D orcodata= dm->getVertDataArray(dm, CD_ORCO); for (i=0; i<totelem; i++) { - MFace *mf=dm->getTessFaceData(dm, i, CD_MFACE); + MFace *mf=dm->getTessFaceData(dm,i,CD_MFACE); if (orcodata) { copy_v3_v3(co1, orcodata[mf->v1]); @@ -1175,14 +1175,14 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D } } else { - v1= (MVert*)dm->getVertData(dm, mf->v1, CD_MVERT); - v2= (MVert*)dm->getVertData(dm, mf->v2, CD_MVERT); - v3= (MVert*)dm->getVertData(dm, mf->v3, CD_MVERT); + v1= (MVert*)dm->getVertData(dm,mf->v1,CD_MVERT); + v2= (MVert*)dm->getVertData(dm,mf->v2,CD_MVERT); + v3= (MVert*)dm->getVertData(dm,mf->v3,CD_MVERT); copy_v3_v3(co1, v1->co); copy_v3_v3(co2, v2->co); copy_v3_v3(co3, v3->co); if (mf->v4) { - v4= (MVert*)dm->getVertData(dm, mf->v4, CD_MVERT); + v4= (MVert*)dm->getVertData(dm,mf->v4,CD_MVERT); copy_v3_v3(co4, v4->co); } } @@ -1202,14 +1202,14 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D maxweight /= totarea; } else { - float min=1.0f/(float)(MIN2(totelem, totpart)); + float min=1.0f/(float)(MIN2(totelem,totpart)); for (i=0; i<totelem; i++) element_weight[i]=min; maxweight=min; } /* Calculate weights from vgroup */ - vweight = psys_cache_vgroup(dm, psys, PSYS_VG_DENSITY); + vweight = psys_cache_vgroup(dm,psys,PSYS_VG_DENSITY); if (vweight) { if (from==PART_FROM_VERT) { @@ -1218,7 +1218,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D } else { /* PART_FROM_FACE / PART_FROM_VOLUME */ for (i=0;i<totelem; i++) { - MFace *mf=dm->getTessFaceData(dm, i, CD_MFACE); + MFace *mf=dm->getTessFaceData(dm,i,CD_MFACE); tweight = vweight[mf->v1] + vweight[mf->v2] + vweight[mf->v3]; if (mf->v4) { @@ -1303,7 +1303,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D } /* Create jittering if needed */ - if (distr==PART_DISTR_JIT && ELEM(from, PART_FROM_FACE, PART_FROM_VOLUME)) { + if (distr==PART_DISTR_JIT && ELEM(from,PART_FROM_FACE,PART_FROM_VOLUME)) { jitlevel= part->userjit; if (jitlevel == 0) { @@ -1399,7 +1399,7 @@ static void distribute_particles_on_shape(ParticleSimulationData *sim, int UNUSE { distribute_invalid(sim->scene, sim->psys, 0); - fprintf(stderr, "Shape emission not yet possible!\n"); + fprintf(stderr,"Shape emission not yet possible!\n"); } static void distribute_particles(ParticleSimulationData *sim, int from) @@ -1419,7 +1419,7 @@ static void distribute_particles(ParticleSimulationData *sim, int from) if (distr_error) { distribute_invalid(sim->scene, sim->psys, from); - fprintf(stderr, "Particle distribution error!\n"); + fprintf(stderr,"Particle distribution error!\n"); } } @@ -1620,18 +1620,18 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P ParticleSystem *psys = sim->psys; ParticleSettings *part; ParticleTexture ptex; - float fac, phasefac, nor[3]={0, 0, 0}, loc[3], vel[3]={0.0, 0.0, 0.0}, rot[4], q2[4]; - float r_vel[3], r_ave[3], r_rot[4], vec[3], p_vel[3]={0.0, 0.0, 0.0}; - float x_vec[3]={1.0, 0.0, 0.0}, utan[3]={0.0, 1.0, 0.0}, vtan[3]={0.0, 0.0, 1.0}, rot_vec[3]={0.0, 0.0, 0.0}; + float fac, phasefac, nor[3]={0,0,0},loc[3],vel[3]={0.0,0.0,0.0},rot[4],q2[4]; + float r_vel[3],r_ave[3],r_rot[4],vec[3],p_vel[3]={0.0,0.0,0.0}; + float x_vec[3]={1.0,0.0,0.0}, utan[3]={0.0,1.0,0.0}, vtan[3]={0.0,0.0,1.0}, rot_vec[3]={0.0,0.0,0.0}; float q_phase[4]; int p = pa - psys->particles; part=psys->part; /* get birth location from object */ if (part->tanfac != 0.f) - psys_particle_on_emitter(sim->psmd, part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, loc, nor, utan, vtan, 0, 0); + psys_particle_on_emitter(sim->psmd, part->from,pa->num, pa->num_dmcache, pa->fuv,pa->foffset,loc,nor,utan,vtan,0,0); else - psys_particle_on_emitter(sim->psmd, part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, loc, nor, 0, 0, 0, 0); + psys_particle_on_emitter(sim->psmd, part->from,pa->num, pa->num_dmcache, pa->fuv,pa->foffset,loc,nor,0,0,0,0); /* get possible textural influence */ psys_get_texture(sim, pa, &ptex, PAMAP_IVEL, cfra); @@ -1647,16 +1647,16 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P /* -tangent */ if (part->tanfac!=0.0f) { - //float phase=vg_rot?2.0f*(psys_particle_value_from_verts(sim->psmd->dm, part->from, pa, vg_rot)-0.5f):0.0f; + //float phase=vg_rot?2.0f*(psys_particle_value_from_verts(sim->psmd->dm,part->from,pa,vg_rot)-0.5f):0.0f; float phase=0.0f; - mul_v3_fl(vtan, -cosf((float)M_PI*(part->tanphase+phase))); + mul_v3_fl(vtan,-cosf((float)M_PI*(part->tanphase+phase))); fac= -sinf((float)M_PI*(part->tanphase+phase)); madd_v3_v3fl(vtan, utan, fac); - mul_mat3_m4_v3(ob->obmat, vtan); + mul_mat3_m4_v3(ob->obmat,vtan); copy_v3_v3(utan, nor); - mul_v3_fl(utan, dot_v3v3(vtan, nor)); + mul_v3_fl(utan,dot_v3v3(vtan,nor)); sub_v3_v3(vtan, utan); normalize_v3(vtan); @@ -1679,7 +1679,7 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P r_ave[1] = 2.0f * (PSYS_FRAND(p + 14) - 0.5f); r_ave[2] = 2.0f * (PSYS_FRAND(p + 15) - 0.5f); - mul_mat3_m4_v3(ob->obmat, r_ave); + mul_mat3_m4_v3(ob->obmat,r_ave); normalize_v3(r_ave); } @@ -1691,14 +1691,14 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P r_rot[3] = 2.0f * (PSYS_FRAND(p + 19) - 0.5f); normalize_qt(r_rot); - mat4_to_quat(rot, ob->obmat); - mul_qt_qtqt(r_rot, r_rot, rot); + mat4_to_quat(rot,ob->obmat); + mul_qt_qtqt(r_rot,r_rot,rot); } if (part->phystype==PART_PHYS_BOIDS && pa->boid) { float dvec[3], q[4], mat[3][3]; - copy_v3_v3(state->co, loc); + copy_v3_v3(state->co,loc); /* boids don't get any initial velocity */ zero_v3(state->vel); @@ -1721,7 +1721,7 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P cross_v3_v3v3(mat[1], mat[2], mat[0]); /* apply rotation */ - mat3_to_quat_is_ok(q, mat); + mat3_to_quat_is_ok( q,mat); copy_qt_qt(state->rot, q); } else { @@ -1775,7 +1775,7 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P mul_v3_v3fl(state->vel, vel, ptex.ivel); /* -location from emitter */ - copy_v3_v3(state->co, loc); + copy_v3_v3(state->co,loc); /* -rotation */ unit_qt(state->rot); @@ -1803,19 +1803,19 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P /* create rotation quat */ negate_v3(rot_vec); - vec_to_quat(q2, rot_vec, OB_POSX, OB_POSZ); + vec_to_quat( q2,rot_vec, OB_POSX, OB_POSZ); /* randomize rotation quat */ if (part->randrotfac!=0.0f) interp_qt_qtqt(rot, q2, r_rot, part->randrotfac); else - copy_qt_qt(rot, q2); + copy_qt_qt(rot,q2); /* rotation phase */ phasefac = part->phasefac; if (part->randphasefac != 0.0f) phasefac += part->randphasefac * PSYS_FRAND(p + 20); - axis_angle_to_quat(q_phase, x_vec, phasefac*(float)M_PI); + axis_angle_to_quat( q_phase,x_vec, phasefac*(float)M_PI); /* combine base rotation & phase */ mul_qt_qtqt(state->rot, rot, q_phase); @@ -2133,7 +2133,7 @@ static void psys_update_effectors(ParticleSimulationData *sim) static void integrate_particle(ParticleSettings *part, ParticleData *pa, float dtime, float *external_acceleration, void (*force_func)(void *forcedata, ParticleKey *state, float *force, float *impulse), void *forcedata) { ParticleKey states[5]; - float force[3], acceleration[3], impulse[3], dx[4][3], dv[4][3], oldpos[3]; + float force[3],acceleration[3],impulse[3],dx[4][3],dv[4][3],oldpos[3]; float pa_mass= (part->flag & PART_SIZEMASS ? part->mass * pa->size : part->mass); int i, steps=1; int integrator = part->integrator; @@ -2538,10 +2538,10 @@ static void sph_force_cb(void *sphdata_v, ParticleKey *state, float *force, floa u = dot_v3v3(vec, dv); if (u < 0.f && visc > 0.f) - madd_v3_v3fl(force, vec, 0.5f * q * visc * u); + madd_v3_v3fl(force, vec, 0.5f * q * visc * u ); if (u > 0.f && stiff_visc > 0.f) - madd_v3_v3fl(force, vec, 0.5f * q * stiff_visc * u); + madd_v3_v3fl(force, vec, 0.5f * q * stiff_visc * u ); } if (spring_constant > 0.f) { @@ -2714,23 +2714,23 @@ static void basic_integrate(ParticleSimulationData *sim, int p, float dfra, floa time=(cfra-pa->time)/pa->lifetime; CLAMP(time, 0.0f, 1.0f); - copy_v3_v3(tkey.co, pa->state.co); - copy_v3_v3(tkey.vel, pa->state.vel); + copy_v3_v3(tkey.co,pa->state.co); + copy_v3_v3(tkey.vel,pa->state.vel); tkey.time=pa->state.time; if (part->type != PART_HAIR) { if (do_guides(sim->psys->effectors, &tkey, p, time)) { - copy_v3_v3(pa->state.co, tkey.co); + copy_v3_v3(pa->state.co,tkey.co); /* guides don't produce valid velocity */ sub_v3_v3v3(pa->state.vel, tkey.co, pa->prev_state.co); - mul_v3_fl(pa->state.vel, 1.0f/dtime); + mul_v3_fl(pa->state.vel,1.0f/dtime); pa->state.time=tkey.time; } } } static void basic_rotate(ParticleSettings *part, ParticleData *pa, float dfra, float timestep) { - float rotfac, rot1[4], rot2[4]={1.0, 0.0, 0.0, 0.0}, dtime=dfra*timestep; + float rotfac, rot1[4], rot2[4]={1.0,0.0,0.0,0.0}, dtime=dfra*timestep; if ((part->flag & PART_ROTATIONS)==0) { pa->state.rot[0]=1.0f; @@ -2758,15 +2758,15 @@ static void basic_rotate(ParticleSettings *part, ParticleData *pa, float dfra, f } rotfac = len_v3(pa->state.ave); - if (rotfac == 0.0f) { /* unit_qt(in VecRotToQuat) doesn't give unit quat [1, 0, 0, 0]?? */ + if (rotfac == 0.0f) { /* unit_qt(in VecRotToQuat) doesn't give unit quat [1,0,0,0]?? */ rot1[0]=1.0f; rot1[1]=rot1[2]=rot1[3]=0; } else { - axis_angle_to_quat(rot1, pa->state.ave, rotfac*dtime); + axis_angle_to_quat(rot1,pa->state.ave,rotfac*dtime); } - mul_qt_qtqt(pa->state.rot, rot1, pa->prev_state.rot); - mul_qt_qtqt(pa->state.rot, rot2, pa->state.rot); + mul_qt_qtqt(pa->state.rot,rot1,pa->prev_state.rot); + mul_qt_qtqt(pa->state.rot,rot2,pa->state.rot); /* keep rotation quat in good health */ normalize_qt(pa->state.rot); @@ -3257,8 +3257,8 @@ static int collision_response(ParticleData *pa, ParticleCollision *col, BVHTreeR float frict = pd->pdef_frict + pd->pdef_rfrict * 2 * (BLI_frand() - 0.5f); float distance, nor[3], dot; - CLAMP(damp, 0.0f, 1.0f); - CLAMP(frict, 0.0f, 1.0f); + CLAMP(damp,0.0f, 1.0f); + CLAMP(frict,0.0f, 1.0f); /* get exact velocity right before collision */ madd_v3_v3v3fl(v0, col->ve1, col->acc, dt1); @@ -3604,7 +3604,7 @@ static void do_hair_dynamics(ParticleSimulationData *sim) psys_mat_hair_to_object(sim->ob, sim->psmd->dm, psys->part->from, pa, hairmat); - for (k=0, key=pa->hair; k<pa->totkey; k++, key++) { + for (k=0, key=pa->hair; k<pa->totkey; k++,key++) { /* create fake root before actual root to resist bending */ if (k==0) { @@ -3870,7 +3870,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) } /* initialize all particles for dynamics */ LOOP_SHOWN_PARTICLES { - copy_particle_key(&pa->prev_state, &pa->state, 1); + copy_particle_key(&pa->prev_state,&pa->state,1); psys_get_texture(sim, pa, &ptex, PAMAP_SIZE, cfra); @@ -3949,7 +3949,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) SPHData sphdata; sph_solver_init(sim, &sphdata); - #pragma omp parallel for firstprivate (sphdata) private (pa) schedule(dynamic, 5) + #pragma omp parallel for firstprivate (sphdata) private (pa) schedule(dynamic,5) LOOP_DYNAMIC_PARTICLES { /* do global forces & effectors */ basic_integrate(sim, p, pa->state.time, cfra); @@ -4086,7 +4086,7 @@ static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra)) gzf = BLI_gzopen(filename, "rb"); if (!gzf) { - BLI_snprintf(debugStrBuffer, sizeof(debugStrBuffer), "readFsPartData::error - Unable to open file for reading '%s'\n", filename); + BLI_snprintf(debugStrBuffer, sizeof(debugStrBuffer),"readFsPartData::error - Unable to open file for reading '%s'\n", filename); // XXX bad level call elbeemDebugOut(debugStrBuffer); return; } @@ -4107,23 +4107,23 @@ static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra)) for (p=0, pa=psys->particles; p<totpart; p++, pa++) { int ptype=0; - gzread(gzf, &ptype, sizeof(ptype)); + gzread(gzf, &ptype, sizeof( ptype )); if (ptype&readMask) { activeParts++; - gzread(gzf, &(pa->size), sizeof(float)); + gzread(gzf, &(pa->size), sizeof( float )); pa->size /= 10.0f; for (j=0; j<3; j++) { float wrf; - gzread(gzf, &wrf, sizeof(wrf)); + gzread(gzf, &wrf, sizeof( wrf )); pa->state.co[j] = wrf; - //fprintf(stderr, "Rj%d ", j); + //fprintf(stderr,"Rj%d ",j); } for (j=0; j<3; j++) { float wrf; - gzread(gzf, &wrf, sizeof(wrf)); + gzread(gzf, &wrf, sizeof( wrf )); pa->state.vel[j] = wrf; } @@ -4135,7 +4135,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... @@ -4148,7 +4148,7 @@ static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra)) gzclose(gzf); totpart = psys->totpart = activeParts; - BLI_snprintf(debugStrBuffer, sizeof(debugStrBuffer), "readFsPartData::done - particles:%d, active:%d, file:%d, mask:%d\n", psys->totpart, activeParts, fileParts, readMask); + BLI_snprintf(debugStrBuffer,sizeof(debugStrBuffer),"readFsPartData::done - particles:%d, active:%d, file:%d, mask:%d\n", psys->totpart,activeParts,fileParts,readMask); // bad level call // XXX elbeemDebugOut(debugStrBuffer); @@ -4303,7 +4303,7 @@ static void system_step(ParticleSimulationData *sim, float cfra) dynamics_step(sim, cfra+dframe+t_frac - 1.f); psys->cfra = cfra+dframe+t_frac - 1.f; #if 0 - printf("%f, %f, %f, %f\n", cfra+dframe+t_frac - 1.f, t_frac, dt_frac, sim->courant_num); + printf("%f,%f,%f,%f\n", cfra+dframe+t_frac - 1.f, t_frac, dt_frac, sim->courant_num); #endif if (part->time_flag & PART_TIME_AUTOSF) dt_frac = update_timestep(psys, sim, t_frac); @@ -4590,7 +4590,7 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys) if (part->phystype == PART_PHYS_KEYED) { psys_count_keyed_targets(&sim); set_keyed_keys(&sim); - psys_update_path_cache(&sim, (int)cfra); + psys_update_path_cache(&sim,(int)cfra); } break; } diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 69808db52b6..f483fd7dc8a 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -2732,7 +2732,7 @@ static void ptcache_dt_to_str(char *str, double dtime) static void *ptcache_bake_thread(void *ptr) { - int usetimer = 0, sfra, efra; + int use_timer = FALSE, sfra, efra; double stime, ptime, ctime, fetd; char run[32], cur[32], etd[32]; @@ -2752,8 +2752,8 @@ static void *ptcache_bake_thread(void *ptr) fetd = (ctime-ptime)*(efra-*data->cfra_ptr)/data->step; - if (usetimer || fetd > 60.0) { - usetimer = 1; + if (use_timer || fetd > 60.0) { + use_timer = TRUE; ptcache_dt_to_str(cur, ctime-ptime); ptcache_dt_to_str(run, ctime-stime); @@ -2765,7 +2765,7 @@ static void *ptcache_bake_thread(void *ptr) } } - if (usetimer) { + if (use_timer) { ptcache_dt_to_str(run, PIL_check_seconds_timer()-stime); printf("Bake %s %s (%i frames simulated).\n", (data->break_operation ? "canceled after" : "finished in"), run, *data->cfra_ptr-sfra); } diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c index 4f67f3600f4..684c1113de6 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -44,7 +44,8 @@ #include "DNA_space_types.h" #include "DNA_view3d_types.h" -#include "BLI_blenlib.h" +#include "BLI_listbase.h" +#include "BLI_utildefines.h" #include "BKE_screen.h" @@ -251,7 +252,7 @@ void BKE_spacedata_draw_locks(int set) if (set) art->do_lock = art->lock; else - art->do_lock = 0; + art->do_lock = FALSE; } } } diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 9358b786472..fac74d27e0d 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -74,10 +74,11 @@ enum { GlowA = 3 }; -static struct ImBuf *prepare_effect_imbufs( - SeqRenderData context, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3){ +static ImBuf *prepare_effect_imbufs( + SeqRenderData context, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) +{ struct ImBuf *out; int x = context.rectx; int y = context.recty; @@ -282,7 +283,7 @@ static ImBuf *IMB_cast_away_list(ImBuf *i) return (ImBuf *) (((void **) i) + 2); } -static struct ImBuf *do_plugin_effect( +static ImBuf *do_plugin_effect( SeqRenderData context, Sequence *seq, float cfra, float facf0, float facf1, struct ImBuf *ibuf1, struct ImBuf *ibuf2, @@ -290,9 +291,9 @@ static struct ImBuf *do_plugin_effect( { char *cp; int float_rendering; - int use_temp_bufs = 0; /* Are needed since blur.c (and maybe some other - * old plugins) do very bad stuff - * with imbuf-internals */ + int use_temp_bufs = FALSE; /* Are needed since blur.c (and maybe some other + * old plugins) do very bad stuff + * with imbuf-internals */ struct ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); int x = context.rectx; @@ -318,7 +319,7 @@ static struct ImBuf *do_plugin_effect( float_rendering = (out->rect_float != NULL); if (seq->plugin->version <= 3 && float_rendering) { - use_temp_bufs = 1; + use_temp_bufs = TRUE; if (ibuf1) { ibuf1 = IMB_dupImBuf(ibuf1); @@ -541,7 +542,7 @@ static void do_alphaover_effect_float(float facf0, float facf1, int x, int y, } } -static struct ImBuf *do_alphaover_effect( +static ImBuf *do_alphaover_effect( SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra), float facf0, float facf1, struct ImBuf *ibuf1, struct ImBuf *ibuf2, @@ -719,7 +720,7 @@ static void do_alphaunder_effect_float(float facf0, float facf1, int x, int y, } } -static struct ImBuf *do_alphaunder_effect( +static ImBuf *do_alphaunder_effect( SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra), float facf0, float facf1, struct ImBuf *ibuf1, struct ImBuf *ibuf2, @@ -845,7 +846,7 @@ static void do_cross_effect_float(float facf0, float facf1, int x, int y, /* careful: also used by speed effect! */ -static struct ImBuf *do_cross_effect( +static ImBuf *do_cross_effect( SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra), float facf0, float facf1, struct ImBuf *ibuf1, struct ImBuf *ibuf2, @@ -1111,7 +1112,7 @@ static void do_gammacross_effect_float(float facf0, float UNUSED(facf1), } } -static struct ImBuf *do_gammacross_effect( +static ImBuf *do_gammacross_effect( SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra), float facf0, float facf1, @@ -1231,11 +1232,12 @@ static void do_add_effect_float(float facf0, float facf1, int x, int y, } } -static struct ImBuf *do_add_effect(SeqRenderData context, - Sequence *UNUSED(seq), float UNUSED(cfra), - float facf0, float facf1, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3){ +static ImBuf *do_add_effect(SeqRenderData context, + Sequence *UNUSED(seq), float UNUSED(cfra), + float facf0, float facf1, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) +{ struct ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); if (out->rect_float) { @@ -1347,11 +1349,12 @@ static void do_sub_effect_float(float facf0, float facf1, int x, int y, } } -static struct ImBuf *do_sub_effect( - SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra), - float facf0, float facf1, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3){ +static ImBuf *do_sub_effect( + SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra), + float facf0, float facf1, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) +{ struct ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); if (out->rect_float) { @@ -1560,7 +1563,7 @@ static void do_mul_effect_float(float facf0, float facf1, int x, int y, } } -static struct ImBuf *do_mul_effect( +static ImBuf *do_mul_effect( SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra), float facf0, float facf1, struct ImBuf *ibuf1, struct ImBuf *ibuf2, @@ -2008,11 +2011,12 @@ static void do_wipe_effect_float(Sequence *seq, float facf0, float UNUSED(facf1) } } -static struct ImBuf *do_wipe_effect( - SeqRenderData context, Sequence *seq, float UNUSED(cfra), - float facf0, float facf1, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3){ +static ImBuf *do_wipe_effect( + SeqRenderData context, Sequence *seq, float UNUSED(cfra), + float facf0, float facf1, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) +{ struct ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); if (out->rect_float) { @@ -2155,11 +2159,12 @@ static void do_transform(Scene *scene, Sequence *seq, float UNUSED(facf0), int x } -static struct ImBuf *do_transform_effect( - SeqRenderData context, Sequence *seq, float UNUSED(cfra), - float facf0, float UNUSED(facf1), - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3){ +static ImBuf *do_transform_effect( + SeqRenderData context, Sequence *seq, float UNUSED(cfra), + float facf0, float UNUSED(facf1), + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) +{ struct ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); do_transform(context.scene, seq, facf0, @@ -2671,7 +2676,7 @@ static void do_glow_effect_float(Sequence *seq, int render_size, float facf0, fl RVAddBitmaps_float(inbuf, outbuf, outbuf, x, y); } -static struct ImBuf *do_glow_effect( +static ImBuf *do_glow_effect( SeqRenderData context, Sequence *seq, float UNUSED(cfra), float facf0, float facf1, struct ImBuf *ibuf1, struct ImBuf *ibuf2, @@ -2736,11 +2741,12 @@ static int early_out_color(struct Sequence *UNUSED(seq), return -1; } -static struct ImBuf *do_solid_color( - SeqRenderData context, Sequence *seq, float UNUSED(cfra), - float facf0, float facf1, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3){ +static ImBuf *do_solid_color( + SeqRenderData context, Sequence *seq, float UNUSED(cfra), + float facf0, float facf1, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) +{ struct ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); SolidColorVars *cv = (SolidColorVars *)seq->effectdata; @@ -2833,11 +2839,12 @@ static int early_out_multicam(struct Sequence *UNUSED(seq), float UNUSED(facf0), return -1; } -static struct ImBuf *do_multicam( - SeqRenderData context, Sequence *seq, float cfra, - float UNUSED(facf0), float UNUSED(facf1), - struct ImBuf *UNUSED(ibuf1), struct ImBuf *UNUSED(ibuf2), - struct ImBuf *UNUSED(ibuf3)){ +static ImBuf *do_multicam( + SeqRenderData context, Sequence *seq, float cfra, + float UNUSED(facf0), float UNUSED(facf1), + struct ImBuf *UNUSED(ibuf1), struct ImBuf *UNUSED(ibuf2), + struct ImBuf *UNUSED(ibuf3)) +{ struct ImBuf *i; struct ImBuf *out; Editing *ed; @@ -2887,8 +2894,8 @@ static int early_out_adjustment(struct Sequence *UNUSED(seq), float UNUSED(facf0 return -1; } -static struct ImBuf *do_adjustment_impl(SeqRenderData context, Sequence *seq, - float cfra){ +static ImBuf *do_adjustment_impl(SeqRenderData context, Sequence *seq, float cfra) +{ Editing *ed; ListBase *seqbasep; struct ImBuf *i = NULL; @@ -2920,11 +2927,12 @@ static struct ImBuf *do_adjustment_impl(SeqRenderData context, Sequence *seq, return i; } -static struct ImBuf *do_adjustment( - SeqRenderData context, Sequence *seq, float cfra, - float UNUSED(facf0), float UNUSED(facf1), - struct ImBuf *UNUSED(ibuf1), struct ImBuf *UNUSED(ibuf2), - struct ImBuf *UNUSED(ibuf3)){ +static ImBuf *do_adjustment( + SeqRenderData context, Sequence *seq, float cfra, + float UNUSED(facf0), float UNUSED(facf1), + struct ImBuf *UNUSED(ibuf1), struct ImBuf *UNUSED(ibuf2), + struct ImBuf *UNUSED(ibuf3)) +{ struct ImBuf *i = NULL; struct ImBuf *out; Editing *ed; @@ -3214,13 +3222,14 @@ static void get_default_fac_fade(struct Sequence *seq, float cfra, *facf1 /= seq->len; } -static struct ImBuf *do_overdrop_effect(SeqRenderData context, - Sequence *UNUSED(seq), - float UNUSED(cfra), - float facf0, float facf1, - struct ImBuf *ibuf1, - struct ImBuf *ibuf2, - struct ImBuf *ibuf3){ +static ImBuf *do_overdrop_effect(SeqRenderData context, + Sequence *UNUSED(seq), + float UNUSED(cfra), + float facf0, float facf1, + struct ImBuf *ibuf1, + struct ImBuf *ibuf2, + struct ImBuf *ibuf3) +{ struct ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); int x = context.rectx; int y = context.recty; @@ -3250,7 +3259,8 @@ static struct ImBuf *do_overdrop_effect(SeqRenderData context, return out; } -static struct SeqEffectHandle get_sequence_effect_impl(int seq_type){ +static struct SeqEffectHandle get_sequence_effect_impl(int seq_type) +{ struct SeqEffectHandle rval; int sequence_type = seq_type; diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 41858eeecb4..a762af960a5 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1464,7 +1464,7 @@ void seq_proxy_rebuild(SeqIndexBuildContext *context, short *stop, short *do_upd *progress = (float)cfra / (seq->enddisp - seq->endstill - seq->startdisp + seq->startstill); - *do_update = 1; + *do_update = TRUE; if (*stop || G.afbreek) break; diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 1666f75ad4c..9e6fdcca73a 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -1685,7 +1685,7 @@ static void sb_sfesf_threads_run(Scene *scene, struct Object *ob, float timenow, else sb_threads[i].ifirst = 0; sb_threads[i].do_effector = do_effector; - sb_threads[i].do_deflector = 0;// not used here + sb_threads[i].do_deflector = FALSE;// not used here sb_threads[i].fieldfactor = 0.0f;// not used here sb_threads[i].windfactor = 0.0f;// not used here sb_threads[i].nr= i; @@ -3233,9 +3233,9 @@ static void springs_from_mesh(Object *ob) sb= ob->soft; if (me && sb) { /* using bp->origS as a container for spring calcualtions here - ** will be overwritten sbObjectStep() to receive - ** actual modifier stack positions - */ + * will be overwritten sbObjectStep() to receive + * actual modifier stack positions + */ if (me->totvert) { bp= ob->soft->bpoint; for (a=0; a<me->totvert; a++, bp++) { @@ -3283,10 +3283,10 @@ static void mesh_to_softbody(Scene *scene, Object *ob) for (a=0; a<me->totvert; a++, bp++) { /* get scalar values needed *per vertex* from vertex group functions, - so we can *paint* them nicly .. - they are normalized [0.0..1.0] so may be we need amplitude for scale - which can be done by caller but still .. i'd like it to go this way - */ + * so we can *paint* them nicly .. + * they are normalized [0.0..1.0] so may be we need amplitude for scale + * which can be done by caller but still .. i'd like it to go this way + */ if ((ob->softflag & OB_SB_GOAL) && sb->vertgroup) { /* even this is a deprecated evil hack */ /* I'd like to have it .. if (sb->namedVG_Goal[0]) */ @@ -3306,8 +3306,8 @@ static void mesh_to_softbody(Scene *scene, Object *ob) } /* to proove the concept - this enables per vertex *mass painting* - */ + * this enables per vertex *mass painting* + */ if (sb->namedVG_Mass[0]) { int grp= defgroup_name_index (ob, sb->namedVG_Mass); @@ -3411,9 +3411,9 @@ static void reference_to_scratch(Object *ob) } /* -helper function to get proper spring length -when object is rescaled -*/ + * helper function to get proper spring length + * when object is rescaled + */ static float globallen(float *v1, float *v2, Object *ob) { float p1[3], p2[3]; @@ -3669,7 +3669,7 @@ static void sb_new_scratch(SoftBody *sb) { if (!sb) return; sb->scratch = MEM_callocN(sizeof(SBScratch), "SBScratch"); - sb->scratch->colliderhash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "sb_new_scratch gh"); + sb->scratch->colliderhash = BLI_ghash_ptr_new("sb_new_scratch gh"); sb->scratch->bodyface = NULL; sb->scratch->totface = 0; sb->scratch->aabbmax[0]=sb->scratch->aabbmax[1]=sb->scratch->aabbmax[2] = 1.0e30f; @@ -3793,7 +3793,7 @@ static void softbody_update_positions(Object *ob, SoftBody *sb, float (*vertexCo /* vertexCos came from local world, go global */ mul_m4_v3(ob->obmat, bp->origE); /* just to be save give bp->origT a defined value - will be calulated in interpolate_exciter()*/ + * will be calulated in interpolate_exciter()*/ copy_v3_v3(bp->origT, bp->origE); } } diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 52007f1f43e..28fb75db41c 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -173,6 +173,7 @@ void sound_force_device(int device) void sound_init_once(void) { AUD_initOnce(); + atexit(sound_exit); } void sound_init(struct Main *bmain) diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 2a92992cb9f..ad5bb24e541 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -1045,7 +1045,7 @@ void subsurf_copy_grid_hidden(DerivedMesh *dm, const MPoly *mpoly, } /* Translate GridPaintMask into vertex paint masks. Assumes vertices - are in the order output by ccgDM_copyFinalVertArray. */ + * are in the order output by ccgDM_copyFinalVertArray. */ void subsurf_copy_grid_paint_mask(DerivedMesh *dm, const MPoly *mpoly, float *paint_mask, const GridPaintMask *grid_paint_mask) @@ -1788,12 +1788,12 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm, int gridFaces = gridSize - 1; int edgeSize = ccgSubSurf_getEdgeSize(ss); DMFlagMat *faceFlags = ccgdm->faceFlags; - int a, b, i, doDraw, numVerts, matnr, new_matnr, totface; + int a, b, i, do_draw, numVerts, matnr, new_matnr, totface; CCG_key_top_level(&key, ss); ccgdm_pbvh_update(ccgdm); - doDraw = 0; + do_draw = 0; matnr = -1; #define PASSATTRIB(dx, dy, vert) { \ @@ -1816,7 +1816,7 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm, float *tang = attribs.tang.array[a * 4 + vert]; \ glVertexAttrib4fvARB(attribs.tang.gl_index, tang); \ } \ -} +} (void)0 totface = ccgSubSurf_getNumFaces(ss); for (a = 0, i = 0; i < totface; i++) { @@ -1837,12 +1837,12 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm, } if (new_matnr != matnr) { - doDraw = setMaterial(matnr = new_matnr, &gattribs); - if (doDraw) + do_draw = setMaterial(matnr = new_matnr, &gattribs); + if (do_draw) DM_vertex_attributes_from_gpu(dm, &gattribs, &attribs); } - if (!doDraw || (setDrawOptions && (origIndex != ORIGINDEX_NONE) && + if (!do_draw || (setDrawOptions && (origIndex != ORIGINDEX_NONE) && (setDrawOptions(userData, origIndex) == DM_DRAW_OPTION_SKIP))) { a += gridFaces * gridFaces * numVerts; @@ -1972,7 +1972,7 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, float *tang = attribs.tang.array[a * 4 + vert]; \ glVertexAttrib4fvARB(attribs.tang.gl_index, tang); \ } \ -} +} (void)0 totface = ccgSubSurf_getNumFaces(ss); for (a = 0, i = 0; i < totface; i++) { diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 799529e04f3..dc3db0b02e8 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -912,7 +912,7 @@ void txt_move_left(Text *text, short sel) void txt_move_right(Text *text, short sel) { TextLine **linep; - int *charp, oundoing = undoing, do_tab = 0, i; + int *charp, oundoing = undoing, do_tab = FALSE, i; if (!text) return; if (sel) txt_curs_sel(text, &linep, &charp); @@ -931,10 +931,10 @@ void txt_move_right(Text *text, short sel) // do nice right only if there are only spaces // spaces hardcoded in DNA_text_types.h if (text->flags & TXT_TABSTOSPACES && (*linep)->line[*charp] == ' ') { - do_tab = 1; + do_tab = TRUE; for (i = 0; i < *charp; i++) if ((*linep)->line[i] != ' ') { - do_tab = 0; + do_tab = FALSE; break; } } diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index 4e2b4be474b..8339e973d43 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -768,7 +768,7 @@ static TracksMap *tracks_map_new(const char *object_name, int is_camera, int num if (customdata_size) map->customdata = MEM_callocN(customdata_size*num_tracks, "TracksMap customdata"); - map->hash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "TracksMap hash"); + map->hash = BLI_ghash_ptr_new("TracksMap hash"); return map; } |