diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-07-14 03:23:06 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-07-14 03:23:06 +0400 |
commit | 065605e0da8ecd7add39f159db624ae9063ec476 (patch) | |
tree | 46cb2051e28dcef4a04a998e2d9ef82a7b36ecfa /source/blender/blenkernel | |
parent | b7b50298148ef502d14143b0a5fa01dfac2ecce4 (diff) | |
parent | 807ad1f0e0de49711d58ade2b660e74ec5452b2b (diff) |
Merged changes in the trunk up to revision 48893.
Conflicts resolved:
source/blender/blenkernel/CMakeLists.txt
source/blender/blenloader/intern/readfile.c
source/blender/editors/animation/anim_filter.c
source/blender/makesrna/RNA_enum_types.h
Diffstat (limited to 'source/blender/blenkernel')
54 files changed, 1499 insertions, 509 deletions
diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 171b62461a0..48c7103d8fd 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -42,7 +42,7 @@ extern "C" { * and keep comment above the defines. * Use STRINGIFY() rather than defining with quotes */ #define BLENDER_VERSION 263 -#define BLENDER_SUBVERSION 13 +#define BLENDER_SUBVERSION 14 #define BLENDER_MINVERSION 250 #define BLENDER_MINSUBVERSION 0 diff --git a/source/blender/blenkernel/BKE_idprop.h b/source/blender/blenkernel/BKE_idprop.h index 2436ada9eaf..3cf4a2c5cdc 100644 --- a/source/blender/blenkernel/BKE_idprop.h +++ b/source/blender/blenkernel/BKE_idprop.h @@ -60,15 +60,33 @@ 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); +#ifdef __GNUC__ +__attribute__((nonnull)) +#endif +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 +95,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 (2))) /* 'name' arg */ +#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 +130,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 +169,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 (1, 3))) /* 'group', 'pnew' */ +#endif +; /** \note this does not free the property!! * @@ -130,18 +190,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 +227,44 @@ 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)) +#endif +; /** * Allocate a new ID. @@ -190,7 +291,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/BKE_mask.h b/source/blender/blenkernel/BKE_mask.h index ee7c13ba7cb..50d8576dd91 100644 --- a/source/blender/blenkernel/BKE_mask.h +++ b/source/blender/blenkernel/BKE_mask.h @@ -64,12 +64,15 @@ void BKE_mask_layer_copy_list(struct ListBase *masklayers_new, struct ListBase * /* splines */ struct MaskSpline *BKE_mask_spline_add(struct MaskLayer *masklay); +int BKE_mask_spline_differentiate_calc_total(const struct MaskSpline *spline, const int resol); + float (*BKE_mask_spline_differentiate(struct MaskSpline *spline, int *tot_diff_point))[2]; float (*BKE_mask_spline_feather_differentiated_points(struct MaskSpline *spline, int *tot_feather_point))[2]; +float (*BKE_mask_spline_differentiate_with_resolution_ex(struct MaskSpline *spline, const int resol, int *tot_diff_point))[2]; float (*BKE_mask_spline_differentiate_with_resolution(struct MaskSpline *spline, int width, int height, int *tot_diff_point))[2]; -float (*BKE_mask_spline_feather_differentiated_points_with_resolution(struct MaskSpline *spline, - int width, int height, int *tot_feather_point))[2]; +float (*BKE_mask_spline_feather_differentiated_points_with_resolution_ex(struct MaskSpline *spline, const int resol, int *tot_feather_point))[2]; +float (*BKE_mask_spline_feather_differentiated_points_with_resolution(struct MaskSpline *spline, int width, int height, int *tot_feather_point))[2]; float (*BKE_mask_spline_feather_points(struct MaskSpline *spline, int *tot_feather_point))[2]; @@ -184,6 +187,12 @@ void BKE_mask_rasterize(struct Mask *mask, int width, int height, float *buffer, const short do_aspect_correct, const short do_mask_aa, const short do_feather); +/* initialization for tiling */ +#ifdef __PLX_RASKTER_MT__ +void BKE_mask_init_layers(Mask *mask, struct layer_init_data *mlayer_data, int width, int height, + const short do_aspect_correct); +#endif + #define MASKPOINT_ISSEL_ANY(p) ( ((p)->bezt.f1 | (p)->bezt.f2 | (p)->bezt.f2) & SELECT) #define MASKPOINT_ISSEL_KNOT(p) ( (p)->bezt.f2 & SELECT) #define MASKPOINT_ISSEL_HANDLE_ONLY(p) ( (((p)->bezt.f1 | (p)->bezt.f2) & SELECT) && (((p)->bezt.f2 & SELECT) == 0) ) @@ -196,4 +205,21 @@ void BKE_mask_rasterize(struct Mask *mask, int width, int height, float *buffer, #define MASKPOINT_SEL_HANDLE(p) { (p)->bezt.f1 |= SELECT; (p)->bezt.f3 |= SELECT; } (void)0 #define MASKPOINT_DESEL_HANDLE(p) { (p)->bezt.f1 &= ~SELECT; (p)->bezt.f3 &= ~SELECT; } (void)0 -#endif +/* disable to test alternate rasterizer */ +#define USE_RASKTER + +/* mask_rasterize.c */ +#ifndef USE_RASKTER +struct MaskRasterHandle; +typedef struct MaskRasterHandle MaskRasterHandle; + +MaskRasterHandle *BLI_maskrasterize_handle_new(void); +void BLI_maskrasterize_handle_free(MaskRasterHandle *mr_handle); +void BLI_maskrasterize_handle_init(MaskRasterHandle *mr_handle, struct Mask *mask, + const int width, const int height, + const short do_aspect_correct, const short do_mask_aa, + const short do_feather); +float BLI_maskrasterize_handle_sample(MaskRasterHandle *mr_handle, const float xy[2]); +#endif /* USE_RASKTER */ + +#endif /* __BKE_MASK_H__ */ diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index b3f17c06d5c..7bd9f75b2dd 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -660,6 +660,7 @@ void ntreeGPUMaterialNodes(struct bNodeTree *ntree, struct GPUMaterial *mat); #define CMP_NODE_MASK 268 #define CMP_NODE_KEYINGSCREEN 269 #define CMP_NODE_KEYING 270 +#define CMP_NODE_TRACKPOS 271 #define CMP_NODE_GLARE 301 #define CMP_NODE_TONEMAP 302 diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index 723a0e32605..1bafc023740 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -103,6 +103,7 @@ set(SRC intern/lattice.c intern/library.c intern/linestyle.c + intern/mask_rasterize.c intern/mask.c intern/material.c intern/mball.c 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 e4ecdf245d1..ea625ec7699 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: @@ -232,7 +232,7 @@ void BKE_free_animdata(ID *id) free_fcurves(&adt->drivers); /* free overrides */ - // TODO... + /* TODO... */ /* free animdata now */ MEM_freeN(adt); @@ -335,7 +335,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) @@ -506,8 +506,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); } @@ -535,9 +535,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; } @@ -604,7 +604,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); @@ -914,7 +914,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; @@ -943,7 +943,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 */ @@ -1026,7 +1026,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; @@ -1123,11 +1123,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; @@ -1223,8 +1225,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>", @@ -1432,11 +1434,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); } @@ -1518,7 +1520,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; @@ -1675,7 +1677,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 @@ -1871,7 +1873,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; @@ -1935,11 +1937,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; @@ -2004,7 +2006,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; } } @@ -2088,7 +2090,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; } @@ -2114,10 +2116,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); @@ -2137,9 +2139,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 /* -------------------- */ @@ -2209,7 +2211,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/blender.c b/source/blender/blenkernel/intern/blender.c index 0def299c24a..9e222307aa9 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -301,8 +301,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 7acbcbf6c93..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" + /* 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/colortools.c b/source/blender/blenkernel/intern/colortools.c index 6879ec506f0..31ad4d0380a 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -71,7 +71,7 @@ CurveMapping *curvemapping_add(int tot, float minx, float miny, float maxx, floa clipmaxx = MAX2(minx, maxx); clipmaxy = MAX2(miny, maxy); - BLI_init_rctf(&cumap->curr, clipminx, clipmaxx, clipminy, clipmaxy); + BLI_rctf_init(&cumap->curr, clipminx, clipmaxx, clipminy, clipmaxy); cumap->clipr = cumap->curr; cumap->white[0] = cumap->white[1] = cumap->white[2] = 1.0f; 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..4026d3f06d3 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; @@ -365,10 +365,10 @@ static void dag_add_material_nodetree_driver_relations(DagForest *dag, DagNode * /* nodetree's nodes... */ for (n = ntree->nodes.first; n; n = n->next) { if (n->id && GS(n->id->name) == ID_MA) { - ma = (Material *)n->id; - if (ma != rootma) { - dag_add_material_driver_relations(dag, node, ma); - } + ma = (Material *)n->id; + if (ma != rootma) { + dag_add_material_driver_relations(dag, node, ma); + } } else if (n->type == NODE_GROUP && n->id) { dag_add_material_nodetree_driver_relations(dag, node, (bNodeTree *)n->id, rootma); @@ -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; @@ -672,7 +672,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O * engine instancing assumes particular ordering of objects in list */ dag_add_relation(dag, node, node2, DAG_RL_OB_OB, "Particle Object Visualization"); if (part->dup_ob->type == OB_MBALL) - dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA, "Particle Object Visualization"); + dag_add_relation(dag, node, node2, DAG_RL_DATA_DATA, "Particle Object Visualization"); } if (part->ren_as == PART_DRAW_GR && part->dup_group) { @@ -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 6e5d6ffb0e9..9b349598db1 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -499,16 +499,14 @@ void BKE_displist_fill(ListBase *dispbase, ListBase *to, int flipnormal) /* vert data */ f1 = dlnew->verts; totvert = 0; - sf_vert = sf_ctx.fillvertbase.first; - while (sf_vert) { + + for (sf_vert = sf_ctx.fillvertbase.first; sf_vert; sf_vert = sf_vert->next) { copy_v3_v3(f1, sf_vert->co); f1 += 3; /* index number */ sf_vert->tmp.l = totvert; totvert++; - - sf_vert = sf_vert->next; } /* index data */ 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..97b245bd067 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -285,12 +285,12 @@ int list_find_data_fcurves(ListBase *dst, ListBase *src, const char *dataPrefix, for (fcu = src->first; fcu; fcu = fcu->next) { /* check if quoted string matches the path */ if ((fcu->rna_path) && strstr(fcu->rna_path, dataPrefix)) { - char *quotedName = BLI_getQuotedStr(fcu->rna_path, dataPrefix); + char *quotedName = BLI_str_quoted_substrN(fcu->rna_path, dataPrefix); if (quotedName) { /* check if the quoted name matches the required name */ if (strcmp(quotedName, dataName) == 0) { - LinkData *ld = MEM_callocN(sizeof(LinkData), "list_find_data_fcurves"); + LinkData *ld = MEM_callocN(sizeof(LinkData), __func__); ld->data = fcu; BLI_addtail(dst, ld); @@ -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 5d33c8fbcbf..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--) { @@ -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..a65d03e64cf 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) @@ -603,7 +604,9 @@ IDProperty *IDP_CopyProperty(IDProperty *prop) IDProperty *IDP_GetProperties(ID *id, int create_if_needed) { - if (id->properties) return id->properties; + if (id->properties) { + return id->properties; + } else { if (create_if_needed) { id->properties = MEM_callocN(sizeof(IDProperty), "IDProperty"); diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index d2a2412843a..658be1fb494 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1216,7 +1216,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; @@ -1297,7 +1297,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; @@ -1312,6 +1312,31 @@ void BKE_imbuf_to_image_format(struct ImageFormatData *im_format, const ImBuf *i } +static void timecode_simple_string(char *text, size_t text_size, const int cfra, int const frs_sec) +{ + int f = (int)(cfra % frs_sec); + int s = (int)(cfra / frs_sec); + int h = 0; + int m = 0; + + if (s) { + m = (int)(s / 60); + s %= 60; + + if (m) { + h = (int)(m / 60); + m %= 60; + } + } + + if (frs_sec < 100) { + BLI_snprintf(text, text_size, "%02d:%02d:%02d.%02d", h, m, s, f); + } + else { + BLI_snprintf(text, text_size, "%02d:%02d:%02d.%03d", h, m, s, f); + } +} + /* could allow access externally - 512 is for long names, 64 is for id names */ typedef struct StampData { char file[512]; @@ -1371,26 +1396,7 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d } if (scene->r.stamp & R_STAMP_TIME) { - int f = (int)(scene->r.cfra % scene->r.frs_sec); - int s = (int)(scene->r.cfra / scene->r.frs_sec); - int h = 0; - int m = 0; - - if (s) { - m = (int)(s / 60); - s %= 60; - - if (m) { - h = (int)(m / 60); - m %= 60; - } - } - - if (scene->r.frs_sec < 100) - BLI_snprintf(text, sizeof(text), "%02d:%02d:%02d.%02d", h, m, s, f); - else - BLI_snprintf(text, sizeof(text), "%02d:%02d:%02d.%03d", h, m, s, f); - + timecode_simple_string(text, sizeof(text), scene->r.cfra, scene->r.frs_sec); BLI_snprintf(stamp_data->time, sizeof(stamp_data->time), do_prefix ? "Time %s" : "%s", text); } else { 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 1cd2d159431..d3ca785caaf 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1357,7 +1357,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) { @@ -1366,7 +1366,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/mask.c b/source/blender/blenkernel/intern/mask.c index b400332db81..4e683d1618f 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -314,14 +314,32 @@ static int BKE_mask_spline_feather_resolution(MaskSpline *spline, int width, int return resol; } -float (*BKE_mask_spline_differentiate_with_resolution(MaskSpline *spline, int width, int height, - int *tot_diff_point))[2] +int BKE_mask_spline_differentiate_calc_total(const MaskSpline *spline, const int resol) +{ + int len; + + /* count */ + len = (spline->tot_point - 1) * resol; + + if (spline->flag & MASK_SPLINE_CYCLIC) { + len += resol; + } + else { + len++; + } + + return len; +} + +float (*BKE_mask_spline_differentiate_with_resolution_ex(MaskSpline *spline, const int resol, + int *tot_diff_point))[2] { MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline); MaskSplinePoint *point, *prev; float (*diff_points)[2], (*fp)[2]; - int a, len, resol = BKE_mask_spline_resolution(spline, width, height); + const int tot = BKE_mask_spline_differentiate_calc_total(spline, resol); + int a; if (spline->tot_point <= 1) { /* nothing to differentiate */ @@ -329,17 +347,9 @@ float (*BKE_mask_spline_differentiate_with_resolution(MaskSpline *spline, int wi return NULL; } - /* count */ - len = (spline->tot_point - 1) * resol; - - if (spline->flag & MASK_SPLINE_CYCLIC) - len += resol; - else - len++; - /* len+1 because of 'forward_diff_bezier' function */ - *tot_diff_point = len; - diff_points = fp = MEM_mallocN((len + 1) * sizeof(*diff_points), "mask spline vets"); + *tot_diff_point = tot; + diff_points = fp = MEM_mallocN((tot + 1) * sizeof(*diff_points), "mask spline vets"); a = spline->tot_point - 1; if (spline->flag & MASK_SPLINE_CYCLIC) @@ -378,24 +388,54 @@ float (*BKE_mask_spline_differentiate_with_resolution(MaskSpline *spline, int wi return diff_points; } +float (*BKE_mask_spline_differentiate_with_resolution(MaskSpline *spline, int width, int height, + int *tot_diff_point))[2] +{ + int resol = BKE_mask_spline_resolution(spline, width, height); + + return BKE_mask_spline_differentiate_with_resolution_ex(spline, resol, tot_diff_point); +} + float (*BKE_mask_spline_differentiate(MaskSpline *spline, int *tot_diff_point))[2] { return BKE_mask_spline_differentiate_with_resolution(spline, 0, 0, tot_diff_point); } -float (*BKE_mask_spline_feather_differentiated_points_with_resolution(MaskSpline *spline, int width, int height, - int *tot_feather_point))[2] +/** + * values align with #BKE_mask_spline_differentiate_with_resolution_ex + * when \a resol arguments match. + */ +float (*BKE_mask_spline_feather_differentiated_points_with_resolution_ex(MaskSpline *spline, const int resol, + int *tot_feather_point))[2] { MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline); - + MaskSplinePoint *point, *prev; float (*feather)[2], (*fp)[2]; - int i, j, tot, resol = BKE_mask_spline_feather_resolution(spline, width, height); - tot = resol * spline->tot_point; - feather = fp = MEM_mallocN(tot * sizeof(*feather), "mask spline feather diff points"); + const int tot = BKE_mask_spline_differentiate_calc_total(spline, resol); + int a; - for (i = 0; i < spline->tot_point; i++) { - MaskSplinePoint *point = &points_array[i]; + /* tot+1 because of 'forward_diff_bezier' function */ + feather = fp = MEM_mallocN((tot + 1) * sizeof(*feather), "mask spline feather diff points"); + + a = spline->tot_point - 1; + if (spline->flag & MASK_SPLINE_CYCLIC) + a++; + + prev = points_array; + point = prev + 1; + + while (a--) { + /* BezTriple *prevbezt; */ /* UNUSED */ + /* BezTriple *bezt; */ /* UNUSED */ + int j; + + if (a == 0 && (spline->flag & MASK_SPLINE_CYCLIC)) + point = points_array; + + + /* prevbezt = &prev->bezt; */ + /* bezt = &point->bezt; */ for (j = 0; j < resol; j++, fp++) { float u = (float) j / resol, weight; @@ -403,12 +443,26 @@ float (*BKE_mask_spline_feather_differentiated_points_with_resolution(MaskSpline /* TODO - these calls all calculate similar things * could be unified for some speed */ - BKE_mask_point_segment_co(spline, point, u, co); - BKE_mask_point_normal(spline, point, u, n); - weight = BKE_mask_point_weight(spline, point, u); + BKE_mask_point_segment_co(spline, prev, u, co); + BKE_mask_point_normal(spline, prev, u, n); + weight = BKE_mask_point_weight(spline, prev, u); + + madd_v2_v2v2fl(*fp, co, n, weight); + } + + if (a == 0 && (spline->flag & MASK_SPLINE_CYCLIC) == 0) { + float u = 1.0f, weight; + float co[2], n[2]; + + BKE_mask_point_segment_co(spline, prev, u, co); + BKE_mask_point_normal(spline, prev, u, n); + weight = BKE_mask_point_weight(spline, prev, u); madd_v2_v2v2fl(*fp, co, n, weight); } + + prev = point; + point++; } *tot_feather_point = tot; @@ -416,6 +470,14 @@ float (*BKE_mask_spline_feather_differentiated_points_with_resolution(MaskSpline return feather; } +float (*BKE_mask_spline_feather_differentiated_points_with_resolution(MaskSpline *spline, int width, int height, + int *tot_feather_point))[2] +{ + int resol = BKE_mask_spline_feather_resolution(spline, width, height); + + return BKE_mask_spline_feather_differentiated_points_with_resolution_ex(spline, resol, tot_feather_point); +} + float (*BKE_mask_spline_feather_differentiated_points(MaskSpline *spline, int *tot_feather_point))[2] { return BKE_mask_spline_feather_differentiated_points_with_resolution(spline, 0, 0, tot_feather_point); @@ -2219,7 +2281,7 @@ void BKE_mask_rasterize_layers(ListBase *masklayers, int width, int height, floa if (tot_diff_point) { PLX_raskterize(diff_points, tot_diff_point, - buffer_tmp, width, height, do_mask_aa); + buffer_tmp, width, height,do_mask_aa); if (tot_diff_feather_points) { PLX_raskterize_feather(diff_points, tot_diff_point, @@ -2273,13 +2335,86 @@ void BKE_mask_rasterize_layers(ListBase *masklayers, int width, int height, floa } } + if(do_mask_aa){ + //PLX_antialias_buffer(buffer,width,height); + } /* clamp at the end */ clamp_vn_vn(buffer, buffer_size); } - MEM_freeN(buffer_tmp); } +#ifdef __PLX_RASKTER_MT__ +void BKE_mask_init_layers(Mask *mask, struct layer_init_data *mlayer_data, int width, int height, const short do_aspect_correct){ + MaskLayer *masklay; + int numLayers=0; + int currLayer=0; + for (masklay = mask->masklayers->first; masklay; masklay = masklay->next) { + numLayers++; + } + mlayer_data = MEM_mallocN(sizeof(struct layer_init_data) * numLayers, __func__); //size correct? + + + for (masklay = mask->masklayers->first; masklay; masklay = masklay->next) { + MaskSpline *spline; + for (spline = masklay->splines.first; spline; spline = spline->next) { + float (*diff_points)[2]; + int tot_diff_point; + + float (*diff_feather_points)[2]; + int tot_diff_feather_points; + + diff_points = BKE_mask_spline_differentiate_with_resolution(spline, width, height, + &tot_diff_point); + + if (tot_diff_point) { + if (do_feather) { + diff_feather_points = + BKE_mask_spline_feather_differentiated_points_with_resolution(spline, width, height, + &tot_diff_feather_points); + } + else { + tot_diff_feather_points = 0; + diff_feather_points = NULL; + } + + if (do_aspect_correct) { + if (width != height) { + float *fp; + float *ffp; + int i; + float asp; + + if (width < height) { + fp = &diff_points[0][0]; + ffp = tot_diff_feather_points ? &diff_feather_points[0][0] : NULL; + asp = (float)width / (float)height; + } + else { + fp = &diff_points[0][1]; + ffp = tot_diff_feather_points ? &diff_feather_points[0][1] : NULL; + asp = (float)height / (float)width; + } + + for (i = 0; i < tot_diff_point; i++, fp += 2) { + (*fp) = (((*fp) - 0.5f) / asp) + 0.5f; + } + + if (tot_diff_feather_points) { + for (i = 0; i < tot_diff_feather_points; i++, ffp += 2) { + (*ffp) = (((*ffp) - 0.5f) / asp) + 0.5f; + } + } + } + } + PLX_init_base_data(mlayer_data[currLayer], diff_points, tot_diff_points, width, height); + currLayer++; + } + } + } +} +#endif + void BKE_mask_rasterize(Mask *mask, int width, int height, float *buffer, const short do_aspect_correct, const short do_mask_aa, const short do_feather) diff --git a/source/blender/blenkernel/intern/mask_rasterize.c b/source/blender/blenkernel/intern/mask_rasterize.c new file mode 100644 index 00000000000..bb18166ba6d --- /dev/null +++ b/source/blender/blenkernel/intern/mask_rasterize.c @@ -0,0 +1,638 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2012 Blender Foundation. + * All rights reserved. + * + * Contributor(s): Blender Foundation, + * Campbell Barton + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/blenkernel/intern/mask_rasterize.c + * \ingroup bke + */ + +#include "MEM_guardedalloc.h" + +#include "DNA_vec_types.h" +#include "DNA_mask_types.h" + +#include "BLI_utildefines.h" +#include "BLI_kdopbvh.h" +#include "BLI_scanfill.h" + +#include "BLI_math.h" +#include "BLI_rect.h" +#include "BLI_listbase.h" +#include "BLI_mempool.h" + +#include "BKE_mask.h" + +#ifndef USE_RASKTER + +#define RESOL 32 + +/** + * A single #MaskRasterHandle contains multile #MaskRasterLayer's, + * each #MaskRasterLayer does its own lookup which contributes to + * the final pixel with its own blending mode and the final pixel is blended between these. + */ + +/* internal use only */ +typedef struct MaskRasterLayer { + /* xy raytree */ + BVHTree *bvhtree; + + /* 2d bounds (to quickly skip raytree lookup) */ + rctf bounds; + + /* geometry */ + unsigned int (*tri_array)[4]; /* access coords tri/quad */ + float (*tri_coords)[3]; /* xy, z 0-1 (1.0 == filled) */ + + + /* copied direct from #MaskLayer.--- */ + /* blending options */ + float alpha; + char blend; + char blend_flag; + +} MaskRasterLayer; + + +/** + * opaque local struct for mask pixel lookup, each MaskLayer needs one of these + */ +struct MaskRasterHandle { + MaskRasterLayer *layers; + unsigned int layers_tot; + + /* 2d bounds (to quickly skip raytree lookup) */ + rctf bounds; +}; + +MaskRasterHandle *BLI_maskrasterize_handle_new(void) +{ + MaskRasterHandle *mr_handle; + + mr_handle = MEM_callocN(sizeof(MaskRasterHandle), STRINGIFY(MaskRasterHandle)); + + return mr_handle; +} + +void BLI_maskrasterize_handle_free(MaskRasterHandle *mr_handle) +{ + const unsigned int layers_tot = mr_handle->layers_tot; + unsigned int i; + MaskRasterLayer *raslayers = mr_handle->layers; + + /* raycast vars */ + for (i = 0; i < layers_tot; i++, raslayers++) { + BLI_bvhtree_free(raslayers->bvhtree); + + if (raslayers->tri_array) { + MEM_freeN(raslayers->tri_array); + } + + if (raslayers->tri_coords) { + MEM_freeN(raslayers->tri_coords); + } + } + + MEM_freeN(mr_handle->layers); + MEM_freeN(mr_handle); +} + +#define PRINT_MASK_DEBUG printf + +#define SF_EDGE_IS_BOUNDARY 0xff + +#define SF_KEYINDEX_TEMP_ID ((unsigned int) -1) + + +void maskrasterize_spline_differentiate_point_inset(float (*diff_feather_points)[2], float (*diff_points)[2], + const int tot_diff_point, const float ofs, const int do_test) +{ + int k_prev = tot_diff_point - 2; + int k_curr = tot_diff_point - 1; + int k_next = 0; + + int k; + + float d_prev[2]; + float d_next[2]; + float d[2]; + + const float *co_prev; + const float *co_curr; + const float *co_next; + + const float ofs_squared = ofs * ofs; + + co_prev = diff_points[k_prev]; + co_curr = diff_points[k_curr]; + co_next = diff_points[k_next]; + + /* precalc */ + sub_v2_v2v2(d_prev, co_prev, co_curr); + normalize_v2(d_prev); + + /* TODO, speedup by only doing one normalize per iter */ + + + for (k = 0; k < tot_diff_point; k++) { + + co_prev = diff_points[k_prev]; + co_curr = diff_points[k_curr]; + co_next = diff_points[k_next]; + + /* sub_v2_v2v2(d_prev, co_prev, co_curr); */ /* precalc */ + sub_v2_v2v2(d_next, co_curr, co_next); + + /* normalize_v2(d_prev); */ /* precalc */ + normalize_v2(d_next); + + if ((do_test == FALSE) || + (len_squared_v2v2(diff_feather_points[k], diff_points[k]) < ofs_squared)) + { + + add_v2_v2v2(d, d_prev, d_next); + + normalize_v2(d); + + diff_feather_points[k][0] = diff_points[k][0] + ( d[1] * ofs); + diff_feather_points[k][1] = diff_points[k][1] + (-d[0] * ofs); + } + + /* use next iter */ + copy_v2_v2(d_prev, d_next); + + k_prev = k_curr; + k_curr = k_next; + k_next++; + } +} + +#define TRI_VERT ((unsigned int) -1) + +void BLI_maskrasterize_handle_init(MaskRasterHandle *mr_handle, struct Mask *mask, + const int width, const int height, + const short do_aspect_correct, const short do_mask_aa, + const short do_feather) +{ + /* TODO: real size */ + const int resol = RESOL; + const float aa_filter_size = 1.0f / MIN2(width, height); + + const float zvec[3] = {0.0f, 0.0f, 1.0f}; + MaskLayer *masklay; + int masklay_index; + + mr_handle->layers_tot = BLI_countlist(&mask->masklayers); + mr_handle->layers = MEM_mallocN(sizeof(MaskRasterLayer) * mr_handle->layers_tot, STRINGIFY(MaskRasterLayer)); + BLI_rctf_init_minmax(&mr_handle->bounds); + + for (masklay = mask->masklayers.first, masklay_index = 0; masklay; masklay = masklay->next, masklay_index++) { + + MaskSpline *spline; + + /* scanfill */ + ScanFillContext sf_ctx; + ScanFillVert *sf_vert = NULL; + ScanFillVert *sf_vert_next = NULL; + ScanFillFace *sf_tri; + + unsigned int sf_vert_tot = 0; + unsigned int tot_feather_quads = 0; + + if (masklay->restrictflag & MASK_RESTRICT_RENDER) { + continue; + } + + BLI_scanfill_begin(&sf_ctx); + + for (spline = masklay->splines.first; spline; spline = spline->next) { + + float (*diff_points)[2]; + int tot_diff_point; + + float (*diff_feather_points)[2]; + int tot_diff_feather_points; + + diff_points = BKE_mask_spline_differentiate_with_resolution_ex(spline, resol, &tot_diff_point); + + /* dont ch*/ + if (do_feather) { + diff_feather_points = BKE_mask_spline_feather_differentiated_points_with_resolution_ex(spline, resol, &tot_diff_feather_points); + } + else { + tot_diff_feather_points = 0; + diff_feather_points = NULL; + } + + if (tot_diff_point > 3) { + ScanFillVert *sf_vert_prev; + int j; + + float co[3]; + co[2] = 0.0f; + + if (do_aspect_correct) { + if (width != height) { + float *fp; + float *ffp; + int i; + float asp; + + if (width < height) { + fp = &diff_points[0][0]; + ffp = tot_diff_feather_points ? &diff_feather_points[0][0] : NULL; + asp = (float)width / (float)height; + } + else { + fp = &diff_points[0][1]; + ffp = tot_diff_feather_points ? &diff_feather_points[0][1] : NULL; + asp = (float)height / (float)width; + } + + for (i = 0; i < tot_diff_point; i++, fp += 2) { + (*fp) = (((*fp) - 0.5f) / asp) + 0.5f; + } + + if (tot_diff_feather_points) { + for (i = 0; i < tot_diff_feather_points; i++, ffp += 2) { + (*ffp) = (((*ffp) - 0.5f) / asp) + 0.5f; + } + } + } + } + + /* fake aa, using small feather */ + if (do_mask_aa == TRUE) { + if (do_feather == FALSE) { + tot_diff_feather_points = tot_diff_point; + diff_feather_points = MEM_mallocN(sizeof(*diff_feather_points) * tot_diff_feather_points, __func__); + /* add single pixel feather */ + maskrasterize_spline_differentiate_point_inset(diff_feather_points, diff_points, + tot_diff_point, aa_filter_size, FALSE); + } + else { + /* ensure single pixel feather, on any zero feather areas */ + maskrasterize_spline_differentiate_point_inset(diff_feather_points, diff_points, + tot_diff_point, aa_filter_size, TRUE); + } + } + + copy_v2_v2(co, diff_points[0]); + sf_vert_prev = BLI_scanfill_vert_add(&sf_ctx, co); + sf_vert_prev->tmp.u = sf_vert_tot; + sf_vert_prev->keyindex = sf_vert_tot + tot_diff_point; /* absolute index of feather vert */ + sf_vert_tot++; + + /* TODO, an alternate functions so we can avoid double vector copy! */ + for (j = 1; j < tot_diff_point; j++) { + copy_v2_v2(co, diff_points[j]); + sf_vert = BLI_scanfill_vert_add(&sf_ctx, co); + sf_vert->tmp.u = sf_vert_tot; + sf_vert->keyindex = sf_vert_tot + tot_diff_point; /* absolute index of feather vert */ + sf_vert_tot++; + } + + sf_vert = sf_vert_prev; + sf_vert_prev = sf_ctx.fillvertbase.last; + + for (j = 0; j < tot_diff_point; j++) { + ScanFillEdge *sf_edge = BLI_scanfill_edge_add(&sf_ctx, sf_vert_prev, sf_vert); + sf_edge->tmp.c = SF_EDGE_IS_BOUNDARY; + + sf_vert_prev = sf_vert; + sf_vert = sf_vert->next; + } + + if (diff_feather_points) { + float co_feather[3]; + co_feather[2] = 1.0f; + + BLI_assert(tot_diff_feather_points == tot_diff_point); + + /* note: only added for convenience, we dont infact use these to scanfill, + * only to create feather faces after scanfill */ + for (j = 0; j < tot_diff_feather_points; j++) { + copy_v2_v2(co_feather, diff_feather_points[j]); + sf_vert = BLI_scanfill_vert_add(&sf_ctx, co_feather); + + /* no need for these attrs */ +#if 0 + sf_vert->tmp.u = sf_vert_tot; + sf_vert->keyindex = sf_vert_tot + tot_diff_point; /* absolute index of feather vert */ +#endif + sf_vert->keyindex = SF_KEYINDEX_TEMP_ID; + sf_vert_tot++; + } + + if (diff_feather_points) { + MEM_freeN(diff_feather_points); + } + + tot_feather_quads += tot_diff_point; + } + } + + if (diff_points) { + MEM_freeN(diff_points); + } + } + + if (sf_ctx.fillvertbase.first) { + unsigned int (*tri_array)[4], *tri; /* access coords */ + float (*tri_coords)[3], *cos; /* xy, z 0-1 (1.0 == filled) */ + int sf_tri_tot; + rctf bounds; + int tri_index; + + BVHTree *bvhtree; + float bvhcos[4][3]; + + /* now we have all the splines */ + tri_coords = MEM_mallocN((sizeof(float) * 3) * sf_vert_tot, "maskrast_tri_coords"); + + /* init bounds */ + BLI_rctf_init_minmax(&bounds); + + /* coords */ + cos = (float *)tri_coords; + for (sf_vert = sf_ctx.fillvertbase.first; sf_vert; sf_vert = sf_vert_next) { + sf_vert_next = sf_vert->next; + copy_v3_v3(cos, sf_vert->co); + + /* remove so as not to interfear with fill (called after) */ + if (sf_vert->keyindex == SF_KEYINDEX_TEMP_ID) { + BLI_remlink(&sf_ctx.fillvertbase, sf_vert); + } + + /* bounds */ + BLI_rctf_do_minmax_v(&bounds, cos); + + cos += 3; + } + + /* main scanfill */ + sf_tri_tot = BLI_scanfill_calc_ex(&sf_ctx, FALSE, zvec); + + tri_array = MEM_mallocN(sizeof(*tri_array) * (sf_tri_tot + tot_feather_quads), "maskrast_tri_index"); + + /* */ + bvhtree = BLI_bvhtree_new(sf_tri_tot + tot_feather_quads, 0.000001f, 8, 6); + + /* tri's */ + tri = (unsigned int *)tri_array; + for (sf_tri = sf_ctx.fillfacebase.first, tri_index = 0; sf_tri; sf_tri = sf_tri->next, tri_index++) { + *(tri++) = sf_tri->v1->tmp.u; + *(tri++) = sf_tri->v2->tmp.u; + *(tri++) = sf_tri->v3->tmp.u; + *(tri++) = TRI_VERT; + + copy_v3_v3(bvhcos[0], tri_coords[*(tri - 4)]); + copy_v3_v3(bvhcos[1], tri_coords[*(tri - 3)]); + copy_v3_v3(bvhcos[2], tri_coords[*(tri - 2)]); + + BLI_bvhtree_insert(bvhtree, tri_index, (float *)bvhcos, 3); + } + + /* start of feather faces... if we have this set, + * 'tri_index' is kept from loop above */ + + BLI_assert(tri_index == sf_tri_tot); + + if (tot_feather_quads) { + ScanFillEdge *sf_edge; + + for (sf_edge = sf_ctx.filledgebase.first; sf_edge; sf_edge = sf_edge->next) { + if (sf_edge->tmp.c == SF_EDGE_IS_BOUNDARY) { + *(tri++) = sf_edge->v1->tmp.u; + *(tri++) = sf_edge->v2->tmp.u; + *(tri++) = sf_edge->v2->keyindex; + *(tri++) = sf_edge->v1->keyindex; + + copy_v3_v3(bvhcos[0], tri_coords[*(tri - 4)]); + copy_v3_v3(bvhcos[1], tri_coords[*(tri - 3)]); + copy_v3_v3(bvhcos[2], tri_coords[*(tri - 2)]); + copy_v3_v3(bvhcos[3], tri_coords[*(tri - 1)]); + + BLI_bvhtree_insert(bvhtree, tri_index++, (const float *)bvhcos, 4); + } + } + } + + fprintf(stderr, "%d %d\n", tri_index, sf_tri_tot + tot_feather_quads); + + BLI_assert(tri_index == sf_tri_tot + tot_feather_quads); + + BLI_bvhtree_balance(bvhtree); + + { + MaskRasterLayer *raslayer = &mr_handle->layers[masklay_index]; + + raslayer->tri_coords = tri_coords; + raslayer->tri_array = tri_array; + raslayer->bounds = bounds; + raslayer->bvhtree = bvhtree; + + /* copy as-is */ + raslayer->alpha = masklay->alpha; + raslayer->blend = masklay->blend; + raslayer->blend_flag = masklay->blend_flag; + + + BLI_union_rctf(&mr_handle->bounds, &bounds); + } + + PRINT_MASK_DEBUG("tris %d, feather tris %d\n", sf_tri_tot, tot_feather_quads); + } + + /* add trianges */ + BLI_scanfill_end(&sf_ctx); + } +} + +//static void tri_flip_tri(unsigned int tri[3]) +//{ + +//} + +/* 2D ray test */ +static float maskrasterize_layer_z_depth_tri(const float pt[2], + const float v1[3], const float v2[3], const float v3[3]) +{ + float w[3]; + barycentric_weights_v2(v1, v2, v3, pt, w); + return (v1[2] * w[0]) + (v2[2] * w[1]) + (v3[2] * w[2]); +} + +#if 0 +static float maskrasterize_layer_z_depth_quad(const float pt[2], + const float v1[3], const float v2[3], const float v3[3], const float v4[3]) +{ + float w[4]; + barycentric_weights_v2_quad(v1, v2, v3, v4, pt, w); + return (v1[2] * w[0]) + (v2[2] * w[1]) + (v3[2] * w[2]) + (v4[2] * w[3]); +} +#endif + +static void maskrasterize_layer_bvh_cb(void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit) +{ + MaskRasterLayer *layer = (struct MaskRasterLayer *)userdata; + unsigned int *tri = layer->tri_array[index]; + float (*cos)[3] = layer->tri_coords; + const float dist_orig = hit->dist; + + /* we always cast from same place only need xy */ + if (tri[3] == TRI_VERT) { + /* --- tri --- */ + + /* not essential but avoids unneeded extra lookups */ + if ((cos[0][2] < dist_orig) || + (cos[1][2] < dist_orig) || + (cos[2][2] < dist_orig)) + { + if (isect_point_tri_v2(ray->origin, cos[tri[0]], cos[tri[1]], cos[tri[2]])) { + /* we know all tris are close for now */ +#if 0 + const float dist = maskrasterize_layer_z_depth_tri(ray->origin, cos[tri[0]], cos[tri[1]], cos[tri[2]]); + if (dist < dist_orig) { + hit->index = index; + hit->dist = dist; + } +#else + hit->index = index; + hit->dist = 0.0f; +#endif + } + } + } + else { + /* --- quad --- */ + + /* not essential but avoids unneeded extra lookups */ + if ((cos[0][2] < dist_orig) || + (cos[1][2] < dist_orig) || + (cos[2][2] < dist_orig) || + (cos[3][2] < dist_orig)) + { + + /* needs work */ +#if 0 + if (isect_point_quad_v2(ray->origin, cos[tri[0]], cos[tri[1]], cos[tri[2]], cos[tri[3]])) { + const float dist = maskrasterize_layer_z_depth_quad(ray->origin, cos[tri[0]], cos[tri[1]], cos[tri[2]], cos[tri[3]]); + if (dist < dist_orig) { + hit->index = index; + hit->dist = dist; + } + } +#elif 1 + if (isect_point_tri_v2(ray->origin, cos[tri[0]], cos[tri[1]], cos[tri[2]])) { + const float dist = maskrasterize_layer_z_depth_tri(ray->origin, cos[tri[0]], cos[tri[1]], cos[tri[2]]); + if (dist < dist_orig) { + hit->index = index; + hit->dist = dist; + } + } + else if (isect_point_tri_v2(ray->origin, cos[tri[0]], cos[tri[2]], cos[tri[3]])) { + const float dist = maskrasterize_layer_z_depth_tri(ray->origin, cos[tri[0]], cos[tri[2]], cos[tri[3]]); + if (dist < dist_orig) { + hit->index = index; + hit->dist = dist; + } + } +#else + /* cheat - we know first 2 verts are z0.0f and second 2 are z 1.0f */ + /* ... worth looking into */ +#endif + } + } +} + +float BLI_maskrasterize_handle_sample(MaskRasterHandle *mr_handle, const float xy[2]) +{ + /* TODO - AA jitter */ + + if (BLI_in_rctf_v(&mr_handle->bounds, xy)) { + const unsigned int layers_tot = mr_handle->layers_tot; + unsigned int i; + MaskRasterLayer *layer = mr_handle->layers; + + /* raycast vars*/ + const float co[3] = {xy[0], xy[1], 0.0f}; + const float dir[3] = {0.0f, 0.0f, 1.0f}; + const float radius = 1.0f; + BVHTreeRayHit hit = {0}; + + /* return */ + float value = 0.0f; + + for (i = 0; i < layers_tot; i++, layer++) { + + if (BLI_in_rctf_v(&layer->bounds, xy)) { + + hit.dist = FLT_MAX; + hit.index = -1; + + /* TODO, and axis aligned version of this function, avoids 2 casts */ + BLI_bvhtree_ray_cast(layer->bvhtree, co, dir, radius, &hit, maskrasterize_layer_bvh_cb, layer); + + /* --- hit (start) --- */ + if (hit.index != -1) { + const float dist = 1.0f - hit.dist; + const float dist_ease = (3.0f * dist * dist - 2.0f * dist * dist * dist); + + float v; + /* apply alpha */ + v = dist_ease * layer->alpha; + + if (layer->blend_flag & MASK_BLENDFLAG_INVERT) { + v = 1.0f - v; + } + + switch (layer->blend) { + case MASK_BLEND_SUBTRACT: + { + value -= v; + break; + } + case MASK_BLEND_ADD: + default: + { + value += v; + break; + } + } + } + /* --- hit (end) --- */ + + } + } + + return CLAMPIS(value, 0.0f, 1.0f); + } + else { + return 0.0f; + } +} + +#endif /* USE_RASKTER */ diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index e0761311c98..6167379309c 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -1619,13 +1619,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; @@ -1633,12 +1633,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; @@ -1647,7 +1647,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; @@ -1662,9 +1662,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" */ @@ -1737,9 +1737,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/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index 54e93f58307..de367b6b4d0 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -322,6 +322,8 @@ typedef struct MovieClipCache { /* cache for stable shot */ struct { + ImBuf *reference_ibuf; + ImBuf *ibuf; int framenr; int postprocess_flag; @@ -338,6 +340,10 @@ typedef struct MovieClipImBufCacheKey { short render_flag; } MovieClipImBufCacheKey; +typedef struct MovieClipCachePriorityData { + int framenr; +} MovieClipCachePriorityData; + static void moviecache_keydata(void *userkey, int *framenr, int *proxy, int *render_flags) { MovieClipImBufCacheKey *key = (MovieClipImBufCacheKey *)userkey; @@ -378,6 +384,32 @@ static int moviecache_hashcmp(const void *av, const void *bv) return 0; } +void *moviecache_getprioritydata(void *key_v) +{ + MovieClipImBufCacheKey *key = (MovieClipImBufCacheKey *) key_v; + MovieClipCachePriorityData *priority_data; + + priority_data = MEM_callocN(sizeof(priority_data), "movie cache clip priority data"); + priority_data->framenr = key->framenr; + + return priority_data; +} + +int moviecache_getitempriority(void *last_userkey_v, void *priority_data_v) +{ + MovieClipImBufCacheKey *last_userkey = (MovieClipImBufCacheKey *) last_userkey_v; + MovieClipCachePriorityData *priority_data = (MovieClipCachePriorityData *) priority_data_v; + + return -abs(last_userkey->framenr - priority_data->framenr); +} + +void moviecache_prioritydeleter(void *priority_data_v) +{ + MovieClipCachePriorityData *priority_data = (MovieClipCachePriorityData *) priority_data_v; + + MEM_freeN(priority_data); +} + static ImBuf *get_imbuf_cache(MovieClip *clip, MovieClipUser *user, int flag) { if (clip->cache) { @@ -405,10 +437,20 @@ static void put_imbuf_cache(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf, i MovieClipImBufCacheKey key; if (!clip->cache) { + struct MovieCache *moviecache; + + // char cache_name[64]; + // BLI_snprintf(cache_name, sizeof(cache_name), "movie %s", clip->id.name); + clip->cache = MEM_callocN(sizeof(MovieClipCache), "movieClipCache"); - clip->cache->moviecache = IMB_moviecache_create(sizeof(MovieClipImBufCacheKey), moviecache_hashhash, - moviecache_hashcmp, moviecache_keydata); + moviecache = IMB_moviecache_create("movieclip", sizeof(MovieClipImBufCacheKey), moviecache_hashhash, moviecache_hashcmp); + + IMB_moviecache_set_getdata_callback(moviecache, moviecache_keydata); + IMB_moviecache_set_priority_callback(moviecache, moviecache_getprioritydata, moviecache_getitempriority, + moviecache_prioritydeleter); + + clip->cache->moviecache = moviecache; } key.framenr = user->framenr; @@ -655,9 +697,6 @@ static ImBuf *put_postprocessed_frame_to_cache(MovieClip *clip, MovieClipUser *u MovieTrackingCamera *camera = &clip->tracking.camera; ImBuf *postproc_ibuf = NULL; - if (cache->postprocessed.ibuf) - IMB_freeImBuf(cache->postprocessed.ibuf); - cache->postprocessed.framenr = user->framenr; cache->postprocessed.flag = postprocess_flag; @@ -695,13 +734,10 @@ static ImBuf *put_postprocessed_frame_to_cache(MovieClip *clip, MovieClipUser *u IMB_refImBuf(postproc_ibuf); - cache->postprocessed.ibuf = postproc_ibuf; + if (cache->postprocessed.ibuf) + IMB_freeImBuf(cache->postprocessed.ibuf); - if (cache->stabilized.ibuf) { - /* force stable buffer be re-calculated */ - IMB_freeImBuf(cache->stabilized.ibuf); - cache->stabilized.ibuf = NULL; - } + cache->postprocessed.ibuf = postproc_ibuf; return postproc_ibuf; } @@ -777,7 +813,8 @@ ImBuf *BKE_movieclip_get_postprocessed_ibuf(MovieClip *clip, MovieClipUser *user return movieclip_get_postprocessed_ibuf(clip, user, clip->flag, postprocess_flag, 0); } -static ImBuf *get_stable_cached_frame(MovieClip *clip, MovieClipUser *user, int framenr, int postprocess_flag) +static ImBuf *get_stable_cached_frame(MovieClip *clip, MovieClipUser *user, ImBuf *reference_ibuf, + int framenr, int postprocess_flag) { MovieClipCache *cache = clip->cache; MovieTracking *tracking = &clip->tracking; @@ -796,6 +833,9 @@ static ImBuf *get_stable_cached_frame(MovieClip *clip, MovieClipUser *user, int if (!cache->stabilized.ibuf || cache->stabilized.framenr != framenr) return NULL; + if (cache->stabilized.reference_ibuf != reference_ibuf) + return NULL; + /* cached ibuf used different proxy settings */ if (cache->stabilized.render_flag != render_flag || cache->stabilized.proxy != proxy) return NULL; @@ -836,13 +876,8 @@ static ImBuf *put_stabilized_frame_to_cache(MovieClip *clip, MovieClipUser *user float tloc[2], tscale, tangle; int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, framenr); - if (cache->stabilized.ibuf) - IMB_freeImBuf(cache->stabilized.ibuf); - stableibuf = BKE_tracking_stabilize_frame(&clip->tracking, clip_framenr, ibuf, tloc, &tscale, &tangle); - cache->stabilized.ibuf = stableibuf; - copy_v2_v2(cache->stabilized.loc, tloc); cache->stabilized.scale = tscale; @@ -862,6 +897,11 @@ static ImBuf *put_stabilized_frame_to_cache(MovieClip *clip, MovieClipUser *user cache->stabilized.postprocess_flag = postprocess_flag; + if (cache->stabilized.ibuf) + IMB_freeImBuf(cache->stabilized.ibuf); + + cache->stabilized.ibuf = stableibuf; + IMB_refImBuf(stableibuf); return stableibuf; @@ -881,7 +921,7 @@ ImBuf *BKE_movieclip_get_stable_ibuf(MovieClip *clip, MovieClipUser *user, float if (clip->tracking.stabilization.flag & TRACKING_2D_STABILIZATION) { MovieClipCache *cache = clip->cache; - stableibuf = get_stable_cached_frame(clip, user, framenr, postprocess_flag); + stableibuf = get_stable_cached_frame(clip, user, ibuf, framenr, postprocess_flag); if (!stableibuf) stableibuf = put_stabilized_frame_to_cache(clip, user, ibuf, framenr, postprocess_flag); 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/node.c b/source/blender/blenkernel/intern/node.c index 33df8e4b503..56b1c0a17e8 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -321,15 +321,18 @@ bNode *nodeAddNode(bNodeTree *ntree, struct bNodeTemplate *ntemp) node->color[0] = node->color[1] = node->color[2] = 0.608; /* default theme color */ node_add_sockets_from_type(ntree, node, ntype); - - /* initialize the node name with the node label */ - BLI_strncpy(node->name, nodeLabel(node), NODE_MAXSTR); - nodeUniqueName(ntree, node); - + BLI_addtail(&ntree->nodes, node); if (ntype->initfunc!=NULL) ntype->initfunc(ntree, node, ntemp); + + /* initialize the node name with the node label. + * note: do this after the initfunc so nodes get + * their data set which may be used in naming + * (node groups for example) */ + BLI_strncpy(node->name, nodeLabel(node), NODE_MAXSTR); + nodeUniqueName(ntree, node); ntree->update |= NTREE_UPDATE_NODES; @@ -1939,6 +1942,7 @@ static void registerCompositNodes(bNodeTreeType *ttype) register_node_type_cmp_switch(ttype); register_node_type_cmp_mask(ttype); + register_node_type_cmp_trackpos(ttype); } static void registerShaderNodes(bNodeTreeType *ttype) diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index cd53bf01a67..f471ffef0f6 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -225,7 +225,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 */ @@ -378,7 +378,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) @@ -1386,7 +1386,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; @@ -1968,8 +1968,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); @@ -1978,10 +1978,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]); } @@ -1997,7 +1997,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; @@ -2310,14 +2310,21 @@ void BKE_object_minmax(Object *ob, float min_r[3], float max_r[3]) } if (change == FALSE) { + float size[3]; + + copy_v3_v3(size, ob->size); + if (ob->type == OB_EMPTY) { + mul_v3_fl(size, ob->empty_drawsize); + } + minmax_v3v3_v3(min_r, max_r, ob->obmat[3]); copy_v3_v3(vec, ob->obmat[3]); - add_v3_v3(vec, ob->size); + add_v3_v3(vec, size); minmax_v3v3_v3(min_r, max_r, vec); copy_v3_v3(vec, ob->obmat[3]); - sub_v3_v3(vec, ob->size); + sub_v3_v3(vec, size); minmax_v3v3_v3(min_r, max_r, vec); } } @@ -2513,7 +2520,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) @@ -2549,7 +2556,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); } @@ -3173,7 +3180,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..c8b07e2ec11 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; @@ -3400,6 +3400,12 @@ void psys_mat_hair_to_object(Object *UNUSED(ob), DerivedMesh *dm, short from, Pa { float vec[3]; + /* can happen when called from a different object's modifier */ + if (!dm) { + unit_m4(hairmat); + return; + } + psys_face_mat(0, dm, pa, hairmat, 0); psys_particle_on_dm(dm, from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, vec, 0, 0, 0, 0, 0); copy_v3_v3(hairmat[3], vec); diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 65f22ebc88f..aa798f59482 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -1576,7 +1576,7 @@ static void initialize_all_particles(ParticleSimulationData *sim) } } -static void get_angular_velocity_vector(short avemode, ParticleKey *state, float *vec) +static void get_angular_velocity_vector(short avemode, ParticleKey *state, float vec[3]) { switch (avemode) { case PART_AVE_VELOCITY: 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 e0aed029451..4a5267be7b3 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -260,10 +260,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; @@ -494,7 +494,7 @@ Scene *BKE_scene_add(const char *name) BLI_strncpy(sce->r.pic, U.renderdir, sizeof(sce->r.pic)); - BLI_init_rctf(&sce->r.safety, 0.1f, 0.9f, 0.1f, 0.9f); + BLI_rctf_init(&sce->r.safety, 0.1f, 0.9f, 0.1f, 0.9f); sce->r.osa = 8; /* note; in header_info.c the scene copy happens..., if you add more to renderdata it has to be checked there */ @@ -959,9 +959,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); @@ -1067,7 +1067,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/seqcache.c b/source/blender/blenkernel/intern/seqcache.c index 582034ae623..0d91dcb7faa 100644 --- a/source/blender/blenkernel/intern/seqcache.c +++ b/source/blender/blenkernel/intern/seqcache.c @@ -98,8 +98,7 @@ void seq_stripelem_cache_cleanup(void) { if (moviecache) { IMB_moviecache_free(moviecache); - moviecache = IMB_moviecache_create(sizeof(SeqCacheKey), seqcache_hashhash, - seqcache_hashcmp, NULL); + moviecache = IMB_moviecache_create("seqcache", sizeof(SeqCacheKey), seqcache_hashhash, seqcache_hashcmp); } } @@ -133,8 +132,7 @@ void seq_stripelem_cache_put( } if (!moviecache) { - moviecache = IMB_moviecache_create(sizeof(SeqCacheKey), seqcache_hashhash, - seqcache_hashcmp, NULL); + moviecache = IMB_moviecache_create("seqcache", sizeof(SeqCacheKey), seqcache_hashhash, seqcache_hashcmp); } key.seq = seq; 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/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/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/blenkernel/intern/writeframeserver.c b/source/blender/blenkernel/intern/writeframeserver.c index b5965838a30..a2028ff5fa1 100644 --- a/source/blender/blenkernel/intern/writeframeserver.c +++ b/source/blender/blenkernel/intern/writeframeserver.c @@ -383,7 +383,7 @@ int BKE_frameserver_append(RenderData *UNUSED(rd), int UNUSED(start_frame), int connsock = -1; } - return 0; + return 1; } void BKE_frameserver_end(void) |