diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2013-03-24 16:13:13 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2013-03-24 16:13:13 +0400 |
commit | 385c72f5f26ae9c86bf40c127c44216ceea0e6c1 (patch) | |
tree | 6c0432578abee5437adc94e96b5a91c593b866b4 /source/blender/blenkernel | |
parent | 5841d1c8145ba50addeb17fa0231705d949d8b3d (diff) | |
parent | b5ce1b1a23a3befbcc4cd3c67a5ec6a76d77aa5a (diff) |
Merged changes in the trunk up to revision 55546.
Conflicts resolved:
source/blenderplayer/bad_level_call_stubs/SConscript
Partly reverted changes to intern/cycles/blender/addon/ui.py in revision 52899
to make it easier to merge trunk changes.
Diffstat (limited to 'source/blender/blenkernel')
42 files changed, 648 insertions, 292 deletions
diff --git a/source/blender/blenkernel/BKE_anim.h b/source/blender/blenkernel/BKE_anim.h index 11537964e32..539c5780cd5 100644 --- a/source/blender/blenkernel/BKE_anim.h +++ b/source/blender/blenkernel/BKE_anim.h @@ -65,8 +65,8 @@ int where_on_path(struct Object *ob, float ctime, float vec[4], float dir[3], fl /* ---------------------------------------------------- */ /* Dupli-Geometry */ -struct ListBase *object_duplilist_ex(struct Scene *sce, struct Object *ob, int update, int for_render); -struct ListBase *object_duplilist(struct Scene *sce, struct Object *ob, int for_render); +struct ListBase *object_duplilist_ex(struct Scene *sce, struct Object *ob, bool update, bool for_render); +struct ListBase *object_duplilist(struct Scene *sce, struct Object *ob, bool for_render); void free_object_duplilist(struct ListBase *lb); int count_duplilist(struct Object *ob); diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index d03c631f7a1..c6b02bc8361 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 266 -#define BLENDER_SUBVERSION 2 +#define BLENDER_SUBVERSION 3 /* 262 was the last editmesh release but it has compatibility code for bmesh data */ #define BLENDER_MINVERSION 262 diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h index 4dfc70db952..e0afb1929a5 100644 --- a/source/blender/blenkernel/BKE_brush.h +++ b/source/blender/blenkernel/BKE_brush.h @@ -42,6 +42,11 @@ struct Scene; struct wmOperator; // enum CurveMappingPreset; + +/* globals for brush execution */ +void BKE_brush_system_init(void); +void BKE_brush_system_exit(void); + /* datablock functions */ struct Brush *BKE_brush_add(struct Main *bmain, const char *name); struct Brush *BKE_brush_copy(struct Brush *brush); diff --git a/source/blender/blenkernel/BKE_camera.h b/source/blender/blenkernel/BKE_camera.h index 057cd79b9e4..a07558cc8af 100644 --- a/source/blender/blenkernel/BKE_camera.h +++ b/source/blender/blenkernel/BKE_camera.h @@ -112,7 +112,7 @@ void BKE_camera_params_compute_matrix(CameraParams *params); /* Camera View Frame */ -void BKE_camera_view_frame_ex(struct Scene *scene, struct Camera *camera, float drawsize, const short do_clip, const float scale[3], +void BKE_camera_view_frame_ex(struct Scene *scene, struct Camera *camera, float drawsize, const bool do_clip, const float scale[3], float r_asp[2], float r_shift[2], float *r_drawsize, float r_vec[4][3]); void BKE_camera_view_frame(struct Scene *scene, struct Camera *camera, float r_vec[4][3]); diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h index 88d9cbb9b35..6e298a6d4f6 100644 --- a/source/blender/blenkernel/BKE_curve.h +++ b/source/blender/blenkernel/BKE_curve.h @@ -124,6 +124,7 @@ bool BKE_nurb_order_clamp_u(struct Nurb *nu); bool BKE_nurb_order_clamp_v(struct Nurb *nu); void BKE_nurb_direction_switch(struct Nurb *nu); +bool BKE_nurb_type_convert(struct Nurb *nu, const short type, const bool use_handles); void BKE_nurb_points_add(struct Nurb *nu, int number); void BKE_nurb_bezierPoints_add(struct Nurb *nu, int number); diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h index 36733d1ced0..a51de2d4ae1 100644 --- a/source/blender/blenkernel/BKE_customdata.h +++ b/source/blender/blenkernel/BKE_customdata.h @@ -259,6 +259,7 @@ int CustomData_get_active_layer_index(const struct CustomData *data, int type); int CustomData_get_render_layer_index(const struct CustomData *data, int type); int CustomData_get_clone_layer_index(const struct CustomData *data, int type); int CustomData_get_stencil_layer_index(const struct CustomData *data, int type); +int CustomData_get_named_layer(const struct CustomData *data, int type, const char *name); int CustomData_get_active_layer(const struct CustomData *data, int type); int CustomData_get_render_layer(const struct CustomData *data, int type); int CustomData_get_clone_layer(const struct CustomData *data, int type); diff --git a/source/blender/blenkernel/BKE_deform.h b/source/blender/blenkernel/BKE_deform.h index b209e8bf667..b18bb5a87b6 100644 --- a/source/blender/blenkernel/BKE_deform.h +++ b/source/blender/blenkernel/BKE_deform.h @@ -43,9 +43,9 @@ struct MDeformVert; void defgroup_copy_list(struct ListBase *lb1, struct ListBase *lb2); struct bDeformGroup *defgroup_duplicate(struct bDeformGroup *ingroup); struct bDeformGroup *defgroup_find_name(struct Object *ob, const char *name); -int *defgroup_flip_map(struct Object *ob, int *flip_map_len, int use_default); -int *defgroup_flip_map_single(struct Object *ob, int *flip_map_len, int use_default, int defgroup); -int defgroup_flip_index(struct Object *ob, int index, int use_default); +int *defgroup_flip_map(struct Object *ob, int *flip_map_len, const bool use_default); +int *defgroup_flip_map_single(struct Object *ob, int *flip_map_len, const bool use_default, int defgroup); +int defgroup_flip_index(struct Object *ob, int index, const bool use_default); int defgroup_name_index(struct Object *ob, const char *name); void defgroup_unique_name(struct bDeformGroup *dg, struct Object *ob); @@ -66,9 +66,9 @@ float defvert_array_find_weight_safe(const struct MDeformVert *dvert, const int void defvert_copy(struct MDeformVert *dvert_dst, const struct MDeformVert *dvert_src); void defvert_copy_index(struct MDeformVert *dvert_dst, const struct MDeformVert *dvert_src, const int defgroup); -void defvert_sync(struct MDeformVert *dvert_dst, const struct MDeformVert *dvert_src, int use_verify); +void defvert_sync(struct MDeformVert *dvert_dst, const struct MDeformVert *dvert_src, const bool use_verify); void defvert_sync_mapped(struct MDeformVert *dvert_dst, const struct MDeformVert *dvert_src, - const int *flip_map, const int flip_map_len, const int use_verify); + const int *flip_map, const int flip_map_len, const bool use_verify); void defvert_remap(struct MDeformVert *dvert, int *map, const int map_len); void defvert_flip(struct MDeformVert *dvert, const int *flip_map, const int flip_map_len); void defvert_flip_merged(struct MDeformVert *dvert, const int *flip_map, const int flip_map_len); @@ -84,5 +84,4 @@ void BKE_deform_split_prefix(const char string[MAX_VGROUP_NAME], char base[MAX_V void flip_side_name(char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_NAME], int strip_number); -#endif - +#endif /* __BKE_DEFORM_H__ */ diff --git a/source/blender/blenkernel/BKE_displist.h b/source/blender/blenkernel/BKE_displist.h index 6b986cdceda..10c31189d02 100644 --- a/source/blender/blenkernel/BKE_displist.h +++ b/source/blender/blenkernel/BKE_displist.h @@ -85,7 +85,7 @@ DispList *BKE_displist_find(struct ListBase *lb, int type); void BKE_displist_normals_add(struct ListBase *lb); void BKE_displist_count(struct ListBase *lb, int *totvert, int *totface, int *tottri); void BKE_displist_free(struct ListBase *lb); -int BKE_displist_has_faces(struct ListBase *lb); +bool BKE_displist_has_faces(struct ListBase *lb); void BKE_displist_make_surf(struct Scene *scene, struct Object *ob, struct ListBase *dispbase, struct DerivedMesh **derivedFinal, int forRender, int forOrco); void BKE_displist_make_curveTypes(struct Scene *scene, struct Object *ob, int forOrco); @@ -94,7 +94,7 @@ void BKE_displist_make_curveTypes_forOrco(struct Scene *scene, struct Object *ob void BKE_displist_make_mball(struct Scene *scene, struct Object *ob); void BKE_displist_make_mball_forRender(struct Scene *scene, struct Object *ob, struct ListBase *dispbase); -int BKE_displist_surfindex_get(DispList *dl, int a, int *b, int *p1, int *p2, int *p3, int *p4); +bool BKE_displist_surfindex_get(DispList *dl, int a, int *b, int *p1, int *p2, int *p3, int *p4); void BKE_displist_fill(struct ListBase *dispbase, struct ListBase *to, int flipnormal); float BKE_displist_calc_taper(struct Scene *scene, struct Object *taperobj, int cur, int tot); diff --git a/source/blender/blenkernel/BKE_idcode.h b/source/blender/blenkernel/BKE_idcode.h index 74dc8de753e..10a34838662 100644 --- a/source/blender/blenkernel/BKE_idcode.h +++ b/source/blender/blenkernel/BKE_idcode.h @@ -32,47 +32,11 @@ * \ingroup bke */ -/** - * Convert an idcode into a name. - * - * \param code The code to convert. - * \return A static string representing the name of - * the code. - */ const char *BKE_idcode_to_name(int code); - -/** - * Convert an idcode into a name (plural). - * - * \param code The code to convert. - * \return A static string representing the name of - * the code. - */ const char *BKE_idcode_to_name_plural(int code); - -/** - * Convert a name into an idcode (ie. ID_SCE) - * - * \param name The name to convert. - * \return The code for the name, or 0 if invalid. - */ -int BKE_idcode_from_name(const char *name); - -/** - * Return non-zero when an ID type is linkable. - * - * \param code The code to check. - * \return Boolean, 0 when non linkable. - */ -bool BKE_idcode_is_linkable(int code); - -/** - * Return if the ID code is a valid ID code. - * - * \param code The code to check. - * \return Boolean, 0 when invalid. - */ -bool BKE_idcode_is_valid(int code); +int BKE_idcode_from_name(const char *name); +bool BKE_idcode_is_linkable(int code); +bool BKE_idcode_is_valid(int code); /** * Return an ID code and steps the index forward 1. diff --git a/source/blender/blenkernel/BKE_idprop.h b/source/blender/blenkernel/BKE_idprop.h index ad3e4bb2251..d8ad3b2e892 100644 --- a/source/blender/blenkernel/BKE_idprop.h +++ b/source/blender/blenkernel/BKE_idprop.h @@ -58,8 +58,6 @@ typedef union IDPropertyTemplate { /* ----------- Property Array Type ---------- */ -/* 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) #ifdef __GNUC__ __attribute__((warn_unused_result)) @@ -136,18 +134,11 @@ __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) #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) #ifdef __GNUC__ __attribute__((nonnull)) @@ -160,42 +151,17 @@ __attribute__((nonnull)) #endif ; -/** - * This function has a sanity check to make sure ID properties with the same name don't - * get added to the group. - * - * The sanity check just means the property is not added to the group if another property - * exists with the same name; the client code using ID properties then needs to detect this - * (the function that adds new properties to groups, IDP_AddToGroup, returns 0 if a property can't - * be added to the group, and 1 if it can) and free the property. - * - * Currently the code to free ID properties is designed to leave the actual struct - * you pass it un-freed, this is needed for how the system works. This means - * to free an ID property, you first call IDP_FreeProperty then MEM_freeN the - * 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) #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) #ifdef __GNUC__ __attribute__((nonnull (1, 3))) /* 'group', 'pnew' */ #endif ; - -/** \note this does not free the property!! - * - * To free the property, you have to do: - * IDP_FreeProperty(prop); //free all subdata - * MEM_freeN(prop); //free property struct itself - */ void IDP_RemFromGroup(struct IDProperty *group, struct IDProperty *prop) #ifdef __GNUC__ __attribute__((nonnull)) @@ -208,41 +174,23 @@ __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) #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) #ifdef __GNUC__ __attribute__((warn_unused_result)) #endif ; - -/** - * Returns the next item in the iteration. To use, simple for a loop like the following: - * while (IDP_GroupIterNext(iter) != NULL) { - * ... - * } - */ 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) #ifdef __GNUC__ __attribute__((nonnull)) @@ -250,9 +198,6 @@ __attribute__((nonnull)) ; /*-------- 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) #ifdef __GNUC__ __attribute__((warn_unused_result)) @@ -278,31 +223,6 @@ __attribute__((warn_unused_result)) #endif ; -/** - * Allocate a new ID. - * - * This function takes three arguments: the ID property type, a union which defines - * it's initial value, and a name. - * - * The union is simple to use; see the top of this header file for its definition. - * An example of using this function: - * - * IDPropertyTemplate val; - * IDProperty *group, *idgroup, *color; - * group = IDP_New(IDP_GROUP, val, "group1"); //groups don't need a template. - * - * val.array.len = 4 - * val.array.type = IDP_FLOAT; - * color = IDP_New(IDP_ARRAY, val, "color1"); - * - * idgroup = IDP_GetProperties(some_id, 1); - * IDP_AddToGroup(idgroup, color); - * IDP_AddToGroup(idgroup, group); - * - * Note that you MUST either attach the id property to an id property group with - * 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) #ifdef __GNUC__ __attribute__((warn_unused_result)) @@ -310,14 +230,10 @@ __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 - * the actual struct IDProperty struct either.*/ void IDP_FreeProperty(struct IDProperty *prop); void IDP_ClearProperty(IDProperty *prop); -/** Unlinks any struct IDProperty<->ID linkage that might be going on.*/ void IDP_UnlinkProperty(struct IDProperty *prop); #define IDP_Int(prop) ((prop)->data.val) diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index eb29c49ab84..71024a4ead2 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -212,7 +212,7 @@ void BKE_mesh_calc_normals_mapping_ex( struct MVert *mverts, int numVerts, struct MLoop *mloop, struct MPoly *mpolys, int numLoops, int numPolys, float (*polyNors_r)[3], struct MFace *mfaces, int numFaces, int *origIndexFace, float (*faceNors_r)[3], - const short only_face_normals); + const bool only_face_normals); void BKE_mesh_calc_normals( struct MVert *mverts, int numVerts, diff --git a/source/blender/blenkernel/BKE_movieclip.h b/source/blender/blenkernel/BKE_movieclip.h index c8c94b2898b..f97b5b1f3a1 100644 --- a/source/blender/blenkernel/BKE_movieclip.h +++ b/source/blender/blenkernel/BKE_movieclip.h @@ -70,7 +70,11 @@ void BKE_movieclip_build_proxy_frame_for_ibuf(struct MovieClip *clip, struct ImB float BKE_movieclip_remap_scene_to_clip_frame(struct MovieClip *clip, float framenr); float BKE_movieclip_remap_clip_to_scene_frame(struct MovieClip *clip, float framenr); -void BKE_movieclip_filename_for_frame(struct MovieClip *clip, int framenr, char *name); +void BKE_movieclip_filename_for_frame(struct MovieClip *clip, struct MovieClipUser *user, char *name); +struct ImBuf *BKE_movieclip_anim_ibuf_for_frame(struct MovieClip *clip, struct MovieClipUser *user); + +int BKE_movieclip_has_cached_frame(struct MovieClip *clip, struct MovieClipUser *user); +int BKE_movieclip_put_frame_if_possible(struct MovieClip *clip, struct MovieClipUser *user, struct ImBuf *ibuf); /* cacheing flags */ #define MOVIECLIP_CACHE_SKIP (1 << 0) diff --git a/source/blender/blenkernel/BKE_multires.h b/source/blender/blenkernel/BKE_multires.h index bee2c374f27..aa09fe1ce8d 100644 --- a/source/blender/blenkernel/BKE_multires.h +++ b/source/blender/blenkernel/BKE_multires.h @@ -75,7 +75,7 @@ struct DerivedMesh *multires_make_derived_from_derived(struct DerivedMesh *dm, struct MultiresModifierData *find_multires_modifier_before(struct Scene *scene, struct ModifierData *lastmd); -struct MultiresModifierData *get_multires_modifier(struct Scene *scene, struct Object *ob, int use_first); +struct MultiresModifierData *get_multires_modifier(struct Scene *scene, struct Object *ob, bool use_first); struct DerivedMesh *get_multires_dm(struct Scene *scene, struct MultiresModifierData *mmd, struct Object *ob); void multiresModifier_del_levels(struct MultiresModifierData *, struct Object *, int direction); diff --git a/source/blender/blenkernel/BKE_nla.h b/source/blender/blenkernel/BKE_nla.h index 9e08f3a8c83..5b41dc481c9 100644 --- a/source/blender/blenkernel/BKE_nla.h +++ b/source/blender/blenkernel/BKE_nla.h @@ -114,7 +114,7 @@ void BKE_nla_tweakmode_exit(struct AnimData *adt); /* Time Mapping */ /* time mapping conversion modes */ -enum { +enum eNlaTime_ConvertModes { /* convert from global time to strip time - for evaluation */ NLATIME_CONVERT_EVAL = 0, /* convert from global time to strip time - for editing corrections */ @@ -123,7 +123,7 @@ enum { /* convert from strip time to global time */ // xxx old 1 invert NLATIME_CONVERT_MAP, -} eNlaTime_ConvertModes; +}; float BKE_nla_tweakedit_remap(struct AnimData *adt, float cframe, short mode); diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index d9a311b7e13..e62994576a3 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -83,6 +83,7 @@ struct ColorManagedViewSettings; struct ColorManagedDisplaySettings; struct bNodeInstanceHash; + /* ************** NODE TYPE DEFINITIONS ***** */ /** Compact definition of a node socket. @@ -331,6 +332,7 @@ typedef struct bNodeTreeType { struct bNodeTreeType *ntreeTypeFind(const char *idname); void ntreeTypeAdd(struct bNodeTreeType *nt); void ntreeTypeFreeLink(struct bNodeTreeType *nt); +bool ntreeIsRegistered(struct bNodeTree *ntree); struct GHashIterator *ntreeTypeGetIterator(void); /* helper macros for iterating over tree types */ @@ -346,7 +348,6 @@ struct GHashIterator *ntreeTypeGetIterator(void); } void ntreeSetTypes(const struct bContext *C, struct bNodeTree *ntree); -int ntreeIsValid(struct bNodeTree *ntree); struct bNodeTree *ntreeAddTree(struct Main *bmain, const char *name, const char *idname); @@ -407,6 +408,7 @@ void ntreeInterfaceTypeUpdate(struct bNodeTree *ntree); struct bNodeType *nodeTypeFind(const char *idname); void nodeRegisterType(struct bNodeType *ntype); void nodeUnregisterType(struct bNodeType *ntype); +bool nodeIsRegistered(struct bNode *node); struct GHashIterator *nodeTypeGetIterator(void); /* helper macros for iterating over node types */ @@ -424,6 +426,7 @@ struct GHashIterator *nodeTypeGetIterator(void); struct bNodeSocketType *nodeSocketTypeFind(const char *idname); void nodeRegisterSocketType(struct bNodeSocketType *stype); void nodeUnregisterSocketType(struct bNodeSocketType *stype); +bool nodeSocketIsRegistered(struct bNodeSocket *sock); struct GHashIterator *nodeSocketTypeGetIterator(void); const char * nodeStaticSocketType(int type, int subtype); const char * nodeStaticSocketInterfaceType(int type, int subtype); @@ -563,7 +566,7 @@ void BKE_node_preview_clear(struct bNodePreview *preview); void BKE_node_preview_clear_tree(struct bNodeTree *ntree); void BKE_node_preview_sync_tree(struct bNodeTree *to_ntree, struct bNodeTree *from_ntree); -void BKE_node_preview_merge_tree(struct bNodeTree *to_ntree, struct bNodeTree *from_ntree); +void BKE_node_preview_merge_tree(struct bNodeTree *to_ntree, struct bNodeTree *from_ntree, bool remove_old); void BKE_node_preview_set_pixel(struct bNodePreview *preview, const float col[4], int x, int y, int do_manage); diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index 5caa484caa0..da5fa3e8195 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -91,11 +91,11 @@ bool BKE_object_is_libdata(struct Object *ob); bool BKE_object_obdata_is_libdata(struct Object *ob); void BKE_object_scale_to_mat3(struct Object *ob, float mat[3][3]); -void BKE_object_rot_to_mat3(struct Object *ob, float mat[3][3], short use_drot); -void BKE_object_mat3_to_rot(struct Object *ob, float mat[3][3], short use_compat); +void BKE_object_rot_to_mat3(struct Object *ob, float mat[3][3], bool use_drot); +void BKE_object_mat3_to_rot(struct Object *ob, float mat[3][3], bool use_compat); void BKE_object_to_mat3(struct Object *ob, float mat[3][3]); void BKE_object_to_mat4(struct Object *ob, float mat[4][4]); -void BKE_object_apply_mat4(struct Object *ob, float mat[4][4], const short use_compat, const short use_parent); +void BKE_object_apply_mat4(struct Object *ob, float mat[4][4], const bool use_compat, const bool use_parent); int BKE_object_pose_context_check(struct Object *ob); struct Object *BKE_object_pose_armature_get(struct Object *ob); @@ -117,8 +117,8 @@ struct BoundBox *BKE_object_boundbox_get(struct Object *ob); void BKE_object_dimensions_get(struct Object *ob, float vec[3]); void BKE_object_dimensions_set(struct Object *ob, const float *value); void BKE_object_boundbox_flag(struct Object *ob, int flag, int set); -void BKE_object_minmax(struct Object *ob, float r_min[3], float r_max[3], const short use_hidden); -int BKE_object_minmax_dupli(struct Scene *scene, struct Object *ob, float r_min[3], float r_max[3], const short use_hidden); +void BKE_object_minmax(struct Object *ob, float r_min[3], float r_max[3], const bool use_hidden); +int BKE_object_minmax_dupli(struct Scene *scene, struct Object *ob, float r_min[3], float r_max[3], const bool use_hidden); /* sometimes min-max isn't enough, we need to loop over each point */ void BKE_object_foreach_display_point(struct Object *ob, float obmat[4][4], diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h index a46d947b9d9..9586df6d119 100644 --- a/source/blender/blenkernel/BKE_sequencer.h +++ b/source/blender/blenkernel/BKE_sequencer.h @@ -368,7 +368,7 @@ struct Sequence *BKE_sequencer_add_sound_strip(struct bContext *C, ListBase *seq struct Sequence *BKE_sequencer_add_movie_strip(struct bContext *C, ListBase *seqbasep, struct SeqLoadInfo *seq_load); /* view3d draw callback, run when not in background view */ -typedef struct ImBuf *(*SequencerDrawView)(struct Scene *, struct Object *, int, int, unsigned int, int, int, int, int, char[256]); +typedef struct ImBuf *(*SequencerDrawView)(struct Scene *, struct Object *, int, int, unsigned int, int, bool, bool, int, char[256]); extern SequencerDrawView sequencer_view3d_cb; /* copy/paste */ diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index ddb4cc4391a..ad791852253 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -1712,7 +1712,7 @@ static void object_duplilist_recursive(ID *id, Scene *scene, Object *ob, ListBas /* Returns a list of DupliObject * note; group dupli's already set transform matrix. see note in group_duplilist() */ -ListBase *object_duplilist_ex(Scene *sce, Object *ob, int update, int for_render) +ListBase *object_duplilist_ex(Scene *sce, Object *ob, bool update, bool for_render) { ListBase *duplilist = MEM_mallocN(sizeof(ListBase), "duplilist"); int persistent_id[MAX_DUPLI_RECUR] = {0}; @@ -1728,9 +1728,9 @@ ListBase *object_duplilist_ex(Scene *sce, Object *ob, int update, int for_render /* note: previously updating was always done, this is why it defaults to be on * but there are likely places it can be called without updating */ -ListBase *object_duplilist(Scene *sce, Object *ob, int for_render) +ListBase *object_duplilist(Scene *sce, Object *ob, bool for_render) { - return object_duplilist_ex(sce, ob, TRUE, for_render); + return object_duplilist_ex(sce, ob, true, for_render); } diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index fa6aafabe05..b3c94beba93 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -66,6 +66,7 @@ #include "BKE_blender.h" #include "BKE_bpath.h" +#include "BKE_brush.h" #include "BKE_context.h" #include "BKE_depsgraph.h" #include "BKE_displist.h" @@ -120,6 +121,8 @@ void free_blender(void) IMB_exit(); BKE_images_exit(); + BKE_brush_system_exit(); + BLI_callback_global_finalize(); BKE_sequencer_cache_destruct(); diff --git a/source/blender/blenkernel/intern/bpath.c b/source/blender/blenkernel/intern/bpath.c index 6998ffabe65..852dcc6216c 100644 --- a/source/blender/blenkernel/intern/bpath.c +++ b/source/blender/blenkernel/intern/bpath.c @@ -682,14 +682,14 @@ int BKE_bpath_relocate_visitor(void *pathbase_v, char *path_dst, const char *pat struct PathStore { struct PathStore *next, *prev; -} PathStore; +}; static int bpath_list_append(void *userdata, char *UNUSED(path_dst), const char *path_src) { /* store the path and string in a single alloc */ ListBase *ls = userdata; size_t path_size = strlen(path_src) + 1; - struct PathStore *path_store = MEM_mallocN(sizeof(PathStore) + path_size, __func__); + struct PathStore *path_store = MEM_mallocN(sizeof(struct PathStore) + path_size, __func__); char *filepath = (char *)(path_store + 1); memcpy(filepath, path_src, path_size); diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index c594e19b960..d6cd7290038 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -55,6 +55,20 @@ #include "RE_render_ext.h" /* externtex */ #include "RE_shader_ext.h" +static RNG *brush_rng; + +void BKE_brush_system_init(void) +{ + brush_rng = BLI_rng_new(0); + BLI_rng_srandom(brush_rng, 31415682); +} + +void BKE_brush_system_exit(void) +{ + BLI_rng_free(brush_rng); +} + + static void brush_defaults(Brush *brush) { brush->blend = 0; @@ -877,8 +891,8 @@ void BKE_brush_jitter_pos(const Scene *scene, Brush *brush, const float pos[2], int diameter; do { - rand_pos[0] = BLI_frand() - 0.5f; - rand_pos[1] = BLI_frand() - 0.5f; + rand_pos[0] = BLI_rng_get_float(brush_rng) - 0.5f; + rand_pos[1] = BLI_rng_get_float(brush_rng) - 0.5f; } while (len_v2(rand_pos) > 0.5f); diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c index 34c2d144f4c..ae1fa3025b9 100644 --- a/source/blender/blenkernel/intern/camera.c +++ b/source/blender/blenkernel/intern/camera.c @@ -371,7 +371,7 @@ void BKE_camera_params_compute_matrix(CameraParams *params) /***************************** Camera View Frame *****************************/ -void BKE_camera_view_frame_ex(Scene *scene, Camera *camera, float drawsize, const short do_clip, const float scale[3], +void BKE_camera_view_frame_ex(Scene *scene, Camera *camera, float drawsize, const bool do_clip, const float scale[3], float r_asp[2], float r_shift[2], float *r_drawsize, float r_vec[4][3]) { float facx, facy; diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 3430c2ea7a1..dc47ff40863 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -43,6 +43,8 @@ #include "BLI_kdopbvh.h" #include "BLI_utildefines.h" +#include "BLF_translation.h" + #include "DNA_armature_types.h" #include "DNA_camera_types.h" #include "DNA_constraint_types.h" @@ -4353,12 +4355,12 @@ static bConstraint *add_new_constraint_internal(const char *name, short type) cti->new_data(con->data); /* if no name is provided, use the type of the constraint as the name */ - newName = (name && name[0]) ? name : cti->name; + newName = (name && name[0]) ? name : DATA_(cti->name); } else { /* if no name is provided, use the generic "Const" name */ /* NOTE: any constraint type that gets here really shouldn't get added... */ - newName = (name && name[0]) ? name : "Const"; + newName = (name && name[0]) ? name : DATA_("Const"); } /* copy the name */ diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 5d2c85e5825..5fba308e3df 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -3393,6 +3393,144 @@ bool BKE_nurb_order_clamp_v(struct Nurb *nu) return change; } +bool BKE_nurb_type_convert(Nurb *nu, const short type, const bool use_handles) +{ + BezTriple *bezt; + BPoint *bp; + int a, c, nr; + + if (nu->type == CU_POLY) { + if (type == CU_BEZIER) { /* to Bezier with vecthandles */ + nr = nu->pntsu; + bezt = (BezTriple *)MEM_callocN(nr * sizeof(BezTriple), "setsplinetype2"); + nu->bezt = bezt; + a = nr; + bp = nu->bp; + while (a--) { + copy_v3_v3(bezt->vec[1], bp->vec); + bezt->f1 = bezt->f2 = bezt->f3 = bp->f1; + bezt->h1 = bezt->h2 = HD_VECT; + bezt->weight = bp->weight; + bezt->radius = bp->radius; + bp++; + bezt++; + } + MEM_freeN(nu->bp); + nu->bp = NULL; + nu->pntsu = nr; + nu->type = CU_BEZIER; + BKE_nurb_handles_calc(nu); + } + else if (type == CU_NURBS) { + nu->type = CU_NURBS; + nu->orderu = 4; + nu->flagu &= CU_NURB_CYCLIC; /* disable all flags except for cyclic */ + BKE_nurb_knot_calc_u(nu); + a = nu->pntsu * nu->pntsv; + bp = nu->bp; + while (a--) { + bp->vec[3] = 1.0; + bp++; + } + } + } + else if (nu->type == CU_BEZIER) { /* Bezier */ + if (type == CU_POLY || type == CU_NURBS) { + nr = use_handles ? (3 * nu->pntsu) : nu->pntsu; + nu->bp = MEM_callocN(nr * sizeof(BPoint), "setsplinetype"); + a = nu->pntsu; + bezt = nu->bezt; + bp = nu->bp; + while (a--) { + if ((type == CU_POLY && bezt->h1 == HD_VECT && bezt->h2 == HD_VECT) || (use_handles == false)) { + /* vector handle becomes 1 poly vertice */ + copy_v3_v3(bp->vec, bezt->vec[1]); + bp->vec[3] = 1.0; + bp->f1 = bezt->f2; + if (use_handles) nr -= 2; + bp->radius = bezt->radius; + bp->weight = bezt->weight; + bp++; + } + else { + char *f = &bezt->f1; + for (c = 0; c < 3; c++, f++) { + copy_v3_v3(bp->vec, bezt->vec[c]); + bp->vec[3] = 1.0; + bp->f1 = *f; + bp->radius = bezt->radius; + bp->weight = bezt->weight; + bp++; + } + } + bezt++; + } + MEM_freeN(nu->bezt); + nu->bezt = NULL; + nu->pntsu = nr; + nu->pntsv = 1; + nu->orderu = 4; + nu->orderv = 1; + nu->type = type; + +#if 0 /* UNUSED */ + if (nu->flagu & CU_NURB_CYCLIC) c = nu->orderu - 1; + else c = 0; +#endif + + if (type == CU_NURBS) { + nu->flagu &= CU_NURB_CYCLIC; /* disable all flags except for cyclic */ + nu->flagu |= CU_NURB_BEZIER; + BKE_nurb_knot_calc_u(nu); + } + } + } + else if (nu->type == CU_NURBS) { + if (type == CU_POLY) { + nu->type = CU_POLY; + if (nu->knotsu) MEM_freeN(nu->knotsu); /* python created nurbs have a knotsu of zero */ + nu->knotsu = NULL; + if (nu->knotsv) MEM_freeN(nu->knotsv); + nu->knotsv = NULL; + } + else if (type == CU_BEZIER) { /* to Bezier */ + nr = nu->pntsu / 3; + + if (nr < 2) { + return false; /* conversion impossible */ + } + else { + bezt = MEM_callocN(nr * sizeof(BezTriple), "setsplinetype2"); + nu->bezt = bezt; + a = nr; + bp = nu->bp; + while (a--) { + copy_v3_v3(bezt->vec[0], bp->vec); + bezt->f1 = bp->f1; + bp++; + copy_v3_v3(bezt->vec[1], bp->vec); + bezt->f2 = bp->f1; + bp++; + copy_v3_v3(bezt->vec[2], bp->vec); + bezt->f3 = bp->f1; + bezt->radius = bp->radius; + bezt->weight = bp->weight; + bp++; + bezt++; + } + MEM_freeN(nu->bp); + nu->bp = NULL; + MEM_freeN(nu->knotsu); + nu->knotsu = NULL; + nu->pntsu = nr; + nu->type = CU_BEZIER; + } + } + } + + return true; +} + /* Get edit nurbs or normal nurbs list */ ListBase *BKE_curve_nurbs_get(Curve *cu) { diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index e91fd0cc929..bb14dbd3ad0 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -1463,6 +1463,14 @@ int CustomData_get_stencil_layer_index(const CustomData *data, int type) /* -------------------------------------------------------------------- */ /* index values per layer type */ +int CustomData_get_named_layer(const struct CustomData *data, int type, const char *name) +{ + const int named_index = CustomData_get_named_layer_index(data, type, name); + const int layer_index = data->typemap[type]; + BLI_assert(customdata_typemap_is_valid(data)); + return (named_index != -1) ? named_index - layer_index : -1; +} + int CustomData_get_active_layer(const CustomData *data, int type) { const int layer_index = data->typemap[type]; diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index 2ba71ecd9b5..7543892f2e3 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -126,7 +126,7 @@ void defvert_copy_index(MDeformVert *dvert_dst, const MDeformVert *dvert_src, co /* only sync over matching weights, don't add or remove groups * warning, loop within loop. */ -void defvert_sync(MDeformVert *dvert_dst, const MDeformVert *dvert_src, int use_verify) +void defvert_sync(MDeformVert *dvert_dst, const MDeformVert *dvert_src, const bool use_verify) { if (dvert_src->totweight && dvert_dst->totweight) { int i; @@ -145,7 +145,7 @@ void defvert_sync(MDeformVert *dvert_dst, const MDeformVert *dvert_src, int use_ /* be sure all flip_map values are valid */ void defvert_sync_mapped(MDeformVert *dvert_dst, const MDeformVert *dvert_src, - const int *flip_map, const int flip_map_len, const int use_verify) + const int *flip_map, const int flip_map_len, const bool use_verify) { if (dvert_src->totweight && dvert_dst->totweight) { int i; @@ -346,7 +346,7 @@ int defgroup_name_index(Object *ob, const char *name) } /* note, must be freed */ -int *defgroup_flip_map(Object *ob, int *flip_map_len, int use_default) +int *defgroup_flip_map(Object *ob, int *flip_map_len, const bool use_default) { int defbase_tot = *flip_map_len = BLI_countlist(&ob->defbase); @@ -384,7 +384,7 @@ int *defgroup_flip_map(Object *ob, int *flip_map_len, int use_default) } /* note, must be freed */ -int *defgroup_flip_map_single(Object *ob, int *flip_map_len, int use_default, int defgroup) +int *defgroup_flip_map_single(Object *ob, int *flip_map_len, const bool use_default, int defgroup) { int defbase_tot = *flip_map_len = BLI_countlist(&ob->defbase); @@ -416,7 +416,7 @@ int *defgroup_flip_map_single(Object *ob, int *flip_map_len, int use_default, in } } -int defgroup_flip_index(Object *ob, int index, int use_default) +int defgroup_flip_index(Object *ob, int index, const bool use_default) { bDeformGroup *dg = BLI_findlink(&ob->defbase, index); int flip_index = -1; diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 6f85d4de60e..e4d7814c4e1 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -122,17 +122,17 @@ DispList *BKE_displist_find(ListBase *lb, int type) return NULL; } -int BKE_displist_has_faces(ListBase *lb) +bool BKE_displist_has_faces(ListBase *lb) { DispList *dl; for (dl = lb->first; dl; dl = dl->next) { if (ELEM3(dl->type, DL_INDEX3, DL_INDEX4, DL_SURF)) { - return TRUE; + return true; } } - return FALSE; + return false; } void BKE_displist_copy(ListBase *lbn, ListBase *lb) @@ -271,10 +271,10 @@ void BKE_displist_count(ListBase *lb, int *totvert, int *totface, int *tottri) } } -int BKE_displist_surfindex_get(DispList *dl, int a, int *b, int *p1, int *p2, int *p3, int *p4) +bool BKE_displist_surfindex_get(DispList *dl, int a, int *b, int *p1, int *p2, int *p3, int *p4) { if ((dl->flag & DL_CYCL_V) == 0 && a == (dl->parts) - 1) { - return 0; + return false; } if (dl->flag & DL_CYCL_U) { @@ -297,7 +297,7 @@ int BKE_displist_surfindex_get(DispList *dl, int a, int *b, int *p1, int *p2, in (*p4) -= dl->nr * dl->parts; } - return 1; + return true; } /* ****************** make displists ********************* */ diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 24fb949481f..4e05595b93a 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -107,9 +107,9 @@ static int neighX[8] = {1, 1, 0, -1, -1, -1, 0, 1}; static int neighY[8] = {0, 1, 1, 1, 0, -1, -1, -1}; /* subframe_updateObject() flags */ -#define UPDATE_PARENTS (1 << 0) +#define SUBFRAME_RECURSION 5 #define UPDATE_MESH (1 << 1) -#define UPDATE_EVERYTHING (UPDATE_PARENTS | UPDATE_MESH) +#define UPDATE_EVERYTHING (UPDATE_MESH) // | UPDATE_PARENTS /* surface_getBrushFlags() return vals */ #define BRUSH_USES_VELOCITY (1 << 0) /* brush mesh raycast status */ @@ -509,7 +509,7 @@ static void object_cacheIgnoreClear(Object *ob, int state) BLI_freelistN(&pidlist); } -static int subframe_updateObject(Scene *scene, Object *ob, int flags, float frame) +static int subframe_updateObject(Scene *scene, Object *ob, int flags, int parent_recursion, float frame) { DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)modifiers_findByType(ob, eModifierType_DynamicPaint); bConstraint *con; @@ -519,10 +519,11 @@ static int subframe_updateObject(Scene *scene, Object *ob, int flags, float fram return 1; /* if object has parents, update them too */ - if (flags & UPDATE_PARENTS) { + if (parent_recursion) { + int recursion = parent_recursion-1; int is_canvas = 0; - if (ob->parent) is_canvas += subframe_updateObject(scene, ob->parent, 0, frame); - if (ob->track) is_canvas += subframe_updateObject(scene, ob->track, 0, frame); + if (ob->parent) is_canvas += subframe_updateObject(scene, ob->parent, 0, recursion, frame); + if (ob->track) is_canvas += subframe_updateObject(scene, ob->track, 0, recursion, frame); /* skip subframe if object is parented * to vertex of a dynamic paint canvas */ @@ -539,7 +540,7 @@ static int subframe_updateObject(Scene *scene, Object *ob, int flags, float fram cti->get_constraint_targets(con, &targets); for (ct = targets.first; ct; ct = ct->next) { if (ct->tar) - subframe_updateObject(scene, ct->tar, 0, frame); + subframe_updateObject(scene, ct->tar, 0, recursion, frame); } /* free temp targets */ if (cti->flush_constraint_targets) @@ -3183,7 +3184,7 @@ static void dynamicPaint_brushMeshCalculateVelocity(Scene *scene, Object *ob, Dy scene->r.cfra = prev_fra; scene->r.subframe = prev_sfra; - subframe_updateObject(scene, ob, UPDATE_EVERYTHING, BKE_scene_frame_get(scene)); + subframe_updateObject(scene, ob, UPDATE_EVERYTHING, SUBFRAME_RECURSION, BKE_scene_frame_get(scene)); dm_p = CDDM_copy(brush->dm); numOfVerts_p = dm_p->getNumVerts(dm_p); mvert_p = dm_p->getVertArray(dm_p); @@ -3193,7 +3194,7 @@ static void dynamicPaint_brushMeshCalculateVelocity(Scene *scene, Object *ob, Dy scene->r.cfra = cur_fra; scene->r.subframe = cur_sfra; - subframe_updateObject(scene, ob, UPDATE_EVERYTHING, BKE_scene_frame_get(scene)); + subframe_updateObject(scene, ob, UPDATE_EVERYTHING, SUBFRAME_RECURSION, BKE_scene_frame_get(scene)); dm_c = brush->dm; numOfVerts_c = dm_c->getNumVerts(dm_c); mvert_c = dm_p->getVertArray(dm_c); @@ -3243,13 +3244,13 @@ static void dynamicPaint_brushObjectCalculateVelocity(Scene *scene, Object *ob, /* previous frame dm */ scene->r.cfra = prev_fra; scene->r.subframe = prev_sfra; - subframe_updateObject(scene, ob, UPDATE_PARENTS, BKE_scene_frame_get(scene)); + subframe_updateObject(scene, ob, 0, SUBFRAME_RECURSION, BKE_scene_frame_get(scene)); copy_m4_m4(prev_obmat, ob->obmat); /* current frame dm */ scene->r.cfra = cur_fra; scene->r.subframe = cur_sfra; - subframe_updateObject(scene, ob, UPDATE_PARENTS, BKE_scene_frame_get(scene)); + subframe_updateObject(scene, ob, 0, SUBFRAME_RECURSION, BKE_scene_frame_get(scene)); /* calculate speed */ mul_m4_v3(prev_obmat, prev_loc); @@ -4973,7 +4974,7 @@ static int dynamicPaint_doStep(Scene *scene, Object *ob, DynamicPaintSurface *su /* update object data on this subframe */ if (subframe) { scene_setSubframe(scene, subframe); - subframe_updateObject(scene, brushObj, UPDATE_EVERYTHING, BKE_scene_frame_get(scene)); + subframe_updateObject(scene, brushObj, UPDATE_EVERYTHING, SUBFRAME_RECURSION, BKE_scene_frame_get(scene)); } /* Prepare materials if required */ if (brush_usesMaterial(brush, scene)) @@ -5007,7 +5008,7 @@ static int dynamicPaint_doStep(Scene *scene, Object *ob, DynamicPaintSurface *su if (subframe) { scene->r.cfra = scene_frame; scene->r.subframe = scene_subframe; - subframe_updateObject(scene, brushObj, UPDATE_EVERYTHING, BKE_scene_frame_get(scene)); + subframe_updateObject(scene, brushObj, UPDATE_EVERYTHING, SUBFRAME_RECURSION, BKE_scene_frame_get(scene)); } /* process special brush effects, like smudge */ diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 594b887d361..f63eb9f87e3 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -1024,10 +1024,11 @@ 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 */ 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); + if (G.debug & G_DEBUG) { + printf("Error: driver has an invalid target to use (path = %s)\n", dtar->rna_path); + } + driver->flag |= DRIVER_FLAG_INVALID; dtar->flag |= DTAR_FLAG_INVALID; return 0.0f; @@ -1089,8 +1090,9 @@ static float dtar_get_prop_val(ChannelDriver *driver, DriverTarget *dtar) } else { /* path couldn't be resolved */ - if (G.debug & G_DEBUG) + if (G.debug & G_DEBUG) { printf("Driver Evaluation Error: cannot resolve target for %s -> %s\n", id->name, dtar->rna_path); + } driver->flag |= DRIVER_FLAG_INVALID; dtar->flag |= DTAR_FLAG_INVALID; @@ -1152,19 +1154,25 @@ static float dvar_eval_rotDiff(ChannelDriver *driver, DriverVar *dvar) /* check what the error was */ if ((pchan == NULL) && (pchan2 == NULL)) { - printf("Driver Evaluation Error: Rotational difference failed - first 2 targets invalid\n"); + if (G.debug & G_DEBUG) { + printf("Driver Evaluation Error: Rotational difference failed - first 2 targets invalid\n"); + } dtar1->flag |= DTAR_FLAG_INVALID; dtar2->flag |= DTAR_FLAG_INVALID; } else if (pchan == NULL) { - printf("Driver Evaluation Error: Rotational difference failed - first target not valid PoseChannel\n"); + if (G.debug & G_DEBUG) { + printf("Driver Evaluation Error: Rotational difference failed - first target not valid PoseChannel\n"); + } dtar1->flag |= DTAR_FLAG_INVALID; dtar2->flag &= ~DTAR_FLAG_INVALID; } else if (pchan2 == NULL) { - printf("Driver Evaluation Error: Rotational difference failed - second target not valid PoseChannel\n"); + if (G.debug & G_DEBUG) { + printf("Driver Evaluation Error: Rotational difference failed - second target not valid PoseChannel\n"); + } dtar1->flag &= ~DTAR_FLAG_INVALID; dtar2->flag |= DTAR_FLAG_INVALID; diff --git a/source/blender/blenkernel/intern/idcode.c b/source/blender/blenkernel/intern/idcode.c index adc0503df29..c64c261b9b0 100644 --- a/source/blender/blenkernel/intern/idcode.c +++ b/source/blender/blenkernel/intern/idcode.c @@ -109,17 +109,36 @@ static IDType *idtype_from_code(int code) return NULL; } +/** + * Return if the ID code is a valid ID code. + * + * \param code The code to check. + * \return Boolean, 0 when invalid. + */ bool BKE_idcode_is_valid(int code) { return idtype_from_code(code) ? true : false; } +/** + * Return non-zero when an ID type is linkable. + * + * \param code The code to check. + * \return Boolean, 0 when non linkable. + */ bool BKE_idcode_is_linkable(int code) { IDType *idt = idtype_from_code(code); return idt ? ((idt->flags & IDTYPE_FLAGS_ISLINKABLE) != 0) : false; } +/** + * Convert an idcode into a name. + * + * \param code The code to convert. + * \return A static string representing the name of + * the code. + */ const char *BKE_idcode_to_name(int code) { IDType *idt = idtype_from_code(code); @@ -127,6 +146,12 @@ const char *BKE_idcode_to_name(int code) return idt ? idt->name : NULL; } +/** + * Convert a name into an idcode (ie. ID_SCE) + * + * \param name The name to convert. + * \return The code for the name, or 0 if invalid. + */ int BKE_idcode_from_name(const char *name) { IDType *idt = idtype_from_name(name); @@ -134,6 +159,13 @@ int BKE_idcode_from_name(const char *name) return idt ? idt->code : 0; } +/** + * Convert an idcode into a name (plural). + * + * \param code The code to convert. + * \return A static string representing the name of + * the code. + */ const char *BKE_idcode_to_name_plural(int code) { IDType *idt = idtype_from_code(code); @@ -141,6 +173,12 @@ const char *BKE_idcode_to_name_plural(int code) return idt ? idt->plural : NULL; } +/** + * Return an ID code and steps the index forward 1. + * + * \param index start as 0. + * \return the code, 0 when all codes have been returned. + */ int BKE_idcode_iter_step(int *index) { return (*index < nidtypes) ? idtypes[(*index)++].code : 0; diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index 8dc284e0a3e..ca1ae23c364 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -61,8 +61,10 @@ static char idp_size_table[] = { /* --------- property array type -------------*/ -/* note: as a start to move away from the stupid IDP_New function, this type - * has it's own allocation function.*/ +/** + * \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 *prop = MEM_callocN(sizeof(IDProperty), "IDProperty prop array"); @@ -443,8 +445,8 @@ void IDP_SyncGroupValues(IDProperty *dest, IDProperty *src) } } -/* - * replaces all properties with the same name in a destination group from a source group. +/** + * Replaces all properties with the same name in a destination group from a source group. */ void IDP_ReplaceGroupInGroup(IDProperty *dest, IDProperty *src) { @@ -471,9 +473,10 @@ void IDP_ReplaceGroupInGroup(IDProperty *dest, IDProperty *src) } } } -/* - * replaces a property with the same name in a group, or adds - * it if the properly doesn't exist. + +/** + * Checks if a property with the same name as prop exists, and if so replaces it. + * Use this to preserve order! */ void IDP_ReplaceInGroup(IDProperty *group, IDProperty *prop) { @@ -515,8 +518,21 @@ void IDP_MergeGroup(IDProperty *dest, IDProperty *src, const int do_overwrite) } } -/* returns 0 if an id property with the same name exists and it failed, - * or 1 if it succeeded in adding to the group.*/ +/** + * This function has a sanity check to make sure ID properties with the same name don't + * get added to the group. + * + * The sanity check just means the property is not added to the group if another property + * exists with the same name; the client code using ID properties then needs to detect this + * (the function that adds new properties to groups, IDP_AddToGroup,returns 0 if a property can't + * be added to the group, and 1 if it can) and free the property. + * + * Currently the code to free ID properties is designed to leave the actual struct + * you pass it un-freed, this is needed for how the system works. This means + * to free an ID property, you first call IDP_FreeProperty then MEM_freeN the + * struct. In the future this will just be IDP_FreeProperty and the code will + * be reorganized to work properly. + */ int IDP_AddToGroup(IDProperty *group, IDProperty *prop) { if (IDP_GetPropertyFromGroup(group, prop->name) == NULL) { @@ -528,6 +544,10 @@ int IDP_AddToGroup(IDProperty *group, IDProperty *prop) return 0; } +/** + * This is the same as IDP_AddToGroup, only you pass an item + * in the group list to be inserted after. + */ int IDP_InsertToGroup(IDProperty *group, IDProperty *previous, IDProperty *pnew) { if (IDP_GetPropertyFromGroup(group, pnew->name) == NULL) { @@ -539,6 +559,13 @@ int IDP_InsertToGroup(IDProperty *group, IDProperty *previous, IDProperty *pnew) return 0; } +/** + * \note this does not free the property!! + * + * To free the property, you have to do: + * IDP_FreeProperty(prop); //free all subdata + * MEM_freeN(prop); //free property struct itself + */ void IDP_RemFromGroup(IDProperty *group, IDProperty *prop) { group->len--; @@ -549,7 +576,7 @@ IDProperty *IDP_GetPropertyFromGroup(IDProperty *prop, const char *name) { return (IDProperty *)BLI_findstring(&prop->data.group, name, offsetof(IDProperty, name)); } - +/** same as above but ensure type match */ IDProperty *IDP_GetPropertyTypeFromGroup(IDProperty *prop, const char *name, const char type) { IDProperty *idprop = IDP_GetPropertyFromGroup(prop, name); @@ -561,6 +588,12 @@ typedef struct IDPIter { IDProperty *parent; } IDPIter; +/** + * 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(IDProperty *prop) { IDPIter *iter = MEM_callocN(sizeof(IDPIter), "IDPIter"); @@ -569,6 +602,12 @@ void *IDP_GetGroupIterator(IDProperty *prop) return (void *) iter; } +/** + * Returns the next item in the iteration. To use, simple for a loop like the following: + * while (IDP_GroupIterNext(iter) != NULL) { + * ... + * } + */ IDProperty *IDP_GroupIterNext(void *vself) { IDPIter *self = (IDPIter *) vself; @@ -582,6 +621,10 @@ IDProperty *IDP_GroupIterNext(void *vself) return (void *) next; } +/** + * 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) { MEM_freeN(vself); @@ -613,6 +656,11 @@ IDProperty *IDP_CopyProperty(IDProperty *prop) } } +/** + * 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. + */ IDProperty *IDP_GetProperties(ID *id, int create_if_needed) { if (id->properties) { @@ -702,7 +750,31 @@ int IDP_EqualsProperties(IDProperty *prop1, IDProperty *prop2) return IDP_EqualsProperties_ex(prop1, prop2, TRUE); } -/* 'val' is never NULL, don't check */ +/** + * Allocate a new ID. + * + * This function takes three arguments: the ID property type, a union which defines + * it's initial value, and a name. + * + * The union is simple to use; see the top of this header file for its definition. + * An example of using this function: + * + * IDPropertyTemplate val; + * IDProperty *group, *idgroup, *color; + * group = IDP_New(IDP_GROUP, val, "group1"); //groups don't need a template. + * + * val.array.len = 4 + * val.array.type = IDP_FLOAT; + * color = IDP_New(IDP_ARRAY, val, "color1"); + * + * idgroup = IDP_GetProperties(some_id, 1); + * IDP_AddToGroup(idgroup, color); + * IDP_AddToGroup(idgroup, group); + * + * Note that you MUST either attach the id property to an id property group with + * IDP_AddToGroup or MEM_freeN the property, doing anything else might result in + * a memory leak. + */ IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *name) { IDProperty *prop = NULL; @@ -793,9 +865,11 @@ IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *n return prop; } -/* NOTE: this will free all child properties including list arrays and groups! +/** + * \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 - * the actual IDProperty struct either.*/ + * the actual struct IDProperty struct either. + */ void IDP_FreeProperty(IDProperty *prop) { switch (prop->type) { @@ -821,8 +895,11 @@ void IDP_ClearProperty(IDProperty *prop) prop->len = prop->totallen = 0; } -/* Unlinks any IDProperty<->ID linkage that might be going on. - * note: currently unused.*/ +/** + * Unlinks any struct IDProperty<->ID linkage that might be going on. + * + * \note currently unused + */ void IDP_UnlinkProperty(IDProperty *prop) { switch (prop->type) { diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 4e79c086d4d..26651d76f68 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1819,7 +1819,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec } /* cleanup the buffer. */ - BLF_buffer(mono, NULL, NULL, 0, 0, 0, FALSE); + BLF_buffer(mono, NULL, NULL, 0, 0, 0, NULL); #undef BUFF_MARGIN_X #undef BUFF_MARGIN_Y @@ -3379,7 +3379,7 @@ void BKE_image_get_aspect(Image *image, float *aspx, float *aspy) unsigned char *BKE_image_get_pixels_for_frame(struct Image *image, int frame) { - ImageUser iuser = {0}; + ImageUser iuser = {NULL}; void *lock; ImBuf *ibuf; unsigned char *pixels = NULL; @@ -3406,7 +3406,7 @@ unsigned char *BKE_image_get_pixels_for_frame(struct Image *image, int frame) float *BKE_image_get_float_pixels_for_frame(struct Image *image, int frame) { - ImageUser iuser = {0}; + ImageUser iuser = {NULL}; void *lock; ImBuf *ibuf; float *pixels = NULL; diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index de176651c19..b36f484f4ee 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1814,7 +1814,7 @@ void BKE_mesh_calc_normals_mapping_ex(MVert *mverts, int numVerts, MLoop *mloop, MPoly *mpolys, int numLoops, int numPolys, float (*polyNors_r)[3], MFace *mfaces, int numFaces, int *origIndexFace, float (*faceNors_r)[3], - const short only_face_normals) + const bool only_face_normals) { float (*pnors)[3] = polyNors_r, (*fnors)[3] = faceNors_r; int i; diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index b0566a6495f..9b8101cdad4 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -95,7 +95,7 @@ ModifierData *modifier_new(int type) ModifierData *md = MEM_callocN(mti->structSize, mti->structName); /* note, this name must be made unique later */ - BLI_strncpy(md->name, mti->name, sizeof(md->name)); + BLI_strncpy(md->name, DATA_(mti->name), sizeof(md->name)); md->type = type; md->mode = eModifierMode_Realtime | eModifierMode_Render | eModifierMode_Expanded; diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index 821c8fe3bda..49a64d8e478 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -457,7 +457,29 @@ static ImBuf *get_imbuf_cache(MovieClip *clip, MovieClipUser *user, int flag) return NULL; } -static void put_imbuf_cache(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf, int flag) +static int has_imbuf_cache(MovieClip *clip, MovieClipUser *user, int flag) +{ + if (clip->cache) { + MovieClipImBufCacheKey key; + + key.framenr = user->framenr; + + if (flag & MCLIP_USE_PROXY) { + key.proxy = rendersize_to_proxy(user, flag); + key.render_flag = user->render_flag; + } + else { + key.proxy = IMB_PROXY_NONE; + key.render_flag = 0; + } + + return IMB_moviecache_has_frame(clip->cache->moviecache, &key); + } + + return FALSE; +} + +static bool put_imbuf_cache(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf, int flag, bool destructive) { MovieClipImBufCacheKey key; @@ -489,7 +511,13 @@ static void put_imbuf_cache(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf, i key.render_flag = 0; } - IMB_moviecache_put(clip->cache->moviecache, &key, ibuf); + if (destructive) { + IMB_moviecache_put(clip->cache->moviecache, &key, ibuf); + return true; + } + else { + return IMB_moviecache_put_if_possible(clip->cache->moviecache, &key, ibuf); + } } /*********************** common functions *************************/ @@ -814,7 +842,7 @@ static ImBuf *movieclip_get_postprocessed_ibuf(MovieClip *clip, MovieClipUser *u } if (ibuf && (cache_flag & MOVIECLIP_CACHE_SKIP) == 0) - put_imbuf_cache(clip, user, ibuf, flag); + put_imbuf_cache(clip, user, ibuf, flag, true); } if (ibuf) { @@ -1111,6 +1139,7 @@ void BKE_movieclip_reload(MovieClip *clip) free_buffers(clip); clip->tracking.stabilization.ok = FALSE; + clip->prefetch_ok = FALSE; /* update clip source */ detect_clip_source(clip); @@ -1420,13 +1449,58 @@ float BKE_movieclip_remap_clip_to_scene_frame(MovieClip *clip, float framenr) return framenr + (float) clip->start_frame - 1.0f; } -void BKE_movieclip_filename_for_frame(MovieClip *clip, int framenr, char *name) +void BKE_movieclip_filename_for_frame(MovieClip *clip, MovieClipUser *user, char *name) { - if (clip->source != MCLIP_SRC_MOVIE) { - get_sequence_fname(clip, framenr, name); + if (clip->source == MCLIP_SRC_SEQUENCE) { + int use_proxy; + + use_proxy = (clip->flag & MCLIP_USE_PROXY) && user->render_size != MCLIP_PROXY_RENDER_SIZE_FULL; + + if (use_proxy) { + int undistort = user->render_flag & MCLIP_PROXY_RENDER_UNDISTORT; + get_proxy_fname(clip, user->render_size, undistort, user->framenr, name); + } + else { + get_sequence_fname(clip, user->framenr, name); + } } else { BLI_strncpy(name, clip->name, FILE_MAX); BLI_path_abs(name, ID_BLEND_PATH(G.main, &clip->id)); } } + +ImBuf *BKE_movieclip_anim_ibuf_for_frame(MovieClip *clip, MovieClipUser *user) +{ + ImBuf *ibuf = NULL; + + if (clip->source == MCLIP_SRC_MOVIE) { + BLI_lock_thread(LOCK_MOVIECLIP); + ibuf = movieclip_load_movie_file(clip, user, user->framenr, clip->flag); + BLI_unlock_thread(LOCK_MOVIECLIP); + } + + return ibuf; +} + +int BKE_movieclip_has_cached_frame(MovieClip *clip, MovieClipUser *user) +{ + int has_frame = FALSE; + + BLI_lock_thread(LOCK_MOVIECLIP); + has_frame = has_imbuf_cache(clip, user, clip->flag); + BLI_unlock_thread(LOCK_MOVIECLIP); + + return has_frame; +} + +int BKE_movieclip_put_frame_if_possible(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf) +{ + bool result; + + BLI_lock_thread(LOCK_MOVIECLIP); + result = put_imbuf_cache(clip, user, ibuf, clip->flag, false); + BLI_unlock_thread(LOCK_MOVIECLIP); + + return result; +} diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 722e1f2b918..88f534c581c 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -310,7 +310,7 @@ MultiresModifierData *find_multires_modifier_before(Scene *scene, ModifierData * /* used for applying scale on mdisps layer and syncing subdivide levels when joining objects * use_first - return first multires modifier if all multires'es are disabled */ -MultiresModifierData *get_multires_modifier(Scene *scene, Object *ob, int use_first) +MultiresModifierData *get_multires_modifier(Scene *scene, Object *ob, bool use_first) { ModifierData *md; MultiresModifierData *mmd = NULL, *firstmmd = NULL; diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 757571b9cf6..788b185c6eb 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -74,6 +74,11 @@ #include "NOD_shader.h" #include "NOD_texture.h" +/* Fallback types for undefined tree, nodes, sockets */ +bNodeTreeType NodeTreeTypeUndefined; +bNodeType NodeTypeUndefined; +bNodeSocketType NodeSocketTypeUndefined; + static void node_add_sockets_from_type(bNodeTree *ntree, bNode *node, bNodeType *ntype) { @@ -101,12 +106,11 @@ static void node_add_sockets_from_type(bNodeTree *ntree, bNode *node, bNodeType /* Note: This function is called to initialize node data based on the type. * The bNodeType may not be registered at creation time of the node, * so this can be delayed until the node type gets registered. - * The node->typeinfo must not be used in that case until it is defined! */ static void node_init(const struct bContext *C, bNodeTree *ntree, bNode *node) { bNodeType *ntype = node->typeinfo; - if (!ntype) + if (ntype == &NodeTypeUndefined) return; /* only do this once */ @@ -151,22 +155,24 @@ static void node_init(const struct bContext *C, bNodeTree *ntree, bNode *node) static void ntree_set_typeinfo(bNodeTree *ntree, bNodeTreeType *typeinfo) { - ntree->typeinfo = typeinfo; - if (typeinfo) { + ntree->typeinfo = typeinfo; + /* deprecated integer type */ ntree->type = typeinfo->type; } else { + ntree->typeinfo = &NodeTreeTypeUndefined; + ntree->init &= ~NTREE_TYPE_INIT; } } static void node_set_typeinfo(const struct bContext *C, bNodeTree *ntree, bNode *node, bNodeType *typeinfo) { - node->typeinfo = typeinfo; - if (typeinfo) { + node->typeinfo = typeinfo; + /* deprecated integer type */ node->type = typeinfo->type; @@ -174,21 +180,25 @@ static void node_set_typeinfo(const struct bContext *C, bNodeTree *ntree, bNode node_init(C, ntree, node); } else { + node->typeinfo = &NodeTypeUndefined; + ntree->init &= ~NTREE_TYPE_INIT; } } static void node_socket_set_typeinfo(bNodeTree *ntree, bNodeSocket *sock, bNodeSocketType *typeinfo) { - sock->typeinfo = typeinfo; - if (typeinfo) { + sock->typeinfo = typeinfo; + if (sock->default_value == NULL) { /* initialize the default_value pointer used by standard socket types */ node_socket_init_default_value(sock); } } else { + sock->typeinfo = &NodeSocketTypeUndefined; + ntree->init &= ~NTREE_TYPE_INIT; } } @@ -301,14 +311,14 @@ void ntreeTypeFreeLink(bNodeTreeType *nt) BLI_ghash_remove(nodetreetypes_hash, nt->idname, NULL, ntree_free_type); } -GHashIterator *ntreeTypeGetIterator(void) +bool ntreeIsRegistered(bNodeTree *ntree) { - return BLI_ghashIterator_new(nodetreetypes_hash); + return (ntree->typeinfo != &NodeTreeTypeUndefined); } -int ntreeIsValid(bNodeTree *ntree) +GHashIterator *ntreeTypeGetIterator(void) { - return (ntree && (ntree->init & NTREE_TYPE_INIT)); + return BLI_ghashIterator_new(nodetreetypes_hash); } bNodeType *nodeTypeFind(const char *idname) @@ -370,6 +380,11 @@ void nodeUnregisterType(bNodeType *nt) BLI_ghash_remove(nodetypes_hash, nt->idname, NULL, node_free_type); } +bool nodeIsRegistered(bNode *node) +{ + return (node->typeinfo != &NodeTypeUndefined); +} + GHashIterator *nodeTypeGetIterator(void) { return BLI_ghashIterator_new(nodetypes_hash); @@ -410,6 +425,11 @@ void nodeUnregisterSocketType(bNodeSocketType *st) BLI_ghash_remove(nodesockettypes_hash, st->idname, NULL, node_free_socket_type); } +bool nodeSocketIsRegistered(bNodeSocket *sock) +{ + return (sock->typeinfo != &NodeSocketTypeUndefined); +} + GHashIterator *nodeSocketTypeGetIterator(void) { return BLI_ghashIterator_new(nodesockettypes_hash); @@ -1329,7 +1349,7 @@ static void node_preview_init_tree_recursive(bNodeInstanceHash *previews, bNodeT BKE_node_preview_verify(previews, key, xsize, ysize, create); } - if (node->type == NODE_GROUP) + if (node->type == NODE_GROUP && node->id) node_preview_init_tree_recursive(previews, (bNodeTree *)node->id, key, xsize, ysize, create); } } @@ -1354,7 +1374,7 @@ static void node_preview_tag_used_recursive(bNodeInstanceHash *previews, bNodeTr if (BKE_node_preview_used(node)) BKE_node_instance_hash_tag_key(previews, key); - if (node->type == NODE_GROUP) + if (node->type == NODE_GROUP && node->id) node_preview_tag_used_recursive(previews, (bNodeTree *)node->id, key); } } @@ -1433,18 +1453,38 @@ void BKE_node_preview_sync_tree(bNodeTree *to_ntree, bNodeTree *from_ntree) } } -void BKE_node_preview_merge_tree(bNodeTree *to_ntree, bNodeTree *from_ntree) +void BKE_node_preview_merge_tree(bNodeTree *to_ntree, bNodeTree *from_ntree, bool remove_old) { - /* free old previews */ - if (to_ntree->previews) - BKE_node_instance_hash_free(to_ntree->previews, (bNodeInstanceValueFP)BKE_node_preview_free); - - /* transfer previews */ - to_ntree->previews = from_ntree->previews; - from_ntree->previews = NULL; - - /* clean up, in case any to_ntree nodes have been removed */ - BKE_node_preview_remove_unused(to_ntree); + if (remove_old || !to_ntree->previews) { + /* free old previews */ + if (to_ntree->previews) + BKE_node_instance_hash_free(to_ntree->previews, (bNodeInstanceValueFP)BKE_node_preview_free); + + /* transfer previews */ + to_ntree->previews = from_ntree->previews; + from_ntree->previews = NULL; + + /* clean up, in case any to_ntree nodes have been removed */ + BKE_node_preview_remove_unused(to_ntree); + } + else { + bNodeInstanceHashIterator iter; + + if (from_ntree->previews) { + NODE_INSTANCE_HASH_ITER(iter, from_ntree->previews) { + bNodeInstanceKey key = BKE_node_instance_hash_iterator_get_key(&iter); + bNodePreview *preview = BKE_node_instance_hash_iterator_get_value(&iter); + + /* replace existing previews */ + BKE_node_instance_hash_remove(to_ntree->previews, key, (bNodeInstanceValueFP)BKE_node_preview_free); + BKE_node_instance_hash_insert(to_ntree->previews, key, preview); + } + + /* Note: NULL free function here, because pointers have already been moved over to to_ntree->previews! */ + BKE_node_instance_hash_free(from_ntree->previews, NULL); + from_ntree->previews = NULL; + } + } } /* hack warning! this function is only used for shader previews, and @@ -1887,7 +1927,7 @@ int ntreeOutputExists(bNode *node, bNodeSocket *testsock) /* returns localized tree for execution in threads */ bNodeTree *ntreeLocalize(bNodeTree *ntree) { - if (ntreeIsValid(ntree)) { + if (ntree) { bNodeTree *ltree; bNode *node; @@ -1944,13 +1984,7 @@ bNodeTree *ntreeLocalize(bNodeTree *ntree) /* is called by jobs manager, outside threads, so it doesnt happen during draw */ void ntreeLocalSync(bNodeTree *localtree, bNodeTree *ntree) { - if (localtree && ntreeIsValid(ntree)) { - /* XXX syncing was disabled for compositor nodes. - * It has to be ensured that there is no concurrent read/write access! - * Possibly needs a mutex lock or a flag to disable for certain tree types ... - */ - BKE_node_preview_sync_tree(ntree, localtree); - + if (localtree && ntree) { if (ntree->typeinfo->local_sync) ntree->typeinfo->local_sync(localtree, ntree); } @@ -1960,9 +1994,7 @@ void ntreeLocalSync(bNodeTree *localtree, bNodeTree *ntree) /* we have to assume the editor already changed completely */ void ntreeLocalMerge(bNodeTree *localtree, bNodeTree *ntree) { - if (localtree && ntreeIsValid(ntree)) { - BKE_node_preview_merge_tree(ntree, localtree); - + if (localtree && ntree) { if (ntree->typeinfo->local_merge) ntree->typeinfo->local_merge(localtree, ntree); @@ -2006,14 +2038,14 @@ static bNodeSocket *make_socket_template(bNodeTree *ntree, int in_out, * but reconstructing own_index in writefile.c would require parsing the identifier string. */ -#if (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 406)) +#if (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 406)) || defined(__clang__) # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wdeprecated-declarations" #endif sock->own_index = own_index; -#if (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 406)) +#if (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 406)) || defined(__clang__) # pragma GCC diagnostic pop #endif @@ -2425,7 +2457,7 @@ typedef struct bNodeClipboard { int type; } bNodeClipboard; -bNodeClipboard node_clipboard = {{0}}; +static bNodeClipboard node_clipboard = {{NULL}}; void BKE_node_clipboard_init(struct bNodeTree *ntree) { @@ -2831,11 +2863,8 @@ void ntreeVerifyNodes(struct Main *main, struct ID *id) FOREACH_NODETREE(main, ntree, owner_id) { bNode *node; - if (!ntreeIsValid(ntree)) - return; - for (node = ntree->nodes.first; node; node = node->next) - if (node->typeinfo && node->typeinfo->verifyfunc) + if (node->typeinfo->verifyfunc) node->typeinfo->verifyfunc(ntree, node, id); } FOREACH_NODETREE_END } @@ -2844,15 +2873,14 @@ void ntreeUpdateTree(bNodeTree *ntree) { bNode *node; + if (!ntree) + return; + /* avoid reentrant updates, can be caused by RNA update callbacks */ if (ntree->is_updating) return; ntree->is_updating = TRUE; - /* only if types are initialized */ - if (!ntreeIsValid(ntree)) - return; - if (ntree->update & (NTREE_UPDATE_LINKS | NTREE_UPDATE_NODES)) { /* set the bNodeSocket->link pointers */ ntree_update_link_pointers(ntree); @@ -3239,6 +3267,34 @@ void node_type_compatibility(struct bNodeType *ntype, short compatibility) ntype->compatibility = compatibility; } +/* callbacks for undefined types */ + +static int node_undefined_poll(bNodeType *UNUSED(ntype), bNodeTree *UNUSED(nodetree)) +{ + /* this type can not be added deliberately, it's just a placeholder */ + return false; +} + +/* register fallback types used for undefined tree, nodes, sockets */ +static void register_undefined_types(void) +{ + /* Note: these types are not registered in the type hashes, + * they are just used as placeholders in case the actual types are not registered. + */ + + strcpy(NodeTreeTypeUndefined.idname, "NodeTreeUndefined"); + strcpy(NodeTreeTypeUndefined.ui_name, "Undefined"); + strcpy(NodeTreeTypeUndefined.ui_description, "Undefined Node Tree Type"); + + node_type_base_custom(&NodeTypeUndefined, "NodeUndefined", "Undefined", 0, 0); + NodeTypeUndefined.poll = node_undefined_poll; + + BLI_strncpy(NodeSocketTypeUndefined.idname, "NodeSocketUndefined", sizeof(NodeSocketTypeUndefined.idname)); + /* extra type info for standard socket types */ + NodeSocketTypeUndefined.type = SOCK_CUSTOM; + NodeSocketTypeUndefined.subtype = PROP_NONE; +} + static void registerCompositNodes(void) { register_node_type_cmp_group(); @@ -3464,6 +3520,8 @@ void init_nodesystem(void) nodetypes_hash = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "nodetypes_hash gh"); nodesockettypes_hash = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "nodesockettypes_hash gh"); + register_undefined_types(); + register_standard_node_socket_types(); register_node_tree_type_cmp(); diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 20a5daf7116..f3655e94eb0 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -65,6 +65,8 @@ #include "BLI_utildefines.h" #include "BLI_linklist.h" +#include "BLF_translation.h" + #include "BKE_pbvh.h" #include "BKE_main.h" #include "BKE_global.h" @@ -865,20 +867,20 @@ void *BKE_object_obdata_add_from_type(int type) static const char *get_obdata_defname(int type) { switch (type) { - case OB_MESH: return "Mesh"; - case OB_CURVE: return "Curve"; - case OB_SURF: return "Surf"; - case OB_FONT: return "Text"; - case OB_MBALL: return "Mball"; - case OB_CAMERA: return "Camera"; - case OB_LAMP: return "Lamp"; - case OB_LATTICE: return "Lattice"; - case OB_ARMATURE: return "Armature"; - case OB_SPEAKER: return "Speaker"; - case OB_EMPTY: return "Empty"; + case OB_MESH: return DATA_("Mesh"); + case OB_CURVE: return DATA_("Curve"); + case OB_SURF: return DATA_("Surf"); + case OB_FONT: return DATA_("Text"); + case OB_MBALL: return DATA_("Mball"); + case OB_CAMERA: return DATA_("Camera"); + case OB_LAMP: return DATA_("Lamp"); + case OB_LATTICE: return DATA_("Lattice"); + case OB_ARMATURE: return DATA_("Armature"); + case OB_SPEAKER: return DATA_("Speaker"); + case OB_EMPTY: return DATA_("Empty"); default: printf("get_obdata_defname: Internal error, bad type: %d\n", type); - return "Empty"; + return DATA_("Empty"); } } @@ -1589,7 +1591,7 @@ void BKE_object_scale_to_mat3(Object *ob, float mat[3][3]) size_to_mat3(mat, vec); } -void BKE_object_rot_to_mat3(Object *ob, float mat[3][3], short use_drot) +void BKE_object_rot_to_mat3(Object *ob, float mat[3][3], bool use_drot) { float rmat[3][3], dmat[3][3]; @@ -1626,7 +1628,7 @@ void BKE_object_rot_to_mat3(Object *ob, float mat[3][3], short use_drot) copy_m3_m3(mat, rmat); } -void BKE_object_mat3_to_rot(Object *ob, float mat[3][3], short use_compat) +void BKE_object_mat3_to_rot(Object *ob, float mat[3][3], bool use_compat) { switch (ob->rotmode) { case ROT_MODE_QUAT: @@ -1729,7 +1731,7 @@ void BKE_object_tfm_protected_restore(Object *ob, } /* see BKE_pchan_apply_mat4() for the equivalent 'pchan' function */ -void BKE_object_apply_mat4(Object *ob, float mat[4][4], const short use_compat, const short use_parent) +void BKE_object_apply_mat4(Object *ob, float mat[4][4], const bool use_compat, const bool use_parent) { float rot[3][3]; @@ -2370,7 +2372,7 @@ void BKE_object_dimensions_set(Object *ob, const float *value) } } -void BKE_object_minmax(Object *ob, float min_r[3], float max_r[3], const short use_hidden) +void BKE_object_minmax(Object *ob, float min_r[3], float max_r[3], const bool use_hidden) { BoundBox bb; float vec[3]; @@ -2474,7 +2476,7 @@ void BKE_object_minmax(Object *ob, float min_r[3], float max_r[3], const short u } } -int BKE_object_minmax_dupli(Scene *scene, Object *ob, float r_min[3], float r_max[3], const short use_hidden) +int BKE_object_minmax_dupli(Scene *scene, Object *ob, float r_min[3], float r_max[3], const bool use_hidden) { int ok = FALSE; if ((ob->transflag & OB_DUPLI) == 0) { @@ -2486,7 +2488,7 @@ int BKE_object_minmax_dupli(Scene *scene, Object *ob, float r_min[3], float r_ma lb = object_duplilist(scene, ob, FALSE); for (dob = lb->first; dob; dob = dob->next) { - if ((use_hidden == FALSE) && (dob->no_draw != 0)) { + if ((use_hidden == false) && (dob->no_draw != 0)) { /* pass */ } else { diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index f90fde983aa..d9dabf24ba0 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -56,6 +56,8 @@ #include "BLI_threads.h" #include "BLI_linklist.h" +#include "BLF_translation.h" + #include "BKE_anim.h" #include "BKE_animsys.h" @@ -3488,17 +3490,19 @@ ModifierData *object_add_particle_system(Scene *scene, Object *ob, const char *n psys->pointcache = BKE_ptcache_add(&psys->ptcaches); BLI_addtail(&ob->particlesystem, psys); - psys->part = psys_new_settings("ParticleSettings", NULL); + psys->part = psys_new_settings(DATA_("ParticleSettings"), NULL); if (BLI_countlist(&ob->particlesystem) > 1) - BLI_snprintf(psys->name, sizeof(psys->name), "ParticleSystem %i", BLI_countlist(&ob->particlesystem)); + BLI_snprintf(psys->name, sizeof(psys->name), DATA_("ParticleSystem %i"), BLI_countlist(&ob->particlesystem)); else - strcpy(psys->name, "ParticleSystem"); + strcpy(psys->name, DATA_("ParticleSystem")); md = modifier_new(eModifierType_ParticleSystem); - if (name) BLI_strncpy_utf8(md->name, name, sizeof(md->name)); - else BLI_snprintf(md->name, sizeof(md->name), "ParticleSystem %i", BLI_countlist(&ob->particlesystem)); + if (name) + BLI_strncpy_utf8(md->name, name, sizeof(md->name)); + else + BLI_snprintf(md->name, sizeof(md->name), DATA_("ParticleSystem %i"), BLI_countlist(&ob->particlesystem)); modifier_unique_name(&ob->modifiers, md); psmd = (ParticleSystemModifierData *) md; diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index 435e81556ab..0863517c7d7 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -1303,9 +1303,17 @@ static void adjustDomainResolution(SmokeDomainSettings *sds, int new_shift[3], E int x, y, z, i; float *density = smoke_get_density(sds->fluid); float *fuel = smoke_get_fuel(sds->fluid); + float *bigdensity = smoke_turbulence_get_density(sds->wt); + float *bigfuel = smoke_turbulence_get_fuel(sds->wt); float *vx = smoke_get_velocity_x(sds->fluid); float *vy = smoke_get_velocity_y(sds->fluid); float *vz = smoke_get_velocity_z(sds->fluid); + int block_size = sds->amplify + 1; + int wt_res[3]; + + if (sds->flags & MOD_SMOKE_HIGHRES && sds->wt) { + smoke_turbulence_get_res(sds->wt, wt_res); + } INIT_MINMAX(min_vel, max_vel); @@ -1317,8 +1325,35 @@ static void adjustDomainResolution(SmokeDomainSettings *sds, int new_shift[3], E int xn = x - new_shift[0]; int yn = y - new_shift[1]; int zn = z - new_shift[2]; - int index = smoke_get_index(x - sds->res_min[0], sds->res[0], y - sds->res_min[1], sds->res[1], z - sds->res_min[2]); - float max_den = (fuel) ? MAX2(density[index], fuel[index]) : density[index]; + int index; + float max_den; + + /* skip if cell already belongs to new area */ + if (xn >= min[0] && xn <= max[0] && yn >= min[1] && yn <= max[1] && zn >= min[2] && zn <= max[2]) + continue; + + index = smoke_get_index(x - sds->res_min[0], sds->res[0], y - sds->res_min[1], sds->res[1], z - sds->res_min[2]); + max_den = (fuel) ? MAX2(density[index], fuel[index]) : density[index]; + + /* check high resolution bounds if max density isnt already high enough */ + if (max_den < sds->adapt_threshold && sds->flags & MOD_SMOKE_HIGHRES && sds->wt) { + int i, j, k; + /* high res grid index */ + int xx = (x - sds->res_min[0]) * block_size; + int yy = (y - sds->res_min[1]) * block_size; + int zz = (z - sds->res_min[2]) * block_size; + + for (i = 0; i < block_size; i++) + for (j = 0; j < block_size; j++) + for (k = 0; k < block_size; k++) + { + int big_index = smoke_get_index(xx + i, wt_res[0], yy + j, wt_res[1], zz + k); + float den = (bigfuel) ? MAX2(bigdensity[big_index], bigfuel[big_index]) : bigdensity[big_index]; + if (den > max_den) { + max_den = den; + } + } + } /* content bounds (use shifted coordinates) */ if (max_den >= sds->adapt_threshold) { @@ -1329,6 +1364,7 @@ static void adjustDomainResolution(SmokeDomainSettings *sds, int new_shift[3], E if (max[1] < yn) max[1] = yn; if (max[2] < zn) max[2] = zn; } + /* velocity bounds */ if (min_vel[0] > vx[index]) min_vel[0] = vx[index]; if (min_vel[1] > vy[index]) min_vel[1] = vy[index]; diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c index d4428be3faf..ff6212f6b09 100644 --- a/source/blender/blenkernel/intern/writeavi.c +++ b/source/blender/blenkernel/intern/writeavi.c @@ -73,7 +73,7 @@ static void filepath_avi(char *string, RenderData *rd); bMovieHandle *BKE_movie_handle_get(const char imtype) { - static bMovieHandle mh = {0}; + static bMovieHandle mh = {NULL}; /* set the default handle, as builtin */ #ifdef WITH_AVI diff --git a/source/blender/blenkernel/nla_private.h b/source/blender/blenkernel/nla_private.h index f068c4c58f0..2e38e33a308 100644 --- a/source/blender/blenkernel/nla_private.h +++ b/source/blender/blenkernel/nla_private.h @@ -49,7 +49,7 @@ typedef struct NlaEvalStrip { } NlaEvalStrip; /* NlaEvalStrip->strip_mode */ -enum { +enum eNlaEvalStrip_StripMode { /* standard evaluation */ NES_TIME_BEFORE = -1, NES_TIME_WITHIN, @@ -58,7 +58,7 @@ enum { /* transition-strip evaluations */ NES_TIME_TRANSITION_START, NES_TIME_TRANSITION_END, -} eNlaEvalStrip_StripMode; +}; /* temp channel for accumulating data from NLA (avoids needing to clear all values first) */ |