diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-07-08 19:55:58 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-07-08 19:55:58 +0400 |
commit | 1bca7fe4927b2517cee02c43464df18144c8637e (patch) | |
tree | d99d2322d4940497b52a41d1cbf0a9c02f3a61d0 /source/blender | |
parent | eab80a40df94b2fedbf0f688248c654e215175f5 (diff) | |
parent | 76629c11ae4190b0eec2315360b1ec3379e751c3 (diff) |
svn merge ^/trunk/blender -r48691:48729
Diffstat (limited to 'source/blender')
191 files changed, 2658 insertions, 2430 deletions
diff --git a/source/blender/avi/intern/avi.c b/source/blender/avi/intern/avi.c index 3d04db56d43..cceba82aca7 100644 --- a/source/blender/avi/intern/avi.c +++ b/source/blender/avi/intern/avi.c @@ -870,7 +870,7 @@ AviError AVI_open_compress(char *name, AviMovie *movie, int streams, ...) } } else if (movie->streams[i].sh.Type == FCC("auds")) { - // pass + /* pass */ } #endif } diff --git a/source/blender/blenkernel/BKE_idprop.h b/source/blender/blenkernel/BKE_idprop.h index 2436ada9eaf..88eb4dc6f97 100644 --- a/source/blender/blenkernel/BKE_idprop.h +++ b/source/blender/blenkernel/BKE_idprop.h @@ -60,15 +60,30 @@ typedef union IDPropertyTemplate { /* note: as a start to move away from the stupid IDP_New function, this type * has it's own allocation function.*/ -IDProperty *IDP_NewIDPArray(const char *name); -IDProperty *IDP_CopyIDPArray(IDProperty *array); +IDProperty *IDP_NewIDPArray(const char *name) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; +IDProperty *IDP_CopyIDPArray(IDProperty *array) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; void IDP_FreeIDPArray(IDProperty *prop); /* shallow copies item */ void IDP_SetIndexArray(struct IDProperty *prop, int index, struct IDProperty *item); -struct IDProperty *IDP_GetIndexArray(struct IDProperty *prop, int index); -struct IDProperty *IDP_AppendArray(struct IDProperty *prop, struct IDProperty *item); +struct IDProperty *IDP_GetIndexArray(struct IDProperty *prop, int index) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; +void IDP_AppendArray(struct IDProperty *prop, struct IDProperty *item); void IDP_ResizeIDPArray(struct IDProperty *prop, int len); /* ----------- Numeric Array Type ----------- */ @@ -77,11 +92,33 @@ void IDP_ResizeArray(struct IDProperty *prop, int newlen); void IDP_FreeArray(struct IDProperty *prop); /* ---------- String Type ------------ */ -IDProperty *IDP_NewString(const char *st, const char *name, int maxlen); /* maxlen excludes '\0' */ -void IDP_AssignString(struct IDProperty *prop, const char *st, int maxlen); /* maxlen excludes '\0' */ -void IDP_ConcatStringC(struct IDProperty *prop, const char *st); -void IDP_ConcatString(struct IDProperty *str1, struct IDProperty *append); -void IDP_FreeString(struct IDProperty *prop); +IDProperty *IDP_NewString(const char *st, const char *name, int maxlen) /* maxlen excludes '\0' */ +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; + +void IDP_AssignString(struct IDProperty *prop, const char *st, int maxlen) /* maxlen excludes '\0' */ +#ifdef __GNUC__ +__attribute__((nonnull)) +#endif +; +void IDP_ConcatStringC(struct IDProperty *prop, const char *st) +#ifdef __GNUC__ +__attribute__((nonnull)) +#endif +; +void IDP_ConcatString(struct IDProperty *str1, struct IDProperty *append) +#ifdef __GNUC__ +__attribute__((nonnull)) +#endif +; +void IDP_FreeString(struct IDProperty *prop) +#ifdef __GNUC__ +__attribute__((nonnull)) +#endif +; /*-------- ID Type -------*/ void IDP_LinkID(struct IDProperty *prop, ID *id); @@ -90,17 +127,29 @@ void IDP_UnlinkID(struct IDProperty *prop); /*-------- Group Functions -------*/ /** Sync values from one group to another, only where they match */ -void IDP_SyncGroupValues(struct IDProperty *dest, struct IDProperty *src); +void IDP_SyncGroupValues(struct IDProperty *dest, struct IDProperty *src) +#ifdef __GNUC__ +__attribute__((nonnull)) +#endif +; /** * replaces all properties with the same name in a destination group from a source group. */ -void IDP_ReplaceGroupInGroup(struct IDProperty *dest, struct IDProperty *src); +void IDP_ReplaceGroupInGroup(struct IDProperty *dest, struct IDProperty *src) +#ifdef __GNUC__ +__attribute__((nonnull)) +#endif +; /** * Checks if a property with the same name as prop exists, and if so replaces it. * Use this to preserve order!*/ -void IDP_ReplaceInGroup(struct IDProperty *group, struct IDProperty *prop); +void IDP_ReplaceInGroup(struct IDProperty *group, struct IDProperty *prop) +#ifdef __GNUC__ +__attribute__((nonnull)) +#endif +; /** * This function has a sanity check to make sure ID properties with the same name don't @@ -117,12 +166,20 @@ void IDP_ReplaceInGroup(struct IDProperty *group, struct IDProperty *prop); * struct. In the future this will just be IDP_FreeProperty and the code will * be reorganized to work properly. */ -int IDP_AddToGroup(struct IDProperty *group, struct IDProperty *prop); +int IDP_AddToGroup(struct IDProperty *group, struct IDProperty *prop) +#ifdef __GNUC__ +__attribute__((nonnull)) +#endif +; /** this is the same as IDP_AddToGroup, only you pass an item * in the group list to be inserted after. */ int IDP_InsertToGroup(struct IDProperty *group, struct IDProperty *previous, - struct IDProperty *pnew); + struct IDProperty *pnew) +#ifdef __GNUC__ +__attribute__((nonnull)) +#endif +; /** \note this does not free the property!! * @@ -130,18 +187,36 @@ int IDP_InsertToGroup(struct IDProperty *group, struct IDProperty *previous, * IDP_FreeProperty(prop); //free all subdata * MEM_freeN(prop); //free property struct itself */ -void IDP_RemFromGroup(struct IDProperty *group, struct IDProperty *prop); +void IDP_RemFromGroup(struct IDProperty *group, struct IDProperty *prop) +#ifdef __GNUC__ +__attribute__((nonnull)) +#endif +; -IDProperty *IDP_GetPropertyFromGroup(struct IDProperty *prop, const char *name); +IDProperty *IDP_GetPropertyFromGroup(struct IDProperty *prop, const char *name) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; /** same as above but ensure type match */ -IDProperty *IDP_GetPropertyTypeFromGroup(struct IDProperty *prop, const char *name, const char type); +IDProperty *IDP_GetPropertyTypeFromGroup(struct IDProperty *prop, const char *name, const char type) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; /** * Get an iterator to iterate over the members of an id property group. * Note that this will automatically free the iterator once iteration is complete; * if you stop the iteration before hitting the end, make sure to call * IDP_FreeIterBeforeEnd(). */ -void *IDP_GetGroupIterator(struct IDProperty *prop); +void *IDP_GetGroupIterator(struct IDProperty *prop) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +#endif +; /** * Returns the next item in the iteration. To use, simple for a loop like the following: @@ -149,21 +224,45 @@ void *IDP_GetGroupIterator(struct IDProperty *prop); * ... * } */ -IDProperty *IDP_GroupIterNext(void *vself); +IDProperty *IDP_GroupIterNext(void *vself) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; /** * Frees the iterator pointed to at vself, only use this if iteration is stopped early; * when the iterator hits the end of the list it'll automatically free itself.*/ -void IDP_FreeIterBeforeEnd(void *vself); +void IDP_FreeIterBeforeEnd(void *vself) +#ifdef __GNUC__ +__attribute__((nonnull)) +#endif +; /*-------- Main Functions --------*/ /** Get the Group property that contains the id properties for ID id. Set create_if_needed * to create the Group property and attach it to id if it doesn't exist; otherwise * the function will return NULL if there's no Group property attached to the ID.*/ -struct IDProperty *IDP_GetProperties(struct ID *id, int create_if_needed); -struct IDProperty *IDP_CopyProperty(struct IDProperty *prop); +struct IDProperty *IDP_GetProperties(struct ID *id, int create_if_needed) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; +struct IDProperty *IDP_CopyProperty(struct IDProperty *prop) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; -int IDP_EqualsProperties(struct IDProperty *prop1, struct IDProperty *prop2); +int IDP_EqualsProperties(struct IDProperty *prop1, struct IDProperty *prop2) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; /** * Allocate a new ID. @@ -190,7 +289,12 @@ int IDP_EqualsProperties(struct IDProperty *prop1, struct IDProperty *prop2); * IDP_AddToGroup or MEM_freeN the property, doing anything else might result in * a memory leak. */ -struct IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *name); +struct IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *name) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; /** \note this will free all child properties of list arrays and groups! * Also, note that this does NOT unlink anything! Plus it doesn't free diff --git a/source/blender/blenkernel/BKE_lamp.h b/source/blender/blenkernel/BKE_lamp.h index f9137e50d74..3acd4d1986e 100644 --- a/source/blender/blenkernel/BKE_lamp.h +++ b/source/blender/blenkernel/BKE_lamp.h @@ -38,9 +38,9 @@ extern "C" { struct Lamp; -void *BKE_lamp_add(const char *name); -struct Lamp *BKE_lamp_copy(struct Lamp *la); -struct Lamp *localize_lamp(struct Lamp *la); +struct Lamp *BKE_lamp_add(const char *name) WARN_UNUSED; +struct Lamp *BKE_lamp_copy(struct Lamp *la) WARN_UNUSED; +struct Lamp *localize_lamp(struct Lamp *la) WARN_UNUSED; void BKE_lamp_make_local(struct Lamp *la); void BKE_lamp_free(struct Lamp *la); diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h index 3248944dae8..91756448297 100644 --- a/source/blender/blenkernel/BKE_library.h +++ b/source/blender/blenkernel/BKE_library.h @@ -45,8 +45,18 @@ struct bContext; struct PointerRNA; struct PropertyRNA; -void *BKE_libblock_alloc(struct ListBase *lb, short type, const char *name); -void *BKE_libblock_copy(struct ID *id); +void *BKE_libblock_alloc(struct ListBase *lb, short type, const char *name) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; +void *BKE_libblock_copy(struct ID *id) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; void BKE_libblock_copy_data(struct ID *id, const struct ID *id_from, const short do_action); void BKE_id_lib_local_paths(struct Main *bmain, struct Library *lib, struct ID *id); @@ -82,7 +92,12 @@ void name_uiprefix_id(char *name, struct ID *id); void test_idbutton(char *name); void text_idbutton(struct ID *id, char *text); void BKE_library_make_local(struct Main *bmain, struct Library *lib, int untagged_only); -struct ID *BKE_libblock_find_name(const short type, const char *name); +struct ID *BKE_libblock_find_name(const short type, const char *name) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; void clear_id_newpoins(void); void IDnames_to_pupstring(const char **str, const char *title, const char *extraops, diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c index 35bf4c0961f..c456840637a 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.c +++ b/source/blender/blenkernel/intern/CCGSubSurf.c @@ -2210,7 +2210,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) VertDataAdd(co, r, ss); } - // edge flags cleared later + /* edge flags cleared later */ } for (ptrIdx = 0; ptrIdx < numEffectedV; ptrIdx++) { CCGVert *v = effectedV[ptrIdx]; @@ -2337,7 +2337,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) VertDataAdd(nCo, r, ss); } - // vert flags cleared later + /* vert flags cleared later */ } if (ss->useAgeCounts) { diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 3f28a4afe8d..120a0b2ba27 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -74,7 +74,7 @@ static DerivedMesh *navmesh_dm_createNavMeshForVisualization(DerivedMesh *dm); #endif -#include "BLO_sys_types.h" // for intptr_t support +#include "BLO_sys_types.h" /* for intptr_t support */ #include "GL/glew.h" @@ -956,22 +956,22 @@ void weight_to_rgb(float r_rgb[3], const float weight) { const float blend = ((weight / 2.0f) + 0.5f); - if (weight <= 0.25f) { // blue->cyan + if (weight <= 0.25f) { /* blue->cyan */ r_rgb[0] = 0.0f; r_rgb[1] = blend * weight * 4.0f; r_rgb[2] = blend; } - else if (weight <= 0.50f) { // cyan->green + else if (weight <= 0.50f) { /* cyan->green */ r_rgb[0] = 0.0f; r_rgb[1] = blend; r_rgb[2] = blend * (1.0f - ((weight - 0.25f) * 4.0f)); } - else if (weight <= 0.75f) { // green->yellow + else if (weight <= 0.75f) { /* green->yellow */ r_rgb[0] = blend * ((weight - 0.50f) * 4.0f); r_rgb[1] = blend; r_rgb[2] = 0.0f; } - else if (weight <= 1.0f) { // yellow->red + else if (weight <= 1.0f) { /* yellow->red */ r_rgb[0] = blend; r_rgb[1] = blend * (1.0f - ((weight - 0.75f) * 4.0f)); r_rgb[2] = 0.0f; @@ -2379,16 +2379,16 @@ float *mesh_get_mapped_verts_nors(Scene *scene, Object *ob) typedef struct { float *precomputedFaceNormals; - MTFace *mtface; // texture coordinates - MFace *mface; // indices - MVert *mvert; // vertices & normals + MTFace *mtface; /* texture coordinates */ + MFace *mface; /* indices */ + MVert *mvert; /* vertices & normals */ float (*orco)[3]; - float (*tangent)[4]; // destination + float (*tangent)[4]; /* destination */ int numTessFaces; } SGLSLMeshToTangent; -// interface +/* interface */ #include "mikktspace.h" static int GetNumFaces(const SMikkTSpaceContext *pContext) @@ -2508,7 +2508,7 @@ void DM_add_tangent_layer(DerivedMesh *dm) BLI_memarena_use_calloc(arena); vtangents = MEM_callocN(sizeof(VertexTangent *) * totvert, "VertexTangent"); - // new computation method + /* new computation method */ iCalcNewMethod = 1; if (iCalcNewMethod != 0) { SGLSLMeshToTangent mesh2tangent = {0}; @@ -2532,7 +2532,7 @@ void DM_add_tangent_layer(DerivedMesh *dm) sInterface.m_getNormal = GetNormal; sInterface.m_setTSpaceBasic = SetTSpace; - // 0 if failed + /* 0 if failed */ iCalcNewMethod = genTangSpaceDefault(&sContext); } @@ -2638,7 +2638,7 @@ void DM_calc_auto_bump_scale(DerivedMesh *dm) tex_coords[3] = mtface[f].uv[3]; } - // discard degenerate faces + /* discard degenerate faces */ is_degenerate = 0; if (equals_v3v3(verts[0], verts[1]) || equals_v3v3(verts[0], verts[2]) || equals_v3v3(verts[1], verts[2]) || equals_v2v2(tex_coords[0], tex_coords[1]) || equals_v2v2(tex_coords[0], tex_coords[2]) || equals_v2v2(tex_coords[1], tex_coords[2])) @@ -2646,7 +2646,7 @@ void DM_calc_auto_bump_scale(DerivedMesh *dm) is_degenerate = 1; } - // verify last vertex as well if this is a quad + /* verify last vertex as well if this is a quad */ if (is_degenerate == 0 && nr_verts == 4) { if (equals_v3v3(verts[3], verts[0]) || equals_v3v3(verts[3], verts[1]) || equals_v3v3(verts[3], verts[2]) || equals_v2v2(tex_coords[3], tex_coords[0]) || equals_v2v2(tex_coords[3], tex_coords[1]) || equals_v2v2(tex_coords[3], tex_coords[2])) @@ -2654,7 +2654,7 @@ void DM_calc_auto_bump_scale(DerivedMesh *dm) is_degenerate = 1; } - // verify the winding is consistent + /* verify the winding is consistent */ if (is_degenerate == 0) { float prev_edge[2]; int is_signed = 0; @@ -2681,11 +2681,11 @@ void DM_calc_auto_bump_scale(DerivedMesh *dm) } } - // proceed if not a degenerate face + /* proceed if not a degenerate face */ if (is_degenerate == 0) { int nr_tris_to_pile = 0; - // quads split at shortest diagonal - int offs = 0; // initial triangulation is 0,1,2 and 0, 2, 3 + /* quads split at shortest diagonal */ + int offs = 0; /* initial triangulation is 0,1,2 and 0, 2, 3 */ if (nr_verts == 4) { float pos_len_diag0, pos_len_diag1; float vtmp[3]; @@ -2743,7 +2743,7 @@ void DM_calc_auto_bump_scale(DerivedMesh *dm) } } - // finalize + /* finalize */ { const float avg_area_ratio = (nr_accumulated > 0) ? ((float)(dsum / nr_accumulated)) : 1.0f; const float use_as_render_bump_scale = sqrtf(avg_area_ratio); // use width of average surface ratio as your bump scale diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 8d1707725b5..af6583fd726 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -134,7 +134,7 @@ void BKE_action_make_local(bAction *act) if (act->id.lib == NULL) return; - // XXX: double-check this; it used to be just single-user check, but that was when fake-users were still default + /* XXX: double-check this; it used to be just single-user check, but that was when fake-users were still default */ if ((act->id.flag & LIB_FAKEUSER) && (act->id.us <= 1)) { id_clear_lib_data(bmain, &act->id); return; @@ -547,7 +547,7 @@ void BKE_pose_copy_data(bPose **dst, bPose *src, int copycon) outPose->ikparam = MEM_dupallocN(src->ikparam); for (pchan = outPose->chanbase.first; pchan; pchan = pchan->next) { - // TODO: rename this argument... + /* TODO: rename this argument... */ if (copycon) { copy_constraints(&listb, &pchan->constraints, TRUE); // copy_constraints NULLs listb pchan->constraints = listb; @@ -807,7 +807,7 @@ void framechange_poses_clear_unkeyed(void) bPoseChannel *pchan; /* This needs to be done for each object that has a pose */ - // TODO: proxies may/may not be correctly handled here... (this needs checking) + /* TODO: proxies may/may not be correctly handled here... (this needs checking) */ for (ob = G.main->object.first; ob; ob = ob->id.next) { /* we only need to do this on objects with a pose */ if ( (pose = ob->pose) ) { @@ -907,7 +907,7 @@ void calc_action_range(const bAction *act, float *start, float *end, short incl_ float nmin, nmax; /* get extents for this curve */ - // TODO: allow enabling/disabling this? + /* TODO: allow enabling/disabling this? */ calc_fcurve_range(fcu, &nmin, &nmax, FALSE, TRUE); /* compare to the running tally */ @@ -949,7 +949,7 @@ void calc_action_range(const bAction *act, float *start, float *end, short incl_ } break; - // TODO: function modifier may need some special limits + /* TODO: function modifier may need some special limits */ default: /* all other standard modifiers are on the infinite range... */ min = MINAFRAMEF; @@ -1129,7 +1129,7 @@ void BKE_pose_copy_result(bPose *to, bPose *from) bPoseChannel *pchanto, *pchanfrom; if (to == NULL || from == NULL) { - printf("pose result copy error to:%p from:%p\n", (void *)to, (void *)from); // debug temp + printf("pose result copy error to:%p from:%p\n", (void *)to, (void *)from); /* debug temp */ return; } @@ -1378,12 +1378,12 @@ static float stridechannel_frame(Object *ob, float sizecorr, bActionStrip *strip /* now we need to go pdist further (or less) on cu path */ where_on_path(ob, (pathdist) / path->totdist, vec1, dir); /* vec needs size 4 */ if (pdistNewNormalized <= 1) { - // search for correction in positive path-direction + /* search for correction in positive path-direction */ where_on_path(ob, pdistNewNormalized, vec2, dir); /* vec needs size 4 */ sub_v3_v3v3(stride_offset, vec2, vec1); } else { - // we reached the end of the path, search backwards instead + /* we reached the end of the path, search backwards instead */ where_on_path(ob, (pathdist - pdist) / path->totdist, vec2, dir); /* vec needs size 4 */ sub_v3_v3v3(stride_offset, vec1, vec2); } diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 52399801691..16ff1646f43 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -86,24 +86,24 @@ void animviz_settings_init(bAnimVizSettings *avs) /* sanity check */ if (avs == NULL) return; - + /* ghosting settings */ avs->ghost_bc = avs->ghost_ac = 10; - - avs->ghost_sf = 1; // xxx - take from scene instead? - avs->ghost_ef = 250; // xxx - take from scene instead? - + + avs->ghost_sf = 1; /* xxx - take from scene instead? */ + avs->ghost_ef = 250; /* xxx - take from scene instead? */ + avs->ghost_step = 1; - - + + /* path settings */ avs->path_bc = avs->path_ac = 10; - - avs->path_sf = 1; // xxx - take from scene instead? - avs->path_ef = 250; // xxx - take from scene instead? - + + avs->path_sf = 1; /* xxx - take from scene instead? */ + avs->path_ef = 250; /* xxx - take from scene instead? */ + avs->path_viewflag = (MOTIONPATH_VIEW_KFRAS | MOTIONPATH_VIEW_KFNOS); - + avs->path_step = 1; } @@ -246,7 +246,7 @@ typedef struct MPathTarget { /* get list of motion paths to be baked for the given object * - assumes the given list is ready to be used */ -// TODO: it would be nice in future to be able to update objects dependent on these bones too? +/* TODO: it would be nice in future to be able to update objects dependent on these bones too? */ void animviz_get_object_motionpaths(Object *ob, ListBase *targets) { MPathTarget *mpt; @@ -309,7 +309,9 @@ static void motionpaths_calc_optimise_depsgraph(Scene *scene, ListBase *targets) BLI_addhead(&scene->base, base); mpt->ob->flag |= BA_TEMP_TAG; - break; // we really don't need to continue anymore once this happens, but this line might really 'break' + + /* we really don't need to continue anymore once this happens, but this line might really 'break' */ + break; } } } @@ -328,17 +330,17 @@ static void motionpaths_calc_update_scene(Scene *scene) DAG_scene_update_flags(G.main, scene, scene->lay, TRUE); /* find the last object with the tag - * - all those afterwards are assumed to not be relevant for our calculations + * - all those afterwards are assumed to not be relevant for our calculations */ - // optimize further by moving out... + /* optimize further by moving out... */ for (base = scene->base.first; base; base = base->next) { if (base->object->flag & BA_TEMP_TAG) last = base; } /* perform updates for tagged objects */ - // XXX: this will break if rigs depend on scene or other data that - // is animated but not attached to/updatable from objects + /* XXX: this will break if rigs depend on scene or other data that + * is animated but not attached to/updatable from objects */ for (base = scene->base.first; base; base = base->next) { /* update this object */ BKE_object_handle_update(scene, base->object); @@ -353,7 +355,7 @@ static void motionpaths_calc_update_scene(Scene *scene) * that doesn't force complete update, but for now, this is the * most accurate way! */ - BKE_scene_update_for_newframe(G.main, scene, scene->lay); // XXX this is the best way we can get anything moving + BKE_scene_update_for_newframe(G.main, scene, scene->lay); /* XXX this is the best way we can get anything moving */ #endif } @@ -401,9 +403,9 @@ static void motionpaths_calc_bake_targets(Scene *scene, ListBase *targets) /* Perform baking of the given object's and/or its bones' transforms to motion paths * - scene: current scene * - ob: object whose flagged motionpaths should get calculated - * - recalc: whether we need to + * - recalc: whether we need to */ -// TODO: include reports pointer? +/* TODO: include reports pointer? */ void animviz_calc_motionpaths(Scene *scene, ListBase *targets) { MPathTarget *mpt; @@ -418,9 +420,9 @@ void animviz_calc_motionpaths(Scene *scene, ListBase *targets) cfra = CFRA; sfra = efra = cfra; - // TODO: this method could be improved... - // 1) max range for standard baking - // 2) minimum range for recalc baking (i.e. between keyframes, but how?) + /* TODO: this method could be improved... + * 1) max range for standard baking + * 2) minimum range for recalc baking (i.e. between keyframes, but how?) */ for (mpt = targets->first; mpt; mpt = mpt->next) { /* try to increase area to do (only as much as needed) */ sfra = MIN2(sfra, mpt->mpath->start_frame); @@ -429,7 +431,7 @@ void animviz_calc_motionpaths(Scene *scene, ListBase *targets) if (efra <= sfra) return; /* optimize the depsgraph for faster updates */ - // TODO: whether this is used should depend on some setting for the level of optimisations used + /* TODO: whether this is used should depend on some setting for the level of optimisations used */ motionpaths_calc_optimise_depsgraph(scene, targets); /* calculate path over requested range */ diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 943bad35cf2..8e8c98a38e4 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -76,9 +76,9 @@ short id_type_can_have_animdata(ID *id) /* sanity check */ if (id == NULL) return 0; - + /* Only some ID-blocks have this info for now */ - // TODO: finish adding this for the other blocktypes + /* TODO: finish adding this for the other blocktypes */ switch (GS(id->name)) { /* has AnimData */ case ID_OB: @@ -231,7 +231,7 @@ void BKE_free_animdata(ID *id) free_fcurves(&adt->drivers); /* free overrides */ - // TODO... + /* TODO... */ /* free animdata now */ MEM_freeN(adt); @@ -334,7 +334,7 @@ void BKE_animdata_make_local(AnimData *adt) if (adt->remap && adt->remap->target) BKE_action_make_local(adt->remap->target); /* Drivers */ - // TODO: need to remap the ID-targets too? + /* TODO: need to remap the ID-targets too? */ /* NLA Data */ for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) @@ -505,8 +505,8 @@ void BKE_animdata_separate_by_basepath(ID *srcID, ID *dstID, ListBase *basepaths else if (dstAdt->action == srcAdt->action) { printf("Argh! Source and Destination share animation! ('%s' and '%s' both use '%s') Making new empty action\n", srcID->name, dstID->name, srcAdt->action->id.name); - - // TODO: review this... + + /* TODO: review this... */ id_us_min(&dstAdt->action->id); dstAdt->action = add_empty_action(dstAdt->action->id.name + 2); } @@ -534,9 +534,9 @@ void BKE_animdata_separate_by_basepath(ID *srcID, ID *dstID, ListBase *basepaths /* just need to change lists */ BLI_remlink(&srcAdt->drivers, fcu); BLI_addtail(&dstAdt->drivers, fcu); - - // TODO: add depsgraph flushing calls? - + + /* TODO: add depsgraph flushing calls? */ + /* can stop now, as moved already */ break; } @@ -603,7 +603,7 @@ static char *rna_path_rename_fix(ID *owner_id, const char *prefix, const char *o BLI_dynstr_free(ds); /* check if the new path will solve our problems */ - // TODO: will need to check whether this step really helps in practice + /* TODO: will need to check whether this step really helps in practice */ if (!verify_paths || check_rna_path_is_valid(owner_id, newPath)) { /* free the old path, and return the new one, since we've solved the issues */ MEM_freeN(oldpath); @@ -907,7 +907,7 @@ void BKE_all_animdata_fix_paths_rename(ID *ref_id, const char *prefix, const cha /* Finding Tools --------------------------- */ /* Find the first path that matches the given criteria */ -// TODO: do we want some method to perform partial matches too? +/* TODO: do we want some method to perform partial matches too? */ KS_Path *BKE_keyingset_find_path(KeyingSet *ks, ID *id, const char group_name[], const char rna_path[], int array_index, int UNUSED(group_mode)) { KS_Path *ksp; @@ -936,7 +936,7 @@ KS_Path *BKE_keyingset_find_path(KeyingSet *ks, ID *id, const char group_name[], /* group */ if (group_name) { - // FIXME: these checks need to be coded... for now, it's not too important though + /* FIXME: these checks need to be coded... for now, it's not too important though */ } /* if all aspects are ok, return */ @@ -1019,7 +1019,7 @@ KS_Path *BKE_keyingset_add_path(KeyingSet *ks, ID *id, const char group_name[], ksp->idtype = GS(id->name); /* just copy path info */ - // TODO: should array index be checked too? + /* TODO: should array index be checked too? */ ksp->rna_path = BLI_strdupn(rna_path, strlen(rna_path)); ksp->array_index = array_index; @@ -1116,11 +1116,13 @@ void BKE_keyingsets_free(ListBase *list) static short animsys_remap_path(AnimMapper *UNUSED(remap), char *path, char **dst) { /* is there a valid remapping table to use? */ - //if (remap) { - /* find a matching entry... to use to remap */ - // ...TODO... - //} - +#if 0 + if (remap) { + /* find a matching entry... to use to remap */ + /* ...TODO... */ + } +#endif + /* nothing suitable found, so just set dst to look at path (i.e. no alloc/free needed) */ *dst = path; return 0; @@ -1216,8 +1218,8 @@ static short animsys_write_rna_setting(PointerRNA *ptr, char *path, int array_in } else { /* failed to get path */ - // XXX don't tag as failed yet though, as there are some legit situations (Action Constraint) - // where some channels will not exist, but shouldn't lock up Action + /* XXX don't tag as failed yet though, as there are some legit situations (Action Constraint) + * where some channels will not exist, but shouldn't lock up Action */ if (G.debug & G_DEBUG) { printf("Animato: Invalid path. ID = '%s', '%s[%d]'\n", (ptr && ptr->id.data) ? (((ID *)ptr->id.data)->name + 2) : "<No ID>", @@ -1425,11 +1427,11 @@ static void nlastrip_evaluate_controls(NlaStrip *strip, float ctime) animsys_evaluate_fcurves(&strip_ptr, &strip->fcurves, NULL, ctime); } - /* if user can control the evaluation time (using F-Curves), consider the option which allows this time to be clamped + /* if user can control the evaluation time (using F-Curves), consider the option which allows this time to be clamped * to lie within extents of the action-clip, so that a steady changing rate of progress through several cycles of the clip * can be achieved easily */ - // NOTE: if we add any more of these special cases, we better group them up nicely... + /* NOTE: if we add any more of these special cases, we better group them up nicely... */ if ((strip->flag & NLASTRIP_FLAG_USR_TIME) && (strip->flag & NLASTRIP_FLAG_USR_TIME_CYCLIC)) strip->strip_time = fmod(strip->strip_time - strip->actstart, strip->actend - strip->actstart); } @@ -1511,7 +1513,7 @@ NlaEvalStrip *nlastrips_ctime_get_strip(ListBase *list, ListBase *strips, short * - skip if no influence (i.e. same effect as muting the strip) * - negative influence is not supported yet... how would that be defined? */ - // TODO: this sounds a bit hacky having a few isolated F-Curves stuck on some data it operates on... + /* TODO: this sounds a bit hacky having a few isolated F-Curves stuck on some data it operates on... */ nlastrip_evaluate_controls(estrip, ctime); if (estrip->influence <= 0.0f) return NULL; @@ -1668,7 +1670,7 @@ static void nlaevalchan_accumulate(NlaEvalChannel *nec, NlaEvalStrip *nes, short break; case NLASTRIP_MODE_REPLACE: - default: // TODO: do we really want to blend by default? it seems more uses might prefer add... + default: /* TODO: do we really want to blend by default? it seems more uses might prefer add... */ /* do linear interpolation * - the influence of the accumulated data (elsewhere, that is called dstweight) * is 1 - influence, since the strip's influence is srcweight @@ -1864,7 +1866,7 @@ static void nlastrip_evaluate_transition(PointerRNA *ptr, ListBase *channels, Li tmp_nes = *nes; /* evaluate these strips into a temp-buffer (tmp_channels) */ - // FIXME: modifier evalation here needs some work... + /* FIXME: modifier evalation here needs some work... */ /* first strip */ tmp_nes.strip_mode = NES_TIME_TRANSITION_START; tmp_nes.strip = s1; @@ -1928,11 +1930,11 @@ static void nlastrip_evaluate_meta(PointerRNA *ptr, ListBase *channels, ListBase void nlastrip_evaluate(PointerRNA *ptr, ListBase *channels, ListBase *modifiers, NlaEvalStrip *nes) { NlaStrip *strip = nes->strip; - + /* to prevent potential infinite recursion problems (i.e. transition strip, beside meta strip containing a transition * several levels deep inside it), we tag the current strip as being evaluated, and clear this when we leave */ - // TODO: be careful with this flag, since some edit tools may be running and have set this while animplayback was running + /* TODO: be careful with this flag, since some edit tools may be running and have set this while animplayback was running */ if (strip->flag & NLASTRIP_FLAG_EDIT_TOUCHED) return; strip->flag |= NLASTRIP_FLAG_EDIT_TOUCHED; @@ -1997,7 +1999,7 @@ void nladata_flush_channels(ListBase *channels) RNA_property_enum_set(ptr, prop, (int)value); break; default: - // can't do anything with other types of property.... + /* can't do anything with other types of property.... */ break; } } @@ -2081,7 +2083,7 @@ static void animsys_evaluate_nla(ListBase *echannels, PointerRNA *ptr, AnimData } else { /* special case - evaluate as if there isn't any NLA data */ - // TODO: this is really just a stop-gap measure... + /* TODO: this is really just a stop-gap measure... */ animsys_evaluate_action(ptr, adt->action, adt->remap, ctime); return; } @@ -2107,10 +2109,10 @@ static void animsys_evaluate_nla(ListBase *echannels, PointerRNA *ptr, AnimData static void animsys_calculate_nla(PointerRNA *ptr, AnimData *adt, float ctime) { ListBase echannels = {NULL, NULL}; - - // TODO: need to zero out all channels used, otherwise we have problems with threadsafety - // and also when the user jumps between different times instead of moving sequentially... - + + /* TODO: need to zero out all channels used, otherwise we have problems with threadsafety + * and also when the user jumps between different times instead of moving sequentially... */ + /* evaluate the NLA stack, obtaining a set of values to flush */ animsys_evaluate_nla(&echannels, ptr, adt, ctime); @@ -2130,9 +2132,9 @@ static void animsys_calculate_nla(PointerRNA *ptr, AnimData *adt, float ctime) #if 0 AnimOverride *BKE_animsys_validate_override(PointerRNA *UNUSED(ptr), char *UNUSED(path), int UNUSED(array_index)) { - // FIXME: need to define how to get overrides + /* FIXME: need to define how to get overrides */ return NULL; -} +} #endif /* -------------------- */ @@ -2202,7 +2204,7 @@ void BKE_animsys_evaluate_animdata(Scene *scene, ID *id, AnimData *adt, float ct * - NLA before Active Action, as Active Action behaves as 'tweaking track' * that overrides 'rough' work in NLA */ - // TODO: need to double check that this all works correctly + /* TODO: need to double check that this all works correctly */ if ((recalc & ADT_RECALC_ANIM) || (adt->recalc & ADT_RECALC_ANIM)) { /* evaluate NLA data */ if ((adt->nla_tracks.first) && !(adt->flag & ADT_NLA_EVAL_OFF)) { diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 5822b296a8a..c10b1e2d4f4 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -2049,7 +2049,8 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o cross_v3_v3v3(raxis, rmat[1], splineVec); rangle = dot_v3v3(rmat[1], splineVec); - rangle = acos(MAX2(-1.0f, MIN2(1.0f, rangle))); + CLAMP(rangle, -1.0f, 1.0f); + rangle = acosf(rangle); /* multiply the magnitude of the angle by the influence of the constraint to * control the influence of the SplineIK effect diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index a2bf42a39e1..e89b82138e3 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -303,8 +303,8 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath //setscreen(G.curscreen); } - // FIXME: this version patching should really be part of the file-reading code, - // but we still get too many unrelated data-corruption crashes otherwise... + /* FIXME: this version patching should really be part of the file-reading code, + * but we still get too many unrelated data-corruption crashes otherwise... */ if (G.main->versionfile < 250) do_versions_ipos_to_animato(G.main); diff --git a/source/blender/blenkernel/intern/bmfont.c b/source/blender/blenkernel/intern/bmfont.c index e1f4e45e9c3..722dc1834dd 100644 --- a/source/blender/blenkernel/intern/bmfont.c +++ b/source/blender/blenkernel/intern/bmfont.c @@ -96,9 +96,9 @@ void readBitmapFontVersion0(ImBuf * ibuf, unsigned char * rect, int step) ysize = (bytes + (ibuf->x - 1)) / ibuf->x; if (ysize < ibuf->y) { - // we're first going to copy all data into a liniar buffer. - // step can be 4 or 1 bytes, and the data is not sequential because - // the bitmap was flipped vertically. + /* we're first going to copy all data into a liniar buffer. + * step can be 4 or 1 bytes, and the data is not sequential because + * the bitmap was flipped vertically. */ buffer = MEM_mallocN(bytes, "readBitmapFontVersion0:buffer"); @@ -107,18 +107,18 @@ void readBitmapFontVersion0(ImBuf * ibuf, unsigned char * rect, int step) buffer[i] = rect[index]; index += step; if (index >= linelength) { - // we've read one line, no skip to the line *before* that + /* we've read one line, no skip to the line *before* that */ rect -= linelength; index -= linelength; } } - // we're now going to endian convert the data + /* we're now going to endian convert the data */ bmfont = MEM_mallocN(bytes, "readBitmapFontVersion0:bmfont"); index = 0; - // first read the header + /* first read the header */ bmfont->magic[0] = buffer[index++]; bmfont->magic[1] = buffer[index++]; bmfont->magic[2] = buffer[index++]; @@ -151,16 +151,16 @@ void readBitmapFontVersion0(ImBuf * ibuf, unsigned char * rect, int step) printf("bytes = %d\n", bytes); } - // we've read the data from the image. Now we're going - // to crop the image vertically so only the bitmap data - // remains visible - + /* we've read the data from the image. Now we're going + * to crop the image vertically so only the bitmap data + * remains visible */ + ibuf->y -= ysize; ibuf->userdata = bmfont; ibuf->userflags |= IB_BITMAPFONT; if (ibuf->planes < 32) { - // we're going to fake alpha here: + /* we're going to fake alpha here: */ calcAlpha(ibuf); } } @@ -176,32 +176,32 @@ void detectBitmapFont(ImBuf *ibuf) int i; if (ibuf != NULL && ibuf->rect != NULL) { - // bitmap must have an x size that is a power of two + /* bitmap must have an x size that is a power of two */ if (is_power_of_two(ibuf->x)) { rect = (unsigned char *) (ibuf->rect + (ibuf->x * (ibuf->y - 1))); - // printf ("starts with: %s %c %c %c %c\n", rect, rect[0], rect[1], rect[2], rect[3]); + /* printf ("starts with: %s %c %c %c %c\n", rect, rect[0], rect[1], rect[2], rect[3]); */ if (rect[0] == 'B' && rect[1] == 'F' && rect[2] == 'N' && rect[3] == 'T') { - // printf("found 8bit font !\n"); - // round y size down - // do the 8 bit font stuff. (not yet) + /* printf("found 8bit font !\n"); + * round y size down + * do the 8 bit font stuff. (not yet) */ } else { - // we try all 4 possible combinations + /* we try all 4 possible combinations */ for (i = 0; i < 4; i++) { if (rect[0] == 'B' && rect[4] == 'F' && rect[8] == 'N' && rect[12] == 'T') { - // printf("found 24bit font !\n"); - // We're going to parse the file: - + /* printf("found 24bit font !\n"); + * We're going to parse the file: */ + version = (rect[16] << 8) | rect[20]; - + if (version == 0) { readBitmapFontVersion0(ibuf, rect, 4); } else { printf("detectBitmapFont :Unsupported version %d\n", version); } - - // on succes ibuf->userdata points to the bitmapfont + + /* on succes ibuf->userdata points to the bitmapfont */ if (ibuf->userdata) { break; } @@ -221,23 +221,23 @@ int locateGlyph(bmFont *bmfont, unsigned short unicode) min = 0; max = bmfont->glyphcount; while (1) { - // look halfway for glyph + /* look halfway for glyph */ current = (min + max) >> 1; if (bmfont->glyphs[current].unicode == unicode) { break; } else if (bmfont->glyphs[current].unicode < unicode) { - // have to move up + /* have to move up */ min = current; } else { - // have to move down + /* have to move down */ max = current; } - + if (max - min <= 1) { - // unable to locate glyph + /* unable to locate glyph */ current = 0; break; } @@ -278,7 +278,7 @@ void matrixGlyph(ImBuf * ibuf, unsigned short unicode, *centerx = bmfont->glyphs[0].locx / (float) ibuf->x; *centery = (ibuf->y - bmfont->glyphs[0].locy) / (float) ibuf->y; - // 2.0 units is the default size of an object + /* 2.0 units is the default size of an object */ *movey = 1.0f - *sizey + 2.0f * (bmfont->glyphs[index].ofsy - bmfont->glyphs[0].ofsy) / (float) bmfont->glyphs[0].sizey; *movex = *sizex - 1.0f + 2.0f * (bmfont->glyphs[index].ofsx - bmfont->glyphs[0].ofsx) / (float) bmfont->glyphs[0].sizex; diff --git a/source/blender/blenkernel/intern/booleanops_mesh.c b/source/blender/blenkernel/intern/booleanops_mesh.c index 972793227a8..be79077bb58 100644 --- a/source/blender/blenkernel/intern/booleanops_mesh.c +++ b/source/blender/blenkernel/intern/booleanops_mesh.c @@ -44,19 +44,19 @@ CSG_DestroyMeshDescriptor( CSG_MeshDescriptor *mesh ) { - // Call mesh descriptors destroy function.... + /* Call mesh descriptors destroy function.... */ mesh->m_destroy_func(mesh); } - -// Destroy function for blender mesh internals. + +/* Destroy function for blender mesh internals. */ static void CSG_DestroyBlenderMeshInternals( CSG_MeshDescriptor *mesh ) { - // Free face and vertex iterators. - FreeMeshDescriptors(&(mesh->m_face_iterator),&(mesh->m_vertex_iterator)); + /* Free face and vertex iterators. */ + FreeMeshDescriptors(&(mesh->m_face_iterator),&(mesh->m_vertex_iterator)); } @@ -140,18 +140,18 @@ CSG_AddMeshToBlender( invert_m4_m4(inv_mat,mesh->base->object->obmat); - // Create a new blender mesh object - using 'base' as - // a template for the new object. + /* Create a new blender mesh object - using 'base' as + * a template for the new object. */ ob_new= AddNewBlenderMesh(mesh->base); me_new = ob_new->data; - // make sure the iterators are reset. + /* make sure the iterators are reset. */ mesh->m_face_iterator.Reset(mesh->m_face_iterator.it); mesh->m_vertex_iterator.Reset(mesh->m_vertex_iterator.it); - // iterate through results of operation and insert into new object - // see subsurf.c + /* iterate through results of operation and insert into new object + * see subsurf.c */ ConvertCSGDescriptorsToMeshObject( ob_new, @@ -195,8 +195,8 @@ CSG_PerformOp( output->base = mesh1->base; if (output->m_descriptor.user_face_vertex_data_size) { - // Then use the only interp function supported - success = + /* Then use the only interp function supported */ + success = CSG_PerformBooleanOperation( bool_op, op_type, @@ -225,8 +225,8 @@ CSG_PerformOp( bool_op = NULL; return 0; } - - // get the ouput mesh descriptors. + + /* get the ouput mesh descriptors. */ CSG_OutputFaceDescriptor(bool_op,&(output->m_face_iterator)); CSG_OutputVertexDescriptor(bool_op,&(output->m_vertex_iterator)); diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 741d4b729ae..53a9057116c 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -1074,7 +1074,7 @@ void BKE_brush_jitter_pos(const Scene *scene, Brush *brush, const float pos[2], const int radius = BKE_brush_size_get(scene, brush); const int diameter = 2 * radius; - // find random position within a circle of diameter 1 + /* find random position within a circle of diameter 1 */ do { rand_pos[0] = BLI_frand() - 0.5f; rand_pos[1] = BLI_frand() - 0.5f; diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c index 752bdab2c00..32ae6d04934 100644 --- a/source/blender/blenkernel/intern/bvhutils.c +++ b/source/blender/blenkernel/intern/bvhutils.c @@ -330,7 +330,7 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f } } - // Account for numerical round-off error + /* Account for numerical round-off error */ if (sqrDist < FLT_EPSILON) sqrDist = 0.0f; @@ -345,7 +345,7 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f add_v3_v3v3(z, z, y); //sub_v3_v3v3(d, p, z); copy_v3_v3(nearest, z); - // d = p - ( v0 + S * e0 + T * e1 ); + //d = p - ( v0 + S * e0 + T * e1 ); } *v = lv; *e = le; diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index f9e72be4fc1..74bfa0d60fc 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -224,26 +224,26 @@ static BVHTree *bvhtree_build_from_cloth (ClothModifierData *clmd, float epsilon verts = cloth->verts; mfaces = cloth->mfaces; - // in the moment, return zero if no faces there + /* in the moment, return zero if no faces there */ if (!cloth->numfaces) return NULL; - - // create quadtree with k=26 + + /* create quadtree with k=26 */ bvhtree = BLI_bvhtree_new(cloth->numfaces, epsilon, 4, 26); - - // fill tree + + /* fill tree */ for (i = 0; i < cloth->numfaces; i++, mfaces++) { copy_v3_v3(&co[0*3], verts[mfaces->v1].xold); copy_v3_v3(&co[1*3], verts[mfaces->v2].xold); copy_v3_v3(&co[2*3], verts[mfaces->v3].xold); - + if (mfaces->v4) copy_v3_v3(&co[3*3], verts[mfaces->v4].xold); - + BLI_bvhtree_insert(bvhtree, i, co, (mfaces->v4 ? 4 : 3)); } - - // balance tree + + /* balance tree */ BLI_bvhtree_balance(bvhtree); return bvhtree; @@ -313,23 +313,23 @@ void bvhselftree_update_from_cloth(ClothModifierData *clmd, int moving) return; mfaces = cloth->mfaces; - + // update vertex position in bvh tree if (verts && mfaces) { for (i = 0; i < cloth->numverts; i++, verts++) { copy_v3_v3(&co[0*3], verts->txold); - + // copy new locations into array if (moving) { // update moving positions copy_v3_v3(&co_moving[0*3], verts->tx); - + ret = BLI_bvhtree_update_node(bvhtree, i, co, co_moving, 1); } else { ret = BLI_bvhtree_update_node(bvhtree, i, co, NULL, 1); } - + // check if tree is already full if (!ret) break; @@ -673,7 +673,7 @@ void cloth_free_modifier_extern(ClothModifierData *clmd ) if ( cloth ) { if (G.rt > 0) printf("cloth_free_modifier_extern in\n"); - + // If our solver provides a free function, call it if ( solvers [clmd->sim_parms->solver_type].free ) { solvers [clmd->sim_parms->solver_type].free ( clmd ); @@ -691,12 +691,12 @@ void cloth_free_modifier_extern(ClothModifierData *clmd ) LinkNode *search = cloth->springs; while (search) { ClothSpring *spring = search->link; - + MEM_freeN ( spring ); search = search->next; } BLI_linklist_free(cloth->springs, NULL); - + cloth->springs = NULL; } @@ -713,11 +713,11 @@ void cloth_free_modifier_extern(ClothModifierData *clmd ) // we save our faces for collision objects if ( cloth->mfaces ) MEM_freeN ( cloth->mfaces ); - + if (cloth->edgehash) BLI_edgehash_free ( cloth->edgehash, NULL ); - - + + /* if (clmd->clothObject->facemarks) MEM_freeN(clmd->clothObject->facemarks); @@ -875,10 +875,10 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d cloth_from_mesh ( clmd, dm ); - // create springs + // create springs clmd->clothObject->springs = NULL; clmd->clothObject->numsprings = -1; - + if ( clmd->sim_parms->shapekey_rest ) shapekey_rest = dm->getVertDataArray ( dm, CD_CLOTH_ORCO ); @@ -1127,13 +1127,13 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) for (i = 0; i < numverts; i++) { cloth->verts[i].avg_spring_len = cloth->verts[i].avg_spring_len * 0.49f / ((float)cloth->verts[i].spring_count); } - + // shear springs for ( i = 0; i < numfaces; i++ ) { // triangle faces already have shear springs due to structural geometry if ( !mface[i].v4 ) - continue; - + continue; + spring = ( ClothSpring *) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" ); if (!spring) { @@ -1174,7 +1174,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) BLI_linklist_prepend ( &cloth->springs, spring ); } - + if (numfaces) { // bending springs search2 = cloth->springs; @@ -1187,14 +1187,14 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) while ( search ) { tspring = search->link; index2 = ( ( tspring->ij==tspring2->kl ) ? ( tspring->kl ) : ( tspring->ij ) ); - + // check for existing spring // check also if startpoint is equal to endpoint if (!BLI_edgehash_haskey(edgehash, MIN2(tspring2->ij, index2), MAX2(tspring2->ij, index2)) && (index2 != tspring2->ij)) { spring = (ClothSpring *)MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" ); - + if (!spring) { cloth_free_errorsprings(cloth, edgehash, edgelist); return 0; diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index d99c36b6c91..516de35fab3 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -226,69 +226,69 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM zero_v3(i2); zero_v3(i3); - // only handle static collisions here + /* only handle static collisions here */ if ( collpair->flag & COLLISION_IN_FUTURE ) continue; - // compute barycentric coordinates for both collision points + /* 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 + /* 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". + /* 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'). + /* 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); + /* printf("magrelVel: %f\n", magrelVel); */ - // Calculate masses of points. - // TODO + /* Calculate masses of points. + * TODO */ - // If v_n_mag < 0 the edges are approaching each other. + /* 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. + /* 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 + /* 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.01f * magrelVel, sqrtf(dot_v3v3(vrel_t_pre, vrel_t_pre))); + /* 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 = minf(clmd->coll_parms->friction * 0.01f * magrelVel, sqrtf(dot_v3v3(vrel_t_pre, vrel_t_pre))); - // Apply friction impulse. + /* Apply friction impulse. */ if ( magtangent > ALMOST_ZERO ) { normalize_v3(vrel_t_pre); - impulse = magtangent / ( 1.0f + w1*w1 + w2*w2 + w3*w3 ); // 2.0 * + impulse = magtangent / ( 1.0f + w1*w1 + w2*w2 + w3*w3 ); /* 2.0 * */ 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 - // I_c = m * v_N / 2.0 - // no 2.0 * magrelVel normally, but looks nicer DG + /* 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 ( i1, collpair->normal, w1 * impulse ); @@ -300,24 +300,24 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM VECADDMUL ( i3, 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)) - // DG: this formula ineeds to be changed for this code since we apply impulses/repulses like this: - // v += impulse; x_new = x + v; - // We don't use dt!! - // DG TODO: Fix usage of dt here! + /* Apply repulse impulse if distance too short + * I_r = -min(dt*kd, m(0, 1d/dt - v_n)) + * DG: this formula ineeds to be changed for this code since we apply impulses/repulses like this: + * v += impulse; x_new = x + v; + * We don't use dt!! + * DG TODO: Fix usage of dt here! */ spf = (float)clmd->sim_parms->stepsPerFrame / clmd->sim_parms->timescale; d = clmd->coll_parms->epsilon*8.0f/9.0f + epsilon2*8.0f/9.0f - collpair->distance; if ( ( magrelVel < 0.1f*d*spf ) && ( d > ALMOST_ZERO ) ) { repulse = MIN2 ( d*1.0f/spf, 0.1f*d*spf - magrelVel ); - // stay on the safe side and clamp repulse + /* 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.0f + w1*w1 + w2*w2 + w3*w3 ); // original 2.0 / 0.25 + 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 ); @@ -326,19 +326,19 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM result = 1; } else { - // Apply repulse impulse if distance too short - // I_r = -min(dt*kd, max(0, 1d/dt - v_n)) - // DG: this formula ineeds to be changed for this code since we apply impulses/repulses like this: - // v += impulse; x_new = x + v; - // We don't use dt!! + /* Apply repulse impulse if distance too short + * I_r = -min(dt*kd, max(0, 1d/dt - v_n)) + * DG: this formula ineeds to be changed for this code since we apply impulses/repulses like this: + * v += impulse; x_new = x + v; + * We don't use dt!! */ 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 + /* stay on the safe side and clamp repulse */ float repulse = d*1.0f/spf; - float impulse = repulse / ( 3.0 * ( 1.0f + w1*w1 + w2*w2 + w3*w3 )); // original 2.0 / 0.25 + float impulse = repulse / ( 3.0 * ( 1.0f + w1*w1 + w2*w2 + w3*w3 )); /* original 2.0 / 0.25 */ VECADDMUL ( i1, collpair->normal, impulse ); VECADDMUL ( i2, collpair->normal, impulse ); @@ -805,7 +805,7 @@ int cloth_bvh_objcollision(Object *ob, ClothModifierData * clmd, float step, flo //////////////////////////////////////////////////////////// if ( clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_SELF ) { for (l = 0; l < (unsigned int)clmd->coll_parms->self_loop_count; l++) { - // TODO: add coll quality rounds again + /* TODO: add coll quality rounds again */ BVHTreeOverlap *overlap = NULL; unsigned int result = 0; diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index c12e740958c..c2b38442a6b 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -1316,7 +1316,7 @@ static void followpath_evaluate(bConstraint *con, bConstraintOb *cob, ListBase * bFollowPathConstraint *data = con->data; /* get Object transform (loc/rot/size) to determine transformation from path */ - // TODO: this used to be local at one point, but is probably more useful as-is + /* TODO: this used to be local at one point, but is probably more useful as-is */ copy_m4_m4(obmat, cob->matrix); /* get scaling of object before applying constraint */ @@ -2163,7 +2163,7 @@ static void actcon_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintT Object workob; /* evaluate using workob */ - // FIXME: we don't have any consistent standards on limiting effects on object... + /* FIXME: we don't have any consistent standards on limiting effects on object... */ what_does_obaction(cob->ob, &workob, NULL, data->act, NULL, t); BKE_object_to_mat4(&workob, ct->matrix); } @@ -2623,7 +2623,7 @@ static void distlimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t } /* if soft-distance is enabled, start fading once owner is dist-soft from the target */ else if (data->flag & LIMITDIST_USESOFT) { - // FIXME: there's a problem with "jumping" when this kicks in + /* FIXME: there's a problem with "jumping" when this kicks in */ if (dist >= (data->dist - data->soft)) { sfac = (float)(data->soft * (1.0f - expf(-(dist - data->dist) / data->soft)) + data->dist); if (dist != 0.0f) sfac /= dist; @@ -2989,7 +2989,7 @@ static void rbj_new_data(void *cdata) { bRigidBodyJointConstraint *data = (bRigidBodyJointConstraint *)cdata; - // removed code which set target of this constraint + /* removed code which set target of this constraint */ data->type = 1; } @@ -3608,7 +3608,7 @@ static void damptrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t if (normalize_v3(tarvec) == 0.0f) { /* the target is sitting on the owner, so just make them use the same direction vectors */ - // FIXME: or would it be better to use the pure direction vector? + /* FIXME: or would it be better to use the pure direction vector? */ copy_v3_v3(tarvec, obvec); //copy_v3_v3(tarvec, track_dir_vecs[data->trackflag]); } @@ -3839,7 +3839,7 @@ static void pivotcon_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *ta } /* get rotation matrix representing the rotation of the owner */ - // TODO: perhaps we might want to include scaling based on the pivot too? + /* TODO: perhaps we might want to include scaling based on the pivot too? */ copy_m3_m4(rotMat, cob->matrix); normalize_m3(rotMat); @@ -4395,7 +4395,7 @@ static bConstraint *add_new_constraint_internal(const char *name, short type) } else { /* if no name is provided, use the generic "Const" name */ - // NOTE: any constraint type that gets here really shouldn't get added... + /* NOTE: any constraint type that gets here really shouldn't get added... */ newName = (name && name[0]) ? name : "Const"; } @@ -4435,9 +4435,9 @@ static bConstraint *add_new_constraint(Object *ob, bPoseChannel *pchan, const ch /* make this constraint the active one */ constraints_set_active(list, con); } - + /* set type+owner specific immutable settings */ - // TODO: does action constraint need anything here - i.e. spaceonce? + /* TODO: does action constraint need anything here - i.e. spaceonce? */ switch (type) { case CONSTRAINT_TYPE_CHILDOF: { diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index f551b2d18a4..8dd3b3da705 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -337,12 +337,12 @@ static void layerSwap_tface(void *data, const int *corner_indices) copy_v2_v2(uv[j], tf->uv[source_index]); - // swap pinning flags around + /* swap pinning flags around */ if (tf->unwrap & pin_flags[source_index]) { unwrap |= pin_flags[j]; } - // swap selection flags around + /* swap selection flags around */ if (tf->flag & sel_flags[source_index]) { flag |= sel_flags[j]; } diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 05a2cfee8e6..1092f877283 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -320,7 +320,7 @@ static void dag_add_driver_relation(AnimData *adt, DagForest *dag, DagNode *node DRIVER_TARGETS_USED_LOOPER(dvar) { if (dtar->id) { - // FIXME: other data types need to be added here so that they can work! + /* FIXME: other data types need to be added here so that they can work! */ if (GS(dtar->id->name) == ID_OB) { Object *ob = (Object *)dtar->id; @@ -383,11 +383,11 @@ static void dag_add_material_driver_relations(DagForest *dag, DagNode *node, Mat if (ma->adt) { dag_add_driver_relation(ma->adt, dag, node, 1); } - + /* textures */ // TODO... //dag_add_texture_driver_relations(DagForest *dag, DagNode *node, ID *id); - + /* material's nodetree */ if (ma->nodetree) { dag_add_material_nodetree_driver_relations(dag, node, ma->nodetree, ma); @@ -399,8 +399,8 @@ static void dag_add_collision_field_relation(DagForest *dag, Scene *scene, Objec Base *base; DagNode *node2; - // would be nice to have a list of colliders here - // so for now walk all objects in scene check 'same layer rule' + /* would be nice to have a list of colliders here + * so for now walk all objects in scene check 'same layer rule' */ for (base = scene->base.first; base; base = base->next) { if ((base->lay & ob->lay) && base->object->pd) { Object *ob1 = base->object; @@ -858,7 +858,7 @@ DagForest *build_dag(Main *bmain, Scene *sce, short mask) } } - // cycle detection and solving + /* cycle detection and solving */ // solve_cycles(dag); return dag; @@ -1567,7 +1567,7 @@ DagNodeQueue *get_first_ancestors(struct DagForest *dag, void *ob) node = dag_find_node(dag, ob); - // need to go over the whole dag for adj list + /* need to go over the whole dag for adj list */ nqueue = queue_create(node->ancestor_count); node1 = dag->DagNode.first; @@ -2205,8 +2205,8 @@ static int object_modifiers_use_time(Object *ob) return 1; } - // XXX: also, should check NLA strips, though for now assume that nobody uses - // that and we can omit that for performance reasons... + /* XXX: also, should check NLA strips, though for now assume that nobody uses + * that and we can omit that for performance reasons... */ } return 0; diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 2493507dca4..6e5d6ffb0e9 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -1386,17 +1386,18 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba ListBase top_capbase = {NULL, NULL}; for (dlb = dlbev.first; dlb; dlb = dlb->next) { - int i, start, steps; - float bevfac1 = MIN2(cu->bevfac1, cu->bevfac2), bevfac2 = MAX2(cu->bevfac1, cu->bevfac2); + const float bevfac1 = minf(cu->bevfac1, cu->bevfac2); + const float bevfac2 = maxf(cu->bevfac1, cu->bevfac2); float firstblend = 0.0f, lastblend = 0.0f; + int i, start, steps; - if (cu->bevfac1 - cu->bevfac2 == 0.0f) + if (bevfac2 - bevfac1 == 0.0f) continue; start = (int)(bevfac1 * (bl->nr - 1)); steps = 2 + (int)((bevfac2) * (bl->nr - 1)) - start; - firstblend = 1.0f - ((float)bevfac1 * (bl->nr - 1) - (int)((float)bevfac1 * (bl->nr - 1))); - lastblend = (float)bevfac2 * (bl->nr - 1) - (int)((float)bevfac2 * (bl->nr - 1)); + firstblend = 1.0f - (bevfac1 * (bl->nr - 1) - (int)(bevfac1 * (bl->nr - 1))); + lastblend = bevfac2 * (bl->nr - 1) - (int)(bevfac2 * (bl->nr - 1)); if (steps > bl->nr) { steps = bl->nr; diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index dd5751c5d1f..8122f9bf617 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -3417,7 +3417,9 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, sampleStrength *= sample_factor; } - else continue; + else { + continue; + } /* velocity brush, only do on main sample */ if (brush->flags & MOD_DPAINT_USES_VELOCITY && ss == 0 && brushVelocity) { diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index b32ac24084f..a4e7676c602 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -393,7 +393,7 @@ void pd_point_from_soft(Scene *scene, float *loc, float *vel, int index, Effecte // triangle - ray callback function static void eff_tri_ray_hit(void *UNUSED(userData), int UNUSED(index), const BVHTreeRay *UNUSED(ray), BVHTreeRayHit *hit) { - // whenever we hit a bounding box, we don't check further + /* whenever we hit a bounding box, we don't check further */ hit->dist = -1; hit->index = 1; } @@ -418,24 +418,24 @@ static float eff_calc_visibility(ListBase *colliders, EffectorCache *eff, Effect negate_v3_v3(norm, efd->vec_to_point); len = normalize_v3(norm); - // check all collision objects + /* check all collision objects */ for (col = colls->first; col; col = col->next) { CollisionModifierData *collmd = col->collmd; if (col->ob == eff->ob) continue; - + if (collmd->bvhtree) { BVHTreeRayHit hit; - + hit.index = -1; hit.dist = len + FLT_EPSILON; - - // check if the way is blocked + + /* check if the way is blocked */ if (BLI_bvhtree_ray_cast(collmd->bvhtree, point->loc, norm, 0.0f, &hit, eff_tri_ray_hit, NULL)>=0) { absorption= col->ob->pd->absorption; - // visibility is only between 0 and 1, calculated from 1-absorption + /* visibility is only between 0 and 1, calculated from 1-absorption */ visibility *= CLAMPIS(1.0f-absorption, 0.0f, 1.0f); if (visibility <= 0.0f) @@ -1006,7 +1006,7 @@ void pdDoEffectors(ListBase *effectors, ListBase *colliders, EffectorWeights *we do_physical_effector(eff, &efd, point, force); - // for softbody backward compatibility + /* for softbody backward compatibility */ if (point->flag & PE_WIND_AS_SPEED && impulse) { sub_v3_v3v3(temp2, force, temp1); sub_v3_v3v3(impulse, impulse, temp2); diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index d072ffb72ec..38c1709d79a 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -422,7 +422,7 @@ int binarysearch_bezt_index(BezTriple array[], float frame, int arraylen, short if (loopbreaker == (maxloop - 1)) { printf("Error: binarysearch_bezt_index() was taking too long\n"); - // include debug info + /* include debug info */ printf("\tround = %d: start = %d, end = %d, arraylen = %d\n", loopbreaker, start, end, arraylen); } @@ -634,9 +634,9 @@ short fcurve_are_keyframes_usable(FCurve *fcu) /* if it has modifiers, none of these should "drastically" alter the curve */ if (fcu->modifiers.first) { FModifier *fcm; - + /* check modifiers from last to first, as last will be more influential */ - // TODO: optionally, only check modifier if it is the active one... + /* TODO: optionally, only check modifier if it is the active one... */ for (fcm = fcu->modifiers.last; fcm; fcm = fcm->prev) { /* ignore if muted/disabled */ if (fcm->flag & (FMODIFIER_FLAG_DISABLED | FMODIFIER_FLAG_MUTED)) @@ -748,7 +748,7 @@ void fcurve_store_samples(FCurve *fcu, void *data, int start, int end, FcuSample int cfra; /* sanity checks */ - // TODO: make these tests report errors using reports not printf's + /* TODO: make these tests report errors using reports not printf's */ if (ELEM(NULL, fcu, sample_cb)) { printf("Error: No F-Curve with F-Curve Modifiers to Bake\n"); return; @@ -1018,7 +1018,7 @@ static float dtar_get_prop_val(ChannelDriver *driver, DriverTarget *dtar) id = dtar_id_ensure_proxy_from(dtar->id); /* error check for missing pointer... */ - // TODO: tag the specific target too as having issues + /* TODO: tag the specific target too as having issues */ if (id == NULL) { printf("Error: driver has an invalid target to use\n"); if (G.debug & G_DEBUG) printf("\tpath = %s\n", dtar->rna_path); @@ -1152,14 +1152,14 @@ static float dvar_eval_rotDiff(ChannelDriver *driver, DriverVar *dvar) } /* evaluate 'location difference' driver variable */ -// TODO: this needs to take into account space conversions... +/* TODO: this needs to take into account space conversions... */ static float dvar_eval_locDiff(ChannelDriver *driver, DriverVar *dvar) { float loc1[3] = {0.0f, 0.0f, 0.0f}; float loc2[3] = {0.0f, 0.0f, 0.0f}; /* get two location values */ - // NOTE: for now, these are all just worldspace + /* NOTE: for now, these are all just worldspace */ DRIVER_TARGETS_USED_LOOPER(dvar) { /* get pointer to loc values to store in */ @@ -1206,7 +1206,7 @@ static float dvar_eval_locDiff(ChannelDriver *driver, DriverVar *dvar) /* object */ if (dtar->flag & DTAR_FLAG_LOCALSPACE) { if (dtar->flag & DTAR_FLAG_LOCAL_CONSTS) { - // XXX: this should practically be the same as transform space... + /* XXX: this should practically be the same as transform space... */ float mat[4][4]; /* extract transform just like how the constraints do it! */ @@ -1796,7 +1796,7 @@ static int findzero(float x, float q0, float q1, float q2, float q3, float *o) c = c0; if (a != 0.0) { - // discriminant + /* discriminant */ p = b * b - 4 * a * c; if (p > 0) { diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index f981ecaf810..cefcbdd2762 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -433,7 +433,7 @@ static void fcm_envelope_verify(FModifier *fcm) /* if the are points, perform bubble-sort on them, as user may have changed the order */ if (env->data) { - // XXX todo... + /* XXX todo... */ } } @@ -463,7 +463,7 @@ static void fcm_envelope_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cv } else { /* evaltime occurs somewhere between segments */ - // TODO: implement binary search for this to make it faster? + /* TODO: implement binary search for this to make it faster? */ for (a = 0; prevfed && fed && (a < env->totvert - 1); a++, prevfed = fed, fed++) { /* evaltime occurs within the interval defined by these two envelope points */ if ((prevfed->time <= evaltime) && (fed->time >= evaltime)) { @@ -539,7 +539,7 @@ static float fcm_cycles_time(FCurve *fcu, FModifier *fcm, float UNUSED(cvalue), int cycles = 0, ofs = 0; /* check if modifier is first in stack, otherwise disable ourself... */ - // FIXME... + /* FIXME... */ if (fcm->prev) { fcm->flag |= FMODIFIER_FLAG_DISABLED; return evaltime; @@ -883,7 +883,7 @@ static void fcm_stepped_new_data(void *mdata) FMod_Stepped *data = (FMod_Stepped *)mdata; /* just need to set the step-size to 2-frames by default */ - // XXX: or would 5 be more normal? + /* XXX: or would 5 be more normal? */ data->step_size = 2.0f; } @@ -1005,7 +1005,7 @@ FModifier *add_fmodifier(ListBase *modifiers, int type) /* special checks for whether modifier can be added */ if ((modifiers->first) && (type == FMODIFIER_TYPE_CYCLES)) { /* cycles modifier must be first in stack, so for now, don't add if it can't be */ - // TODO: perhaps there is some better way, but for now, + /* TODO: perhaps there is some better way, but for now, */ printf("Error: Cannot add 'Cycles' modifier to F-Curve, as 'Cycles' modifier can only be first in stack.\n"); return NULL; } @@ -1104,7 +1104,7 @@ int remove_fmodifier(ListBase *modifiers, FModifier *fcm) return 1; } else { - // XXX this case can probably be removed some day, as it shouldn't happen... + /* XXX this case can probably be removed some day, as it shouldn't happen... */ printf("remove_fmodifier() - no modifier stack given\n"); MEM_freeN(fcm); return 0; @@ -1343,7 +1343,7 @@ void fcurve_bake_modifiers(FCurve *fcu, int start, int end) ChannelDriver *driver; /* sanity checks */ - // TODO: make these tests report errors using reports not printf's + /* TODO: make these tests report errors using reports not printf's */ if (ELEM(NULL, fcu, fcu->modifiers.first)) { printf("Error: No F-Curve with F-Curve Modifiers to Bake\n"); return; diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 061530965ef..050f921998d 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -133,7 +133,7 @@ struct TmpFont *BKE_vfont_find_tmpfont(VFont *vfont) if (vfont == NULL) return NULL; - // Try finding the font from font list + /* Try finding the font from font list */ tmpfnt = ttfdata.first; while (tmpfnt) { if (tmpfnt->vfont == vfont) @@ -150,28 +150,28 @@ static VFontData *vfont_get_data(Main *bmain, VFont *vfont) if (vfont == NULL) return NULL; - // Try finding the font from font list + /* Try finding the font from font list */ tmpfnt = BKE_vfont_find_tmpfont(vfont); - - // And then set the data + + /* And then set the data */ if (!vfont->data) { PackedFile *pf; - + if (strcmp(vfont->name, FO_BUILTIN_NAME) == 0) { pf = get_builtin_packedfile(); } else { if (vfont->packedfile) { pf = vfont->packedfile; - - // We need to copy a tmp font to memory unless it is already there + + /* We need to copy a tmp font to memory unless it is already there */ if (!tmpfnt) { tpf = MEM_callocN(sizeof(*tpf), "PackedFile"); tpf->data = MEM_mallocN(pf->size, "packFile"); tpf->size = pf->size; memcpy(tpf->data, pf->data, pf->size); - - // Add temporary packed file to globals + + /* Add temporary packed file to globals */ tmpfnt = (struct TmpFont *) MEM_callocN(sizeof(struct TmpFont), "temp_font"); tmpfnt->pf = tpf; tmpfnt->vfont = vfont; @@ -183,8 +183,8 @@ static VFontData *vfont_get_data(Main *bmain, VFont *vfont) if (!tmpfnt) { tpf = newPackedFile(NULL, vfont->name, ID_BLEND_PATH(bmain, &vfont->id)); - - // Add temporary packed file to globals + + /* Add temporary packed file to globals */ tmpfnt = (struct TmpFont *) MEM_callocN(sizeof(struct TmpFont), "temp_font"); tmpfnt->pf = tpf; tmpfnt->vfont = vfont; @@ -251,21 +251,21 @@ VFont *BKE_vfont_load(Main *bmain, const char *name) } BLI_strncpy(vfont->name, name, sizeof(vfont->name)); - // if autopack is on store the packedfile in de font structure + /* if autopack is on store the packedfile in de font structure */ if (!is_builtin && (G.fileflags & G_AUTOPACK)) { vfont->packedfile = pf; } - - // Do not add FO_BUILTIN_NAME to temporary listbase + + /* Do not add FO_BUILTIN_NAME to temporary listbase */ if (strcmp(filename, FO_BUILTIN_NAME)) { tmpfnt = (struct TmpFont *) MEM_callocN(sizeof(struct TmpFont), "temp_font"); tmpfnt->pf = tpf; tmpfnt->vfont = vfont; BLI_addtail(&ttfdata, tmpfnt); - } + } } - - // Free the packed file + + /* Free the packed file */ if (!vfont || vfont->packedfile != pf) { freePackedFile(pf); } @@ -390,11 +390,11 @@ static void buildchar(Main *bmain, Curve *cu, unsigned long character, CharInfo che = find_vfont_char(vfd, character); - // Select the glyph data + /* Select the glyph data */ if (che) nu1 = che->nurbsbase.first; - // Create the character + /* Create the character */ while (nu1) { bezt1 = nu1->bezt; if (bezt1) { @@ -508,7 +508,7 @@ int BKE_vfont_select_get(Object *ob, int *start, int *end) static float char_width(Curve *cu, VChar *che, CharInfo *info) { - // The character wasn't found, propably ascii = 0, then the width shall be 0 as well + /* The character wasn't found, propably ascii = 0, then the width shall be 0 as well */ if (che == NULL) { return 0.0f; } @@ -543,20 +543,20 @@ struct chartrans *BKE_vfont_to_curve(Main *bmain, Scene *scene, Object *ob, int if (ob->type != OB_FONT) return NULL; - // Set font data + /* Set font data */ cu = (Curve *) ob->data; vfont = cu->vfont; - + if (cu->str == NULL) return NULL; if (vfont == NULL) return NULL; - // Create unicode string + /* Create unicode string */ utf8len = BLI_strlen_utf8(cu->str); mem = MEM_callocN(((utf8len + 1) * sizeof(wchar_t)), "convertedmem"); - + BLI_strncpy_wchar_from_utf8(mem, cu->str, utf8len + 1); - // Count the wchar_t string length + /* Count the wchar_t string length */ slen = wcslen(mem); if (cu->ulheight == 0.0f) @@ -612,7 +612,7 @@ struct chartrans *BKE_vfont_to_curve(Main *bmain, Scene *scene, Object *ob, int curbox = 0; for (i = 0; i <= slen; i++) { makebreak: - // Characters in the list + /* Characters in the list */ info = &(custrinfo[i]); ascii = mem[i]; if (info->flag & CU_CHINFO_SMALLCAPS) { @@ -664,7 +664,7 @@ makebreak: twidth = char_width(cu, che, info); - // Calculate positions + /* Calculate positions */ if ((tb->w != 0.0f) && (ct->dobreak == 0) && ((xof - (tb->x / cu->fsize) + twidth) * cu->fsize) > tb->w + cu->xof * cu->fsize) { // fprintf(stderr, "linewidth exceeded: %c%c%c...\n", mem[i], mem[i+1], mem[i+2]); for (j = i; j && (mem[j] != '\n') && (mem[j] != '\r') && (chartransdata[j].dobreak == 0); j--) { @@ -699,7 +699,7 @@ makebreak: yof -= linedist; - maxlen = MAX2(maxlen, (xof - tb->x / cu->fsize)); + maxlen = maxf(maxlen, (xof - tb->x / cu->fsize)); linedata[lnr] = xof - tb->x / cu->fsize; linedata2[lnr] = cnr; linedata3[lnr] = tb->w / cu->fsize; @@ -762,7 +762,7 @@ makebreak: } else wsfac = 1.0f; - // Set the width of the character + /* Set the width of the character */ twidth = char_width(cu, che, info); xof += (twidth * wsfac * (1.0f + (info->kern / 40.0f)) ) + xtrax; @@ -781,10 +781,10 @@ makebreak: if (ascii == '\n' || ascii == '\r' || ct->dobreak) cu->lines++; } - // linedata is now: width of line - // linedata2 is now: number of characters - // linedata3 is now: maxlen of that line - // linedata4 is now: number of whitespaces of line + /* linedata is now: width of line + * linedata2 is now: number of characters + * linedata3 is now: maxlen of that line + * linedata4 is now: number of whitespaces of line */ if (cu->spacemode != CU_LEFT) { ct = chartransdata; @@ -1023,7 +1023,7 @@ makebreak: /* printf("Error: Illegal material index (%d) in text object, setting to 0\n", info->mat_nr); */ info->mat_nr = 0; } - // We do not want to see any character for \n or \r + /* We do not want to see any character for \n or \r */ if (cha != '\n' && cha != '\r') buildchar(bmain, cu, cha, info, ct->xof, ct->yof, ct->rot, i); @@ -1035,8 +1035,8 @@ makebreak: { uloverlap = xtrax + 0.1f; } - // Find the character, the characters has to be in the memory already - // since character checking has been done earlier already. + /* Find the character, the characters has to be in the memory already + * since character checking has been done earlier already. */ che = find_vfont_char(vfd, cha); twidth = char_width(cu, che, info); diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index 42c7869a365..cff6ab2f125 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -33,11 +33,13 @@ #include <stddef.h> #include <string.h> +#include "BLI_utildefines.h" +#include "BLI_string.h" +#include "BLI_listbase.h" + #include "BKE_idprop.h" #include "BKE_library.h" -#include "BLI_blenlib.h" - #include "MEM_guardedalloc.h" /* IDPropertyTemplate is a union in DNA_ID.h */ @@ -122,11 +124,10 @@ IDProperty *IDP_GetIndexArray(IDProperty *prop, int index) return GETPROP(prop, index); } -IDProperty *IDP_AppendArray(IDProperty *prop, IDProperty *item) +void IDP_AppendArray(IDProperty *prop, IDProperty *item) { IDP_ResizeIDPArray(prop, prop->len + 1); IDP_SetIndexArray(prop, prop->len - 1, item); - return item; } void IDP_ResizeIDPArray(IDProperty *prop, int newlen) diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index a5e424edbf9..24269c287bb 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1230,7 +1230,7 @@ void BKE_imbuf_to_image_format(struct ImageFormatData *im_format, const ImBuf *i { BKE_imformat_defaults(im_format); - // file type + /* file type */ if (imbuf->ftype == IMAGIC) im_format->imtype = R_IMF_IMTYPE_IRIS; @@ -1311,7 +1311,7 @@ void BKE_imbuf_to_image_format(struct ImageFormatData *im_format, const ImBuf *i im_format->quality = imbuf->ftype & ~JPG_MSK; } - // planes + /* planes */ switch (imbuf->channels) { case 0: case 4: im_format->planes = R_IMF_PLANES_RGBA; diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index 4755fccff99..5b3e823f050 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -185,7 +185,7 @@ DO_INLINE void print_lfvector(float (*fLongVector)[3], unsigned int verts) /* create long vector */ DO_INLINE lfVector *create_lfvector(unsigned int verts) { - // TODO: check if memory allocation was successfull */ + /* TODO: check if memory allocation was successfull */ return (lfVector *)MEM_callocN(verts * sizeof(lfVector), "cloth_implicit_alloc_vector"); // return (lfVector *)cloth_aligned_malloc(&MEMORY_BASE, verts * sizeof(lfVector)); } @@ -529,8 +529,8 @@ DO_INLINE void del_bfmatrix(fmatrix3x3 *matrix) /* copy big matrix */ DO_INLINE void cp_bfmatrix(fmatrix3x3 *to, fmatrix3x3 *from) -{ - // TODO bounds checking +{ + // TODO bounds checking memcpy(to, from, sizeof(fmatrix3x3) * (from[0].vcount+from[0].scount)); } @@ -1239,13 +1239,13 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s, s->flags |= CLOTH_SPRING_FLAG_NEEDED; k = clmd->sim_parms->structural; - + scaling = k + s->stiffness * ABS(clmd->sim_parms->max_struct-k); - + k = scaling / (clmd->sim_parms->avg_spring_len + FLT_EPSILON); - + // TODO: verify, half verified (couldn't see error) - mul_fvector_S(stretch_force, dir, k*(length-L)); + mul_fvector_S(stretch_force, dir, k*(length-L)); VECADD(s->f, s->f, stretch_force); @@ -1833,11 +1833,11 @@ int implicit_solver(Object *ob, float frame, ClothModifierData *clmd, ListBase * for (i=0, cv=cloth->verts; i<cloth->numverts; i++, cv++) { copy_v3_v3(initial_cos[i], cv->tx); } - + // call collision function // TODO: check if "step" or "step+dt" is correct - dg do_extra_solve = cloth_bvh_objcollision(ob, clmd, step/clmd->sim_parms->timescale, dt/clmd->sim_parms->timescale); - + // copy corrected positions back to simulation for (i = 0; i < numverts; i++) { // correct velocity again, just to be sure we had to change it due to adaptive collisions diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index f51fee674cf..2fe567cc9bf 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -895,7 +895,7 @@ static char *get_rna_access(int blocktype, int adrcode, char actname[], char con /* special case for rotdiff drivers... we don't need a property for this... */ break; - // TODO... add other blocktypes... + /* TODO... add other blocktypes... */ default: printf("IPO2ANIMATO WARNING: No path for blocktype %d, adrcode %d yet\n", blocktype, adrcode); break; @@ -1588,9 +1588,9 @@ static void action_to_animdata(ID *id, bAction *act) /* ------------------------- */ -// TODO: -// - NLA group duplicators info -// - NLA curve/stride modifiers... +/* TODO: + * - NLA group duplicators info + * - NLA curve/stride modifiers... */ /* Convert NLA-Strip to new system */ static void nlastrips_to_animdata(ID *id, ListBase *strips) diff --git a/source/blender/blenkernel/intern/lamp.c b/source/blender/blenkernel/intern/lamp.c index 20e3edc7044..4782d09a7c8 100644 --- a/source/blender/blenkernel/intern/lamp.c +++ b/source/blender/blenkernel/intern/lamp.c @@ -51,7 +51,7 @@ #include "BKE_main.h" #include "BKE_node.h" -void *BKE_lamp_add(const char *name) +Lamp *BKE_lamp_add(const char *name) { Lamp *la; diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 6e6891684c9..f3ef01425dd 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1342,7 +1342,7 @@ static void lib_indirect_test_id(ID *id, Library *lib) int a; #if 0 /* XXX OLD ANIMSYS, NLASTRIPS ARE NO LONGER USED */ - // XXX old animation system! -------------------------------------- + /* XXX old animation system! -------------------------------------- */ { bActionStrip *strip; for (strip = ob->nlastrips.first; strip; strip = strip->next) { @@ -1351,7 +1351,7 @@ static void lib_indirect_test_id(ID *id, Library *lib) LIBTAG(strip->ipo); } } - // XXX: new animation system needs something like this? + /* XXX: new animation system needs something like this? */ #endif for (a = 0; a < ob->totcol; a++) { diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index de2b99fcbf9..c605f33b98f 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -1618,13 +1618,13 @@ static void decode_tfaceflag(Material *ma, int flag, int convertall) /* boolean check to see if the mesh needs a material */ static int check_tfaceneedmaterial(int flag) { - // check if the flags we have are not deprecated != than default material options - // also if only flags are visible and collision see if all objects using this mesh have this option in physics + /* check if the flags we have are not deprecated != than default material options + * also if only flags are visible and collision see if all objects using this mesh have this option in physics */ /* flag is shifted in 1 to make 0 != no flag yet (see encode_tfaceflag) */ flag -= 1; - // deprecated flags + /* deprecated flags */ flag &= ~TF_OBCOL; flag &= ~TF_SHAREDVERT; flag &= ~TF_SHAREDCOL; @@ -1632,12 +1632,12 @@ static int check_tfaceneedmaterial(int flag) /* light tface flag is ignored in GLSL mode */ flag &= ~TF_LIGHT; - // automatic detected if tex image has alpha + /* automatic detected if tex image has alpha */ flag &= ~(TF_ALPHA << 15); - // automatic detected if using texture + /* automatic detected if using texture */ flag &= ~TF_TEX; - // settings for the default NoMaterial + /* settings for the default NoMaterial */ if (flag == TF_DYNAMIC) return 0; @@ -1646,7 +1646,7 @@ static int check_tfaceneedmaterial(int flag) } /* return number of digits of an integer */ -// XXX to be optmized or replaced by an equivalent blender internal function +/* XXX to be optmized or replaced by an equivalent blender internal function */ static int integer_getdigits(int number) { int i = 0; @@ -1661,9 +1661,9 @@ static int integer_getdigits(int number) static void calculate_tface_materialname(char *matname, char *newname, int flag) { - // if flag has only light and collision and material matches those values - // you can do strcpy(name, mat_name); - // otherwise do: + /* if flag has only light and collision and material matches those values + * you can do strcpy(name, mat_name); + * otherwise do: */ int digits = integer_getdigits(flag); /* clamp the old name, remove the MA prefix and add the .TF.flag suffix * e.g. matname = "MALoooooooooooooongName"; newname = "Loooooooooooooon.TF.2" */ @@ -1736,9 +1736,9 @@ static short convert_tfacenomaterial(Main *main, Mesh *me, MTFace *tf, int flag) set_facetexture_flags(ma, tf->tpage); decode_tfaceflag(ma, flag, 1); - // the final decoding will happen after, outside the main loop - // for now store the flag into the material and change light/tex/collision - // store the flag as a negative number + /* the final decoding will happen after, outside the main loop + * for now store the flag into the material and change light/tex/collision + * store the flag as a negative number */ ma->game.flag = -flag; id_us_min((ID *)ma); } diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index fb15aa82fa2..d62b03b5060 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -407,7 +407,7 @@ static float nlastrip_get_frame_actionclip(NlaStrip *strip, float cframe, short /* reversed = play strip backwards */ if (strip->flag & NLASTRIP_FLAG_REVERSE) { - // FIXME: this won't work right with Graph Editor? + /* FIXME: this won't work right with Graph Editor? */ if (mode == NLATIME_CONVERT_MAP) { return strip->end - scale * (cframe - strip->actstart); } @@ -1154,7 +1154,7 @@ static short nlastrip_is_first(AnimData *adt, NlaStrip *strip) return 0; /* check other tracks to see if they have a strip that's earlier */ - // TODO: or should we check that the strip's track is also the first? + /* TODO: or should we check that the strip's track is also the first? */ for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) { /* only check the first strip, assuming that they're all in order */ ns = nlt->strips.first; @@ -1234,7 +1234,7 @@ void BKE_nlastrip_validate_fcurves(NlaStrip *strip) /* store path - make copy, and store that */ fcu->rna_path = BLI_strdupn("influence", 9); - // TODO: insert a few keyframes to ensure default behavior? + /* TODO: insert a few keyframes to ensure default behavior? */ } } @@ -1255,7 +1255,7 @@ void BKE_nlastrip_validate_fcurves(NlaStrip *strip) /* store path - make copy, and store that */ fcu->rna_path = BLI_strdupn("strip_time", 10); - // TODO: insert a few keyframes to ensure default behavior? + /* TODO: insert a few keyframes to ensure default behavior? */ } } } @@ -1340,7 +1340,7 @@ static void nlastrip_get_endpoint_overlaps(NlaStrip *strip, NlaTrack *track, flo /* find strips that overlap over the start/end of the given strip, * but which don't cover the entire length */ - // TODO: this scheme could get quite slow for doing this on many strips... + /* TODO: this scheme could get quite slow for doing this on many strips... */ for (nls = track->strips.first; nls; nls = nls->next) { /* check if strip overlaps (extends over or exactly on) the entire range of the strip we're validating */ if ((nls->start <= strip->start) && (nls->end >= strip->end)) { @@ -1443,7 +1443,7 @@ void BKE_nla_validate_state(AnimData *adt) /* apart from 'nothing' option which user has to explicitly choose, we don't really know if * we should be overwriting the extend setting (but assume that's what the user wanted) */ - // TODO: 1 solution is to tie this in with auto-blending... + /* TODO: 1 solution is to tie this in with auto-blending... */ if (strip->extendmode != NLASTRIP_EXTEND_NOTHING) { /* 1) First strip must be set to extend hold, otherwise, stuff before acts dodgy * 2) Only overwrite extend mode if *not* changing it will most probably result in @@ -1469,20 +1469,20 @@ void BKE_nla_validate_state(AnimData *adt) * for normal editing only (i.e. not in editmode for some strip's action), * so no checks for this are performed. */ -// TODO: maybe we should have checks for this too... +/* TODO: maybe we should have checks for this too... */ void BKE_nla_action_pushdown(AnimData *adt) { NlaStrip *strip; - + /* sanity checks */ - // TODO: need to report the error for this + /* TODO: need to report the error for this */ if (ELEM(NULL, adt, adt->action)) return; - - /* if the action is empty, we also shouldn't try to add to stack, + + /* if the action is empty, we also shouldn't try to add to stack, * as that will cause us grief down the track */ - // TODO: what about modifiers? + /* TODO: what about modifiers? */ if (action_has_motion(adt->action) == 0) { printf("BKE_nla_action_pushdown(): action has no data\n"); return; @@ -1505,7 +1505,7 @@ void BKE_nla_action_pushdown(AnimData *adt) /* not first, so extend mode can only be NLASTRIP_EXTEND_HOLD_FORWARD not NLASTRIP_EXTEND_HOLD, * so that it doesn't override strips in previous tracks */ - // FIXME: this needs to be more automated, since user can rearrange strips + /* FIXME: this needs to be more automated, since user can rearrange strips */ strip->extendmode = NLASTRIP_EXTEND_HOLD_FORWARD; } @@ -1632,8 +1632,8 @@ void BKE_nla_tweakmode_exit(AnimData *adt) if ((adt->flag & ADT_NLA_EDIT_ON) == 0) return; - // TODO: need to sync the user-strip with the new state of the action! - + /* TODO: need to sync the user-strip with the new state of the action! */ + /* for all Tracks, clear the 'disabled' flag * for all Strips, clear the 'tweak-user' flag */ diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index f0d47791374..2ba2ad7bd6e 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -223,7 +223,7 @@ void BKE_object_link_modifiers(struct Object *ob, struct Object *from) BKE_object_copy_particlesystems(ob, from); BKE_object_copy_softbody(ob, from); - // TODO: smoke?, cloth? + /* TODO: smoke?, cloth? */ } /* here we will collect all local displist stuff */ @@ -376,7 +376,7 @@ void BKE_object_unlink(Object *ob) unlink_actuators(&ob->actuators); /* check all objects: parents en bevels and fields, also from libraries */ - // FIXME: need to check all animation blocks (drivers) + /* FIXME: need to check all animation blocks (drivers) */ obt = bmain->object.first; while (obt) { if (obt->proxy == ob) @@ -1376,7 +1376,7 @@ void BKE_object_make_proxy(Object *ob, Object *target, Object *gob) BKE_object_copy_proxy_drivers(ob, target); /* skip constraints? */ - // FIXME: this is considered by many as a bug + /* FIXME: this is considered by many as a bug */ /* set object type and link to data */ ob->type = target->type; @@ -1958,8 +1958,8 @@ static void solve_parenting(Scene *scene, Object *ob, Object *par, float obmat[] break; } - // total - mul_serie_m4(tmat, totmat, ob->parentinv, + /* total */ + mul_serie_m4(tmat, totmat, ob->parentinv, NULL, NULL, NULL, NULL, NULL, NULL); mul_serie_m4(obmat, tmat, locmat, NULL, NULL, NULL, NULL, NULL, NULL); @@ -1968,10 +1968,10 @@ static void solve_parenting(Scene *scene, Object *ob, Object *par, float obmat[] } else { - // external usable originmat + /* external usable originmat */ copy_m3_m4(originmat, tmat); - // origin, voor help line + /* origin, for help line */ if ((ob->partype & PARTYPE) == PARSKEL) { copy_v3_v3(ob->orig, par->obmat[3]); } @@ -1987,7 +1987,7 @@ static int where_is_object_parslow(Object *ob, float obmat[4][4], float slowmat[ float fac1, fac2; int a; - // include framerate + /* include framerate */ fac1 = (1.0f / (1.0f + fabsf(ob->sf)) ); if (fac1 >= 1.0f) return 0; fac2 = 1.0f - fac1; @@ -2503,7 +2503,7 @@ void BKE_object_handle_update(Scene *scene, Object *ob) /* XXX new animsys warning: depsgraph tag OB_RECALC_DATA should not skip drivers, * which is only in BKE_object_where_is_calc now */ - // XXX: should this case be OB_RECALC_OB instead? + /* XXX: should this case be OB_RECALC_OB instead? */ if (ob->recalc & OB_RECALC_ALL) { if (G.debug & G_DEBUG) @@ -2539,7 +2539,7 @@ void BKE_object_handle_update(Scene *scene, Object *ob) if (adt) { /* evaluate drivers - datalevel */ - // XXX: for mesh types, should we push this to derivedmesh instead? + /* XXX: for mesh types, should we push this to derivedmesh instead? */ BKE_animsys_evaluate_animdata(scene, data_id, adt, ctime, ADT_RECALC_DRIVERS); } @@ -3163,7 +3163,7 @@ struct LinkNode *BKE_object_relational_superset(struct Scene *scene, eObjectSet /* iterate over all selected and visible objects */ for (base = scene->base.first; base; base = base->next) { if (objectSet == OB_SET_ALL) { - // as we get all anyways just add it + /* as we get all anyways just add it */ Object *ob = base->object; obrel_list_add(&links, ob); } diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index a2c89967f44..52acbeb94e5 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -132,7 +132,7 @@ int countPackedFiles(Main *bmain) bSound *sound; int count = 0; - // let's check if there are packed files... + /* let's check if there are packed files... */ for (ima = bmain->image.first; ima; ima = ima->id.next) if (ima->packedfile) count++; @@ -181,13 +181,13 @@ PackedFile *newPackedFile(ReportList *reports, const char *filename, const char //XXX waitcursor(1); - // convert relative filenames to absolute filenames - + /* convert relative filenames to absolute filenames */ + BLI_strncpy(name, filename, sizeof(name)); BLI_path_abs(name, basepath); - - // open the file - // and create a PackedFile structure + + /* open the file + * and create a PackedFile structure */ file = BLI_open(name, O_BINARY | O_RDONLY, 0); if (file <= 0) { @@ -197,8 +197,8 @@ PackedFile *newPackedFile(ReportList *reports, const char *filename, const char filelen = BLI_file_descriptor_size(file); if (filelen == 0) { - // MEM_mallocN complains about MEM_mallocN(0, "bla"); - // we don't care.... + /* MEM_mallocN complains about MEM_mallocN(0, "bla"); + * we don't care.... */ data = MEM_mallocN(1, "packFile"); } else { @@ -294,7 +294,7 @@ int writePackedFile(ReportList *reports, const char *filename, PackedFile *pf, i } } - // make sure the path to the file exists... + /* make sure the path to the file exists... */ BLI_make_existing_file(name); file = BLI_open(name, O_BINARY + O_WRONLY + O_CREAT + O_TRUNC, 0666); @@ -354,23 +354,23 @@ int checkPackedFile(const char *filename, PackedFile *pf) ret_val = PF_DIFFERS; } else { - // we'll have to compare the two... - + /* we'll have to compare the two... */ + file = BLI_open(name, O_BINARY | O_RDONLY, 0); if (file < 0) { ret_val = PF_NOFILE; } else { ret_val = PF_EQUAL; - + for (i = 0; i < pf->size; i += sizeof(buf)) { len = pf->size - i; if (len > sizeof(buf)) { len = sizeof(buf); } - + if (read(file, buf, len) != len) { - // read error ... + /* read error ... */ ret_val = PF_DIFFERS; break; } @@ -412,24 +412,24 @@ char *unpackFile(ReportList *reports, const char *abs_name, const char *local_na temp = abs_name; break; case PF_USE_LOCAL: - // if file exists use it + /* if file exists use it */ if (BLI_exists(local_name)) { temp = local_name; break; } - // else fall through and create it + /* else fall through and create it */ case PF_WRITE_LOCAL: if (writePackedFile(reports, local_name, pf, 1) == RET_OK) { temp = local_name; } break; case PF_USE_ORIGINAL: - // if file exists use it + /* if file exists use it */ if (BLI_exists(abs_name)) { temp = abs_name; break; } - // else fall through and create it + /* else fall through and create it */ case PF_WRITE_ORIGINAL: if (writePackedFile(reports, abs_name, pf, 1) == RET_OK) { temp = abs_name; diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index a1fe1f7b8a9..dcd1a797a7a 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -546,7 +546,7 @@ void psys_free(Object *ob, ParticleSystem *psys) psys->totchild = 0; } - // check if we are last non-visible particle system + /* check if we are last non-visible particle system */ for (tpsys = ob->particlesystem.first; tpsys; tpsys = tpsys->next) { if (tpsys->part) { if (ELEM(tpsys->part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) { @@ -555,7 +555,7 @@ void psys_free(Object *ob, ParticleSystem *psys) } } } - // clear do-not-draw-flag + /* clear do-not-draw-flag */ if (!nr) ob->transflag &= ~OB_DUPLIPARTS; diff --git a/source/blender/blenkernel/intern/property.c b/source/blender/blenkernel/intern/property.c index b82521504dd..46ddce4b51b 100644 --- a/source/blender/blenkernel/intern/property.c +++ b/source/blender/blenkernel/intern/property.c @@ -223,8 +223,8 @@ int compare_property(bProperty *prop, const char *str) case GPROP_FLOAT: case GPROP_TIME: - // WARNING: untested for GPROP_TIME - // function isn't used currently + /* WARNING: untested for GPROP_TIME + * function isn't used currently */ fvalue = *((float *)&prop->data); ftest = (float)atof(str); if (fvalue > ftest) return 1; diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 1113555e3bf..6f24eadd1b6 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -257,10 +257,10 @@ void BKE_scene_free(Scene *sce) /* do not free objects! */ if (sce->gpd) { -#if 0 // removed since this can be invalid memory when freeing everything - // since the grease pencil data is freed before the scene. - // since grease pencil data is not (yet?), shared between objects - // its probably safe not to do this, some save and reload will free this. +#if 0 /* removed since this can be invalid memory when freeing everything */ + /* since the grease pencil data is freed before the scene. + * since grease pencil data is not (yet?), shared between objects + * its probably safe not to do this, some save and reload will free this. */ sce->gpd->id.us--; #endif sce->gpd = NULL; @@ -952,9 +952,9 @@ static void scene_update_drivers(Main *UNUSED(bmain), Scene *scene) if (scene->adt && scene->adt->drivers.first) { BKE_animsys_evaluate_animdata(scene, &scene->id, scene->adt, ctime, ADT_RECALC_DRIVERS); } - + /* world */ - // TODO: what about world textures? but then those have nodes too... + /* TODO: what about world textures? but then those have nodes too... */ if (scene->world) { ID *wid = (ID *)scene->world; AnimData *adt = BKE_animdata_from_id(wid); @@ -1060,7 +1060,7 @@ void BKE_scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay) sound_set_cfra(sce->r.cfra); /* clear animation overrides */ - // XXX TODO... + /* XXX TODO... */ for (sce_iter = sce; sce_iter; sce_iter = sce_iter->set) { if (sce_iter->theDag == NULL) diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 6e5149d7924..2e2f0e54792 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -1848,7 +1848,7 @@ static void do_transform(Scene *scene, Sequence *seq, float UNUSED(facf0), int x TransformVars *transform = (TransformVars *)seq->effectdata; float scale_x, scale_y, translate_x, translate_y, rotate_radians; - // Scale + /* Scale */ if (transform->uniform_scale) { scale_x = scale_y = transform->ScalexIni; } @@ -1857,7 +1857,7 @@ static void do_transform(Scene *scene, Sequence *seq, float UNUSED(facf0), int x scale_y = transform->ScaleyIni; } - // Translate + /* Translate */ if (!transform->percent) { float rd_s = (scene->r.size / 100.0f); @@ -1868,8 +1868,8 @@ static void do_transform(Scene *scene, Sequence *seq, float UNUSED(facf0), int x translate_x = x * (transform->xIni / 100.0f) + (x / 2.0f); translate_y = y * (transform->yIni / 100.0f) + (y / 2.0f); } - - // Rotate + + /* Rotate */ rotate_radians = DEG2RADF(transform->rotIni); transform_image(x, y, ibuf1, out, scale_x, scale_y, translate_x, translate_y, rotate_radians, transform->interpolation); diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 78ccdc425e5..902eeefd934 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -2528,7 +2528,7 @@ static ImBuf *seq_render_strip_stack( #if 0 /* commentind since this breaks keyframing, since it resets the value on draw */ if (scene->r.cfra != cfra) { - // XXX for prefetch and overlay offset!..., very bad!!! + /* XXX for prefetch and overlay offset!..., very bad!!! */ AnimData *adt = BKE_animdata_from_id(&scene->id); BKE_animsys_evaluate_animdata(scene, &scene->id, adt, cfra, ADT_RECALC_ANIM); } diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index 464b7fda51d..f9399946570 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -120,13 +120,13 @@ void space_transform_invert(const SpaceTransform *data, float co[3]) static void space_transform_apply_normal(const SpaceTransform *data, float no[3]) { mul_mat3_m4_v3(((SpaceTransform *)data)->local2target, no); - normalize_v3(no); // TODO: could we just determine de scale value from the matrix? + normalize_v3(no); /* TODO: could we just determine de scale value from the matrix? */ } static void space_transform_invert_normal(const SpaceTransform *data, float no[3]) { mul_mat3_m4_v3(((SpaceTransform *)data)->target2local, no); - normalize_v3(no); // TODO: could we just determine de scale value from the matrix? + normalize_v3(no); /* TODO: could we just determine de scale value from the matrix? */ } /* diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index 32def1be647..ddcba509301 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -141,7 +141,7 @@ struct SmokeModifierData; /* forward declerations */ static void calcTriangleDivs(Object *ob, MVert *verts, int numverts, MFace *tris, int numfaces, int numtris, int **tridivs, float cell_len); -static void get_cell(float *p0, int res[3], float dx, float *pos, int *cell, int correct); +static void get_cell(const float p0[3], const int res[3], float dx, const float pos[3], int cell[3], int correct); static void fill_scs_points(Object *ob, DerivedMesh *dm, SmokeCollSettings *scs); #else /* WITH_SMOKE */ @@ -1977,7 +1977,7 @@ static void bresenham_linie_3D(int x1, int y1, int z1, int x2, int y2, int z2, f cb(result, input, res, pixel, tRay, correct); } -static void get_cell(float *p0, int res[3], float dx, float *pos, int *cell, int correct) +static void get_cell(const float p0[3], const int res[3], float dx, const float pos[3], int cell[3], int correct) { float tmp[3]; diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 63f0a29821f..1d6895a8c71 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -1718,15 +1718,15 @@ static int choose_winner(float*w, float* pos, float*a, float*b, float*c, float*c { float mindist, cp; int winner =1; - mindist = ABS(dot_v3v3(pos, a)); + mindist = fabsf(dot_v3v3(pos, a)); - cp = ABS(dot_v3v3(pos, b)); + cp = fabsf(dot_v3v3(pos, b)); if ( mindist < cp ) { mindist = cp; winner =2; } - cp = ABS(dot_v3v3(pos, c)); + cp = fabsf(dot_v3v3(pos, c)); if (mindist < cp ) { mindist = cp; winner =3; diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 7081a642b8a..5bad69c2e8d 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -1413,11 +1413,11 @@ int BKE_texture_dependsOnTime(const struct Tex *texture) return 1; } else if (texture->adt) { - // assume anything in adt means the texture is animated + /* assume anything in adt means the texture is animated */ return 1; } else if (texture->type == TEX_NOISE) { - // noise always varies with time + /* noise always varies with time */ return 1; } return 0; diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index 6167536fb9b..4342eb20d55 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -2315,10 +2315,10 @@ static int tracking_check_marker_margin(MovieTrackingTrack *track, MovieTracking /* margin from frame boundaries */ BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max); sub_v2_v2v2(dim, pat_max, pat_min); - margin[0] = margin[1] = MAX2(dim[0], dim[1]) / 2.0f; + margin[0] = margin[1] = maxf(dim[0], dim[1]) / 2.0f; - margin[0] = MAX2(margin[0], (float)track->margin / frame_width); - margin[1] = MAX2(margin[1], (float)track->margin / frame_height); + margin[0] = maxf(margin[0], (float)track->margin / frame_width); + margin[1] = maxf(margin[1], (float)track->margin / frame_height); /* do not track markers which are too close to boundary */ if (marker->pos[0] < margin[0] || marker->pos[0] > 1.0f - margin[0] || diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index f72942df8b3..f22fd74baf4 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -516,7 +516,7 @@ static AVStream *alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex c->qmax = 51; } - // Keep lossless encodes in the RGB domain. + /* Keep lossless encodes in the RGB domain. */ if (codec_id == CODEC_ID_HUFFYUV) { /* HUFFYUV was PIX_FMT_YUV422P before */ c->pix_fmt = PIX_FMT_RGB32; @@ -572,12 +572,12 @@ static AVStream *alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex } if (codec_id == CODEC_ID_QTRLE) { - // normally it should be enough to have buffer with actual image size, - // but some codecs like QTRLE might store extra information in this buffer, - // so it should be a way larger + /* normally it should be enough to have buffer with actual image size, + * but some codecs like QTRLE might store extra information in this buffer, + * so it should be a way larger */ - // maximum video buffer size is 6-bytes per pixel, plus DPX header size (1664) - // (from FFmpeg sources) + /* maximum video buffer size is 6-bytes per pixel, plus DPX header size (1664) + * (from FFmpeg sources) */ int size = c->width * c->height; video_buffersize = 7 * size + 10000; } diff --git a/source/blender/blenlib/BLI_string.h b/source/blender/blenlib/BLI_string.h index c8f439c677f..8fde8fcf13f 100644 --- a/source/blender/blenlib/BLI_string.h +++ b/source/blender/blenlib/BLI_string.h @@ -43,7 +43,12 @@ extern "C" { * \param str The string to be duplicated * \retval Returns the duplicated string */ -char *BLI_strdup(const char *str); +char *BLI_strdup(const char *str) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; /** * Duplicates the first \a len bytes of cstring \a str @@ -54,7 +59,12 @@ char *BLI_strdup(const char *str); * \param len The number of bytes to duplicate * \retval Returns the duplicated string */ -char *BLI_strdupn(const char *str, const size_t len); +char *BLI_strdupn(const char *str, const size_t len) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; /** * Appends the two strings, and returns new mallocN'ed string @@ -62,7 +72,12 @@ char *BLI_strdupn(const char *str, const size_t len); * \param str2 second string for append * \retval Returns dst */ -char *BLI_strdupcat(const char *str1, const char *str2); +char *BLI_strdupcat(const char *str1, const char *str2) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; /** * Like strncpy but ensures dst is always @@ -74,9 +89,14 @@ char *BLI_strdupcat(const char *str1, const char *str2); * the size of dst) * \retval Returns dst */ -char *BLI_strncpy(char *dst, const char *src, const size_t maxncpy); +char *BLI_strncpy(char *dst, const char *src, const size_t maxncpy) +#ifdef __GNUC__ +__attribute__((nonnull)) +#endif +; -/* Makes a copy of the text within the "" that appear after some text 'blahblah' +/** + *Makes a copy of the text within the "" that appear after some text 'blahblah' * i.e. for string 'pose["apples"]' with prefix 'pose[', it should grab "apples" * * - str: is the entire string to chop @@ -85,7 +105,12 @@ char *BLI_strncpy(char *dst, const char *src, const size_t maxncpy); * Assume that the strings returned must be freed afterwards, and that the inputs will contain * data we want... */ -char *BLI_getQuotedStr(const char *str, const char *prefix); +char *BLI_getQuotedStr(const char *str, const char *prefix) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; /** * Returns a copy of the cstring \a str into a newly mallocN'd @@ -97,7 +122,12 @@ char *BLI_getQuotedStr(const char *str, const char *prefix); * \param newText The text in the string to find and replace * \retval Returns the duplicated string */ -char *BLI_replacestr(char *str, const char *oldText, const char *newText); +char *BLI_replacestr(char *str, const char *oldText, const char *newText) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; /* * Replacement for snprintf @@ -105,6 +135,7 @@ char *BLI_replacestr(char *str, const char *oldText, const char *newText); size_t BLI_snprintf(char *buffer, size_t len, const char *format, ...) #ifdef __GNUC__ __attribute__ ((format(printf, 3, 4))) +__attribute__((nonnull)) #endif ; @@ -115,27 +146,75 @@ __attribute__ ((format(printf, 3, 4))) char *BLI_sprintfN(const char *format, ...) #ifdef __GNUC__ __attribute__ ((format(printf, 1, 2))) +__attribute__((warn_unused_result)) +__attribute__((nonnull)) #endif ; -size_t BLI_strescape(char *dst, const char *src, const size_t maxlen); +size_t BLI_strescape(char *dst, const char *src, const size_t maxlen) +#ifdef __GNUC__ +__attribute__((nonnull)) +#endif +; /** * Compare two strings without regard to case. * * \retval True if the strings are equal, false otherwise. */ -int BLI_strcaseeq(const char *a, const char *b); +int BLI_strcaseeq(const char *a, const char *b) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; -char *BLI_strcasestr(const char *s, const char *find); -int BLI_strcasecmp(const char *s1, const char *s2); -int BLI_strncasecmp(const char *s1, const char *s2, size_t len); -int BLI_natstrcmp(const char *s1, const char *s2); -size_t BLI_strnlen(const char *str, size_t maxlen); -void BLI_timestr(double _time, char *str); /* time var is global */ +char *BLI_strcasestr(const char *s, const char *find) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; +int BLI_strcasecmp(const char *s1, const char *s2) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; +int BLI_strncasecmp(const char *s1, const char *s2, size_t len) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; +int BLI_natstrcmp(const char *s1, const char *s2) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; +size_t BLI_strnlen(const char *str, size_t maxlen) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; +void BLI_timestr(double _time, char *str) +#ifdef __GNUC__ +__attribute__((nonnull)) +#endif +; /* time var is global */ -void BLI_ascii_strtolower(char *str, int len); -void BLI_ascii_strtoupper(char *str, int len); +void BLI_ascii_strtolower(char *str, int len) +#ifdef __GNUC__ +__attribute__((nonnull)) +#endif +; +void BLI_ascii_strtoupper(char *str, int len) +#ifdef __GNUC__ +__attribute__((nonnull)) +#endif +; #ifdef __cplusplus } diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c index 4bcedb06fb0..844407f9e06 100644 --- a/source/blender/blenlib/intern/BLI_ghash.c +++ b/source/blender/blenlib/intern/BLI_ghash.c @@ -35,8 +35,6 @@ #include "MEM_guardedalloc.h" -// #include "BLI_blenlib.h" - #include "BLI_utildefines.h" #include "BLI_mempool.h" #include "BLI_ghash.h" diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c index 6a4ee64ebcd..d07f19e78e0 100644 --- a/source/blender/blenlib/intern/BLI_kdopbvh.c +++ b/source/blender/blenlib/intern/BLI_kdopbvh.c @@ -29,15 +29,11 @@ * \ingroup bli */ - #include <assert.h> #include "MEM_guardedalloc.h" #include "BLI_utildefines.h" - - - #include "BLI_kdopbvh.h" #include "BLI_math.h" @@ -45,14 +41,12 @@ #include <omp.h> #endif - - #define MAX_TREETYPE 32 #define DEFAULT_FIND_NEAREST_HEAP_SIZE 1024 typedef struct BVHNode { struct BVHNode **children; - struct BVHNode *parent; // some user defined traversed need that + struct BVHNode *parent; /* some user defined traversed need that */ struct BVHNode *skip[2]; float *bv; /* Bounding volume of all nodes, max 13 axis */ int index; /* face, edge, vertex index */ @@ -104,16 +98,15 @@ typedef struct BVHRayCastData { BVHTreeRayHit hit; } BVHRayCastData; -////////////////////////////////////////m -//////////////////////////////////////////////////////////////////////// -// Bounding Volume Hierarchy Definition -// -// Notes: From OBB until 26-DOP --> all bounding volumes possible, just choose type below -// Notes: You have to choose the type at compile time ITM -// Notes: You can choose the tree type --> binary, quad, octree, choose below -//////////////////////////////////////////////////////////////////////// +/* + * Bounding Volume Hierarchy Definition + * + * Notes: From OBB until 26-DOP --> all bounding volumes possible, just choose type below + * Notes: You have to choose the type at compile time ITM + * Notes: You can choose the tree type --> binary, quad, octree, choose below + */ static float KDOP_AXES[13][3] = { {1.0, 0, 0}, {0, 1.0, 0}, {0, 0, 1.0}, {1.0, 1.0, 1.0}, {1.0, -1.0, 1.0}, {1.0, 1.0, -1.0}, @@ -188,13 +181,15 @@ static int ADJUST_MEMORY(void *local_memblock, void **memblock, int new_size, in } #endif -////////////////////////////////////////////////////////////////////////////////////////////////////// -// Introsort -// with permission deriven from the following Java code: -// http://ralphunden.net/content/tutorials/a-guide-to-introsort/ -// and he derived it from the SUN STL -////////////////////////////////////////////////////////////////////////////////////////////////////// +/* + * Introsort + * with permission deriven from the following Java code: + * http://ralphunden.net/content/tutorials/a-guide-to-introsort/ + * and he derived it from the SUN STL + */ + //static int size_threshold = 16; + /* * Common methods for all algorithms */ @@ -336,9 +331,9 @@ static void sort_along_axis(BVHTree *tree, int start, int end, int axis) } #endif -//after a call to this function you can expect one of: -// every node to left of a[n] are smaller or equal to it -// every node to the right of a[n] are greater or equal to it +/* after a call to this function you can expect one of: + * - every node to left of a[n] are smaller or equal to it + * - every node to the right of a[n] are greater or equal to it */ static int partition_nth_element(BVHNode **a, int _begin, int _end, int n, int axis) { int begin = _begin, end = _end, cut; @@ -354,7 +349,7 @@ static int partition_nth_element(BVHNode **a, int _begin, int _end, int n, int a return n; } -////////////////////////////////////////////////////////////////////////////////////////////////////// +/* --- */ static void build_skip_links(BVHTree *tree, BVHNode *node, BVHNode *left, BVHNode *right) { int i; @@ -381,8 +376,8 @@ static void create_kdop_hull(BVHTree *tree, BVHNode *node, const float *co, int float *bv = node->bv; int i, k; - // don't init boudings for the moving case - if (!moving) { + /* don't init boudings for the moving case */ + if (!moving) { for (i = tree->start_axis; i < tree->stop_axis; i++) { bv[2 * i] = FLT_MAX; bv[2 * i + 1] = -FLT_MAX; @@ -401,7 +396,7 @@ static void create_kdop_hull(BVHTree *tree, BVHNode *node, const float *co, int } } -// depends on the fact that the BVH's for each face is already build +/* depends on the fact that the BVH's for each face is already build */ static void refit_kdop_hull(BVHTree *tree, BVHNode *node, int start, int end) { float newmin, newmax; @@ -429,31 +424,31 @@ static void refit_kdop_hull(BVHTree *tree, BVHNode *node, int start, int end) } -// only supports x,y,z axis in the moment -// but we should use a plain and simple function here for speed sake +/* only supports x,y,z axis in the moment + * but we should use a plain and simple function here for speed sake */ static char get_largest_axis(float *bv) { float middle_point[3]; - middle_point[0] = (bv[1]) - (bv[0]); // x axis - middle_point[1] = (bv[3]) - (bv[2]); // y axis - middle_point[2] = (bv[5]) - (bv[4]); // z axis + middle_point[0] = (bv[1]) - (bv[0]); /* x axis */ + middle_point[1] = (bv[3]) - (bv[2]); /* y axis */ + middle_point[2] = (bv[5]) - (bv[4]); /* z axis */ if (middle_point[0] > middle_point[1]) { if (middle_point[0] > middle_point[2]) - return 1; // max x axis + return 1; /* max x axis */ else - return 5; // max z axis + return 5; /* max z axis */ } else { if (middle_point[1] > middle_point[2]) - return 3; // max y axis + return 3; /* max y axis */ else - return 5; // max z axis + return 5; /* max z axis */ } } -// bottom-up update of bvh node BV -// join the children on the parent BV +/* bottom-up update of bvh node BV + * join the children on the parent BV */ static void node_join(BVHTree *tree, BVHNode *node) { int i, j; @@ -466,11 +461,11 @@ static void node_join(BVHTree *tree, BVHNode *node) for (i = 0; i < tree->tree_type; i++) { if (node->children[i]) { for (j = tree->start_axis; j < tree->stop_axis; j++) { - // update minimum - if (node->children[i]->bv[(2 * j)] < node->bv[(2 * j)]) + /* update minimum */ + if (node->children[i]->bv[(2 * j)] < node->bv[(2 * j)]) node->bv[(2 * j)] = node->children[i]->bv[(2 * j)]; - - // update maximum + + /* update maximum */ if (node->children[i]->bv[(2 * j) + 1] > node->bv[(2 * j) + 1]) node->bv[(2 * j) + 1] = node->children[i]->bv[(2 * j) + 1]; } @@ -523,7 +518,7 @@ static void verify_tree(BVHTree *tree) { int i, j, check = 0; - // check the pointer list + /* check the pointer list */ for (i = 0; i < tree->totleaf; i++) { if (tree->nodes[i]->parent == NULL) { @@ -543,7 +538,7 @@ static void verify_tree(BVHTree *tree) } } - // check the leaf list + /* check the leaf list */ for (i = 0; i < tree->totleaf; i++) { if (tree->nodearray[i].parent == NULL) { @@ -567,8 +562,8 @@ static void verify_tree(BVHTree *tree) } #endif -//Helper data and structures to build a min-leaf generalized implicit tree -//This code can be easily reduced (basicly this is only method to calculate pow(k, n) in O(1).. and stuff like that) +/* Helper data and structures to build a min-leaf generalized implicit tree + * This code can be easily reduced (basicly this is only method to calculate pow(k, n) in O(1).. and stuff like that) */ typedef struct BVHBuildHelper { int tree_type; /* */ int totleafs; /* */ @@ -589,7 +584,7 @@ static void build_implicit_tree_helper(BVHTree *tree, BVHBuildHelper *data) data->totleafs = tree->totleaf; data->tree_type = tree->tree_type; - //Calculate the smallest tree_type^n such that tree_type^n >= num_leafs + /* Calculate the smallest tree_type^n such that tree_type^n >= num_leafs */ for (data->leafs_per_child[0] = 1; data->leafs_per_child[0] < data->totleafs; data->leafs_per_child[0] *= data->tree_type) @@ -599,7 +594,7 @@ static void build_implicit_tree_helper(BVHTree *tree, BVHBuildHelper *data) data->branches_on_level[0] = 1; - //We could stop the loop first (but I am lazy to find out when) + /* We could stop the loop first (but I am lazy to find out when) */ for (depth = 1; depth < 32; depth++) { data->branches_on_level[depth] = data->branches_on_level[depth - 1] * data->tree_type; data->leafs_per_child[depth] = data->leafs_per_child[depth - 1] / data->tree_type; @@ -700,18 +695,18 @@ static void non_recursive_bvh_div_nodes(BVHTree *tree, BVHNode *branches_array, int i; const int tree_type = tree->tree_type; - const int tree_offset = 2 - tree->tree_type; //this value is 0 (on binary trees) and negative on the others + const int tree_offset = 2 - tree->tree_type; /* this value is 0 (on binary trees) and negative on the others */ const int num_branches = implicit_needed_branches(tree_type, num_leafs); BVHBuildHelper data; int depth; - // set parent from root node to NULL + /* set parent from root node to NULL */ BVHNode *tmp = branches_array + 0; tmp->parent = NULL; - //Most of bvhtree code relies on 1-leaf trees having at least one branch - //We handle that special case here + /*Most of bvhtree code relies on 1-leaf trees having at least one branch + *We handle that special case here */ if (num_leafs == 1) { BVHNode *root = branches_array + 0; refit_kdop_hull(tree, root, 0, num_leafs); @@ -722,17 +717,17 @@ static void non_recursive_bvh_div_nodes(BVHTree *tree, BVHNode *branches_array, return; } - branches_array--; //Implicit trees use 1-based indexs - + branches_array--; /* Implicit trees use 1-based indexs */ + build_implicit_tree_helper(tree, &data); - //Loop tree levels (log N) loops + /* Loop tree levels (log N) loops */ for (i = 1, depth = 1; i <= num_branches; i = i * tree_type + tree_offset, depth++) { const int first_of_next_level = i * tree_type + tree_offset; - const int end_j = MIN2(first_of_next_level, num_branches + 1); //index of last branch on this level + const int end_j = MIN2(first_of_next_level, num_branches + 1); /* index of last branch on this level */ int j; - //Loop all branches on this level + /* Loop all branches on this level */ #pragma omp parallel for private(j) schedule(static) for (j = i; j < end_j; j++) { int k; @@ -744,34 +739,34 @@ static void non_recursive_bvh_div_nodes(BVHTree *tree, BVHNode *branches_array, int parent_leafs_begin = implicit_leafs_index(&data, depth, parent_level_index); int parent_leafs_end = implicit_leafs_index(&data, depth, parent_level_index + 1); - //This calculates the bounding box of this branch - //and chooses the largest axis as the axis to divide leafs + /* This calculates the bounding box of this branch + * and chooses the largest axis as the axis to divide leafs */ refit_kdop_hull(tree, parent, parent_leafs_begin, parent_leafs_end); split_axis = get_largest_axis(parent->bv); - //Save split axis (this can be used on raytracing to speedup the query time) + /* Save split axis (this can be used on raytracing to speedup the query time) */ parent->main_axis = split_axis / 2; - //Split the childs along the split_axis, note: its not needed to sort the whole leafs array - //Only to assure that the elements are partioned on a way that each child takes the elements - //it would take in case the whole array was sorted. - //Split_leafs takes care of that "sort" problem. + /* Split the childs along the split_axis, note: its not needed to sort the whole leafs array + * Only to assure that the elements are partioned on a way that each child takes the elements + * it would take in case the whole array was sorted. + * Split_leafs takes care of that "sort" problem. */ nth_positions[0] = parent_leafs_begin; nth_positions[tree_type] = parent_leafs_end; for (k = 1; k < tree_type; k++) { int child_index = j * tree_type + tree_offset + k; - int child_level_index = child_index - first_of_next_level; //child level index + int child_level_index = child_index - first_of_next_level; /* child level index */ nth_positions[k] = implicit_leafs_index(&data, depth + 1, child_level_index); } split_leafs(leafs_array, nth_positions, tree_type, split_axis); - //Setup children and totnode counters - //Not really needed but currently most of BVH code relies on having an explicit children structure + /* Setup children and totnode counters + * Not really needed but currently most of BVH code relies on having an explicit children structure */ for (k = 0; k < tree_type; k++) { int child_index = j * tree_type + tree_offset + k; - int child_level_index = child_index - first_of_next_level; //child level index + int child_level_index = child_index - first_of_next_level; /* child level index */ int child_leafs_begin = implicit_leafs_index(&data, depth + 1, child_level_index); int child_leafs_end = implicit_leafs_index(&data, depth + 1, child_level_index + 1); @@ -803,20 +798,20 @@ BVHTree *BLI_bvhtree_new(int maxsize, float epsilon, char tree_type, char axis) BVHTree *tree; int numnodes, i; - // theres not support for trees below binary-trees :P + /* theres not support for trees below binary-trees :P */ if (tree_type < 2) return NULL; - + if (tree_type > MAX_TREETYPE) return NULL; tree = (BVHTree *)MEM_callocN(sizeof(BVHTree), "BVHTree"); - //tree epsilon must be >= FLT_EPSILON - //so that tangent rays can still hit a bounding volume.. - //this bug would show up when casting a ray aligned with a kdop-axis and with an edge of 2 faces + /* tree epsilon must be >= FLT_EPSILON + * so that tangent rays can still hit a bounding volume.. + * this bug would show up when casting a ray aligned with a kdop-axis and with an edge of 2 faces */ epsilon = MAX2(FLT_EPSILON, epsilon); - + if (tree) { tree->epsilon = epsilon; tree->tree_type = tree_type; @@ -910,59 +905,59 @@ void BLI_bvhtree_balance(BVHTree *tree) BVHNode *branches_array = tree->nodearray + tree->totleaf; BVHNode **leafs_array = tree->nodes; - //This function should only be called once (some big bug goes here if its being called more than once per tree) + /* This function should only be called once (some big bug goes here if its being called more than once per tree) */ assert(tree->totbranch == 0); - //Build the implicit tree + /* Build the implicit tree */ non_recursive_bvh_div_nodes(tree, branches_array, leafs_array, tree->totleaf); - //current code expects the branches to be linked to the nodes array - //we perform that linkage here + /*current code expects the branches to be linked to the nodes array + *we perform that linkage here */ tree->totbranch = implicit_needed_branches(tree->tree_type, tree->totleaf); for (i = 0; i < tree->totbranch; i++) tree->nodes[tree->totleaf + i] = branches_array + i; build_skip_links(tree, tree->nodes[tree->totleaf], NULL, NULL); - //bvhtree_info(tree); + /* bvhtree_info(tree); */ } int BLI_bvhtree_insert(BVHTree *tree, int index, const float *co, int numpoints) { int i; BVHNode *node = NULL; - - // insert should only possible as long as tree->totbranch is 0 + + /* insert should only possible as long as tree->totbranch is 0 */ if (tree->totbranch > 0) return 0; - + if (tree->totleaf + 1 >= MEM_allocN_len(tree->nodes) / sizeof(*(tree->nodes))) return 0; - - // TODO check if have enough nodes in array - + + /* TODO check if have enough nodes in array */ + node = tree->nodes[tree->totleaf] = &(tree->nodearray[tree->totleaf]); tree->totleaf++; - + create_kdop_hull(tree, node, co, numpoints, 0); node->index = index; - - // inflate the bv with some epsilon + + /* inflate the bv with some epsilon */ for (i = tree->start_axis; i < tree->stop_axis; i++) { - node->bv[(2 * i)] -= tree->epsilon; // minimum - node->bv[(2 * i) + 1] += tree->epsilon; // maximum + node->bv[(2 * i)] -= tree->epsilon; /* minimum */ + node->bv[(2 * i) + 1] += tree->epsilon; /* maximum */ } return 1; } -// call before BLI_bvhtree_update_tree() +/* call before BLI_bvhtree_update_tree() */ int BLI_bvhtree_update_node(BVHTree *tree, int index, const float *co, const float *co_moving, int numpoints) { int i; BVHNode *node = NULL; - // check if index exists + /* check if index exists */ if (index > tree->totleaf) return 0; @@ -982,12 +977,12 @@ int BLI_bvhtree_update_node(BVHTree *tree, int index, const float *co, const flo return 1; } -// call BLI_bvhtree_update_node() first for every node/point/triangle +/* call BLI_bvhtree_update_node() first for every node/point/triangle */ void BLI_bvhtree_update_tree(BVHTree *tree) { - //Update bottom=>top - //TRICKY: the way we build the tree all the childs have an index greater than the parent - //This allows us todo a bottom up update by starting on the biger numbered branch + /* Update bottom=>top + * TRICKY: the way we build the tree all the childs have an index greater than the parent + * This allows us todo a bottom up update by starting on the biger numbered branch */ BVHNode **root = tree->nodes + tree->totleaf; BVHNode **index = tree->nodes + tree->totleaf + tree->totbranch - 1; @@ -1004,8 +999,8 @@ float BLI_bvhtree_getepsilon(BVHTree *tree) /* * BLI_bvhtree_overlap - */ -// overlap - is it possbile for 2 bv's to collide ? + * + * overlap - is it possbile for 2 bv's to collide ? */ static int tree_overlap(BVHNode *node1, BVHNode *node2, int start_axis, int stop_axis) { float *bv1 = node1->bv; @@ -1016,31 +1011,31 @@ static int tree_overlap(BVHNode *node1, BVHNode *node2, int start_axis, int stop bv1 += start_axis << 1; bv2 += start_axis << 1; - // test all axis if min + max overlap + /* test all axis if min + max overlap */ for (; bv1 != bv1_end; bv1 += 2, bv2 += 2) { - if ((*(bv1) > *(bv2 + 1)) || (*(bv2) > *(bv1 + 1))) + if ((*(bv1) > *(bv2 + 1)) || (*(bv2) > *(bv1 + 1))) return 0; } - + return 1; } static void traverse(BVHOverlapData *data, BVHNode *node1, BVHNode *node2) { int j; - + if (tree_overlap(node1, node2, data->start_axis, data->stop_axis)) { - // check if node1 is a leaf + /* check if node1 is a leaf */ if (!node1->totnode) { - // check if node2 is a leaf + /* check if node2 is a leaf */ if (!node2->totnode) { - + if (node1 == node2) { return; } - + if (data->i >= data->max_overlap) { - // try to make alloc'ed memory bigger + /* try to make alloc'ed memory bigger */ data->overlap = realloc(data->overlap, sizeof(BVHTreeOverlap) * data->max_overlap * 2); if (!data->overlap) { @@ -1222,14 +1217,14 @@ PUSH_HEAP_BODY(NodeDistance, NodeDistance_priority, heap, heap_size) static void NodeDistance_pop_heap(NodeDistance *heap, int heap_size) POP_HEAP_BODY(NodeDistance, NodeDistance_priority, heap, heap_size) -//NN function that uses an heap.. this functions leads to an optimal number of min-distance -//but for normal tri-faces and BV 6-dop.. a simple dfs with local heuristics (as implemented -//in source/blender/blenkernel/intern/shrinkwrap.c) works faster. -// -//It may make sense to use this function if the callback queries are very slow.. or if its impossible -//to get a nice heuristic -// -//this function uses "malloc/free" instead of the MEM_* because it intends to be openmp safe +/* NN function that uses an heap.. this functions leads to an optimal number of min-distance + * but for normal tri-faces and BV 6-dop.. a simple dfs with local heuristics (as implemented + * in source/blender/blenkernel/intern/shrinkwrap.c) works faster. + * + * It may make sense to use this function if the callback queries are very slow.. or if its impossible + * to get a nice heuristic + * + * this function uses "malloc/free" instead of the MEM_* because it intends to be openmp safe */ static void bfs_find_nearest(BVHNearestData *data, BVHNode *node) { int i; @@ -1327,11 +1322,11 @@ int BLI_bvhtree_find_nearest(BVHTree *tree, const float co[3], BVHTreeNearest *n data.nearest.dist = FLT_MAX; } - //dfs search + /* dfs search */ if (root) dfs_find_nearest_begin(&data, root); - //copy back results + /* copy back results */ if (nearest) { memcpy(nearest, &data.nearest, sizeof(*nearest)); } @@ -1347,7 +1342,7 @@ int BLI_bvhtree_find_nearest(BVHTree *tree, const float co[3], BVHTreeNearest *n */ -//Determines the distance that the ray must travel to hit the bounding volume of the given node +/* Determines the distance that the ray must travel to hit the bounding volume of the given node */ static float ray_nearest_hit(BVHRayCastData *data, float *bv) { int i; @@ -1382,11 +1377,11 @@ static float ray_nearest_hit(BVHRayCastData *data, float *bv) return low; } -//Determines the distance that the ray must travel to hit the bounding volume of the given node -//Based on Tactical Optimization of Ray/Box Intersection, by Graham Fyffe -//[http://tog.acm.org/resources/RTNews/html/rtnv21n1.html#art9] -// -//TODO this doens't has data->ray.radius in consideration +/* Determines the distance that the ray must travel to hit the bounding volume of the given node + * Based on Tactical Optimization of Ray/Box Intersection, by Graham Fyffe + * [http://tog.acm.org/resources/RTNews/html/rtnv21n1.html#art9] + * + * TODO this doens't has data->ray.radius in consideration */ static float fast_ray_nearest_hit(const BVHRayCastData *data, const BVHNode *node) { const float *bv = node->bv; @@ -1413,8 +1408,8 @@ static void dfs_raycast(BVHRayCastData *data, BVHNode *node) { int i; - //ray-bv is really fast.. and simple tests revealed its worth to test it - //before calling the ray-primitive functions + /* ray-bv is really fast.. and simple tests revealed its worth to test it + * before calling the ray-primitive functions */ /* XXX: temporary solution for particles until fast_ray_nearest_hit supports ray.radius */ float dist = (data->ray.radius > 0.0f) ? ray_nearest_hit(data, node->bv) : fast_ray_nearest_hit(data, node); if (dist >= data->hit.dist) return; @@ -1430,7 +1425,7 @@ static void dfs_raycast(BVHRayCastData *data, BVHNode *node) } } else { - //pick loop direction to dive into the tree (based on ray direction and split axis) + /* pick loop direction to dive into the tree (based on ray direction and split axis) */ if (data->ray_dot_axis[(int)node->main_axis] > 0.0f) { for (i = 0; i != node->totnode; i++) { dfs_raycast(data, node->children[i]); diff --git a/source/blender/blenlib/intern/DLRB_tree.c b/source/blender/blenlib/intern/DLRB_tree.c index bed5750ad44..c8c2ad35380 100644 --- a/source/blender/blenlib/intern/DLRB_tree.c +++ b/source/blender/blenlib/intern/DLRB_tree.c @@ -134,12 +134,12 @@ DLRBT_Node *BLI_dlrbTree_search(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_cb, vo { DLRBT_Node *node = (tree) ? tree->root : NULL; short found = 0; - + /* check that there is a comparator to use */ - // TODO: if no comparator is supplied, try using the one supplied with the tree... + /* TODO: if no comparator is supplied, try using the one supplied with the tree... */ if (cmp_cb == NULL) return NULL; - + /* iteratively perform this search */ while (node && found == 0) { /* check if traverse further or not @@ -177,7 +177,7 @@ DLRBT_Node *BLI_dlrbTree_search_exact(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_ short found = 0; /* check that there is a comparator to use */ - // TODO: if no comparator is supplied, try using the one supplied with the tree... + /* TODO: if no comparator is supplied, try using the one supplied with the tree... */ if (cmp_cb == NULL) return NULL; @@ -217,7 +217,7 @@ DLRBT_Node *BLI_dlrbTree_search_prev(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_c DLRBT_Node *node; /* check that there is a comparator to use */ - // TODO: if no comparator is supplied, try using the one supplied with the tree... + /* TODO: if no comparator is supplied, try using the one supplied with the tree... */ if (cmp_cb == NULL) return NULL; @@ -230,7 +230,7 @@ DLRBT_Node *BLI_dlrbTree_search_prev(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_c return node; /* return the previous node otherwise */ - // NOTE: what happens if there is no previous node? + /* NOTE: what happens if there is no previous node? */ return node->prev; } @@ -242,9 +242,9 @@ DLRBT_Node *BLI_dlrbTree_search_prev(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_c DLRBT_Node *BLI_dlrbTree_search_next(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_cb, void *search_data) { DLRBT_Node *node; - + /* check that there is a comparator to use */ - // TODO: if no comparator is supplied, try using the one supplied with the tree... + /* TODO: if no comparator is supplied, try using the one supplied with the tree... */ if (cmp_cb == NULL) return NULL; @@ -257,7 +257,7 @@ DLRBT_Node *BLI_dlrbTree_search_next(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_c return node; /* return the previous node otherwise */ - // NOTE: what happens if there is no previous node? + /* NOTE: what happens if there is no previous node? */ return node->next; } @@ -512,18 +512,18 @@ DLRBT_Node *BLI_dlrbTree_add(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_cb, /* sanity checks */ if (tree == NULL) return NULL; - - // TODO: if no comparator is supplied, try using the one supplied with the tree... + + /* TODO: if no comparator is supplied, try using the one supplied with the tree... */ if (cmp_cb == NULL) return NULL; - // TODO: if no allocator is supplied, try using the one supplied with the tree... + /* TODO: if no allocator is supplied, try using the one supplied with the tree... */ if (new_cb == NULL) return NULL; - // TODO: if no updater is supplied, try using the one supplied with the tree... - + /* TODO: if no updater is supplied, try using the one supplied with the tree... */ + /* try to find the nearest node to this one */ parNode = BLI_dlrbTree_search(tree, cmp_cb, data); - + /* add new node to the BST in the 'standard way' as appropriate * NOTE: we do not support duplicates in our tree... */ @@ -586,6 +586,6 @@ DLRBT_Node *BLI_dlrbTree_add(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_cb, /* *********************************************** */ /* Remove */ -// TODO: this hasn't been coded yet, since this functionality was not needed by the author +/* TODO: this hasn't been coded yet, since this functionality was not needed by the author */ /* *********************************************** */ diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c index 5f564f71646..7aa956a0548 100644 --- a/source/blender/blenlib/intern/fileops.c +++ b/source/blender/blenlib/intern/fileops.c @@ -274,12 +274,12 @@ int BLI_move(const char *file, const char *to) { int err; - // windows doesn't support moveing to a directory - // it has to be 'mv filename filename' and not - // 'mv filename destdir' + /* windows doesn't support moveing to a directory + * it has to be 'mv filename filename' and not + * 'mv filename destdir' */ BLI_strncpy(str, to, sizeof(str)); - // points 'to' to a directory ? + /* points 'to' to a directory ? */ if (BLI_last_slash(str) == (str + strlen(str) - 1)) { if (BLI_last_slash(file) != NULL) { strcat(str, BLI_last_slash(file) + 1); @@ -305,12 +305,12 @@ int BLI_copy(const char *file, const char *to) { int err; - // windows doesn't support copying to a directory - // it has to be 'cp filename filename' and not - // 'cp filename destdir' + /* windows doesn't support copying to a directory + * it has to be 'cp filename filename' and not + * 'cp filename destdir' */ BLI_strncpy(str, to, sizeof(str)); - // points 'to' to a directory ? + /* points 'to' to a directory ? */ if (BLI_last_slash(str) == (str + strlen(str) - 1)) { if (BLI_last_slash(file) != NULL) { strcat(str, BLI_last_slash(file) + 1); diff --git a/source/blender/blenlib/intern/freetypefont.c b/source/blender/blenlib/intern/freetypefont.c index eb2070bce76..a499f9a81ea 100644 --- a/source/blender/blenlib/intern/freetypefont.c +++ b/source/blender/blenlib/intern/freetypefont.c @@ -71,55 +71,55 @@ static FT_Error err; static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vfd) { - // Blender + /* Blender */ struct Nurb *nu; struct VChar *che; struct BezTriple *bezt; - - // Freetype2 + + /* Freetype2 */ FT_GlyphSlot glyph; FT_UInt glyph_index; FT_Outline ftoutline; float scale, height; float dx, dy; int j, k, l, m = 0; - - // adjust font size + + /* adjust font size */ height = ((double) face->bbox.yMax - (double) face->bbox.yMin); if (height != 0.0f) scale = 1.0f / height; else scale = 1.0f / 1000.0f; - - // - // Generate the character 3D data - // - // Get the FT Glyph index and load the Glyph + + /* + * Generate the character 3D data + * + * Get the FT Glyph index and load the Glyph */ glyph_index = FT_Get_Char_Index(face, charcode); err = FT_Load_Glyph(face, glyph_index, FT_LOAD_NO_SCALE | FT_LOAD_NO_BITMAP); - - // If loading succeeded, convert the FT glyph to the internal format + + /* If loading succeeded, convert the FT glyph to the internal format */ if (!err) { int *npoints; int *onpoints; - - // First we create entry for the new character to the character list + + /* First we create entry for the new character to the character list */ che = (VChar *) MEM_callocN(sizeof(struct VChar), "objfnt_char"); BLI_addtail(&vfd->characters, che); - - // Take some data for modifying purposes + + /* Take some data for modifying purposes */ glyph = face->glyph; ftoutline = glyph->outline; - - // Set the width and character code + + /* Set the width and character code */ che->index = charcode; che->width = glyph->advance.x * scale; - - // Start converting the FT data + + /* Start converting the FT data */ npoints = (int *)MEM_callocN((ftoutline.n_contours) * sizeof(int), "endpoints"); onpoints = (int *)MEM_callocN((ftoutline.n_contours) * sizeof(int), "onpoints"); - // calculate total points of each contour + /* calculate total points of each contour */ for (j = 0; j < ftoutline.n_contours; j++) { if (j == 0) npoints[j] = ftoutline.contours[j] + 1; @@ -127,7 +127,7 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf npoints[j] = ftoutline.contours[j] - ftoutline.contours[j - 1]; } - // get number of on-curve points for beziertriples (including conic virtual on-points) + /* get number of on-curve points for beziertriples (including conic virtual on-points) */ for (j = 0; j < ftoutline.n_contours; j++) { for (k = 0; k < npoints[j]; k++) { l = (j > 0) ? (k + ftoutline.contours[j - 1] + 1) : k; @@ -145,9 +145,9 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf } } - //contour loop, bezier & conic styles merged + /* contour loop, bezier & conic styles merged */ for (j = 0; j < ftoutline.n_contours; j++) { - // add new curve + /* add new curve */ nu = (Nurb *)MEM_callocN(sizeof(struct Nurb), "objfnt_nurb"); bezt = (BezTriple *)MEM_callocN((onpoints[j]) * sizeof(BezTriple), "objfnt_bezt"); BLI_addtail(&che->nurbsbase, nu); @@ -159,26 +159,26 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf nu->flagu = CU_NURB_CYCLIC; nu->bezt = bezt; - //individual curve loop, start-end + /* individual curve loop, start-end */ for (k = 0; k < npoints[j]; k++) { if (j > 0) l = k + ftoutline.contours[j - 1] + 1; else l = k; if (k == 0) m = l; - - //virtual conic on-curve points + + /* virtual conic on-curve points */ if (k < npoints[j] - 1) { if (ftoutline.tags[l] == FT_Curve_Tag_Conic && ftoutline.tags[l + 1] == FT_Curve_Tag_Conic) { dx = (ftoutline.points[l].x + ftoutline.points[l + 1].x) * scale / 2.0f; dy = (ftoutline.points[l].y + ftoutline.points[l + 1].y) * scale / 2.0f; - //left handle + /* left handle */ bezt->vec[0][0] = (dx + (2 * ftoutline.points[l].x) * scale) / 3.0f; bezt->vec[0][1] = (dy + (2 * ftoutline.points[l].y) * scale) / 3.0f; - //midpoint (virtual on-curve point) + /* midpoint (virtual on-curve point) */ bezt->vec[1][0] = dx; bezt->vec[1][1] = dy; - //right handle + /* right handle */ bezt->vec[2][0] = (dx + (2 * ftoutline.points[l + 1].x) * scale) / 3.0f; bezt->vec[2][1] = (dy + (2 * ftoutline.points[l + 1].y) * scale) / 3.0f; @@ -188,9 +188,9 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf } } - //on-curve points + /* on-curve points */ if (ftoutline.tags[l] == FT_Curve_Tag_On) { - //left handle + /* left handle */ if (k > 0) { if (ftoutline.tags[l - 1] == FT_Curve_Tag_Cubic) { bezt->vec[0][0] = ftoutline.points[l - 1].x * scale; @@ -208,7 +208,7 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf bezt->h1 = HD_VECT; } } - else { //first point on curve + else { /* first point on curve */ if (ftoutline.tags[ftoutline.contours[j]] == FT_Curve_Tag_Cubic) { bezt->vec[0][0] = ftoutline.points[ftoutline.contours[j]].x * scale; bezt->vec[0][1] = ftoutline.points[ftoutline.contours[j]].y * scale; @@ -226,11 +226,11 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf } } - //midpoint (on-curve point) + /* midpoint (on-curve point) */ bezt->vec[1][0] = ftoutline.points[l].x * scale; bezt->vec[1][1] = ftoutline.points[l].y * scale; - //right handle + /* right handle */ if (k < (npoints[j] - 1)) { if (ftoutline.tags[l + 1] == FT_Curve_Tag_Cubic) { bezt->vec[2][0] = ftoutline.points[l + 1].x * scale; @@ -248,7 +248,7 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf bezt->h2 = HD_VECT; } } - else { //last point on curve + else { /* last point on curve */ if (ftoutline.tags[m] == FT_Curve_Tag_Cubic) { bezt->vec[2][0] = ftoutline.points[m].x * scale; bezt->vec[2][1] = ftoutline.points[m].y * scale; @@ -266,17 +266,19 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf } } - // get the handles that are aligned, tricky... - // dist_to_line_v2, check if the three beztriple points are on one line - // len_squared_v2v2, see if there's a distance between the three points - // len_squared_v2v2 again, to check the angle between the handles - // finally, check if one of them is a vector handle - if ((dist_to_line_v2(bezt->vec[0], bezt->vec[1], bezt->vec[2]) < 0.001f) && + /* get the handles that are aligned, tricky... + * dist_to_line_v2, check if the three beztriple points are on one line + * len_squared_v2v2, see if there's a distance between the three points + * len_squared_v2v2 again, to check the angle between the handles + * finally, check if one of them is a vector handle */ + if ((bezt->h1 != HD_VECT && bezt->h2 != HD_VECT) && + (dist_to_line_v2(bezt->vec[0], bezt->vec[1], bezt->vec[2]) < 0.001f) && (len_squared_v2v2(bezt->vec[0], bezt->vec[1]) > 0.0001f * 0.0001f) && (len_squared_v2v2(bezt->vec[1], bezt->vec[2]) > 0.0001f * 0.0001f) && (len_squared_v2v2(bezt->vec[0], bezt->vec[2]) > 0.0002f * 0.0001f) && - (len_squared_v2v2(bezt->vec[0], bezt->vec[2]) > MAX2(len_squared_v2v2(bezt->vec[0], bezt->vec[1]), len_squared_v2v2(bezt->vec[1], bezt->vec[2]))) && - bezt->h1 != HD_VECT && bezt->h2 != HD_VECT) + (len_squared_v2v2(bezt->vec[0], bezt->vec[2]) > + maxf(len_squared_v2v2(bezt->vec[0], bezt->vec[1]), + len_squared_v2v2(bezt->vec[1], bezt->vec[2])))) { bezt->h1 = bezt->h2 = HD_ALIGN; } @@ -292,17 +294,17 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf static int objchr_to_ftvfontdata(VFont *vfont, FT_ULong charcode) { - // Freetype2 + /* Freetype2 */ FT_Face face; struct TmpFont *tf; - - // Find the correct FreeType font + + /* Find the correct FreeType font */ tf = BKE_vfont_find_tmpfont(vfont); - - // What, no font found. Something strange here + + /* What, no font found. Something strange here */ if (!tf) return FALSE; - - // Load the font to memory + + /* Load the font to memory */ if (tf->pf) { err = FT_New_Memory_Face(library, tf->pf->data, @@ -316,17 +318,17 @@ static int objchr_to_ftvfontdata(VFont *vfont, FT_ULong charcode) return FALSE; } - // Read the char + /* Read the char */ freetypechar_to_vchar(face, charcode, vfont->data); - // And everything went ok + /* And everything went ok */ return TRUE; } static VFontData *objfnt_to_ftvfontdata(PackedFile *pf) { - // Variables + /* Variables */ FT_Face face; FT_ULong charcode = 0, lcode; FT_UInt glyph_index; @@ -341,7 +343,7 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile *pf) int n; #endif - // load the freetype font + /* load the freetype font */ err = FT_New_Memory_Face(library, pf->data, pf->size, @@ -364,22 +366,22 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile *pf) if (!found) { return NULL; } - // now, select the charmap for the face object + /* now, select the charmap for the face object */ err = FT_Set_Charmap(face, found); if (err) { return NULL; } #endif - // allocate blender font + /* allocate blender font */ vfd = MEM_callocN(sizeof(*vfd), "FTVFontData"); - // get the name + /* get the name */ fontname = FT_Get_Postscript_Name(face); BLI_strncpy(vfd->name, (fontname == NULL) ? "" : fontname, sizeof(vfd->name)); - // Extract the first 256 character from TTF + /* Extract the first 256 character from TTF */ lcode = charcode = FT_Get_First_Char(face, &glyph_index); - // No charmap found from the ttf so we need to figure it out + /* No charmap found from the ttf so we need to figure it out */ if (glyph_index == 0) { FT_CharMap found = NULL; FT_CharMap charmap; @@ -401,15 +403,15 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile *pf) lcode = charcode = FT_Get_First_Char(face, &glyph_index); } - // Load characters + /* Load characters */ while (charcode < 256) { - // Generate the font data + /* Generate the font data */ freetypechar_to_vchar(face, charcode, vfd); - // Next glyph + /* Next glyph */ charcode = FT_Get_Next_Char(face, charcode, &glyph_index); - // Check that we won't start infinite loop + /* Check that we won't start infinite loop */ if (charcode <= lcode) break; lcode = charcode; @@ -455,7 +457,7 @@ static int check_freetypefont(PackedFile *pf) if (!found) { return 0; } - // now, select the charmap for the face object + /* now, select the charmap for the face object */ err = FT_Set_Charmap(face, found); if (err) { return 0; } #endif @@ -509,21 +511,21 @@ int BLI_vfontchar_from_freetypefont(VFont *vfont, unsigned long character) if (!vfont) return FALSE; - // Init Freetype + /* Init Freetype */ err = FT_Init_FreeType(&library); if (err) { - //XXX error("Failed to load the Freetype font library"); + /* XXX error("Failed to load the Freetype font library"); */ return 0; } - // Load the character + /* Load the character */ success = objchr_to_ftvfontdata(vfont, character); if (success == FALSE) return FALSE; - // Free Freetype + /* Free Freetype */ FT_Done_FreeType(library); - // Ahh everything ok + /* Ahh everything ok */ return TRUE; } diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index 402aacf369a..a7ffb95172e 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -554,29 +554,29 @@ static short IsectLLPt2Df(const float x0, const float y0, const float x1, const * compute slopes, note the cludge for infinity, however, this will * be close enough */ - if (fabs(x1 - x0) > 0.000001) + if (fabs(x1 - x0) > 0.000001f) m1 = (y1 - y0) / (x1 - x0); else - return -1; /*m1 = (float)1e+10;*/ // close enough to infinity + return -1; /*m1 = (float)1e+10;*/ /* close enough to infinity */ - if (fabs(x3 - x2) > 0.000001) + if (fabs(x3 - x2) > 0.000001f) m2 = (y3 - y2) / (x3 - x2); else - return -1; /*m2 = (float)1e+10;*/ // close enough to infinity + return -1; /*m2 = (float)1e+10;*/ /* close enough to infinity */ - if (fabs(m1 - m2) < 0.000001) + if (fabs(m1 - m2) < 0.000001f) return -1; /* parallel lines */ - // compute constants + /* compute constants */ c1 = (y0 - m1 * x0); c2 = (y2 - m2 * x2); - // compute the inverse of the determinate + /* compute the inverse of the determinate */ det_inv = 1.0f / (-m1 + m2); - // use Kramers rule to compute xi and yi + /* use Kramers rule to compute xi and yi */ *xi = ((-c2 + c1) * det_inv); *yi = ((m2 * c1 - m1 * c2) * det_inv); @@ -1123,15 +1123,17 @@ int isect_axial_line_tri_v3(const int axis, const float p1[3], const float p2[3] float u, v, f; int a0 = axis, a1 = (axis + 1) % 3, a2 = (axis + 2) % 3; - //return isect_line_tri_v3(p1,p2,v0,v1,v2,lambda); +#if 0 + return isect_line_tri_v3(p1,p2,v0,v1,v2,lambda); - ///* first a simple bounding box test */ - //if (MIN3(v0[a1],v1[a1],v2[a1]) > p1[a1]) return 0; - //if (MIN3(v0[a2],v1[a2],v2[a2]) > p1[a2]) return 0; - //if (MAX3(v0[a1],v1[a1],v2[a1]) < p1[a1]) return 0; - //if (MAX3(v0[a2],v1[a2],v2[a2]) < p1[a2]) return 0; + /* first a simple bounding box test */ + if (MIN3(v0[a1],v1[a1],v2[a1]) > p1[a1]) return 0; + if (MIN3(v0[a2],v1[a2],v2[a2]) > p1[a2]) return 0; + if (MAX3(v0[a1],v1[a1],v2[a1]) < p1[a1]) return 0; + if (MAX3(v0[a2],v1[a2],v2[a2]) < p1[a2]) return 0; - ///* then a full intersection test */ + /* then a full intersection test */ +#endif sub_v3_v3v3(e1, v1, v0); sub_v3_v3v3(e2, v2, v0); @@ -1331,9 +1333,9 @@ int isect_ray_aabb(const IsectRayAABBData *data, const float bb_min[3], if (tzmin > tmin) tmin = tzmin; - // XXX jwilkins: tmax does not need to be updated since we don't use it - // keeping this here for future reference - //if (tzmax < tmax) tmax = tzmax; + /* XXX jwilkins: tmax does not need to be updated since we don't use it + * keeping this here for future reference */ + //if (tzmax < tmax) tmax = tzmax; if (tmin_out) (*tmin_out) = tmin; @@ -2803,21 +2805,21 @@ static int ff_visible_quad(const float p[3], const float n[3], if (sd[0] > 0) { if (sd[1] > 0) { if (sd[2] > 0) { - // +++ + /* +++ */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // ++- + /* ++- */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); vec_add_dir(q2, v1, v2, (sd[1] / (sd[1] - sd[2]))); vec_add_dir(q3, v0, v2, (sd[0] / (sd[0] - sd[2]))); } else { - // ++0 + /* ++0 */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); @@ -2826,21 +2828,21 @@ static int ff_visible_quad(const float p[3], const float n[3], } else if (sd[1] < 0) { if (sd[2] > 0) { - // +-+ + /* +-+ */ copy_v3_v3(q0, v0); vec_add_dir(q1, v0, v1, (sd[0] / (sd[0] - sd[1]))); vec_add_dir(q2, v1, v2, (sd[1] / (sd[1] - sd[2]))); copy_v3_v3(q3, v2); } else if (sd[2] < 0) { - // +-- + /* +-- */ copy_v3_v3(q0, v0); vec_add_dir(q1, v0, v1, (sd[0] / (sd[0] - sd[1]))); vec_add_dir(q2, v0, v2, (sd[0] / (sd[0] - sd[2]))); copy_v3_v3(q3, q2); } else { - // +-0 + /* +-0 */ copy_v3_v3(q0, v0); vec_add_dir(q1, v0, v1, (sd[0] / (sd[0] - sd[1]))); copy_v3_v3(q2, v2); @@ -2849,21 +2851,21 @@ static int ff_visible_quad(const float p[3], const float n[3], } else { if (sd[2] > 0) { - // +0+ + /* +0+ */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // +0- + /* +0- */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); vec_add_dir(q2, v0, v2, (sd[0] / (sd[0] - sd[2]))); copy_v3_v3(q3, q2); } else { - // +00 + /* +00 */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); @@ -2874,21 +2876,21 @@ static int ff_visible_quad(const float p[3], const float n[3], else if (sd[0] < 0) { if (sd[1] > 0) { if (sd[2] > 0) { - // -++ + /* -++ */ vec_add_dir(q0, v0, v1, (sd[0] / (sd[0] - sd[1]))); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); vec_add_dir(q3, v0, v2, (sd[0] / (sd[0] - sd[2]))); } else if (sd[2] < 0) { - // -+- + /* -+- */ vec_add_dir(q0, v0, v1, (sd[0] / (sd[0] - sd[1]))); copy_v3_v3(q1, v1); vec_add_dir(q2, v1, v2, (sd[1] / (sd[1] - sd[2]))); copy_v3_v3(q3, q2); } else { - // -+0 + /* -+0 */ vec_add_dir(q0, v0, v1, (sd[0] / (sd[0] - sd[1]))); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); @@ -2897,35 +2899,35 @@ static int ff_visible_quad(const float p[3], const float n[3], } else if (sd[1] < 0) { if (sd[2] > 0) { - // --+ + /* --+ */ vec_add_dir(q0, v0, v2, (sd[0] / (sd[0] - sd[2]))); vec_add_dir(q1, v1, v2, (sd[1] / (sd[1] - sd[2]))); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // --- + /* --- */ return 0; } else { - // --0 + /* --0 */ return 0; } } else { if (sd[2] > 0) { - // -0+ + /* -0+ */ vec_add_dir(q0, v0, v2, (sd[0] / (sd[0] - sd[2]))); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // -0- + /* -0- */ return 0; } else { - // -00 + /* -00 */ return 0; } } @@ -2933,21 +2935,21 @@ static int ff_visible_quad(const float p[3], const float n[3], else { if (sd[1] > 0) { if (sd[2] > 0) { - // 0++ + /* 0++ */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // 0+- + /* 0+- */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); vec_add_dir(q2, v1, v2, (sd[1] / (sd[1] - sd[2]))); copy_v3_v3(q3, q2); } else { - // 0+0 + /* 0+0 */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); @@ -2956,35 +2958,35 @@ static int ff_visible_quad(const float p[3], const float n[3], } else if (sd[1] < 0) { if (sd[2] > 0) { - // 0-+ + /* 0-+ */ copy_v3_v3(q0, v0); vec_add_dir(q1, v1, v2, (sd[1] / (sd[1] - sd[2]))); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // 0-- + /* 0-- */ return 0; } else { - // 0-0 + /* 0-0 */ return 0; } } else { if (sd[2] > 0) { - // 00+ + /* 00+ */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // 00- + /* 00- */ return 0; } else { - // 000 + /* 000 */ return 0; } } diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index b3b58dca1a6..f159a6b9d17 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -1271,7 +1271,7 @@ int is_negative_m4(float mat[][4]) /* make a 4x4 matrix out of 3 transform components */ /* matrices are made in the order: scale * rot * loc */ -// TODO: need to have a version that allows for rotation order... +/* TODO: need to have a version that allows for rotation order... */ void loc_eul_size_to_mat4(float mat[4][4], const float loc[3], const float eul[3], const float size[3]) { diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index f1e08993825..ab5601fc2dc 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -1199,12 +1199,12 @@ typedef struct RotOrderInfo { */ static RotOrderInfo rotOrders[] = { /* i, j, k, n */ - {{0, 1, 2}, 0}, // XYZ - {{0, 2, 1}, 1}, // XZY - {{1, 0, 2}, 1}, // YXZ - {{1, 2, 0}, 0}, // YZX - {{2, 0, 1}, 0}, // ZXY - {{2, 1, 0}, 1} // ZYX + {{0, 1, 2}, 0}, /* XYZ */ + {{0, 2, 1}, 1}, /* XZY */ + {{1, 0, 2}, 1}, /* YXZ */ + {{1, 2, 0}, 0}, /* YZX */ + {{2, 0, 1}, 0}, /* ZXY */ + {{2, 1, 0}, 1} /* ZYX */ }; /* Get relevant pointer to rotation order set from the array diff --git a/source/blender/blenlib/intern/noise.c b/source/blender/blenlib/intern/noise.c index 2ff0b564592..859bb66073c 100644 --- a/source/blender/blenlib/intern/noise.c +++ b/source/blender/blenlib/intern/noise.c @@ -282,8 +282,8 @@ static float npfade(float t) static float grad(int hash, float x, float y, float z) { - int h = hash & 15; // CONVERT LO 4 BITS OF HASH CODE - float u = h < 8 ? x : y, // INTO 12 GRADIENT DIRECTIONS. + int h = hash & 15; /* CONVERT LO 4 BITS OF HASH CODE */ + float u = h < 8 ? x : y, /* INTO 12 GRADIENT DIRECTIONS. */ v = h < 4 ? y : h == 12 || h == 14 ? x : z; return ((h & 1) == 0 ? u : -u) + ((h & 2) == 0 ? v : -v); } @@ -293,21 +293,21 @@ static float newPerlin(float x, float y, float z) { int A, AA, AB, B, BA, BB; float u = floor(x), v = floor(y), w = floor(z); - int X = ((int)u) & 255, Y = ((int)v) & 255, Z = ((int)w) & 255; // FIND UNIT CUBE THAT CONTAINS POINT - x -= u; // FIND RELATIVE X,Y,Z - y -= v; // OF POINT IN CUBE. + int X = ((int)u) & 255, Y = ((int)v) & 255, Z = ((int)w) & 255; /* FIND UNIT CUBE THAT CONTAINS POINT */ + x -= u; /* FIND RELATIVE X,Y,Z */ + y -= v; /* OF POINT IN CUBE. */ z -= w; - u = npfade(x); // COMPUTE FADE CURVES - v = npfade(y); // FOR EACH OF X,Y,Z. + u = npfade(x); /* COMPUTE FADE CURVES */ + v = npfade(y); /* FOR EACH OF X,Y,Z. */ w = npfade(z); - A = hash[X ]+Y; AA = hash[A]+Z; AB = hash[A+1]+Z; // HASH COORDINATES OF - B = hash[X+1]+Y; BA = hash[B]+Z; BB = hash[B+1]+Z; // THE 8 CUBE CORNERS, - return lerp(w, lerp(v, lerp(u, grad(hash[AA ], x, y, z ), // AND ADD - grad(hash[BA ], x - 1, y, z )), // BLENDED - lerp(u, grad(hash[AB ], x, y - 1, z ), // RESULTS - grad(hash[BB ], x - 1, y - 1, z ))), // FROM 8 - lerp(v, lerp(u, grad(hash[AA + 1], x, y, z - 1), // CORNERS - grad(hash[BA + 1], x - 1, y, z - 1)), // OF CUBE + A = hash[X ]+Y; AA = hash[A]+Z; AB = hash[A+1]+Z; /* HASH COORDINATES OF */ + B = hash[X+1]+Y; BA = hash[B]+Z; BB = hash[B+1]+Z; /* THE 8 CUBE CORNERS, */ + return lerp(w, lerp(v, lerp(u, grad(hash[AA ], x, y, z ), /* AND ADD */ + grad(hash[BA ], x - 1, y, z )), /* BLENDED */ + lerp(u, grad(hash[AB ], x, y - 1, z ), /* RESULTS */ + grad(hash[BB ], x - 1, y - 1, z ))), /* FROM 8 */ + lerp(v, lerp(u, grad(hash[AA + 1], x, y, z - 1), /* CORNERS */ + grad(hash[BA + 1], x - 1, y, z - 1)), /* OF CUBE */ lerp(u, grad(hash[AB + 1], x, y - 1, z - 1), grad(hash[BB + 1], x - 1, y - 1, z - 1)))); } diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c index e73899ce929..d86d151b1ef 100644 --- a/source/blender/blenlib/intern/string.c +++ b/source/blender/blenlib/intern/string.c @@ -178,8 +178,8 @@ char *BLI_getQuotedStr(const char *str, const char *prefix) startMatch = strstr(str, prefix) + prefixLen + 1; /* get the end point (i.e. where the next occurance of " is after the starting point) */ - endMatch = strchr(startMatch, '"'); // " NOTE: this comment here is just so that my text editor still shows the functions ok... - + endMatch = strchr(startMatch, '"'); /* " NOTE: this comment here is just so that my text editor still shows the functions ok... */ + /* return the slice indicated */ return BLI_strdupn(startMatch, (size_t)(endMatch - startMatch)); } @@ -187,8 +187,9 @@ char *BLI_getQuotedStr(const char *str, const char *prefix) /* Replaces all occurrences of oldText with newText in str, returning a new string that doesn't * contain the 'replaced' occurrences. */ -// A rather wasteful string-replacement utility, though this shall do for now... -// Feel free to replace this with an even safe + nicer alternative + +/* A rather wasteful string-replacement utility, though this shall do for now... + * Feel free to replace this with an even safe + nicer alternative */ char *BLI_replacestr(char *str, const char *oldText, const char *newText) { DynStr *ds = NULL; diff --git a/source/blender/blenlib/intern/voxel.c b/source/blender/blenlib/intern/voxel.c index 3a8705bbbba..bc775cb8f0c 100644 --- a/source/blender/blenlib/intern/voxel.c +++ b/source/blender/blenlib/intern/voxel.c @@ -56,15 +56,18 @@ float BLI_voxel_sample_nearest(float *data, const int res[3], const float co[3]) return D(data, res, xi, yi, zi); } -// returns highest integer <= x as integer (slightly faster than floor()) +/* returns highest integer <= x as integer (slightly faster than floor()) */ BLI_INLINE int FLOORI(float x) { const int r = (int)x; return ((x >= 0.f) || (float)r == x) ? r : (r - 1); } -// clamp function, cannot use the CLAMPIS macro, it sometimes returns unwanted results apparently related to gcc optimization flag -fstrict-overflow which is enabled at -O2 -// this causes the test (x + 2) < 0 with int x == 2147483647 to return false (x being an integer, x + 2 should wrap around to -2147483647 so the test < 0 should return true, which it doesn't) +/* clamp function, cannot use the CLAMPIS macro, it sometimes returns unwanted results apparently related to + * gcc optimization flag -fstrict-overflow which is enabled at -O2 + * + * this causes the test (x + 2) < 0 with int x == 2147483647 to return false (x being an integer, + * x + 2 should wrap around to -2147483647 so the test < 0 should return true, which it doesn't) */ BLI_INLINE int _clamp(int a, int b, int c) { return (a < b) ? b : ((a > c) ? c : a); diff --git a/source/blender/blenlib/intern/winstuff.c b/source/blender/blenlib/intern/winstuff.c index e34150ee4f2..0dc4d3c2db6 100644 --- a/source/blender/blenlib/intern/winstuff.c +++ b/source/blender/blenlib/intern/winstuff.c @@ -98,10 +98,10 @@ void RegisterBlendExtension(void) printf("Registering file extension..."); GetModuleFileName(0, BlPath, MAX_PATH); - // root is HKLM by default + /* root is HKLM by default */ lresult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Classes", 0, KEY_ALL_ACCESS, &root); if (lresult != ERROR_SUCCESS) { - // try HKCU on failure + /* try HKCU on failure */ usr_mode = TRUE; lresult = RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Classes", 0, KEY_ALL_ACCESS, &root); if (lresult != ERROR_SUCCESS) diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c index b6d9fbc85a2..c80a88d280e 100644 --- a/source/blender/bmesh/intern/bmesh_opdefines.c +++ b/source/blender/bmesh/intern/bmesh_opdefines.c @@ -99,11 +99,11 @@ */ static BMOpDefine bmo_smooth_vert_def = { "smooth_vert", - {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, //input vertices - {BMO_OP_SLOT_BOOL, "mirror_clip_x"}, //set vertices close to the x axis before the operation to 0 - {BMO_OP_SLOT_BOOL, "mirror_clip_y"}, //set vertices close to the y axis before the operation to 0 - {BMO_OP_SLOT_BOOL, "mirror_clip_z"}, //set vertices close to the z axis before the operation to 0 - {BMO_OP_SLOT_FLT, "clipdist"}, //clipping threshod for the above three slots + {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */ + {BMO_OP_SLOT_BOOL, "mirror_clip_x"}, /* set vertices close to the x axis before the operation to 0 */ + {BMO_OP_SLOT_BOOL, "mirror_clip_y"}, /* set vertices close to the y axis before the operation to 0 */ + {BMO_OP_SLOT_BOOL, "mirror_clip_z"}, /* set vertices close to the z axis before the operation to 0 */ + {BMO_OP_SLOT_FLT, "clipdist"}, /* clipping threshod for the above three slots */ {0} /* null-terminating sentinel */, }, bmo_smooth_vert_exec, @@ -119,7 +119,7 @@ static BMOpDefine bmo_smooth_vert_def = { static BMOpDefine bmo_recalc_face_normals_def = { "recalc_face_normals", {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, - {BMO_OP_SLOT_BOOL, "do_flip"}, //internal flag, used by bmesh_rationalize_normals + {BMO_OP_SLOT_BOOL, "do_flip"}, /* internal flag, used by bmesh_rationalize_normals */ {0} /* null-terminating sentinel */, }, bmo_recalc_face_normals_exec, @@ -138,10 +138,10 @@ static BMOpDefine bmo_recalc_face_normals_def = { */ static BMOpDefine bmo_region_extend_def = { "region_extend", - {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, //input geometry - {BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, //output slot, computed boundary geometry. - {BMO_OP_SLOT_BOOL, "constrict"}, //find boundary inside the regions, not outside. - {BMO_OP_SLOT_BOOL, "use_faces"}, //extend from faces instead of edges + {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, /* input geometry */ + {BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, /* output slot, computed boundary geometry. */ + {BMO_OP_SLOT_BOOL, "constrict"}, /* find boundary inside the regions, not outside. */ + {BMO_OP_SLOT_BOOL, "use_faces"}, /* extend from faces instead of edges */ {0} /* null-terminating sentinel */, }, bmo_region_extend_exec, @@ -156,9 +156,9 @@ static BMOpDefine bmo_region_extend_def = { */ static BMOpDefine bmo_rotate_edges_def = { "rotate_edges", - {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, //input edges - {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, //newly spun edges - {BMO_OP_SLOT_BOOL, "ccw"}, //rotate edge counter-clockwise if true, othewise clockwise + {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edges */ + {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, /* newly spun edges */ + {BMO_OP_SLOT_BOOL, "ccw"}, /* rotate edge counter-clockwise if true, othewise clockwise */ {0} /* null-terminating sentinel */, }, bmo_rotate_edges_exec, @@ -173,7 +173,7 @@ static BMOpDefine bmo_rotate_edges_def = { */ static BMOpDefine bmo_reverse_faces_def = { "reverse_faces", - {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, //input faces + {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */ {0} /* null-terminating sentinel */, }, bmo_reverse_faces_exec, @@ -188,9 +188,9 @@ static BMOpDefine bmo_reverse_faces_def = { */ static BMOpDefine bmo_bisect_edges_def = { "bisect_edges", - {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, //input edges - {BMO_OP_SLOT_INT, "numcuts"}, //number of cuts - {BMO_OP_SLOT_ELEMENT_BUF, "outsplit"}, //newly created vertices and edges + {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edges */ + {BMO_OP_SLOT_INT, "numcuts"}, /* number of cuts */ + {BMO_OP_SLOT_ELEMENT_BUF, "outsplit"}, /* newly created vertices and edges */ {0} /* null-terminating sentinel */, }, bmo_bisect_edges_exec, @@ -207,13 +207,13 @@ static BMOpDefine bmo_bisect_edges_def = { static BMOpDefine bmo_mirror_def = { "mirror", - {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, //input geometry - {BMO_OP_SLOT_MAT, "mat"}, //matrix defining the mirror transformation - {BMO_OP_SLOT_FLT, "mergedist"}, //maximum distance for merging. does no merging if 0. - {BMO_OP_SLOT_ELEMENT_BUF, "newout"}, //output geometry, mirrored - {BMO_OP_SLOT_INT, "axis"}, //the axis to use, 0, 1, or 2 for x, y, z - {BMO_OP_SLOT_BOOL, "mirror_u"}, //mirror UVs across the u axis - {BMO_OP_SLOT_BOOL, "mirror_v"}, //mirror UVs across the v axis + {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, /* input geometry */ + {BMO_OP_SLOT_MAT, "mat"}, /* matrix defining the mirror transformation */ + {BMO_OP_SLOT_FLT, "mergedist"}, /* maximum distance for merging. does no merging if 0. */ + {BMO_OP_SLOT_ELEMENT_BUF, "newout"}, /* output geometry, mirrored */ + {BMO_OP_SLOT_INT, "axis"}, /* the axis to use, 0, 1, or 2 for x, y, z */ + {BMO_OP_SLOT_BOOL, "mirror_u"}, /* mirror UVs across the u axis */ + {BMO_OP_SLOT_BOOL, "mirror_v"}, /* mirror UVs across the v axis */ {0, /* null-terminating sentinel */}}, bmo_mirror_exec, 0, @@ -230,9 +230,9 @@ static BMOpDefine bmo_mirror_def = { */ static BMOpDefine bmo_find_doubles_def = { "find_doubles", - {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, //input vertices - {BMO_OP_SLOT_ELEMENT_BUF, "keep_verts"}, //list of verts to keep - {BMO_OP_SLOT_FLT, "dist"}, //minimum distance + {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */ + {BMO_OP_SLOT_ELEMENT_BUF, "keep_verts"}, /* list of verts to keep */ + {BMO_OP_SLOT_FLT, "dist"}, /* minimum distance */ {BMO_OP_SLOT_MAPPING, "targetmapout"}, {0, /* null-terminating sentinel */}}, bmo_find_doubles_exec, @@ -247,8 +247,8 @@ static BMOpDefine bmo_find_doubles_def = { */ static BMOpDefine bmo_remove_doubles_def = { "remove_doubles", - {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, //input verts - {BMO_OP_SLOT_FLT, "dist"}, //minimum distance + {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input verts */ + {BMO_OP_SLOT_FLT, "dist"}, /* minimum distance */ {0, /* null-terminating sentinel */}}, bmo_remove_doubles_exec, BMO_OP_FLAG_UNTAN_MULTIRES, @@ -263,8 +263,8 @@ static BMOpDefine bmo_remove_doubles_def = { */ static BMOpDefine bmo_automerge_def = { "automerge", - {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, //input verts - {BMO_OP_SLOT_FLT, "dist"}, //minimum distance + {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input verts */ + {BMO_OP_SLOT_FLT, "dist"}, /* minimum distance */ {0, /* null-terminating sentinel */}}, bmo_automerge_exec, BMO_OP_FLAG_UNTAN_MULTIRES, @@ -916,11 +916,11 @@ static BMOpDefine bmo_split_edges_def = { */ static BMOpDefine bmo_create_grid_def = { "create_grid", - {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, //output verts - {BMO_OP_SLOT_INT, "xsegments"}, //number of x segments - {BMO_OP_SLOT_INT, "ysegments"}, //number of y segments - {BMO_OP_SLOT_FLT, "size"}, //size of the grid - {BMO_OP_SLOT_MAT, "mat"}, //matrix to multiply the new geometry with + {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output verts */ + {BMO_OP_SLOT_INT, "xsegments"}, /* number of x segments */ + {BMO_OP_SLOT_INT, "ysegments"}, /* number of y segments */ + {BMO_OP_SLOT_FLT, "size"}, /* size of the grid */ + {BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with */ {0, /* null-terminating sentinel */}}, bmo_create_grid_exec, 0, @@ -933,11 +933,11 @@ static BMOpDefine bmo_create_grid_def = { */ static BMOpDefine bmo_create_uvsphere_def = { "create_uvsphere", - {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, //output verts - {BMO_OP_SLOT_INT, "segments"}, //number of u segments - {BMO_OP_SLOT_INT, "revolutions"}, //number of v segment - {BMO_OP_SLOT_FLT, "diameter"}, //diameter - {BMO_OP_SLOT_MAT, "mat"}, //matrix to multiply the new geometry with-- + {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output verts */ + {BMO_OP_SLOT_INT, "segments"}, /* number of u segments */ + {BMO_OP_SLOT_INT, "revolutions"}, /* number of v segment */ + {BMO_OP_SLOT_FLT, "diameter"}, /* diameter */ + {BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with-- */ {0, /* null-terminating sentinel */}}, bmo_create_uvsphere_exec, 0, @@ -950,10 +950,10 @@ static BMOpDefine bmo_create_uvsphere_def = { */ static BMOpDefine bmo_create_icosphere_def = { "create_icosphere", - {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, //output verts - {BMO_OP_SLOT_INT, "subdivisions"}, //how many times to recursively subdivide the sphere - {BMO_OP_SLOT_FLT, "diameter"}, //diameter - {BMO_OP_SLOT_MAT, "mat"}, //matrix to multiply the new geometry with + {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output verts */ + {BMO_OP_SLOT_INT, "subdivisions"}, /* how many times to recursively subdivide the sphere */ + {BMO_OP_SLOT_FLT, "diameter"}, /* diameter */ + {BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with */ {0, /* null-terminating sentinel */}}, bmo_create_icosphere_exec, 0, @@ -966,8 +966,8 @@ static BMOpDefine bmo_create_icosphere_def = { */ static BMOpDefine bmo_create_monkey_def = { "create_monkey", - {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, //output verts - {BMO_OP_SLOT_MAT, "mat"}, //matrix to multiply the new geometry with-- + {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output verts */ + {BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with-- */ {0, /* null-terminating sentinel */}}, bmo_create_monkey_exec, 0, @@ -980,14 +980,14 @@ static BMOpDefine bmo_create_monkey_def = { */ static BMOpDefine bmo_create_cone_def = { "create_cone", - {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, //output verts - {BMO_OP_SLOT_BOOL, "cap_ends"}, //wheter or not to fill in the ends with faces - {BMO_OP_SLOT_BOOL, "cap_tris"}, //fill ends with triangles instead of ngons + {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output verts */ + {BMO_OP_SLOT_BOOL, "cap_ends"}, /* wheter or not to fill in the ends with faces */ + {BMO_OP_SLOT_BOOL, "cap_tris"}, /* fill ends with triangles instead of ngons */ {BMO_OP_SLOT_INT, "segments"}, - {BMO_OP_SLOT_FLT, "diameter1"}, //diameter of one end - {BMO_OP_SLOT_FLT, "diameter2"}, //diameter of the opposite - {BMO_OP_SLOT_FLT, "depth"}, //distance between ends - {BMO_OP_SLOT_MAT, "mat"}, //matrix to multiply the new geometry with-- + {BMO_OP_SLOT_FLT, "diameter1"}, /* diameter of one end */ + {BMO_OP_SLOT_FLT, "diameter2"}, /* diameter of the opposite */ + {BMO_OP_SLOT_FLT, "depth"}, /* distance between ends */ + {BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with-- */ {0, /* null-terminating sentinel */}}, bmo_create_cone_exec, 0, @@ -998,12 +998,12 @@ static BMOpDefine bmo_create_cone_def = { */ static BMOpDefine bmo_create_circle_def = { "create_circle", - {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, //output verts - {BMO_OP_SLOT_BOOL, "cap_ends"}, //wheter or not to fill in the ends with faces - {BMO_OP_SLOT_BOOL, "cap_tris"}, //fill ends with triangles instead of ngons + {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output verts */ + {BMO_OP_SLOT_BOOL, "cap_ends"}, /* wheter or not to fill in the ends with faces */ + {BMO_OP_SLOT_BOOL, "cap_tris"}, /* fill ends with triangles instead of ngons */ {BMO_OP_SLOT_INT, "segments"}, - {BMO_OP_SLOT_FLT, "diameter"}, //diameter of one end - {BMO_OP_SLOT_MAT, "mat"}, //matrix to multiply the new geometry with-- + {BMO_OP_SLOT_FLT, "diameter"}, /* diameter of one end */ + {BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with-- */ {0, /* null-terminating sentinel */}}, bmo_create_circle_exec, 0, @@ -1016,9 +1016,9 @@ static BMOpDefine bmo_create_circle_def = { */ static BMOpDefine bmo_create_cube_def = { "create_cube", - {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, //output verts - {BMO_OP_SLOT_FLT, "size"}, //size of the cube - {BMO_OP_SLOT_MAT, "mat"}, //matrix to multiply the new geometry with-- + {{BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output verts */ + {BMO_OP_SLOT_FLT, "size"}, /* size of the cube */ + {BMO_OP_SLOT_MAT, "mat"}, /* matrix to multiply the new geometry with-- */ {0, /* null-terminating sentinel */}}, bmo_create_cube_exec, 0, diff --git a/source/blender/bmesh/operators/bmo_hull.c b/source/blender/bmesh/operators/bmo_hull.c index d4f63ab7557..b22bdf60210 100644 --- a/source/blender/bmesh/operators/bmo_hull.c +++ b/source/blender/bmesh/operators/bmo_hull.c @@ -31,6 +31,13 @@ #include "BLI_math.h" #include "BLI_utildefines.h" +/*XXX: This operator doesn't work well (at all?) for flat surfaces with + * >3 sides - creating overlapping faces at times. + * An easy workaround is to add in some noise but this is + * weak and unreliable, ideally this would detect flat surfaces + * (possibly making them into ngons) - see + */ + /* XXX: using 128 for totelem and pchunk of mempool, no idea what good * values would be though */ #include "BLI_mempool.h" diff --git a/source/blender/compositor/operations/COM_BokehBlurOperation.cpp b/source/blender/compositor/operations/COM_BokehBlurOperation.cpp index fb06f6d3761..e83ad4824e4 100644 --- a/source/blender/compositor/operations/COM_BokehBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_BokehBlurOperation.cpp @@ -160,15 +160,13 @@ bool BokehBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBuffe return false; } -static cl_kernel kernel = 0; void BokehBlurOperation::executeOpenCL(OpenCLDevice* device, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp) { - if (!kernel) { - kernel = device->COM_clCreateKernel("bokehBlurKernel", NULL); - } + cl_kernel kernel = device->COM_clCreateKernel("bokehBlurKernel", NULL); + cl_int radius = this->getWidth() * this->m_size / 100.0f; cl_int step = this->getStep(); diff --git a/source/blender/compositor/operations/COM_DilateErodeOperation.cpp b/source/blender/compositor/operations/COM_DilateErodeOperation.cpp index 338a3a0b59b..a9b40f8a6ac 100644 --- a/source/blender/compositor/operations/COM_DilateErodeOperation.cpp +++ b/source/blender/compositor/operations/COM_DilateErodeOperation.cpp @@ -234,15 +234,13 @@ bool DilateDistanceOperation::determineDependingAreaOfInterest(rcti *input, Read return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } -static cl_kernel dilateKernel = 0; void DilateDistanceOperation::executeOpenCL(OpenCLDevice* device, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp) { - if (!dilateKernel) { - dilateKernel = device->COM_clCreateKernel("dilateKernel", NULL); - } + cl_kernel dilateKernel = device->COM_clCreateKernel("dilateKernel", NULL); + cl_int distanceSquared = this->m_distance * this->m_distance; cl_int scope = this->m_scope; @@ -293,15 +291,13 @@ void ErodeDistanceOperation::executePixel(float *color, int x, int y, MemoryBuff color[0] = value; } -static cl_kernel erodeKernel = 0; void ErodeDistanceOperation::executeOpenCL(OpenCLDevice* device, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp) { - if (!erodeKernel) { - erodeKernel = device->COM_clCreateKernel("erodeKernel", NULL); - } + cl_kernel erodeKernel = device->COM_clCreateKernel("erodeKernel", NULL); + cl_int distanceSquared = this->m_distance * this->m_distance; cl_int scope = this->m_scope; diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp index 7ddcb78b61f..90fd0f04ea4 100644 --- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp @@ -130,15 +130,13 @@ void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, Me } -static cl_kernel defocusKernel = 0; void VariableSizeBokehBlurOperation::executeOpenCL(OpenCLDevice* device, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp) { - if (!defocusKernel) { - defocusKernel = device->COM_clCreateKernel("defocusKernel", NULL); - } + cl_kernel defocusKernel = device->COM_clCreateKernel("defocusKernel", NULL); + cl_int step = this->getStep(); cl_int maxBlur = this->m_maxBlur; cl_float threshold = this->m_threshold; diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index f6b301c4594..a21154bde1b 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -3009,28 +3009,28 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float offset += ICON_WIDTH; } } - + /* step 5) draw name ............................................... */ - // TODO: when renaming, we might not want to draw this, especially if name happens to be longer than channel + /* TODO: when renaming, we might not want to draw this, especially if name happens to be longer than channel */ if (acf->name) { char name[ANIM_CHAN_NAME_SIZE]; /* hopefully this will be enough! */ - + /* set text color */ - // XXX: if active, highlight differently? + /* XXX: if active, highlight differently? */ if (selected) UI_ThemeColor(TH_TEXT_HI); else UI_ThemeColor(TH_TEXT); - + /* get name */ acf->name(ale, name); - + offset += 3; UI_DrawString(offset, ytext, name); - + /* draw red underline if channel is disabled */ if ((ale->type == ANIMTYPE_FCURVE) && (ale->flag & FCURVE_DISABLED)) { - // FIXME: replace hardcoded color here, and check on extents! + /* FIXME: replace hardcoded color here, and check on extents! */ glColor3f(1.0f, 0.0f, 0.0f); glLineWidth(2.0); fdrawline((float)(offset), yminc, @@ -3038,13 +3038,13 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float glLineWidth(1.0); } } - + /* step 6) draw backdrops behidn mute+protection toggles + (sliders) ....................... */ /* reset offset - now goes from RHS of panel */ offset = 0; - - // TODO: when drawing sliders, make those draw instead of these toggles if not enough space - + + /* TODO: when drawing sliders, make those draw instead of these toggles if not enough space */ + if (v2d) { short draw_sliders = 0; float color[3]; diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index 5c57407d14e..9cd2b29afa6 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -400,7 +400,7 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAn /* compare data, and type as main way of identifying the channel */ if ((ale->data == ale_setting->data) && (ale->type == ale_setting->type)) { /* we also have to check the ID, this is assigned to, since a block may have multiple users */ - // TODO: is the owner-data more revealing? + /* TODO: is the owner-data more revealing? */ if (ale->id == ale_setting->id) { match = ale; break; @@ -576,13 +576,13 @@ static int animedit_poll_channels_active(bContext *C) ScrArea *sa = CTX_wm_area(C); /* channels region test */ - // TODO: could enhance with actually testing if channels region? + /* TODO: could enhance with actually testing if channels region? */ if (ELEM(NULL, sa, CTX_wm_region(C))) return 0; /* animation editor test */ if (ELEM3(sa->spacetype, SPACE_ACTION, SPACE_IPO, SPACE_NLA) == 0) return 0; - + return 1; } @@ -591,9 +591,9 @@ static int animedit_poll_channels_nla_tweakmode_off(bContext *C) { ScrArea *sa = CTX_wm_area(C); Scene *scene = CTX_data_scene(C); - + /* channels region test */ - // TODO: could enhance with actually testing if channels region? + /* TODO: could enhance with actually testing if channels region? */ if (ELEM(NULL, sa, CTX_wm_region(C))) return 0; /* animation editor test */ @@ -1314,16 +1314,16 @@ static int animchannels_visibility_set_exec(bContext *C, wmOperator *UNUSED(op)) /* make all the selected channels visible */ filter = (ANIMFILTER_SEL | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + for (ale = anim_data.first; ale; ale = ale->next) { /* hack: skip object channels for now, since flushing those will always flush everything, but they are always included */ - // TODO: find out why this is the case, and fix that + /* TODO: find out why this is the case, and fix that */ if (ale->type == ANIMTYPE_OBJECT) continue; - + /* enable the setting */ ANIM_channel_setting_set(&ac, ale, ACHANNEL_SETTING_VISIBLE, ACHANNEL_SETFLAG_ADD); - + /* now, also flush selection status up/down as appropriate */ ANIM_flush_setting_anim_channels(&ac, &all_data, ale, ACHANNEL_SETTING_VISIBLE, 1); } @@ -1394,13 +1394,13 @@ static int animchannels_visibility_toggle_exec(bContext *C, wmOperator *UNUSED(o /* Now set the flags */ for (ale = anim_data.first; ale; ale = ale->next) { /* hack: skip object channels for now, since flushing those will always flush everything, but they are always included */ - // TODO: find out why this is the case, and fix that + /* TODO: find out why this is the case, and fix that */ if (ale->type == ANIMTYPE_OBJECT) continue; - + /* change the setting */ ANIM_channel_setting_set(&ac, ale, ACHANNEL_SETTING_VISIBLE, vis); - + /* now, also flush selection status up/down as appropriate */ ANIM_flush_setting_anim_channels(&ac, &all_data, ale, ACHANNEL_SETTING_VISIBLE, (vis == ACHANNEL_SETFLAG_ADD)); } @@ -1734,9 +1734,9 @@ static void ANIM_OT_channels_collapse(wmOperatorType *ot) static int animchannels_enable_poll(bContext *C) { ScrArea *sa = CTX_wm_area(C); - + /* channels region test */ - // TODO: could enhance with actually testing if channels region? + /* TODO: could enhance with actually testing if channels region? */ if (ELEM(NULL, sa, CTX_wm_region(C))) return 0; @@ -2103,17 +2103,17 @@ static int mouse_anim_channels(bAnimContext *ac, float UNUSED(x), int channel_in BLI_freelistN(&anim_data); return 0; } - + /* selectmode -1 is a special case for ActionGroups only, which selects all of the channels underneath it only... */ - // TODO: should this feature be extended to work with other channel types too? + /* TODO: should this feature be extended to work with other channel types too? */ if ((selectmode == -1) && (ale->type != ANIMTYPE_GROUP)) { /* normal channels should not behave normally in this case */ BLI_freelistN(&anim_data); return 0; } - + /* action to take depends on what channel we've got */ - // WARNING: must keep this in sync with the equivalent function in nla_channels.c + /* WARNING: must keep this in sync with the equivalent function in nla_channels.c */ switch (ale->type) { case ANIMTYPE_SCENE: { @@ -2152,9 +2152,9 @@ static int mouse_anim_channels(bAnimContext *ac, float UNUSED(x), int channel_in } else { Base *b; - + /* deselect all */ - // TODO: should this deselect all other types of channels too? + /* TODO: should this deselect all other types of channels too? */ for (b = sce->base.first; b; b = b->next) { b->flag &= ~SELECT; b->object->flag = b->flag; @@ -2438,10 +2438,10 @@ void ED_operatortypes_animchannels(void) WM_operatortype_append(ANIM_OT_channels_setting_enable); WM_operatortype_append(ANIM_OT_channels_setting_disable); WM_operatortype_append(ANIM_OT_channels_setting_toggle); - + WM_operatortype_append(ANIM_OT_channels_delete); - - // XXX does this need to be a separate operator? + + /* XXX does this need to be a separate operator? */ WM_operatortype_append(ANIM_OT_channels_editable_toggle); WM_operatortype_append(ANIM_OT_channels_move); @@ -2463,11 +2463,11 @@ void ED_keymap_animchannels(wmKeyConfig *keyconf) /* selection */ /* click-select */ - // XXX for now, only leftmouse.... + /* XXX for now, only leftmouse.... */ WM_keymap_add_item(keymap, "ANIM_OT_channels_click", LEFTMOUSE, KM_PRESS, 0, 0); RNA_boolean_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_click", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "extend", TRUE); RNA_boolean_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_click", LEFTMOUSE, KM_PRESS, KM_CTRL | KM_SHIFT, 0)->ptr, "children_only", TRUE); - + /* rename */ WM_keymap_add_item(keymap, "ANIM_OT_channels_rename", LEFTMOUSE, KM_PRESS, KM_CTRL, 0); diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c index ddc4f4d943c..0d48bf19c9e 100644 --- a/source/blender/editors/animation/anim_draw.c +++ b/source/blender/editors/animation/anim_draw.c @@ -381,11 +381,11 @@ float ANIM_unit_mapping_get_factor(Scene *scene, ID *id, FCurve *fcu, short rest return RAD2DEGF(1.0f); /* radians to degrees */ } } - - // TODO: other rotation types here as necessary + + /* TODO: other rotation types here as necessary */ } } - + /* no mapping needs to occur... */ return 1.0f; } diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index a6d1ac64bbe..e239719d894 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -164,21 +164,21 @@ static short actedit_get_context(bAnimContext *ac, SpaceAction *saction) ac->mode = saction->mode; return 1; - - case SACTCONT_GPENCIL: /* Grease Pencil */ // XXX review how this mode is handled... + + case SACTCONT_GPENCIL: /* Grease Pencil */ /* XXX review how this mode is handled... */ /* update scene-pointer (no need to check for pinning yet, as not implemented) */ saction->ads.source = (ID *)ac->scene; - + ac->datatype = ANIMCONT_GPENCIL; ac->data = &saction->ads; - + ac->mode = saction->mode; return 1; - - case SACTCONT_MASK: /* Grease Pencil */ // XXX review how this mode is handled... + + case SACTCONT_MASK: /* Grease Pencil */ /* XXX review how this mode is handled... */ /* update scene-pointer (no need to check for pinning yet, as not implemented) */ { - // TODO, other methods to get the mask + /* TODO, other methods to get the mask */ // Sequence *seq = BKE_sequencer_active_get(ac->scene); //MovieClip *clip = ac->scene->clip; // struct Mask *mask = seq ? seq->mask : NULL; @@ -1890,9 +1890,9 @@ static size_t animdata_filter_ds_obanim(bAnimContext *ac, ListBase *anim_data, b AnimData *adt = ob->adt; short type = 0, expanded = 1; void *cdata = NULL; - + /* determine the type of expander channels to use */ - // this is the best way to do this for now... + /* this is the best way to do this for now... */ ANIMDATA_FILTER_CASES(ob, { /* AnimData - no channel, but consider data */ }, { /* NLA - no channel, but consider data */ }, @@ -2122,11 +2122,11 @@ static size_t animdata_filter_dopesheet_scene(bAnimContext *ac, ListBase *anim_d if ((ntree) && !(ads->filterflag & ADS_FILTER_NONTREE)) { tmp_items += animdata_filter_ds_nodetree(ac, &tmp_data, ads, (ID *)sce, ntree, filter_mode); } - - // TODO: one day, when sequencer becomes its own datatype, perhaps it should be included here + + /* TODO: one day, when sequencer becomes its own datatype, perhaps it should be included here */ } END_ANIMFILTER_SUBCHANNELS; - + /* if we collected some channels, add these to the new list... */ if (tmp_items) { /* firstly add object expander if required */ diff --git a/source/blender/editors/animation/anim_ipo_utils.c b/source/blender/editors/animation/anim_ipo_utils.c index a73651d7664..35782c3b3ae 100644 --- a/source/blender/editors/animation/anim_ipo_utils.c +++ b/source/blender/editors/animation/anim_ipo_utils.c @@ -143,15 +143,15 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu) /* no array index */ arrayname = ""; } - + /* putting this all together into the buffer */ - // XXX we need to check for invalid names... - // XXX the name length limit needs to be passed in or as some define + /* XXX we need to check for invalid names... + * XXX the name length limit needs to be passed in or as some define */ if (structname) - BLI_snprintf(name, 256, "%s%s (%s)", arrayname, propname, structname); + BLI_snprintf(name, 256, "%s%s (%s)", arrayname, propname, structname); else - BLI_snprintf(name, 256, "%s%s", arrayname, propname); - + BLI_snprintf(name, 256, "%s%s", arrayname, propname); + /* free temp name if nameprop is set */ if (free_structname) MEM_freeN((void *)structname); @@ -170,11 +170,11 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu) else { /* invalid path */ BLI_snprintf(name, 256, "\"%s[%d]\"", fcu->rna_path, fcu->array_index); - + /* icon for this should be the icon for the base ID */ - // TODO: or should we just use the error icon? + /* TODO: or should we just use the error icon? */ icon = RNA_struct_ui_icon(id_ptr.type); - + /* tag F-Curve as disabled - as not usable path */ fcu->flag |= FCURVE_DISABLED; } diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c index 8c1e2bedd86..91cc602c838 100644 --- a/source/blender/editors/animation/fmodifier_ui.c +++ b/source/blender/editors/animation/fmodifier_ui.c @@ -506,10 +506,10 @@ static void draw_modifier__envelope(uiLayout *layout, ID *id, FModifier *fcm, sh row = uiLayoutRow(col, TRUE); uiItemR(row, &ptr, "default_min", 0, IFACE_("Min"), ICON_NONE); uiItemR(row, &ptr, "default_max", 0, IFACE_("Max"), ICON_NONE); - + /* control points header */ - // TODO: move this control-point control stuff to using the new special widgets for lists - // the current way is far too cramped + /* TODO: move this control-point control stuff to using the new special widgets for lists + * the current way is far too cramped */ row = uiLayoutRow(layout, FALSE); block = uiLayoutGetBlock(row); diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c index 46a89963ad9..84711b97729 100644 --- a/source/blender/editors/animation/keyframes_draw.c +++ b/source/blender/editors/animation/keyframes_draw.c @@ -673,23 +673,23 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa /* draw keys */ if (keys) { /* locked channels are less strongly shown, as feedback for locked channels in DopeSheet */ - // TODO: allow this opacity factor to be themed? + /* TODO: allow this opacity factor to be themed? */ float kalpha = (channelLocked) ? 0.35f : 1.0f; - + for (ak = keys->first; ak; ak = ak->next) { - /* optimization: if keyframe doesn't appear within 5 units (screenspace) in visible area, don't draw + /* optimization: if keyframe doesn't appear within 5 units (screenspace) in visible area, don't draw * - this might give some improvements, since we current have to flip between view/region matrices */ if (IN_RANGE_INCL(ak->cfra, v2d->cur.xmin, v2d->cur.xmax) == 0) continue; - + /* draw using OpenGL - uglier but faster */ - // NOTE1: a previous version of this didn't work nice for some intel cards - // NOTE2: if we wanted to go back to icons, these are icon = (ak->sel & SELECT) ? ICON_SPACE2 : ICON_SPACE3; + /* NOTE1: a previous version of this didn't work nice for some intel cards + * NOTE2: if we wanted to go back to icons, these are icon = (ak->sel & SELECT) ? ICON_SPACE2 : ICON_SPACE3; */ draw_keyframe_shape(ak->cfra, ypos, xscale, 5.0f, (ak->sel & SELECT), ak->key_type, KEYFRAME_SHAPE_BOTH, kalpha); - } + } } - + glDisable(GL_BLEND); } diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 0c9a6ff6bf1..7600e1d4690 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -134,9 +134,9 @@ bAction *verify_adt_action(ID *id, short add) printf("ERROR: Couldn't add AnimData (ID = %s)\n", (id) ? (id->name) : "<None>"); return NULL; } - + /* init action if none available yet */ - // TODO: need some wizardry to handle NLA stuff correct + /* TODO: need some wizardry to handle NLA stuff correct */ if ((adt->action == NULL) && (add)) { char actname[sizeof(id->name) - 2]; BLI_snprintf(actname, sizeof(actname), "%sAction", id->name + 2); @@ -256,8 +256,8 @@ int insert_bezt_fcurve(FCurve *fcu, BezTriple *bezt, short flag) dst->f1 = bezt->f1; dst->f2 = bezt->f2; dst->f3 = bezt->f3; - - // TODO: perform some other operations? + + /* TODO: perform some other operations? */ } } /* keyframing modes allow to not replace keyframe */ @@ -1691,11 +1691,11 @@ static short object_frame_has_keyframe(Object *ob, float frame, short filter) /* 1. test for relative (with keyframes) */ if (id_frame_has_keyframe((ID *)key, frame, filter)) return 1; - + /* 2. test for time */ - // TODO... yet to be implemented (this feature may evolve before then anyway) + /* TODO... yet to be implemented (this feature may evolve before then anyway) */ } - + /* try materials */ if (!(filter & ANIMFILTER_KEYS_LOCAL) && !(filter & ANIMFILTER_KEYS_NOMAT) ) { /* if only active, then we can skip a lot of looping */ diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index cd914f9ff9a..04fd7f677b0 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -597,13 +597,13 @@ void ANIM_keyingset_info_register(KeyingSetInfo *ksi) void ANIM_keyingset_info_unregister(Main *bmain, KeyingSetInfo *ksi) { KeyingSet *ks, *ksn; - + /* find relevant builtin KeyingSets which use this, and remove them */ - // TODO: this isn't done now, since unregister is really only used atm when we - // reload the scripts, which kindof defeats the purpose of "builtin"? + /* TODO: this isn't done now, since unregister is really only used atm when we + * reload the scripts, which kindof defeats the purpose of "builtin"? */ for (ks = builtin_keyingsets.first; ks; ks = ksn) { ksn = ks->next; - + /* remove if matching typeinfo name */ if (strcmp(ks->typeinfo, ksi->idname) == 0) { Scene *scene; @@ -791,8 +791,8 @@ short ANIM_keyingset_context_ok_poll(bContext *C, KeyingSet *ks) /* get the associated 'type info' for this KeyingSet */ if (ksi == NULL) return 0; - // TODO: check for missing callbacks! - + /* TODO: check for missing callbacks! */ + /* check if it can be used in the current context */ return (ksi->poll(ksi, C)); } @@ -878,8 +878,8 @@ short ANIM_validate_keyingset(bContext *C, ListBase *dsources, KeyingSet *ks) /* get the associated 'type info' for this KeyingSet */ if (ksi == NULL) return MODIFYKEY_MISSING_TYPEINFO; - // TODO: check for missing callbacks! - + /* TODO: check for missing callbacks! */ + /* check if it can be used in the current context */ if (ksi->poll(ksi, C)) { /* if a list of data sources are provided, run a special iterator over them, diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c index 59ee90c553b..c19904d39ac 100644 --- a/source/blender/editors/armature/armature_ops.c +++ b/source/blender/editors/armature/armature_ops.c @@ -191,8 +191,8 @@ void ED_operatormacros_armature(void) RNA_enum_set(otmacro->ptr, "proportional", 0); } - // XXX would it be nicer to just be able to have standard extrude_move, but set the forked property separate? - // that would require fixing a properties bug 19733 + /* XXX would it be nicer to just be able to have standard extrude_move, but set the forked property separate? + * that would require fixing a properties bug 19733 */ ot = WM_operatortype_append_macro("ARMATURE_OT_extrude_forked", "Extrude Forked", "Create new bones from the selected joints and move them", OPTYPE_UNDO | OPTYPE_REGISTER); @@ -218,7 +218,7 @@ void ED_keymap_armature(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "SKETCH_OT_delete", DELKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "SKETCH_OT_finish_stroke", RIGHTMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "SKETCH_OT_cancel_stroke", ESCKEY, KM_PRESS, 0, 0); - // Already part of view3d select + /* Already part of view3d select */ //WM_keymap_add_item(keymap, "SKETCH_OT_select", SELECTMOUSE, KM_PRESS, 0, 0); /* sketch poll checks mode */ @@ -321,7 +321,7 @@ void ED_keymap_armature(wmKeyConfig *keyconf) WM_keymap_add_menu(keymap, "VIEW3D_MT_pose_apply", AKEY, KM_PRESS, KM_CTRL, 0); - // TODO: clear pose + /* TODO: clear pose */ WM_keymap_add_item(keymap, "POSE_OT_rot_clear", RKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "POSE_OT_loc_clear", GKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "POSE_OT_scale_clear", SKEY, KM_PRESS, KM_ALT, 0); diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 6cef843d828..2a3f2182fdf 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -657,12 +657,12 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "Cannot apply pose to lib-linked armature"); //error_libdata(); return OPERATOR_CANCELLED; } - + /* helpful warnings... */ - // TODO: add warnings to be careful about actions, applying deforms first, etc. - if (ob->adt && ob->adt->action) + /* TODO: add warnings to be careful about actions, applying deforms first, etc. */ + if (ob->adt && ob->adt->action) BKE_report(op->reports, RPT_WARNING, "Actions on this armature will be destroyed by this new rest pose as the transforms stored are relative to the old rest pose"); - + /* Get editbones of active armature to alter */ ED_armature_to_edit(ob); @@ -1192,9 +1192,9 @@ static int separate_armature_exec(bContext *C, wmOperator *UNUSED(op)) * 4. fix constraint links * 5. make original armature active and enter editmode */ - + /* 1) only edit-base selected */ - // TODO: use context iterators for this? + /* TODO: use context iterators for this? */ CTX_DATA_BEGIN(C, Base *, base, visible_bases) { if (base->object == obedit) base->flag |= 1; @@ -1402,7 +1402,7 @@ static void selectconnected_posebonechildren(Object *ob, Bone *bone, int extend) if (!(bone->flag & BONE_CONNECTED) || (bone->flag & BONE_UNSELECTABLE)) return; - // XXX old cruft! use notifiers instead + /* XXX old cruft! use notifiers instead */ //select_actionchannel_by_name (ob->action, bone->name, !(shift)); if (extend) @@ -5404,7 +5404,7 @@ static int hide_unselected_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr bArmature *arm = ob->data; if (arm->layer & bone->layer) { - // hrm... typo here? + /* hrm... typo here? */ if ((bone->flag & BONE_SELECTED) == 0) { bone->flag |= BONE_HIDDEN_P; if (arm->act_bone == bone) diff --git a/source/blender/editors/armature/poseSlide.c b/source/blender/editors/armature/poseSlide.c index 51700793791..cdcb3ab4683 100644 --- a/source/blender/editors/armature/poseSlide.c +++ b/source/blender/editors/armature/poseSlide.c @@ -243,32 +243,32 @@ static void pose_slide_apply_val(tPoseSlideOp *pso, FCurve *fcu, float *val) * - numerator should be larger than denominator to 'expand' the result * - perform this weighting a number of times given by the percentage... */ - int iters = (int)ceil(10.0f * pso->percentage); // TODO: maybe a sensitivity ctrl on top of this is needed - + int iters = (int)ceil(10.0f * pso->percentage); /* TODO: maybe a sensitivity ctrl on top of this is needed */ + while (iters-- > 0) { (*val) = (-((sVal * w2) + (eVal * w1)) + ((*val) * 6.0f) ) / 5.0f; } } break; - + case POSESLIDE_RELAX: /* make the current pose more like its surrounding ones */ { /* perform a weighted average here, favoring the middle pose * - numerator should be smaller than denominator to 'relax' the result * - perform this weighting a number of times given by the percentage... */ - int iters = (int)ceil(10.0f * pso->percentage); // TODO: maybe a sensitivity ctrl on top of this is needed - + int iters = (int)ceil(10.0f * pso->percentage); /* TODO: maybe a sensitivity ctrl on top of this is needed */ + while (iters-- > 0) { (*val) = ( ((sVal * w2) + (eVal * w1)) + ((*val) * 5.0f) ) / 6.0f; } } break; - + case POSESLIDE_BREAKDOWN: /* make the current pose slide around between the endpoints */ { /* perform simple linear interpolation - coefficient for start must come from pso->percentage... */ - // TODO: make this use some kind of spline interpolation instead? + /* TODO: make this use some kind of spline interpolation instead? */ (*val) = ((sVal * w2) + (eVal * w1)); } break; @@ -415,11 +415,11 @@ static void pose_slide_apply_quat(tPoseSlideOp *pso, tPChanFCurveLink *pfl) } else if (pso->mode == POSESLIDE_PUSH) { float quat_diff[4], quat_orig[4]; - + /* calculate the delta transform from the previous to the current */ - // TODO: investigate ways to favour one transform more? + /* TODO: investigate ways to favour one transform more? */ sub_qt_qtqt(quat_diff, pchan->quat, quat_prev); - + /* make a copy of the original rotation */ copy_qt_qt(quat_orig, pchan->quat); @@ -428,8 +428,8 @@ static void pose_slide_apply_quat(tPoseSlideOp *pso, tPChanFCurveLink *pfl) } else { float quat_interp[4], quat_orig[4]; - int iters = (int)ceil(10.0f * pso->percentage); // TODO: maybe a sensitivity ctrl on top of this is needed - + int iters = (int)ceil(10.0f * pso->percentage); /* TODO: maybe a sensitivity ctrl on top of this is needed */ + /* perform this blending several times until a satisfactory result is reached */ while (iters-- > 0) { /* calculate the interpolation between the endpoints */ diff --git a/source/blender/editors/armature/poseUtils.c b/source/blender/editors/armature/poseUtils.c index 4e0398168d3..e2e3c49e7e0 100644 --- a/source/blender/editors/armature/poseUtils.c +++ b/source/blender/editors/armature/poseUtils.c @@ -185,7 +185,7 @@ void poseAnim_mapping_refresh(bContext *C, Scene *scene, Object *ob) /* old optimize trick... this enforces to bypass the depgraph * - note: code copied from transform_generics.c -> recalcData() */ - // FIXME: shouldn't this use the builtin stuff? + /* FIXME: shouldn't this use the builtin stuff? */ if ((arm->flag & ARM_DELAYDEFORM) == 0) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* sets recalc flags */ else diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c index ee54fc2c6fe..23c987c3536 100644 --- a/source/blender/editors/armature/poselib.c +++ b/source/blender/editors/armature/poselib.c @@ -306,11 +306,11 @@ static int poselib_sanitize_exec(bContext *C, wmOperator *op) BLI_dlrbTree_init(&keys); action_to_keylist(NULL, act, &keys, NULL); BLI_dlrbTree_linkedlist_sync(&keys); - + /* for each key, make sure there is a corresponding pose */ for (ak = keys.first; ak; ak = ak->next) { /* check if any pose matches this */ - // TODO: don't go looking through the list like this every time... + /* TODO: don't go looking through the list like this every time... */ for (marker = act->markers.first; marker; marker = marker->next) { if (IS_EQ(marker->frame, (double)ak->cfra)) { marker->flag = -1; @@ -472,8 +472,8 @@ static int poselib_add_exec(bContext *C, wmOperator *op) BLI_uniquename(&act->markers, marker, "Pose", '.', offsetof(TimeMarker, name), sizeof(marker->name)); /* use Keying Set to determine what to store for the pose */ - // FIXME: in the past, the Keying Set respected selections (LocRotScale), but the current one doesn't (WholeCharacter) - // so perhaps we need either a new Keying Set, or just to add overrides here... + /* FIXME: in the past, the Keying Set respected selections (LocRotScale), but the current one doesn't + * (WholeCharacter) so perhaps we need either a new Keying Set, or just to add overrides here... */ ANIM_apply_keyingset(C, NULL, act, ks, MODIFYKEY_MODE_INSERT, (float)frame); /* store new 'active' pose number */ @@ -819,12 +819,12 @@ static void poselib_backup_restore(tPoseLib_PreviewData *pld) for (plb = pld->backups.first; plb; plb = plb->next) { /* copy most of data straight back */ memcpy(plb->pchan, &plb->olddata, sizeof(bPoseChannel)); - + /* just overwrite values of properties from the stored copies (there should be some) */ if (plb->oldprops) IDP_SyncGroupValues(plb->pchan->prop, plb->oldprops); - - // TODO: constraints settings aren't restored yet, even though these could change (though not that likely) + + /* TODO: constraints settings aren't restored yet, even though these could change (though not that likely) */ } } @@ -832,10 +832,10 @@ static void poselib_backup_restore(tPoseLib_PreviewData *pld) static void poselib_backup_free_data(tPoseLib_PreviewData *pld) { tPoseLib_Backup *plb, *plbn; - + for (plb = pld->backups.first; plb; plb = plbn) { plbn = plb->next; - + /* free custom data */ if (plb->oldprops) { IDP_FreeProperty(plb->oldprops); @@ -1658,11 +1658,11 @@ void POSELIB_OT_apply_pose(wmOperatorType *ot) /* callbacks */ ot->exec = poselib_preview_exec; ot->poll = has_poselib_pose_data_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - - /* properties */ - // TODO: make the pose_index into a proper enum instead of a cryptic int... + + /* properties */ + /* TODO: make the pose_index into a proper enum instead of a cryptic int... */ ot->prop = RNA_def_int(ot->srna, "pose_index", -1, -2, INT_MAX, "Pose", "Index of the pose to apply (-2 for no change to pose, -1 for poselib active pose)", 0, INT_MAX); } diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c index 9bcbf313f13..f837d8a726e 100644 --- a/source/blender/editors/armature/poseobject.c +++ b/source/blender/editors/armature/poseobject.c @@ -103,7 +103,7 @@ void ED_armature_enter_posemode(bContext *C, Base *base) return; } - // XXX: disabled as this would otherwise cause a nasty loop... + /* XXX: disabled as this would otherwise cause a nasty loop... */ //ED_object_toggle_modes(C, ob->mode); } @@ -253,14 +253,14 @@ static int pose_calculate_paths_exec(bContext *C, wmOperator *op) animviz_verify_motionpaths(op->reports, scene, ob, pchan); } CTX_DATA_END; - + /* calculate the bones that now have motionpaths... */ - // TODO: only make for the selected bones? + /* TODO: only make for the selected bones? */ ED_pose_recalculate_paths(scene, ob); - + /* notifiers for updates */ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); - + return OPERATOR_FINISHED; } @@ -299,9 +299,9 @@ static int pose_update_paths_exec(bContext *C, wmOperator *UNUSED(op)) if (ELEM(NULL, ob, scene)) return OPERATOR_CANCELLED; - + /* calculate the bones that now have motionpaths... */ - // TODO: only make for the selected bones? + /* TODO: only make for the selected bones? */ ED_pose_recalculate_paths(scene, ob); /* notifiers for updates */ diff --git a/source/blender/editors/armature/reeb.c b/source/blender/editors/armature/reeb.c index 20b95ea55d6..af252ffe60c 100644 --- a/source/blender/editors/armature/reeb.c +++ b/source/blender/editors/armature/reeb.c @@ -1753,18 +1753,18 @@ int filterSmartReebGraph(ReebGraph *UNUSED(rg), float UNUSED(threshold)) #endif arc->angle = avg_angle; - + if (avg_angle > threshold) merging = 1; - + if (merging) { ReebNode *terminalNode = NULL; ReebNode *middleNode = NULL; ReebNode *newNode = NULL; ReebNode *removedNode = NULL; int merging = 0; - - // Assign terminal and middle nodes + + /* Assign terminal and middle nodes */ if (arc->head->degree == 1) { terminalNode = arc->head; middleNode = arc->tail; @@ -1773,31 +1773,31 @@ int filterSmartReebGraph(ReebGraph *UNUSED(rg), float UNUSED(threshold)) terminalNode = arc->tail; middleNode = arc->head; } - - // If middle node is a normal node, merge to terminal node + + /* If middle node is a normal node, merge to terminal node */ if (middleNode->degree == 2) { merging = 1; newNode = terminalNode; removedNode = middleNode; } - // Otherwise, just plain remove of the arc + /* Otherwise, just plain remove of the arc */ else { merging = 0; newNode = middleNode; removedNode = terminalNode; } - - // Merging arc + + /* Merging arc */ if (merging) { filterArc(rg, newNode, removedNode, arc, 1); } else { - // removing arc, so we need to decrease the degree of the remaining node - //newNode->degree--; + /* removing arc, so we need to decrease the degree of the remaining node + *newNode->degree--; */ NodeDegreeDecrement(rg, newNode); } - - // Reset nextArc, it might have changed + + /* Reset nextArc, it might have changed */ nextArc = arc->next; BLI_remlink(&rg->arcs, arc); diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index 83f6b1d1824..bb66b1f4347 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -215,16 +215,16 @@ static void update_string(Curve *cu) EditFont *ef = cu->editfont; int len; - // Free the old curve string + /* Free the old curve string */ MEM_freeN(cu->str); - // Calculate the actual string length in UTF-8 variable characters + /* Calculate the actual string length in UTF-8 variable characters */ len = BLI_wstrlen_utf8(ef->textbuf); - // Alloc memory for UTF-8 variable char length string + /* Alloc memory for UTF-8 variable char length string */ cu->str = MEM_callocN(len + sizeof(wchar_t), "str"); - // Copy the wchar to UTF-8 + /* Copy the wchar to UTF-8 */ BLI_strncpy_wchar_as_utf8(cu->str, ef->textbuf, len + 1); } @@ -362,8 +362,8 @@ static int paste_file(bContext *C, ReportList *reports, const char *filename) strp = MEM_callocN(filelen + 4, "tempstr"); - // fread() instead of read(), because windows read() converts text - // to DOS \r\n linebreaks, causing double linebreaks in the 3d text + /* fread() instead of read(), because windows read() converts text + * to DOS \r\n linebreaks, causing double linebreaks in the 3d text */ filelen = fread(strp, 1, filelen, fp); fclose(fp); strp[filelen] = 0; @@ -753,7 +753,7 @@ static int paste_selection(Object *obedit, ReportList *reports) EditFont *ef = cu->editfont; int len = wcslen(ef->copybuf); - // Verify that the copy buffer => [copy buffer len] + cu->len < MAXTEXT + /* Verify that the copy buffer => [copy buffer len] + cu->len < MAXTEXT */ if (cu->len + len <= MAXTEXT) { if (len) { int size = (cu->len * sizeof(wchar_t)) - (cu->pos * sizeof(wchar_t)) + sizeof(wchar_t); @@ -1452,12 +1452,12 @@ void make_editText(Object *obedit) ef->oldstrinfo = MEM_callocN((MAXTEXT + 4) * sizeof(CharInfo), "oldstrbuf"); } - // Convert the original text to wchar_t + /* Convert the original text to wchar_t */ BLI_strncpy_wchar_from_utf8(ef->textbuf, cu->str, MAXTEXT + 4); /* length is bogus */ wcscpy(ef->oldstr, ef->textbuf); - + cu->len = wcslen(ef->textbuf); - + memcpy(ef->textbufinfo, cu->strinfo, (cu->len) * sizeof(CharInfo)); memcpy(ef->oldstrinfo, cu->strinfo, (cu->len) * sizeof(CharInfo)); @@ -1467,8 +1467,8 @@ void make_editText(Object *obedit) cu->curinfo = ef->textbufinfo[cu->pos - 1]; else cu->curinfo = ef->textbufinfo[0]; - - // Convert to UTF-8 + + /* Convert to UTF-8 */ update_string(cu); } @@ -1773,10 +1773,10 @@ static void *editFont_to_undoFont(void *ecu, void *UNUSED(obdata)) EditFont *ef = cu->editfont; char *str; - // The undo buffer includes [MAXTEXT+6]=actual string and [MAXTEXT+4]*sizeof(CharInfo)=charinfo + /* The undo buffer includes [MAXTEXT+6]=actual string and [MAXTEXT+4]*sizeof(CharInfo)=charinfo */ str = MEM_callocN((MAXTEXT + 6) * sizeof(wchar_t) + (MAXTEXT + 4) * sizeof(CharInfo), "string undo"); - // Copy the string and string information + /* Copy the string and string information */ memcpy(str + 4, ef->textbuf, (cu->len + 1) * sizeof(wchar_t)); memcpy(str + 4 + (cu->len + 1) * sizeof(wchar_t), ef->textbufinfo, cu->len * sizeof(CharInfo)); diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index 6d113cbb924..bc912fc8c76 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -683,7 +683,7 @@ void draw_gpencil_2dimage(const bContext *C) { /* just draw using standard scaling (settings here are currently ignored anyways) */ - // FIXME: the opengl poly-strokes don't draw at right thickness when done this way, so disabled + /* FIXME: the opengl poly-strokes don't draw at right thickness when done this way, so disabled */ offsx = 0; offsy = 0; sizex = ar->winx; @@ -740,7 +740,7 @@ void draw_gpencil_view2d(const bContext *C, short onlyv2d) if (gpd == NULL) return; /* special hack for Image Editor */ - // FIXME: the opengl poly-strokes don't draw at right thickness when done this way, so disabled + /* FIXME: the opengl poly-strokes don't draw at right thickness when done this way, so disabled */ if (ELEM(sa->spacetype, SPACE_IMAGE, SPACE_CLIP)) dflag |= GP_DRAWDATA_IEDITHACK; diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 3f53f0403d7..949f92c68e9 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -93,8 +93,8 @@ bGPdata **gpencil_data_get_pointers(const bContext *C, PointerRNA *ptr) { Object *ob = CTX_data_active_object(C); - // TODO: we can include other data-types such as bones later if need be... - + /* TODO: we can include other data-types such as bones later if need be... */ + /* just in case no active object */ if (ob) { /* for now, as long as there's an object, default to using that in 3D-View */ @@ -126,18 +126,18 @@ bGPdata **gpencil_data_get_pointers(const bContext *C, PointerRNA *ptr) SpaceSeq *sseq = (SpaceSeq *)CTX_wm_space_data(C); /* for now, Grease Pencil data is associated with the space (actually preview region only) */ - // XXX our convention for everything else is to link to data though... + /* XXX our convention for everything else is to link to data though... */ if (ptr) RNA_pointer_create(screen_id, &RNA_SpaceSequenceEditor, sseq, ptr); return &sseq->gpd; } break; - + case SPACE_IMAGE: /* Image/UV Editor */ { SpaceImage *sima = (SpaceImage *)CTX_wm_space_data(C); - + /* for now, Grease Pencil data is associated with the space... */ - // XXX our convention for everything else is to link to data though... + /* XXX our convention for everything else is to link to data though... */ if (ptr) RNA_pointer_create(screen_id, &RNA_SpaceImageEditor, sima, ptr); return &sima->gpd; } diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 12b002ef612..fd98dd83a7d 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -1623,12 +1623,12 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, wmEvent *event) } else p = op->customdata; - - // TODO: set any additional settings that we can take from the events? - // TODO? if tablet is erasing, force eraser to be on? - - // TODO: move cursor setting stuff to stroke-start so that paintmode can be changed midway... - + + /* TODO: set any additional settings that we can take from the events? + * TODO? if tablet is erasing, force eraser to be on? */ + + /* TODO: move cursor setting stuff to stroke-start so that paintmode can be changed midway... */ + /* if eraser is on, draw radial aid */ if (p->paintmode == GP_PAINTMODE_ERASER) { gpencil_draw_toggle_eraser_cursor(C, p, TRUE); @@ -1692,8 +1692,8 @@ static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op) //printf("\t\tGP - start stroke\n"); /* we may need to set up paint env again if we're resuming */ - // XXX: watch it with the paintmode! in future, it'd be nice to allow changing paint-mode when in sketching-sessions - // XXX: with tablet events, we may event want to check for eraser here, for nicer tablet support + /* XXX: watch it with the paintmode! in future, it'd be nice to allow changing paint-mode when in sketching-sessions */ + /* XXX: with tablet events, we may event want to check for eraser here, for nicer tablet support */ if (gp_session_initdata(C, p)) gp_paint_initstroke(p, p->paintmode); @@ -1727,17 +1727,17 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, wmEvent *event) tGPsdata *p = op->customdata; int estate = OPERATOR_PASS_THROUGH; /* default exit state - not handled, so let others have a share of the pie */ - // if (event->type == NDOF_MOTION) - // return OPERATOR_PASS_THROUGH; - // ------------------------------- - // [mce] Not quite what I was looking - // for, but a good start! GP continues to - // draw on the screen while the 3D mouse - // moves the viewpoint. Problem is that - // the stroke is converted to 3D only after - // it is finished. This approach should work - // better in tools that immediately apply - // in 3D space. + /* if (event->type == NDOF_MOTION) + * return OPERATOR_PASS_THROUGH; + * ------------------------------- + * [mce] Not quite what I was looking + * for, but a good start! GP continues to + * draw on the screen while the 3D mouse + * moves the viewpoint. Problem is that + * the stroke is converted to 3D only after + * it is finished. This approach should work + * better in tools that immediately apply + * in 3D space. */ //printf("\tGP - handle modal event...\n"); diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 49d56d427ba..1c5cc7528fe 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -524,8 +524,8 @@ static void ui_draw_links(uiBlock *block) uiBut *but; uiLinkLine *line; - // Draw the inactive lines (lines with neither button being hovered over). - // As we go, remember if we see any active or selected lines. + /* Draw the inactive lines (lines with neither button being hovered over). + * As we go, remember if we see any active or selected lines. */ int foundselectline = 0; int foundactiveline = 0; for (but = block->buttons.first; but; but = but->next) { @@ -542,8 +542,8 @@ static void ui_draw_links(uiBlock *block) } } - // Draw any active lines (lines with either button being hovered over). - // Do this last so they appear on top of inactive lines. + /* Draw any active lines (lines with either button being hovered over). + * Do this last so they appear on top of inactive lines. */ if (foundactiveline) { for (but = block->buttons.first; but; but = but->next) { if (but->type == LINK && but->link) { @@ -2486,7 +2486,7 @@ static void ui_block_do_align_but(uiBut *first, short nr) /* merge coordinates */ if (prev) { - // simple cases + /* simple cases */ if (rows == 0) { but->x1 = (prev->x2 + but->x1) / 2.0f; prev->x2 = but->x1; @@ -3432,7 +3432,7 @@ int uiButGetUnitType(uiBut *but) /* own unit define always takes precedence over RNA provided, allowing for overriding * default value provided in RNA in a few special cases (i.e. Active Keyframe in Graph Edit) */ - // XXX: this doesn't allow clearing unit completely, though the same could be said for icons + /* XXX: this doesn't allow clearing unit completely, though the same could be said for icons */ if ((ownUnit != 0) || (but->rnaprop == NULL)) { return ownUnit << 16; } diff --git a/source/blender/editors/interface/interface_anim.c b/source/blender/editors/interface/interface_anim.c index c7f8ad521fa..3099fcb2b40 100644 --- a/source/blender/editors/interface/interface_anim.c +++ b/source/blender/editors/interface/interface_anim.c @@ -141,7 +141,7 @@ int ui_but_anim_expression_create(uiBut *but, const char *str) } /* make sure we have animdata for this */ - // FIXME: until materials can be handled by depsgraph, don't allow drivers to be created for them + /* FIXME: until materials can be handled by depsgraph, don't allow drivers to be created for them */ id = (ID *)but->rnapoin.id.data; if ((id == NULL) || (GS(id->name) == ID_MA) || (GS(id->name) == ID_TE)) { if (G.debug & G_DEBUG) @@ -160,9 +160,9 @@ int ui_but_anim_expression_create(uiBut *but, const char *str) if (driver) { /* set type of driver */ driver->type = DRIVER_TYPE_PYTHON; - + /* set the expression */ - // TODO: need some way of identifying variables used + /* TODO: need some way of identifying variables used */ BLI_strncpy_utf8(driver->expression, str, sizeof(driver->expression)); /* updates */ @@ -187,12 +187,12 @@ void ui_but_anim_autokey(bContext *C, uiBut *but, Scene *scene, float cfra) if (fcu && !driven) { id = but->rnapoin.id.data; - - // TODO: this should probably respect the keyingset only option for anim + + /* TODO: this should probably respect the keyingset only option for anim */ if (autokeyframe_cfra_can_key(scene, id)) { ReportList *reports = CTX_wm_reports(C); short flag = ANIM_get_keyframing_flags(scene, 1); - + fcu->flag &= ~FCURVE_SELECTED; insert_keyframe(reports, id, action, ((fcu->grp) ? (fcu->grp->name) : (NULL)), fcu->rna_path, fcu->array_index, cfra, flag); WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index f173e7ce630..e576b71e442 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -441,7 +441,7 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(w w = (rect->xmax - rect->xmin); h = (rect->ymax - rect->ymin); - // prevent drawing outside widget area + /* prevent drawing outside widget area */ glGetIntegerv(GL_SCISSOR_BOX, scissor); glScissor(ar->winrct.xmin + rect->xmin, ar->winrct.ymin + rect->ymin, w, h); #endif @@ -509,7 +509,7 @@ static void ui_draw_but_CHARTAB(uiBut *but) /* Set the font, in case it is not FO_BUILTIN_NAME font */ if (G.selfont && strcmp(G.selfont->name, FO_BUILTIN_NAME)) { - // Is the font file packed, if so then use the packed file + /* Is the font file packed, if so then use the packed file */ if (G.selfont->packedfile) { pf = G.selfont->packedfile; FTF_SetFont(pf->data, pf->size, 14.0); @@ -537,27 +537,27 @@ static void ui_draw_but_CHARTAB(uiBut *but) glColor3ub(0, 0, 0); for (y = 0; y < 6; y++) { - // Do not draw more than the category allows + /* Do not draw more than the category allows */ if (cs > charmax) break; for (x = 0; x < 12; x++) { - // Do not draw more than the category allows + /* Do not draw more than the category allows */ if (cs > charmax) break; - // Draw one grid cell + /* Draw one grid cell */ glBegin(GL_LINE_LOOP); glVertex2f(sx, sy); glVertex2f(ex, sy); glVertex2f(ex, ey); glVertex2f(sx, ey); - glEnd(); + glEnd(); - // Draw character inside the cell + /* Draw character inside the cell */ memset(wstr, 0, sizeof(wchar_t) * 2); memset(ustr, 0, 16); - // Set the font to be either unicode or FO_BUILTIN_NAME + /* Set the font to be either unicode or FO_BUILTIN_NAME */ wstr[0] = cs; if (strcmp(G.selfont->name, FO_BUILTIN_NAME)) { BLI_strncpy_wchar_as_utf8((char *)ustr, (wchar_t *)wstr, sizeof(ustr)); @@ -580,17 +580,17 @@ static void ui_draw_but_CHARTAB(uiBut *but) float dx, dy; float px, py; - // Calculate the position + /* Calculate the position */ wid = FTF_GetStringWidth((char *) ustr, FTF_USE_GETTEXT | FTF_INPUT_UTF8); FTF_GetBoundingBox((char *) ustr, &llx, &lly, &llz, &urx, &ury, &urz, FTF_USE_GETTEXT | FTF_INPUT_UTF8); dx = urx - llx; dy = ury - lly; - // This isn't fully functional since the but->aspect isn't working like I suspected + /* This isn't fully functional since the but->aspect isn't working like I suspected */ px = sx + ((butw / but->aspect) - dx) / 2; py = sy + ((buth / but->aspect) - dy) / 2; - // Set the position and draw the character + /* Set the position and draw the character */ ui_rasterpos_safe(px, py, but->aspect); FTF_DrawString((char *) ustr, FTF_USE_GETTEXT | FTF_INPUT_UTF8); } @@ -598,8 +598,8 @@ static void ui_draw_but_CHARTAB(uiBut *but) ui_rasterpos_safe(sx + butw / 2, sy + buth / 2, but->aspect); UI_DrawString(but->font, (char *) ustr, 0); } - - // Calculate the next position and character + + /* Calculate the next position and character */ sx += butw; ex += butw; cs++; } @@ -1571,9 +1571,9 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc if (tmpibuf->rect_float) IMB_rect_from_float(tmpibuf); - // XXX: for debug only - // tmpibuf->ftype = PNG; - // IMB_saveiff(tmpibuf, "sample.png", IB_rect); + /* XXX: for debug only + * tmpibuf->ftype = PNG; + * IMB_saveiff(tmpibuf, "sample.png", IB_rect); */ if (tmpibuf->rect) scopes->track_preview = tmpibuf; diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 30c5f2fbe40..18b256d061d 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -804,7 +804,7 @@ static void ui_add_smart_controller(bContext *C, uiBut *from, uiBut *to) break; } - // only works if the sensor and the actuator are from the same object + /* only works if the sensor and the actuator are from the same object */ if (!act_iter) return; /* (3) add a new controller */ @@ -3478,13 +3478,13 @@ static int ui_do_but_HSVCIRCLE(bContext *C, uiBlock *block, uiBut *but, uiHandle else if (event->type == WHEELDOWNMOUSE) { float *hsv = ui_block_hsv_get(but->block); hsv[2] = CLAMPIS(hsv[2] - 0.05f, 0.0f, 1.0f); - ui_set_but_hsv(but); // converts to rgb + ui_set_but_hsv(but); /* converts to rgb */ ui_numedit_apply(C, block, but, data); } else if (event->type == WHEELUPMOUSE) { float *hsv = ui_block_hsv_get(but->block); hsv[2] = CLAMPIS(hsv[2] + 0.05f, 0.0f, 1.0f); - ui_set_but_hsv(but); // converts to rgb + ui_set_but_hsv(but); /* converts to rgb */ ui_numedit_apply(C, block, but, data); } else if (event->type == MOUSEMOVE) { @@ -3810,7 +3810,7 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt static int in_scope_resize_zone(uiBut *but, int UNUSED(x), int y) { - // bottom corner return (x > but->x2 - SCOPE_RESIZE_PAD) && (y < but->y1 + SCOPE_RESIZE_PAD); + /* bottom corner return (x > but->x2 - SCOPE_RESIZE_PAD) && (y < but->y1 + SCOPE_RESIZE_PAD); */ return (y < but->y1 + SCOPE_RESIZE_PAD); } @@ -3833,7 +3833,7 @@ static int ui_numedit_but_HISTOGRAM(uiBut *but, uiHandleButtonData *data, int mx } else { /* scale histogram values */ - const float yfac = MIN2(powf(hist->ymax, 2.f), 1.f) * 0.5f; + const float yfac = minf(powf(hist->ymax, 2.0f), 1.0f) * 0.5f; hist->ymax += dy * yfac; CLAMP(hist->ymax, 1.f, 100.f); @@ -4505,7 +4505,7 @@ static int ui_but_menu(bContext *C, uiBut *but) } /* Keying Sets */ - // TODO: check on modifyability of Keying Set when doing this + /* TODO: check on modifyability of Keying Set when doing this */ if (is_anim) { uiItemS(layout); @@ -4529,8 +4529,8 @@ static int ui_but_menu(bContext *C, uiBut *but) /* Property Operators */ - //Copy Property Value - //Paste Property Value + /*Copy Property Value + *Paste Property Value */ if (length) { uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Reset All to Default Values"), @@ -4566,7 +4566,7 @@ static int ui_but_menu(bContext *C, uiBut *but) /* keyboard shortcuts */ if ((kmi) && ISKEYBOARD(kmi->type)) { - // would rather use a block but, but gets weirdly positioned... + /* would rather use a block but, but gets weirdly positioned... */ //uiDefBlockBut(block, menu_change_shortcut, but, "Change Shortcut", 0, 0, uiLayoutGetWidth(layout), UI_UNIT_Y, ""); but2 = uiDefIconTextBut(block, BUT, 0, 0, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Change Shortcut"), diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 40f28de50fa..5d6a331c466 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -1454,21 +1454,21 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, /* when you are outside parent button, safety there should be smaller */ - // parent button to left + /* parent button to left */ if (midx < block->minx) block->safety.xmin = block->minx - 3; else block->safety.xmin = block->minx - 40; - // parent button to right + /* parent button to right */ if (midx > block->maxx) block->safety.xmax = block->maxx + 3; else block->safety.xmax = block->maxx + 40; - - // parent button on bottom + + /* parent button on bottom */ if (midy < block->miny) block->safety.ymin = block->miny - 3; else block->safety.ymin = block->miny - 40; - // parent button on top + /* parent button on top */ if (midy > block->maxy) block->safety.ymax = block->maxy + 3; else block->safety.ymax = block->maxy + 40; - - // exception for switched pulldowns... + + /* exception for switched pulldowns... */ if (dir1 && (dir1 & block->direction) == 0) { if (dir2 == UI_RIGHT) block->safety.xmax = block->maxx + 3; if (dir2 == UI_LEFT) block->safety.xmin = block->minx - 3; @@ -1862,7 +1862,7 @@ static void ui_update_block_buts_rgb(uiBlock *block, const float rgb[3]) */ rgb_to_hsv_compat_v(rgb, hsv); - // this updates button strings, is hackish... but button pointers are on stack of caller function + /* this updates button strings, is hackish... but button pointers are on stack of caller function */ for (bt = block->buttons.first; bt; bt = bt->next) { if (bt->rnaprop) { @@ -2130,8 +2130,8 @@ static void uiBlockPicker(uiBlock *block, float rgba[4], PointerRNA *ptr, Proper bt = uiDefButR_prop(block, NUMSLI, 0, IFACE_("B "), 0, -100, butwidth, UI_UNIT_Y, ptr, prop, 2, 0.0, 0.0, 0, 3, TIP_("Blue")); uiButSetFunc(bt, do_picker_rna_cb, bt, NULL); - // could use uiItemFullR(col, ptr, prop, -1, 0, UI_ITEM_R_EXPAND|UI_ITEM_R_SLIDER, "", ICON_NONE); - // but need to use uiButSetFunc for updating other fake buttons + /* could use uiItemFullR(col, ptr, prop, -1, 0, UI_ITEM_R_EXPAND|UI_ITEM_R_SLIDER, "", ICON_NONE); + * but need to use uiButSetFunc for updating other fake buttons */ /* HSV values */ uiBlockBeginAlign(block); diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index 5d527667170..779341160c5 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -374,7 +374,7 @@ void uiStyleInit(void) ui_style_new(&U.uistyles, "Default Style", UIFONT_DEFAULT); } - // XXX, this should be moved into a style, but for now best only load the monospaced font once. + /* XXX, this should be moved into a style, but for now best only load the monospaced font once. */ if (blf_mono_font == -1) blf_mono_font = BLF_load_mem_unique("monospace", (unsigned char *)datatoc_bmonofont_ttf, datatoc_bmonofont_ttf_size); diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index e6a4c260d0f..49e3818fe08 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -587,7 +587,7 @@ void uiTemplateAnyID(uiLayout *layout, PointerRNA *ptr, const char *propname, co uiItemL(row, "ID-Block:", ICON_NONE); /* ID-Type Selector - just have a menu of icons */ - // FIXME: the icon-only setting doesn't work when we supply a blank name + /* FIXME: the icon-only setting doesn't work when we supply a blank name */ uiItemFullR(row, ptr, propType, 0, 0, UI_ITEM_R_ICON_ONLY, "", ICON_NONE); /* ID-Block Selector - just use pointer widget... */ @@ -622,7 +622,7 @@ void uiTemplatePathBuilder(uiLayout *layout, PointerRNA *ptr, const char *propna /* Path (existing string) Widget */ uiItemR(row, ptr, propname, 0, text, ICON_RNA); - // TODO: attach something to this to make allow searching of nested properties to 'build' the path + /* TODO: attach something to this to make allow searching of nested properties to 'build' the path */ } /************************ Modifier Template *************************/ @@ -741,7 +741,7 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_EXPAND); block = uiLayoutGetBlock(row); /* VIRTUAL MODIFIER */ - // XXX this is not used now, since these cannot be accessed via RNA + /* XXX this is not used now, since these cannot be accessed via RNA */ BLI_snprintf(str, sizeof(str), "%s parent deform", md->name); uiDefBut(block, LABEL, 0, str, 0, 0, 185, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, "Modifier name"); @@ -821,7 +821,7 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, uiBlockEndAlign(block); uiBlockSetEmboss(block, UI_EMBOSSN); - // When Modifier is a simulation, show button to switch to context rather than the delete button. + /* When Modifier is a simulation, show button to switch to context rather than the delete button. */ if (modifier_can_delete(md) && !modifier_is_simulation(md)) uiItemO(row, "", ICON_X, "OBJECT_OT_modifier_remove"); if (modifier_is_simulation(md) == 1) @@ -908,7 +908,7 @@ uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr) /* find modifier and draw it */ cageIndex = modifiers_getCageIndex(scene, ob, &lastCageIndex, 0); - // XXX virtual modifiers are not accesible for python + /* XXX virtual modifiers are not accesible for python */ vmd = modifiers_getVirtualModifierList(ob); for (i = 0; vmd; i++, vmd = vmd->next) { @@ -945,20 +945,20 @@ static void do_constraint_panels(bContext *C, void *ob_pt, int event) switch (event) { case B_CONSTRAINT_TEST: - break; // no handling + break; /* no handling */ case B_CONSTRAINT_CHANGETARGET: - if (ob->pose) ob->pose->flag |= POSE_RECALC; // checks & sorts pose channels + if (ob->pose) ob->pose->flag |= POSE_RECALC; /* checks & sorts pose channels */ DAG_scene_sort(bmain, scene); break; default: break; } - // note: RNA updates now call this, commenting else it gets called twice. - // if there are problems because of this, then rna needs changed update functions. - // - // object_test_constraints(ob); - // if (ob->pose) BKE_pose_update_constraint_flags(ob->pose); + /* note: RNA updates now call this, commenting else it gets called twice. + * if there are problems because of this, then rna needs changed update functions. + * + * object_test_constraints(ob); + * if (ob->pose) BKE_pose_update_constraint_flags(ob->pose); */ if (ob->type == OB_ARMATURE) DAG_id_tag_update(&ob->id, OB_RECALC_DATA | OB_RECALC_OB); else DAG_id_tag_update(&ob->id, OB_RECALC_OB); @@ -1984,14 +1984,14 @@ static void handle_layer_buttons(bContext *C, void *arg1, void *arg2) RNA_property_boolean_set_index(&but->rnapoin, but->rnaprop, i, FALSE); } } - + /* view3d layer change should update depsgraph (invisible object changed maybe) */ /* see view3d_header.c */ } -// TODO: -// - for now, grouping of layers is determined by dividing up the length of -// the array of layer bitflags +/* TODO: + * - for now, grouping of layers is determined by dividing up the length of + * the array of layer bitflags */ void uiTemplateLayers(uiLayout *layout, PointerRNA *ptr, const char *propname, PointerRNA *used_ptr, const char *used_propname, int active_layer) diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 5ee89bb418f..7b139d81a1c 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1952,8 +1952,8 @@ void ui_draw_gradient(rcti *rect, const float hsv[3], const int type, const floa int a; float h = hsv[0], s = hsv[1], v = hsv[2]; float dx, dy, sx1, sx2, sy; - float col0[4][3]; // left half, rect bottom to top - float col1[4][3]; // right half, rect bottom to top + float col0[4][3]; /* left half, rect bottom to top */ + float col1[4][3]; /* right half, rect bottom to top */ /* draw series of gouraud rects */ glShadeModel(GL_SMOOTH); @@ -2542,12 +2542,12 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat round_box_edges(&wtb, roundboxalign, rect, 5.0f); ui_get_but_vectorf(but, col); - + if (state & (UI_BUT_ANIMATED | UI_BUT_ANIMATED_KEY | UI_BUT_DRIVEN | UI_BUT_REDALERT)) { - // draw based on state - color for keyed etc + /* draw based on state - color for keyed etc */ widgetbase_draw(&wtb, wcol); - - // inset to draw swatch color + + /* inset to draw swatch color */ rect->xmin += SWATCH_KEYED_BORDER; rect->xmax -= SWATCH_KEYED_BORDER; rect->ymin += SWATCH_KEYED_BORDER; diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 9a965fa8f7f..f3acd970a57 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -91,7 +91,7 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo if (btheme) { - // first check for ui buttons theme + /* first check for ui buttons theme */ if (colorid < TH_THEMEUI) { switch (colorid) { @@ -936,7 +936,7 @@ void UI_SetTheme(int spacetype, int regionid) theme_regionid = RGN_TYPE_WINDOW; } else { - // later on, a local theme can be found too + /* later on, a local theme can be found too */ theme_active = U.themes.first; theme_spacetype = spacetype; theme_regionid = regionid; @@ -1295,8 +1295,8 @@ void init_userdef_do_versions(void) /* transform widget settings */ if (U.tw_hotspot == 0) { U.tw_hotspot = 14; - U.tw_size = 20; // percentage of window size - U.tw_handlesize = 16; // percentage of widget radius + U.tw_size = 20; /* percentage of window size */ + U.tw_handlesize = 16; /* percentage of widget radius */ } if (U.pad_rot_angle == 0) U.pad_rot_angle = 15; @@ -1353,7 +1353,7 @@ void init_userdef_do_versions(void) for (btheme = U.themes.first; btheme; btheme = btheme->next) { /* check for (alpha == 0) is safe, then color was never set */ if (btheme->ttime.back[3] == 0) { - // copied from ui_theme_init_default + /* copied from ui_theme_init_default */ btheme->ttime = btheme->tv3d; rgba_char_args_set_fl(btheme->ttime.back, 0.45, 0.45, 0.45, 1.0); rgba_char_args_set_fl(btheme->ttime.grid, 0.36, 0.36, 0.36, 1.0); diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 392aae1632d..47e91f4c659 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -91,7 +91,7 @@ static void view2d_masks(View2D *v2d) v2d->mask.ymax = v2d->winy - 1; #if 0 - // XXX see above + /* XXX see above */ v2d->scroll &= ~(V2D_SCROLL_HORIZONTAL_HIDE | V2D_SCROLL_VERTICAL_HIDE); /* check size if: */ if (v2d->scroll & V2D_SCROLL_HORIZONTAL) @@ -203,7 +203,7 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy) v2d->cur = v2d->tot; /* scrollers - should we have these by default? */ - // XXX for now, we don't override this, or set it either! + /* XXX for now, we don't override this, or set it either! */ } break; diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 129a47c7063..3be41d1f46e 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -1133,7 +1133,7 @@ static int view_borderzoom_exec(bContext *C, wmOperator *op) */ float zoom, center, size; - // TODO: is this zoom factor calculation valid? It seems to produce same results everytime... + /* TODO: is this zoom factor calculation valid? It seems to produce same results everytime... */ if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0) { size = (v2d->cur.xmax - v2d->cur.xmin); zoom = size / (rect.xmax - rect.xmin); @@ -1266,7 +1266,7 @@ static short mouse_in_scroller_handle(int mouse, int sc_min, int sc_max, int sh_ } /* check if mouse is in or past either handle */ - // TODO: check if these extents are still valid or not + /* TODO: check if these extents are still valid or not */ in_max = ( (mouse >= (sh_max - V2D_SCROLLER_HANDLE_SIZE)) && (mouse <= (sh_max + V2D_SCROLLER_HANDLE_SIZE)) ); in_min = ( (mouse <= (sh_min + V2D_SCROLLER_HANDLE_SIZE)) && (mouse >= (sh_min - V2D_SCROLLER_HANDLE_SIZE)) ); in_bar = ( (mouse < (sh_max - V2D_SCROLLER_HANDLE_SIZE)) && (mouse > (sh_min + V2D_SCROLLER_HANDLE_SIZE)) ); diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c index 77808d0a00d..6e4da6b7e88 100644 --- a/source/blender/editors/io/io_collada.c +++ b/source/blender/editors/io/io_collada.c @@ -174,7 +174,7 @@ void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr) uiItemR(row, imfptr, "include_armatures", 0, NULL, ICON_NONE); uiLayoutSetEnabled(row, RNA_boolean_get(imfptr, "selected")); - // Texture options + /* Texture options */ box = uiLayoutBox(layout); row = uiLayoutRow(box, FALSE); uiItemL(row, IFACE_("Texture Options:"), ICON_TEXTURE_DATA); @@ -192,7 +192,7 @@ void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr) uiItemR(row, imfptr, "use_texture_copies", 1, NULL, ICON_NONE); - // Armature options + /* Armature options */ box = uiLayoutBox(layout); row = uiLayoutRow(box, FALSE); uiItemL(row, IFACE_("Armature Options:"), ICON_ARMATURE_DATA); diff --git a/source/blender/editors/io/io_ops.c b/source/blender/editors/io/io_ops.c index b724db6e737..d2b0ddd4e7e 100644 --- a/source/blender/editors/io/io_ops.c +++ b/source/blender/editors/io/io_ops.c @@ -37,7 +37,7 @@ void ED_operatortypes_io(void) { #ifdef WITH_COLLADA - // Collada operators: + /* Collada operators: */ WM_operatortype_append(WM_OT_collada_export); WM_operatortype_append(WM_OT_collada_import); #endif diff --git a/source/blender/editors/mask/mask_editaction.c b/source/blender/editors/mask/mask_editaction.c index 3836b393bf8..6124947e3b9 100644 --- a/source/blender/editors/mask/mask_editaction.c +++ b/source/blender/editors/mask/mask_editaction.c @@ -243,7 +243,7 @@ void ED_masklayer_frames_duplicate(MaskLayer *masklay) mask_shape_dupe = BKE_mask_layer_shape_duplicate(masklay_shape); masklay_shape->flag &= ~MASK_SHAPE_SELECT; - // XXX - how to handle duplicate frames? + /* XXX - how to handle duplicate frames? */ BLI_insertlinkafter(&masklay->splines_shapes, masklay_shape, mask_shape_dupe); } } diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c index b592449fff5..addd0b14916 100644 --- a/source/blender/editors/mesh/editface.c +++ b/source/blender/editors/mesh/editface.c @@ -329,7 +329,7 @@ void paintface_select_linked(bContext *UNUSED(C), Object *ob, int UNUSED(mval[2] if (me == NULL || me->totpoly == 0) return; if (mode == 0 || mode == 1) { - // XXX - Causes glitches, not sure why + /* XXX - Causes glitches, not sure why */ #if 0 if (!facesel_face_pick(C, me, mval, &index, 1)) return; diff --git a/source/blender/editors/mesh/editmesh_bvh.c b/source/blender/editors/mesh/editmesh_bvh.c index 2cb03104874..549032f7286 100644 --- a/source/blender/editors/mesh/editmesh_bvh.c +++ b/source/blender/editors/mesh/editmesh_bvh.c @@ -55,7 +55,7 @@ typedef struct BMBVHTree { BMesh *bm; BVHTree *tree; float epsilon; - float maxdist; //for nearest point search + float maxdist; /* for nearest point search */ float uv[2]; /* stuff for topological vert search */ diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 2ceb8aeef26..882d3115ba0 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -1400,9 +1400,10 @@ static float knife_snap_size(KnifeTool_OpData *kcd, float maxsize) { float density = (float)knife_sample_screen_density(kcd, maxsize * 2.0f); - density = MAX2(density, 1); + if (density < 1.0f) + density = 1.0f; - return MIN2(maxsize / (density * 0.5f), maxsize); + return minf(maxsize / (density * 0.5f), maxsize); } /* p is closest point on edge to the mouse cursor */ diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index 5404eb3bea6..a9912b90aef 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -1498,25 +1498,25 @@ int mouse_mesh(bContext *C, const int mval[2], short extend, short deselect, sho BMVert *eve = NULL; BMEdge *eed = NULL; BMFace *efa = NULL; - + /* setup view context for argument to callbacks */ em_setup_viewcontext(C, &vc); vc.mval[0] = mval[0]; vc.mval[1] = mval[1]; - + if (unified_findnearest(&vc, &eve, &eed, &efa)) { - - // Deselect everything + + /* Deselect everything */ if (extend == 0 && deselect == 0 && toggle == 0) EDBM_flag_disable_all(vc.em, BM_ELEM_SELECT); - + if (efa) { if (extend) { - // set the last selected face + /* set the last selected face */ BM_active_face_set(vc.em->bm, efa); - - // Work-around: deselect first, so we can guarantee it will - // be active even if it was already selected + + /* Work-around: deselect first, so we can guarantee it will */ + /* be active even if it was already selected */ BM_select_history_remove(vc.em->bm, efa); BM_face_select_set(vc.em->bm, efa, FALSE); BM_select_history_store(vc.em->bm, efa); @@ -1527,9 +1527,9 @@ int mouse_mesh(bContext *C, const int mval[2], short extend, short deselect, sho BM_face_select_set(vc.em->bm, efa, FALSE); } else { - // set the last selected face + /* set the last selected face */ BM_active_face_set(vc.em->bm, efa); - + if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) { BM_select_history_store(vc.em->bm, efa); BM_face_select_set(vc.em->bm, efa, TRUE); @@ -1542,8 +1542,8 @@ int mouse_mesh(bContext *C, const int mval[2], short extend, short deselect, sho } else if (eed) { if (extend) { - // Work-around: deselect first, so we can guarantee it will - // be active even if it was already selected + /* Work-around: deselect first, so we can guarantee it will */ + /* be active even if it was already selected */ BM_select_history_remove(vc.em->bm, eed); BM_edge_select_set(vc.em->bm, eed, FALSE); BM_select_history_store(vc.em->bm, eed); @@ -1566,8 +1566,8 @@ int mouse_mesh(bContext *C, const int mval[2], short extend, short deselect, sho } else if (eve) { if (extend) { - // Work-around: deselect first, so we can guarantee it will - // be active even if it was already selected + /* Work-around: deselect first, so we can guarantee it will */ + /* be active even if it was already selected */ BM_select_history_remove(vc.em->bm, eve); BM_vert_select_set(vc.em->bm, eve, FALSE); BM_select_history_store(vc.em->bm, eve); @@ -1588,9 +1588,9 @@ int mouse_mesh(bContext *C, const int mval[2], short extend, short deselect, sho } } } - + EDBM_selectmode_flush(vc.em); - + /* change active material on object */ if (efa && efa->mat_nr != vc.obedit->actcol - 1) { vc.obedit->actcol = efa->mat_nr + 1; diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 0f13df4c777..4c7545fa4fa 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -443,7 +443,7 @@ static int edbm_extrude_mesh(Scene *scene, Object *obedit, BMEditMesh *em, wmOpe nr = 3; // pupmenu("Extrude %t|Only Edges%x3|Only Vertices%x4"); else if (em->bm->totfacesel == 1) nr = 1; // pupmenu("Extrude %t|Region %x1|Only Edges%x3|Only Vertices%x4"); - else + else nr = 1; // pupmenu("Extrude %t|Region %x1||Individual Faces %x2|Only Edges%x3|Only Vertices%x4"); } else if (em->selectmode & SCE_SELECT_EDGE) { diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index cdbf5751ea1..044c23092bd 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -265,11 +265,11 @@ int join_mesh_exec(bContext *C, wmOperator *op) key->totkey++; if (key->totkey == 1) key->refkey = kbn; - // XXX 2.5 Animato + /* XXX 2.5 Animato */ #if 0 /* also, copy corresponding ipo-curve to ipo-block if applicable */ if (me->key->ipo && key->ipo) { - // FIXME... this is a luxury item! + /* FIXME... this is a luxury item! */ puts("FIXME: ignoring IPO's when joining shapekeys on Meshes for now..."); } #endif @@ -530,7 +530,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) /* free temp copy of destination shapekeys (if applicable) */ if (nkey) { - // XXX 2.5 Animato + /* XXX 2.5 Animato */ #if 0 /* free it's ipo too - both are not actually freed from memory yet as ID-blocks */ if (nkey->ipo) { diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index ba26b92f354..7ab20033239 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -558,8 +558,8 @@ static int object_metaball_add_exec(bContext *C, wmOperator *op) unsigned int layer; float loc[3], rot[3]; float mat[4][4]; - - object_add_generic_invoke_options(C, op); // XXX these props don't get set right when only exec() is called + + object_add_generic_invoke_options(C, op); /* XXX these props don't get set right when only exec() is called */ if (!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL)) return OPERATOR_CANCELLED; @@ -629,7 +629,7 @@ static int object_add_text_exec(bContext *C, wmOperator *op) unsigned int layer; float loc[3], rot[3]; - object_add_generic_invoke_options(C, op); // XXX these props don't get set right when only exec() is called + object_add_generic_invoke_options(C, op); /* XXX these props don't get set right when only exec() is called */ if (!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL)) return OPERATOR_CANCELLED; @@ -669,18 +669,18 @@ static int object_armature_add_exec(bContext *C, wmOperator *op) int enter_editmode; unsigned int layer; float loc[3], rot[3]; - - object_add_generic_invoke_options(C, op); // XXX these props don't get set right when only exec() is called + + object_add_generic_invoke_options(C, op); /* XXX these props don't get set right when only exec() is called */ if (!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL)) return OPERATOR_CANCELLED; - + if ((obedit == NULL) || (obedit->type != OB_ARMATURE)) { obedit = ED_object_add_type(C, OB_ARMATURE, loc, rot, TRUE, layer); ED_object_enter_editmode(C, 0); newob = 1; } else DAG_id_tag_update(&obedit->id, OB_RECALC_DATA); - + if (obedit == NULL) { BKE_report(op->reports, RPT_ERROR, "Cannot create editmode armature"); return OPERATOR_CANCELLED; diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index a38c69fba8a..be25c79ba25 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -462,7 +462,7 @@ static void test_constraints(Object *owner, bPoseChannel *pchan) if (type == CONSTRAINT_OBTYPE_BONE) { if (!BKE_armature_find_bone_name(BKE_armature_from_object(owner), ct->subtarget)) { /* bone must exist in armature... */ - // TODO: clear subtarget? + /* TODO: clear subtarget? */ curcon->flag |= CONSTRAINT_DISABLE; } else if (strcmp(pchan->name, ct->subtarget) == 0) { @@ -718,7 +718,7 @@ static void child_get_inverse_matrix(Scene *scene, Object *ob, bConstraint *con, unit_m4(invmat); /* try to find a pose channel - assume that this is the constraint owner */ - // TODO: get from context instead? + /* TODO: get from context instead? */ if (ob && ob->pose) pchan = BKE_pose_channel_active(ob); @@ -974,7 +974,7 @@ void ED_object_constraint_set_active(Object *ob, bConstraint *con) ListBase *lb = get_constraint_lb(ob, con, NULL); /* lets be nice and escape if its active already */ - // NOTE: this assumes that the stack doesn't have other active ones set... + /* NOTE: this assumes that the stack doesn't have other active ones set... */ if ((lb && con) && (con->flag & CONSTRAINT_ACTIVE)) return; @@ -1518,16 +1518,16 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase /* do type-specific tweaking to the constraint settings */ switch (type) { - case CONSTRAINT_TYPE_PYTHON: // FIXME: this code is not really valid anymore + case CONSTRAINT_TYPE_PYTHON: /* FIXME: this code is not really valid anymore */ { #ifdef WITH_PYTHON char *menustr; int scriptint = 0; /* popup a list of usable scripts */ menustr = buildmenu_pyconstraints(NULL, &scriptint); - // XXX scriptint = pupmenu(menustr); + /* XXX scriptint = pupmenu(menustr); */ MEM_freeN(menustr); - + /* only add constraint if a script was chosen */ if (scriptint) { /* add constraint */ @@ -1787,7 +1787,7 @@ static int pose_ik_clear_exec(bContext *C, wmOperator *UNUSED(op)) { bConstraint *con, *next; - // TODO: should we be checking if these contraints were local before we try and remove them? + /* TODO: should we be checking if these contraints were local before we try and remove them? */ for (con = pchan->constraints.first; con; con = next) { next = con->next; if (con->type == CONSTRAINT_TYPE_KINEMATIC) { diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 35ee641d2c1..b5e85c3712b 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -408,12 +408,12 @@ void ED_object_enter_editmode(bContext *C, int flag) ScrArea *sa = CTX_wm_area(C); View3D *v3d = NULL; int ok = 0; - + if (scene->id.lib) return; - + if (sa && sa->spacetype == SPACE_VIEW3D) v3d = sa->spacedata.first; - + if ((flag & EM_IGNORE_LAYER) == 0) { base = CTX_data_active_base(C); /* active layer checked here for view3d */ @@ -428,12 +428,12 @@ void ED_object_enter_editmode(bContext *C, int flag) if (ELEM3(NULL, base, base->object, base->object->data)) return; ob = base->object; - + if (BKE_object_obdata_is_libdata(ob)) { error_libdata(); return; } - + if (flag & EM_WAITCURSOR) waitcursor(1); ob->restore_mode = ob->mode; @@ -444,7 +444,7 @@ void ED_object_enter_editmode(bContext *C, int flag) ED_object_toggle_modes(C, ob->mode); ob->mode = OB_MODE_EDIT; - + if (ob->type == OB_MESH) { BMEditMesh *em; ok = 1; @@ -457,7 +457,7 @@ void ED_object_enter_editmode(bContext *C, int flag) /* order doesn't matter */ EDBM_mesh_normals_update(em); BMEdit_RecalcTessellation(em); - + BM_mesh_select_mode_flush(em->bm); } @@ -482,48 +482,48 @@ void ED_object_enter_editmode(bContext *C, int flag) scene->obedit = ob; ED_armature_to_edit(ob); /* to ensure all goes in restposition and without striding */ - DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); // XXX: should this be OB_RECALC_DATA? + DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); /* XXX: should this be OB_RECALC_DATA? */ WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_EDITMODE_ARMATURE, scene); } else if (ob->type == OB_FONT) { - scene->obedit = ob; // XXX for context + scene->obedit = ob; /* XXX for context */ ok = 1; make_editText(ob); WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_EDITMODE_TEXT, scene); } else if (ob->type == OB_MBALL) { - scene->obedit = ob; // XXX for context + scene->obedit = ob; /* XXX for context */ ok = 1; make_editMball(ob); WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_EDITMODE_MBALL, scene); } else if (ob->type == OB_LATTICE) { - scene->obedit = ob; // XXX for context + scene->obedit = ob; /* XXX for context */ ok = 1; make_editLatt(ob); - + WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_EDITMODE_LATTICE, scene); } else if (ob->type == OB_SURF || ob->type == OB_CURVE) { ok = 1; - scene->obedit = ob; // XXX for context + scene->obedit = ob; /* XXX for context */ make_editNurb(ob); - + WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_EDITMODE_CURVE, scene); } - + if (ok) { DAG_id_tag_update(&ob->id, OB_RECALC_DATA); } else { - scene->obedit = NULL; // XXX for context + scene->obedit = NULL; /* XXX for context */ ob->mode &= ~OB_MODE_EDIT; WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, scene); } - + if (flag & EM_DO_UNDO) ED_undo_push(C, "Enter Editmode"); if (flag & EM_WAITCURSOR) waitcursor(0); } @@ -1145,7 +1145,7 @@ static int object_calculate_paths_invoke(bContext *C, wmOperator *op, wmEvent *U } /* show popup dialog to allow editing of range... */ - // FIXME: hardcoded dimensions here are just arbitrary + /* FIXME: hardcoded dimensions here are just arbitrary */ return WM_operator_props_dialog_popup(C, op, 200, 200); } diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index e9341d90e86..65dd9a12d3b 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -397,7 +397,7 @@ static void object_hook_select(Object *ob, HookModifierData *hmd) } /* special poll operators for hook operators */ -// TODO: check for properties window modifier context too as alternative? +/* TODO: check for properties window modifier context too as alternative? */ static int hook_op_edit_poll(bContext *C) { Object *obedit = CTX_data_edit_object(C); diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index aab3d8afb22..3d9e62b1a16 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -1353,7 +1353,7 @@ void OBJECT_OT_multires_external_save(wmOperatorType *ot) ot->description = "Save displacements to an external file"; ot->idname = "OBJECT_OT_multires_external_save"; - // XXX modifier no longer in context after file browser .. ot->poll = multires_poll; + /* XXX modifier no longer in context after file browser .. ot->poll = multires_poll; */ ot->exec = multires_external_save_exec; ot->invoke = multires_external_save_invoke; ot->poll = multires_poll; @@ -1375,7 +1375,7 @@ static int multires_external_pack_exec(bContext *C, wmOperator *UNUSED(op)) if (!CustomData_external_test(&me->ldata, CD_MDISPS)) return OPERATOR_CANCELLED; - // XXX don't remove.. + /* XXX don't remove.. */ CustomData_external_remove(&me->ldata, &me->id, CD_MDISPS, me->totloop); return OPERATOR_FINISHED; diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index 07557d8ea4c..83d92b9df27 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -119,7 +119,7 @@ static void object_clear_rot(Object *ob) if ((ob->protectflag & OB_LOCK_ROTZ) == 0) ob->quat[3] = ob->dquat[3] = 0.0f; - // TODO: does this quat need normalizing now? + /* TODO: does this quat need normalizing now? */ } else { /* the flag may have been set for the other modes, so just ignore the extra flag... */ @@ -133,7 +133,7 @@ static void object_clear_rot(Object *ob) } else { /* perform clamping using euler form (3-components) */ - // FIXME: deltas are not handled for these cases yet... + /* FIXME: deltas are not handled for these cases yet... */ float eul[3], oldeul[3], quat1[4] = {0}; if (ob->rotmode == ROT_MODE_QUAT) { diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index b5a0451b507..2e9652686da 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -1007,7 +1007,7 @@ static void moveCloserToDistanceFromPlane(Scene *scene, Object *ob, Mesh *me, in } } bestIndex = -1; - // find the best change with an acceptable horizontal change + /* find the best change with an acceptable horizontal change */ for (i = 0; i < totweight; i++) { if (fabs(changes[i][0]) > fabs(changes[i][1] * 2.0f)) { bestIndex = i; @@ -1016,8 +1016,8 @@ static void moveCloserToDistanceFromPlane(Scene *scene, Object *ob, Mesh *me, in } if (bestIndex != -1) { wasChange = TRUE; - // it is a good place to stop if it tries to move the opposite direction - // (relative to the plane) of last time + /* it is a good place to stop if it tries to move the opposite direction + * (relative to the plane) of last time */ if (lastIndex != -1) { if (wasUp != upDown[bestIndex]) { wasChange = FALSE; diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index 2e58fa85a11..1fe533eb23f 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -203,7 +203,7 @@ static void fluidsimPrintChannel(FILE *file, float *channel, int paramsize, char elbeemSimplifyChannelFloat(channel, &channelSize); } else { - // invalid, cant happen? + /* invalid, cant happen? */ } fprintf(file, " CHANNEL %s =\n", str); @@ -651,16 +651,16 @@ static int fluid_init_filepaths(Object *fsDomain, char *targetDir, char *targetF FluidsimSettings *domainSettings= fluidmd->fss; FILE *fileCfg; int dirExist = 0; - char newSurfdataPath[FILE_MAX]; // modified output settings + char newSurfdataPath[FILE_MAX]; /* modified output settings */ const char *suffixConfigTmp = FLUID_SUFFIX_CONFIG_TMP; int outStringsChanged = 0; - // prepare names... + /* prepare names... */ const char *relbase= modifier_path_relbase(fsDomain); BLI_strncpy(targetDir, domainSettings->surfdataPath, FILE_MAXDIR); BLI_strncpy(newSurfdataPath, domainSettings->surfdataPath, FILE_MAXDIR); /* if 0'd out below, this value is never used! */ - BLI_path_abs(targetDir, relbase); // fixed #frame-no + BLI_path_abs(targetDir, relbase); /* fixed #frame-no */ /* .tmp: don't overwrite/delete original file */ BLI_join_dirfile(targetFile, FILE_MAX, targetDir, suffixConfigTmp); diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index d37a16cb1bb..538b4b3884a 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -477,11 +477,9 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) const short view_context = (oglrender->v3d != NULL); Object *camera = NULL; - /* update animated image textures for gpu, etc, - * call before BKE_scene_update_for_newframe so modifiers with textures don't lag 1 frame */ - ED_image_update_frame(bmain, scene->r.cfra); - /* go to next frame */ + if (CFRA < oglrender->nfra) + CFRA++; while (CFRA < oglrender->nfra) { unsigned int lay = screen_opengl_layers(oglrender); @@ -492,6 +490,10 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) CFRA++; } + /* update animated image textures for gpu, etc, + * call before BKE_scene_update_for_newframe so modifiers with textures don't lag 1 frame */ + ED_image_update_frame(bmain, CFRA); + BKE_scene_update_for_newframe(bmain, scene, screen_opengl_layers(oglrender)); if (view_context) { @@ -569,10 +571,9 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) /* go to next frame */ oglrender->nfra += scene->r.frame_step; - scene->r.cfra++; /* stop at the end or on error */ - if (scene->r.cfra > PEFRA || !ok) { + if (CFRA >= PEFRA || !ok) { screen_opengl_render_end(C, op->customdata); return 0; } diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 9771fef2d58..a79d38d4081 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -1149,7 +1149,7 @@ static void ed_default_handlers(wmWindowManager *wm, ScrArea *sa, ListBase *hand { /* note, add-handler checks if it already exists */ - // XXX it would be good to have boundbox checks for some of these... + /* XXX it would be good to have boundbox checks for some of these... */ if (flag & ED_KEYMAP_UI) { /* user interface widgets */ UI_add_region_handlers(handlers); @@ -1654,7 +1654,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char * v2d->scroll |= V2D_SCROLL_HORIZONTAL_HIDE; v2d->scroll &= ~V2D_SCROLL_VERTICAL_HIDE; - // don't jump back when panels close or hide + /* don't jump back when panels close or hide */ if (!newcontext) y = MAX2(-y, -v2d->cur.ymin); else @@ -1669,14 +1669,14 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char * //v2d->keepofs &= ~(V2D_LOCKOFS_X|V2D_KEEPOFS_Y); v2d->scroll |= V2D_SCROLL_VERTICAL_HIDE; v2d->scroll &= ~V2D_SCROLL_HORIZONTAL_HIDE; - - // don't jump back when panels close or hide + + /* don't jump back when panels close or hide */ if (!newcontext) x = MAX2(x, v2d->cur.xmax); y = -y; } - // +V2D_SCROLL_HEIGHT is workaround to set the actual height + /* +V2D_SCROLL_HEIGHT is workaround to set the actual height */ UI_view2d_totRect_set(v2d, x + V2D_SCROLL_WIDTH, y + V2D_SCROLL_HEIGHT); /* set the view */ @@ -1698,17 +1698,17 @@ void ED_region_panels_init(wmWindowManager *wm, ARegion *ar) { wmKeyMap *keymap; - // XXX quick hacks for files saved with 2.5 already (i.e. the builtin defaults file) - // scrollbars for button regions + /* XXX quick hacks for files saved with 2.5 already (i.e. the builtin defaults file) + * scrollbars for button regions */ ar->v2d.scroll |= (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM); ar->v2d.scroll |= V2D_SCROLL_HORIZONTAL_HIDE; ar->v2d.scroll &= ~V2D_SCROLL_VERTICAL_HIDE; ar->v2d.keepzoom |= V2D_KEEPZOOM; - // correctly initialized User-Prefs? + /* correctly initialized User-Prefs? */ if (!(ar->v2d.align & V2D_ALIGN_NO_POS_Y)) ar->v2d.flag &= ~V2D_IS_INITIALISED; - + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_PANELS_UI, ar->winx, ar->winy); keymap = WM_keymap_find(wm->defaultconf, "View2D Buttons List", 0, 0); diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index 5ca436b07b2..7f51f54ee4b 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -294,7 +294,7 @@ static int project_brush_radius(ViewContext *vc, ED_view3d_global_to_vector(vc->rv3d, location, view); - // create a vector that is not orthogonal to view + /* create a vector that is not orthogonal to view */ if (fabsf(view[0]) < 0.1f) { nonortho[0] = view[0] + 1.0f; @@ -312,19 +312,19 @@ static int project_brush_radius(ViewContext *vc, nonortho[2] = view[2] + 1.0f; } - // get a vector in the plane of the view + /* get a vector in the plane of the view */ cross_v3_v3v3(ortho, nonortho, view); normalize_v3(ortho); - // make a point on the surface of the brush tagent to the view + /* make a point on the surface of the brush tagent to the view */ mul_v3_fl(ortho, radius); add_v3_v3v3(offset, location, ortho); - // project the center of the brush, and the tangent point to the view onto the screen + /* project the center of the brush, and the tangent point to the view onto the screen */ project_float(vc->ar, location, p1); project_float(vc->ar, offset, p2); - // the distance between these points is the size of the projected brush in pixels + /* the distance between these points is the size of the projected brush in pixels */ return len_v2v2(p1, p2); } diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 6a8f7db5fc9..f6c17c97758 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -1455,8 +1455,8 @@ static float project_paint_uvpixel_mask( } /* otherwise no mask normal is needed, were within the limit */ } - // This only works when the opacity dosnt change while painting, stylus pressure messes with this - // so don't use it. + /* This only works when the opacity dosnt change while painting, stylus pressure messes with this + * so don't use it. */ // if (ps->is_airbrush==0) mask *= BKE_brush_alpha_get(ps->brush); return mask; diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index b5cd49cc15c..dbde950188d 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -489,15 +489,15 @@ static int actkeys_copy_exec(bContext *C, wmOperator *op) /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* copy keyframes */ if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) { - // FIXME... + /* FIXME... */ BKE_report(op->reports, RPT_ERROR, "Keyframe pasting is not available for Grease Pencil mode"); return OPERATOR_CANCELLED; } else if (ac.datatype == ANIMCONT_MASK) { - // FIXME... + /* FIXME... */ BKE_report(op->reports, RPT_ERROR, "Keyframe pasting is not available for mask mode"); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/space_buttons/buttons_header.c b/source/blender/editors/space_buttons/buttons_header.c index b13ba9a1aa3..199875fdc7b 100644 --- a/source/blender/editors/space_buttons/buttons_header.c +++ b/source/blender/editors/space_buttons/buttons_header.c @@ -116,8 +116,8 @@ void buttons_header_buttons(const bContext *C, ARegion *ar) uiBlockSetEmboss(block, UI_EMBOSS); xco -= UI_UNIT_X; - - // Default panels + + /* Default panels */ uiBlockBeginAlign(block); diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index fb12ea8417a..a23cb86bb76 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -351,11 +351,11 @@ void filelist_filter(FileList *filelist) { int num_filtered = 0; int i, j; - + if (!filelist->filelist) return; - // How many files are left after filter ? + /* How many files are left after filter ? */ for (i = 0; i < filelist->numfiles; ++i) { struct direntry *file = &filelist->filelist[i]; if (filelist->filterf(file, filelist->dir, filelist->filter, filelist->hide_dot) ) { @@ -428,7 +428,7 @@ void folderlist_popdir(struct ListBase *folderlist, char *dir) folder = folderlist->last; if (folder) { - // remove the current directory + /* remove the current directory */ MEM_freeN(folder->foldername); BLI_freelinkN(folderlist, folder); @@ -438,7 +438,7 @@ void folderlist_popdir(struct ListBase *folderlist, char *dir) BLI_strncpy(dir, prev_dir, FILE_MAXDIR); } } - // delete the folder next or use setdir directly before PREVIOUS OP + /* delete the folder next or use setdir directly before PREVIOUS OP */ } void folderlist_pushdir(ListBase *folderlist, const char *dir) @@ -446,21 +446,21 @@ void folderlist_pushdir(ListBase *folderlist, const char *dir) struct FolderList *folder, *previous_folder; previous_folder = folderlist->last; - // check if already exists + /* check if already exists */ if (previous_folder && previous_folder->foldername) { if (BLI_path_cmp(previous_folder->foldername, dir) == 0) { return; } } - // create next folder element + /* create next folder element */ folder = (FolderList *)MEM_mallocN(sizeof(FolderList), "FolderList"); folder->foldername = (char *)MEM_mallocN(sizeof(char) * (strlen(dir) + 1), "foldername"); folder->foldername[0] = '\0'; BLI_strncpy(folder->foldername, dir, FILE_MAXDIR); - // add it to the end of the list + /* add it to the end of the list */ BLI_addtail(folderlist, folder); } @@ -468,16 +468,16 @@ int folderlist_clear_next(struct SpaceFile *sfile) { struct FolderList *folder; - // if there is no folder_next there is nothing we can clear + /* if there is no folder_next there is nothing we can clear */ if (!sfile->folders_next) return 0; - // if previous_folder, next_folder or refresh_folder operators are executed it doesn't clear folder_next + /* if previous_folder, next_folder or refresh_folder operators are executed it doesn't clear folder_next */ folder = sfile->folders_prev->last; if ((!folder) || (BLI_path_cmp(folder->foldername, sfile->params->dir) == 0)) return 0; - // eventually clear flist->folders_next + /* eventually clear flist->folders_next */ return 1; } diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index adb3e7acca5..ef3e150b034 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -117,7 +117,7 @@ short ED_fileselect_set_params(SpaceFile *sfile) const short is_directory = (RNA_struct_find_property(op->ptr, "directory") != NULL); const short is_relative_path = (RNA_struct_find_property(op->ptr, "relative_path") != NULL); - BLI_strncpy(params->title, RNA_struct_ui_name(op->type->srna), sizeof(params->title)); + BLI_strncpy_utf8(params->title, RNA_struct_ui_name(op->type->srna), sizeof(params->title)); if (RNA_struct_find_property(op->ptr, "filemode")) params->type = RNA_int_get(op->ptr, "filemode"); diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index 0366043aaa0..a127e2ca2bc 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -179,15 +179,15 @@ void fsmenu_insert_entry(struct FSMenu *fsmenu, FSMenuCategory category, const c } } else { - // if we're bookmarking this, file should come - // before the last separator, only automatically added - // current dir go after the last sep. + /* if we're bookmarking this, file should come + * before the last separator, only automatically added + * current dir go after the last sep. */ if (save) { break; } } } - + fsme = MEM_mallocN(sizeof(*fsme), "fsme"); fsme->path = BLI_strdup(path); fsme->save = save; @@ -247,7 +247,7 @@ void fsmenu_write_file(struct FSMenu *fsmenu, const char *filename) } fprintf(fp, "[Recent]\n"); nskip = fsmenu_get_nentries(fsmenu, FS_CATEGORY_RECENT) - FSMENU_RECENT_MAX; - // skip first entries if list too long + /* skip first entries if list too long */ for (fsme = fsmenu_get_category(fsmenu, FS_CATEGORY_RECENT); fsme && (nskip > 0); fsme = fsme->next, --nskip) { /* pass */ } diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index dbc66b81874..b1e1b6e411a 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -260,8 +260,8 @@ void GRAPH_OT_view_all(wmOperatorType *ot) /* api callbacks */ ot->exec = graphkeys_viewall_exec; - ot->poll = ED_operator_graphedit_active; // XXX: unchecked poll to get fsamples working too, but makes modifier damage trickier... - + ot->poll = ED_operator_graphedit_active; /* XXX: unchecked poll to get fsamples working too, but makes modifier damage trickier... */ + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -279,7 +279,7 @@ void GRAPH_OT_view_selected(wmOperatorType *ot) /* api callbacks */ ot->exec = graphkeys_view_selected_exec; - ot->poll = ED_operator_graphedit_active; // XXX: unchecked poll to get fsamples working too, but makes modifier damage trickier... + ot->poll = ED_operator_graphedit_active; /* XXX: unchecked poll to get fsamples working too, but makes modifier damage trickier... */ /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1641,7 +1641,7 @@ static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op) int f; /* sanity check: ensure that there are enough F-Curves to work on in this group */ - // TODO: also enforce assumption that there be a full set of keyframes at each position by ensuring that totvert counts are same? + /* TODO: also enforce assumption that there be a full set of keyframes at each position by ensuring that totvert counts are same? */ if (ELEM3(NULL, euf->fcurves[0], euf->fcurves[1], euf->fcurves[2])) { /* report which components are missing */ BKE_reportf(op->reports, RPT_WARNING, @@ -1655,9 +1655,9 @@ static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op) failed++; continue; } - + /* simple method: just treat any difference between keys of greater than 180 degrees as being a flip */ - // FIXME: there are more complicated methods that will be needed to fix more cases than just some + /* FIXME: there are more complicated methods that will be needed to fix more cases than just some */ for (f = 0; f < 3; f++) { FCurve *fcu = euf->fcurves[f]; BezTriple *bezt, *prev = NULL; @@ -2217,10 +2217,10 @@ static int graph_fmodifier_copy_exec(bContext *C, wmOperator *op) /* if this exists, call the copy F-Modifiers API function */ if (ale && ale->data) { FCurve *fcu = (FCurve *)ale->data; - - // TODO: when 'active' vs 'all' boolean is added, change last param! + + /* TODO: when 'active' vs 'all' boolean is added, change last param! */ ok = ANIM_fmodifiers_copy_to_buf(&fcu->modifiers, 0); - + /* free temp data now */ MEM_freeN(ale); } @@ -2272,11 +2272,11 @@ static int graph_fmodifier_paste_exec(bContext *C, wmOperator *op) /* paste modifiers */ for (ale = anim_data.first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->data; - - // TODO: do we want to replace existing modifiers? add user pref for that! + + /* TODO: do we want to replace existing modifiers? add user pref for that! */ ok += ANIM_fmodifiers_paste_from_buf(&fcu->modifiers, 0); } - + /* clean up */ BLI_freelistN(&anim_data); diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c index 33e32363cf5..52a7f9b115c 100644 --- a/source/blender/editors/space_graph/graph_select.c +++ b/source/blender/editors/space_graph/graph_select.c @@ -961,9 +961,9 @@ static void nearest_fcurve_vert_store(ListBase *matches, View2D *v2d, FCurve *fc } } else if (fpt) { - // TODO... + /* TODO... */ } -} +} /* helper for find_nearest_fcurve_vert() - build the list of nearest matches */ static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], ListBase *matches) diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index b92f4829cd3..1f4fc939818 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -372,7 +372,7 @@ static char *slot_menu(void) static char *layer_menu(RenderResult *rr, short *UNUSED(curlay)) { RenderLayer *rl; - int len = 64 + 32 * BLI_countlist(&rr->layers); + int len = 64 + RE_MAXNAME * BLI_countlist(&rr->layers); short a, nr = 0; char *str = MEM_callocN(len, "menu layers"); diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 28fe1459239..dba943589ba 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -1695,7 +1695,7 @@ static int image_invert_exec(bContext *C, wmOperator *op) Image *ima = CTX_data_edit_image(C); ImBuf *ibuf = BKE_image_get_ibuf(ima, NULL); - // flags indicate if this channel should be inverted + /* flags indicate if this channel should be inverted */ const short r = RNA_boolean_get(op->ptr, "invert_r"); const short g = RNA_boolean_get(op->ptr, "invert_g"); const short b = RNA_boolean_get(op->ptr, "invert_b"); @@ -1703,7 +1703,7 @@ static int image_invert_exec(bContext *C, wmOperator *op) int i; - if (ibuf == NULL) // TODO: this should actually never happen, but does for render-results -> cleanup + if (ibuf == NULL) /* TODO: this should actually never happen, but does for render-results -> cleanup */ return OPERATOR_CANCELLED; /* TODO: make this into an IMB_invert_channels(ibuf,r,g,b,a) method!? */ diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c index e3c831824f1..af790443928 100644 --- a/source/blender/editors/space_nla/nla_channels.c +++ b/source/blender/editors/space_nla/nla_channels.c @@ -140,9 +140,9 @@ static int mouse_nla_channels(bAnimContext *ac, float x, int channel_index, shor } else { Base *b; - + /* deselect all */ - // TODO: should this deselect all other types of channels too? + /* TODO: should this deselect all other types of channels too? */ for (b = sce->base.first; b; b = b->next) { b->flag &= ~SELECT; b->object->flag = b->flag; @@ -268,8 +268,8 @@ static int mouse_nla_channels(bAnimContext *ac, float x, int channel_index, shor if (x >= (v2d->cur.xmax - NLACHANNEL_BUTTON_WIDTH)) { if (nlaedit_is_tweakmode_on(ac) == 0) { /* 'push-down' action - only usable when not in TweakMode */ - // TODO: make this use the operator instead of calling the function directly - // however, calling the operator requires that we supply the args, and that works with proper buttons only + /* TODO: make this use the operator instead of calling the function directly + * however, calling the operator requires that we supply the args, and that works with proper buttons only */ BKE_nla_action_pushdown(adt); } else { diff --git a/source/blender/editors/space_view3d/drawanimviz.c b/source/blender/editors/space_view3d/drawanimviz.c index f8d942b4fd1..4fc3edb521e 100644 --- a/source/blender/editors/space_view3d/drawanimviz.c +++ b/source/blender/editors/space_view3d/drawanimviz.c @@ -63,9 +63,9 @@ /* ************************************ Motion Paths ************************************* */ -// TODO: -// - options to draw paths with lines -// - include support for editing the path verts +/* TODO: + * - options to draw paths with lines + * - include support for editing the path verts */ /* Set up drawing environment for drawing motion paths */ void draw_motion_paths_init(View3D *v3d, ARegion *ar) diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 339b5560711..7f7970382bc 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2118,7 +2118,7 @@ static void drawSelectedVertices__mapFunc(void *userData, int index, const float if (!(mv->flag & ME_HIDE)) { const char sel = mv->flag & SELECT; - // TODO define selected color + /* TODO define selected color */ if (sel) { glColor3f(1.0f, 1.0f, 0.0f); } diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index e6ea42aa5ba..3079719efe0 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1574,6 +1574,8 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d, else if (bgpic->source == V3D_BGPIC_MOVIE) { clip = NULL; + /* TODO: skip drawing when out of frame range (as image sequences do above) */ + if (bgpic->flag & V3D_BGPIC_CAMERACLIP) { if (scene->camera) clip = BKE_object_movieclip_get(scene, scene->camera, 1); diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 44860258c89..35281168c2e 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -1392,8 +1392,8 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) float dx = t->mval[0] - cent[0], dy = t->mval[1] - cent[1]; float angle = atan2f(dy, dx); float dist = sqrtf(dx * dx + dy * dy); - float delta_angle = MIN2(15.0f / dist, (float)M_PI / 4.0f); - float spacing_angle = MIN2(5.0f / dist, (float)M_PI / 12.0f); + float delta_angle = minf(15.0f / dist, (float)M_PI / 4.0f); + float spacing_angle = minf(5.0f / dist, (float)M_PI / 12.0f); UI_ThemeColor(TH_WIRE); setlinestyle(3); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index af0b33d58ae..d7241555cc7 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -1829,7 +1829,7 @@ static void editmesh_set_connectivity_distance(BMEditMesh *em, float mtx[][3], f d2 = d + len_v3(vec); if (dists[BM_elem_index_get(v3)] != FLT_MAX) - dists[BM_elem_index_get(v3)] = MIN2(d2, dists[BM_elem_index_get(v3)]); + dists[BM_elem_index_get(v3)] = minf(d2, dists[BM_elem_index_get(v3)]); else dists[BM_elem_index_get(v3)] = d2; diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c index 43f3e81ae92..5c2e57cf27f 100644 --- a/source/blender/editors/uvedit/uvedit_smart_stitch.c +++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c @@ -403,7 +403,9 @@ static void stitch_island_calculate_edge_rotation(UvEdge *edge, StitchState *sta edgecos = uv1[0] * uv2[0] + uv1[1] * uv2[1]; edgesin = uv1[0] * uv2[1] - uv2[0] * uv1[1]; - rotation = (edgesin > 0.0f) ? acosf(MAX2(-1.0f, MIN2(1.0f, edgecos))) : -acosf(MAX2(-1.0f, MIN2(1.0f, edgecos))); + rotation = (edgesin > 0.0f) ? + +acosf(maxf(-1.0f, minf(1.0f, edgecos))) : + -acosf(maxf(-1.0f, minf(1.0f, edgecos))); island_stitch_data[element1->island].num_rot_elements++; island_stitch_data[element1->island].rotation += rotation; diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index 78b5219206d..0fad5e47445 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -1032,7 +1032,9 @@ static void do_material_tex(GPUShadeInput *shi) if (tex->imaflag & TEX_USEALPHA) talpha= 1; } - else continue; + else { + continue; + } /* texture output */ if ((rgbnor & TEX_RGB) && (mtex->texflag & MTEX_RGBTOINT)) { diff --git a/source/blender/ikplugin/intern/iksolver_plugin.c b/source/blender/ikplugin/intern/iksolver_plugin.c index d544e6501fc..21d50e4a71d 100644 --- a/source/blender/ikplugin/intern/iksolver_plugin.c +++ b/source/blender/ikplugin/intern/iksolver_plugin.c @@ -139,7 +139,7 @@ static void initialize_posetree(struct Object *UNUSED(ob), bPoseChannel *pchan_t size = MIN2(segcount, tree->totchannel); a = t = 0; while (a < size && t < tree->totchannel) { - // locate first matching channel + /* locate first matching channel */ for (; t < tree->totchannel && tree->pchan[t] != chanlist[segcount - a - 1]; t++) ; if (t >= tree->totchannel) break; @@ -535,7 +535,7 @@ void iksolver_execute_tree(struct Scene *scene, struct Object *ob, struct bPose for (a = 0; a < tree->totchannel; a++) { if (!(tree->pchan[a]->flag & POSE_DONE)) // successive trees can set the flag BKE_pose_where_is_bone(scene, ob, tree->pchan[a], ctime, 1); - // tell blender that this channel was controlled by IK, it's cleared on each BKE_pose_where_is() + /* tell blender that this channel was controlled by IK, it's cleared on each BKE_pose_where_is() */ tree->pchan[a]->flag |= POSE_CHAIN; } /* 5. execute the IK solver */ diff --git a/source/blender/imbuf/intern/IMB_anim.h b/source/blender/imbuf/intern/IMB_anim.h index 7f4abd29890..571c54b9cb3 100644 --- a/source/blender/imbuf/intern/IMB_anim.h +++ b/source/blender/imbuf/intern/IMB_anim.h @@ -129,9 +129,9 @@ struct anim { float frs_sec_base; int x, y; - /* voor op nummer */ + /* for number */ char name[1024]; - /* voor sequence */ + /* for sequence */ char first[1024]; /* movie */ diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c index 0c36ecdda7e..41e78422f4b 100644 --- a/source/blender/imbuf/intern/allocimbuf.c +++ b/source/blender/imbuf/intern/allocimbuf.c @@ -428,7 +428,7 @@ ImBuf *IMB_dupImBuf(ImBuf *ibuf1) /* silly trick to copy the entire contents of ibuf1 struct over to ibuf */ tbuf = *ibuf1; - // fix pointers + /* fix pointers */ tbuf.rect = ibuf2->rect; tbuf.rect_float = ibuf2->rect_float; tbuf.encodedbuffer = ibuf2->encodedbuffer; @@ -437,12 +437,12 @@ ImBuf *IMB_dupImBuf(ImBuf *ibuf1) for (a = 0; a < IB_MIPMAP_LEVELS; a++) tbuf.mipmap[a] = NULL; - // set malloc flag + /* set malloc flag */ tbuf.mall = ibuf2->mall; tbuf.c_handle = NULL; tbuf.refcounter = 0; - // for now don't duplicate metadata + /* for now don't duplicate metadata */ tbuf.metadata = NULL; *ibuf2 = tbuf; diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c index f0c2d754333..a27aae815da 100644 --- a/source/blender/imbuf/intern/anim_movie.c +++ b/source/blender/imbuf/intern/anim_movie.c @@ -42,8 +42,8 @@ #include <vfw.h> #endif -#undef AVIIF_KEYFRAME // redefined in AVI_avi.h -#undef AVIIF_LIST // redefined in AVI_avi.h +#undef AVIIF_KEYFRAME /* redefined in AVI_avi.h */ +#undef AVIIF_LIST /* redefined in AVI_avi.h */ #define FIXCC(fcc) \ { \ @@ -324,10 +324,10 @@ static int startavi(struct anim *anim) if (anim->pgf) { firstvideo = i; - // get stream length + /* get stream length */ anim->avi->header->TotalFrames = AVIStreamLength(anim->pavi[i]); - - // get information about images inside the stream + + /* get information about images inside the stream */ l = sizeof(abFormat); AVIStreamReadFormat(anim->pavi[i], 0, &abFormat, &l); lpbi = (LPBITMAPINFOHEADER)abFormat; @@ -344,12 +344,12 @@ static int startavi(struct anim *anim) } } - // register number of opened avistreams + /* register number of opened avistreams */ anim->avistreams = i; - // - // Couldn't get any video streams out of this file - // + /* + * Couldn't get any video streams out of this file + */ if ((anim->avistreams == 0) || (firstvideo == -1)) { avierror = AVI_ERROR_FORMAT; } diff --git a/source/blender/imbuf/intern/imageprocess.c b/source/blender/imbuf/intern/imageprocess.c index 40f6f36e06b..5114fcb3ae0 100644 --- a/source/blender/imbuf/intern/imageprocess.c +++ b/source/blender/imbuf/intern/imageprocess.c @@ -258,11 +258,11 @@ void bilinear_interpolation_color(struct ImBuf *in, unsigned char *outI, float * y1 = (int)floor(v); y2 = (int)ceil(v); - // sample area entirely outside image? + /* sample area entirely outside image? */ if (x2 < 0 || x1 > in->x - 1 || y2 < 0 || y1 > in->y - 1) return; if (outF) { - // sample including outside of edges of image + /* sample including outside of edges of image */ if (x1 < 0 || y1 < 0) row1 = empty; else row1 = (float *)in->rect_float + in->x * y1 * 4 + 4 * x1; @@ -285,7 +285,7 @@ void bilinear_interpolation_color(struct ImBuf *in, unsigned char *outI, float * outF[3] = ma_mb * row1[3] + a_mb * row3[3] + ma_b * row2[3] + a_b * row4[3]; } if (outI) { - // sample including outside of edges of image + /* sample including outside of edges of image */ if (x1 < 0 || y1 < 0) row1I = emptyI; else row1I = (unsigned char *)in->rect + in->x * y1 * 4 + 4 * x1; @@ -332,18 +332,18 @@ void bilinear_interpolation_color_wrap(struct ImBuf *in, unsigned char *outI, fl y1 = (int)floor(v); y2 = (int)ceil(v); - // sample area entirely outside image? + /* sample area entirely outside image? */ if (x2 < 0 || x1 > in->x - 1 || y2 < 0 || y1 > in->y - 1) return; - + /* wrap interpolation pixels - main difference from bilinear_interpolation_color */ if (x1 < 0) x1 = in->x + x1; if (y1 < 0) y1 = in->y + y1; - + if (x2 >= in->x) x2 = x2 - in->x; if (y2 >= in->y) y2 = y2 - in->y; if (outF) { - // sample including outside of edges of image + /* sample including outside of edges of image */ row1 = (float *)in->rect_float + in->x * y1 * 4 + 4 * x1; row2 = (float *)in->rect_float + in->x * y2 * 4 + 4 * x1; row3 = (float *)in->rect_float + in->x * y1 * 4 + 4 * x2; @@ -359,7 +359,7 @@ void bilinear_interpolation_color_wrap(struct ImBuf *in, unsigned char *outI, fl outF[3] = ma_mb * row1[3] + a_mb * row3[3] + ma_b * row2[3] + a_b * row4[3]; } if (outI) { - // sample including outside of edges of image + /* sample including outside of edges of image */ row1I = (unsigned char *)in->rect + in->x * y1 * 4 + 4 * x1; row2I = (unsigned char *)in->rect + in->x * y2 * 4 + 4 * x1; row3I = (unsigned char *)in->rect + in->x * y1 * 4 + 4 * x2; @@ -404,10 +404,10 @@ void neareast_interpolation_color(struct ImBuf *in, unsigned char *outI, float * x1 = (int)(u); y1 = (int)(v); - // sample area entirely outside image? + /* sample area entirely outside image? */ if (x1 < 0 || x1 > in->x - 1 || y1 < 0 || y1 > in->y - 1) return; - - // sample including outside of edges of image + + /* sample including outside of edges of image */ if (x1 < 0 || y1 < 0) { if (outI) { outI[0] = 0; diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c index 8b2e27ae1f3..9cf06b08ba4 100644 --- a/source/blender/imbuf/intern/indexer.c +++ b/source/blender/imbuf/intern/indexer.c @@ -181,12 +181,12 @@ struct anim_index *IMB_indexer_open(const char *name) fseek(fp, 0, SEEK_END); idx->num_entries = (ftell(fp) - 12) / - (sizeof(int) + // framepos - sizeof(unsigned long long) + // seek_pos - sizeof(unsigned long long) + // seek_pos_dts - sizeof(unsigned long long) // pts + (sizeof(int) + /* framepos */ + sizeof(unsigned long long) + /* seek_pos */ + sizeof(unsigned long long) + /* seek_pos_dts */ + sizeof(unsigned long long) /* pts */ ); - + fseek(fp, 12, SEEK_SET); idx->entries = MEM_callocN(sizeof(struct anim_index_entry) * @@ -472,7 +472,7 @@ static struct proxy_output_ctx *alloc_proxy_output_ffmpeg( char fname[FILE_MAX]; int ffmpeg_quality; - // JPEG requires this + /* JPEG requires this */ width = round_up(width, 8); height = round_up(height, 8); diff --git a/source/blender/imbuf/intern/indexer_dv.c b/source/blender/imbuf/intern/indexer_dv.c index 0090577062f..4c6b750aa41 100644 --- a/source/blender/imbuf/intern/indexer_dv.c +++ b/source/blender/imbuf/intern/indexer_dv.c @@ -129,7 +129,7 @@ static void parse_packet(indexer_dv_context *This, unsigned char *p) b = bitstream_new(p + 1); switch (type) { - case 0x62: // Record date + case 0x62: /* Record date */ parse_num(&b, 8); This->rec_curr_day = parse_bcd(&b, 6); parse_num(&b, 2); @@ -144,7 +144,7 @@ static void parse_packet(indexer_dv_context *This, unsigned char *p) } This->got_record_date = 1; break; - case 0x63: // Record time + case 0x63: /* Record time */ This->rec_curr_frame = parse_bcd(&b, 6); parse_num(&b, 2); This->rec_curr_second = parse_bcd(&b, 7); @@ -322,7 +322,7 @@ static void proc_frame(indexer_dv_context *This, } } else if (This->ref_time_read_new == This->ref_time_read) { - // do nothing + /* do nothing */ } else { This->gap_start = This->ref_time_read; diff --git a/source/blender/imbuf/intern/jp2.c b/source/blender/imbuf/intern/jp2.c index 3008c233718..6477d40d695 100644 --- a/source/blender/imbuf/intern/jp2.c +++ b/source/blender/imbuf/intern/jp2.c @@ -880,7 +880,7 @@ int imb_savejp2(struct ImBuf *ibuf, const char *name, int flags) parameters.tcp_rates[0] = ((100 - quality) / 90.0f * 99.0f) + 1; - parameters.tcp_numlayers = 1; // only one resolution + parameters.tcp_numlayers = 1; /* only one resolution */ parameters.cp_disto_alloc = 1; image = ibuftoimage(ibuf, ¶meters); diff --git a/source/blender/imbuf/intern/jpeg.c b/source/blender/imbuf/intern/jpeg.c index 47555302a59..03c949bc3d1 100644 --- a/source/blender/imbuf/intern/jpeg.c +++ b/source/blender/imbuf/intern/jpeg.c @@ -86,9 +86,9 @@ int imb_is_a_jpeg(unsigned char *mem) return 0; } -//---------------------------------------------------------- -// JPG ERROR HANDLING -//---------------------------------------------------------- +/*---------------------------------------------------------- + * JPG ERROR HANDLING + *---------------------------------------------------------- */ typedef struct my_error_mgr { struct jpeg_error_mgr pub; /* "public" fields */ @@ -112,9 +112,9 @@ static void jpeg_error(j_common_ptr cinfo) longjmp(err->setjmp_buffer, 1); } -//---------------------------------------------------------- -// INPUT HANDLER FROM MEMORY -//---------------------------------------------------------- +/*---------------------------------------------------------- + * INPUT HANDLER FROM MEMORY + *---------------------------------------------------------- */ typedef struct { unsigned char *buffer; @@ -159,7 +159,7 @@ static void skip_input_data(j_decompress_ptr cinfo, long num_bytes) my_src_ptr src = (my_src_ptr) cinfo->src; if (num_bytes > 0) { - // prevent skipping over file end + /* prevent skipping over file end */ size_t skip_size = (size_t)num_bytes <= src->pub.bytes_in_buffer ? num_bytes : src->pub.bytes_in_buffer; src->pub.next_input_byte = src->pub.next_input_byte + skip_size; diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index 18957cb8260..f5479bce570 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -665,9 +665,9 @@ void IMB_exr_read_channels(void *handle) } void IMB_exr_multilayer_convert(void *handle, void *base, - void * (*addlayer)(void *base, char *str), - void (*addpass)(void *base, void *lay, char *str, - float *rect, int totchan, char *chan_id)) + void * (*addlayer)(void *base, const char *str), + void (*addpass)(void *base, void *lay, const char *str, + float *rect, int totchan, const char *chan_id)) { ExrHandle *data = (ExrHandle *)handle; ExrLayer *lay; @@ -908,14 +908,6 @@ static ExrHandle *imb_exr_begin_read_mem(InputFile *file, int width, int height) /* ********************************************************* */ -typedef struct RGBA { - float r; - float g; - float b; - float a; -} RGBA; - - /* debug only */ static void exr_print_filecontents(InputFile *file) { diff --git a/source/blender/imbuf/intern/openexr/openexr_multi.h b/source/blender/imbuf/intern/openexr/openexr_multi.h index 523dc8120c4..78071975c72 100644 --- a/source/blender/imbuf/intern/openexr/openexr_multi.h +++ b/source/blender/imbuf/intern/openexr/openexr_multi.h @@ -37,9 +37,9 @@ /* Note: as for now openexr only supports 32 chars in channel names. * This api also supports max 8 channels per pass now. easy to fix! */ -#define EXR_LAY_MAXNAME 19 +#define EXR_LAY_MAXNAME 51 #define EXR_PASS_MAXNAME 11 -#define EXR_TOT_MAXNAME 32 +#define EXR_TOT_MAXNAME 64 #define EXR_PASS_MAXCHAN 8 @@ -62,8 +62,8 @@ void IMB_exrtile_write_channels(void *handle, int partx, int party, int level void IMB_exrtile_clear_channels(void *handle); void IMB_exr_multilayer_convert(void *handle, void *base, - void * (*addlayer)(void *base, char *str), - void (*addpass)(void *base, void *lay, char *str, float *rect, int totchan, char *chan_id)); + void * (*addlayer)(void *base, const char *str), + void (*addpass)(void *base, void *lay, const char *str, float *rect, int totchan, const char *chan_id)); void IMB_exr_close(void *handle); diff --git a/source/blender/imbuf/intern/openexr/openexr_stub.cpp b/source/blender/imbuf/intern/openexr/openexr_stub.cpp index e896fc58cf3..7262656d4e8 100644 --- a/source/blender/imbuf/intern/openexr/openexr_stub.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_stub.cpp @@ -48,8 +48,8 @@ void IMB_exrtile_write_channels (void *handle, int partx, int party, int level) void IMB_exrtile_clear_channels (void *handle) { (void)handle; } void IMB_exr_multilayer_convert (void *handle, void *base, - void * (*addlayer)(void *base, char *str), - void (*addpass)(void *base, void *lay, char *str, float *rect, int totchan, char *chan_id)) + void * (*addlayer)(void *base, const char *str), + void (*addpass)(void *base, void *lay, const char *str, float *rect, int totchan, const char *chan_id)) { (void)handle; (void)base; (void)addlayer; (void)addpass; } diff --git a/source/blender/imbuf/intern/png.c b/source/blender/imbuf/intern/png.c index 2aed1485700..928eb219ea5 100644 --- a/source/blender/imbuf/intern/png.c +++ b/source/blender/imbuf/intern/png.c @@ -73,7 +73,7 @@ static void WriteData(png_structp png_ptr, png_bytep data, png_size_t length) { ImBuf *ibuf = (ImBuf *) png_get_io_ptr(png_ptr); - // if buffer is to small increase it. + /* if buffer is to small increase it. */ while (ibuf->encodedsize + length > ibuf->encodedbuffersize) { imb_enlargeencodedbufferImBuf(ibuf); } @@ -144,7 +144,7 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags) return 0; } - // copy image data + /* copy image data */ pixels = MEM_mallocN(ibuf->x * ibuf->y * bytesperpixel * sizeof(unsigned char), "pixels"); if (pixels == NULL) { @@ -186,7 +186,7 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags) } if (flags & IB_mem) { - // create image in memory + /* create image in memory */ imb_addencodedbufferImBuf(ibuf); ibuf->encodedsize = 0; @@ -218,7 +218,7 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags) png_set_compression_level(png_ptr, compression); - // png image settings + /* png image settings */ png_set_IHDR(png_ptr, info_ptr, ibuf->x, @@ -261,10 +261,10 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags) png_set_pHYs(png_ptr, info_ptr, (unsigned int)(ibuf->ppm[0] + 0.5), (unsigned int)(ibuf->ppm[1] + 0.5), PNG_RESOLUTION_METER); } - // write the file header information + /* write the file header information */ png_write_info(png_ptr, info_ptr); - // allocate memory for an array of row-pointers + /* allocate memory for an array of row-pointers */ row_pointers = (png_bytepp) MEM_mallocN(ibuf->y * sizeof(png_bytep), "row_pointers"); if (row_pointers == NULL) { printf("imb_savepng: Cannot allocate row-pointers array for file '%s'\n", name); @@ -276,19 +276,19 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags) return 0; } - // set the individual row-pointers to point at the correct offsets + /* set the individual row-pointers to point at the correct offsets */ for (i = 0; i < ibuf->y; i++) { row_pointers[ibuf->y - 1 - i] = (png_bytep) ((unsigned char *)pixels + (i * ibuf->x) * bytesperpixel * sizeof(unsigned char)); } - // write out the entire image data in one call + /* write out the entire image data in one call */ png_write_image(png_ptr, row_pointers); - // write the additional chunks to the PNG file (not really needed) + /* write the additional chunks to the PNG file (not really needed) */ png_write_end(png_ptr, info_ptr); - // clean up + /* clean up */ MEM_freeN(pixels); MEM_freeN(row_pointers); png_destroy_write_struct(&png_ptr, &info_ptr); @@ -419,14 +419,14 @@ ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags) longjmp(png_jmpbuf(png_ptr), 1); } - // allocate memory for an array of row-pointers + /* allocate memory for an array of row-pointers */ row_pointers = (png_bytepp) MEM_mallocN(ibuf->y * sizeof(png_uint_16p), "row_pointers"); if (row_pointers == NULL) { printf("Cannot allocate row-pointers array\n"); longjmp(png_jmpbuf(png_ptr), 1); } - // set the individual row-pointers to point at the correct offsets + /* set the individual row-pointers to point at the correct offsets */ for (i = 0; i < ibuf->y; i++) { row_pointers[ibuf->y - 1 - i] = (png_bytep) ((png_uint_16 *)pixels16 + (i * ibuf->x) * bytesperpixel); @@ -434,7 +434,7 @@ ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags) png_read_image(png_ptr, row_pointers); - // copy image data + /* copy image data */ to_float = ibuf->rect_float; from16 = pixels16; @@ -487,14 +487,14 @@ ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags) longjmp(png_jmpbuf(png_ptr), 1); } - // allocate memory for an array of row-pointers + /* allocate memory for an array of row-pointers */ row_pointers = (png_bytepp) MEM_mallocN(ibuf->y * sizeof(png_bytep), "row_pointers"); if (row_pointers == NULL) { printf("Cannot allocate row-pointers array\n"); longjmp(png_jmpbuf(png_ptr), 1); } - // set the individual row-pointers to point at the correct offsets + /* set the individual row-pointers to point at the correct offsets */ for (i = 0; i < ibuf->y; i++) { row_pointers[ibuf->y - 1 - i] = (png_bytep) ((unsigned char *)pixels + (i * ibuf->x) * bytesperpixel * sizeof(unsigned char)); @@ -502,7 +502,7 @@ ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags) png_read_image(png_ptr, row_pointers); - // copy image data + /* copy image data */ to = (unsigned char *) ibuf->rect; from = pixels; @@ -555,7 +555,7 @@ ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags) png_read_end(png_ptr, info_ptr); } - // clean up + /* clean up */ if (pixels) MEM_freeN(pixels); if (pixels16) diff --git a/source/blender/imbuf/intern/radiance_hdr.c b/source/blender/imbuf/intern/radiance_hdr.c index 29c2e63637d..2ba1ebf90b5 100644 --- a/source/blender/imbuf/intern/radiance_hdr.c +++ b/source/blender/imbuf/intern/radiance_hdr.c @@ -163,8 +163,8 @@ static void FLOAT2RGBE(fCOLOR fcol, RGBE rgbe) int imb_is_a_hdr(unsigned char *buf) { - // For recognition, Blender only loads first 32 bytes, so use #?RADIANCE id instead - // update: actually, the 'RADIANCE' part is just an optional program name, the magic word is really only the '#?' part + /* For recognition, Blender only loads first 32 bytes, so use #?RADIANCE id instead */ + /* update: actually, the 'RADIANCE' part is just an optional program name, the magic word is really only the '#?' part */ //if (strstr((char*)buf, "#?RADIANCE")) return 1; if (strstr((char *)buf, "#?")) return 1; // if (strstr((char*)buf, "32-bit_rle_rgbe")) return 1; diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c index 615b420429a..cc57ffff812 100644 --- a/source/blender/imbuf/intern/tiff.c +++ b/source/blender/imbuf/intern/tiff.c @@ -466,7 +466,7 @@ static int imb_read_tiff_pixels(ImBuf *ibuf, TIFF *image, int premul) if (success) { ibuf->profile = (bitspersample == 32) ? IB_PROFILE_LINEAR_RGB : IB_PROFILE_SRGB; -// Code seems to be not needed for 16 bits tif, on PPC G5 OSX (ton) + /* Code seems to be not needed for 16 bits tif, on PPC G5 OSX (ton) */ if (bitspersample < 16) if (ENDIAN_ORDER == B_ENDIAN) IMB_convert_rgba_to_abgr(tmpibuf); diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h index 95eadc23ef4..fe2e218637a 100644 --- a/source/blender/makesdna/DNA_ID.h +++ b/source/blender/makesdna/DNA_ID.h @@ -108,7 +108,7 @@ typedef struct ID { void *next, *prev; struct ID *newid; struct Library *lib; - char name[66]; + char name[66]; /* MAX_ID_NAME */ short pad, us; /** * LIB_... flags report on status of the datablock this ID belongs diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index 816187ad61d..0d47f7073be 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -518,7 +518,7 @@ typedef enum eSpaceSeq_Proxy_RenderSize { /* Config and Input for File Selector */ typedef struct FileSelectParams { - char title[32]; /* title, also used for the text of the execute button */ + char title[96]; /* title, also used for the text of the execute button */ char dir[1056]; /* directory, FILE_MAX_LIBEXTRA, 1024 + 32, this is for extreme case when 1023 length path * needs to be linked in, where foo.blend/Armature need adding */ char file[256]; /* file */ diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c index 09cb22683a7..6436d04f54f 100644 --- a/source/blender/makesdna/intern/makesdna.c +++ b/source/blender/makesdna/intern/makesdna.c @@ -64,8 +64,8 @@ /* headers around with more freedom. */ static const char *includefiles[] = { - // if you add files here, please add them at the end - // of makesdna.c (this file) as well + /* if you add files here, please add them at the end + * of makesdna.c (this file) as well */ "DNA_listBase.h", "DNA_vec_types.h", @@ -80,8 +80,8 @@ static const char *includefiles[] = { "DNA_lamp_types.h", "DNA_material_types.h", "DNA_vfont_types.h", - // if you add files here, please add them at the end - // of makesdna.c (this file) as well + /* if you add files here, please add them at the end + * of makesdna.c (this file) as well */ "DNA_meta_types.h", "DNA_curve_types.h", "DNA_mesh_types.h", @@ -122,8 +122,8 @@ static const char *includefiles[] = { "DNA_particle_types.h", "DNA_cloth_types.h", "DNA_gpencil_types.h", - // if you add files here, please add them at the end - // of makesdna.c (this file) as well + /* if you add files here, please add them at the end + * of makesdna.c (this file) as well */ "DNA_windowmanager_types.h", "DNA_anim_types.h", "DNA_boid_types.h", @@ -134,7 +134,7 @@ static const char *includefiles[] = { "DNA_dynamicpaint_types.h", "DNA_mask_types.h", - // empty string to indicate end of includefiles + /* empty string to indicate end of includefiles */ "" }; @@ -450,7 +450,7 @@ static int preprocess_include(char *maindata, int len) memcpy(temp, maindata, len); - // remove all c++ comments + /* remove all c++ comments */ /* replace all enters/tabs/etc with spaces */ cp = temp; a = len; @@ -829,8 +829,8 @@ static int calculate_structlens(int firststruct) else { typelens[structtype] = len; alphalens[structtype] = alphalen; - // two ways to detect if a struct contains a pointer: - // has_pointer is set or alphalen != len + /* two ways to detect if a struct contains a pointer: + * has_pointer is set or alphalen != len */ if (has_pointer || alphalen != len) { if (alphalen % 8) { printf("Sizeerror 8 in struct: %s (add %d bytes)\n", types[structtype], alphalen % 8); @@ -972,7 +972,7 @@ static int make_structDNA(char *baseDirectory, FILE *file) add_type("uint64_t", 8); /* SDNA_TYPE_UINT64 */ add_type("void", 0); /* SDNA_TYPE_VOID */ - // the defines above shouldn't be output in the padding file... + /* the defines above shouldn't be output in the padding file... */ firststruct = nr_types; /* add all include files defined in the global array */ @@ -990,7 +990,7 @@ static int make_structDNA(char *baseDirectory, FILE *file) if (debugSDNA) printf("\tFinished scanning %d headers.\n", i); if (calculate_structlens(firststruct)) { - // error + /* error */ return(1); } @@ -1091,7 +1091,7 @@ static int make_structDNA(char *baseDirectory, FILE *file) if (fp == NULL) ; else { - // add all include files defined in the global array + /* add all include files defined in the global array */ for (i = 0; strlen(includefiles[i]); i++) { fprintf(fp, "#include \"%s%s\"\n", baseDirectory, includefiles[i]); } @@ -1168,7 +1168,7 @@ int main(int argc, char **argv) fprintf(file, "unsigned char DNAstr[]= {\n"); if (make_structDNA(baseDirectory, file)) { - // error + /* error */ fclose(file); make_bad_file(argv[1], __LINE__); return_status = 1; diff --git a/source/blender/makesrna/intern/rna_mesh_api.c b/source/blender/makesrna/intern/rna_mesh_api.c index ec03d452b57..fe18e6254d0 100644 --- a/source/blender/makesrna/intern/rna_mesh_api.c +++ b/source/blender/makesrna/intern/rna_mesh_api.c @@ -36,6 +36,8 @@ #include "BLO_sys_types.h" +#include "BLI_utildefines.h" + #include "BKE_mesh.h" #include "ED_mesh.h" diff --git a/source/blender/modifiers/intern/MOD_boolean_util.c b/source/blender/modifiers/intern/MOD_boolean_util.c index 1b4d9444fd9..9ff35c227de 100644 --- a/source/blender/modifiers/intern/MOD_boolean_util.c +++ b/source/blender/modifiers/intern/MOD_boolean_util.c @@ -73,7 +73,7 @@ typedef struct { static void VertexIt_Destruct(CSG_VertexIteratorDescriptor *iterator) { if (iterator->it) { - // deallocate memory for iterator + /* deallocate memory for iterator */ MEM_freeN(iterator->it); iterator->it = 0; } @@ -128,18 +128,18 @@ static void VertexIt_Construct(CSG_VertexIteratorDescriptor *output, DerivedMesh VertexIt *it; if (output == 0) return; - // allocate some memory for blender iterator + /* allocate some memory for blender iterator */ it = (VertexIt *)(MEM_mallocN(sizeof(VertexIt), "Boolean_VIt")); if (it == 0) { return; } - // assign blender specific variables + /* assign blender specific variables */ it->dm = dm; - it->ob = ob; // needed for obmat transformations - + it->ob = ob; /* needed for obmat transformations */ + it->pos = 0; - // assign iterator function pointers. + /* assign iterator function pointers. */ output->Step = VertexIt_Step; output->Fill = VertexIt_Fill; output->Done = VertexIt_Done; @@ -171,14 +171,14 @@ static void FaceIt_Destruct(CSG_FaceIteratorDescriptor *iterator) static int FaceIt_Done(CSG_IteratorPtr it) { - // assume CSG_IteratorPtr is of the correct type. + /* assume CSG_IteratorPtr is of the correct type. */ FaceIt *iterator = (FaceIt *)it; return(iterator->pos >= iterator->dm->getNumTessFaces(iterator->dm)); } static void FaceIt_Fill(CSG_IteratorPtr it, CSG_IFace *face) { - // assume CSG_IteratorPtr is of the correct type. + /* assume CSG_IteratorPtr is of the correct type. */ FaceIt *face_it = (FaceIt *)it; MFace *mfaces = face_it->dm->getTessFaceArray(face_it->dm); MFace *mface = &mfaces[face_it->pos]; @@ -222,12 +222,12 @@ static void FaceIt_Construct( FaceIt *it; if (output == 0) return; - // allocate some memory for blender iterator + /* allocate some memory for blender iterator */ it = (FaceIt *)(MEM_mallocN(sizeof(FaceIt), "Boolean_FIt")); if (it == 0) { return; } - // assign blender specific variables + /* assign blender specific variables */ it->dm = dm; it->offset = offset; it->pos = 0; @@ -256,7 +256,7 @@ static void FaceIt_Construct( } } - // assign iterator function pointers. + /* assign iterator function pointers. */ output->Step = FaceIt_Step; output->Fill = FaceIt_Fill; output->Done = FaceIt_Done; @@ -267,37 +267,37 @@ static void FaceIt_Construct( static Object *AddNewBlenderMesh(Scene *scene, Base *base) { - // This little function adds a new mesh object to the blender object list - // It uses ob to duplicate data as this seems to be easier than creating - // a new one. This new oject contains no faces nor vertices. + /* This little function adds a new mesh object to the blender object list + * It uses ob to duplicate data as this seems to be easier than creating + * a new one. This new oject contains no faces nor vertices. */ Mesh *old_me; Base *basen; Object *ob_new; - // now create a new blender object. - // duplicating all the settings from the previous object - // to the new one. + /* now create a new blender object. + * duplicating all the settings from the previous object + * to the new one. */ ob_new = BKE_object_copy(base->object); - // Ok we don't want to use the actual data from the - // last object, the above function incremented the - // number of users, so decrement it here. + /* Ok we don't want to use the actual data from the + * last object, the above function incremented the + * number of users, so decrement it here. */ old_me = ob_new->data; old_me->id.us--; - // Now create a new base to add into the linked list of - // vase objects. - + /* Now create a new base to add into the linked list of + * vase objects. */ + basen = MEM_mallocN(sizeof(Base), "duplibase"); *basen = *base; BLI_addhead(&scene->base, basen); /* addhead: anders oneindige lus */ basen->object = ob_new; basen->flag &= ~SELECT; - // Initialize the mesh data associated with this object. + /* Initialize the mesh data associated with this object. */ ob_new->data = BKE_mesh_add("Mesh"); - // Finally assign the object type. + /* Finally assign the object type. */ ob_new->type = OB_MESH; return ob_new; @@ -314,20 +314,20 @@ static void InterpCSGFace( mface = CDDM_get_tessface(dm, index); orig_mface = orig_dm->getTessFaceArray(orig_dm) + orig_index; - // get the vertex coordinates from the original mesh + /* get the vertex coordinates from the original mesh */ orig_co[0] = (orig_dm->getVertArray(orig_dm) + orig_mface->v1)->co; orig_co[1] = (orig_dm->getVertArray(orig_dm) + orig_mface->v2)->co; orig_co[2] = (orig_dm->getVertArray(orig_dm) + orig_mface->v3)->co; orig_co[3] = (orig_mface->v4) ? (orig_dm->getVertArray(orig_dm) + orig_mface->v4)->co : NULL; - // get the vertex coordinates from the new derivedmesh + /* get the vertex coordinates from the new derivedmesh */ co[0] = CDDM_get_vert(dm, mface->v1)->co; co[1] = CDDM_get_vert(dm, mface->v2)->co; co[2] = CDDM_get_vert(dm, mface->v3)->co; co[3] = (nr == 4) ? CDDM_get_vert(dm, mface->v4)->co : NULL; for (j = 0; j < nr; j++) { - // get coordinate into the space of the original mesh + /* get coordinate into the space of the original mesh */ if (mapmat) mul_v3_m4v3(obco, mapmat, co[j]); else @@ -359,28 +359,28 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh( Mesh *me2 = (Mesh *)ob2->data; int i, *origindex_layer; - // create a new DerivedMesh + /* create a new DerivedMesh */ result = CDDM_new(vertex_it->num_elements, 0, face_it->num_elements, 0, 0); CustomData_merge(&dm1->faceData, &result->faceData, CD_MASK_DERIVEDMESH & ~(CD_MASK_NORMAL | CD_MASK_POLYINDEX | CD_MASK_ORIGINDEX), CD_DEFAULT, face_it->num_elements); CustomData_merge(&dm2->faceData, &result->faceData, CD_MASK_DERIVEDMESH & ~(CD_MASK_NORMAL | CD_MASK_POLYINDEX | CD_MASK_ORIGINDEX), CD_DEFAULT, face_it->num_elements); - // step through the vertex iterators: + /* step through the vertex iterators: */ for (i = 0; !vertex_it->Done(vertex_it->it); i++) { CSG_IVertex csgvert; MVert *mvert = CDDM_get_vert(result, i); - // retrieve a csg vertex from the boolean module + /* retrieve a csg vertex from the boolean module */ vertex_it->Fill(vertex_it->it, &csgvert); vertex_it->Step(vertex_it->it); - // we have to map the vertex coordinates back in the coordinate frame - // of the resulting object, since it was computed in world space + /* we have to map the vertex coordinates back in the coordinate frame + * of the resulting object, since it was computed in world space */ mul_v3_m4v3(mvert->co, parinv, csgvert.position); } - // a hash table to remap materials to indices + /* a hash table to remap materials to indices */ material_hash = BLI_ghash_ptr_new("CSG_mat gh"); if (mat) @@ -388,7 +388,7 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh( origindex_layer = result->getTessFaceDataArray(result, CD_ORIGINDEX); - // step through the face iterators + /* step through the face iterators */ for (i = 0; !face_it->Done(face_it->it); i++) { Mesh *orig_me; Object *orig_ob; @@ -397,27 +397,27 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh( MFace *mface; int orig_index, mat_nr; - // retrieve a csg face from the boolean module + /* retrieve a csg face from the boolean module */ face_it->Fill(face_it->it, &csgface); face_it->Step(face_it->it); - // find the original mesh and data + /* find the original mesh and data */ orig_ob = (csgface.orig_face < dm1->getNumTessFaces(dm1)) ? ob1 : ob2; orig_dm = (csgface.orig_face < dm1->getNumTessFaces(dm1)) ? dm1 : dm2; orig_me = (orig_ob == ob1) ? me1 : me2; orig_index = (orig_ob == ob1) ? csgface.orig_face : csgface.orig_face - dm1->getNumTessFaces(dm1); - // copy all face layers, including mface + /* copy all face layers, including mface */ CustomData_copy_data(&orig_dm->faceData, &result->faceData, orig_index, i, 1); - // set mface + /* set mface */ mface = CDDM_get_tessface(result, i); mface->v1 = csgface.vertex_index[0]; mface->v2 = csgface.vertex_index[1]; mface->v3 = csgface.vertex_index[2]; mface->v4 = (csgface.vertex_number == 4) ? csgface.vertex_index[3] : 0; - // set material, based on lookup in hash table + /* set material, based on lookup in hash table */ orig_mat = give_current_material(orig_ob, mface->mat_nr + 1); if (mat && orig_mat) { @@ -431,11 +431,11 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh( } else if (orig_mat) { if (orig_ob == ob1) { - // No need to change materian index for faces from left operand + /* No need to change materian index for faces from left operand */ } else { - // for faces from right operand checn if there's needed material in left operand and if it is, - // use index of that material, otherwise fallback to first material (material with index=0) + /* for faces from right operand checn if there's needed material in left operand and if it is, + * use index of that material, otherwise fallback to first material (material with index=0) */ if (!BLI_ghash_haskey(material_hash, orig_mat)) { int a; @@ -521,27 +521,27 @@ static DerivedMesh *NewBooleanDerivedMesh_intern( if (dm == NULL || dm_select == NULL) return 0; if (!dm->getNumTessFaces(dm) || !dm_select->getNumTessFaces(dm_select)) return 0; - // we map the final object back into ob's local coordinate space. For this - // we need to compute the inverse transform from global to ob (inv_mat), - // and the transform from ob to ob_select for use in interpolation (map_mat) + /* we map the final object back into ob's local coordinate space. For this + * we need to compute the inverse transform from global to ob (inv_mat), + * and the transform from ob to ob_select for use in interpolation (map_mat) */ invert_m4_m4(inv_mat, ob->obmat); mult_m4_m4m4(map_mat, inv_mat, ob_select->obmat); invert_m4_m4(inv_mat, ob_select->obmat); { - // interface with the boolean module: - // - // the idea is, we pass the boolean module verts and faces using the - // provided descriptors. once the boolean operation is performed, we - // get back output descriptors, from which we then build a DerivedMesh + /* interface with the boolean module: + * + * the idea is, we pass the boolean module verts and faces using the + * provided descriptors. once the boolean operation is performed, we + * get back output descriptors, from which we then build a DerivedMesh */ CSG_VertexIteratorDescriptor vd_1, vd_2; CSG_FaceIteratorDescriptor fd_1, fd_2; CSG_OperationType op_type; CSG_BooleanOperation *bool_op; - // work out the operation they chose and pick the appropriate - // enum from the csg module. + /* work out the operation they chose and pick the appropriate + * enum from the csg module. */ switch (int_op_type) { case 1: op_type = e_csg_intersection; break; case 2: op_type = e_csg_union; break; @@ -549,13 +549,13 @@ static DerivedMesh *NewBooleanDerivedMesh_intern( case 4: op_type = e_csg_classify; break; default: op_type = e_csg_intersection; } - + BuildMeshDescriptors(dm_select, ob_select, 0, &fd_1, &vd_1); BuildMeshDescriptors(dm, ob, dm_select->getNumTessFaces(dm_select), &fd_2, &vd_2); bool_op = CSG_NewBooleanFunction(); - // perform the operation + /* perform the operation */ if (CSG_PerformBooleanOperation(bool_op, op_type, fd_1, vd_1, fd_2, vd_2)) { CSG_VertexIteratorDescriptor vd_o; CSG_FaceIteratorDescriptor fd_o; @@ -563,12 +563,12 @@ static DerivedMesh *NewBooleanDerivedMesh_intern( CSG_OutputFaceDescriptor(bool_op, &fd_o); CSG_OutputVertexDescriptor(bool_op, &vd_o); - // iterate through results of operation and insert - // into new object + /* iterate through results of operation and insert + * into new object */ result = ConvertCSGDescriptorsToDerivedMesh( &fd_o, &vd_o, inv_mat, map_mat, mat, totmat, dm_select, ob_select, dm, ob); - // free up the memory + /* free up the memory */ CSG_FreeVertexDescriptor(&vd_o); CSG_FreeFaceDescriptor(&fd_o); } diff --git a/source/blender/modifiers/intern/MOD_collision.c b/source/blender/modifiers/intern/MOD_collision.c index 609d70b6e98..45296e322b5 100644 --- a/source/blender/modifiers/intern/MOD_collision.c +++ b/source/blender/modifiers/intern/MOD_collision.c @@ -140,15 +140,15 @@ static void deformVerts(ModifierData *md, Object *ob, if ((current_time > collmd->time_xnew) || (BKE_ptcache_get_continue_physics())) { unsigned int i; - // check if mesh has changed + /* check if mesh has changed */ if (collmd->x && (numverts != collmd->numverts)) freeData((ModifierData *)collmd); - + if (collmd->time_xnew == -1000) { /* first time */ - collmd->x = dm->dupVertArray(dm); // frame start position - + collmd->x = dm->dupVertArray(dm); /* frame start position */ + for (i = 0; i < numverts; i++) { - // we save global positions + /* we save global positions */ mul_m4_v3(ob->obmat, collmd->x[i].co); } @@ -164,22 +164,22 @@ static void deformVerts(ModifierData *md, Object *ob, collmd->mfaces = dm->dupTessFaceArray(dm); collmd->numfaces = dm->getNumTessFaces(dm); - // create bounding box hierarchy + /* create bounding box hierarchy */ collmd->bvhtree = bvhtree_build_from_mvert(collmd->mfaces, collmd->numfaces, collmd->x, numverts, ob->pd->pdef_sboft); - + collmd->time_x = collmd->time_xnew = current_time; } else if (numverts == collmd->numverts) { - // put positions to old positions + /* put positions to old positions */ tempVert = collmd->x; collmd->x = collmd->xnew; collmd->xnew = tempVert; collmd->time_x = collmd->time_xnew; - + memcpy(collmd->xnew, dm->getVertArray(dm), numverts * sizeof(MVert)); - + for (i = 0; i < numverts; i++) { - // we save global positions + /* we save global positions */ mul_m4_v3(ob->obmat, collmd->xnew[i].co); } @@ -200,7 +200,7 @@ static void deformVerts(ModifierData *md, Object *ob, collmd->bvhtree = bvhtree_build_from_mvert(collmd->mfaces, collmd->numfaces, collmd->current_x, numverts, ob->pd->pdef_sboft); } else { - // recalc static bounding boxes + /* recalc static bounding boxes */ bvhtree_update_from_mvert(collmd->bvhtree, collmd->mfaces, collmd->numfaces, collmd->current_x, collmd->current_xnew, collmd->numverts, 1); } diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.c b/source/blender/modifiers/intern/MOD_fluidsim_util.c index a33d80bcd35..1c98880c3db 100644 --- a/source/blender/modifiers/intern/MOD_fluidsim_util.c +++ b/source/blender/modifiers/intern/MOD_fluidsim_util.c @@ -96,20 +96,20 @@ void fluidsim_init(FluidsimModifierData *fluidmd) fss->animRate = 1.0; fss->gstar = 0.005; // used as normgstar fss->maxRefine = -1; - // maxRefine is set according to resolutionxyz during bake + /* maxRefine is set according to resolutionxyz during bake */ - // fluid/inflow settings - // fss->iniVel --> automatically set to 0 + /* fluid/inflow settings + * fss->iniVel --> automatically set to 0 */ modifier_path_init(fss->surfdataPath, sizeof(fss->surfdataPath), "cache_fluid"); - // first init of bounding box - // no bounding box needed - - // todo - reuse default init from elbeem! + /* first init of bounding box */ + /* no bounding box needed */ + + /* todo - reuse default init from elbeem! */ fss->typeFlags = OB_FSBND_PARTSLIP | OB_FSSG_NOOBS; fss->domainNovecgen = 0; - fss->volumeInitType = 1; // volume + fss->volumeInitType = 1; /* volume */ fss->partSlipValue = 0.2; fss->generateTracers = 0; @@ -118,8 +118,8 @@ void fluidsim_init(FluidsimModifierData *fluidmd) fss->surfaceSubdivs = 0.0; fss->particleInfSize = 0.0; fss->particleInfAlpha = 0.0; - - // init fluid control settings + + /* init fluid control settings */ fss->attractforceStrength = 0.2; fss->attractforceRadius = 0.75; fss->velocityforceStrength = 0.2; @@ -179,27 +179,27 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam const short mp_mat_nr = mp_example->mat_nr; const char mp_flag = mp_example->flag; - // ------------------------------------------------ - // get numverts + numfaces first - // ------------------------------------------------ + /* ------------------------------------------------ + * get numverts + numfaces first + * ------------------------------------------------ */ gzf = BLI_gzopen(filename, "rb"); if (!gzf) { return NULL; } - // read numverts + /* read numverts */ gotBytes = gzread(gzf, &wri, sizeof(wri)); numverts = wri; - // skip verts + /* skip verts */ gotBytes = gzseek(gzf, numverts * 3 * sizeof(float), SEEK_CUR) != -1; - // read number of normals + /* read number of normals */ if (gotBytes) gotBytes = gzread(gzf, &wri, sizeof(wri)); - // skip normals + /* skip normals */ gotBytes = gzseek(gzf, numverts * 3 * sizeof(float), SEEK_CUR) != -1; /* get no. of triangles */ @@ -208,7 +208,7 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam numfaces = wri; gzclose(gzf); - // ------------------------------------------------ + /* ------------------------------------------------ */ if (!numfaces || !numverts || !gotBytes) return NULL; @@ -225,16 +225,16 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam return NULL; } - // read numverts + /* read numverts */ gotBytes = gzread(gzf, &wri, sizeof(wri)); - // read vertex position from file + /* read vertex position from file */ mv = CDDM_get_verts(dm); for (i = 0; i < numverts; i++, mv++) gotBytes = gzread(gzf, mv->co, sizeof(float) * 3); - // should be the same as numverts + /* should be the same as numverts */ gotBytes = gzread(gzf, &wri, sizeof(wri)); if (wri != numverts) { if (dm) @@ -251,7 +251,7 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam return NULL; } - // read normals from file (but don't save them yet) + /* read normals from file (but don't save them yet) */ for (i = numverts, no_s = normals; i > 0; i--, no_s += 3) { gotBytes = gzread(gzf, no, sizeof(float) * 3); normal_float_to_short_v3(no_s, no); @@ -269,7 +269,7 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam return NULL; } - // read triangles from file + /* read triangles from file */ mp = CDDM_get_polys(dm); ml = CDDM_get_loops(dm); for (i = 0; i < numfaces; i++, mp++, ml += 3) { @@ -333,7 +333,7 @@ void fluid_get_bb(MVert *mvert, int totvert, float obmat[][4], if (vec[2] > bbez) { bbez = vec[2]; } } - // return values... + /* return values... */ if (start) { start[0] = bbsx; start[1] = bbsy; @@ -377,7 +377,7 @@ static void fluidsim_read_vel_cache(FluidsimModifierData *fluidmd, DerivedMesh * int totvert = dm->getNumVerts(dm); FluidVertexVelocity *velarray = NULL; - // mesh and vverts have to be valid from loading... + /* mesh and vverts have to be valid from loading... */ if (fss->meshVelocities) MEM_freeN(fss->meshVelocities); @@ -393,8 +393,8 @@ static void fluidsim_read_vel_cache(FluidsimModifierData *fluidmd, DerivedMesh * velarray = fss->meshVelocities; - // .bobj.gz, correct filename - // 87654321 + /* .bobj.gz, correct filename + * 87654321 */ filename[len - 6] = 'v'; filename[len - 5] = 'e'; filename[len - 4] = 'l'; @@ -461,8 +461,8 @@ static DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm, BLI_path_abs(targetFile, modifier_path_relbase(ob)); BLI_path_frame(targetFile, curFrame, 0); // fixed #frame-no - // assign material + flags to new dm - // if there's no faces in original dm, keep materials and flags unchanged + /* assign material + flags to new dm + * if there's no faces in original dm, keep materials and flags unchanged */ mpoly = orgdm->getPolyArray(orgdm); if (mpoly) { mp_example = *mpoly; @@ -472,7 +472,7 @@ static DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm, dm = fluidsim_read_obj(targetFile, &mp_example); if (!dm) { - // switch, abort background rendering when fluidsim mesh is missing + /* switch, abort background rendering when fluidsim mesh is missing */ const char *strEnvName2 = "BLENDER_ELBEEMBOBJABORT"; // from blendercall.cpp if (G.background == 1) { @@ -486,13 +486,13 @@ static DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm, } } - // display org. object upon failure which is in dm + /* display org. object upon failure which is in dm */ return NULL; } - // load vertex velocities, if they exist... - // TODO? use generate flag as loading flag as well? - // warning, needs original .bobj.gz mesh loading filename + /* load vertex velocities, if they exist... + * TODO? use generate flag as loading flag as well? + * warning, needs original .bobj.gz mesh loading filename */ if (displaymode == 3) { fluidsim_read_vel_cache(fluidmd, dm, targetFile); } @@ -519,20 +519,20 @@ DerivedMesh *fluidsimModifier_do(FluidsimModifierData *fluidmd, Scene *scene, framenr = (int)scene->r.cfra; - // only handle fluidsim domains + /* only handle fluidsim domains */ if (fluidmd && fluidmd->fss && (fluidmd->fss->type != OB_FLUIDSIM_DOMAIN)) return dm; - - // sanity check + + /* sanity check */ if (!fluidmd || (fluidmd && !fluidmd->fss)) return dm; - + fss = fluidmd->fss; - - // timescale not supported yet - // clmd->sim_parms->timescale= timescale; - // support reversing of baked fluid frames here + /* timescale not supported yet + * clmd->sim_parms->timescale= timescale; */ + + /* support reversing of baked fluid frames here */ if ((fss->flag & OB_FLUIDSIM_REVERSE) && (fss->lastgoodframe >= 0)) { framenr = fss->lastgoodframe - framenr + 1; CLAMP(framenr, 1, fss->lastgoodframe); diff --git a/source/blender/modifiers/intern/MOD_multires.c b/source/blender/modifiers/intern/MOD_multires.c index 472836e3716..afc85a8144e 100644 --- a/source/blender/modifiers/intern/MOD_multires.c +++ b/source/blender/modifiers/intern/MOD_multires.c @@ -38,6 +38,8 @@ #include "DNA_mesh_types.h" #include "DNA_object_types.h" +#include "BLI_utildefines.h" + #include "BKE_cdderivedmesh.h" #include "BKE_mesh.h" #include "BKE_multires.h" diff --git a/source/blender/modifiers/intern/MOD_smoke.c b/source/blender/modifiers/intern/MOD_smoke.c index 7092ef04d0f..b9b3b89e06d 100644 --- a/source/blender/modifiers/intern/MOD_smoke.c +++ b/source/blender/modifiers/intern/MOD_smoke.c @@ -117,7 +117,7 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, if (go->ob) { SmokeModifierData *smd2 = (SmokeModifierData *)modifiers_findByType(go->ob, eModifierType_Smoke); - // check for initialized smoke object + /* check for initialized smoke object */ if (smd2 && (smd2->type & MOD_SMOKE_TYPE_FLOW) && smd2->flow) { DagNode *curNode = dag_get_node(forest, go->ob); dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Smoke Flow"); @@ -130,7 +130,7 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, if (go->ob) { SmokeModifierData *smd2 = (SmokeModifierData *)modifiers_findByType(go->ob, eModifierType_Smoke); - // check for initialized smoke object + /* check for initialized smoke object */ if (smd2 && (smd2->type & MOD_SMOKE_TYPE_COLL) && smd2->coll) { DagNode *curNode = dag_get_node(forest, go->ob); dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Smoke Coll"); diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index ac9ff4c8ef5..93f49fd72c9 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -303,7 +303,7 @@ void BPY_python_end(void) PyGILState_Ensure(); /* finalizing, no need to grab the state */ - // free other python data. + /* free other python data. */ pyrna_free_types(); /* clear all python data from structs */ @@ -317,7 +317,7 @@ void BPY_python_end(void) Py_Finalize(); #ifdef TIME_PY_RUN - // measure time since py started + /* measure time since py started */ bpy_timer = PIL_check_seconds_timer() - bpy_timer; printf("*bpy stats* - "); diff --git a/source/blender/python/intern/bpy_library.c b/source/blender/python/intern/bpy_library.c index d34bdfe9448..40ec8136eb7 100644 --- a/source/blender/python/intern/bpy_library.c +++ b/source/blender/python/intern/bpy_library.c @@ -39,6 +39,12 @@ #include "BLO_readfile.h" +#include "BLI_utildefines.h" +#include "BLI_string.h" +#include "BLI_linklist.h" +#include "BLI_path_util.h" +#include "BLI_listbase.h" + #include "BKE_global.h" #include "BKE_main.h" #include "BKE_library.h" @@ -46,12 +52,6 @@ #include "BKE_report.h" #include "BKE_context.h" -#include "BLI_utildefines.h" -#include "BLI_string.h" -#include "BLI_linklist.h" -#include "BLI_path_util.h" -#include "BLI_listbase.h" - #include "DNA_space_types.h" /* FILE_LINK, FILE_RELPATH */ #include "bpy_util.h" diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 4bba7ba6838..e85adf21477 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -4267,7 +4267,7 @@ static int foreach_parse_args(BPy_PropertyRNA *self, PyObject *args, return -1; } - *tot = PySequence_Size(*seq); // TODO - buffer may not be a sequence! array.array() is tho. + *tot = PySequence_Size(*seq); /* TODO - buffer may not be a sequence! array.array() is tho. */ if (*tot > 0) { foreach_attr_type(self, *attr, raw_type, attr_tot, attr_signed); diff --git a/source/blender/python/intern/gpu.c b/source/blender/python/intern/gpu.c index e5f45ca7736..7e2da5b1818 100644 --- a/source/blender/python/intern/gpu.c +++ b/source/blender/python/intern/gpu.c @@ -83,7 +83,7 @@ PyInit_gpu(void) if (m == NULL) return NULL; - // device constants + /* device constants */ PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_OBJECT_VIEWMAT); PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_OBJECT_MAT); PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_OBJECT_VIEWIMAT); @@ -187,13 +187,13 @@ static PyObject *GPU_export_shader(PyObject *UNUSED(self), PyObject *args, PyObj return NULL; } - // we can call our internal function at last: + /* we can call our internal function at last: */ shader = GPU_shader_export(scene, material); if (!shader) { PyErr_SetString(PyExc_RuntimeError, "cannot export shader"); return NULL; } - // build a dictionary + /* build a dictionary */ result = PyDict_New(); if (shader->fragment) { PY_DICT_ADD_STRING(result, shader, fragment); diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c index 5f372abcc69..895352ccf93 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.c +++ b/source/blender/python/mathutils/mathutils_Matrix.c @@ -2282,7 +2282,7 @@ static struct PyMethodDef Matrix_methods[] = { {"invert", (PyCFunction) Matrix_invert, METH_NOARGS, Matrix_invert_doc}, {"inverted", (PyCFunction) Matrix_inverted, METH_NOARGS, Matrix_inverted_doc}, {"to_3x3", (PyCFunction) Matrix_to_3x3, METH_NOARGS, Matrix_to_3x3_doc}, - // TODO. {"resize_3x3", (PyCFunction) Matrix_resize3x3, METH_NOARGS, Matrix_resize3x3_doc}, + /* TODO. {"resize_3x3", (PyCFunction) Matrix_resize3x3, METH_NOARGS, Matrix_resize3x3_doc}, */ {"to_4x4", (PyCFunction) Matrix_to_4x4, METH_NOARGS, Matrix_to_4x4_doc}, {"resize_4x4", (PyCFunction) Matrix_resize_4x4, METH_NOARGS, Matrix_resize_4x4_doc}, {"rotate", (PyCFunction) Matrix_rotate, METH_O, Matrix_rotate_doc}, diff --git a/source/blender/quicktime/apple/quicktime_export.c b/source/blender/quicktime/apple/quicktime_export.c index ab1192bfdfc..659fd997c1f 100644 --- a/source/blender/quicktime/apple/quicktime_export.c +++ b/source/blender/quicktime/apple/quicktime_export.c @@ -202,7 +202,7 @@ static OSErr QT_SaveCodecSettingsToScene(RenderData *rd, ReportList *reports) QuicktimeCodecData *qcd = rd->qtcodecdata; - // check if current scene already has qtcodec settings, and clear them + /* check if current scene already has qtcodec settings, and clear them */ if (qcd) { free_qtcodecdata(qcd); } @@ -210,26 +210,26 @@ static OSErr QT_SaveCodecSettingsToScene(RenderData *rd, ReportList *reports) qcd = rd->qtcodecdata = MEM_callocN(sizeof(QuicktimeCodecData), "QuicktimeCodecData"); } - // obtain all current codec settings + /* obtain all current codec settings */ SCSetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings); SCSetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings); SCSetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting); - // retreive codecdata from quicktime in a atomcontainer + /* retreive codecdata from quicktime in a atomcontainer */ myErr = SCGetSettingsAsAtomContainer(qtdata->theComponent, &myContainer); if (myErr != noErr) { - BKE_reportf(reports, RPT_ERROR, "Quicktime: SCGetSettingsAsAtomContainer failed\n"); + BKE_reportf(reports, RPT_ERROR, "Quicktime: SCGetSettingsAsAtomContainer failed\n"); goto bail; } - // get the size of the atomcontainer + /* get the size of the atomcontainer */ mySize = GetHandleSize((Handle)myContainer); - // lock and convert the atomcontainer to a *valid* pointer + /* lock and convert the atomcontainer to a *valid* pointer */ QTLockContainer(myContainer); myPtr = *(Handle)myContainer; - // copy the Quicktime data into the blender qtcodecdata struct + /* copy the Quicktime data into the blender qtcodecdata struct */ if (myPtr) { qcd->cdParms = MEM_mallocN(mySize, "qt.cdParms"); memcpy(qcd->cdParms, myPtr, mySize); @@ -258,21 +258,21 @@ static OSErr QT_GetCodecSettingsFromScene(RenderData *rd, ReportList *reports) QuicktimeCodecData *qcd = rd->qtcodecdata; - // if there is codecdata in the blendfile, convert it to a Quicktime handle + /* if there is codecdata in the blendfile, convert it to a Quicktime handle */ if (qcd) { myHandle = NewHandle(qcd->cdSize); PtrToHand(qcd->cdParms, &myHandle, qcd->cdSize); } - // restore codecsettings to the quicktime component + /* restore codecsettings to the quicktime component */ if (qcd->cdParms && qcd->cdSize) { myErr = SCSetSettingsFromAtomContainer((GraphicsExportComponent)qtdata->theComponent, (QTAtomContainer)myHandle); if (myErr != noErr) { - BKE_reportf(reports, RPT_ERROR, "Quicktime: SCSetSettingsFromAtomContainer failed\n"); + BKE_reportf(reports, RPT_ERROR, "Quicktime: SCSetSettingsFromAtomContainer failed\n"); goto bail; } - // update runtime codecsettings for use with the codec dialog + /* update runtime codecsettings for use with the codec dialog */ SCGetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting); SCGetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings); SCGetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings); @@ -312,22 +312,22 @@ static OSErr QT_AddUserDataTextToMovie(Movie theMovie, char *theText, OSType the long myLength = strlen(theText); OSErr myErr = noErr; - // get the movie's user data list + /* get the movie's user data list */ myUserData = GetMovieUserData(theMovie); if (myUserData == NULL) return(paramErr); - - // copy the specified text into a new handle + + /* copy the specified text into a new handle */ myHandle = NewHandleClear(myLength); if (myHandle == NULL) return(MemError()); BlockMoveData(theText, *myHandle, myLength); - // add the data to the movie's user data + /* add the data to the movie's user data */ myErr = AddUserDataText(myUserData, myHandle, theType, 1, (short)GetScriptManagerVariable(smRegionCode)); - // clean up + /* clean up */ DisposeHandle(myHandle); return(myErr); } @@ -408,9 +408,9 @@ static void QT_StartAddVideoSamplesToMedia(const Rect *trackFrame, int rectx, in SCDefaultPixMapSettings(qtdata->theComponent, qtexport->thePixMap, true); - // workaround for crash with H.264, which requires an upgrade to - // the new callback based api for proper encoding, but that's not - // really compatible with rendering out frames sequentially + /* workaround for crash with H.264, which requires an upgrade to + * the new callback based api for proper encoding, but that's not + * really compatible with rendering out frames sequentially */ gTemporalSettings = qtdata->gTemporalSettings; if (qtdata->gSpatialSettings.codecType == kH264CodecType) { if (gTemporalSettings.temporalQuality != codecMinQuality) { @@ -662,7 +662,7 @@ void free_qtcomponentdata(void) static void check_renderbutton_framerate(RenderData *rd, ReportList *reports) { - // to keep float framerates consistent between the codec dialog and frs/sec button. + /* to keep float framerates consistent between the codec dialog and frs/sec button. */ OSErr err; err = SCGetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings); @@ -722,17 +722,17 @@ void quicktime_verify_image_type(RenderData *rd, ImageFormatData *imf) int get_qtcodec_settings(RenderData *rd, ReportList *reports) { OSErr err = noErr; - // erase any existing codecsetting + /* erase any existing codecsetting */ if (qtdata) { if (qtdata->theComponent) CloseComponent(qtdata->theComponent); free_qtcomponentdata(); } - // allocate new + /* allocate new */ qtdata = MEM_callocN(sizeof(QuicktimeComponentData), "QuicktimeComponentData"); qtdata->theComponent = OpenDefaultComponent(StandardCompressionType, StandardCompressionSubType); - // get previous selected codecsetting, from qtatom or detailed settings + /* get previous selected codecsetting, from qtatom or detailed settings */ if (rd->qtcodecdata && rd->qtcodecdata->cdParms) { QT_GetCodecSettingsFromScene(rd, reports); } @@ -774,17 +774,17 @@ static int request_qtcodec_settings(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); RenderData *rd = &scene->r; - // erase any existing codecsetting + /* erase any existing codecsetting */ if (qtdata) { if (qtdata->theComponent) CloseComponent(qtdata->theComponent); free_qtcomponentdata(); } - - // allocate new + + /* allocate new */ qtdata = MEM_callocN(sizeof(QuicktimeComponentData), "QuicktimeComponentData"); qtdata->theComponent = OpenDefaultComponent(StandardCompressionType, StandardCompressionSubType); - - // get previous selected codecsetting, from qtatom or detailed settings + + /* get previous selected codecsetting, from qtatom or detailed settings */ if (rd->qtcodecdata && rd->qtcodecdata->cdParms) { QT_GetCodecSettingsFromScene(rd, op->reports); } @@ -813,14 +813,14 @@ static int request_qtcodec_settings(bContext *C, wmOperator *op) err = SCSetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting); CheckError(err, "SCSetInfo3 error", op->reports); } - // put up the dialog box - it needs to be called from the main thread + /* put up the dialog box - it needs to be called from the main thread */ err = SCRequestSequenceSettings(qtdata->theComponent); - + if (err == scUserCancelled) { return OPERATOR_FINISHED; } - // update runtime codecsettings for use with the codec dialog + /* update runtime codecsettings for use with the codec dialog */ SCGetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting); SCGetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings); SCGetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings); @@ -843,7 +843,7 @@ static int request_qtcodec_settings(bContext *C, wmOperator *op) QT_SaveCodecSettingsToScene(rd, op->reports); - // framerate jugglin' + /* framerate jugglin' */ if (qtdata->gTemporalSettings.frameRate == 1571553) { // 23.98 fps qtdata->kVideoTimeScale = 24000; qtdata->duration = 1001; diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h index c276d3796dd..f9c55a3dc03 100644 --- a/source/blender/render/extern/include/RE_pipeline.h +++ b/source/blender/render/extern/include/RE_pipeline.h @@ -51,8 +51,8 @@ struct EnvMap; /* this include is what is exposed of render to outside world */ /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#define RE_MAXNAME 32 +/* length of the scene name + passname */ +#define RE_MAXNAME ((MAX_ID_NAME - 2) + 10) /* only used as handle */ typedef struct Render Render; @@ -81,7 +81,7 @@ typedef struct RenderLayer { struct RenderLayer *next, *prev; /* copy of RenderData */ - char name[RE_MAXNAME]; + char name[RE_MAXNAME]; unsigned int lay, lay_zmask, lay_exclude; int layflag, passflag, pass_xor; @@ -147,8 +147,7 @@ typedef struct RenderStats { short curfield, curblur, curpart, partsdone, convertdone, curfsa; double starttime, lastframetime; const char *infostr, *statstr; - char scenename[32]; - + char scene_name[MAX_ID_NAME - 2]; } RenderStats; /* *********************** API ******************** */ diff --git a/source/blender/render/intern/raytrace/rayobject_qbvh.cpp b/source/blender/render/intern/raytrace/rayobject_qbvh.cpp index 2e37782d047..16d70297a34 100644 --- a/source/blender/render/intern/raytrace/rayobject_qbvh.cpp +++ b/source/blender/render/intern/raytrace/rayobject_qbvh.cpp @@ -151,7 +151,7 @@ RayObject *RE_rayobject_qbvh_create(int size) #else -RayObject *RE_rayobject_qbvh_create(int size) +RayObject *RE_rayobject_qbvh_create(int UNUSED(size)) { puts("WARNING: SSE disabled at compile time\n"); return NULL; diff --git a/source/blender/render/intern/raytrace/rayobject_svbvh.cpp b/source/blender/render/intern/raytrace/rayobject_svbvh.cpp index 697ba9ad6e2..c1bdfa6c72c 100644 --- a/source/blender/render/intern/raytrace/rayobject_svbvh.cpp +++ b/source/blender/render/intern/raytrace/rayobject_svbvh.cpp @@ -183,7 +183,7 @@ RayObject *RE_rayobject_svbvh_create(int size) #else -RayObject *RE_rayobject_svbvh_create(int size) +RayObject *RE_rayobject_svbvh_create(int UNUSED(size)) { puts("WARNING: SSE disabled at compile time\n"); return NULL; diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index d21a22f553b..803a9a95571 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -525,7 +525,7 @@ typedef struct { } SRenderMeshToTangent; -// interface +/* interface */ #include "mikktspace.h" static int GetNumFaces(const SMikkTSpaceContext * pContext) @@ -1029,7 +1029,7 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par static int second=0; sub_v3_v3v3(nor, vec, vec1); - normalize_v3(nor); // nor needed as tangent + normalize_v3(nor); /* nor needed as tangent */ cross_v3_v3v3(cross, vec, nor); /* turn cross in pixelsize */ @@ -1089,7 +1089,7 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par add_v3_v3(vlr->v1->co, cross); copy_v3_v3(vlr->v1->n, nor); vlr->v1->orco= sd->orco; - vlr->v1->accum= -1.0f; // accum abuse for strand texco + vlr->v1->accum = -1.0f; /* accum abuse for strand texco */ copy_v3_v3(vlr->v2->co, vec); sub_v3_v3v3(vlr->v2->co, vlr->v2->co, cross); @@ -1101,8 +1101,8 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par add_v3_v3(vlr->v4->co, cross); copy_v3_v3(vlr->v4->n, nor); vlr->v4->orco= sd->orco; - vlr->v4->accum= 1.0f; // accum abuse for strand texco - + vlr->v4->accum = 1.0f; /* accum abuse for strand texco */ + copy_v3_v3(vlr->v3->co, vec1); sub_v3_v3v3(vlr->v3->co, vlr->v3->co, cross); copy_v3_v3(vlr->v3->n, nor); @@ -1163,7 +1163,7 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par add_v3_v3(v1->co, cross); copy_v3_v3(v1->n, nor); v1->orco= sd->orco; - v1->accum= -1.0f; // accum abuse for strand texco + v1->accum = -1.0f; /* accum abuse for strand texco */ copy_v3_v3(v2->co, vec); sub_v3_v3v3(v2->co, v2->co, cross); @@ -1180,11 +1180,11 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par vlr->v2= v2; vlr->v3= RE_findOrAddVert(obr, obr->totvert++); vlr->v4= RE_findOrAddVert(obr, obr->totvert++); - - v1= vlr->v4; // cycle - v2= vlr->v3; // cycle - + v1= vlr->v4; /* cycle */ + v2= vlr->v3; /* cycle */ + + if (sd->adapt) { second=0; copy_v3_v3(anor, nor); @@ -1209,9 +1209,9 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par vlr->v2= v2; vlr->v3= RE_findOrAddVert(obr, obr->totvert++); vlr->v4= RE_findOrAddVert(obr, obr->totvert++); - - v1= vlr->v4; // cycle - v2= vlr->v3; // cycle + + v1= vlr->v4; /* cycle */ + v2= vlr->v3; /* cycle */ copy_v3_v3(anor, nor); copy_v3_v3(avec, vec); @@ -1225,8 +1225,8 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par add_v3_v3(vlr->v4->co, cross); copy_v3_v3(vlr->v4->n, nor); vlr->v4->orco= sd->orco; - vlr->v4->accum= -1.0f + 2.0f*sd->time; // accum abuse for strand texco - + vlr->v4->accum= -1.0f + 2.0f * sd->time; /* accum abuse for strand texco */ + copy_v3_v3(vlr->v3->co, vec); sub_v3_v3v3(vlr->v3->co, vlr->v3->co, cross); copy_v3_v3(vlr->v3->n, nor); @@ -1309,7 +1309,7 @@ static void static_particle_wire(ObjectRen *obr, Material *ma, const float vec[3 vlr->v3= vlr->v2; vlr->v4= NULL; - v1= vlr->v2; // cycle + v1= vlr->v2; /* cycle */ copy_v3_v3(v1->co, vec); sub_v3_v3v3(vlr->n, vec, vec1); @@ -1630,12 +1630,12 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem /* 2.1 setup material stff */ ma= give_render_material(re, ob, part->omat); -#if 0 // XXX old animation system +#if 0 /* XXX old animation system */ if (ma->ipo) { calc_ipo(ma->ipo, cfra); execute_ipo((ID *)ma, ma->ipo); } -#endif // XXX old animation system +#endif /* XXX old animation system */ hasize = ma->hasize; seed = ma->seed1; @@ -2087,10 +2087,10 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem strandbuf->surface= cache_strand_surface(re, obr, psmd->dm, mat, timeoffset); /* 4. clean up */ -#if 0 // XXX old animation system +#if 0 /* XXX old animation system */ if (ma) do_mat_ipo(re->scene, ma); -#endif // XXX old animation system - +#endif /* XXX old animation system */ + if (orco1) MEM_freeN(sd.orco); @@ -3267,7 +3267,7 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) int a, a1, ok, vertofs; int end, do_autosmooth = FALSE, totvert = 0; int use_original_normals = FALSE; - int recalc_normals = 0; // false by default + int recalc_normals = 0; /* false by default */ int negative_scale; me= ob->data; @@ -3471,7 +3471,7 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) int t; mtf= RE_vlakren_get_tface(obr, vlr, mtfn++, &name, 1); mtface= (MTFace*)layer->data; - *mtf= mtface[a]; // copy face info + *mtf = mtface[a]; /* copy face info */ for (vindex=0; vindex<nr_verts; vindex++) for (t=0; t<2; t++) mtf->uv[vindex][t]=mtface[a].uv[rev_tab[vindex]][t]; @@ -3733,7 +3733,7 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) lar->shdwb= la->shdwb; lar->k= la->k; - // area + /* area */ lar->ray_samp= la->ray_samp; lar->ray_sampy= la->ray_sampy; lar->ray_sampz= la->ray_sampz; @@ -3784,7 +3784,7 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) } area_lamp_vectors(lar); - init_jitter_plane(lar); // subsamples + init_jitter_plane(lar); /* subsamples */ } else if (lar->type==LA_SUN) { lar->ray_totsamp= lar->ray_samp*lar->ray_samp; @@ -3819,7 +3819,7 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) memcpy(lar->mtex, la->mtex, MAX_MTEX*sizeof(void *)); - lar->lay= ob->lay & 0xFFFFFF; // higher 8 bits are localview layers + lar->lay = ob->lay & 0xFFFFFF; /* higher 8 bits are localview layers */ lar->falloff_type = la->falloff_type; lar->ld1= la->att1; @@ -3904,7 +3904,7 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) /* Per lamp, one shadow buffer is made. */ lar->bufflag= la->bufflag; copy_m4_m4(mat, ob->obmat); - initshadowbuf(re, lar, mat); // mat is altered + initshadowbuf(re, lar, mat); /* mat is altered */ } @@ -4247,8 +4247,8 @@ static void check_non_flat_quads(ObjectRen *obr) xn = dot_v3v3(nor, vlr->n); - if (ABS(xn) < 0.999995f ) { // checked on noisy fractal grid - + if (ABS(xn) < 0.999995f ) { /* checked on noisy fractal grid */ + float d1, d2; vlr1= RE_vlakren_copy(obr, vlr); @@ -5038,7 +5038,7 @@ void RE_Database_FromScene(Render *re, Main *bmain, Scene *scene, unsigned int l /* per second, per object, stats print this */ re->i.infostr= "Preparing Scene data"; re->i.cfra= scene->r.cfra; - BLI_strncpy(re->i.scenename, scene->id.name+2, sizeof(re->i.scenename)); + BLI_strncpy(re->i.scene_name, scene->id.name + 2, sizeof(re->i.scene_name)); /* XXX add test if dbase was filled already? */ @@ -5478,7 +5478,7 @@ static int load_fluidsimspeedvectors(Render *re, ObjectInstanceRen *obi, float * else ver++; - // get fluid velocity + /* get fluid velocity */ fsvec[3] = 0.0f; //fsvec[0] = fsvec[1] = fsvec[2] = fsvec[3] = 0.0; fsvec[2] = 2.0f; // NT fixed test for (j=0;j<3;j++) fsvec[j] = velarray[a].vel[j]; @@ -5490,31 +5490,31 @@ static int load_fluidsimspeedvectors(Render *re, ObjectInstanceRen *obi, float * fsvec[2] = avgvel[2]; } - // transform (=rotate) to cam space + /* transform (=rotate) to cam space */ camco[0] = dot_v3v3(imat[0], fsvec); camco[1] = dot_v3v3(imat[1], fsvec); camco[2] = dot_v3v3(imat[2], fsvec); - // get homogenous coordinates + /* get homogenous coordinates */ projectvert(camco, winmat, hoco); projectvert(ver->co, winmat, ho); /* now map hocos to screenspace, uses very primitive clip still */ - // use ho[3] of original vertex, xy component of vel. direction + /* use ho[3] of original vertex, xy component of vel. direction */ if (ho[3]<0.1f) div= 10.0f; else div= 1.0f/ho[3]; zco[0]= zmulx*hoco[0]*div; zco[1]= zmuly*hoco[1]*div; - // maximize speed as usual + /* maximize speed as usual */ len= zco[0]*zco[0] + zco[1]*zco[1]; if (len > winsq) { len= winroot/sqrtf(len); zco[0]*= len; zco[1]*= len; } - + speed= RE_vertren_get_winspeed(obi, ver, 1); - // set both to the same value + /* set both to the same value */ speed[0]= speed[2]= zco[0]; speed[1]= speed[3]= zco[1]; //if (a < 20) fprintf(stderr,"speed %d %f,%f | camco %f,%f,%f | hoco %f,%f,%f,%f\n", a, speed[0], speed[1], camco[0],camco[1], camco[2], hoco[0],hoco[1], hoco[2],hoco[3]); // NT DEBUG @@ -5651,7 +5651,7 @@ void RE_Database_FromScene_Vectors(Render *re, Main *bmain, Scene *sce, unsigned continue; } - // NT check for fluidsim special treatment + /* NT check for fluidsim special treatment */ fluidmd = (FluidsimModifierData *)modifiers_findByType(obi->ob, eModifierType_Fluidsim); if (fluidmd && fluidmd->fss && (fluidmd->fss->type & OB_FLUIDSIM_DOMAIN)) { /* use preloaded per vertex simulation data, only does calculation for step=1 */ @@ -5664,7 +5664,7 @@ void RE_Database_FromScene_Vectors(Render *re, Main *bmain, Scene *sce, unsigned calculate_speedvectors(re, obi, oldobi->vectors, step); else printf("Warning: object %s has different amount of vertices or strands on other frame\n", obi->ob->id.name+2); - } // not fluidsim + } /* not fluidsim */ oldobi= oldobi->next; } diff --git a/source/blender/render/intern/source/envmap.c b/source/blender/render/intern/source/envmap.c index 61de4d39585..5879a9bd66d 100644 --- a/source/blender/render/intern/source/envmap.c +++ b/source/blender/render/intern/source/envmap.c @@ -49,7 +49,7 @@ #include "BKE_library.h" #include "BKE_main.h" -#include "BKE_image.h" // BKE_imbuf_write +#include "BKE_image.h" /* BKE_imbuf_write */ #include "BKE_texture.h" @@ -579,7 +579,7 @@ void make_envmaps(Render *re) re->display_clear(re->dch, re->result); // re->flag |= R_REDRAW_PRV; } - // restore + /* restore */ re->r.mode |= trace; } diff --git a/source/blender/render/intern/source/external_engine.c b/source/blender/render/intern/source/external_engine.c index 2b5ccae7df7..ab66a3c770f 100644 --- a/source/blender/render/intern/source/external_engine.c +++ b/source/blender/render/intern/source/external_engine.c @@ -195,7 +195,7 @@ void RE_engine_update_result(RenderEngine *engine, RenderResult *result) Render *re = engine->re; if (result) { - result->renlay = result->layers.first; // weak, draws first layer always + result->renlay = result->layers.first; /* weak, draws first layer always */ re->display_draw(re->ddh, result, NULL); } } @@ -227,7 +227,7 @@ void RE_engine_end_result(RenderEngine *engine, RenderResult *result, int cancel /* draw */ if (!re->test_break(re->tbh)) { - result->renlay = result->layers.first; // weak, draws first layer always + result->renlay = result->layers.first; /* weak, draws first layer always */ re->display_draw(re->ddh, result, NULL); } } @@ -327,7 +327,7 @@ int RE_engine_render(Render *re, int do_all) /* set render info */ re->i.cfra = re->scene->r.cfra; - BLI_strncpy(re->i.scenename, re->scene->id.name + 2, sizeof(re->i.scenename)); + BLI_strncpy(re->i.scene_name, re->scene->id.name + 2, sizeof(re->i.scene_name)); re->i.totface = re->i.totvert = re->i.totstrand = re->i.totlamp = re->i.tothalo = 0; /* render */ diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c index dcc09c92bb0..a0ba2a82ead 100644 --- a/source/blender/render/intern/source/imagetexture.c +++ b/source/blender/render/intern/source/imagetexture.c @@ -231,13 +231,13 @@ int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], TexResul if (texres->nor) { if (tex->imaflag & TEX_NORMALMAP) { - // qdn: normal from color - // The invert of the red channel is to make - // the normal map compliant with the outside world. - // It needs to be done because in Blender - // the normal used in the renderer points inward. It is generated - // this way in calc_vertexnormals(). Should this ever change - // this negate must be removed. + /* qdn: normal from color + * The invert of the red channel is to make + * the normal map compliant with the outside world. + * It needs to be done because in Blender + * the normal used in the renderer points inward. It is generated + * this way in calc_vertexnormals(). Should this ever change + * this negate must be removed. */ texres->nor[0] = -2.f*(texres->tr - 0.5f); texres->nor[1] = 2.f*(texres->tg - 0.5f); texres->nor[2] = 2.f*(texres->tb - 0.5f); @@ -619,36 +619,36 @@ static void boxsample(ImBuf *ibuf, float minx, float miny, float maxx, float max } } -//----------------------------------------------------------------------------------------------------------------- -// from here, some functions only used for the new filtering +/*----------------------------------------------------------------------------------------------------------------- + * from here, some functions only used for the new filtering */ -// anisotropic filters, data struct used instead of long line of (possibly unused) func args +/* anisotropic filters, data struct used instead of long line of (possibly unused) func args */ typedef struct afdata_t { float dxt[2], dyt[2]; int intpol, extflag; - // feline only + /* feline only */ float majrad, minrad, theta; int iProbes; float dusc, dvsc; } afdata_t; -// this only used here to make it easier to pass extend flags as single int -enum {TXC_XMIR=1, TXC_YMIR, TXC_REPT, TXC_EXTD}; +/* this only used here to make it easier to pass extend flags as single int */ +enum {TXC_XMIR = 1, TXC_YMIR, TXC_REPT, TXC_EXTD}; -// similar to ibuf_get_color() but clips/wraps coords according to repeat/extend flags -// returns true if out of range in clipmode +/* similar to ibuf_get_color() but clips/wraps coords according to repeat/extend flags + * returns true if out of range in clipmode */ static int ibuf_get_color_clip(float col[4], ImBuf *ibuf, int x, int y, int extflag) { int clip = 0; switch (extflag) { - case TXC_XMIR: // y rep + case TXC_XMIR: /* y rep */ x %= 2*ibuf->x; x += x < 0 ? 2*ibuf->x : 0; x = x >= ibuf->x ? 2*ibuf->x - x - 1 : x; y %= ibuf->y; y += y < 0 ? ibuf->y : 0; break; - case TXC_YMIR: // x rep + case TXC_YMIR: /* x rep */ x %= ibuf->x; x += x < 0 ? ibuf->x : 0; y %= 2*ibuf->y; @@ -665,11 +665,12 @@ static int ibuf_get_color_clip(float col[4], ImBuf *ibuf, int x, int y, int extf y %= ibuf->y; y += (y < 0) ? ibuf->y : 0; break; - default: { // as extend, if clipped, set alpha to 0.0 - if (x < 0) { x = 0; } // TXF alpha: clip = 1; } - if (x >= ibuf->x) { x = ibuf->x - 1; } // TXF alpha: clip = 1; } - if (y < 0) { y = 0; } // TXF alpha: clip = 1; } - if (y >= ibuf->y) { y = ibuf->y - 1; } // TXF alpha: clip = 1; } + default: + { /* as extend, if clipped, set alpha to 0.0 */ + if (x < 0) { x = 0; } /* TXF alpha: clip = 1; } */ + if (x >= ibuf->x) { x = ibuf->x - 1; } /* TXF alpha: clip = 1; } */ + if (y < 0) { y = 0; } /* TXF alpha: clip = 1; } */ + if (y >= ibuf->y) { y = ibuf->y - 1; } /* TXF alpha: clip = 1; } */ } } @@ -694,7 +695,7 @@ static int ibuf_get_color_clip(float col[4], ImBuf *ibuf, int x, int y, int extf return clip; } -// as above + bilerp +/* as above + bilerp */ static int ibuf_get_color_clip_bilerp(float col[4], ImBuf *ibuf, float u, float v, int intpol, int extflag) { if (intpol) { @@ -749,12 +750,12 @@ static void area_sample(TexResult* texr, ImBuf* ibuf, float fx, float fy, afdata texr->tr *= xsd; texr->tg *= xsd; texr->tb *= xsd; - // clipping can be ignored if alpha used, texr->ta already includes filtered edge + /* clipping can be ignored if alpha used, texr->ta already includes filtered edge */ texr->ta = texr->talpha ? texr->ta*xsd : (clip ? cw*xsd : 1.f); } -// table of (exp(ar) - exp(a)) / (1 - exp(a)) for r in range [0, 1] and a = -2 -// used instead of actual gaussian, otherwise at high texture magnifications circular artifacts are visible +/* table of (exp(ar) - exp(a)) / (1 - exp(a)) for r in range [0, 1] and a = -2 + * used instead of actual gaussian, otherwise at high texture magnifications circular artifacts are visible */ #define EWA_MAXIDX 255 static float EWA_WTS[EWA_MAXIDX + 1] = { 1.f, 0.990965f, 0.982f, 0.973105f, 0.96428f, 0.955524f, 0.946836f, 0.938216f, 0.929664f, @@ -791,9 +792,9 @@ static float EWA_WTS[EWA_MAXIDX + 1] = 0.00754159f, 0.00625989f, 0.00498819f, 0.00372644f, 0.00247454f, 0.00123242f, 0.f }; -// test if a float value is 'nan' -// there is a C99 function for this: isnan(), but blender seems to use C90 (according to gcc warns), -// and may not be supported by other compilers either +/* test if a float value is 'nan' + * there is a C99 function for this: isnan(), but blender seems to use C90 (according to gcc warns), + * and may not be supported by other compilers either */ #ifndef ISNAN #define ISNAN(x) ((x) != (x)) #endif @@ -802,7 +803,7 @@ static float EWA_WTS[EWA_MAXIDX + 1] = static void radangle2imp(float a2, float b2, float th, float* A, float* B, float* C, float* F) { float ct2 = cosf(th); - const float st2 = 1.f - ct2*ct2; // <- sin(th)^2 + const float st2 = 1.0f - ct2 * ct2; /* <- sin(th)^2 */ ct2 *= ct2; *A = a2*st2 + b2*ct2; *B = (b2 - a2)*sinf(2.f*th); @@ -810,10 +811,10 @@ static void radangle2imp(float a2, float b2, float th, float* A, float* B, float *F = a2*b2; } -// all tests here are done to make sure possible overflows are hopefully minimized +/* all tests here are done to make sure possible overflows are hopefully minimized */ static void imp2radangle(float A, float B, float C, float F, float* a, float* b, float* th, float* ecc) { - if (F <= 1e-5f) { // use arbitrary major radius, zero minor, infinite eccentricity + if (F <= 1e-5f) { /* use arbitrary major radius, zero minor, infinite eccentricity */ *a = sqrtf(A > C ? A : C); *b = 0.f; *ecc = 1e10f; @@ -833,31 +834,31 @@ static void imp2radangle(float A, float B, float C, float F, float* a, float* b, *b = sqrtf(F2 / d); *ecc = *a / *b; } - // incr theta by 0.5*pi (angle of major axis) + /* incr theta by 0.5*pi (angle of major axis) */ *th = 0.5f*(atan2f(B, AmC) + (float)M_PI); } } static void ewa_eval(TexResult* texr, ImBuf* ibuf, float fx, float fy, afdata_t* AFD) { - // scaling dxt/dyt by full resolution can cause overflow because of huge A/B/C and esp. F values, - // scaling by aspect ratio alone does the opposite, so try something in between instead... + /* scaling dxt/dyt by full resolution can cause overflow because of huge A/B/C and esp. F values, + * scaling by aspect ratio alone does the opposite, so try something in between instead... */ const float ff2 = ibuf->x, ff = sqrtf(ff2), q = ibuf->y / ff; const float Ux = AFD->dxt[0]*ff, Vx = AFD->dxt[1]*q, Uy = AFD->dyt[0]*ff, Vy = AFD->dyt[1]*q; float A = Vx*Vx + Vy*Vy; float B = -2.f*(Ux*Vx + Uy*Vy); float C = Ux*Ux + Uy*Uy; float F = A*C - B*B*0.25f; - float a, b, th, ecc, a2, b2, ue, ve, U0, V0, DDQ, U, ac1, ac2, BU, d; // TXF alpha: cw = 0.f; - int u, v, u1, u2, v1, v2; // TXF alpha: clip = 0; - - // The so-called 'high' quality ewa method simply adds a constant of 1 to both A & C, - // so the ellipse always covers at least some texels. But since the filter is now always larger, - // it also means that everywhere else it's also more blurry then ideally should be the case. - // So instead here the ellipse radii are modified instead whenever either is too low. - // Use a different radius based on interpolation switch, just enough to anti-alias when interpolation is off, - // and slightly larger to make result a bit smoother than bilinear interpolation when interpolation is on - // (minimum values: const float rmin = intpol ? 1.f : 0.5f;) + float a, b, th, ecc, a2, b2, ue, ve, U0, V0, DDQ, U, ac1, ac2, BU, d; /* TXF alpha: cw = 0.f; */ + int u, v, u1, u2, v1, v2; /* TXF alpha: clip = 0; */ + + /* The so-called 'high' quality ewa method simply adds a constant of 1 to both A & C, + * so the ellipse always covers at least some texels. But since the filter is now always larger, + * it also means that everywhere else it's also more blurry then ideally should be the case. + * So instead here the ellipse radii are modified instead whenever either is too low. + * Use a different radius based on interpolation switch, just enough to anti-alias when interpolation is off, + * and slightly larger to make result a bit smoother than bilinear interpolation when interpolation is on + * (minimum values: const float rmin = intpol ? 1.f : 0.5f;) */ const float rmin = (AFD->intpol ? 1.5625f : 0.765625f)/ff2; imp2radangle(A, B, C, F, &a, &b, &th, &ecc); if ((b2 = b*b) < rmin) { @@ -903,8 +904,8 @@ static void ewa_eval(TexResult* texr, ImBuf* ibuf, float fx, float fy, afdata_t* float tc[4]; const float wt = EWA_WTS[(Q < 0.f) ? 0 : (unsigned int)Q]; /*const int out =*/ ibuf_get_color_clip(tc, ibuf, u, v, AFD->extflag); - // TXF alpha: clip |= out; - // TXF alpha: cw += out ? 0.f : wt; + /* TXF alpha: clip |= out; + * TXF alpha: cw += out ? 0.f : wt; */ texr->tr += tc[0]*wt; texr->tg += tc[1]*wt; texr->tb += tc[2]*wt; @@ -916,13 +917,13 @@ static void ewa_eval(TexResult* texr, ImBuf* ibuf, float fx, float fy, afdata_t* } } - // d should hopefully never be zero anymore + /* d should hopefully never be zero anymore */ d = 1.f/d; texr->tr *= d; texr->tg *= d; texr->tb *= d; - // clipping can be ignored if alpha used, texr->ta already includes filtered edge - texr->ta = texr->talpha ? texr->ta*d : 1.f; // TXF alpha (clip ? cw*d : 1.f); + /* clipping can be ignored if alpha used, texr->ta already includes filtered edge */ + texr->ta = texr->talpha ? texr->ta*d : 1.f; /* TXF alpha (clip ? cw*d : 1.f); */ } static void feline_eval(TexResult* texr, ImBuf* ibuf, float fx, float fy, afdata_t* AFD) @@ -931,11 +932,11 @@ static void feline_eval(TexResult* texr, ImBuf* ibuf, float fx, float fy, afdata const float ll = ((AFD->majrad == AFD->minrad) ? 2.f*AFD->majrad : 2.f*(AFD->majrad - AFD->minrad)) / (maxn ? (float)maxn : 1.f); float du = maxn ? cosf(AFD->theta)*ll : 0.f; float dv = maxn ? sinf(AFD->theta)*ll : 0.f; - //const float D = -0.5f*(du*du + dv*dv) / (AFD->majrad*AFD->majrad); + /* const float D = -0.5f*(du*du + dv*dv) / (AFD->majrad*AFD->majrad); */ const float D = (EWA_MAXIDX + 1)*0.25f*(du*du + dv*dv) / (AFD->majrad*AFD->majrad); - float d; // TXF alpha: cw = 0.f; - int n; // TXF alpha: clip = 0; - // have to use same scaling for du/dv here as for Ux/Vx/Uy/Vy (*after* D calc.) + float d; /* TXF alpha: cw = 0.f; */ + int n; /* TXF alpha: clip = 0; */ + /* have to use same scaling for du/dv here as for Ux/Vx/Uy/Vy (*after* D calc.) */ du *= AFD->dusc; dv *= AFD->dvsc; d = texr->tr = texr->tb = texr->tg = texr->ta = 0.f; @@ -943,12 +944,12 @@ static void feline_eval(TexResult* texr, ImBuf* ibuf, float fx, float fy, afdata float tc[4]; const float hn = n*0.5f; const float u = fx + hn*du, v = fy + hn*dv; - //const float wt = expf(n*n*D); - // can use ewa table here too + /*const float wt = expf(n*n*D); + * can use ewa table here too */ const float wt = EWA_WTS[(int)(n*n*D)]; /*const int out =*/ ibuf_get_color_clip_bilerp(tc, ibuf, ibuf->x*u, ibuf->y*v, AFD->intpol, AFD->extflag); - // TXF alpha: clip |= out; - // TXF alpha: cw += out ? 0.f : wt; + /* TXF alpha: clip |= out; + * TXF alpha: cw += out ? 0.f : wt; */ texr->tr += tc[0]*wt; texr->tg += tc[1]*wt; texr->tb += tc[2]*wt; @@ -960,7 +961,7 @@ static void feline_eval(TexResult* texr, ImBuf* ibuf, float fx, float fy, afdata texr->tr *= d; texr->tg *= d; texr->tb *= d; - // clipping can be ignored if alpha used, texr->ta already includes filtered edge + /* clipping can be ignored if alpha used, texr->ta already includes filtered edge */ texr->ta = texr->talpha ? texr->ta*d : 1.f; // TXF alpha: (clip ? cw*d : 1.f); } #undef EWA_MAXIDX @@ -970,8 +971,8 @@ static void alpha_clip_aniso(ImBuf *ibuf, float minx, float miny, float maxx, fl float alphaclip; rctf rf; - // TXF apha: we're doing the same alphaclip here as boxsample, but i'm doubting - // if this is actually correct for the all the filtering algorithms .. + /* TXF apha: we're doing the same alphaclip here as boxsample, but i'm doubting + * if this is actually correct for the all the filtering algorithms .. */ if (!(extflag == TXC_REPT || extflag == TXC_EXTD)) { rf.xmin = minx*(ibuf->x); @@ -1040,13 +1041,13 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex texres->tin = texres->ta = texres->tr = texres->tg = texres->tb = 0.f; - // we need to set retval OK, otherwise texture code generates normals itself... + /* we need to set retval OK, otherwise texture code generates normals itself... */ retval = texres->nor ? 3 : 1; - // quick tests + /* quick tests */ if (ibuf==NULL && ima==NULL) return retval; - if (ima) { // hack for icon render + if (ima) { /* hack for icon render */ if ((ima->ibufs.first == NULL) && (R.r.scemode & R_NO_IMAGE_LOAD)) return retval; ibuf = BKE_image_get_ibuf(ima, &tex->iuser); } @@ -1079,18 +1080,18 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex } } - // pixel coordinates + /* pixel coordinates */ minx = MIN3(dxt[0], dyt[0], dxt[0] + dyt[0]); maxx = MAX3(dxt[0], dyt[0], dxt[0] + dyt[0]); miny = MIN3(dxt[1], dyt[1], dxt[1] + dyt[1]); maxy = MAX3(dxt[1], dyt[1], dxt[1] + dyt[1]); - // tex_sharper has been removed + /* tex_sharper has been removed */ minx = (maxx - minx)*0.5f; miny = (maxy - miny)*0.5f; if (tex->imaflag & TEX_FILTER_MIN) { - // make sure the filtersize is minimal in pixels (normal, ref map can have miniature pixel dx/dy) + /* make sure the filtersize is minimal in pixels (normal, ref map can have miniature pixel dx/dy) */ const float addval = (0.5f * tex->filtersize) / (float)MIN2(ibuf->x, ibuf->y); if (addval > minx) minx = addval; if (addval > miny) miny = addval; @@ -1107,9 +1108,9 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex if (tex->imaflag & TEX_IMAROT) { float t; SWAP(float, minx, miny); - // must rotate dxt/dyt 90 deg - // yet another blender problem is that swapping X/Y axes (or any tex proj switches) should do something similar, - // but it doesn't, it only swaps coords, so filter area will be incorrect in those cases. + /* must rotate dxt/dyt 90 deg + * yet another blender problem is that swapping X/Y axes (or any tex proj switches) should do something similar, + * but it doesn't, it only swaps coords, so filter area will be incorrect in those cases. */ t = dxt[0]; dxt[0] = dxt[1]; dxt[1] = -t; @@ -1118,11 +1119,11 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex dyt[1] = -t; } - // side faces of unit-cube + /* side faces of unit-cube */ minx = (minx > 0.25f) ? 0.25f : ((minx < 1e-5f) ? 1e-5f : minx); miny = (miny > 0.25f) ? 0.25f : ((miny < 1e-5f) ? 1e-5f : miny); - // repeat and clip + /* repeat and clip */ if (tex->extend == TEX_REPEAT) { if ((tex->flag & (TEX_REPEAT_XMIR | TEX_REPEAT_YMIR)) == (TEX_REPEAT_XMIR | TEX_REPEAT_YMIR)) @@ -1139,7 +1140,7 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex if (tex->extend == TEX_CHECKER) { int xs = (int)floorf(fx), ys = (int)floorf(fy); - // both checkers available, no boundary exceptions, checkerdist will eat aliasing + /* both checkers available, no boundary exceptions, checkerdist will eat aliasing */ if ((tex->flag & TEX_CHECKER_ODD) && (tex->flag & TEX_CHECKER_EVEN)) { fx -= xs; fy -= ys; @@ -1166,7 +1167,7 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex fy -= ys; } } - // scale around center, (0.5, 0.5) + /* scale around center, (0.5, 0.5) */ if (tex->checkerdist < 1.f) { const float omcd = 1.f / (1.f - tex->checkerdist); fx = (fx - 0.5f)*omcd + 0.5f; @@ -1195,34 +1196,34 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex intpol = tex->imaflag & TEX_INTERPOL; - // warning no return! + /* warning no return! */ if ((R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields)) ibuf->rect += ibuf->x*ibuf->y; - // struct common data + /* struct common data */ copy_v2_v2(AFD.dxt, dxt); copy_v2_v2(AFD.dyt, dyt); AFD.intpol = intpol; AFD.extflag = extflag; - // brecht: added stupid clamping here, large dx/dy can give very large - // filter sizes which take ages to render, it may be better to do this - // more intelligently later in the code .. probably it's not noticeable + /* brecht: added stupid clamping here, large dx/dy can give very large + * filter sizes which take ages to render, it may be better to do this + * more intelligently later in the code .. probably it's not noticeable */ if (AFD.dxt[0]*AFD.dxt[0] + AFD.dxt[1]*AFD.dxt[1] > 2.0f*2.0f) mul_v2_fl(AFD.dxt, 2.0f/len_v2(AFD.dxt)); if (AFD.dyt[0]*AFD.dyt[0] + AFD.dyt[1]*AFD.dyt[1] > 2.0f*2.0f) mul_v2_fl(AFD.dyt, 2.0f/len_v2(AFD.dyt)); - // choice: + /* choice: */ if (tex->imaflag & TEX_MIPMAP) { ImBuf *previbuf, *curibuf; float levf; int maxlev; ImBuf* mipmaps[IB_MIPMAP_LEVELS + 1]; - // modify ellipse minor axis if too eccentric, use for area sampling as well - // scaling dxt/dyt as done in pbrt is not the same - // (as in ewa_eval(), scale by sqrt(ibuf->x) to maximize precision) + /* modify ellipse minor axis if too eccentric, use for area sampling as well + * scaling dxt/dyt as done in pbrt is not the same + * (as in ewa_eval(), scale by sqrt(ibuf->x) to maximize precision) */ const float ff = sqrtf(ibuf->x), q = ibuf->y/ff; const float Ux = dxt[0]*ff, Vx = dxt[1]*q, Uy = dyt[0]*ff, Vy = dyt[1]*q; const float A = Vx*Vx + Vy*Vy; @@ -1248,7 +1249,7 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex AFD.dusc = 1.f/ff; AFD.dvsc = ff / (float)ibuf->y; } - else { // EWA & area + else { /* EWA & area */ if (ecc > (float)tex->afmax) b = a / (float)tex->afmax; b *= ff; } @@ -1264,8 +1265,8 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex curmap++; } - // mipmap level - if (levf < 0.f) { // original image only + /* mipmap level */ + if (levf < 0.f) { /* original image only */ previbuf = curibuf = mipmaps[0]; levf = 0.f; } @@ -1281,39 +1282,39 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex levf -= floorf(levf); } - // filter functions take care of interpolation themselves, no need to modify dxt/dyt here + /* filter functions take care of interpolation themselves, no need to modify dxt/dyt here */ if (texres->nor && ((tex->imaflag & TEX_NORMALMAP) == 0)) { - // color & normal + /* color & normal */ filterfunc(texres, curibuf, fx, fy, &AFD); val1 = texres->tr + texres->tg + texres->tb; filterfunc(&texr, curibuf, fx + dxt[0], fy + dxt[1], &AFD); val2 = texr.tr + texr.tg + texr.tb; filterfunc(&texr, curibuf, fx + dyt[0], fy + dyt[1], &AFD); val3 = texr.tr + texr.tg + texr.tb; - // don't switch x or y! + /* don't switch x or y! */ texres->nor[0] = val1 - val2; texres->nor[1] = val1 - val3; - if (previbuf != curibuf) { // interpolate + if (previbuf != curibuf) { /* interpolate */ filterfunc(&texr, previbuf, fx, fy, &AFD); - // rgb + /* rgb */ texres->tr += levf*(texr.tr - texres->tr); texres->tg += levf*(texr.tg - texres->tg); texres->tb += levf*(texr.tb - texres->tb); texres->ta += levf*(texr.ta - texres->ta); - // normal + /* normal */ val1 += levf*((texr.tr + texr.tg + texr.tb) - val1); filterfunc(&texr, previbuf, fx + dxt[0], fy + dxt[1], &AFD); val2 += levf*((texr.tr + texr.tg + texr.tb) - val2); filterfunc(&texr, previbuf, fx + dyt[0], fy + dyt[1], &AFD); val3 += levf*((texr.tr + texr.tg + texr.tb) - val3); - texres->nor[0] = val1 - val2; // vals have been interpolated above! + texres->nor[0] = val1 - val2; /* vals have been interpolated above! */ texres->nor[1] = val1 - val3; } } - else { // color + else { /* color */ filterfunc(texres, curibuf, fx, fy, &AFD); - if (previbuf != curibuf) { // interpolate + if (previbuf != curibuf) { /* interpolate */ filterfunc(&texr, previbuf, fx, fy, &AFD); texres->tr += levf*(texr.tr - texres->tr); texres->tg += levf*(texr.tg - texres->tg); @@ -1324,8 +1325,8 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex alpha_clip_aniso(ibuf, fx-minx, fy-miny, fx+minx, fy+miny, extflag, texres); } } - else { // no mipmap - // filter functions take care of interpolation themselves, no need to modify dxt/dyt here + else { /* no mipmap */ + /* filter functions take care of interpolation themselves, no need to modify dxt/dyt here */ if (tex->texfilter == TXF_FELINE) { const float ff = sqrtf(ibuf->x), q = ibuf->y/ff; const float Ux = dxt[0]*ff, Vx = dxt[1]*q, Uy = dyt[0]*ff, Vy = dyt[1]*q; @@ -1340,7 +1341,7 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex a = MAX2(a, 1.f); b = MAX2(b, 1.f); fProbes = 2.f*(a / b) - 1.f; - // no limit to number of Probes here + /* no limit to number of Probes here */ AFD.iProbes = (int)floorf(fProbes + 0.5f); if (AFD.iProbes < fProbes) b = 2.f*a / (float)(AFD.iProbes + 1); AFD.majrad = a/ff; @@ -1350,14 +1351,14 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex AFD.dvsc = ff / (float)ibuf->y; } if (texres->nor && ((tex->imaflag & TEX_NORMALMAP) == 0)) { - // color & normal + /* color & normal */ filterfunc(texres, ibuf, fx, fy, &AFD); val1 = texres->tr + texres->tg + texres->tb; filterfunc(&texr, ibuf, fx + dxt[0], fy + dxt[1], &AFD); val2 = texr.tr + texr.tg + texr.tb; filterfunc(&texr, ibuf, fx + dyt[0], fy + dyt[1], &AFD); val3 = texr.tr + texr.tg + texr.tb; - // don't switch x or y! + /* don't switch x or y! */ texres->nor[0] = val1 - val2; texres->nor[1] = val1 - val3; } @@ -1376,23 +1377,23 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex if ((R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields)) ibuf->rect -= ibuf->x*ibuf->y; - if (texres->nor && (tex->imaflag & TEX_NORMALMAP)) { // normal from color - // The invert of the red channel is to make - // the normal map compliant with the outside world. - // It needs to be done because in Blender - // the normal used in the renderer points inward. It is generated - // this way in calc_vertexnormals(). Should this ever change - // this negate must be removed. + if (texres->nor && (tex->imaflag & TEX_NORMALMAP)) { /* normal from color */ + /* The invert of the red channel is to make + * the normal map compliant with the outside world. + * It needs to be done because in Blender + * the normal used in the renderer points inward. It is generated + * this way in calc_vertexnormals(). Should this ever change + * this negate must be removed. */ texres->nor[0] = -2.f*(texres->tr - 0.5f); texres->nor[1] = 2.f*(texres->tg - 0.5f); texres->nor[2] = 2.f*(texres->tb - 0.5f); } - - // de-premul, this is being premulled in shade_input_do_shade() - // TXF: this currently does not (yet?) work properly, destroys edge AA in clip/checker mode, so for now commented out - // also disabled in imagewraposa() to be able to compare results with blender's default texture filtering - // brecht: tried to fix this, see "TXF alpha" comments + /* de-premul, this is being premulled in shade_input_do_shade() + * TXF: this currently does not (yet?) work properly, destroys edge AA in clip/checker mode, so for now commented out + * also disabled in imagewraposa() to be able to compare results with blender's default texture filtering */ + + /* brecht: tried to fix this, see "TXF alpha" comments */ if (texres->ta != 1.f && (texres->ta > 1e-4f)) { fx = 1.f/texres->ta; @@ -1414,12 +1415,12 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const float maxd, pixsize, val1, val2, val3; int curmap, retval, imaprepeat, imapextend; - // TXF: since dxt/dyt might be modified here and since they might be needed after imagewraposa() call, - // make a local copy here so that original vecs remain untouched + /* TXF: since dxt/dyt might be modified here and since they might be needed after imagewraposa() call, + * make a local copy here so that original vecs remain untouched */ copy_v3_v3(dxt, DXT); copy_v3_v3(dyt, DYT); - // anisotropic filtering + /* anisotropic filtering */ if (tex->texfilter != TXF_BOX) return imagewraposa_aniso(tex, ima, ibuf, texvec, dxt, dyt, texres); @@ -1530,7 +1531,7 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const xs= (int)floor(fx); ys= (int)floor(fy); - // both checkers available, no boundary exceptions, checkerdist will eat aliasing + /* both checkers available, no boundary exceptions, checkerdist will eat aliasing */ if ( (tex->flag & TEX_CHECKER_ODD) && (tex->flag & TEX_CHECKER_EVEN) ) { fx-= xs; fy-= ys; @@ -1765,18 +1766,18 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const } if (texres->nor && (tex->imaflag & TEX_NORMALMAP)) { - // qdn: normal from color - // The invert of the red channel is to make - // the normal map compliant with the outside world. - // It needs to be done because in Blender - // the normal used in the renderer points inward. It is generated - // this way in calc_vertexnormals(). Should this ever change - // this negate must be removed. + /* qdn: normal from color + * The invert of the red channel is to make + * the normal map compliant with the outside world. + * It needs to be done because in Blender + * the normal used in the renderer points inward. It is generated + * this way in calc_vertexnormals(). Should this ever change + * this negate must be removed. */ texres->nor[0] = -2.f*(texres->tr - 0.5f); texres->nor[1] = 2.f*(texres->tg - 0.5f); texres->nor[2] = 2.f*(texres->tb - 0.5f); } - + /* de-premul, this is being premulled in shade_input_do_shade() */ if (texres->ta!=1.0f && texres->ta>1e-4f) { fx= 1.0f/texres->ta; diff --git a/source/blender/render/intern/source/occlusion.c b/source/blender/render/intern/source/occlusion.c index b3eb8c0fd5c..485dd005be7 100644 --- a/source/blender/render/intern/source/occlusion.c +++ b/source/blender/render/intern/source/occlusion.c @@ -96,11 +96,11 @@ typedef struct OccNode { typedef struct OcclusionTree { MemArena *arena; - float (*co)[3]; /* temporary during build */ + float (*co)[3]; /* temporary during build */ - OccFace *face; /* instance and face indices */ - float *occlusion; /* occlusion for faces */ - float (*rad)[3]; /* radiance for faces */ + OccFace *face; /* instance and face indices */ + float *occlusion; /* occlusion for faces */ + float (*rad)[3]; /* radiance for faces */ OccNode *root; @@ -137,35 +137,35 @@ typedef struct OcclusionBuildThread { /* ------------------------- Shading --------------------------- */ -extern Render R; // meh +extern Render R; /* meh */ static void occ_shade(ShadeSample *ssamp, ObjectInstanceRen *obi, VlakRen *vlr, float *rad) { - ShadeInput *shi= ssamp->shi; - ShadeResult *shr= ssamp->shr; + ShadeInput *shi = ssamp->shi; + ShadeResult *shr = ssamp->shr; float l, u, v, *v1, *v2, *v3; /* init */ if (vlr->v4) { - shi->u= u= 0.5f; - shi->v= v= 0.5f; + shi->u = u = 0.5f; + shi->v = v = 0.5f; } else { - shi->u= u= 1.0f/3.0f; - shi->v= v= 1.0f/3.0f; + shi->u = u = 1.0f / 3.0f; + shi->v = v = 1.0f / 3.0f; } /* setup render coordinates */ - v1= vlr->v1->co; - v2= vlr->v2->co; - v3= vlr->v3->co; + v1 = vlr->v1->co; + v2 = vlr->v2->co; + v3 = vlr->v3->co; /* renderco */ - l= 1.0f-u-v; + l = 1.0f - u - v; - shi->co[0]= l*v3[0]+u*v1[0]+v*v2[0]; - shi->co[1]= l*v3[1]+u*v1[1]+v*v2[1]; - shi->co[2]= l*v3[2]+u*v1[2]+v*v2[2]; + shi->co[0] = l * v3[0] + u * v1[0] + v * v2[0]; + shi->co[1] = l * v3[1] + u * v1[1] + v * v2[1]; + shi->co[2] = l * v3[2] + u * v1[2] + v * v2[2]; shade_input_set_triangle_i(shi, obi, vlr, 0, 1, 2); @@ -175,9 +175,9 @@ static void occ_shade(ShadeSample *ssamp, ObjectInstanceRen *obi, VlakRen *vlr, /* cache for shadow */ shi->samplenr++; - - shi->xs= 0; // TODO - shi->ys= 0; + + shi->xs = 0; /* TODO */ + shi->ys = 0; shade_input_set_normals(shi); @@ -195,9 +195,9 @@ static void occ_shade(ShadeSample *ssamp, ObjectInstanceRen *obi, VlakRen *vlr, } /* init material vars */ - // note, keep this synced with render_types.h - memcpy(&shi->r, &shi->mat->r, 23*sizeof(float)); - shi->har= shi->mat->har; + /* note, keep this synced with render_types.h */ + memcpy(&shi->r, &shi->mat->r, 23 * sizeof(float)); + shi->har = shi->mat->har; /* render */ shade_input_set_shade_texco(shi); @@ -213,18 +213,18 @@ static void occ_build_shade(Render *re, OcclusionTree *tree) VlakRen *vlr; int a; - R= *re; + R = *re; /* setup shade sample with correct passes */ memset(&ssamp, 0, sizeof(ShadeSample)); - ssamp.shi[0].lay= re->lay; - ssamp.shi[0].passflag= SCE_PASS_DIFFUSE|SCE_PASS_RGBA; - ssamp.shi[0].combinedflag= ~(SCE_PASS_SPEC); - ssamp.tot= 1; + ssamp.shi[0].lay = re->lay; + ssamp.shi[0].passflag = SCE_PASS_DIFFUSE | SCE_PASS_RGBA; + ssamp.shi[0].combinedflag = ~(SCE_PASS_SPEC); + ssamp.tot = 1; - for (a=0; a<tree->totface; a++) { - obi= &R.objectinstance[tree->face[a].obi]; - vlr= RE_findOrAddVlak(obi->obr, tree->face[a].facenr); + for (a = 0; a < tree->totface; a++) { + obi = &R.objectinstance[tree->face[a].obi]; + vlr = RE_findOrAddVlak(obi->obr, tree->face[a].facenr); occ_shade(&ssamp, obi, vlr, tree->rad[a]); } @@ -233,20 +233,20 @@ static void occ_build_shade(Render *re, OcclusionTree *tree) /* ------------------------- Spherical Harmonics --------------------------- */ /* Use 2nd order SH => 9 coefficients, stored in this order: - * 0 = (0,0), - * 1 = (1,-1), 2 = (1,0), 3 = (1,1), - * 4 = (2,-2), 5 = (2,-1), 6 = (2,0), 7 = (2,1), 8 = (2,2) */ +* 0 = (0,0), +* 1 = (1,-1), 2 = (1,0), 3 = (1,1), +* 4 = (2,-2), 5 = (2,-1), 6 = (2,0), 7 = (2,1), 8 = (2,2) */ static void sh_copy(float *shresult, float *sh) { - memcpy(shresult, sh, sizeof(float)*9); + memcpy(shresult, sh, sizeof(float) * 9); } static void sh_mul(float *sh, float f) { int i; - for (i=0; i<9; i++) + for (i = 0; i < 9; i++) sh[i] *= f; } @@ -254,8 +254,8 @@ static void sh_add(float *shresult, float *sh1, float *sh2) { int i; - for (i=0; i<9; i++) - shresult[i]= sh1[i] + sh2[i]; + for (i = 0; i < 9; i++) + shresult[i] = sh1[i] + sh2[i]; } static void sh_from_disc(float *n, float area, float *shresult) @@ -264,21 +264,21 @@ static void sh_from_disc(float *n, float area, float *shresult) * "An Efficient Representation for Irradiance Environment Maps" */ float sh[9], x, y, z; - x= n[0]; - y= n[1]; - z= n[2]; + x = n[0]; + y = n[1]; + z = n[2]; - sh[0]= 0.282095f; + sh[0] = 0.282095f; - sh[1]= 0.488603f*y; - sh[2]= 0.488603f*z; - sh[3]= 0.488603f*x; - - sh[4]= 1.092548f*x*y; - sh[5]= 1.092548f*y*z; - sh[6]= 0.315392f*(3.0f*z*z - 1.0f); - sh[7]= 1.092548f*x*z; - sh[8]= 0.546274f*(x*x - y*y); + sh[1] = 0.488603f * y; + sh[2] = 0.488603f * z; + sh[3] = 0.488603f * x; + + sh[4] = 1.092548f * x * y; + sh[5] = 1.092548f * y * z; + sh[6] = 0.315392f * (3.0f * z * z - 1.0f); + sh[7] = 1.092548f * x * z; + sh[8] = 0.546274f * (x * x - y * y); sh_mul(sh, area); sh_copy(shresult, sh); @@ -292,16 +292,16 @@ static float sh_eval(float *sh, float *v) static const float c4 = 0.886227f, c5 = 0.247708f; float x, y, z, sum; - x= v[0]; - y= v[1]; - z= v[2]; + x = v[0]; + y = v[1]; + z = v[2]; - sum= c1*sh[8]*(x*x - y*y); - sum += c3*sh[6]*z*z; - sum += c4*sh[0]; - sum += -c5*sh[6]; - sum += 2.0f*c1*(sh[4]*x*y + sh[7]*x*z + sh[5]*y*z); - sum += 2.0f*c2*(sh[3]*x + sh[1]*y + sh[2]*z); + sum = c1 * sh[8] * (x * x - y * y); + sum += c3 * sh[6] * z * z; + sum += c4 * sh[0]; + sum += -c5 * sh[6]; + sum += 2.0f * c1 * (sh[4] * x * y + sh[7] * x * z + sh[5] * y * z); + sum += 2.0f * c2 * (sh[3] * x + sh[1] * y + sh[2] * z); return sum; } @@ -314,8 +314,8 @@ static void occ_face(const OccFace *face, float co[3], float normal[3], float *a VlakRen *vlr; float v1[3], v2[3], v3[3], v4[3]; - obi= &R.objectinstance[face->obi]; - vlr= RE_findOrAddVlak(obi->obr, face->facenr); + obi = &R.objectinstance[face->obi]; + vlr = RE_findOrAddVlak(obi->obr, face->facenr); if (co) { if (vlr->v4) @@ -328,9 +328,9 @@ static void occ_face(const OccFace *face, float co[3], float normal[3], float *a } if (normal) { - normal[0]= -vlr->n[0]; - normal[1]= -vlr->n[1]; - normal[2]= -vlr->n[2]; + normal[0] = -vlr->n[0]; + normal[1] = -vlr->n[1]; + normal[2] = -vlr->n[2]; if (obi->flag & R_TRANSFORMED) mul_m3_v3(obi->nmat, normal); @@ -351,9 +351,9 @@ static void occ_face(const OccFace *face, float co[3], float normal[3], float *a /* todo: correct area for instances */ if (vlr->v4) - *area= area_quad_v3(v1, v2, v3, v4); + *area = area_quad_v3(v1, v2, v3, v4); else - *area= area_tri_v3(v1, v2, v3); + *area = area_tri_v3(v1, v2, v3); } } @@ -361,25 +361,25 @@ static void occ_sum_occlusion(OcclusionTree *tree, OccNode *node) { OccNode *child; float occ, area, totarea, rad[3]; - int a, b, indirect= tree->doindirect; + int a, b, indirect = tree->doindirect; - occ= 0.0f; - totarea= 0.0f; + occ = 0.0f; + totarea = 0.0f; if (indirect) zero_v3(rad); - for (b=0; b<TOTCHILD; b++) { - if (node->childflag & (1<<b)) { - a= node->child[b].face; + for (b = 0; b < TOTCHILD; b++) { + if (node->childflag & (1 << b)) { + a = node->child[b].face; occ_face(&tree->face[a], 0, 0, &area); - occ += area*tree->occlusion[a]; + occ += area * tree->occlusion[a]; if (indirect) madd_v3_v3fl(rad, tree->rad[a], area); totarea += area; } else if (node->child[b].node) { - child= node->child[b].node; + child = node->child[b].node; occ_sum_occlusion(tree, child); - occ += child->area*child->occlusion; + occ += child->area * child->occlusion; if (indirect) madd_v3_v3fl(rad, child->rad, child->area); totarea += child->area; } @@ -387,16 +387,16 @@ static void occ_sum_occlusion(OcclusionTree *tree, OccNode *node) if (totarea != 0.0f) { occ /= totarea; - if (indirect) mul_v3_fl(rad, 1.0f/totarea); + if (indirect) mul_v3_fl(rad, 1.0f / totarea); } - node->occlusion= occ; + node->occlusion = occ; if (indirect) copy_v3_v3(node->rad, rad); } static int occ_find_bbox_axis(OcclusionTree *tree, int begin, int end, float *min, float *max) { - float len, maxlen= -1.0f; + float len, maxlen = -1.0f; int a, axis = 0; INIT_MINMAX(min, max); @@ -405,12 +405,12 @@ static int occ_find_bbox_axis(OcclusionTree *tree, int begin, int end, float *mi minmax_v3v3_v3(min, max, tree->co[a]); } - for (a=0; a<3; a++) { - len= max[a] - min[a]; + for (a = 0; a < 3; a++) { + len = max[a] - min[a]; if (len > maxlen) { - maxlen= len; - axis= a; + maxlen = len; + axis = a; } } @@ -422,21 +422,21 @@ static void occ_node_from_face(OccFace *face, OccNode *node) float n[3]; occ_face(face, node->co, n, &node->area); - node->dco= 0.0f; + node->dco = 0.0f; sh_from_disc(n, node->area, node->sh); } static void occ_build_dco(OcclusionTree *tree, OccNode *node, const float co[3], float *dco) { int b; - for (b=0; b<TOTCHILD; b++) { + for (b = 0; b < TOTCHILD; b++) { float dist, d[3], nco[3]; - if (node->childflag & (1<<b)) { - occ_face(tree->face+node->child[b].face, nco, NULL, NULL); + if (node->childflag & (1 << b)) { + occ_face(tree->face + node->child[b].face, nco, NULL, NULL); } else if (node->child[b].node) { - OccNode *child= node->child[b].node; + OccNode *child = node->child[b].node; occ_build_dco(tree, child, co, dco); copy_v3_v3(nco, child->co); } @@ -445,9 +445,9 @@ static void occ_build_dco(OcclusionTree *tree, OccNode *node, const float co[3], } sub_v3_v3v3(d, nco, co); - dist= dot_v3v3(d, d); + dist = dot_v3v3(d, d); if (dist > *dco) - *dco= dist; + *dco = dist; } } @@ -459,12 +459,12 @@ static void occ_build_split(OcclusionTree *tree, int begin, int end, int *split) /* split in middle of boundbox. this seems faster than median split * on complex scenes, possibly since it avoids two distant faces to * be in the same node better? */ - axis= occ_find_bbox_axis(tree, begin, end, min, max); - mid= 0.5f*(min[axis]+max[axis]); + axis = occ_find_bbox_axis(tree, begin, end, min, max); + mid = 0.5f * (min[axis] + max[axis]); - a= begin; - enda= end; - while (a<enda) { + a = begin; + enda = end; + while (a < enda) { if (tree->co[a][axis] > mid) { enda--; SWAP(OccFace, tree->face[a], tree->face[enda]); @@ -476,7 +476,7 @@ static void occ_build_split(OcclusionTree *tree, int begin, int end, int *split) a++; } - *split= enda; + *split = enda; } static void occ_build_8_split(OcclusionTree *tree, int begin, int end, int *offset, int *count) @@ -488,7 +488,7 @@ static void occ_build_8_split(OcclusionTree *tree, int begin, int end, int *offs /* force split if none found, to deal with degenerate geometry */ if (splitx == begin || splitx == end) - splitx= (begin+end)/2; + splitx = (begin + end) / 2; occ_build_split(tree, begin, splitx, &splity[0]); occ_build_split(tree, splitx, end, &splity[1]); @@ -498,25 +498,25 @@ static void occ_build_8_split(OcclusionTree *tree, int begin, int end, int *offs occ_build_split(tree, splitx, splity[1], &splitz[2]); occ_build_split(tree, splity[1], end, &splitz[3]); - offset[0]= begin; - offset[1]= splitz[0]; - offset[2]= splity[0]; - offset[3]= splitz[1]; - offset[4]= splitx; - offset[5]= splitz[2]; - offset[6]= splity[1]; - offset[7]= splitz[3]; - - for (b=0; b<7; b++) - count[b]= offset[b+1] - offset[b]; - count[7]= end - offset[7]; + offset[0] = begin; + offset[1] = splitz[0]; + offset[2] = splity[0]; + offset[3] = splitz[1]; + offset[4] = splitx; + offset[5] = splitz[2]; + offset[6] = splity[1]; + offset[7] = splitz[3]; + + for (b = 0; b < 7; b++) + count[b] = offset[b + 1] - offset[b]; + count[7] = end - offset[7]; } static void occ_build_recursive(OcclusionTree *tree, OccNode *node, int begin, int end, int depth); static void *exec_occ_build(void *data) { - OcclusionBuildThread *othread= (OcclusionBuildThread*)data; + OcclusionBuildThread *othread = (OcclusionBuildThread *)data; occ_build_recursive(othread->tree, othread->node, othread->begin, othread->end, othread->depth); @@ -529,17 +529,17 @@ static void occ_build_recursive(OcclusionTree *tree, OccNode *node, int begin, i OcclusionBuildThread othreads[BLENDER_MAX_THREADS]; OccNode *child, tmpnode; /* OccFace *face; */ - int a, b, totthread=0, offset[TOTCHILD], count[TOTCHILD]; + int a, b, totthread = 0, offset[TOTCHILD], count[TOTCHILD]; /* add a new node */ - node->occlusion= 1.0f; + node->occlusion = 1.0f; /* leaf node with only children */ if (end - begin <= TOTCHILD) { - for (a=begin, b=0; a<end; a++, b++) { + for (a = begin, b = 0; a < end; a++, b++) { /* face= &tree->face[a]; */ - node->child[b].face= a; - node->childflag |= (1<<b); + node->child[b].face = a; + node->childflag |= (1 << b); } } else { @@ -549,40 +549,40 @@ static void occ_build_recursive(OcclusionTree *tree, OccNode *node, int begin, i if (depth == 1 && tree->dothreadedbuild) BLI_init_threads(&threads, exec_occ_build, tree->totbuildthread); - for (b=0; b<TOTCHILD; b++) { + for (b = 0; b < TOTCHILD; b++) { if (count[b] == 0) { - node->child[b].node= NULL; + node->child[b].node = NULL; } else if (count[b] == 1) { /* face= &tree->face[offset[b]]; */ - node->child[b].face= offset[b]; - node->childflag |= (1<<b); + node->child[b].face = offset[b]; + node->childflag |= (1 << b); } else { if (tree->dothreadedbuild) BLI_lock_thread(LOCK_CUSTOM1); - child= BLI_memarena_alloc(tree->arena, sizeof(OccNode)); - node->child[b].node= child; + child = BLI_memarena_alloc(tree->arena, sizeof(OccNode)); + node->child[b].node = child; /* keep track of maximum depth for stack */ - if (depth+1 > tree->maxdepth) - tree->maxdepth= depth+1; + if (depth + 1 > tree->maxdepth) + tree->maxdepth = depth + 1; if (tree->dothreadedbuild) BLI_unlock_thread(LOCK_CUSTOM1); if (depth == 1 && tree->dothreadedbuild) { - othreads[totthread].tree= tree; - othreads[totthread].node= child; - othreads[totthread].begin= offset[b]; - othreads[totthread].end= offset[b]+count[b]; - othreads[totthread].depth= depth+1; + othreads[totthread].tree = tree; + othreads[totthread].node = child; + othreads[totthread].begin = offset[b]; + othreads[totthread].end = offset[b] + count[b]; + othreads[totthread].depth = depth + 1; BLI_insert_thread(&threads, &othreads[totthread]); totthread++; } else - occ_build_recursive(tree, child, offset[b], offset[b]+count[b], depth+1); + occ_build_recursive(tree, child, offset[b], offset[b] + count[b], depth + 1); } } @@ -591,13 +591,13 @@ static void occ_build_recursive(OcclusionTree *tree, OccNode *node, int begin, i } /* combine area, position and sh */ - for (b=0; b<TOTCHILD; b++) { - if (node->childflag & (1<<b)) { - child= &tmpnode; - occ_node_from_face(tree->face+node->child[b].face, &tmpnode); + for (b = 0; b < TOTCHILD; b++) { + if (node->childflag & (1 << b)) { + child = &tmpnode; + occ_node_from_face(tree->face + node->child[b].face, &tmpnode); } else { - child= node->child[b].node; + child = node->child[b].node; } if (child) { @@ -608,10 +608,10 @@ static void occ_build_recursive(OcclusionTree *tree, OccNode *node, int begin, i } if (node->area != 0.0f) - mul_v3_fl(node->co, 1.0f/node->area); + mul_v3_fl(node->co, 1.0f / node->area); /* compute maximum distance from center */ - node->dco= 0.0f; + node->dco = 0.0f; if (node->area > 0.0f) occ_build_dco(tree, node, node->co, &node->dco); } @@ -623,10 +623,10 @@ static void occ_build_sh_normalize(OccNode *node) int b; if (node->area != 0.0f) - sh_mul(node->sh, 1.0f/node->area); + sh_mul(node->sh, 1.0f / node->area); - for (b=0; b<TOTCHILD; b++) { - if (node->childflag & (1<<b)); + for (b = 0; b < TOTCHILD; b++) { + if (node->childflag & (1 << b)) ; else if (node->child[b].node) occ_build_sh_normalize(node->child[b].node); } @@ -638,18 +638,18 @@ static OcclusionTree *occ_tree_build(Render *re) ObjectInstanceRen *obi; ObjectRen *obr; Material *ma; - VlakRen *vlr= NULL; + VlakRen *vlr = NULL; int a, b, c, totface; /* count */ - totface= 0; - for (obi=re->instancetable.first; obi; obi=obi->next) { - obr= obi->obr; - for (a=0; a<obr->totvlak; a++) { - if ((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; + totface = 0; + for (obi = re->instancetable.first; obi; obi = obi->next) { + obr = obi->obr; + for (a = 0; a < obr->totvlak; a++) { + if ((a & 255) == 0) vlr = obr->vlaknodes[a >> 8].vlak; else vlr++; - ma= vlr->mat; + ma = vlr->mat; if ((ma->shade_flag & MA_APPROX_OCCLUSION) && (ma->material_type == MA_TYPE_SURFACE)) totface++; @@ -659,41 +659,41 @@ static OcclusionTree *occ_tree_build(Render *re) if (totface == 0) return NULL; - tree= MEM_callocN(sizeof(OcclusionTree), "OcclusionTree"); - tree->totface= totface; + tree = MEM_callocN(sizeof(OcclusionTree), "OcclusionTree"); + tree->totface = totface; /* parameters */ - tree->error= get_render_aosss_error(&re->r, re->wrld.ao_approx_error); - tree->distfac= (re->wrld.aomode & WO_AODIST)? re->wrld.aodistfac: 0.0f; - tree->doindirect= (re->wrld.ao_indirect_energy > 0.0f && re->wrld.ao_indirect_bounces > 0); + tree->error = get_render_aosss_error(&re->r, re->wrld.ao_approx_error); + tree->distfac = (re->wrld.aomode & WO_AODIST) ? re->wrld.aodistfac : 0.0f; + tree->doindirect = (re->wrld.ao_indirect_energy > 0.0f && re->wrld.ao_indirect_bounces > 0); /* allocation */ - tree->arena= BLI_memarena_new(0x8000 * sizeof(OccNode), "occ tree arena"); + tree->arena = BLI_memarena_new(0x8000 * sizeof(OccNode), "occ tree arena"); BLI_memarena_use_calloc(tree->arena); if (re->wrld.aomode & WO_AOCACHE) - tree->cache= MEM_callocN(sizeof(OcclusionCache)*BLENDER_MAX_THREADS, "OcclusionCache"); + tree->cache = MEM_callocN(sizeof(OcclusionCache) * BLENDER_MAX_THREADS, "OcclusionCache"); - tree->face= MEM_callocN(sizeof(OccFace)*totface, "OcclusionFace"); - tree->co= MEM_callocN(sizeof(float)*3*totface, "OcclusionCo"); - tree->occlusion= MEM_callocN(sizeof(float)*totface, "OcclusionOcclusion"); + tree->face = MEM_callocN(sizeof(OccFace) * totface, "OcclusionFace"); + tree->co = MEM_callocN(sizeof(float) * 3 * totface, "OcclusionCo"); + tree->occlusion = MEM_callocN(sizeof(float) * totface, "OcclusionOcclusion"); if (tree->doindirect) - tree->rad= MEM_callocN(sizeof(float)*3*totface, "OcclusionRad"); + tree->rad = MEM_callocN(sizeof(float) * 3 * totface, "OcclusionRad"); /* make array of face pointers */ - for (b=0, c=0, obi=re->instancetable.first; obi; obi=obi->next, c++) { - obr= obi->obr; - for (a=0; a<obr->totvlak; a++) { - if ((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; + for (b = 0, c = 0, obi = re->instancetable.first; obi; obi = obi->next, c++) { + obr = obi->obr; + for (a = 0; a < obr->totvlak; a++) { + if ((a & 255) == 0) vlr = obr->vlaknodes[a >> 8].vlak; else vlr++; - ma= vlr->mat; + ma = vlr->mat; if ((ma->shade_flag & MA_APPROX_OCCLUSION) && (ma->material_type == MA_TYPE_SURFACE)) { - tree->face[b].obi= c; - tree->face[b].facenr= a; - tree->occlusion[b]= 1.0f; + tree->face[b].obi = c; + tree->face[b].facenr = a; + tree->occlusion[b] = 1.0f; occ_face(&tree->face[b], tree->co[b], NULL, NULL); b++; } @@ -701,12 +701,12 @@ static OcclusionTree *occ_tree_build(Render *re) } /* threads */ - tree->totbuildthread= (re->r.threads > 1 && totface > 10000)? 8: 1; - tree->dothreadedbuild= (tree->totbuildthread > 1); + tree->totbuildthread = (re->r.threads > 1 && totface > 10000) ? 8 : 1; + tree->dothreadedbuild = (tree->totbuildthread > 1); /* recurse */ - tree->root= BLI_memarena_alloc(tree->arena, sizeof(OccNode)); - tree->maxdepth= 1; + tree->root = BLI_memarena_alloc(tree->arena, sizeof(OccNode)); + tree->maxdepth = 1; occ_build_recursive(tree, tree->root, 0, totface, 1); if (tree->doindirect) { @@ -715,12 +715,12 @@ static OcclusionTree *occ_tree_build(Render *re) } MEM_freeN(tree->co); - tree->co= NULL; + tree->co = NULL; occ_build_sh_normalize(tree->root); - for (a=0; a<BLENDER_MAX_THREADS; a++) - tree->stack[a]= MEM_callocN(sizeof(OccNode)*TOTCHILD*(tree->maxdepth+1), "OccStack"); + for (a = 0; a < BLENDER_MAX_THREADS; a++) + tree->stack[a] = MEM_callocN(sizeof(OccNode) * TOTCHILD * (tree->maxdepth + 1), "OccStack"); return tree; } @@ -731,7 +731,7 @@ static void occ_free_tree(OcclusionTree *tree) if (tree) { if (tree->arena) BLI_memarena_free(tree->arena); - for (a=0; a<BLENDER_MAX_THREADS; a++) + for (a = 0; a < BLENDER_MAX_THREADS; a++) if (tree->stack[a]) MEM_freeN(tree->stack[a]); if (tree->occlusion) MEM_freeN(tree->occlusion); @@ -749,36 +749,40 @@ static float occ_solid_angle(OccNode *node, const float v[3], float d2, float in float dotreceive, dotemit; float ev[3]; - ev[0]= -v[0]*invd2; - ev[1]= -v[1]*invd2; - ev[2]= -v[2]*invd2; - dotemit= sh_eval(node->sh, ev); - dotreceive= dot_v3v3(receivenormal, v)*invd2; + ev[0] = -v[0] * invd2; + ev[1] = -v[1] * invd2; + ev[2] = -v[2] * invd2; + dotemit = sh_eval(node->sh, ev); + dotreceive = dot_v3v3(receivenormal, v) * invd2; CLAMP(dotemit, 0.0f, 1.0f); CLAMP(dotreceive, 0.0f, 1.0f); - return ((node->area*dotemit*dotreceive)/(d2 + node->area*INVPI))*INVPI; + return ((node->area * dotemit * dotreceive) / (d2 + node->area * INVPI)) * INVPI; } -static void VecAddDir(float result[3], const float v1[3], const float v2[3], const float fac) +static void vec_add_dir(float r[3], const float v1[3], const float v2[3], const float fac) { - result[0]= v1[0] + fac*(v2[0] - v1[0]); - result[1]= v1[1] + fac*(v2[1] - v1[1]); - result[2]= v1[2] + fac*(v2[2] - v1[2]); + r[0] = v1[0] + fac * (v2[0] - v1[0]); + r[1] = v1[1] + fac * (v2[1] - v1[1]); + r[2] = v1[2] + fac * (v2[2] - v1[2]); } -static int occ_visible_quad(float *p, const float n[3], const float v0[3], const float *v1, const float *v2, float q0[3], float q1[3], float q2[3], float q3[3]) +/* TODO: exact duplicate of ff_visible_quad() in math_geom.c + * why not de-duplicate? (also above helper func) */ +static int occ_visible_quad(const float p[3], const float n[3], + const float v0[3], const float v1[3], const float v2[3], + float q0[3], float q1[3], float q2[3], float q3[3]) { static const float epsilon = 1e-6f; float c, sd[3]; - c= dot_v3v3(n, p); + c = dot_v3v3(n, p); /* signed distances from the vertices to the plane. */ - sd[0]= dot_v3v3(n, v0) - c; - sd[1]= dot_v3v3(n, v1) - c; - sd[2]= dot_v3v3(n, v2) - c; + sd[0] = dot_v3v3(n, v0) - c; + sd[1] = dot_v3v3(n, v1) - c; + sd[2] = dot_v3v3(n, v2) - c; if (fabsf(sd[0]) < epsilon) sd[0] = 0.0f; if (fabsf(sd[1]) < epsilon) sd[1] = 0.0f; @@ -787,21 +791,21 @@ static int occ_visible_quad(float *p, const float n[3], const float v0[3], const if (sd[0] > 0) { if (sd[1] > 0) { if (sd[2] > 0) { - // +++ + /* +++ */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // ++- + /* ++- */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); - VecAddDir(q2, v1, v2, (sd[1]/(sd[1]-sd[2]))); - VecAddDir(q3, v0, v2, (sd[0]/(sd[0]-sd[2]))); + vec_add_dir(q2, v1, v2, (sd[1] / (sd[1] - sd[2]))); + vec_add_dir(q3, v0, v2, (sd[0] / (sd[0] - sd[2]))); } else { - // ++0 + /* ++0 */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); @@ -810,44 +814,44 @@ static int occ_visible_quad(float *p, const float n[3], const float v0[3], const } else if (sd[1] < 0) { if (sd[2] > 0) { - // +-+ + /* +-+ */ copy_v3_v3(q0, v0); - VecAddDir(q1, v0, v1, (sd[0]/(sd[0]-sd[1]))); - VecAddDir(q2, v1, v2, (sd[1]/(sd[1]-sd[2]))); + vec_add_dir(q1, v0, v1, (sd[0] / (sd[0] - sd[1]))); + vec_add_dir(q2, v1, v2, (sd[1] / (sd[1] - sd[2]))); copy_v3_v3(q3, v2); } else if (sd[2] < 0) { - // +-- + /* +-- */ copy_v3_v3(q0, v0); - VecAddDir(q1, v0, v1, (sd[0]/(sd[0]-sd[1]))); - VecAddDir(q2, v0, v2, (sd[0]/(sd[0]-sd[2]))); + vec_add_dir(q1, v0, v1, (sd[0] / (sd[0] - sd[1]))); + vec_add_dir(q2, v0, v2, (sd[0] / (sd[0] - sd[2]))); copy_v3_v3(q3, q2); } else { - // +-0 + /* +-0 */ copy_v3_v3(q0, v0); - VecAddDir(q1, v0, v1, (sd[0]/(sd[0]-sd[1]))); + vec_add_dir(q1, v0, v1, (sd[0] / (sd[0] - sd[1]))); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } } else { if (sd[2] > 0) { - // +0+ + /* +0+ */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // +0- + /* +0- */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); - VecAddDir(q2, v0, v2, (sd[0]/(sd[0]-sd[2]))); + vec_add_dir(q2, v0, v2, (sd[0] / (sd[0] - sd[2]))); copy_v3_v3(q3, q2); } else { - // +00 + /* +00 */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); @@ -858,22 +862,22 @@ static int occ_visible_quad(float *p, const float n[3], const float v0[3], const else if (sd[0] < 0) { if (sd[1] > 0) { if (sd[2] > 0) { - // -++ - VecAddDir(q0, v0, v1, (sd[0]/(sd[0]-sd[1]))); + /* -++ */ + vec_add_dir(q0, v0, v1, (sd[0] / (sd[0] - sd[1]))); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); - VecAddDir(q3, v0, v2, (sd[0]/(sd[0]-sd[2]))); + vec_add_dir(q3, v0, v2, (sd[0] / (sd[0] - sd[2]))); } else if (sd[2] < 0) { - // -+- - VecAddDir(q0, v0, v1, (sd[0]/(sd[0]-sd[1]))); + /* -+- */ + vec_add_dir(q0, v0, v1, (sd[0] / (sd[0] - sd[1]))); copy_v3_v3(q1, v1); - VecAddDir(q2, v1, v2, (sd[1]/(sd[1]-sd[2]))); + vec_add_dir(q2, v1, v2, (sd[1] / (sd[1] - sd[2]))); copy_v3_v3(q3, q2); } else { - // -+0 - VecAddDir(q0, v0, v1, (sd[0]/(sd[0]-sd[1]))); + /* -+0 */ + vec_add_dir(q0, v0, v1, (sd[0] / (sd[0] - sd[1]))); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); @@ -881,35 +885,35 @@ static int occ_visible_quad(float *p, const float n[3], const float v0[3], const } else if (sd[1] < 0) { if (sd[2] > 0) { - // --+ - VecAddDir(q0, v0, v2, (sd[0]/(sd[0]-sd[2]))); - VecAddDir(q1, v1, v2, (sd[1]/(sd[1]-sd[2]))); + /* --+ */ + vec_add_dir(q0, v0, v2, (sd[0] / (sd[0] - sd[2]))); + vec_add_dir(q1, v1, v2, (sd[1] / (sd[1] - sd[2]))); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // --- + /* --- */ return 0; } else { - // --0 + /* --0 */ return 0; } } else { if (sd[2] > 0) { - // -0+ - VecAddDir(q0, v0, v2, (sd[0]/(sd[0]-sd[2]))); + /* -0+ */ + vec_add_dir(q0, v0, v2, (sd[0] / (sd[0] - sd[2]))); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // -0- + /* -0- */ return 0; } else { - // -00 + /* -00 */ return 0; } } @@ -917,21 +921,21 @@ static int occ_visible_quad(float *p, const float n[3], const float v0[3], const else { if (sd[1] > 0) { if (sd[2] > 0) { - // 0++ + /* 0++ */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // 0+- + /* 0+- */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); - VecAddDir(q2, v1, v2, (sd[1]/(sd[1]-sd[2]))); + vec_add_dir(q2, v1, v2, (sd[1] / (sd[1] - sd[2]))); copy_v3_v3(q3, q2); } else { - // 0+0 + /* 0+0 */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); @@ -940,35 +944,35 @@ static int occ_visible_quad(float *p, const float n[3], const float v0[3], const } else if (sd[1] < 0) { if (sd[2] > 0) { - // 0-+ + /* 0-+ */ copy_v3_v3(q0, v0); - VecAddDir(q1, v1, v2, (sd[1]/(sd[1]-sd[2]))); + vec_add_dir(q1, v1, v2, (sd[1] / (sd[1] - sd[2]))); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // 0-- + /* 0-- */ return 0; } else { - // 0-0 + /* 0-0 */ return 0; } } else { if (sd[2] > 0) { - // 00+ + /* 00+ */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // 00- + /* 00- */ return 0; } else { - // 000 + /* 000 */ return 0; } } @@ -995,49 +999,49 @@ static vFloat vec_splat_float(float val) static float occ_quad_form_factor(float *p, float *n, float *q0, float *q1, float *q2, float *q3) { vFloat vcos, rlen, vrx, vry, vrz, vsrx, vsry, vsrz, gx, gy, gz, vangle; - vUInt8 rotate = (vUInt8) {4,5,6,7,8,9,10,11,12,13,14,15,0,1,2,3}; + vUInt8 rotate = (vUInt8) {4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3}; vFloatResult vresult; float result; /* compute r* */ - vrx = (vFloat) {q0[0], q1[0], q2[0], q3[0]} - vec_splat_float(p[0]); - vry = (vFloat) {q0[1], q1[1], q2[1], q3[1]} - vec_splat_float(p[1]); - vrz = (vFloat) {q0[2], q1[2], q2[2], q3[2]} - vec_splat_float(p[2]); + vrx = (vFloat) {q0[0], q1[0], q2[0], q3[0]} -vec_splat_float(p[0]); + vry = (vFloat) {q0[1], q1[1], q2[1], q3[1]} -vec_splat_float(p[1]); + vrz = (vFloat) {q0[2], q1[2], q2[2], q3[2]} -vec_splat_float(p[2]); /* normalize r* */ - rlen = vec_rsqrte(vrx*vrx + vry*vry + vrz*vrz + vec_splat_float(1e-16f)); - vrx = vrx*rlen; - vry = vry*rlen; - vrz = vrz*rlen; + rlen = vec_rsqrte(vrx * vrx + vry * vry + vrz * vrz + vec_splat_float(1e-16f)); + vrx = vrx * rlen; + vry = vry * rlen; + vrz = vrz * rlen; /* rotate r* for cross and dot */ - vsrx= vec_perm(vrx, vrx, rotate); - vsry= vec_perm(vry, vry, rotate); - vsrz= vec_perm(vrz, vrz, rotate); + vsrx = vec_perm(vrx, vrx, rotate); + vsry = vec_perm(vry, vry, rotate); + vsrz = vec_perm(vrz, vrz, rotate); /* cross product */ - gx = vsry*vrz - vsrz*vry; - gy = vsrz*vrx - vsrx*vrz; - gz = vsrx*vry - vsry*vrx; + gx = vsry * vrz - vsrz * vry; + gy = vsrz * vrx - vsrx * vrz; + gz = vsrx * vry - vsry * vrx; /* normalize */ - rlen = vec_rsqrte(gx*gx + gy*gy + gz*gz + vec_splat_float(1e-16f)); - gx = gx*rlen; - gy = gy*rlen; - gz = gz*rlen; + rlen = vec_rsqrte(gx * gx + gy * gy + gz * gz + vec_splat_float(1e-16f)); + gx = gx * rlen; + gy = gy * rlen; + gz = gz * rlen; /* angle */ - vcos = vrx*vsrx + vry*vsry + vrz*vsrz; - vcos= vec_max(vec_min(vcos, vec_splat_float(1.0f)), vec_splat_float(-1.0f)); - vangle= vacosf(vcos); + vcos = vrx * vsrx + vry * vsry + vrz * vsrz; + vcos = vec_max(vec_min(vcos, vec_splat_float(1.0f)), vec_splat_float(-1.0f)); + vangle = vacosf(vcos); /* dot */ - vresult.v = (vec_splat_float(n[0])*gx + - vec_splat_float(n[1])*gy + - vec_splat_float(n[2])*gz)*vangle; + vresult.v = (vec_splat_float(n[0]) * gx + + vec_splat_float(n[1]) * gy + + vec_splat_float(n[2]) * gz) * vangle; - result= (vresult.f[0] + vresult.f[1] + vresult.f[2] + vresult.f[3])*(0.5f/(float)M_PI); - result= MAX2(result, 0.0f); + result = (vresult.f[0] + vresult.f[1] + vresult.f[2] + vresult.f[3]) * (0.5f / (float)M_PI); + result = MAX2(result, 0.0f); return result; } @@ -1053,8 +1057,8 @@ static float occ_quad_form_factor(float *p, float *n, float *q0, float *q1, floa static __m128 sse_approx_acos(__m128 x) { /* needs a better approximation than taylor expansion of acos, since that - * gives big erros for near 1.0 values, sqrt(2*x)*acos(1-x) should work - * better, see http://www.tom.womack.net/projects/sse-fast-arctrig.html */ + * gives big erros for near 1.0 values, sqrt(2*x)*acos(1-x) should work + * better, see http://www.tom.womack.net/projects/sse-fast-arctrig.html */ return _mm_set_ps1(1.0f); } @@ -1076,36 +1080,36 @@ static float occ_quad_form_factor(float *p, float *n, float *q0, float *q1, floa rz = qz - _mm_set_ps1(p[2]); /* normalize r */ - rlen = _mm_rsqrt_ps(rx*rx + ry*ry + rz*rz + _mm_set_ps1(1e-16f)); - rx = rx*rlen; - ry = ry*rlen; - rz = rz*rlen; + rlen = _mm_rsqrt_ps(rx * rx + ry * ry + rz * rz + _mm_set_ps1(1e-16f)); + rx = rx * rlen; + ry = ry * rlen; + rz = rz * rlen; /* cross product */ - srx = _mm_shuffle_ps(rx, rx, _MM_SHUFFLE(0,3,2,1)); - sry = _mm_shuffle_ps(ry, ry, _MM_SHUFFLE(0,3,2,1)); - srz = _mm_shuffle_ps(rz, rz, _MM_SHUFFLE(0,3,2,1)); + srx = _mm_shuffle_ps(rx, rx, _MM_SHUFFLE(0, 3, 2, 1)); + sry = _mm_shuffle_ps(ry, ry, _MM_SHUFFLE(0, 3, 2, 1)); + srz = _mm_shuffle_ps(rz, rz, _MM_SHUFFLE(0, 3, 2, 1)); - gx = sry*rz - srz*ry; - gy = srz*rx - srx*rz; - gz = srx*ry - sry*rx; + gx = sry * rz - srz * ry; + gy = srz * rx - srx * rz; + gz = srx * ry - sry * rx; /* normalize g */ - glen = _mm_rsqrt_ps(gx*gx + gy*gy + gz*gz + _mm_set_ps1(1e-16f)); - gx = gx*glen; - gy = gy*glen; - gz = gz*glen; + glen = _mm_rsqrt_ps(gx * gx + gy * gy + gz * gz + _mm_set_ps1(1e-16f)); + gx = gx * glen; + gy = gy * glen; + gz = gz * glen; /* compute angle */ - rcos = rx*srx + ry*sry + rz*srz; - rcos= _mm_max_ps(_mm_min_ps(rcos, _mm_set_ps1(1.0f)), _mm_set_ps1(-1.0f)); + rcos = rx * srx + ry * sry + rz * srz; + rcos = _mm_max_ps(_mm_min_ps(rcos, _mm_set_ps1(1.0f)), _mm_set_ps1(-1.0f)); angle = sse_approx_cos(rcos); - aresult = (_mm_set_ps1(n[0])*gx + _mm_set_ps1(n[1])*gy + _mm_set_ps1(n[2])*gz)*angle; + aresult = (_mm_set_ps1(n[0]) * gx + _mm_set_ps1(n[1]) * gy + _mm_set_ps1(n[2]) * gz) * angle; /* sum together */ - result= (fresult[0] + fresult[1] + fresult[2] + fresult[3])*(0.5f/(float)M_PI); - result= MAX2(result, 0.0f); + result = (fresult[0] + fresult[1] + fresult[2] + fresult[3]) * (0.5f / (float)M_PI); + result = MAX2(result, 0.0f); return result; } @@ -1116,10 +1120,10 @@ static void normalizef(float *n) { float d; - d= dot_v3v3(n, n); + d = dot_v3v3(n, n); if (d > 1.0e-35F) { - d= 1.0f/sqrtf(d); + d = 1.0f / sqrtf(d); n[0] *= d; n[1] *= d; @@ -1127,6 +1131,8 @@ static void normalizef(float *n) } } +/* TODO: exact duplicate of ff_quad_form_factor() in math_geom.c + * why not de-duplicate? (also above helper func) */ static float occ_quad_form_factor(const float p[3], const float n[3], const float q0[3], const float q1[3], const float q2[3], const float q3[3]) { float r0[3], r1[3], r2[3], r3[3], g0[3], g1[3], g2[3], g3[3]; @@ -1147,18 +1153,18 @@ static float occ_quad_form_factor(const float p[3], const float n[3], const floa cross_v3_v3v3(g2, r3, r2); normalizef(g2); cross_v3_v3v3(g3, r0, r3); normalizef(g3); - a1= saacosf(dot_v3v3(r0, r1)); - a2= saacosf(dot_v3v3(r1, r2)); - a3= saacosf(dot_v3v3(r2, r3)); - a4= saacosf(dot_v3v3(r3, r0)); + a1 = saacosf(dot_v3v3(r0, r1)); + a2 = saacosf(dot_v3v3(r1, r2)); + a3 = saacosf(dot_v3v3(r2, r3)); + a4 = saacosf(dot_v3v3(r3, r0)); - dot1= dot_v3v3(n, g0); - dot2= dot_v3v3(n, g1); - dot3= dot_v3v3(n, g2); - dot4= dot_v3v3(n, g3); + dot1 = dot_v3v3(n, g0); + dot2 = dot_v3v3(n, g1); + dot3 = dot_v3v3(n, g2); + dot4 = dot_v3v3(n, g3); - result= (a1*dot1 + a2*dot2 + a3*dot3 + a4*dot4)*0.5f/(float)M_PI; - result= MAX2(result, 0.0f); + result = (a1 * dot1 + a2 * dot2 + a3 * dot3 + a4 * dot4) * 0.5f / (float)M_PI; + result = MAX2(result, 0.0f); return result; } @@ -1167,10 +1173,10 @@ static float occ_form_factor(OccFace *face, float *p, float *n) { ObjectInstanceRen *obi; VlakRen *vlr; - float v1[3], v2[3], v3[3], v4[3], q0[3], q1[3], q2[3], q3[3], contrib= 0.0f; + float v1[3], v2[3], v3[3], v4[3], q0[3], q1[3], q2[3], q3[3], contrib = 0.0f; - obi= &R.objectinstance[face->obi]; - vlr= RE_findOrAddVlak(obi->obr, face->facenr); + obi = &R.objectinstance[face->obi]; + vlr = RE_findOrAddVlak(obi->obr, face->facenr); copy_v3_v3(v1, vlr->v1->co); copy_v3_v3(v2, vlr->v2->co); @@ -1214,103 +1220,103 @@ static void occ_lookup(OcclusionTree *tree, int thread, OccFace *exclude, if (bentn) copy_v3_v3(bentn, n); - error= tree->error; - distfac= tree->distfac; + error = tree->error; + distfac = tree->distfac; - resultocc= 0.0f; + resultocc = 0.0f; zero_v3(resultrad); /* init stack */ - stack= tree->stack[thread]; - stack[0]= tree->root; - totstack= 1; + stack = tree->stack[thread]; + stack[0] = tree->root; + totstack = 1; while (totstack) { /* pop point off the stack */ - node= stack[--totstack]; + node = stack[--totstack]; sub_v3_v3v3(v, node->co, p); - d2= dot_v3v3(v, v) + 1e-16f; - emitarea= MAX2(node->area, node->dco); + d2 = dot_v3v3(v, v) + 1e-16f; + emitarea = MAX2(node->area, node->dco); - if (d2*error > emitarea) { + if (d2 * error > emitarea) { if (distfac != 0.0f) { - fac= 1.0f/(1.0f + distfac*d2); + fac = 1.0f / (1.0f + distfac * d2); if (fac < 0.01f) continue; } else - fac= 1.0f; + fac = 1.0f; /* accumulate occlusion from spherical harmonics */ - invd2 = 1.0f/sqrtf(d2); - weight= occ_solid_angle(node, v, d2, invd2, n); + invd2 = 1.0f / sqrtf(d2); + weight = occ_solid_angle(node, v, d2, invd2, n); if (rad) - madd_v3_v3fl(resultrad, node->rad, weight*fac); + madd_v3_v3fl(resultrad, node->rad, weight * fac); weight *= node->occlusion; if (bentn) { - bentn[0] -= weight*invd2*v[0]; - bentn[1] -= weight*invd2*v[1]; - bentn[2] -= weight*invd2*v[2]; + bentn[0] -= weight * invd2 * v[0]; + bentn[1] -= weight * invd2 * v[1]; + bentn[2] -= weight * invd2 * v[2]; } - resultocc += weight*fac; + resultocc += weight * fac; } else { /* traverse into children */ - for (b=0; b<TOTCHILD; b++) { - if (node->childflag & (1<<b)) { - f= node->child[b].face; - face= &tree->face[f]; + for (b = 0; b < TOTCHILD; b++) { + if (node->childflag & (1 << b)) { + f = node->child[b].face; + face = &tree->face[f]; /* accumulate occlusion with face form factor */ if (!exclude || !(face->obi == exclude->obi && face->facenr == exclude->facenr)) { if (bentn || distfac != 0.0f) { occ_face(face, co, NULL, NULL); sub_v3_v3v3(v, co, p); - d2= dot_v3v3(v, v) + 1e-16f; + d2 = dot_v3v3(v, v) + 1e-16f; - fac= (distfac == 0.0f)? 1.0f: 1.0f/(1.0f + distfac*d2); + fac = (distfac == 0.0f) ? 1.0f : 1.0f / (1.0f + distfac * d2); if (fac < 0.01f) continue; } else - fac= 1.0f; + fac = 1.0f; - weight= occ_form_factor(face, p, n); + weight = occ_form_factor(face, p, n); if (rad) - madd_v3_v3fl(resultrad, tree->rad[f], weight*fac); + madd_v3_v3fl(resultrad, tree->rad[f], weight * fac); weight *= tree->occlusion[f]; if (bentn) { - invd2= 1.0f/sqrtf(d2); - bentn[0] -= weight*invd2*v[0]; - bentn[1] -= weight*invd2*v[1]; - bentn[2] -= weight*invd2*v[2]; + invd2 = 1.0f / sqrtf(d2); + bentn[0] -= weight * invd2 * v[0]; + bentn[1] -= weight * invd2 * v[1]; + bentn[2] -= weight * invd2 * v[2]; } - resultocc += weight*fac; + resultocc += weight * fac; } } else if (node->child[b].node) { /* push child on the stack */ - stack[totstack++]= node->child[b].node; + stack[totstack++] = node->child[b].node; } } } } - if (occ) *occ= resultocc; + if (occ) *occ = resultocc; if (rad) copy_v3_v3(rad, resultrad); #if 0 if (rad && exclude) { int a; - for (a=0; a<tree->totface; a++) + for (a = 0; a < tree->totface; a++) if ((tree->face[a].obi == exclude->obi && tree->face[a].facenr == exclude->facenr)) copy_v3_v3(rad, tree->rad[a]); } @@ -1323,18 +1329,18 @@ static void occ_compute_bounces(Render *re, OcclusionTree *tree, int totbounce) float (*rad)[3], (*sum)[3], (*tmp)[3], co[3], n[3], occ; int bounce, i; - rad= MEM_callocN(sizeof(float)*3*tree->totface, "OcclusionBounceRad"); - sum= MEM_dupallocN(tree->rad); + rad = MEM_callocN(sizeof(float) * 3 * tree->totface, "OcclusionBounceRad"); + sum = MEM_dupallocN(tree->rad); - for (bounce=1; bounce<totbounce; bounce++) { - for (i=0; i<tree->totface; i++) { + for (bounce = 1; bounce < totbounce; bounce++) { + for (i = 0; i < tree->totface; i++) { occ_face(&tree->face[i], co, n, NULL); madd_v3_v3fl(co, n, 1e-8f); occ_lookup(tree, 0, &tree->face[i], co, n, &occ, rad[i], NULL); - rad[i][0]= MAX2(rad[i][0], 0.0f); - rad[i][1]= MAX2(rad[i][1], 0.0f); - rad[i][2]= MAX2(rad[i][2], 0.0f); + rad[i][0] = MAX2(rad[i][0], 0.0f); + rad[i][1] = MAX2(rad[i][1], 0.0f); + rad[i][2] = MAX2(rad[i][2], 0.0f); add_v3_v3(sum[i], rad[i]); if (re->test_break(re->tbh)) @@ -1344,16 +1350,16 @@ static void occ_compute_bounces(Render *re, OcclusionTree *tree, int totbounce) if (re->test_break(re->tbh)) break; - tmp= tree->rad; - tree->rad= rad; - rad= tmp; + tmp = tree->rad; + tree->rad = rad; + rad = tmp; occ_sum_occlusion(tree, tree->root); } MEM_freeN(rad); MEM_freeN(tree->rad); - tree->rad= sum; + tree->rad = sum; if (!re->test_break(re->tbh)) occ_sum_occlusion(tree, tree->root); @@ -1364,10 +1370,10 @@ static void occ_compute_passes(Render *re, OcclusionTree *tree, int totpass) float *occ, co[3], n[3]; int pass, i; - occ= MEM_callocN(sizeof(float)*tree->totface, "OcclusionPassOcc"); + occ = MEM_callocN(sizeof(float) * tree->totface, "OcclusionPassOcc"); - for (pass=0; pass<totpass; pass++) { - for (i=0; i<tree->totface; i++) { + for (pass = 0; pass < totpass; pass++) { + for (i = 0; i < tree->totface; i++) { occ_face(&tree->face[i], co, n, NULL); negate_v3(n); madd_v3_v3fl(co, n, 1e-8f); @@ -1380,10 +1386,10 @@ static void occ_compute_passes(Render *re, OcclusionTree *tree, int totpass) if (re->test_break(re->tbh)) break; - for (i=0; i<tree->totface; i++) { + for (i = 0; i < tree->totface; i++) { tree->occlusion[i] -= occ[i]; //MAX2(1.0f-occ[i], 0.0f); if (tree->occlusion[i] < 0.0f) - tree->occlusion[i]= 0.0f; + tree->occlusion[i] = 0.0f; } occ_sum_occlusion(tree, tree->root); @@ -1399,25 +1405,25 @@ static void sample_occ_tree(Render *re, OcclusionTree *tree, OccFace *exclude, float nn[3], bn[3], fac, occ, occlusion, correction, rad[3]; int envcolor; - envcolor= re->wrld.aocolor; + envcolor = re->wrld.aocolor; if (onlyshadow) - envcolor= WO_AOPLAIN; + envcolor = WO_AOPLAIN; negate_v3_v3(nn, n); - occ_lookup(tree, thread, exclude, co, nn, &occ, (tree->doindirect)? rad: NULL, (env && envcolor)? bn: NULL); + occ_lookup(tree, thread, exclude, co, nn, &occ, (tree->doindirect) ? rad : NULL, (env && envcolor) ? bn : NULL); - correction= re->wrld.ao_approx_correction; + correction = re->wrld.ao_approx_correction; - occlusion= (1.0f-correction)*(1.0f-occ); + occlusion = (1.0f - correction) * (1.0f - occ); CLAMP(occlusion, 0.0f, 1.0f); if (correction != 0.0f) - occlusion += correction*expf(-occ); + occlusion += correction * expf(-occ); if (env) { /* sky shading using bent normal */ if (ELEM(envcolor, WO_AOSKYCOL, WO_AOSKYTEX)) { - fac= 0.5f * (1.0f + dot_v3v3(bn, re->grvec)); + fac = 0.5f * (1.0f + dot_v3v3(bn, re->grvec)); env[0] = (1.0f - fac) * re->wrld.horr + fac * re->wrld.zenr; env[1] = (1.0f - fac) * re->wrld.horg + fac * re->wrld.zeng; env[2] = (1.0f - fac) * re->wrld.horb + fac * re->wrld.zenb; @@ -1425,28 +1431,28 @@ static void sample_occ_tree(Render *re, OcclusionTree *tree, OccFace *exclude, mul_v3_fl(env, occlusion); } else { - env[0]= occlusion; - env[1]= occlusion; - env[2]= occlusion; + env[0] = occlusion; + env[1] = occlusion; + env[2] = occlusion; } #if 0 - else { /* WO_AOSKYTEX */ + else { /* WO_AOSKYTEX */ float dxyview[3]; - bn[0]= -bn[0]; - bn[1]= -bn[1]; - bn[2]= -bn[2]; - dxyview[0]= 1.0f; - dxyview[1]= 1.0f; - dxyview[2]= 0.0f; + bn[0] = -bn[0]; + bn[1] = -bn[1]; + bn[2] = -bn[2]; + dxyview[0] = 1.0f; + dxyview[1] = 1.0f; + dxyview[2] = 0.0f; shadeSkyView(ao, co, bn, dxyview); } #endif } if (ao) { - ao[0]= occlusion; - ao[1]= occlusion; - ao[2]= occlusion; + ao[0] = occlusion; + ao[1] = occlusion; + ao[2] = occlusion; } if (tree->doindirect) copy_v3_v3(indirect, rad); @@ -1468,7 +1474,7 @@ static OcclusionCacheSample *find_occ_sample(OcclusionCache *cache, int x, int y if (x < 0 || x >= cache->w || y < 0 || y >= cache->h) return NULL; else - return &cache->sample[y*cache->w + x]; + return &cache->sample[y * cache->w + x]; } static int sample_occ_cache(OcclusionTree *tree, float *co, float *n, int x, int y, int thread, float *ao, float *env, float *indirect) @@ -1483,14 +1489,14 @@ static int sample_occ_cache(OcclusionTree *tree, float *co, float *n, int x, int return 0; /* first try to find a sample in the same pixel */ - cache= &tree->cache[thread]; + cache = &tree->cache[thread]; if (cache->sample && cache->step) { - sample= &cache->sample[(y-cache->y)*cache->w + (x-cache->x)]; + sample = &cache->sample[(y - cache->y) * cache->w + (x - cache->x)]; if (sample->filled) { sub_v3_v3v3(d, sample->co, co); - dist2= dot_v3v3(d, d); - if (dist2 < 0.5f*sample->dist2 && dot_v3v3(sample->n, n) > 0.98f) { + dist2 = dot_v3v3(d, d); + if (dist2 < 0.5f * sample->dist2 && dot_v3v3(sample->n, n) > 0.98f) { copy_v3_v3(ao, sample->ao); copy_v3_v3(env, sample->env); copy_v3_v3(indirect, sample->indirect); @@ -1502,18 +1508,18 @@ static int sample_occ_cache(OcclusionTree *tree, float *co, float *n, int x, int return 0; /* try to interpolate between 4 neighboring pixels */ - samples[0]= find_occ_sample(cache, x, y); - samples[1]= find_occ_sample(cache, x+cache->step, y); - samples[2]= find_occ_sample(cache, x, y+cache->step); - samples[3]= find_occ_sample(cache, x+cache->step, y+cache->step); + samples[0] = find_occ_sample(cache, x, y); + samples[1] = find_occ_sample(cache, x + cache->step, y); + samples[2] = find_occ_sample(cache, x, y + cache->step); + samples[3] = find_occ_sample(cache, x + cache->step, y + cache->step); - for (i=0; i<4; i++) + for (i = 0; i < 4; i++) if (!samples[i] || !samples[i]->filled) return 0; /* require intensities not being too different */ - mino= MIN4(samples[0]->intensity, samples[1]->intensity, samples[2]->intensity, samples[3]->intensity); - maxo= MAX4(samples[0]->intensity, samples[1]->intensity, samples[2]->intensity, samples[3]->intensity); + mino = MIN4(samples[0]->intensity, samples[1]->intensity, samples[2]->intensity, samples[3]->intensity); + maxo = MAX4(samples[0]->intensity, samples[1]->intensity, samples[2]->intensity, samples[3]->intensity); if (maxo - mino > 0.05f) return 0; @@ -1522,29 +1528,29 @@ static int sample_occ_cache(OcclusionTree *tree, float *co, float *n, int x, int zero_v3(ao); zero_v3(env); zero_v3(indirect); - totw= 0.0f; + totw = 0.0f; - x1= samples[0]->x; - y1= samples[0]->y; - x2= samples[3]->x; - y2= samples[3]->y; + x1 = samples[0]->x; + y1 = samples[0]->y; + x2 = samples[3]->x; + y2 = samples[3]->y; - tx= (float)(x2 - x)/(float)(x2 - x1); - ty= (float)(y2 - y)/(float)(y2 - y1); + tx = (float)(x2 - x) / (float)(x2 - x1); + ty = (float)(y2 - y) / (float)(y2 - y1); - wb[3]= (1.0f-tx)*(1.0f-ty); - wb[2]= (tx)*(1.0f-ty); - wb[1]= (1.0f-tx)*(ty); - wb[0]= tx*ty; + wb[3] = (1.0f - tx) * (1.0f - ty); + wb[2] = (tx) * (1.0f - ty); + wb[1] = (1.0f - tx) * (ty); + wb[0] = tx * ty; - for (i=0; i<4; i++) { + for (i = 0; i < 4; i++) { sub_v3_v3v3(d, samples[i]->co, co); //dist2= dot_v3v3(d, d); - wz[i]= 1.0f; //(samples[i]->dist2/(1e-4f + dist2)); - wn[i]= pow(dot_v3v3(samples[i]->n, n), 32.0f); + wz[i] = 1.0f; //(samples[i]->dist2/(1e-4f + dist2)); + wn[i] = pow(dot_v3v3(samples[i]->n, n), 32.0f); - w= wb[i]*wn[i]*wz[i]; + w = wb[i] * wn[i] * wz[i]; totw += w; madd_v3_v3fl(ao, samples[i]->ao, w); @@ -1553,7 +1559,7 @@ static int sample_occ_cache(OcclusionTree *tree, float *co, float *n, int x, int } if (totw >= 0.9f) { - totw= 1.0f/totw; + totw = 1.0f / totw; mul_v3_fl(ao, totw); mul_v3_fl(env, totw); mul_v3_fl(indirect, totw); @@ -1565,18 +1571,18 @@ static int sample_occ_cache(OcclusionTree *tree, float *co, float *n, int x, int static void sample_occ_surface(ShadeInput *shi) { - StrandRen *strand= shi->strand; - StrandSurface *mesh= strand->buffer->surface; + StrandRen *strand = shi->strand; + StrandSurface *mesh = strand->buffer->surface; int *face, *index = RE_strandren_get_face(shi->obr, strand, 0); float w[4], *co1, *co2, *co3, *co4; if (mesh && mesh->face && mesh->co && mesh->ao && index) { - face= mesh->face[*index]; + face = mesh->face[*index]; - co1= mesh->co[face[0]]; - co2= mesh->co[face[1]]; - co3= mesh->co[face[2]]; - co4= (face[3])? mesh->co[face[3]]: NULL; + co1 = mesh->co[face[0]]; + co2 = mesh->co[face[1]]; + co3 = mesh->co[face[2]]; + co4 = (face[3]) ? mesh->co[face[3]] : NULL; interp_weights_face_v3(w, co1, co2, co3, co4, strand->vert->co); @@ -1600,9 +1606,9 @@ static void sample_occ_surface(ShadeInput *shi) } } else { - shi->ao[0]= 1.0f; - shi->ao[1]= 1.0f; - shi->ao[2]= 1.0f; + shi->ao[0] = 1.0f; + shi->ao[1] = 1.0f; + shi->ao[2] = 1.0f; zero_v3(shi->env); zero_v3(shi->indirect); } @@ -1612,20 +1618,20 @@ static void sample_occ_surface(ShadeInput *shi) static void *exec_strandsurface_sample(void *data) { - OcclusionThread *othread= (OcclusionThread*)data; - Render *re= othread->re; - StrandSurface *mesh= othread->mesh; + OcclusionThread *othread = (OcclusionThread *)data; + Render *re = othread->re; + StrandSurface *mesh = othread->mesh; float ao[3], env[3], indirect[3], co[3], n[3], *co1, *co2, *co3, *co4; int a, *face; - for (a=othread->begin; a<othread->end; a++) { - face= mesh->face[a]; - co1= mesh->co[face[0]]; - co2= mesh->co[face[1]]; - co3= mesh->co[face[2]]; + for (a = othread->begin; a < othread->end; a++) { + face = mesh->face[a]; + co1 = mesh->co[face[0]]; + co2 = mesh->co[face[1]]; + co3 = mesh->co[face[2]]; if (face[3]) { - co4= mesh->co[face[3]]; + co4 = mesh->co[face[3]]; mid_v3_v3v3(co, co1, co3); normal_quad_v3(n, co1, co2, co3, co4); @@ -1655,12 +1661,12 @@ void make_occ_tree(Render *re) int a, totface, totthread, *face, *count; /* ugly, needed for occ_face */ - R= *re; + R = *re; - re->i.infostr= "Occlusion preprocessing"; + re->i.infostr = "Occlusion preprocessing"; re->stats_draw(re->sdh, &re->i); - re->occlusiontree= tree= occ_tree_build(re); + re->occlusiontree = tree = occ_tree_build(re); if (tree) { if (re->wrld.ao_approx_passes > 0) @@ -1668,26 +1674,26 @@ void make_occ_tree(Render *re) if (tree->doindirect && (re->wrld.mode & WO_INDIRECT_LIGHT)) occ_compute_bounces(re, tree, re->wrld.ao_indirect_bounces); - for (mesh=re->strandsurface.first; mesh; mesh=mesh->next) { + for (mesh = re->strandsurface.first; mesh; mesh = mesh->next) { if (!mesh->face || !mesh->co || !mesh->ao) continue; - count= MEM_callocN(sizeof(int)*mesh->totvert, "OcclusionCount"); - faceao= MEM_callocN(sizeof(float)*3*mesh->totface, "StrandSurfFaceAO"); - faceenv= MEM_callocN(sizeof(float)*3*mesh->totface, "StrandSurfFaceEnv"); - faceindirect= MEM_callocN(sizeof(float)*3*mesh->totface, "StrandSurfFaceIndirect"); - - totthread= (mesh->totface > 10000)? re->r.threads: 1; - totface= mesh->totface/totthread; - for (a=0; a<totthread; a++) { - othreads[a].re= re; - othreads[a].faceao= faceao; - othreads[a].faceenv= faceenv; - othreads[a].faceindirect= faceindirect; - othreads[a].thread= a; - othreads[a].mesh= mesh; - othreads[a].begin= a*totface; - othreads[a].end= (a == totthread-1)? mesh->totface: (a+1)*totface; + count = MEM_callocN(sizeof(int) * mesh->totvert, "OcclusionCount"); + faceao = MEM_callocN(sizeof(float) * 3 * mesh->totface, "StrandSurfFaceAO"); + faceenv = MEM_callocN(sizeof(float) * 3 * mesh->totface, "StrandSurfFaceEnv"); + faceindirect = MEM_callocN(sizeof(float) * 3 * mesh->totface, "StrandSurfFaceIndirect"); + + totthread = (mesh->totface > 10000) ? re->r.threads : 1; + totface = mesh->totface / totthread; + for (a = 0; a < totthread; a++) { + othreads[a].re = re; + othreads[a].faceao = faceao; + othreads[a].faceenv = faceenv; + othreads[a].faceindirect = faceindirect; + othreads[a].thread = a; + othreads[a].mesh = mesh; + othreads[a].begin = a * totface; + othreads[a].end = (a == totthread - 1) ? mesh->totface : (a + 1) * totface; } if (totthread == 1) { @@ -1696,14 +1702,14 @@ void make_occ_tree(Render *re) else { BLI_init_threads(&threads, exec_strandsurface_sample, totthread); - for (a=0; a<totthread; a++) + for (a = 0; a < totthread; a++) BLI_insert_thread(&threads, &othreads[a]); BLI_end_threads(&threads); } - for (a=0; a<mesh->totface; a++) { - face= mesh->face[a]; + for (a = 0; a < mesh->totface; a++) { + face = mesh->face[a]; copy_v3_v3(ao, faceao[a]); copy_v3_v3(env, faceenv[a]); @@ -1730,11 +1736,11 @@ void make_occ_tree(Render *re) } } - for (a=0; a<mesh->totvert; a++) { + for (a = 0; a < mesh->totvert; a++) { if (count[a]) { - mul_v3_fl(mesh->ao[a], 1.0f/count[a]); - mul_v3_fl(mesh->env[a], 1.0f/count[a]); - mul_v3_fl(mesh->indirect[a], 1.0f/count[a]); + mul_v3_fl(mesh->ao[a], 1.0f / count[a]); + mul_v3_fl(mesh->env[a], 1.0f / count[a]); + mul_v3_fl(mesh->indirect[a], 1.0f / count[a]); } } @@ -1756,7 +1762,7 @@ void free_occ(Render *re) void sample_occ(Render *re, ShadeInput *shi) { - OcclusionTree *tree= re->occlusiontree; + OcclusionTree *tree = re->occlusiontree; OcclusionCache *cache; OcclusionCacheSample *sample; OccFace exclude; @@ -1767,91 +1773,91 @@ void sample_occ(Render *re, ShadeInput *shi) sample_occ_surface(shi); } /* try to get result from the cache if possible */ - else if (shi->depth!=0 || !sample_occ_cache(tree, shi->co, shi->vno, shi->xs, shi->ys, shi->thread, shi->ao, shi->env, shi->indirect)) { + else if (shi->depth != 0 || !sample_occ_cache(tree, shi->co, shi->vno, shi->xs, shi->ys, shi->thread, shi->ao, shi->env, shi->indirect)) { /* no luck, let's sample the occlusion */ - exclude.obi= shi->obi - re->objectinstance; - exclude.facenr= shi->vlr->index; - onlyshadow= (shi->mat->mode & MA_ONLYSHADOW); + exclude.obi = shi->obi - re->objectinstance; + exclude.facenr = shi->vlr->index; + onlyshadow = (shi->mat->mode & MA_ONLYSHADOW); sample_occ_tree(re, tree, &exclude, shi->co, shi->vno, shi->thread, onlyshadow, shi->ao, shi->env, shi->indirect); /* fill result into sample, each time */ if (tree->cache) { - cache= &tree->cache[shi->thread]; + cache = &tree->cache[shi->thread]; if (cache->sample && cache->step) { - sample= &cache->sample[(shi->ys-cache->y)*cache->w + (shi->xs-cache->x)]; + sample = &cache->sample[(shi->ys - cache->y) * cache->w + (shi->xs - cache->x)]; copy_v3_v3(sample->co, shi->co); copy_v3_v3(sample->n, shi->vno); copy_v3_v3(sample->ao, shi->ao); copy_v3_v3(sample->env, shi->env); copy_v3_v3(sample->indirect, shi->indirect); - sample->intensity= MAX3(sample->ao[0], sample->ao[1], sample->ao[2]); - sample->intensity= MAX2(sample->intensity, MAX3(sample->env[0], sample->env[1], sample->env[2])); - sample->intensity= MAX2(sample->intensity, MAX3(sample->indirect[0], sample->indirect[1], sample->indirect[2])); - sample->dist2= dot_v3v3(shi->dxco, shi->dxco) + dot_v3v3(shi->dyco, shi->dyco); - sample->filled= 1; + sample->intensity = MAX3(sample->ao[0], sample->ao[1], sample->ao[2]); + sample->intensity = MAX2(sample->intensity, MAX3(sample->env[0], sample->env[1], sample->env[2])); + sample->intensity = MAX2(sample->intensity, MAX3(sample->indirect[0], sample->indirect[1], sample->indirect[2])); + sample->dist2 = dot_v3v3(shi->dxco, shi->dxco) + dot_v3v3(shi->dyco, shi->dyco); + sample->filled = 1; } } } } else { - shi->ao[0]= 1.0f; - shi->ao[1]= 1.0f; - shi->ao[2]= 1.0f; + shi->ao[0] = 1.0f; + shi->ao[1] = 1.0f; + shi->ao[2] = 1.0f; - shi->env[0]= 0.0f; - shi->env[1]= 0.0f; - shi->env[2]= 0.0f; + shi->env[0] = 0.0f; + shi->env[1] = 0.0f; + shi->env[2] = 0.0f; - shi->indirect[0]= 0.0f; - shi->indirect[1]= 0.0f; - shi->indirect[2]= 0.0f; + shi->indirect[0] = 0.0f; + shi->indirect[1] = 0.0f; + shi->indirect[2] = 0.0f; } } void cache_occ_samples(Render *re, RenderPart *pa, ShadeSample *ssamp) { - OcclusionTree *tree= re->occlusiontree; + OcclusionTree *tree = re->occlusiontree; PixStr ps; OcclusionCache *cache; OcclusionCacheSample *sample; OccFace exclude; ShadeInput *shi; - intptr_t *rd=NULL; - int *ro=NULL, *rp=NULL, *rz=NULL, onlyshadow; + intptr_t *rd = NULL; + int *ro = NULL, *rp = NULL, *rz = NULL, onlyshadow; int x, y, step = CACHE_STEP; if (!tree->cache) return; - cache= &tree->cache[pa->thread]; - cache->w= pa->rectx; - cache->h= pa->recty; - cache->x= pa->disprect.xmin; - cache->y= pa->disprect.ymin; - cache->step= step; - cache->sample= MEM_callocN(sizeof(OcclusionCacheSample)*cache->w*cache->h, "OcclusionCacheSample"); - sample= cache->sample; + cache = &tree->cache[pa->thread]; + cache->w = pa->rectx; + cache->h = pa->recty; + cache->x = pa->disprect.xmin; + cache->y = pa->disprect.ymin; + cache->step = step; + cache->sample = MEM_callocN(sizeof(OcclusionCacheSample) * cache->w * cache->h, "OcclusionCacheSample"); + sample = cache->sample; if (re->osa) { - rd= pa->rectdaps; + rd = pa->rectdaps; } else { /* fake pixel struct for non-osa */ - ps.next= NULL; - ps.mask= 0xFFFF; + ps.next = NULL; + ps.mask = 0xFFFF; - ro= pa->recto; - rp= pa->rectp; - rz= pa->rectz; + ro = pa->recto; + rp = pa->rectp; + rz = pa->rectz; } /* compute a sample at every step pixels */ - for (y=pa->disprect.ymin; y<pa->disprect.ymax; y++) { - for (x=pa->disprect.xmin; x<pa->disprect.xmax; x++, sample++, rd++, ro++, rp++, rz++) { - if (!(((x - pa->disprect.xmin + step) % step) == 0 || x == pa->disprect.xmax-1)) + for (y = pa->disprect.ymin; y < pa->disprect.ymax; y++) { + for (x = pa->disprect.xmin; x < pa->disprect.xmax; x++, sample++, rd++, ro++, rp++, rz++) { + if (!(((x - pa->disprect.xmin + step) % step) == 0 || x == pa->disprect.xmax - 1)) continue; - if (!(((y - pa->disprect.ymin + step) % step) == 0 || y == pa->disprect.ymax-1)) + if (!(((y - pa->disprect.ymin + step) % step) == 0 || y == pa->disprect.ymax - 1)) continue; if (re->osa) { @@ -1862,17 +1868,17 @@ void cache_occ_samples(Render *re, RenderPart *pa, ShadeSample *ssamp) else { if (!*rp) continue; - ps.obi= *ro; - ps.facenr= *rp; - ps.z= *rz; + ps.obi = *ro; + ps.facenr = *rp; + ps.z = *rz; shade_samples_fill_with_ps(ssamp, &ps, x, y); } - shi= ssamp->shi; + shi = ssamp->shi; if (shi->vlr) { - onlyshadow= (shi->mat->mode & MA_ONLYSHADOW); - exclude.obi= shi->obi - re->objectinstance; - exclude.facenr= shi->vlr->index; + onlyshadow = (shi->mat->mode & MA_ONLYSHADOW); + exclude.obi = shi->obi - re->objectinstance; + exclude.facenr = shi->vlr->index; sample_occ_tree(re, tree, &exclude, shi->co, shi->vno, shi->thread, onlyshadow, shi->ao, shi->env, shi->indirect); copy_v3_v3(sample->co, shi->co); @@ -1880,13 +1886,13 @@ void cache_occ_samples(Render *re, RenderPart *pa, ShadeSample *ssamp) copy_v3_v3(sample->ao, shi->ao); copy_v3_v3(sample->env, shi->env); copy_v3_v3(sample->indirect, shi->indirect); - sample->intensity= MAX3(sample->ao[0], sample->ao[1], sample->ao[2]); - sample->intensity= MAX2(sample->intensity, MAX3(sample->env[0], sample->env[1], sample->env[2])); - sample->intensity= MAX2(sample->intensity, MAX3(sample->indirect[0], sample->indirect[1], sample->indirect[2])); - sample->dist2= dot_v3v3(shi->dxco, shi->dxco) + dot_v3v3(shi->dyco, shi->dyco); - sample->x= shi->xs; - sample->y= shi->ys; - sample->filled= 1; + sample->intensity = MAX3(sample->ao[0], sample->ao[1], sample->ao[2]); + sample->intensity = MAX2(sample->intensity, MAX3(sample->env[0], sample->env[1], sample->env[2])); + sample->intensity = MAX2(sample->intensity, MAX3(sample->indirect[0], sample->indirect[1], sample->indirect[2])); + sample->dist2 = dot_v3v3(shi->dxco, shi->dxco) + dot_v3v3(shi->dyco, shi->dyco); + sample->x = shi->xs; + sample->y = shi->ys; + sample->filled = 1; } if (re->test_break(re->tbh)) @@ -1897,18 +1903,18 @@ void cache_occ_samples(Render *re, RenderPart *pa, ShadeSample *ssamp) void free_occ_samples(Render *re, RenderPart *pa) { - OcclusionTree *tree= re->occlusiontree; + OcclusionTree *tree = re->occlusiontree; OcclusionCache *cache; if (tree->cache) { - cache= &tree->cache[pa->thread]; + cache = &tree->cache[pa->thread]; if (cache->sample) MEM_freeN(cache->sample); - cache->w= 0; - cache->h= 0; - cache->step= 0; + cache->w = 0; + cache->h = 0; + cache->step = 0; } } diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 4d227f9586d..a665d1a4bc2 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -167,9 +167,9 @@ static void stats_background(void *UNUSED(arg), RenderStats *rs) } else { if (rs->tothalo) - fprintf(stdout, "Sce: %s Ve:%d Fa:%d Ha:%d La:%d", rs->scenename, rs->totvert, rs->totface, rs->tothalo, rs->totlamp); + fprintf(stdout, "Sce: %s Ve:%d Fa:%d Ha:%d La:%d", rs->scene_name, rs->totvert, rs->totface, rs->tothalo, rs->totlamp); else - fprintf(stdout, "Sce: %s Ve:%d Fa:%d La:%d", rs->scenename, rs->totvert, rs->totface, rs->totlamp); + fprintf(stdout, "Sce: %s Ve:%d Fa:%d La:%d", rs->scene_name, rs->totvert, rs->totface, rs->totlamp); } BLI_callback_exec(G.main, NULL, BLI_CB_EVT_RENDER_STATS); diff --git a/source/blender/render/intern/source/rayshade.c b/source/blender/render/intern/source/rayshade.c index f11e5d22574..8a936545903 100644 --- a/source/blender/render/intern/source/rayshade.c +++ b/source/blender/render/intern/source/rayshade.c @@ -99,7 +99,7 @@ static RayObject* RE_rayobject_create(Render *re, int type, int size) RayObject * res = NULL; if (type == R_RAYSTRUCTURE_AUTO) { - //TODO + /* TODO */ //if (detect_simd()) #ifdef __SSE__ type = BLI_cpu_support_sse2()? R_RAYSTRUCTURE_SIMD_SVBVH: R_RAYSTRUCTURE_VBVH; @@ -216,12 +216,12 @@ static int is_raytraceable(Render *re, ObjectInstanceRen *obi) RayObject* makeraytree_object(Render *re, ObjectInstanceRen *obi) { - //TODO - // out-of-memory safeproof - // break render - // update render stats + /*TODO + * out-of-memory safeproof + * break render + * update render stats */ ObjectRen *obr = obi->obr; - + if (obr->raytree == NULL) { RayObject *raytree; RayFace *face = NULL; @@ -421,8 +421,8 @@ void makeraytree(Render *re) re->stats_draw(re->sdh, &re->i); } else { - //Calculate raytree max_size - //This is ONLY needed to kept a bogus behavior of SUN and HEMI lights + /* Calculate raytree max_size + * This is ONLY needed to kept a bogus behavior of SUN and HEMI lights */ INIT_MINMAX(min, max); RE_rayobject_merge_bb(re->raytree, min, max); for (i=0; i<3; i++) { @@ -739,8 +739,8 @@ static void traceray(ShadeInput *origshi, ShadeResult *origshr, short depth, con tracol[0]= shi.r; tracol[1]= shi.g; tracol[2]= shi.b; - tracol[3]= col[3]; // we pass on and accumulate alpha - + tracol[3]= col[3]; /* we pass on and accumulate alpha */ + if ((shi.mat->mode & MA_TRANSP) && (shi.mat->mode & MA_RAYTRANSP)) { /* don't overwrite traflag, it's value is used in mirror reflection */ int new_traflag = traflag; @@ -883,12 +883,12 @@ static void DP_energy(float *table, float vec[2], int tot, float xsize, float ys } vec[0] += 0.1f*min*result[0]/(float)tot; vec[1] += 0.1f*min*result[1]/(float)tot; - // cyclic clamping + /* cyclic clamping */ vec[0]= vec[0] - xsize*floorf(vec[0]/xsize + 0.5f); vec[1]= vec[1] - ysize*floorf(vec[1]/ysize + 0.5f); } -// random offset of 1 in 2 +/* random offset of 1 in 2 */ static void jitter_plane_offset(float *jitter1, float *jitter2, int tot, float sizex, float sizey, float ofsx, float ofsy) { float dsizex= sizex*ofsx; @@ -974,10 +974,10 @@ static float *give_jitter_plane(LampRen *lar, int thread, int xs, int ys) static void halton_sample(double *ht_invprimes, double *ht_nums, double *v) { - // incremental halton sequence generator, from: - // "Instant Radiosity", Keller A. + /* incremental halton sequence generator, from: + * "Instant Radiosity", Keller A. */ unsigned int i; - + for (i = 0; i < 2; i++) { double r = fabs((1.0 - ht_nums[i]) - 1e-10); @@ -1812,7 +1812,7 @@ static float *sphere_sampler(int type, int resol, int thread, int xs, int ys, in float *sphere; int a; - // always returns table + /* always returns table */ sphere= threadsafe_table_sphere(0, thread, xs, ys, tot); /* total random sampling. NOT THREADSAFE! (should be removed, is not useful) */ @@ -1827,7 +1827,7 @@ static float *sphere_sampler(int type, int resol, int thread, int xs, int ys, in float *sphere; float *vec1; - // returns table if xs and ys were equal to last call, and not resetting + /* returns table if xs and ys were equal to last call, and not resetting */ sphere= (reset)? NULL: threadsafe_table_sphere(1, thread, xs, ys, tot); if (sphere==NULL) { float cosfi, sinfi, cost, sint; @@ -1836,7 +1836,7 @@ static float *sphere_sampler(int type, int resol, int thread, int xs, int ys, in sphere= threadsafe_table_sphere(0, thread, xs, ys, tot); - // random rotation + /* random rotation */ ang= BLI_thread_frand(thread); sinfi= sin(ang); cosfi= cos(ang); ang= BLI_thread_frand(thread); @@ -2056,7 +2056,7 @@ static void ray_ao_spheresamp(ShadeInput *shi, float ao[3], float env[3]) * for strand render we always require a new sampler because x/y are not set */ vec= sphere_sampler(R.wrld.aomode, resol, shi->thread, shi->xs, shi->ys, shi->strand != NULL); - // warning: since we use full sphere now, and dotproduct is below, we do twice as much + /* warning: since we use full sphere now, and dotproduct is below, we do twice as much */ tot= 2*resol*resol; if (envcolor == WO_AOSKYTEX) { @@ -2116,7 +2116,7 @@ static void ray_ao_spheresamp(ShadeInput *shi, float ao[3], float env[3]) skyadded++; } } - // samples + /* samples */ vec+= 3; } @@ -2436,7 +2436,7 @@ static void ray_shadow_jitter(ShadeInput *shi, LampRen *lar, const float lampco[ shadfac[3] /= div; } else { - // sqrt makes nice umbra effect + /* sqrt makes nice umbra effect */ if (lar->ray_samp_type & LA_SAMP_UMBRA) shadfac[3]= sqrt(1.0f-fac/div); else @@ -2501,8 +2501,8 @@ void ray_shadow(ShadeInput *shi, LampRen *lar, float shadfac[4]) isec.orig.ob = shi->obi; isec.orig.face = shi->vlr; - shadfac[3]= 1.0f; // 1.0=full light - + shadfac[3]= 1.0f; /* 1.0=full light */ + /* set up isec.dir */ copy_v3_v3(isec.start, shi->co); sub_v3_v3v3(isec.dir, lampco, isec.start); diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c index 8a9b483a540..f1c4c0b15af 100644 --- a/source/blender/render/intern/source/render_result.c +++ b/source/blender/render/intern/source/render_result.c @@ -463,7 +463,7 @@ RenderResult *render_result_new(Render *re, rcti *partrct, int crop, int savebuf rl->lay_zmask = srl->lay_zmask; rl->lay_exclude = srl->lay_exclude; rl->layflag = srl->layflag; - rl->passflag = srl->passflag; // for debugging: srl->passflag|SCE_PASS_RAYHITS; + rl->passflag = srl->passflag; /* for debugging: srl->passflag | SCE_PASS_RAYHITS; */ rl->pass_xor = srl->pass_xor; rl->light_override = srl->light_override; rl->mat_override = srl->mat_override; @@ -590,7 +590,7 @@ RenderResult *render_result_new_full_sample(Render *re, ListBase *lb, rcti *part } /* callbacks for render_result_new_from_exr */ -static void *ml_addlayer_cb(void *base, char *str) +static void *ml_addlayer_cb(void *base, const char *str) { RenderResult *rr = base; RenderLayer *rl; @@ -602,7 +602,7 @@ static void *ml_addlayer_cb(void *base, char *str) return rl; } -static void ml_addpass_cb(void *UNUSED(base), void *lay, char *str, float *rect, int totchan, char *chan_id) +static void ml_addpass_cb(void *UNUSED(base), void *lay, const char *str, float *rect, int totchan, const char *chan_id) { RenderLayer *rl = lay; RenderPass *rpass = MEM_callocN(sizeof(RenderPass), "loaded pass"); @@ -626,7 +626,7 @@ static void ml_addpass_cb(void *UNUSED(base), void *lay, char *str, float *rect, /* from imbuf, if a handle was returned we convert this to render result */ RenderResult *render_result_new_from_exr(void *exrhandle, int rectx, int recty) { - RenderResult *rr = MEM_callocN(sizeof(RenderResult), "loaded render result"); + RenderResult *rr = MEM_callocN(sizeof(RenderResult), __func__); RenderLayer *rl; RenderPass *rpass; diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index 39577bf8da8..c8ef3e4a8dd 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -244,7 +244,7 @@ static int clouds(Tex *tex, float *texvec, TexResult *texres) texres->tin = BLI_gTurbulence(tex->noisesize, texvec[0], texvec[1], texvec[2], tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis); if (texres->nor!=NULL) { - // calculate bumpnormal + /* calculate bumpnormal */ texres->nor[0] = BLI_gTurbulence(tex->noisesize, texvec[0] + tex->nabla, texvec[1], texvec[2], tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis); texres->nor[1] = BLI_gTurbulence(tex->noisesize, texvec[0], texvec[1] + tex->nabla, texvec[2], tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis); texres->nor[2] = BLI_gTurbulence(tex->noisesize, texvec[0], texvec[1], texvec[2] + tex->nabla, tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis); @@ -254,8 +254,8 @@ static int clouds(Tex *tex, float *texvec, TexResult *texres) } if (tex->stype==TEX_COLOR) { - // in this case, int. value should really be computed from color, - // and bumpnormal from that, would be too slow, looks ok as is + /* in this case, int. value should really be computed from color, + * and bumpnormal from that, would be too slow, looks ok as is */ texres->tr = texres->tin; texres->tg = BLI_gTurbulence(tex->noisesize, texvec[1], texvec[0], texvec[2], tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis); texres->tb = BLI_gTurbulence(tex->noisesize, texvec[1], texvec[2], texvec[0], tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis); @@ -538,8 +538,8 @@ static float mg_mFractalOrfBmTex(Tex *tex, float *texvec, TexResult *texres) texres->tin = tex->ns_outscale*mgravefunc(texvec[0], texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->noisebasis); if (texres->nor!=NULL) { - float offs= tex->nabla/tex->noisesize; // also scaling of texvec - + float offs= tex->nabla/tex->noisesize; /* also scaling of texvec */ + /* calculate bumpnormal */ texres->nor[0] = tex->ns_outscale*mgravefunc(texvec[0] + offs, texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->noisebasis); texres->nor[1] = tex->ns_outscale*mgravefunc(texvec[0], texvec[1] + offs, texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->noisebasis); @@ -568,8 +568,8 @@ static float mg_ridgedOrHybridMFTex(Tex *tex, float *texvec, TexResult *texres) texres->tin = tex->ns_outscale*mgravefunc(texvec[0], texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->mg_gain, tex->noisebasis); if (texres->nor!=NULL) { - float offs= tex->nabla/tex->noisesize; // also scaling of texvec - + float offs= tex->nabla/tex->noisesize; /* also scaling of texvec */ + /* calculate bumpnormal */ texres->nor[0] = tex->ns_outscale*mgravefunc(texvec[0] + offs, texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->mg_gain, tex->noisebasis); texres->nor[1] = tex->ns_outscale*mgravefunc(texvec[0], texvec[1] + offs, texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->mg_gain, tex->noisebasis); @@ -593,8 +593,8 @@ static float mg_HTerrainTex(Tex *tex, float *texvec, TexResult *texres) texres->tin = tex->ns_outscale*mg_HeteroTerrain(texvec[0], texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->noisebasis); if (texres->nor!=NULL) { - float offs= tex->nabla/tex->noisesize; // also scaling of texvec - + float offs= tex->nabla/tex->noisesize; /* also scaling of texvec */ + /* calculate bumpnormal */ texres->nor[0] = tex->ns_outscale*mg_HeteroTerrain(texvec[0] + offs, texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->noisebasis); texres->nor[1] = tex->ns_outscale*mg_HeteroTerrain(texvec[0], texvec[1] + offs, texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->noisebasis); @@ -618,8 +618,8 @@ static float mg_distNoiseTex(Tex *tex, float *texvec, TexResult *texres) texres->tin = mg_VLNoise(texvec[0], texvec[1], texvec[2], tex->dist_amount, tex->noisebasis, tex->noisebasis2); if (texres->nor!=NULL) { - float offs= tex->nabla/tex->noisesize; // also scaling of texvec - + float offs= tex->nabla/tex->noisesize; /* also scaling of texvec */ + /* calculate bumpnormal */ texres->nor[0] = mg_VLNoise(texvec[0] + offs, texvec[1], texvec[2], tex->dist_amount, tex->noisebasis, tex->noisebasis2); texres->nor[1] = mg_VLNoise(texvec[0], texvec[1] + offs, texvec[2], tex->dist_amount, tex->noisebasis, tex->noisebasis2); @@ -688,7 +688,7 @@ static float voronoiTex(Tex *tex, float *texvec, TexResult *texres) } if (texres->nor!=NULL) { - float offs= tex->nabla/tex->noisesize; // also scaling of texvec + float offs= tex->nabla/tex->noisesize; /* also scaling of texvec */ /* calculate bumpnormal */ voronoi(texvec[0] + offs, texvec[1], texvec[2], da, pa, tex->vn_mexp, tex->vn_distm); @@ -745,7 +745,7 @@ static int cubemap_glob(const float n[3], float x, float y, float z, float *adr1 int ret; if (n==NULL) { - nor[0]= x; nor[1]= y; nor[2]= z; // use local render coord + nor[0]= x; nor[1]= y; nor[2]= z; /* use local render coord */ } else { copy_v3_v3(nor, n); @@ -1026,7 +1026,7 @@ static void do_2d_mapping(MTex *mtex, float *t, VlakRen *vlr, const float n[3], if (tex->xrepeat>1) { float origf= fx *= tex->xrepeat; - // TXF: omit mirror here, see comments in do_material_tex() after do_2d_mapping() call + /* TXF: omit mirror here, see comments in do_material_tex() after do_2d_mapping() call */ if (tex->texfilter == TXF_BOX) { if (fx>1.0f) fx -= (int)(fx); else if (fx<0.0f) fx+= 1-(int)(fx); @@ -1046,7 +1046,7 @@ static void do_2d_mapping(MTex *mtex, float *t, VlakRen *vlr, const float n[3], if (tex->yrepeat>1) { float origf= fy *= tex->yrepeat; - // TXF: omit mirror here, see comments in do_material_tex() after do_2d_mapping() call + /* TXF: omit mirror here, see comments in do_material_tex() after do_2d_mapping() call */ if (tex->texfilter == TXF_BOX) { if (fy>1.0f) fy -= (int)(fy); else if (fy<0.0f) fy+= 1-(int)(fy); @@ -1512,9 +1512,9 @@ float texture_value_blend(float tex, float out, float fact, float facg, int blen static void texco_mapping(ShadeInput* shi, Tex* tex, MTex* mtex, float* co, float* dx, float* dy, float* texvec, float* dxt, float* dyt) { - // new: first swap coords, then map, then trans/scale + /* new: first swap coords, then map, then trans/scale */ if (tex->type == TEX_IMAGE) { - // placement + /* placement */ texvec[0] = mtex->projx ? co[mtex->projx - 1] : 0.f; texvec[1] = mtex->projy ? co[mtex->projy - 1] : 0.f; texvec[2] = mtex->projz ? co[mtex->projz - 1] : 0.f; @@ -1538,7 +1538,7 @@ static void texco_mapping(ShadeInput* shi, Tex* tex, MTex* mtex, float* co, floa } do_2d_mapping(mtex, texvec, shi->vlr, shi->facenor, dxt, dyt); - // translate and scale + /* translate and scale */ texvec[0] = mtex->size[0]*(texvec[0] - 0.5f) + mtex->ofs[0] + 0.5f; texvec[1] = mtex->size[1]*(texvec[1] - 0.5f) + mtex->ofs[1] + 0.5f; if (shi->osatex) { @@ -1549,13 +1549,13 @@ static void texco_mapping(ShadeInput* shi, Tex* tex, MTex* mtex, float* co, floa } /* problem: repeat-mirror is not a 'repeat' but 'extend' in imagetexture.c */ - // TXF: bug was here, only modify texvec when repeat mode set, old code affected other modes too. - // New texfilters solve mirroring differently so that it also works correctly when - // textures are scaled (sizeXYZ) as well as repeated. See also modification in do_2d_mapping(). - // (since currently only done in osa mode, results will look incorrect without osa TODO) + /* TXF: bug was here, only modify texvec when repeat mode set, old code affected other modes too. + * New texfilters solve mirroring differently so that it also works correctly when + * textures are scaled (sizeXYZ) as well as repeated. See also modification in do_2d_mapping(). + * (since currently only done in osa mode, results will look incorrect without osa TODO) */ if (tex->extend == TEX_REPEAT && (tex->flag & TEX_REPEAT_XMIR)) { if (tex->texfilter == TXF_BOX) - texvec[0] -= floorf(texvec[0]); // this line equivalent to old code, same below + texvec[0] -= floorf(texvec[0]); /* this line equivalent to old code, same below */ else if (texvec[0] < 0.f || texvec[0] > 1.f) { const float tx = 0.5f*texvec[0]; texvec[0] = 2.f*(tx - floorf(tx)); @@ -1573,8 +1573,8 @@ static void texco_mapping(ShadeInput* shi, Tex* tex, MTex* mtex, float* co, floa } } - else { // procedural - // placement + else { /* procedural */ + /* placement */ texvec[0] = mtex->size[0]*(mtex->projx ? (co[mtex->projx - 1] + mtex->ofs[0]) : mtex->ofs[0]); texvec[1] = mtex->size[1]*(mtex->projy ? (co[mtex->projy - 1] + mtex->ofs[1]) : mtex->ofs[1]); texvec[2] = mtex->size[2]*(mtex->projz ? (co[mtex->projz - 1] + mtex->ofs[2]) : mtex->ofs[2]); @@ -1617,11 +1617,16 @@ static void compatible_bump_init(CompatibleBump *compat_bump) static void compatible_bump_uv_derivs(CompatibleBump *compat_bump, ShadeInput *shi, MTex *mtex, int i) { - // uvmapping only, calculation of normal tangent u/v partial derivatives - // (should not be here, dudnu, dudnv, dvdnu & dvdnv should probably be part of ShadeInputUV struct, - // nu/nv in ShadeInput and this calculation should then move to shadeinput.c, shade_input_set_shade_texco() func.) - // NOTE: test for shi->obr->ob here, since vlr/obr/obi can be 'fake' when called from fastshade(), another reason to move it.. - // NOTE: shi->v1 is NULL when called from displace_render_vert, assigning verts in this case is not trivial because the shi quad face side is not know. + /* uvmapping only, calculation of normal tangent u/v partial derivatives + * (should not be here, dudnu, dudnv, dvdnu & dvdnv should probably be part of ShadeInputUV struct, + * nu/nv in ShadeInput and this calculation should then move to shadeinput.c, + * shade_input_set_shade_texco() func.) */ + + /* NOTE: test for shi->obr->ob here, + * since vlr/obr/obi can be 'fake' when called from fastshade(), another reason to move it.. */ + + /* NOTE: shi->v1 is NULL when called from displace_render_vert, + * assigning verts in this case is not trivial because the shi quad face side is not know. */ if ((mtex->texflag & MTEX_COMPAT_BUMP) && shi->obr && shi->obr->ob && shi->v1) { if (mtex->mapto & (MAP_NORM|MAP_WARP) && !((mtex->tex->type==TEX_IMAGE) && (mtex->tex->imaflag & TEX_NORMALMAP))) { MTFace* tf = RE_vlakren_get_tface(shi->obr, shi->vlr, i, NULL, 0); @@ -1629,9 +1634,9 @@ static void compatible_bump_uv_derivs(CompatibleBump *compat_bump, ShadeInput *s vlr_set_uv_indices(shi->vlr, &j1, &j2, &j3); - // compute ortho basis around normal + /* compute ortho basis around normal */ if (!compat_bump->nunvdone) { - // render normal is negated + /* render normal is negated */ compat_bump->nn[0] = -shi->vn[0]; compat_bump->nn[1] = -shi->vn[1]; compat_bump->nn[2] = -shi->vn[2]; @@ -1672,32 +1677,32 @@ static void compatible_bump_uv_derivs(CompatibleBump *compat_bump, ShadeInput *s static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi, MTex *mtex, Tex *tex, TexResult *texres, float Tnor, float *co, float *dx, float *dy, float *texvec, float *dxt, float *dyt) { - TexResult ttexr = {0, 0, 0, 0, 0, texres->talpha, NULL}; // temp TexResult + TexResult ttexr = {0, 0, 0, 0, 0, texres->talpha, NULL}; /* temp TexResult */ float tco[3], texv[3], cd, ud, vd, du, dv, idu, idv; const int fromrgb = ((tex->type == TEX_IMAGE) || ((tex->flag & TEX_COLORBAND)!=0)); const float bf = -0.04f*Tnor*mtex->norfac; int rgbnor; - // disable internal bump eval + /* disable internal bump eval */ float* nvec = texres->nor; texres->nor = NULL; - // du & dv estimates, constant value defaults + /* du & dv estimates, constant value defaults */ du = dv = 0.01f; - // compute ortho basis around normal + /* compute ortho basis around normal */ if (!compat_bump->nunvdone) { - // render normal is negated + /* render normal is negated */ negate_v3_v3(compat_bump->nn, shi->vn); ortho_basis_v3v3_v3(compat_bump->nu, compat_bump->nv, compat_bump->nn); compat_bump->nunvdone = TRUE; } - // two methods, either constant based on main image resolution, - // (which also works without osa, though of course not always good (or even very bad) results), - // or based on tex derivative max values (osa only). Not sure which is best... + /* two methods, either constant based on main image resolution, + * (which also works without osa, though of course not always good (or even very bad) results), + * or based on tex derivative max values (osa only). Not sure which is best... */ if (!shi->osatex && (tex->type == TEX_IMAGE) && tex->ima) { - // in case we have no proper derivatives, fall back to - // computing du/dv it based on image size + /* in case we have no proper derivatives, fall back to + * computing du/dv it based on image size */ ImBuf* ibuf = BKE_image_get_ibuf(tex->ima, &tex->iuser); if (ibuf) { du = 1.f/(float)ibuf->x; @@ -1705,14 +1710,14 @@ static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi, } } else if (shi->osatex) { - // we have derivatives, can compute proper du/dv - if (tex->type == TEX_IMAGE) { // 2d image, use u & v max. of dx/dy 2d vecs + /* we have derivatives, can compute proper du/dv */ + if (tex->type == TEX_IMAGE) { /* 2d image, use u & v max. of dx/dy 2d vecs */ const float adx[2] = {fabsf(dx[0]), fabsf(dx[1])}; const float ady[2] = {fabsf(dy[0]), fabsf(dy[1])}; du = MAX2(adx[0], ady[0]); dv = MAX2(adx[1], ady[1]); } - else { // 3d procedural, estimate from all dx/dy elems + else { /* 3d procedural, estimate from all dx/dy elems */ const float adx[3] = {fabsf(dx[0]), fabsf(dx[1]), fabsf(dx[2])}; const float ady[3] = {fabsf(dy[0]), fabsf(dy[1]), fabsf(dy[2])}; du = MAX3(adx[0], adx[1], adx[2]); @@ -1720,18 +1725,18 @@ static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi, } } - // center, main return value + /* center, main return value */ texco_mapping(shi, tex, mtex, co, dx, dy, texvec, dxt, dyt); rgbnor = multitex_mtex(shi, mtex, texvec, dxt, dyt, texres); cd = fromrgb ? (texres->tr + texres->tg + texres->tb)*0.33333333f : texres->tin; if (mtex->texco == TEXCO_UV) { - // for the uv case, use the same value for both du/dv, - // since individually scaling the normal derivatives makes them useless... + /* for the uv case, use the same value for both du/dv, + * since individually scaling the normal derivatives makes them useless... */ du = MIN2(du, dv); idu = (du < 1e-5f) ? bf : (bf/du); - // +u val + /* +u val */ tco[0] = co[0] + compat_bump->dudnu*du; tco[1] = co[1] + compat_bump->dvdnu*du; tco[2] = 0.f; @@ -1739,7 +1744,7 @@ static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi, multitex_mtex(shi, mtex, texv, dxt, dyt, &ttexr); ud = idu*(cd - (fromrgb ? (ttexr.tr + ttexr.tg + ttexr.tb)*0.33333333f : ttexr.tin)); - // +v val + /* +v val */ tco[0] = co[0] + compat_bump->dudnv*du; tco[1] = co[1] + compat_bump->dvdnv*du; tco[2] = 0.f; @@ -1773,7 +1778,7 @@ static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi, normalize_v3(tv); } - // +u val + /* +u val */ tco[0] = co[0] + tu[0]*du; tco[1] = co[1] + tu[1]*du; tco[2] = co[2] + tu[2]*du; @@ -1781,7 +1786,7 @@ static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi, multitex_mtex(shi, mtex, texv, dxt, dyt, &ttexr); ud = idu*(cd - (fromrgb ? (ttexr.tr + ttexr.tg + ttexr.tb)*0.33333333f : ttexr.tin)); - // +v val + /* +v val */ tco[0] = co[0] + tv[0]*dv; tco[1] = co[1] + tv[1]*dv; tco[2] = co[2] + tv[2]*dv; @@ -1790,7 +1795,7 @@ static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi, vd = idv*(cd - (fromrgb ? (ttexr.tr + ttexr.tg + ttexr.tb)*0.33333333f : ttexr.tin)); } - // bumped normal + /* bumped normal */ compat_bump->nu[0] += ud*compat_bump->nn[0]; compat_bump->nu[1] += ud*compat_bump->nn[1]; compat_bump->nu[2] += ud*compat_bump->nn[2]; @@ -1812,13 +1817,13 @@ static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi, typedef struct NTapBump { int init_done; - int iPrevBumpSpace; // 0: uninitialized, 1: objectspace, 2: texturespace, 4: viewspace - // bumpmapping - float vNorg[3]; // backup copy of shi->vn - float vNacc[3]; // original surface normal minus the surface gradient of every bump map which is encountered - float vR1[3], vR2[3]; // cross products (sigma_y, original_normal), (original_normal, sigma_x) - float sgn_det; // sign of the determinant of the matrix {sigma_x, sigma_y, original_normal} - float fPrevMagnitude; // copy of previous magnitude, used for multiple bumps in different spaces + int iPrevBumpSpace; /* 0: uninitialized, 1: objectspace, 2: texturespace, 4: viewspace */ + /* bumpmapping */ + float vNorg[3]; /* backup copy of shi->vn */ + float vNacc[3]; /* original surface normal minus the surface gradient of every bump map which is encountered */ + float vR1[3], vR2[3]; /* cross products (sigma_y, original_normal), (original_normal, sigma_x) */ + float sgn_det; /* sign of the determinant of the matrix {sigma_x, sigma_y, original_normal} */ + float fPrevMagnitude; /* copy of previous magnitude, used for multiple bumps in different spaces */ } NTapBump; static void ntap_bump_init(NTapBump *ntap_bump) @@ -1828,38 +1833,38 @@ static void ntap_bump_init(NTapBump *ntap_bump) static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, Tex *tex, TexResult *texres, float Tnor, float *co, float *dx, float *dy, float *texvec, float *dxt, float *dyt) { - TexResult ttexr = {0, 0, 0, 0, 0, texres->talpha, NULL}; // temp TexResult + TexResult ttexr = {0, 0, 0, 0, 0, texres->talpha, NULL}; /* temp TexResult */ const int fromrgb = ((tex->type == TEX_IMAGE) || ((tex->flag & TEX_COLORBAND)!=0)); - // The negate on Hscale is done because the - // normal in the renderer points inward which corresponds - // to inverting the bump map. The normals are generated - // this way in calc_vertexnormals(). Should this ever change - // this negate must be removed. + /* The negate on Hscale is done because the + * normal in the renderer points inward which corresponds + * to inverting the bump map. The normals are generated + * this way in calc_vertexnormals(). Should this ever change + * this negate must be removed. */ float Hscale = -Tnor*mtex->norfac; int dimx=512, dimy=512; - const int imag_tspace_dimension_x = 1024; // only used for texture space variant + const int imag_tspace_dimension_x = 1024; /* only used for texture space variant */ float aspect = 1.0f; - // 2 channels for 2D texture and 3 for 3D textures. + /* 2 channels for 2D texture and 3 for 3D textures. */ const int nr_channels = (mtex->texco == TEXCO_UV)? 2 : 3; int c, rgbnor, iBumpSpace; float dHdx, dHdy; int found_deriv_map = (tex->type==TEX_IMAGE) && (tex->imaflag & TEX_DERIVATIVEMAP); - // disable internal bump eval in sampler, save pointer + /* disable internal bump eval in sampler, save pointer */ float *nvec = texres->nor; texres->nor = NULL; if (found_deriv_map==0) { if ( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) { if (tex->ima) - Hscale *= 13.0f; // appears to be a sensible default value + Hscale *= 13.0f; /* appears to be a sensible default value */ } else - Hscale *= 0.1f; // factor 0.1 proved to look like the previous bump code + Hscale *= 0.1f; /* factor 0.1 proved to look like the previous bump code */ } if ( !ntap_bump->init_done ) { @@ -1871,7 +1876,7 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T ntap_bump->init_done = TRUE; } - // resolve image dimensions + /* resolve image dimensions */ if (found_deriv_map || (mtex->texflag&MTEX_BUMP_TEXTURESPACE)!=0) { ImBuf* ibuf = BKE_image_get_ibuf(tex->ima, &tex->iuser); if (ibuf) { @@ -1883,7 +1888,7 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T if (found_deriv_map) { float dBdu, dBdv, auto_bump = 1.0f; - float s = 1; // negate this if flipped texture coordinate + float s = 1; /* negate this if flipped texture coordinate */ texco_mapping(shi, tex, mtex, co, dx, dy, texvec, dxt, dyt); rgbnor = multitex_mtex(shi, mtex, texvec, dxt, dyt, texres); @@ -1895,9 +1900,9 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T float fVirtDim = sqrtf(fabsf((float) (dimx*dimy)*mtex->size[0]*mtex->size[1])); auto_bump /= MAX2(fVirtDim, FLT_EPSILON); } - - // this variant using a derivative map is described here - // http://mmikkelsen3d.blogspot.com/2011/07/derivative-maps.html + + /* this variant using a derivative map is described here + * http://mmikkelsen3d.blogspot.com/2011/07/derivative-maps.html */ dBdu = auto_bump*Hscale*dimx*(2*texres->tr-1); dBdv = auto_bump*Hscale*dimy*(2*texres->tg-1); @@ -1905,32 +1910,32 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T dHdy = dBdu*dyt[0] + s * dBdv*dyt[1]; } else if (!(mtex->texflag & MTEX_5TAP_BUMP)) { - // compute height derivatives with respect to output image pixel coordinates x and y + /* compute height derivatives with respect to output image pixel coordinates x and y */ float STll[3], STlr[3], STul[3]; float Hll, Hlr, Hul; texco_mapping(shi, tex, mtex, co, dx, dy, texvec, dxt, dyt); for (c=0; c<nr_channels; c++) { - // dx contains the derivatives (du/dx, dv/dx) - // dy contains the derivatives (du/dy, dv/dy) + /* dx contains the derivatives (du/dx, dv/dx) + * dy contains the derivatives (du/dy, dv/dy) */ STll[c] = texvec[c]; STlr[c] = texvec[c]+dxt[c]; STul[c] = texvec[c]+dyt[c]; } - // clear unused derivatives + /* clear unused derivatives */ for (c=nr_channels; c<3; c++) { STll[c] = 0.0f; STlr[c] = 0.0f; STul[c] = 0.0f; } - // use texres for the center sample, set rgbnor + /* use texres for the center sample, set rgbnor */ rgbnor = multitex_mtex(shi, mtex, STll, dxt, dyt, texres); Hll = (fromrgb) ? rgb_to_grayscale(&texres->tr) : texres->tin; - // use ttexr for the other 2 taps + /* use ttexr for the other 2 taps */ multitex_mtex(shi, mtex, STlr, dxt, dyt, &ttexr); Hlr = (fromrgb) ? rgb_to_grayscale(&ttexr.tr) : ttexr.tin; @@ -1955,7 +1960,7 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T STu[c] = texvec[c] + 0.5f*dyt[c]; } - // clear unused derivatives + /* clear unused derivatives */ for (c=nr_channels; c<3; c++) { STc[c] = 0.0f; STl[c] = 0.0f; @@ -1964,11 +1969,11 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T STu[c] = 0.0f; } - // use texres for the center sample, set rgbnor + /* use texres for the center sample, set rgbnor */ rgbnor = multitex_mtex(shi, mtex, STc, dxt, dyt, texres); /* Hc = (fromrgb) ? rgb_to_grayscale(&texres->tr) : texres->tin; */ /* UNUSED */ - // use ttexr for the other taps + /* use ttexr for the other taps */ multitex_mtex(shi, mtex, STl, dxt, dyt, &ttexr); Hl = (fromrgb) ? rgb_to_grayscale(&ttexr.tr) : ttexr.tin; multitex_mtex(shi, mtex, STr, dxt, dyt, &ttexr); @@ -1982,7 +1987,7 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T dHdy = Hscale*(Hu - Hd); } - // restore pointer + /* restore pointer */ texres->nor = nvec; /* replaced newbump with code based on listing 1 and 2 of @@ -1994,32 +1999,32 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T else if ( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) iBumpSpace = 2; else - iBumpSpace = 4; // ViewSpace - + iBumpSpace = 4; /* ViewSpace */ + if ( ntap_bump->iPrevBumpSpace != iBumpSpace ) { - - // initialize normal perturbation vectors + + /* initialize normal perturbation vectors */ int xyz; float fDet, abs_fDet, fMagnitude; - // object2view and inverted matrix + /* object2view and inverted matrix */ float obj2view[3][3], view2obj[3][3], tmp[4][4]; - // local copies of derivatives and normal + /* local copies of derivatives and normal */ float dPdx[3], dPdy[3], vN[3]; copy_v3_v3(dPdx, shi->dxco); copy_v3_v3(dPdy, shi->dyco); copy_v3_v3(vN, ntap_bump->vNorg); if ( mtex->texflag & MTEX_BUMP_OBJECTSPACE ) { - // TODO: these calculations happen for every pixel! - // -> move to shi->obi + /* TODO: these calculations happen for every pixel! + * -> move to shi->obi */ mult_m4_m4m4(tmp, R.viewmat, shi->obr->ob->obmat); - copy_m3_m4(obj2view, tmp); // use only upper left 3x3 matrix + copy_m3_m4(obj2view, tmp); /* use only upper left 3x3 matrix */ invert_m3_m3(view2obj, obj2view); - - // generate the surface derivatives in object space + + /* generate the surface derivatives in object space */ mul_m3_v3(view2obj, dPdx); mul_m3_v3(view2obj, dPdy); - // generate the unit normal in object space + /* generate the unit normal in object space */ mul_transposed_m3_v3(obj2view, vN); normalize_v3(vN); } @@ -2032,7 +2037,7 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T if ( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) { if (tex->ima) { - // crazy hack solution that gives results similar to normal mapping - part 1 + /* crazy hack solution that gives results similar to normal mapping - part 1 */ normalize_v3(ntap_bump->vR1); normalize_v3(ntap_bump->vR2); abs_fDet = 1.0f; @@ -2041,7 +2046,7 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T fMagnitude = abs_fDet; if ( mtex->texflag & MTEX_BUMP_OBJECTSPACE ) { - // pre do transform of texres->nor by the inverse transposed of obj2view + /* pre do transform of texres->nor by the inverse transposed of obj2view */ mul_transposed_m3_v3(view2obj, vN); mul_transposed_m3_v3(view2obj, ntap_bump->vR1); mul_transposed_m3_v3(view2obj, ntap_bump->vR2); @@ -2059,7 +2064,7 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T if ( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) { if (tex->ima) { - // crazy hack solution that gives results similar to normal mapping - part 2 + /* crazy hack solution that gives results similar to normal mapping - part 2 */ float vec[2]; const float imag_tspace_dimension_y = aspect*imag_tspace_dimension_x; @@ -2072,11 +2077,11 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T } } - // subtract the surface gradient from vNacc + /* subtract the surface gradient from vNacc */ for (c=0; c<3; c++) { float vSurfGrad_compi = ntap_bump->sgn_det * (dHdx * ntap_bump->vR1[c] + dHdy * ntap_bump->vR2[c]); ntap_bump->vNacc[c] -= vSurfGrad_compi; - texres->nor[c] = ntap_bump->vNacc[c]; // copy + texres->nor[c] = ntap_bump->vNacc[c]; /* copy */ } rgbnor |= TEX_NOR; @@ -2235,7 +2240,9 @@ void do_material_tex(ShadeInput *shi, Render *re) dy[0]= 0.0f; dy[1]= dy[2]= 0.0f; } - else continue; // can happen when texco defines disappear and it renders old files + else { + continue; /* can happen when texco defines disappear and it renders old files */ + } /* the pointer defines if bumping happens */ if (mtex->mapto & (MAP_NORM|MAP_WARP)) { @@ -2319,7 +2326,7 @@ void do_material_tex(ShadeInput *shi, Render *re) texres.nor[2]= f2*co_nor-f1*si; } } - // warping, local space + /* warping, local space */ if (mtex->mapto & MAP_WARP) { float *warpnor= texres.nor, warpnor_[3]; @@ -2335,11 +2342,11 @@ void do_material_tex(ShadeInput *shi, Render *re) } #if 0 if (mtex->texflag & MTEX_VIEWSPACE) { - // rotate to global coords + /* rotate to global coords */ if (mtex->texco==TEXCO_ORCO || mtex->texco==TEXCO_UV) { if (shi->vlr && shi->obr && shi->obr->ob) { float len= normalize_v3(texres.nor); - // can be optimized... (ton) + /* can be optimized... (ton) */ mul_mat3_m4_v3(shi->obr->ob->obmat, texres.nor); mul_mat3_m4_v3(re->viewmat, texres.nor); normalize_v3(texres.nor); @@ -2388,7 +2395,7 @@ void do_material_tex(ShadeInput *shi, Render *re) if (mtex->mapto & MAP_COLMIR) { float mirrfac= mtex->mirrfac*stencilTin; - // exception for envmap only + /* exception for envmap only */ if (tex->type==TEX_ENVMAP && mtex->blendtype==MTEX_BLEND) { fact= texres.tin*mirrfac; facm= 1.0f- fact; @@ -2565,7 +2572,7 @@ void do_material_tex(ShadeInput *shi, Render *re) else if (shi->alpha>1.0f) shi->alpha= 1.0f; } if (mtex->mapto & MAP_HAR) { - float har; // have to map to 0-1 + float har; /* have to map to 0-1 */ float hardfac= mtex->hardfac*stencilTin; har= ((float)shi->har)/128.0f; @@ -2605,7 +2612,7 @@ void do_material_tex(ShadeInput *shi, Render *re) } if ((use_compat_bump || use_ntap_bump || found_nmapping) && (shi->mat->mode & MA_TANGENT_V) != 0) { const float fnegdot = -dot_v3v3(shi->vn, shi->tang); - // apply Gram-Schmidt projection + /* apply Gram-Schmidt projection */ madd_v3_v3fl(shi->tang, shi->vn, fnegdot); normalize_v3(shi->tang); } @@ -2665,12 +2672,14 @@ void do_volume_tex(ShadeInput *shi, const float *xyz, int mapto_flag, float col_ copy_v3_v3(co, xyz); mul_m4_v3(re->viewinv, co); } - else continue; // can happen when texco defines disappear and it renders old files + else { + continue; /* can happen when texco defines disappear and it renders old files */ + } texres.nor= NULL; - if (tex->type==TEX_IMAGE) { - continue; /* not supported yet */ + if (tex->type == TEX_IMAGE) { + continue; /* not supported yet */ //do_2d_mapping(mtex, texvec, NULL, NULL, dxt, dyt); } else { @@ -3381,7 +3390,7 @@ int externtex(MTex *mtex, const float vec[3], float *tin, float *tr, float *tg, void render_realtime_texture(ShadeInput *shi, Image *ima) { TexResult texr; - static Tex imatex[BLENDER_MAX_THREADS]; // threadsafe + static Tex imatex[BLENDER_MAX_THREADS]; /* threadsafe */ static int firsttime= 1; Tex *tex; float texvec[3], dx[2], dy[2]; @@ -3409,7 +3418,7 @@ void render_realtime_texture(ShadeInput *shi, Image *ima) texvec[0]= 0.5f+0.5f*suv->uv[0]; texvec[1]= 0.5f+0.5f*suv->uv[1]; - texvec[2] = 0.0f; // initalize it because imagewrap looks at it. + texvec[2] = 0.0f; /* initalize it because imagewrap looks at it. */ if (shi->osatex) { dx[0]= 0.5f*suv->dxuv[0]; dx[1]= 0.5f*suv->dxuv[1]; diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index 03bea0122cf..63aa6cdd139 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -2098,12 +2098,12 @@ static void bake_shade(void *handle, Object *ob, ShadeInput *shi, int UNUSED(qua normalize_v3(nor); /* in case object has scaling */ - // The invert of the red channel is to make - // the normal map compliant with the outside world. - // It needs to be done because in Blender - // the normal used in the renderer points inward. It is generated - // this way in calc_vertexnormals(). Should this ever change - // this negate must be removed. + /* The invert of the red channel is to make + * the normal map compliant with the outside world. + * It needs to be done because in Blender + * the normal used in the renderer points inward. It is generated + * this way in calc_vertexnormals(). Should this ever change + * this negate must be removed. */ shr.combined[0]= (-nor[0])/2.0f + 0.5f; shr.combined[1]= nor[1]/2.0f + 0.5f; shr.combined[2]= nor[2]/2.0f + 0.5f; diff --git a/source/blender/render/intern/source/shadbuf.c b/source/blender/render/intern/source/shadbuf.c index 93587734e2b..f696f95781b 100644 --- a/source/blender/render/intern/source/shadbuf.c +++ b/source/blender/render/intern/source/shadbuf.c @@ -1561,9 +1561,9 @@ static void isb_bsp_split(ISBBranch *root, MemArena *mem) right= root->right= BLI_memarena_alloc(mem, sizeof(ISBBranch)); /* new sample array */ - left->samples= BLI_memarena_alloc(mem, BSPMAX_SAMPLE*sizeof(void *)); - right->samples= samples; // tmp - + left->samples = BLI_memarena_alloc(mem, BSPMAX_SAMPLE*sizeof(void *)); + right->samples = samples; /* tmp */ + /* split samples */ for (a=BSPMAX_SAMPLE-1; a>=0; a--) { int comp= 0; diff --git a/source/blender/render/intern/source/shadeinput.c b/source/blender/render/intern/source/shadeinput.c index f9b0de5b87d..5e80370a6f0 100644 --- a/source/blender/render/intern/source/shadeinput.c +++ b/source/blender/render/intern/source/shadeinput.c @@ -818,7 +818,7 @@ void shade_input_set_normals(ShadeInput *shi) shi->vn[1]= l*n3[1]-u*n1[1]-v*n2[1]; shi->vn[2]= l*n3[2]-u*n1[2]-v*n2[2]; - // use unnormalized normal (closer to games) + /* use unnormalized normal (closer to games) */ copy_v3_v3(shi->nmapnorm, shi->vn); normalize_v3(shi->vn); @@ -851,7 +851,7 @@ void shade_input_set_vertex_normals(ShadeInput *shi) shi->vn[1]= l*n3[1]-u*n1[1]-v*n2[1]; shi->vn[2]= l*n3[2]-u*n1[2]-v*n2[2]; - // use unnormalized normal (closer to games) + /* use unnormalized normal (closer to games) */ copy_v3_v3(shi->nmapnorm, shi->vn); normalize_v3(shi->vn); @@ -968,22 +968,22 @@ void shade_input_set_shade_texco(ShadeInput *shi) copy_v3_v3(c1, &tangent[j2*4]); copy_v3_v3(c2, &tangent[j3*4]); - // keeping tangents normalized at vertex level - // corresponds better to how it's done in game engines + /* keeping tangents normalized at vertex level + * corresponds better to how it's done in game engines */ if (obi->flag & R_TRANSFORMED) { mul_mat3_m4_v3(obi->mat, c0); normalize_v3(c0); mul_mat3_m4_v3(obi->mat, c1); normalize_v3(c1); mul_mat3_m4_v3(obi->mat, c2); normalize_v3(c2); } - - // we don't normalize the interpolated TBN tangent - // corresponds better to how it's done in game engines + + /* we don't normalize the interpolated TBN tangent + * corresponds better to how it's done in game engines */ shi->nmaptang[0]= (tl*c2[0] - tu*c0[0] - tv*c1[0]); shi->nmaptang[1]= (tl*c2[1] - tu*c0[1] - tv*c1[1]); shi->nmaptang[2]= (tl*c2[2] - tu*c0[2] - tv*c1[2]); - // the sign is the same for all 3 vertices of any - // non degenerate triangle. + /* the sign is the same for all 3 vertices of any + * non degenerate triangle. */ shi->nmaptang[3]= tangent[j1*4+3]; } } diff --git a/source/blender/render/intern/source/shadeoutput.c b/source/blender/render/intern/source/shadeoutput.c index 82f2add7c3d..e209baa49a8 100644 --- a/source/blender/render/intern/source/shadeoutput.c +++ b/source/blender/render/intern/source/shadeoutput.c @@ -173,7 +173,7 @@ static void spothalo(struct LampRen *lar, ShadeInput *shi, float *intens) p1[1]= shi->co[1]-lar->co[1]; p1[2]= -lar->co[2]; mul_m3_v3(lar->imat, p1); - copy_v3db_v3fl(npos, p1); // npos is double! + copy_v3db_v3fl(npos, p1); /* npos is double! */ /* pre-scale */ npos[2] *= (double)lar->sh_zfac; @@ -371,11 +371,12 @@ void renderspothalo(ShadeInput *shi, float col[4], float alpha) continue; spothalo(lar, shi, &i); - if (i>0.0f) { - col[3]+= i*alpha; // all premul - col[0]+= i*lar->r*alpha; - col[1]+= i*lar->g*alpha; - col[2]+= i*lar->b*alpha; + if (i > 0.0f) { + const float i_alpha = i * alpha; + col[0] += i_alpha * lar->r; + col[1] += i_alpha * lar->g; + col[2] += i_alpha * lar->b; + col[3] += i_alpha; /* all premul */ } } } @@ -519,7 +520,7 @@ static float area_lamp_energy_multisample(LampRen *lar, const float co[3], float } intens /= (float)lar->ray_totsamp; - return pow(intens*lar->areasize, lar->k); // corrected for buttons size and lar->dist^2 + return pow(intens * lar->areasize, lar->k); /* corrected for buttons size and lar->dist^2 */ } static float spec(float inp, int hard) @@ -798,7 +799,6 @@ static float OrenNayar_Diff(float nl, const float n[3], const float l[3], const /* Minnaert diffuse */ static float Minnaert_Diff(float nl, const float n[3], const float v[3], float darkness) { - float i, nv; /* nl = dot product between surface normal and light vector */ @@ -806,12 +806,12 @@ static float Minnaert_Diff(float nl, const float n[3], const float v[3], float d return 0.0f; /* nv = dot product between surface normal and view vector */ - nv = n[0]*v[0]+n[1]*v[1]+n[2]*v[2]; + nv = dot_v3v3(n, v); if (nv < 0.0f) nv = 0.0f; if (darkness <= 1.0f) - i = nl * pow(MAX2(nv*nl, 0.1f), (darkness - 1.0f) ); /*The Real model*/ + i = nl * pow(maxf(nv * nl, 0.1f), (darkness - 1.0f) ); /*The Real model*/ else i = nl * pow( (1.001f - nv), (darkness - 1.0f) ); /*Nvidia model*/ @@ -933,7 +933,7 @@ static void add_to_diffuse(float *diff, ShadeInput *shi, float is, float r, floa /* MA_RAMP_IN_RESULT is exceptional */ if (ma->rampin_col==MA_RAMP_IN_RESULT) { - // normal add + /* normal add */ diff[0] += r * shi->r; diff[1] += g * shi->g; diff[2] += b * shi->b; @@ -1369,10 +1369,10 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int /* diffuse shaders */ if (lar->mode & LA_NO_DIFF) { - is= 0.0f; // skip shaders + is = 0.0f; /* skip shaders */ } else if (lar->type==LA_HEMI) { - is= 0.5f*inp + 0.5f; + is = 0.5f * inp + 0.5f; } else { @@ -1384,12 +1384,13 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int else if (ma->diff_shader==MA_DIFF_TOON) is= Toon_Diff(vn, lv, view, ma->param[0], ma->param[1]); else if (ma->diff_shader==MA_DIFF_MINNAERT) is= Minnaert_Diff(inp, vn, view, ma->darkness); else if (ma->diff_shader==MA_DIFF_FRESNEL) is= Fresnel_Diff(vn, lv, view, ma->param[0], ma->param[1]); - else is= inp; // Lambert + else is= inp; /* Lambert */ } - + /* 'is' is diffuse */ - if ((ma->shade_flag & MA_CUBIC) && is>0.0f && is<1.0f) - is= 3.0f*is*is - 2.0f*is*is*is; // nicer termination of shades + if ((ma->shade_flag & MA_CUBIC) && is > 0.0f && is < 1.0f) { + is= 3.0f * is * is - 2.0f * is * is * is; /* nicer termination of shades */ + } i= is*phongcorr; @@ -1398,7 +1399,7 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int } i_noshad= i; - vn= shi->vn; // bring back original vector, we use special specular shaders for tangent + vn = shi->vn; /* bring back original vector, we use special specular shaders for tangent */ if (ma->mode & MA_TANGENT_V) vn= shi->tang; @@ -1729,7 +1730,7 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr) return; } - if ( (ma->mode & (MA_VERTEXCOL|MA_VERTEXCOLP))== MA_VERTEXCOL ) { // vertexcolor light + if ( (ma->mode & (MA_VERTEXCOL|MA_VERTEXCOLP))== MA_VERTEXCOL ) { /* vertexcolor light */ shr->emit[0]= shi->r*(shi->emit+shi->vcol[0]*shi->vcol[3]); shr->emit[1]= shi->g*(shi->emit+shi->vcol[1]*shi->vcol[3]); shr->emit[2]= shi->b*(shi->emit+shi->vcol[2]*shi->vcol[3]); @@ -1750,8 +1751,8 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr) if (shi->depth || shi->volume_depth) ambient_occlusion(shi); copy_v3_v3(shr->ao, shi->ao); - copy_v3_v3(shr->env, shi->env); // XXX multiply - copy_v3_v3(shr->indirect, shi->indirect); // XXX multiply + copy_v3_v3(shr->env, shi->env); /* XXX multiply */ + copy_v3_v3(shr->indirect, shi->indirect); /* XXX multiply */ } } } diff --git a/source/blender/render/intern/source/sunsky.c b/source/blender/render/intern/source/sunsky.c index 9187bea641d..ddc7dff7b06 100644 --- a/source/blender/render/intern/source/sunsky.c +++ b/source/blender/render/intern/source/sunsky.c @@ -174,7 +174,7 @@ void InitSunSky(struct SunSky *sunsky, float turb, float *toSun, float horizon_b DirectionToThetaPhi(sunsky->toSun, &sunsky->theta, &sunsky->phi); - sunsky->sunSolidAngle = 0.25 * M_PI * 1.39 * 1.39 / (150 * 150); // = 6.7443e-05 + sunsky->sunSolidAngle = 0.25 * M_PI * 1.39 * 1.39 / (150 * 150); /* = 6.7443e-05 */ theta2 = sunsky->theta * sunsky->theta; theta3 = theta2 * sunsky->theta; @@ -183,7 +183,7 @@ void InitSunSky(struct SunSky *sunsky, float turb, float *toSun, float horizon_b chi = (4.0f / 9.0f - T / 120.0f) * ((float)M_PI - 2.0f * sunsky->theta); sunsky->zenith_Y = (4.0453f * T - 4.9710f) * tanf(chi) - 0.2155f * T + 2.4192f; - sunsky->zenith_Y *= 1000; // conversion from kcd/m^2 to cd/m^2 + sunsky->zenith_Y *= 1000; /* conversion from kcd/m^2 to cd/m^2 */ if (sunsky->zenith_Y <= 0) sunsky->zenith_Y = 1e-6; @@ -272,7 +272,7 @@ void GetSkyXYZRadiance(struct SunSky *sunsky, float theta, float phi, float colo gamma = AngleBetween(theta, phi, sunsky->theta, sunsky->phi); - // Compute xyY values + /* Compute xyY values */ x = PerezFunction(sunsky, sunsky->perez_x, theta, gamma, sunsky->zenith_x); y = PerezFunction(sunsky, sunsky->perez_y, theta, gamma, sunsky->zenith_y); Y = 6.666666667e-5f *nfade *hfade *PerezFunction(sunsky, sunsky->perez_Y, theta, gamma, sunsky->zenith_Y); @@ -340,13 +340,13 @@ static void ComputeAttenuatedSunlight(float theta, int turbidity, float fTau[3]) m = 1.0f / (cosf(theta) + 0.15f * powf(93.885f - theta / (float)M_PI * 180.0f, -1.253f)); for (i = 0; i < 3; i++) { - // Rayleigh Scattering + /* Rayleigh Scattering */ fTauR = expf(-m * 0.008735f * powf(fLambda[i], (float)(-4.08f))); - // Aerosal (water + dust) attenuation + /* Aerosal (water + dust) attenuation */ fTauA = exp(-m * fBeta * powf(fLambda[i], -fAlpha)); - fTau[i] = fTauR * fTauA; + fTau[i] = fTauR * fTauA; } } @@ -366,7 +366,7 @@ void InitAtmosphere(struct SunSky *sunSky, float sun_intens, float mief, float r float inscattf, float extincf, float disf) { const float pi = M_PI; - const float n = 1.003f; // refractive index + const float n = 1.003f; /* refractive index */ const float N = 2.545e25; const float pn = 0.035f; const float T = 2.0f; @@ -406,16 +406,16 @@ void InitAtmosphere(struct SunSky *sunSky, float sun_intens, float mief, float r vLambda4[1] = fLambda4[1]; vLambda4[2] = fLambda4[2]; - // Rayleigh scattering constants. + /* Rayleigh scattering constants. */ fTemp = pi * pi * (n * n - 1) * (n * n - 1) * (6 + 3 * pn) / (6 - 7 * pn) / N; fBeta = 8 * fTemp * pi / 3; - + VEC3OPF(sunSky->atm_BetaRay, vLambda4, *, fBeta); fBetaDash = fTemp / 2; VEC3OPF(sunSky->atm_BetaDashRay, vLambda4, *, fBetaDash); - - // Mie scattering constants. + + /* Mie scattering constants. */ fTemp2 = 0.434f * c * (2 * pi) * (2 * pi) * 0.5f; VEC3OPF(sunSky->atm_BetaDashMie, vLambda2, *, fTemp2); @@ -457,23 +457,23 @@ void AtmospherePixleShader(struct SunSky *sunSky, float view[3], float s, float sunDirection[0] = sunSky->toSun[0]; sunDirection[1] = sunSky->toSun[1]; sunDirection[2] = sunSky->toSun[2]; - - costheta = dot_v3v3(view, sunDirection); // cos(theta) - Phase_1 = 1 + (costheta * costheta); // Phase_1 - + + costheta = dot_v3v3(view, sunDirection); /* cos(theta) */ + Phase_1 = 1 + (costheta * costheta); /* Phase_1 */ + VEC3OPF(sunSky->atm_BetaRay, sunSky->atm_BetaRay, *, sunSky->atm_BetaRayMultiplier); VEC3OPF(sunSky->atm_BetaMie, sunSky->atm_BetaMie, *, sunSky->atm_BetaMieMultiplier); VEC3OPV(sunSky->atm_BetaRM, sunSky->atm_BetaRay, +, sunSky->atm_BetaMie); - - //e^(-(beta_1 + beta_2) * s) = E1 + + /* e^(-(beta_1 + beta_2) * s) = E1 */ VEC3OPF(E1, sunSky->atm_BetaRM, *, -s / (float)M_LN2); E1[0] = exp(E1[0]); E1[1] = exp(E1[1]); E1[2] = exp(E1[2]); copy_v3_v3(E, E1); - - //Phase2(theta) = (1-g^2)/(1+g-2g*cos(theta))^(3/2) + + /* Phase2(theta) = (1-g^2)/(1+g-2g*cos(theta))^(3/2) */ fTemp = 1 + sunSky->atm_HGg - 2 * sunSky->atm_HGg * costheta; fTemp = fTemp * sqrtf(fTemp); Phase_2 = (1 - sunSky->atm_HGg * sunSky->atm_HGg) / fTemp; @@ -491,8 +491,8 @@ void AtmospherePixleShader(struct SunSky *sunSky, float view[3], float s, float VEC3OPF(I, I, *, sunSky->atm_InscatteringMultiplier); VEC3OPF(E, E, *, sunSky->atm_ExtinctionMultiplier); - - //scale to color sun + + /* scale to color sun */ ComputeAttenuatedSunlight(sunSky->theta, sunSky->turbidity, sunColor); VEC3OPV(E, E, *, sunColor); diff --git a/source/blender/render/intern/source/texture_ocean.c b/source/blender/render/intern/source/texture_ocean.c index 4ef88e4740a..5071303dff7 100644 --- a/source/blender/render/intern/source/texture_ocean.c +++ b/source/blender/render/intern/source/texture_ocean.c @@ -81,12 +81,12 @@ int ocean_texture(Tex *tex, float *texvec, TexResult *texres) if (omd->oceancache && omd->cached == TRUE) { CLAMP(cfra, omd->bakestart, omd->bakeend); - cfra -= omd->bakestart; // shift to 0 based + cfra -= omd->bakestart; /* shift to 0 based */ BKE_ocean_cache_eval_uv(omd->oceancache, &ocr, cfra, u, v); } - else { // non-cached + else { /* non-cached */ if (G.rendering) BKE_ocean_eval_uv_catrom(omd->ocean, &ocr, u, v); diff --git a/source/blender/render/intern/source/volume_precache.c b/source/blender/render/intern/source/volume_precache.c index ea6b9b890ac..8a92695a15e 100644 --- a/source/blender/render/intern/source/volume_precache.c +++ b/source/blender/render/intern/source/volume_precache.c @@ -261,14 +261,14 @@ static void lightcache_filter2(VolumePrecache *vp) } #endif -BLI_INLINE int ms_I(int x, int y, int z, int *n) //has a pad of 1 voxel surrounding the core for boundary simulation -{ +BLI_INLINE int ms_I(int x, int y, int z, int *n) /* has a pad of 1 voxel surrounding the core for boundary simulation */ +{ /* different ordering to light cache */ - return x*(n[1]+2)*(n[2]+2) + y*(n[2]+2) + z; + return x*(n[1]+2)*(n[2]+2) + y*(n[2]+2) + z; } -BLI_INLINE int v_I_pad(int x, int y, int z, int *n) //has a pad of 1 voxel surrounding the core for boundary simulation -{ +BLI_INLINE int v_I_pad(int x, int y, int z, int *n) /* has a pad of 1 voxel surrounding the core for boundary simulation */ +{ /* same ordering to light cache, with padding */ return z*(n[1]+2)*(n[0]+2) + y*(n[0]+2) + x; } @@ -465,7 +465,7 @@ static void multiple_scattering_diffusion(Render *re, VolumePrecache *vp, Materi -#if 0 // debug stuff +#if 0 /* debug stuff */ static void *vol_precache_part_test(void *data) { VolPrecachePart *pa = data; @@ -526,10 +526,10 @@ static void *vol_precache_part(void *data) /* convert from world->camera space for shading */ mul_v3_m4v3(cco, pa->viewmat, co); - + i = BLI_VOXEL_INDEX(x, y, z, res); - - // don't bother if the point is not inside the volume mesh + + /* don't bother if the point is not inside the volume mesh */ if (!point_inside_obi(tree, obi, cco)) { obi->volume_precache->data_r[i] = -1.0f; obi->volume_precache->data_g[i] = -1.0f; @@ -563,7 +563,7 @@ static void precache_setup_shadeinput(Render *re, ObjectInstanceRen *obi, Materi shi->mask= 1; shi->mat = ma; shi->vlr = NULL; - memcpy(&shi->r, &shi->mat->r, 23*sizeof(float)); // note, keep this synced with render_types.h + memcpy(&shi->r, &shi->mat->r, 23*sizeof(float)); /* note, keep this synced with render_types.h */ shi->har= shi->mat->har; shi->obi= obi; shi->obr= obi->obr; @@ -757,7 +757,8 @@ static void vol_precache_objectinstance_threads(Render *re, ObjectInstanceRen *o BLI_freelistN(&re->volume_precache_parts); if (tree) { - //TODO: makeraytree_object creates a tree and saves it on OBI, if we free this tree we should also clear other pointers to it + /* TODO: makeraytree_object creates a tree and saves it on OBI, + * if we free this tree we should also clear other pointers to it */ //RE_rayobject_free(tree); //tree= NULL; } diff --git a/source/blender/render/intern/source/volumetric.c b/source/blender/render/intern/source/volumetric.c index c1f85914479..67e453577e4 100644 --- a/source/blender/render/intern/source/volumetric.c +++ b/source/blender/render/intern/source/volumetric.c @@ -253,9 +253,9 @@ static float metadensity(Object *ob, const float co[3]) /* element rotation transform */ float tp[3] = {ml->x - tco[0], ml->y - tco[1], ml->z - tco[2]}; quat_to_mat3(bmat, ml->quat); - transpose_m3(bmat); // rot.only, so inverse == transpose + transpose_m3(bmat); /* rot.only, so inverse == transpose */ mul_m3_v3(bmat, tp); - + /* MB_BALL default */ switch (ml->type) { case MB_ELIPSOID: @@ -263,14 +263,14 @@ static float metadensity(Object *ob, const float co[3]) break; case MB_CUBE: tp[2] = (tp[2] > ml->expz) ? (tp[2] - ml->expz) : ((tp[2] < -ml->expz) ? (tp[2] + ml->expz) : 0.f); - // no break, xy as plane + /* no break, xy as plane */ case MB_PLANE: tp[1] = (tp[1] > ml->expy) ? (tp[1] - ml->expy) : ((tp[1] < -ml->expy) ? (tp[1] + ml->expy) : 0.f); - // no break, x as tube + /* no break, x as tube */ case MB_TUBE: tp[0] = (tp[0] > ml->expx) ? (tp[0] - ml->expx) : ((tp[0] < -ml->expx) ? (tp[0] + ml->expx) : 0.f); } - + /* ml->rad2 is not set */ dist2 = 1.0f - (dot_v3v3(tp, tp) / (ml->rad * ml->rad)); if (dist2 > 0.f) @@ -289,7 +289,7 @@ float vol_get_density(struct ShadeInput *shi, const float co[3]) if (shi->mat->mapto_textured & MAP_DENSITY) do_volume_tex(shi, co, MAP_DENSITY, NULL, &density, &R); - // if meta-object, modulate by metadensity without increasing it + /* if meta-object, modulate by metadensity without increasing it */ if (shi->obi->obr->ob->type == OB_MBALL) { const float md = metadensity(shi->obi->obr->ob, co); if (md < 1.f) density *= md; diff --git a/source/blender/render/intern/source/voxeldata.c b/source/blender/render/intern/source/voxeldata.c index 7d54f77fc90..d73171648fb 100644 --- a/source/blender/render/intern/source/voxeldata.c +++ b/source/blender/render/intern/source/voxeldata.c @@ -240,7 +240,7 @@ static void init_frame_smoke(VoxelData *vd, float cfra) copy_v3_v3_int(vd->resol, smd->domain->res); totRes = vd_resol_size(vd); - // scaling heat values from -2.0-2.0 to 0.0-1.0 + /* scaling heat values from -2.0-2.0 to 0.0-1.0 */ vd->dataset = MEM_mapallocN(sizeof(float) * (totRes), "smoke data"); @@ -250,7 +250,7 @@ static void init_frame_smoke(VoxelData *vd, float cfra) vd->dataset[i] = (heat[i] + 2.0f) / 4.0f; } - //vd->dataset = smoke_get_heat(smd->domain->fluid); + /* vd->dataset = smoke_get_heat(smd->domain->fluid); */ } else if (vd->smoked_type == TEX_VD_SMOKEVEL) { size_t totRes; @@ -260,7 +260,7 @@ static void init_frame_smoke(VoxelData *vd, float cfra) copy_v3_v3_int(vd->resol, smd->domain->res); totRes = vd_resol_size(vd); - // scaling heat values from -2.0-2.0 to 0.0-1.0 + /* scaling heat values from -2.0-2.0 to 0.0-1.0 */ vd->dataset = MEM_mapallocN(sizeof(float) * (totRes), "smoke data"); xvel = smoke_get_velocity_x(smd->domain->fluid); @@ -290,7 +290,7 @@ static void init_frame_smoke(VoxelData *vd, float cfra) /* always store copy, as smoke internal data can change */ vd->dataset = MEM_mapallocN(sizeof(float) * (totRes), "smoke data"); memcpy(vd->dataset, density, sizeof(float) * totRes); - } // end of fluid condition + } /* end of fluid condition */ } } diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c index c88858c44da..1ebb963a790 100644 --- a/source/blender/render/intern/source/zbuf.c +++ b/source/blender/render/intern/source/zbuf.c @@ -466,7 +466,7 @@ static void zbuflineAc(ZSpan *zspan, int obi, int zvlnr, const float vec1[3], co vergz= v1[2]; vergz-= zspan->polygon_offset; dz= (v2[2]-v1[2])/dx; - if (vergz>0x50000000 && dz>0) maxtest= 1; // prevent overflow + if (vergz>0x50000000 && dz>0) maxtest= 1; /* prevent overflow */ rectz= (int *)(zspan->arectz+zspan->rectx*(oldy) +start); rectmask= (int *)(zspan->rectmask+zspan->rectx*(oldy) +start); @@ -537,7 +537,7 @@ static void zbuflineAc(ZSpan *zspan, int obi, int zvlnr, const float vec1[3], co vergz= v1[2]; vergz-= zspan->polygon_offset; dz= (v2[2]-v1[2])/dy; - if (vergz>0x50000000 && dz>0) maxtest= 1; // prevent overflow + if (vergz>0x50000000 && dz>0) maxtest= 1; /* prevent overflow */ rectz= (int *)( zspan->arectz+ (start)*zspan->rectx+ oldx ); rectmask= (int *)( zspan->rectmask+ (start)*zspan->rectx+ oldx ); @@ -619,7 +619,7 @@ static void zbufline(ZSpan *zspan, int obi, int zvlnr, const float vec1[3], cons vergz= floor(v1[2]); dz= floor((v2[2]-v1[2])/dx); - if (vergz>0x50000000 && dz>0) maxtest= 1; // prevent overflow + if (vergz>0x50000000 && dz>0) maxtest= 1; /* prevent overflow */ rectz= zspan->rectz + oldy*zspan->rectx+ start; rectp= zspan->rectp + oldy*zspan->rectx+ start; @@ -678,7 +678,7 @@ static void zbufline(ZSpan *zspan, int obi, int zvlnr, const float vec1[3], cons vergz= floor(v1[2]); dz= floor((v2[2]-v1[2])/dy); - if (vergz>0x50000000 && dz>0) maxtest= 1; // prevent overflow + if (vergz>0x50000000 && dz>0) maxtest= 1; /* prevent overflow */ rectz= zspan->rectz + start*zspan->rectx+ oldx; rectp= zspan->rectp + start*zspan->rectx+ oldx; @@ -749,7 +749,7 @@ static void zbufline_onlyZ(ZSpan *zspan, int UNUSED(obi), int UNUSED(zvlnr), con vergz= floor(v1[2]); dz= floor((v2[2]-v1[2])/dx); - if (vergz>0x50000000 && dz>0) maxtest= 1; // prevent overflow + if (vergz>0x50000000 && dz>0) maxtest= 1; /* prevent overflow */ rectz= zspan->rectz + oldy*zspan->rectx+ start; if (zspan->rectz1) @@ -806,8 +806,8 @@ static void zbufline_onlyZ(ZSpan *zspan, int UNUSED(obi), int UNUSED(zvlnr), con vergz= floor(v1[2]); dz= floor((v2[2]-v1[2])/dy); - if (vergz>0x50000000 && dz>0) maxtest= 1; // prevent overflow - + if (vergz>0x50000000 && dz>0) maxtest= 1; /* prevent overflow */ + rectz= zspan->rectz + start*zspan->rectx+ oldx; if (zspan->rectz1) rectz1= zspan->rectz1 + start*zspan->rectx+ oldx; @@ -1447,21 +1447,21 @@ void zspan_scanconvert_strand(ZSpan *zspan, void *handle, float *v1, float *v2, zxd= -(double)x0/(double)z0; zyd= -(double)y0/(double)z0; zy0= ((double)my2)*zyd + (double)xx1; - - z1= 1.0f; // (u1 - u2) - z2= 0.0f; // (u2 - u3) + + z1= 1.0f; /* (u1 - u2) */ + z2= 0.0f; /* (u2 - u3) */ x0= y1*z2-z1*y2; y0= z1*x2-x1*z2; - - xx1= (x0*v1[0] + y0*v1[1])/z0 + 1.0f; + + xx1= (x0*v1[0] + y0*v1[1])/z0 + 1.0f; uxd= -(double)x0/(double)z0; uyd= -(double)y0/(double)z0; uy0= ((double)my2)*uyd + (double)xx1; - z1= -1.0f; // (v1 - v2) - z2= 1.0f; // (v2 - v3) - + z1= -1.0f; /* (v1 - v2) */ + z2= 1.0f; /* (v2 - v3) */ + x0= y1*z2-z1*y2; y0= z1*x2-x1*z2; @@ -1535,23 +1535,23 @@ void zspan_scanconvert(ZSpan *zspan, void *handle, float *v1, float *v2, float * y1= v1[1]- v2[1]; y2= v2[1]- v3[1]; - z1= 1.0f; // (u1 - u2) - z2= 0.0f; // (u2 - u3) - + z1= 1.0f; /* (u1 - u2) */ + z2= 0.0f; /* (u2 - u3) */ + x0= y1*z2-z1*y2; y0= z1*x2-x1*z2; z0= x1*y2-y1*x2; - + if (z0==0.0f) return; - - xx1= (x0*v1[0] + y0*v1[1])/z0 + 1.0f; + + xx1= (x0*v1[0] + y0*v1[1])/z0 + 1.0f; uxd= -(double)x0/(double)z0; uyd= -(double)y0/(double)z0; uy0= ((double)my2)*uyd + (double)xx1; - z1= -1.0f; // (v1 - v2) - z2= 1.0f; // (v2 - v3) - + z1= -1.0f; /* (v1 - v2) */ + z2= 1.0f; /* (v2 - v3) */ + x0= y1*z2-z1*y2; y0= z1*x2-x1*z2; diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c index 039f3bff4d1..bb985802e23 100644 --- a/source/blender/windowmanager/intern/wm_cursors.c +++ b/source/blender/windowmanager/intern/wm_cursors.c @@ -191,7 +191,7 @@ void WM_cursor_grab(wmWindow *win, int wrap, int hide, int *bounds) if ((G.debug & G_DEBUG) == 0) { if (win && win->ghostwin) { const GHOST_TabletData *tabletdata = GHOST_GetTabletData(win->ghostwin); - // Note: There is no tabletdata on Windows if no tablet device is connected. + /* Note: There is no tabletdata on Windows if no tablet device is connected. */ if (!tabletdata) GHOST_SetCursorGrab(win->ghostwin, mode, bounds); else if (tabletdata->Active == GHOST_kTabletModeNone) diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 3d1902409e8..cb0f9c226b4 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -315,7 +315,7 @@ static int wm_read_exotic(Scene *UNUSED(scene), const char *name) char header[7]; int retval; - // make sure we're not trying to read a directory.... + /* make sure we're not trying to read a directory.... */ len = strlen(name); if (ELEM(name[len - 1], '/', '\\')) { diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index cabc51a6e5b..0a9d8658000 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -232,21 +232,21 @@ int WM_init_game(bContext *C) Scene *scene = CTX_data_scene(C); if (!scene) { - // XXX, this should not be needed. + /* XXX, this should not be needed. */ Main *bmain = CTX_data_main(C); scene = bmain->scene.first; } win = wm->windows.first; - //first to get a valid window + /* first to get a valid window */ if (win) CTX_wm_window_set(C, win); sa = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_VIEW3D, 0); ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); - // if we have a valid 3D view + /* if we have a valid 3D view */ if (sa && ar) { ARegion *arhide; diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 18caa8c2afe..eb6da146a73 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -329,7 +329,7 @@ static void keymap_item_set_id(wmKeyMap *keymap, wmKeyMapItem *kmi) kmi->id = keymap->kmi_id; } else { - kmi->id = -keymap->kmi_id; // User defined keymap entries have negative ids + kmi->id = -keymap->kmi_id; /* User defined keymap entries have negative ids */ } } diff --git a/source/blender/windowmanager/intern/wm_subwindow.c b/source/blender/windowmanager/intern/wm_subwindow.c index d599b9504e8..0b9dc441227 100644 --- a/source/blender/windowmanager/intern/wm_subwindow.c +++ b/source/blender/windowmanager/intern/wm_subwindow.c @@ -331,12 +331,12 @@ unsigned int index_to_framebuffer(int index) break; case 24: break; - default: // 18 bits... + default: /* 18 bits... */ i = ((i & 0x3F000) << 6) + ((i & 0xFC0) << 4) + ((i & 0x3F) << 2); i |= 0x010101; break; } - + return i; } @@ -365,7 +365,7 @@ unsigned int index_to_framebuffer(int index) break; case 24: break; - default: // 18 bits... + default: /* 18 bits... */ i = ((i & 0x3F000) << 6) + ((i & 0xFC0) << 4) + ((i & 0x3F) << 2); i |= 0x030303; break; |