diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-05-05 15:40:42 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-05-05 15:40:42 +0400 |
commit | bb1f8d9586220446c4df6339554b6cb0af02f030 (patch) | |
tree | 8b0778b7f5e8eb18b7ce817e150efc949adcab22 /source/blender/blenkernel | |
parent | 19e27ce15b213bc7c888e4a57ad97faa5dbb4220 (diff) | |
parent | f1e3c31d4ffa86b695fddd45d9ccc6ce9ac62ea7 (diff) |
Merged changes in the trunk up to revision 46309.
Conflicts resolved:
source/blender/blenloader/intern/readfile.c
source/blender/editors/interface/resources.c
source/blender/editors/mesh/editmesh_tools.c
Diffstat (limited to 'source/blender/blenkernel')
90 files changed, 3360 insertions, 2904 deletions
diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h index 3a28af97166..a15192f156a 100644 --- a/source/blender/blenkernel/BKE_DerivedMesh.h +++ b/source/blender/blenkernel/BKE_DerivedMesh.h @@ -664,22 +664,22 @@ void DM_update_weight_mcol(struct Object *ob, struct DerivedMesh *dm, int const typedef struct DMVertexAttribs { struct { struct MTFace *array; - int emOffset, glIndex, glTexco; + int em_offset, gl_index, gl_texco; } tface[MAX_MTFACE]; struct { struct MCol *array; - int emOffset, glIndex; + int em_offset, gl_index; } mcol[MAX_MCOL]; struct { float (*array)[4]; - int emOffset, glIndex; + int em_offset, gl_index; } tang; struct { float (*array)[3]; - int emOffset, glIndex, glTexco; + int em_offset, gl_index, gl_texco; } orco; int tottface, totmcol, tottang, totorco; diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 14f5c27c3df..62f1dbc5867 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 0 +#define BLENDER_SUBVERSION 4 #define BLENDER_MINVERSION 250 #define BLENDER_MINSUBVERSION 0 diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h index 1ff9bc46638..b5edc8f3e50 100644 --- a/source/blender/blenkernel/BKE_brush.h +++ b/source/blender/blenkernel/BKE_brush.h @@ -41,34 +41,34 @@ struct wmOperator; // enum CurveMappingPreset; /* datablock functions */ -struct Brush *add_brush(const char *name); -struct Brush *copy_brush(struct Brush *brush); -void make_local_brush(struct Brush *brush); -void free_brush(struct Brush *brush); +struct Brush *BKE_brush_add(const char *name); +struct Brush *BKE_brush_copy(struct Brush *brush); +void BKE_brush_make_local(struct Brush *brush); +void BKE_brush_free(struct Brush *brush); -void brush_reset_sculpt(struct Brush *brush); +void BKE_brush_sculpt_reset(struct Brush *brush); /* image icon function */ struct ImBuf *get_brush_icon(struct Brush *brush); /* brush library operations used by different paint panels */ -int brush_texture_set_nr(struct Brush *brush, int nr); -int brush_texture_delete(struct Brush *brush); -int brush_clone_image_set_nr(struct Brush *brush, int nr); -int brush_clone_image_delete(struct Brush *brush); +int BKE_brush_texture_set_nr(struct Brush *brush, int nr); +int BKE_brush_texture_delete(struct Brush *brush); +int BKE_brush_clone_image_set_nr(struct Brush *brush, int nr); +int BKE_brush_clone_image_delete(struct Brush *brush); /* jitter */ -void brush_jitter_pos(const struct Scene *scene, struct Brush *brush, +void BKE_brush_jitter_pos(const struct Scene *scene, struct Brush *brush, const float pos[2], float jitterpos[2]); /* brush curve */ -void brush_curve_preset(struct Brush *b, /*enum CurveMappingPreset*/int preset); -float brush_curve_strength_clamp(struct Brush *br, float p, const float len); -float brush_curve_strength(struct Brush *br, float p, const float len); /* used for sculpt */ +void BKE_brush_curve_preset(struct Brush *b, /*enum CurveMappingPreset*/int preset); +float BKE_brush_curve_strength_clamp(struct Brush *br, float p, const float len); +float BKE_brush_curve_strength(struct Brush *br, float p, const float len); /* used for sculpt */ /* sampling */ -void brush_sample_tex(const struct Scene *scene, struct Brush *brush, const float xy[2], float rgba[4], const int thread); -void brush_imbuf_new(const struct Scene *scene, struct Brush *brush, short flt, short texfalloff, int size, +void BKE_brush_sample_tex(const struct Scene *scene, struct Brush *brush, const float xy[2], float rgba[4], const int thread); +void BKE_brush_imbuf_new(const struct Scene *scene, struct Brush *brush, short flt, short texfalloff, int size, struct ImBuf **imbuf, int use_color_correction); /* painting */ @@ -76,46 +76,48 @@ struct BrushPainter; typedef struct BrushPainter BrushPainter; typedef int (*BrushFunc)(void *user, struct ImBuf *ibuf, const float lastpos[2], const float pos[2]); -BrushPainter *brush_painter_new(struct Scene *scene, struct Brush *brush); -void brush_painter_require_imbuf(BrushPainter *painter, short flt, +BrushPainter *BKE_brush_painter_new(struct Scene *scene, struct Brush *brush); +void BKE_brush_painter_require_imbuf(BrushPainter *painter, short flt, short texonly, int size); -int brush_painter_paint(BrushPainter *painter, BrushFunc func, const float pos[2], +int BKE_brush_painter_paint(BrushPainter *painter, BrushFunc func, const float pos[2], double time, float pressure, void *user, int use_color_correction); -void brush_painter_break_stroke(BrushPainter *painter); -void brush_painter_free(BrushPainter *painter); +void BKE_brush_painter_break_stroke(BrushPainter *painter); +void BKE_brush_painter_free(BrushPainter *painter); /* texture */ -unsigned int *brush_gen_texture_cache(struct Brush *br, int half_side); +unsigned int *BKE_brush_gen_texture_cache(struct Brush *br, int half_side); /* radial control */ -struct ImBuf *brush_gen_radial_control_imbuf(struct Brush *br); +struct ImBuf *BKE_brush_gen_radial_control_imbuf(struct Brush *br); /* unified strength and size */ -int brush_size(const struct Scene *scene, struct Brush *brush); -void brush_set_size(struct Scene *scene, struct Brush *brush, int value); +int BKE_brush_size_get(const struct Scene *scene, struct Brush *brush); +void BKE_brush_size_set(struct Scene *scene, struct Brush *brush, int value); -float brush_unprojected_radius(const struct Scene *scene, struct Brush *brush); -void brush_set_unprojected_radius(struct Scene *scene, struct Brush *brush, float value); +float BKE_brush_unprojected_radius_get(const struct Scene *scene, struct Brush *brush); +void BKE_brush_unprojected_radius_set(struct Scene *scene, struct Brush *brush, float value); -float brush_alpha(const struct Scene *scene, struct Brush *brush); +float BKE_brush_alpha_get(const struct Scene *scene, struct Brush *brush); +float BKE_brush_weight_get(const Scene *scene, struct Brush *brush); +void BKE_brush_weight_set(const Scene *scene, struct Brush *brush, float value); -int brush_use_locked_size(const struct Scene *scene, struct Brush *brush); -int brush_use_alpha_pressure(const struct Scene *scene, struct Brush *brush); -int brush_use_size_pressure(const struct Scene *scene, struct Brush *brush); +int BKE_brush_use_locked_size(const struct Scene *scene, struct Brush *brush); +int BKE_brush_use_alpha_pressure(const struct Scene *scene, struct Brush *brush); +int BKE_brush_use_size_pressure(const struct Scene *scene, struct Brush *brush); /* scale unprojected radius to reflect a change in the brush's 2D size */ -void brush_scale_unprojected_radius(float *unprojected_radius, +void BKE_brush_scale_unprojected_radius(float *unprojected_radius, int new_brush_size, int old_brush_size); /* scale brush size to reflect a change in the brush's unprojected radius */ -void brush_scale_size(int *brush_size, +void BKE_brush_scale_size(int *BKE_brush_size_get, float new_unprojected_radius, float old_unprojected_radius); /* debugging only */ -void brush_debug_print_state(struct Brush *br); +void BKE_brush_debug_print_state(struct Brush *br); #endif diff --git a/source/blender/blenkernel/BKE_camera.h b/source/blender/blenkernel/BKE_camera.h index 6d10219e74c..8f68d7abcac 100644 --- a/source/blender/blenkernel/BKE_camera.h +++ b/source/blender/blenkernel/BKE_camera.h @@ -48,18 +48,18 @@ struct View3D; /* Camera Datablock */ -void *add_camera(const char *name); -struct Camera *copy_camera(struct Camera *cam); -void make_local_camera(struct Camera *cam); -void free_camera(struct Camera *ca); +void *BKE_camera_add(const char *name); +struct Camera *BKE_camera_copy(struct Camera *cam); +void BKE_camera_make_local(struct Camera *cam); +void BKE_camera_free(struct Camera *ca); /* Camera Usage */ -float object_camera_dof_distance(struct Object *ob); -void object_camera_mode(struct RenderData *rd, struct Object *ob); +float BKE_camera_object_dof_distance(struct Object *ob); +void BKE_camera_object_mode(struct RenderData *rd, struct Object *ob); -int camera_sensor_fit(int sensor_fit, float sizex, float sizey); -float camera_sensor_size(int sensor_fit, float sensor_x, float sensor_y); +int BKE_camera_sensor_fit(int sensor_fit, float sizex, float sizey); +float BKE_camera_sensor_size(int sensor_fit, float sensor_x, float sensor_y); /* Camera Parameters: * @@ -102,21 +102,21 @@ typedef struct CameraParams { float winmat[4][4]; } CameraParams; -void camera_params_init(CameraParams *params); -void camera_params_from_object(CameraParams *params, struct Object *camera); -void camera_params_from_view3d(CameraParams *params, struct View3D *v3d, struct RegionView3D *rv3d); +void BKE_camera_params_init(CameraParams *params); +void BKE_camera_params_from_object(CameraParams *params, struct Object *camera); +void BKE_camera_params_from_view3d(CameraParams *params, struct View3D *v3d, struct RegionView3D *rv3d); -void camera_params_compute_viewplane(CameraParams *params, int winx, int winy, float aspx, float aspy); -void camera_params_compute_matrix(CameraParams *params); +void BKE_camera_params_compute_viewplane(CameraParams *params, int winx, int winy, float aspx, float aspy); +void BKE_camera_params_compute_matrix(CameraParams *params); /* Camera View Frame */ -void 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 short do_clip, const float scale[3], float r_asp[2], float r_shift[2], float *r_drawsize, float r_vec[4][3]); -void camera_view_frame(struct Scene *scene, struct Camera *camera, float r_vec[4][3]); +void BKE_camera_view_frame(struct Scene *scene, struct Camera *camera, float r_vec[4][3]); -int camera_view_frame_fit_to_scene( +int BKE_camera_view_frame_fit_to_scene( struct Scene *scene, struct View3D *v3d, struct Object *camera_ob, float r_co[3]); diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h index 623dbd9c7ac..378cc72beb1 100644 --- a/source/blender/blenkernel/BKE_cloth.h +++ b/source/blender/blenkernel/BKE_cloth.h @@ -169,10 +169,10 @@ typedef enum /* Spring types as defined in the paper.*/ typedef enum { - CLOTH_SPRING_TYPE_STRUCTURAL = ( 1 << 1 ), - CLOTH_SPRING_TYPE_SHEAR = ( 1 << 2 ) , - CLOTH_SPRING_TYPE_BENDING = ( 1 << 3 ), - CLOTH_SPRING_TYPE_GOAL = ( 1 << 4 ), + CLOTH_SPRING_TYPE_STRUCTURAL = (1 << 1), + CLOTH_SPRING_TYPE_SHEAR = (1 << 2), + CLOTH_SPRING_TYPE_BENDING = (1 << 3), + CLOTH_SPRING_TYPE_GOAL = (1 << 4) } CLOTH_SPRING_TYPES; /* SPRING FLAGS */ diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h index 6a3625e2133..4b52189d8b7 100644 --- a/source/blender/blenkernel/BKE_customdata.h +++ b/source/blender/blenkernel/BKE_customdata.h @@ -305,6 +305,7 @@ int CustomData_sizeof(int type); /* get the name of a layer type */ const char *CustomData_layertype_name(int type); +int CustomData_layertype_is_singleton(int type); /* make sure the name of layer at index is unique */ void CustomData_set_layer_unique_name(struct CustomData *data, int index); diff --git a/source/blender/blenkernel/BKE_deform.h b/source/blender/blenkernel/BKE_deform.h index 17275b6ea7d..559dd4571f5 100644 --- a/source/blender/blenkernel/BKE_deform.h +++ b/source/blender/blenkernel/BKE_deform.h @@ -69,9 +69,13 @@ void defvert_flip_merged(struct MDeformVert *dvert, const int *flip_map, const i void defvert_normalize(struct MDeformVert *dvert); void defvert_normalize_lock(struct MDeformVert *dvert, const int def_nr_lock); -/* utility function, note that 32 chars is the maximum string length since its only +/* utility function, note that MAX_VGROUP_NAME chars is the maximum string length since its only * used with defgroups currently */ -void flip_side_name(char name[64], const char from_name[64], int strip_number); + +void BKE_deform_split_suffix(const char string[MAX_VGROUP_NAME], char base[MAX_VGROUP_NAME], char ext[MAX_VGROUP_NAME]); +void BKE_deform_split_prefix(const char string[MAX_VGROUP_NAME], char base[MAX_VGROUP_NAME], char ext[MAX_VGROUP_NAME]); + +void flip_side_name(char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_NAME], int strip_number); #endif diff --git a/source/blender/blenkernel/BKE_displist.h b/source/blender/blenkernel/BKE_displist.h index 5a36add2834..c5684e83903 100644 --- a/source/blender/blenkernel/BKE_displist.h +++ b/source/blender/blenkernel/BKE_displist.h @@ -1,5 +1,4 @@ /* - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -24,8 +23,7 @@ * Contributor(s): none yet. * * ***** END GPL LICENSE BLOCK ***** - -*/ + */ #ifndef __BKE_DISPLIST_H__ #define __BKE_DISPLIST_H__ diff --git a/source/blender/blenkernel/BKE_dynamicpaint.h b/source/blender/blenkernel/BKE_dynamicpaint.h index a71522773fe..59f8864bb21 100644 --- a/source/blender/blenkernel/BKE_dynamicpaint.h +++ b/source/blender/blenkernel/BKE_dynamicpaint.h @@ -1,4 +1,4 @@ -/** +/* * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -6,6 +6,15 @@ * 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. + * * Contributor(s): Miika Hämäläinen * * ***** END GPL LICENSE BLOCK ***** @@ -14,6 +23,10 @@ #ifndef __BKE_DYNAMICPAINT_H__ #define __BKE_DYNAMICPAINT_H__ +/** \file BKE_dynamicpaint.h + * \ingroup bke + */ + struct bContext; struct wmOperator; diff --git a/source/blender/blenkernel/BKE_font.h b/source/blender/blenkernel/BKE_font.h index e94787cfd3c..16e98f25e0c 100644 --- a/source/blender/blenkernel/BKE_font.h +++ b/source/blender/blenkernel/BKE_font.h @@ -49,7 +49,7 @@ struct Main; struct chartrans { float xof, yof; float rot; - short linenr,charnr; + short linenr, charnr; char dobreak; }; diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h index b18d25094dc..be21996428a 100644 --- a/source/blender/blenkernel/BKE_library.h +++ b/source/blender/blenkernel/BKE_library.h @@ -85,7 +85,7 @@ struct ID *find_id(const char *type, const char *name); void clear_id_newpoins(void); void IDnames_to_pupstring(const char **str, const char *title, const char *extraops, - struct ListBase *lb,struct ID* link, short *nr); + struct ListBase *lb, struct ID* link, short *nr); void IMAnames_to_pupstring(const char **str, const char *title, const char *extraops, struct ListBase *lb, struct ID *link, short *nr); diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index 742e6ef0b89..14cb5d19ddf 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -146,7 +146,7 @@ void copy_dverts(struct MDeformVert *dst, struct MDeformVert *src, int totvert); void mesh_delete_material_index(struct Mesh *me, short index); void mesh_set_smooth_flag(struct Object *meshOb, int enableSmooth); void BKE_mesh_convert_mfaces_to_mpolys(struct Mesh *mesh); -void mesh_calc_normals_tessface(struct MVert *mverts, int numVerts,struct MFace *mfaces, int numFaces, float (*faceNors_r)[3]); +void mesh_calc_normals_tessface(struct MVert *mverts, int numVerts, struct MFace *mfaces, int numFaces, float (*faceNors_r)[3]); /* used for unit testing; compares two meshes, checking only * differences we care about. should be usable with leaf's diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index cb161b26ee5..e7e1577c6b4 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -123,7 +123,7 @@ typedef struct bNodeTemplate { * implementing the node behavior. */ typedef struct bNodeType { - void *next,*prev; + void *next, *prev; short needs_free; /* set for allocated types that need to be freed */ int type; @@ -145,6 +145,9 @@ typedef struct bNodeType { void (*uifunc)(struct uiLayout *, struct bContext *C, struct PointerRNA *ptr); /// Additional parameters in the side panel. void (*uifuncbut)(struct uiLayout *, struct bContext *C, struct PointerRNA *ptr); + /// Draw a node socket. Default draws the input value button. + NodeSocketButtonFunction drawinputfunc; + NodeSocketButtonFunction drawoutputfunc; /// Optional custom label function for the node header. const char *(*labelfunc)(struct bNode *); /// Optional custom resize handle polling. diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index 971320765e9..2e334c4abc9 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -80,6 +80,7 @@ int exist_object(struct Object *obtest); struct Object *add_only_object(int type, const char *name); struct Object *add_object(struct Scene *scene, int type); +void *add_obdata_from_type(int type); struct Object *copy_object(struct Object *ob); void make_local_object(struct Object *ob); @@ -152,6 +153,7 @@ int object_insert_ptcache(struct Object *ob); struct KeyBlock *object_insert_shape_key(struct Scene *scene, struct Object *ob, const char *name, int from_mix); int object_is_modified(struct Scene *scene, struct Object *ob); +int object_is_deform_modified(struct Scene *scene, struct Object *ob); void object_relink(struct Object *ob); diff --git a/source/blender/blenkernel/BKE_ocean.h b/source/blender/blenkernel/BKE_ocean.h index 7c0d99b35ea..1c659b61d7d 100644 --- a/source/blender/blenkernel/BKE_ocean.h +++ b/source/blender/blenkernel/BKE_ocean.h @@ -32,17 +32,16 @@ extern "C" { typedef struct OceanResult { float disp[3]; - float normal[3]; + float normal[3]; float foam; /* raw eigenvalues/vectors */ float Jminus; - float Jplus; + float Jplus; float Eminus[3]; - float Eplus[3]; + float Eplus[3]; } OceanResult; - - + typedef struct OceanCache { struct ImBuf **ibufs_disp; struct ImBuf **ibufs_foam; @@ -74,13 +73,12 @@ typedef struct OceanCache { #define OCEAN_CACHING 1 #define OCEAN_CACHED 2 - struct Ocean *BKE_add_ocean(void); void BKE_free_ocean_data(struct Ocean *oc); void BKE_free_ocean(struct Ocean *oc); -void BKE_init_ocean(struct Ocean* o, int M,int N, float Lx, float Lz, float V, float l, float A, float w, float damp, - float alignment, float depth, float time, short do_height_field, short do_chop, short do_normals, short do_jacobian, int seed); +void BKE_init_ocean(struct Ocean* o, int M, int N, float Lx, float Lz, float V, float l, float A, float w, float damp, + float alignment, float depth, float time, short do_height_field, short do_chop, short do_normals, short do_jacobian, int seed); void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount); /* sampling the ocean surface */ diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h index acf39d83370..bd31a62abf9 100644 --- a/source/blender/blenkernel/BKE_paint.h +++ b/source/blender/blenkernel/BKE_paint.h @@ -103,6 +103,10 @@ typedef struct SculptSession { struct SculptStroke *stroke; struct StrokeCache *cache; + + /* last paint/sculpt stroke location */ + int last_stroke_valid; + float last_stroke[3]; } SculptSession; void free_sculptsession(struct Object *ob); diff --git a/source/blender/blenkernel/BKE_softbody.h b/source/blender/blenkernel/BKE_softbody.h index 6714225f513..547fd9e4393 100644 --- a/source/blender/blenkernel/BKE_softbody.h +++ b/source/blender/blenkernel/BKE_softbody.h @@ -39,9 +39,9 @@ typedef struct BodyPoint { float origS[3], origE[3], origT[3], pos[3], vec[3], force[3]; float goal; float prevpos[3], prevvec[3], prevdx[3], prevdv[3]; /* used for Heun integration */ - float impdv[3],impdx[3]; + float impdv[3], impdx[3]; int nofsprings; int *springs; - float choke,choke2,frozen; + float choke, choke2, frozen; float colball; short loc_flag; //reserved by locale module specific states //char octantflag; @@ -68,7 +68,7 @@ extern void sbObjectToSoftbody(struct Object *ob); /* pass NULL to unlink again */ extern void sbSetInterruptCallBack(int (*f)(void)); -extern void SB_estimate_transform(Object *ob,float lloc[3],float lrot[3][3],float lscale[3][3]); +extern void SB_estimate_transform(Object *ob, float lloc[3], float lrot[3][3], float lscale[3][3]); #endif diff --git a/source/blender/blenkernel/BKE_text.h b/source/blender/blenkernel/BKE_text.h index 0a94d89a121..115c00d9e73 100644 --- a/source/blender/blenkernel/BKE_text.h +++ b/source/blender/blenkernel/BKE_text.h @@ -96,6 +96,8 @@ void txt_unindent (struct Text *text); void txt_comment (struct Text *text); void txt_indent (struct Text *text); void txt_uncomment (struct Text *text); +void txt_move_lines (struct Text *text, const int direction); +void txt_duplicate_line (struct Text *text); int setcurr_tab_spaces (struct Text *text, int space); void txt_add_marker (struct Text *text, struct TextLine *line, int start, int end, const unsigned char color[4], int group, int flags); @@ -113,6 +115,11 @@ int text_check_digit(const char ch); int text_check_identifier(const char ch); int text_check_whitespace(const char ch); +enum { + TXT_MOVE_LINE_UP = -1, + TXT_MOVE_LINE_DOWN = 1 +}; + /* Undo opcodes */ @@ -169,6 +176,11 @@ int text_check_whitespace(const char ch); #define UNDO_COMMENT 034 #define UNDO_UNCOMMENT 035 +#define UNDO_MOVE_LINES_UP 036 +#define UNDO_MOVE_LINES_DOWN 037 + +#define UNDO_DUPLICATE 040 + /* Marker flags */ #define TMARK_TEMP 0x01 /* Remove on non-editing events, don't save */ #define TMARK_EDITALL 0x02 /* Edit all markers of the same group as one */ diff --git a/source/blender/blenkernel/BKE_tracking.h b/source/blender/blenkernel/BKE_tracking.h index 2bb8fc691f0..817cb477aba 100644 --- a/source/blender/blenkernel/BKE_tracking.h +++ b/source/blender/blenkernel/BKE_tracking.h @@ -164,6 +164,10 @@ struct MovieTrackingObject *BKE_tracking_named_object(struct MovieTracking *trac void BKE_tracking_select_track(struct ListBase *tracksbase, struct MovieTrackingTrack *track, int area, int extend); void BKE_tracking_deselect_track(struct MovieTrackingTrack *track, int area); +/* Dopesheet */ +void BKE_tracking_dopesheet_tag_update(struct MovieTracking *tracking); +void BKE_tracking_dopesheet_update(struct MovieTracking *tracking, int sort_method, int inverse); + #define TRACK_SELECTED(track) ((track)->flag&SELECT || (track)->pat_flag&SELECT || (track)->search_flag&SELECT) #define TRACK_AREA_SELECTED(track, area) ((area)==TRACK_AREA_POINT ? (track)->flag&SELECT : \ @@ -175,7 +179,7 @@ void BKE_tracking_deselect_track(struct MovieTrackingTrack *track, int area); (((sc)->flag & SC_SHOW_MARKER_PATTERN) && TRACK_AREA_SELECTED(track, TRACK_AREA_PAT)) || \ (((sc)->flag & SC_SHOW_MARKER_SEARCH) && TRACK_AREA_SELECTED(track, TRACK_AREA_SEARCH)))) -#define MARKER_VISIBLE(sc, marker) (((marker)->flag & MARKER_DISABLED)==0 || ((sc)->flag & SC_HIDE_DISABLED)==0) +#define MARKER_VISIBLE(sc, track, marker) (((marker)->flag & MARKER_DISABLED)==0 || ((sc)->flag & SC_HIDE_DISABLED)==0 || (sc->clip->tracking.act_track == track)) #define TRACK_CLEAR_UPTO 0 #define TRACK_CLEAR_REMAINED 1 @@ -194,4 +198,9 @@ void BKE_tracking_deselect_track(struct MovieTrackingTrack *track, int area); #define TRACK_AREA_ALL (TRACK_AREA_POINT|TRACK_AREA_PAT|TRACK_AREA_SEARCH) +#define TRACK_SORT_NONE -1 +#define TRACK_SORT_NAME 0 +#define TRACK_SORT_LONGEST 1 +#define TRACK_SORT_TOTAL 2 + #endif diff --git a/source/blender/blenkernel/BKE_utildefines.h b/source/blender/blenkernel/BKE_utildefines.h index 39458cb3a13..591be9e81c4 100644 --- a/source/blender/blenkernel/BKE_utildefines.h +++ b/source/blender/blenkernel/BKE_utildefines.h @@ -1,5 +1,4 @@ -/* - * +/* * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenkernel/depsgraph_private.h b/source/blender/blenkernel/depsgraph_private.h index f27ee2f1a41..c5e2f0900f0 100644 --- a/source/blender/blenkernel/depsgraph_private.h +++ b/source/blender/blenkernel/depsgraph_private.h @@ -117,10 +117,10 @@ DagNode * get_top_node_queue(DagNodeQueue *queue); DagForest *getMainDag(void); void setMainDag(DagForest *dag); DagForest * dag_init(void); -DagNode * dag_find_node (DagForest *forest,void * fob); -DagNode * dag_add_node (DagForest *forest,void * fob); -DagNode * dag_get_node (DagForest *forest,void * fob); -DagNode * dag_get_sub_node (DagForest *forest,void * fob); +DagNode * dag_find_node (DagForest *forest, void * fob); +DagNode * dag_add_node (DagForest *forest, void * fob); +DagNode * dag_get_node (DagForest *forest, void * fob); +DagNode * dag_get_sub_node (DagForest *forest, void * fob); void dag_add_relation(DagForest *forest, DagNode *fob1, DagNode *fob2, short rel, const char *name); void graph_bfs(void); diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 0fd030be39c..f648a9e297c 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -322,7 +322,7 @@ int DM_release(DerivedMesh *dm) { if (dm->needsFree) { bvhcache_free(&dm->bvhCache); - GPU_drawobject_free( dm ); + GPU_drawobject_free(dm); CustomData_free(&dm->vertData, dm->numVertData); CustomData_free(&dm->edgeData, dm->numEdgeData); CustomData_free(&dm->faceData, dm->numTessFaceData); @@ -371,7 +371,7 @@ void DM_ensure_tessface(DerivedMesh *dm) const int numTessFaces = dm->getNumTessFaces(dm); const int numPolys = dm->getNumPolys(dm); - if ( (numTessFaces == 0) && (numPolys != 0)) { + if ((numTessFaces == 0) && (numPolys != 0)) { dm->recalcTessellation(dm); if (dm->getNumTessFaces(dm) != 0) { @@ -2413,7 +2413,7 @@ static void GetTextureCoordinate(const SMikkTSpaceContext * pContext, float fUV[ } else { const float *orco= pMesh->orco[(&pMesh->mface[face_num].v1)[vert_index]]; - map_to_sphere( &fUV[0], &fUV[1], orco[0], orco[1], orco[2]); + map_to_sphere(&fUV[0], &fUV[1], orco[0], orco[1], orco[2]); } } @@ -2536,11 +2536,11 @@ void DM_add_tangent_layer(DerivedMesh *dm) if (mf->v4) { v4= &mvert[mf->v4]; - normal_quad_v3( fno,v4->co, v3->co, v2->co, v1->co); + normal_quad_v3(fno, v4->co, v3->co, v2->co, v1->co); } else { v4= NULL; - normal_tri_v3( fno,v3->co, v2->co, v1->co); + normal_tri_v3(fno, v3->co, v2->co, v1->co); } if (mtface) { @@ -2551,11 +2551,11 @@ void DM_add_tangent_layer(DerivedMesh *dm) } else { uv1= uv[0]; uv2= uv[1]; uv3= uv[2]; uv4= uv[3]; - map_to_sphere( &uv[0][0], &uv[0][1],orco[mf->v1][0], orco[mf->v1][1], orco[mf->v1][2]); - map_to_sphere( &uv[1][0], &uv[1][1],orco[mf->v2][0], orco[mf->v2][1], orco[mf->v2][2]); - map_to_sphere( &uv[2][0], &uv[2][1],orco[mf->v3][0], orco[mf->v3][1], orco[mf->v3][2]); + map_to_sphere(&uv[0][0], &uv[0][1], orco[mf->v1][0], orco[mf->v1][1], orco[mf->v1][2]); + map_to_sphere(&uv[1][0], &uv[1][1], orco[mf->v2][0], orco[mf->v2][1], orco[mf->v2][2]); + map_to_sphere(&uv[2][0], &uv[2][1], orco[mf->v3][0], orco[mf->v3][1], orco[mf->v3][2]); if (v4) - map_to_sphere( &uv[3][0], &uv[3][1],orco[mf->v4][0], orco[mf->v4][1], orco[mf->v4][2]); + map_to_sphere(&uv[3][0], &uv[3][1], orco[mf->v4][0], orco[mf->v4][1], orco[mf->v4][2]); } tangent_from_uv(uv1, uv2, uv3, v1->co, v2->co, v3->co, fno, tang); @@ -2578,11 +2578,11 @@ void DM_add_tangent_layer(DerivedMesh *dm) len= (mf->v4)? 4 : 3; if (mtface == NULL) { - map_to_sphere( &uv[0][0], &uv[0][1],orco[mf->v1][0], orco[mf->v1][1], orco[mf->v1][2]); - map_to_sphere( &uv[1][0], &uv[1][1],orco[mf->v2][0], orco[mf->v2][1], orco[mf->v2][2]); - map_to_sphere( &uv[2][0], &uv[2][1],orco[mf->v3][0], orco[mf->v3][1], orco[mf->v3][2]); + map_to_sphere(&uv[0][0], &uv[0][1], orco[mf->v1][0], orco[mf->v1][1], orco[mf->v1][2]); + map_to_sphere(&uv[1][0], &uv[1][1], orco[mf->v2][0], orco[mf->v2][1], orco[mf->v2][2]); + map_to_sphere(&uv[2][0], &uv[2][1], orco[mf->v3][0], orco[mf->v3][1], orco[mf->v3][2]); if (len==4) - map_to_sphere( &uv[3][0], &uv[3][1],orco[mf->v4][0], orco[mf->v4][1], orco[mf->v4][2]); + map_to_sphere(&uv[3][0], &uv[3][1], orco[mf->v4][0], orco[mf->v4][1], orco[mf->v4][2]); } mf_vi[0]= mf->v1; @@ -2616,7 +2616,7 @@ void DM_calc_auto_bump_scale(DerivedMesh *dm) int nr_accumulated = 0; int f; - for ( f=0; f < totface; f++ ) { + for (f=0; f < totface; f++ ) { { float * verts[4], * tex_coords[4]; const int nr_verts = mface[f].v4!=0 ? 4 : 3; @@ -2632,7 +2632,7 @@ void DM_calc_auto_bump_scale(DerivedMesh *dm) // 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]) ) + equals_v2v2(tex_coords[0], tex_coords[1]) || equals_v2v2(tex_coords[0], tex_coords[2]) || equals_v2v2(tex_coords[1], tex_coords[2])) { is_degenerate = 1; } @@ -2640,7 +2640,7 @@ void DM_calc_auto_bump_scale(DerivedMesh *dm) // 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]) ) + equals_v2v2(tex_coords[3], tex_coords[0]) || equals_v2v2(tex_coords[3], tex_coords[1]) || equals_v2v2(tex_coords[3], tex_coords[2])) { is_degenerate = 1; } @@ -2705,7 +2705,7 @@ void DM_calc_auto_bump_scale(DerivedMesh *dm) if (nr_tris_to_pile==1 || nr_tris_to_pile==2) { const int indices[] = {offs+0, offs+1, offs+2, offs+0, offs+2, (offs+3)&0x3 }; int t; - for ( t=0; t<nr_tris_to_pile; t++ ) { + for (t=0; t<nr_tris_to_pile; t++ ) { float f2x_area_uv; float * p0 = verts[indices[t*3+0]]; float * p1 = verts[indices[t*3+1]]; @@ -2786,9 +2786,9 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs, a = attribs->tottface++; attribs->tface[a].array = tfdata->layers[layer].data; - attribs->tface[a].emOffset = tfdata->layers[layer].offset; - attribs->tface[a].glIndex = gattribs->layer[b].glindex; - attribs->tface[a].glTexco = gattribs->layer[b].gltexco; + attribs->tface[a].em_offset = tfdata->layers[layer].offset; + attribs->tface[a].gl_index = gattribs->layer[b].glindex; + attribs->tface[a].gl_texco = gattribs->layer[b].gltexco; } } else { @@ -2802,9 +2802,9 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs, a = attribs->tottface++; attribs->tface[a].array = tfdata->layers[layer].data; - attribs->tface[a].emOffset = tfdata->layers[layer].offset; - attribs->tface[a].glIndex = gattribs->layer[b].glindex; - attribs->tface[a].glTexco = gattribs->layer[b].gltexco; + attribs->tface[a].em_offset = tfdata->layers[layer].offset; + attribs->tface[a].gl_index = gattribs->layer[b].glindex; + attribs->tface[a].gl_texco = gattribs->layer[b].gltexco; } } } @@ -2823,8 +2823,8 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs, a = attribs->totmcol++; attribs->mcol[a].array = tfdata->layers[layer].data; - attribs->mcol[a].emOffset = tfdata->layers[layer].offset; - attribs->mcol[a].glIndex = gattribs->layer[b].glindex; + attribs->mcol[a].em_offset = tfdata->layers[layer].offset; + attribs->mcol[a].gl_index = gattribs->layer[b].glindex; } } else { @@ -2839,8 +2839,8 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs, a = attribs->totmcol++; attribs->mcol[a].array = tfdata->layers[layer].data; - attribs->mcol[a].emOffset = tfdata->layers[layer].offset; - attribs->mcol[a].glIndex = gattribs->layer[b].glindex; + attribs->mcol[a].em_offset = tfdata->layers[layer].offset; + attribs->mcol[a].gl_index = gattribs->layer[b].glindex; } } } @@ -2852,8 +2852,8 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs, attribs->tottang = 1; attribs->tang.array = fdata->layers[layer].data; - attribs->tang.emOffset = fdata->layers[layer].offset; - attribs->tang.glIndex = gattribs->layer[b].glindex; + attribs->tang.em_offset = fdata->layers[layer].offset; + attribs->tang.gl_index = gattribs->layer[b].glindex; } } else if (gattribs->layer[b].type == CD_ORCO) { @@ -2864,9 +2864,9 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs, attribs->totorco = 1; attribs->orco.array = vdata->layers[layer].data; - attribs->orco.emOffset = vdata->layers[layer].offset; - attribs->orco.glIndex = gattribs->layer[b].glindex; - attribs->orco.glTexco = gattribs->layer[b].gltexco; + attribs->orco.em_offset = vdata->layers[layer].offset; + attribs->orco.gl_index = gattribs->layer[b].glindex; + attribs->orco.gl_texco = gattribs->layer[b].gltexco; } } } @@ -2936,7 +2936,7 @@ static void navmesh_drawColored(DerivedMesh *dm) glDisable(GL_LIGHTING); /* if (GPU_buffer_legacy(dm) ) */ { /* TODO - VBO draw code, not high priority - campbell */ - DEBUG_VBO( "Using legacy code. drawNavMeshColored\n" ); + DEBUG_VBO("Using legacy code. drawNavMeshColored\n"); //glShadeModel(GL_SMOOTH); glBegin(glmode = GL_QUADS); for (a = 0; a < dm->numTessFaceData; a++, mface++) { @@ -3117,7 +3117,7 @@ static void dm_debug_info_layers(DynStr *dynstr, DerivedMesh *dm, void *(*getEle CustomData_file_write_info(type, &structname, &structnum); BLI_dynstr_appendf(dynstr, " dict(name='%s', struct='%s', type=%d, ptr='%p', elem=%d, length=%d),\n", - name, structname, type, (void *)pt, size, (int)(MEM_allocN_len(pt) / size)); + name, structname, type, (void *)pt, size, (int)(MEM_allocN_len(pt) / size)); } } } diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 93401a528ab..5a2407ca56b 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -157,7 +157,7 @@ void make_local_action(bAction *act) /* .................................. */ -void free_action (bAction *act) +void free_action(bAction *act) { /* sanity check */ if (act == NULL) @@ -235,7 +235,7 @@ bActionGroup *get_active_actiongroup (bAction *act) } /* Make the given Action-Group the active one */ -void set_active_action_group (bAction *act, bActionGroup *agrp, short select) +void set_active_action_group(bAction *act, bActionGroup *agrp, short select) { bActionGroup *grp; @@ -280,7 +280,7 @@ bActionGroup *action_groups_add_new (bAction *act, const char name[]) * - assumes that channel is not linked to anything anymore * - always adds at the end of the group */ -void action_groups_add_channel (bAction *act, bActionGroup *agrp, FCurve *fcurve) +void action_groups_add_channel(bAction *act, bActionGroup *agrp, FCurve *fcurve) { /* sanity checks */ if (ELEM3(NULL, act, agrp, fcurve)) @@ -346,7 +346,7 @@ void action_groups_add_channel (bAction *act, bActionGroup *agrp, FCurve *fcurve } /* Remove the given channel from all groups */ -void action_groups_remove_channel (bAction *act, FCurve *fcu) +void action_groups_remove_channel(bAction *act, FCurve *fcu) { /* sanity checks */ if (ELEM(NULL, act, fcu)) @@ -394,7 +394,7 @@ bActionGroup *action_groups_find_named (bAction *act, const char name[]) } /* Clear all 'temp' flags on all groups */ -void action_groups_clear_tempflags (bAction *act) +void action_groups_clear_tempflags(bAction *act) { bActionGroup *agrp; @@ -491,7 +491,7 @@ const char *get_ikparam_name(bPose *pose) return NULL; } /* dst should be freed already, makes entire duplicate */ -void copy_pose (bPose **dst, bPose *src, int copycon) +void copy_pose(bPose **dst, bPose *src, int copycon) { bPose *outPose; bPoseChannel *pchan; @@ -792,7 +792,7 @@ void framechange_poses_clear_unkeyed(void) /* ************************** Bone Groups ************************** */ /* Adds a new bone-group */ -void pose_add_group (Object *ob) +void pose_add_group(Object *ob) { bPose *pose= (ob) ? ob->pose : NULL; bActionGroup *grp; @@ -809,7 +809,7 @@ void pose_add_group (Object *ob) } /* Remove the active bone-group */ -void pose_remove_group (Object *ob) +void pose_remove_group(Object *ob) { bPose *pose= (ob) ? ob->pose : NULL; bActionGroup *grp = NULL; @@ -946,7 +946,7 @@ void calc_action_range(const bAction *act, float *start, float *end, short incl_ /* Return flags indicating which transforms the given object/posechannel has * - if 'curves' is provided, a list of links to these curves are also returned */ -short action_get_item_transforms (bAction *act, Object *ob, bPoseChannel *pchan, ListBase *curves) +short action_get_item_transforms(bAction *act, Object *ob, bPoseChannel *pchan, ListBase *curves) { PointerRNA ptr; FCurve *fcu; @@ -1134,7 +1134,7 @@ void copy_pose_result(bPose *to, bPose *from) /* For the calculation of the effects of an Action at the given frame on an object * This is currently only used for the Action Constraint */ -void what_does_obaction (Object *ob, Object *workob, bPose *pose, bAction *act, char groupname[], float cframe) +void what_does_obaction(Object *ob, Object *workob, bPose *pose, bAction *act, char groupname[], float cframe) { bActionGroup *agrp= action_groups_find_named(act, groupname); diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 38c73ba72b9..afa4723bc6d 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -144,9 +144,11 @@ void animviz_free_motionpath(bMotionPath *mpath) /* ------------------- */ /* Setup motion paths for the given data - * - scene: current scene (for frame ranges, etc.) - * - ob: object to add paths for (must be provided) - * - pchan: posechannel to add paths for (optional; if not provided, object-paths are assumed) + * - Only used when explicitly calculating paths on bones which may/may not be consider already + * + * < scene: current scene (for frame ranges, etc.) + * < ob: object to add paths for (must be provided) + * < pchan: posechannel to add paths for (optional; if not provided, object-paths are assumed) */ bMotionPath *animviz_verify_motionpaths(ReportList *reports, Scene *scene, Object *ob, bPoseChannel *pchan) { @@ -180,14 +182,25 @@ bMotionPath *animviz_verify_motionpaths(ReportList *reports, Scene *scene, Objec } /* if there is already a motionpath, just return that, - * but provided it's settings are ok + * provided it's settings are ok (saves extra free+alloc) */ if (*dst != NULL) { + int expected_length = avs->path_ef - avs->path_sf; + mpath= *dst; - /* if range is not invalid, and/or length is set ok, just return */ - if ((mpath->start_frame != mpath->end_frame) && (mpath->length > 0)) - return mpath; + /* path is "valid" if length is valid, but must also be of the same length as is being requested */ + if ((mpath->start_frame != mpath->end_frame) && (mpath->length > 0)) { + /* outer check ensures that we have some curve data for this path */ + if (mpath->length == expected_length) { + /* return/use this as it is already valid length */ + return mpath; + } + else { + /* clear the existing path (as the range has changed), and reallocate below */ + animviz_free_motionpath_cache(mpath); + } + } } else { /* create a new motionpath, and assign it */ @@ -863,9 +876,9 @@ static void vertex_dupli__mapFunc(void *userData, int index, const float co[3], vec[0]= -no_s[0]; vec[1]= -no_s[1]; vec[2]= -no_s[2]; } - vec_to_quat( q2,vec, vdd->ob->trackflag, vdd->ob->upflag); + vec_to_quat(q2, vec, vdd->ob->trackflag, vdd->ob->upflag); - quat_to_mat3( mat,q2); + quat_to_mat3(mat, q2); copy_m4_m4(tmat, obmat); mul_m4_m4m3(obmat, tmat, mat); } @@ -1142,8 +1155,8 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa copy_v3_v3(obmat[3], cent); /* rotation */ - tri_to_quat( quat,v1, v2, v3); - quat_to_mat3( mat,quat); + tri_to_quat(quat, v1, v2, v3); + quat_to_mat3(mat, quat); /* scale */ if (par->transflag & OB_DUPLIFACES_SCALE) { @@ -1329,7 +1342,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p else a = totpart; - for (pa=psys->particles,counter=0; a<totpart+totchild; a++,pa++,counter++) { + for (pa=psys->particles, counter=0; a<totpart+totchild; a++, pa++, counter++) { if (a<totpart) { /* handle parent particle */ if (pa->flag & no_draw_flag) @@ -1505,7 +1518,7 @@ static Object *find_family_object(Object **obar, char *family, char ch) ob= G.main->object.first; while (ob) { - if ( ob->id.name[flen+2]==ch ) { + if (ob->id.name[flen + 2] == ch) { if ( strncmp(ob->id.name+2, family, flen)==0 ) break; } ob= ob->id.next; diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 06913910829..73f1ce1526a 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -71,7 +71,7 @@ /* Getter/Setter -------------------------------------------- */ /* Check if ID can have AnimData */ -short id_type_can_have_animdata (ID *id) +short id_type_can_have_animdata(ID *id) { /* sanity check */ if (id == NULL) @@ -153,7 +153,7 @@ AnimData *BKE_id_add_animdata (ID *id) /* Action Setter --------------------------------------- */ /* Called when user tries to change the active action of an AnimData block (via RNA, Outliner, etc.) */ -short BKE_animdata_set_action (ReportList *reports, ID *id, bAction *act) +short BKE_animdata_set_action(ReportList *reports, ID *id, bAction *act) { AnimData *adt = BKE_animdata_from_id(id); short ok = 0; @@ -206,7 +206,7 @@ short BKE_animdata_set_action (ReportList *reports, ID *id, bAction *act) /* Freeing -------------------------------------------- */ /* Free AnimData used by the nominated ID-block, and clear ID-block's AnimData pointer */ -void BKE_free_animdata (ID *id) +void BKE_free_animdata(ID *id) { /* Only some ID-blocks have this info for now, so we cast the * types that do to be of type IdAdtTemplate @@ -275,7 +275,7 @@ AnimData *BKE_copy_animdata (AnimData *adt, const short do_action) return dadt; } -int BKE_copy_animdata_id (ID *id_to, ID *id_from, const short do_action) +int BKE_copy_animdata_id(ID *id_to, ID *id_from, const short do_action) { AnimData *adt; @@ -345,7 +345,7 @@ void BKE_animdata_make_local(AnimData *adt) /* When duplicating data (i.e. objects), drivers referring to the original data will * get updated to point to the duplicated data (if drivers belong to the new data) */ -void BKE_relink_animdata (AnimData *adt) +void BKE_relink_animdata(AnimData *adt) { /* sanity check */ if (adt == NULL) @@ -394,7 +394,7 @@ static short animpath_matches_basepath (const char path[], const char basepath[] * - This is used when data moves from one datablock to another, causing the * F-Curves to need to be moved over too */ -void action_move_fcurves_by_basepath (bAction *srcAct, bAction *dstAct, const char basepath[]) +void action_move_fcurves_by_basepath(bAction *srcAct, bAction *dstAct, const char basepath[]) { FCurve *fcu, *fcn=NULL; @@ -474,7 +474,7 @@ void action_move_fcurves_by_basepath (bAction *srcAct, bAction *dstAct, const ch * animation data is based off "basepath", creating new AnimData and * associated data as necessary */ -void BKE_animdata_separate_by_basepath (ID *srcID, ID *dstID, ListBase *basepaths) +void BKE_animdata_separate_by_basepath(ID *srcID, ID *dstID, ListBase *basepaths) { AnimData *srcAdt=NULL, *dstAdt=NULL; LinkData *ld; @@ -736,7 +736,7 @@ void BKE_animdata_fix_paths_rename(ID *owner_id, AnimData *adt, ID *ref_id, cons /* Whole Database Ops -------------------------------------------- */ /* apply the given callback function on all data in main database */ -void BKE_animdata_main_cb (Main *mainptr, ID_AnimData_Edit_Callback func, void *user_data) +void BKE_animdata_main_cb(Main *mainptr, ID_AnimData_Edit_Callback func, void *user_data) { ID *id; @@ -1035,7 +1035,7 @@ KS_Path *BKE_keyingset_add_path (KeyingSet *ks, ID *id, const char group_name[], } /* Free the given Keying Set path */ -void BKE_keyingset_free_path (KeyingSet *ks, KS_Path *ksp) +void BKE_keyingset_free_path(KeyingSet *ks, KS_Path *ksp) { /* sanity check */ if (ELEM(NULL, ks, ksp)) @@ -1050,7 +1050,7 @@ void BKE_keyingset_free_path (KeyingSet *ks, KS_Path *ksp) } /* Copy all KeyingSets in the given list */ -void BKE_keyingsets_copy (ListBase *newlist, ListBase *list) +void BKE_keyingsets_copy(ListBase *newlist, ListBase *list) { KeyingSet *ksn; KS_Path *kspn; @@ -1068,7 +1068,7 @@ void BKE_keyingsets_copy (ListBase *newlist, ListBase *list) /* Freeing Tools --------------------------- */ /* Free data for KeyingSet but not set itself */ -void BKE_keyingset_free (KeyingSet *ks) +void BKE_keyingset_free(KeyingSet *ks) { KS_Path *ksp, *kspn; @@ -1084,7 +1084,7 @@ void BKE_keyingset_free (KeyingSet *ks) } /* Free all the KeyingSets in the given list */ -void BKE_keyingsets_free (ListBase *list) +void BKE_keyingsets_free(ListBase *list) { KeyingSet *ks, *ksn; @@ -1341,7 +1341,7 @@ static void action_idcode_patch_check (ID *id, bAction *act) /* ----------------------------------------- */ /* Evaluate Action Group */ -void animsys_evaluate_action_group (PointerRNA *ptr, bAction *act, bActionGroup *agrp, AnimMapper *remap, float ctime) +void animsys_evaluate_action_group(PointerRNA *ptr, bAction *act, bActionGroup *agrp, AnimMapper *remap, float ctime) { FCurve *fcu; @@ -1366,7 +1366,7 @@ void animsys_evaluate_action_group (PointerRNA *ptr, bAction *act, bActionGroup } /* Evaluate Action (F-Curve Bag) */ -void animsys_evaluate_action (PointerRNA *ptr, bAction *act, AnimMapper *remap, float ctime) +void animsys_evaluate_action(PointerRNA *ptr, bAction *act, AnimMapper *remap, float ctime) { /* check if mapper is appropriate for use here (we set to NULL if it's inappropriate) */ if (act == NULL) return; @@ -1923,7 +1923,7 @@ static void nlastrip_evaluate_meta (PointerRNA *ptr, ListBase *channels, ListBas } /* evaluates the given evaluation strip */ -void nlastrip_evaluate (PointerRNA *ptr, ListBase *channels, ListBase *modifiers, NlaEvalStrip *nes) +void nlastrip_evaluate(PointerRNA *ptr, ListBase *channels, ListBase *modifiers, NlaEvalStrip *nes) { NlaStrip *strip= nes->strip; @@ -1956,7 +1956,7 @@ void nlastrip_evaluate (PointerRNA *ptr, ListBase *channels, ListBase *modifiers } /* write the accumulated settings to */ -void nladata_flush_channels (ListBase *channels) +void nladata_flush_channels(ListBase *channels) { NlaEvalChannel *nec; @@ -2042,8 +2042,10 @@ static void animsys_evaluate_nla (ListBase *echannels, PointerRNA *ptr, AnimData /* add 'active' Action (may be tweaking track) as last strip to evaluate in NLA stack * - only do this if we're not exclusively evaluating the 'solo' NLA-track + * - however, if the 'solo' track houses the current 'tweaking' strip, + * then we should allow this to play, otherwise nothing happens */ - if ((adt->action) && !(adt->flag & ADT_NLA_SOLO_TRACK)) { + if ((adt->action) && ((adt->flag & ADT_NLA_SOLO_TRACK)==0 || (adt->flag & ADT_NLA_EDIT_ON))) { /* if there are strips, evaluate action as per NLA rules */ if ((has_strips) || (adt->actstrip)) { /* make dummy NLA strip, and add that to the stack */ @@ -2183,7 +2185,7 @@ static void animsys_evaluate_overrides (PointerRNA *ptr, AnimData *adt) * and that the flags for which parts of the anim-data settings need to be recalculated * have been set already by the depsgraph. Now, we use the recalc */ -void BKE_animsys_evaluate_animdata (Scene *scene, ID *id, AnimData *adt, float ctime, short recalc) +void BKE_animsys_evaluate_animdata(Scene *scene, ID *id, AnimData *adt, float ctime, short recalc) { PointerRNA id_ptr; @@ -2253,7 +2255,7 @@ void BKE_animsys_evaluate_animdata (Scene *scene, ID *id, AnimData *adt, float c * 'local' (i.e. belonging in the nearest ID-block that setting is related to, not a * standard 'root') block are overridden by a larger 'user' */ -void BKE_animsys_evaluate_all_animation (Main *main, Scene *scene, float ctime) +void BKE_animsys_evaluate_all_animation(Main *main, Scene *scene, float ctime) { ID *id; diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index d1d6833e903..b0d0ace2a7e 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -471,7 +471,7 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest) next = pchan->child; /* find the handle points, since this is inside bone space, the - * first point = (0,0,0) + * first point = (0, 0, 0) * last point = (0, length, 0) */ if (rest) { invert_m4_m4(imat, pchan->bone->arm_mat); @@ -1028,13 +1028,13 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, float if (armature_weight != 1.0f) { copy_v3_v3(dco, co); - mul_v3m3_dq( dco, (defMats) ? summat : NULL,dq); + mul_v3m3_dq(dco, (defMats) ? summat : NULL, dq); sub_v3_v3(dco, co); mul_v3_fl(dco, armature_weight); add_v3_v3(co, dco); } else - mul_v3m3_dq( co, (defMats) ? summat : NULL,dq); + mul_v3m3_dq(co, (defMats) ? summat : NULL, dq); smat = summat; } @@ -1208,9 +1208,8 @@ void pchan_to_pose_mat(bPoseChannel *pchan, float rotscale_mat[][4], float loc_m else mult_m4_m4m4(rotscale_mat, parchan->pose_mat, offs_bone); -# if 1 /* Compose the loc matrix for this bone. */ - /* NOTE: That version deos not modify bone's loc when HINGE/NO_SCALE options are set. */ + /* NOTE: That version does not modify bone's loc when HINGE/NO_SCALE options are set. */ /* In this case, use the object's space *orientation*. */ if (bone->flag & BONE_NO_LOCAL_LOCATION) { @@ -1236,58 +1235,6 @@ void pchan_to_pose_mat(bPoseChannel *pchan, float rotscale_mat[][4], float loc_m /* Else (i.e. default, usual case), just use the same matrix for rotation/scaling, and location. */ else copy_m4_m4(loc_mat, rotscale_mat); -# endif -# if 0 - /* Compose the loc matrix for this bone. */ - /* NOTE: That version modifies bone's loc when HINGE/NO_SCALE options are set. */ - - /* In these cases we need to compute location separately */ - if (bone->flag & (BONE_HINGE|BONE_NO_SCALE|BONE_NO_LOCAL_LOCATION)) { - float bone_loc[4][4], bone_rotscale[3][3], tmat4[4][4], tmat3[3][3]; - unit_m4(bone_loc); - unit_m4(loc_mat); - unit_m4(tmat4); - - mul_v3_m4v3(bone_loc[3], parchan->pose_mat, offs_bone[3]); - - /* "No local location" is not transformed by bone matrix. */ - /* This only affects orientations (rotations), as scale is always 1.0 here. */ - if (bone->flag & BONE_NO_LOCAL_LOCATION) - unit_m3(bone_rotscale); - else - /* We could also use bone->bone_mat directly, here... */ - copy_m3_m4(bone_rotscale, offs_bone); - - if (bone->flag & BONE_HINGE) { - copy_m3_m4(tmat3, parbone->arm_mat); - /* for hinge-only, we use armature *rotation*, but pose mat *scale*! */ - if (!(bone->flag & BONE_NO_SCALE)) { - float size[3], tsmat[3][3]; - mat4_to_size(size, parchan->pose_mat); - size_to_mat3(tsmat, size); - mul_m3_m3m3(tmat3, tsmat, tmat3); - } - mul_m3_m3m3(bone_rotscale, tmat3, bone_rotscale); - } - else if (bone->flag & BONE_NO_SCALE) { - /* For no-scale only, normalized parent pose mat is enough! */ - copy_m3_m4(tmat3, parchan->pose_mat); - normalize_m3(tmat3); - mul_m3_m3m3(bone_rotscale, tmat3, bone_rotscale); - } - /* NO_LOCAL_LOCATION only. */ - else { - copy_m3_m4(tmat3, parchan->pose_mat); - mul_m3_m3m3(bone_rotscale, tmat3, bone_rotscale); - } - - copy_m4_m3(tmat4, bone_rotscale); - mult_m4_m4m4(loc_mat, bone_loc, tmat4); - } - /* Else, just use the same matrix for rotation/scaling, and location. */ - else - copy_m4_m4(loc_mat, rotscale_mat); -# endif } /* Root bones. */ else { @@ -1413,18 +1360,18 @@ void armature_mat_pose_to_delta(float delta_mat[][4], float pose_mat[][4], float /* Called from RNA when rotation mode changes * - the result should be that the rotations given in the provided pointers have had conversions * applied (as appropriate), such that the rotation of the element hasn't 'visually' changed */ -void BKE_rotMode_change_values (float quat[4], float eul[3], float axis[3], float *angle, short oldMode, short newMode) +void BKE_rotMode_change_values(float quat[4], float eul[3], float axis[3], float *angle, short oldMode, short newMode) { /* check if any change - if so, need to convert data */ if (newMode > 0) { /* to euler */ if (oldMode == ROT_MODE_AXISANGLE) { /* axis-angle to euler */ - axis_angle_to_eulO( eul, newMode,axis, *angle); + axis_angle_to_eulO(eul, newMode, axis, *angle); } else if (oldMode == ROT_MODE_QUAT) { /* quat to euler */ normalize_qt(quat); - quat_to_eulO(eul, newMode,quat); + quat_to_eulO(eul, newMode, quat); } /* else { no conversion needed } */ } @@ -1517,7 +1464,7 @@ void vec_roll_to_mat3(const float vec[3], const float roll, float mat[][3]) * was 0.000001, causes bug [#30438] (which is same as [#27675, imho). * Reseting it to org value seems to cause no more [#23954]... */ - if (dot_v3v3(axis,axis) > 1.0e-13f) { + if (dot_v3v3(axis, axis) > 1.0e-13f) { /* if nor is *not* a multiple of target ... */ normalize_v3(axis); @@ -1531,7 +1478,7 @@ void vec_roll_to_mat3(const float vec[3], const float roll, float mat[][3]) float updown; /* point same direction, or opposite? */ - updown = (dot_v3v3(target,nor) > 0) ? 1.0f : -1.0f; + updown = (dot_v3v3(target, nor) > 0) ? 1.0f : -1.0f; /* I think this should work... */ bMatrix[0][0] = updown; bMatrix[0][1] = 0.0; bMatrix[0][2] = 0.0; @@ -2362,8 +2309,8 @@ static void do_strip_modifiers(Scene *scene, Object *armob, Bone *bone, bPoseCha /* make a copy of starting conditions */ copy_v3_v3(loc, pchan->pose_mat[3]); - mat4_to_eul( eul,pchan->pose_mat); - mat4_to_size( size,pchan->pose_mat); + mat4_to_eul(eul, pchan->pose_mat); + mat4_to_size(size, pchan->pose_mat); copy_v3_v3(eulo, eul); copy_v3_v3(sizeo, size); @@ -2438,16 +2385,6 @@ void where_is_pose_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float cti /* Construct the posemat based on PoseChannels, that we do before applying constraints. */ /* pose_mat(b) = pose_mat(b-1) * yoffs(b-1) * d_root(b) * bone_mat(b) * chan_mat(b) */ armature_mat_bone_to_pose(pchan, pchan->chan_mat, pchan->pose_mat); -#if 0 /* XXX Old code, will remove this later. */ - { - float rotscale_mat[4][4], loc_mat[4][4]; - pchan_to_pose_mat(pchan, rotscale_mat, loc_mat); - /* Rotation and scale. */ - mult_m4_m4m4(pchan->pose_mat, rotscale_mat, pchan->chan_mat); - /* Location. */ - mul_v3_m4v3(pchan->pose_mat[3], loc_mat, pchan->chan_mat[3]); - } -#endif /* Only rootbones get the cyclic offset (unless user doesn't want that). */ /* XXX That could be a problem for snapping and other "reverse transform" features... */ @@ -2498,7 +2435,7 @@ void where_is_pose_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float cti /* This only reads anim data from channels, and writes to channels */ /* This is the only function adding poses */ -void where_is_pose (Scene *scene, Object *ob) +void where_is_pose(Scene *scene, Object *ob) { bArmature *arm; Bone *bone; diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 9c9b207970c..b0bfd2ee98d 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -110,7 +110,7 @@ void free_blender(void) IMB_exit(); - BLI_cb_finalize(); + BLI_callback_global_finalize(); seq_stripelem_cache_destruct(); IMB_moviecache_destruct(); @@ -129,9 +129,9 @@ void initglobals(void) strcpy(G.ima, "//"); if (BLENDER_SUBVERSION) - BLI_snprintf(versionstr, sizeof(versionstr), "blender.org %d.%d", BLENDER_VERSION, BLENDER_SUBVERSION); + BLI_snprintf(versionstr, sizeof(versionstr), "v%d.%02d.%d", BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION); else - BLI_snprintf(versionstr, sizeof(versionstr), "blender.org %d", BLENDER_VERSION); + BLI_snprintf(versionstr, sizeof(versionstr), "v%d.%02d", BLENDER_VERSION/100, BLENDER_VERSION%100); #ifdef _WIN32 // FULLSCREEN G.windowstate = G_WINDOWSTATE_USERDEF; @@ -173,7 +173,7 @@ static void clean_paths(Main *main) { Scene *scene; - bpath_traverse_main(main, clean_paths_visit_cb, BPATH_TRAVERSE_SKIP_MULTIFILE, NULL); + BLI_bpath_traverse_main(main, clean_paths_visit_cb, BLI_BPATH_TRAVERSE_SKIP_MULTIFILE, NULL); for (scene= main->scene.first; scene; scene= scene->id.next) { BLI_clean(scene->r.pic); @@ -431,7 +431,7 @@ int BKE_read_file_from_memfile(bContext *C, MemFile *memfile, ReportList *report /* ***************** testing for break ************* */ -static void (*blender_test_break_cb)(void)= NULL; +static void (*blender_test_break_cb)(void) = NULL; void set_blender_test_break_cb(void (*func)(void) ) { @@ -722,7 +722,7 @@ void BKE_undo_save_quit(void) BLI_make_file_string("/", str, BLI_temporary_dir(), "quit.blend"); - file = BLI_open(str,O_BINARY+O_WRONLY+O_CREAT+O_TRUNC, 0666); + file = BLI_open(str, O_BINARY + O_WRONLY + O_CREAT + O_TRUNC, 0666); if (file == -1) { //XXX error("Unable to save %s, check you have permissions", str); return; diff --git a/source/blender/blenkernel/intern/bmfont.c b/source/blender/blenkernel/intern/bmfont.c index 04ac6cbfb4c..e1f4e45e9c3 100644 --- a/source/blender/blenkernel/intern/bmfont.c +++ b/source/blender/blenkernel/intern/bmfont.c @@ -65,8 +65,8 @@ void printfGlyph(bmGlyph * glyph) printf(" advan: %3d reser: %3d\n", glyph->advance, glyph->reserved); } -#define MAX2(x,y) ( (x)>(y) ? (x) : (y) ) -#define MAX3(x,y,z) MAX2( MAX2((x),(y)) , (z) ) +#define MAX2(x,y) ((x) > (y) ? (x) : (y)) +#define MAX3(x,y,z) MAX2(MAX2((x), (y)), (z)) void calcAlpha(ImBuf * ibuf) { diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index fbcabccd2b9..014b3f5e40b 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -230,8 +230,8 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues * /* avoid head-on collision */ if (dot_v3v3(col.pce.nor, pa->prev_state.ave) < -0.99f) { - /* don't know why, but uneven range [0.0,1.0] */ - /* works much better than even [-1.0,1.0] */ + /* don't know why, but uneven range [0.0, 1.0] */ + /* works much better than even [-1.0, 1.0] */ bbd->wanted_co[0] = BLI_frand(); bbd->wanted_co[1] = BLI_frand(); bbd->wanted_co[2] = BLI_frand(); @@ -262,7 +262,7 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues * sub_v3_v3v3(vec, vel1, vel2); - inp = dot_v3v3(vec,vec); + inp = dot_v3v3(vec, vec); /* velocities not parallel */ if (inp != 0.0f) { @@ -308,7 +308,7 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues * sub_v3_v3v3(vec, vel1, vel2); - inp = dot_v3v3(vec,vec); + inp = dot_v3v3(vec, vec); /* velocities not parallel */ if (inp != 0.0f) { @@ -583,7 +583,7 @@ static int rule_average_speed(BoidRule *rule, BoidBrainData *bbd, BoidValues *va copy_v3_v3(bbd->wanted_co, pa->prev_state.ave); /* may happen at birth */ - if (dot_v2v2(bbd->wanted_co,bbd->wanted_co)==0.0f) { + if (dot_v2v2(bbd->wanted_co, bbd->wanted_co)==0.0f) { bbd->wanted_co[0] = 2.0f*(0.5f - BLI_frand()); bbd->wanted_co[1] = 2.0f*(0.5f - BLI_frand()); bbd->wanted_co[2] = 2.0f*(0.5f - BLI_frand()); @@ -610,7 +610,7 @@ static int rule_fight(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti ParticleData *enemy_pa = NULL; BoidParticle *bpa; /* friends & enemies */ - float closest_enemy[3] = {0.0f,0.0f,0.0f}; + float closest_enemy[3] = {0.0f, 0.0f, 0.0f}; float closest_dist = fbr->distance + 1.0f; float f_strength = 0.0f, e_strength = 0.0f; float health = 0.0f; @@ -748,7 +748,7 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float grou SurfaceModifierData *surmd = NULL; float x[3], v[3]; - surmd = (SurfaceModifierData *)modifiers_findByType ( bpa->ground, eModifierType_Surface ); + surmd = (SurfaceModifierData *)modifiers_findByType(bpa->ground, eModifierType_Surface ); /* take surface velocity into account */ closest_point_on_surface(surmd, pa->state.co, x, NULL, v); @@ -1096,7 +1096,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) set_boid_values(&val, boids, pa); /* make sure there's something in new velocity, location & rotation */ - copy_particle_key(&pa->state,&pa->prev_state,0); + copy_particle_key(&pa->state, &pa->prev_state, 0); if (bbd->part->flag & PART_SIZEMASS) pa_mass*=pa->size; @@ -1170,13 +1170,13 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) angle = MIN2(angle, val.max_ave); cross_v3_v3v3(nor, old_dir, wanted_dir); - axis_angle_to_quat( q,nor, angle); + axis_angle_to_quat(q, nor, angle); copy_v3_v3(new_dir, old_dir); mul_qt_v3(q, new_dir); normalize_v3(new_dir); /* save direction in case resulting velocity too small */ - axis_angle_to_quat( q,nor, angle*dtime); + axis_angle_to_quat(q, nor, angle*dtime); copy_v3_v3(pa->state.ave, old_dir); mul_qt_v3(q, pa->state.ave); normalize_v3(pa->state.ave); @@ -1196,7 +1196,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) /* maintain minimum flying velocity if not landing */ if (level >= landing_level) { - float len2 = dot_v2v2(new_vel,new_vel); + float len2 = dot_v2v2(new_vel, new_vel); float root; len2 = MAX2(len2, val.min_speed*val.min_speed); @@ -1427,7 +1427,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) cross_v3_v3v3(mat[1], mat[2], mat[0]); /* apply rotation */ - mat3_to_quat_is_ok( q,mat); + mat3_to_quat_is_ok(q, mat); copy_qt_qt(pa->state.rot, q); } diff --git a/source/blender/blenkernel/intern/booleanops_mesh.c b/source/blender/blenkernel/intern/booleanops_mesh.c index 31c90d54d14..7c225eb0fad 100644 --- a/source/blender/blenkernel/intern/booleanops_mesh.c +++ b/source/blender/blenkernel/intern/booleanops_mesh.c @@ -1,7 +1,5 @@ #if 0 - /* - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 3df6de2fd24..51258b13f68 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -67,7 +67,7 @@ #include "RE_render_ext.h" /* externtex */ #include "RE_shader_ext.h" -static void brush_set_defaults(Brush *brush) +static void brush_defaults(Brush *brush) { brush->blend = 0; brush->flag = 0; @@ -75,6 +75,7 @@ static void brush_set_defaults(Brush *brush) brush->ob_mode = OB_MODE_ALL_PAINT; /* BRUSH SCULPT TOOL SETTINGS */ + brush->weight= 1.0f; /* weight of brush 0 - 1.0 */ brush->size= 35; /* radius of the brush in pixels */ brush->alpha= 0.5f; /* brush strength/intensity probably variable should be renamed? */ brush->autosmooth_factor= 0.0f; @@ -121,7 +122,7 @@ static void brush_set_defaults(Brush *brush) /* Datablock add/copy/free/make_local */ -Brush *add_brush(const char *name) +Brush *BKE_brush_add(const char *name) { Brush *brush; @@ -130,17 +131,17 @@ Brush *add_brush(const char *name) /* enable fake user by default */ brush->id.flag |= LIB_FAKEUSER; - brush_set_defaults(brush); + brush_defaults(brush); brush->sculpt_tool = SCULPT_TOOL_DRAW; /* sculpting defaults to the draw tool for new brushes */ /* the default alpha falloff curve */ - brush_curve_preset(brush, CURVE_PRESET_SMOOTH); + BKE_brush_curve_preset(brush, CURVE_PRESET_SMOOTH); return brush; } -Brush *copy_brush(Brush *brush) +Brush *BKE_brush_copy(Brush *brush) { Brush *brushn; @@ -166,7 +167,7 @@ Brush *copy_brush(Brush *brush) } /* not brush itself */ -void free_brush(Brush *brush) +void BKE_brush_free(Brush *brush) { if (brush->mtex.tex) brush->mtex.tex->id.us--; @@ -185,7 +186,7 @@ static void extern_local_brush(Brush *brush) id_lib_extern((ID *)brush->clone.image); } -void make_local_brush(Brush *brush) +void BKE_brush_make_local(Brush *brush) { /* - only lib users: do nothing @@ -224,7 +225,7 @@ void make_local_brush(Brush *brush) } } else if (is_local && is_lib) { - Brush *brush_new= copy_brush(brush); + Brush *brush_new= BKE_brush_copy(brush); brush_new->id.us= 1; /* only keep fake user */ brush_new->id.flag |= LIB_FAKEUSER; @@ -241,11 +242,11 @@ void make_local_brush(Brush *brush) } } -void brush_debug_print_state(Brush *br) +void BKE_brush_debug_print_state(Brush *br) { /* create a fake brush and set it to the defaults */ Brush def= {{NULL}}; - brush_set_defaults(&def); + brush_defaults(&def); #define BR_TEST(field, t) \ if (br->field != def.field) \ @@ -328,14 +329,14 @@ void brush_debug_print_state(Brush *br) #undef BR_TEST_FLAG } -void brush_reset_sculpt(Brush *br) +void BKE_brush_sculpt_reset(Brush *br) { /* enable this to see any non-default * settings used by a brush: */ - // brush_debug_print_state(br); + // BKE_brush_debug_print_state(br); - brush_set_defaults(br); - brush_curve_preset(br, CURVE_PRESET_SMOOTH); + brush_defaults(br); + BKE_brush_curve_preset(br, CURVE_PRESET_SMOOTH); switch (br->sculpt_tool) { case SCULPT_TOOL_CLAY: @@ -408,7 +409,7 @@ void brush_reset_sculpt(Brush *br) } /* Library Operations */ -void brush_curve_preset(Brush *b, /*CurveMappingPreset*/int preset) +void BKE_brush_curve_preset(Brush *b, /*CurveMappingPreset*/int preset) { CurveMap *cm = NULL; @@ -423,7 +424,7 @@ void brush_curve_preset(Brush *b, /*CurveMappingPreset*/int preset) curvemapping_changed(b->curve, 0); } -int brush_texture_set_nr(Brush *brush, int nr) +int BKE_brush_texture_set_nr(Brush *brush, int nr) { ID *idtest, *id=NULL; @@ -436,7 +437,7 @@ int brush_texture_set_nr(Brush *brush, int nr) idtest->us--; } if (idtest!=id) { - brush_texture_delete(brush); + BKE_brush_texture_delete(brush); brush->mtex.tex= (Tex*)idtest; id_us_plus(idtest); @@ -447,7 +448,7 @@ int brush_texture_set_nr(Brush *brush, int nr) return 0; } -int brush_texture_delete(Brush *brush) +int BKE_brush_texture_delete(Brush *brush) { if (brush->mtex.tex) brush->mtex.tex->id.us--; @@ -455,13 +456,13 @@ int brush_texture_delete(Brush *brush) return 1; } -int brush_clone_image_set_nr(Brush *brush, int nr) +int BKE_brush_clone_image_set_nr(Brush *brush, int nr) { if (brush && nr > 0) { Image *ima= (Image*)BLI_findlink(&G.main->image, nr-1); if (ima) { - brush_clone_image_delete(brush); + BKE_brush_clone_image_delete(brush); brush->clone.image= ima; id_us_plus(&ima->id); brush->clone.offset[0]= brush->clone.offset[1]= 0.0f; @@ -473,7 +474,7 @@ int brush_clone_image_set_nr(Brush *brush, int nr) return 0; } -int brush_clone_image_delete(Brush *brush) +int BKE_brush_clone_image_delete(Brush *brush) { if (brush && brush->clone.image) { brush->clone.image->id.us--; @@ -485,14 +486,14 @@ int brush_clone_image_delete(Brush *brush) } /* Brush Sampling */ -void brush_sample_tex(const Scene *scene, Brush *brush, const float xy[2], float rgba[4], const int thread) +void BKE_brush_sample_tex(const Scene *scene, Brush *brush, const float xy[2], float rgba[4], const int thread) { MTex *mtex= &brush->mtex; if (mtex && mtex->tex) { float co[3], tin, tr, tg, tb, ta; int hasrgb; - const int radius= brush_size(scene, brush); + const int radius= BKE_brush_size_get(scene, brush); co[0]= xy[0]/radius; co[1]= xy[1]/radius; @@ -519,14 +520,14 @@ void brush_sample_tex(const Scene *scene, Brush *brush, const float xy[2], float } /* TODO, use define for 'texfall' arg */ -void brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texfall, int bufsize, ImBuf **outbuf, int use_color_correction) +void BKE_brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texfall, int bufsize, ImBuf **outbuf, int use_color_correction) { ImBuf *ibuf; float xy[2], rgba[4], *dstf; int x, y, rowbytes, xoff, yoff, imbflag; - const int radius= brush_size(scene, brush); + const int radius= BKE_brush_size_get(scene, brush); unsigned char *dst, crgb[3]; - const float alpha= brush_alpha(scene, brush); + const float alpha= BKE_brush_alpha_get(scene, brush); float brush_rgb[3]; imbflag= (flt)? IB_rectfloat: IB_rect; @@ -554,15 +555,15 @@ void brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texfall, if (texfall == 0) { copy_v3_v3(dstf, brush_rgb); - dstf[3]= alpha*brush_curve_strength_clamp(brush, len_v2(xy), radius); + dstf[3]= alpha*BKE_brush_curve_strength_clamp(brush, len_v2(xy), radius); } else if (texfall == 1) { - brush_sample_tex(scene, brush, xy, dstf, 0); + BKE_brush_sample_tex(scene, brush, xy, dstf, 0); } else { - brush_sample_tex(scene, brush, xy, rgba, 0); + BKE_brush_sample_tex(scene, brush, xy, rgba, 0); mul_v3_v3v3(dstf, rgba, brush_rgb); - dstf[3] = rgba[3]*alpha*brush_curve_strength_clamp(brush, len_v2(xy), radius); + dstf[3] = rgba[3]*alpha*BKE_brush_curve_strength_clamp(brush, len_v2(xy), radius); } } } @@ -579,7 +580,7 @@ void brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texfall, xy[1] = y + yoff; if (texfall == 0) { - alpha_f = alpha * brush_curve_strength(brush, len_v2(xy), radius); + alpha_f = alpha * BKE_brush_curve_strength(brush, len_v2(xy), radius); dst[0] = crgb[0]; dst[1] = crgb[1]; @@ -587,21 +588,21 @@ void brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texfall, dst[3] = FTOCHAR(alpha_f); } else if (texfall == 1) { - brush_sample_tex(scene, brush, xy, rgba, 0); + BKE_brush_sample_tex(scene, brush, xy, rgba, 0); rgba_float_to_uchar(dst, rgba); } else if (texfall == 2) { - brush_sample_tex(scene, brush, xy, rgba, 0); + BKE_brush_sample_tex(scene, brush, xy, rgba, 0); mul_v3_v3(rgba, brush->rgb); - alpha_f = rgba[3] * alpha * brush_curve_strength_clamp(brush, len_v2(xy), radius); + alpha_f = rgba[3] * alpha * BKE_brush_curve_strength_clamp(brush, len_v2(xy), radius); rgb_float_to_uchar(dst, rgba); dst[3] = FTOCHAR(alpha_f); } else { - brush_sample_tex(scene, brush, xy, rgba, 0); - alpha_f = rgba[3] * alpha * brush_curve_strength_clamp(brush, len_v2(xy), radius); + BKE_brush_sample_tex(scene, brush, xy, rgba, 0); + alpha_f = rgba[3] * alpha * BKE_brush_curve_strength_clamp(brush, len_v2(xy), radius); dst[0] = crgb[0]; dst[1] = crgb[1]; @@ -630,7 +631,7 @@ void brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texfall, // In anycase, a better solution is needed to prevent // inconsistency. -void brush_set_size(Scene *scene, Brush *brush, int size) +void BKE_brush_size_set(Scene *scene, Brush *brush, int size) { UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; @@ -640,14 +641,14 @@ void brush_set_size(Scene *scene, Brush *brush, int size) brush->size= size; } -int brush_size(const Scene *scene, Brush *brush) +int BKE_brush_size_get(const Scene *scene, Brush *brush) { UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; return (ups->flag & UNIFIED_PAINT_SIZE) ? ups->size : brush->size; } -int brush_use_locked_size(const Scene *scene, Brush *brush) +int BKE_brush_use_locked_size(const Scene *scene, Brush *brush) { const short us_flag = scene->toolsettings->unified_paint_settings.flag; @@ -656,7 +657,7 @@ int brush_use_locked_size(const Scene *scene, Brush *brush) (brush->flag & BRUSH_LOCK_SIZE); } -int brush_use_size_pressure(const Scene *scene, Brush *brush) +int BKE_brush_use_size_pressure(const Scene *scene, Brush *brush) { const short us_flag = scene->toolsettings->unified_paint_settings.flag; @@ -665,7 +666,7 @@ int brush_use_size_pressure(const Scene *scene, Brush *brush) (brush->flag & BRUSH_SIZE_PRESSURE); } -int brush_use_alpha_pressure(const Scene *scene, Brush *brush) +int BKE_brush_use_alpha_pressure(const Scene *scene, Brush *brush) { const short us_flag = scene->toolsettings->unified_paint_settings.flag; @@ -674,7 +675,7 @@ int brush_use_alpha_pressure(const Scene *scene, Brush *brush) (brush->flag & BRUSH_ALPHA_PRESSURE); } -void brush_set_unprojected_radius(Scene *scene, Brush *brush, float unprojected_radius) +void BKE_brush_unprojected_radius_set(Scene *scene, Brush *brush, float unprojected_radius) { UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; @@ -684,7 +685,7 @@ void brush_set_unprojected_radius(Scene *scene, Brush *brush, float unprojected_ brush->unprojected_radius= unprojected_radius; } -float brush_unprojected_radius(const Scene *scene, Brush *brush) +float BKE_brush_unprojected_radius_get(const Scene *scene, Brush *brush) { UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; @@ -693,7 +694,7 @@ float brush_unprojected_radius(const Scene *scene, Brush *brush) brush->unprojected_radius; } -static void brush_set_alpha(Scene *scene, Brush *brush, float alpha) +static void brush_alpha_set(Scene *scene, Brush *brush, float alpha) { UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; @@ -703,17 +704,34 @@ static void brush_set_alpha(Scene *scene, Brush *brush, float alpha) brush->alpha= alpha; } -float brush_alpha(const Scene *scene, Brush *brush) +float BKE_brush_alpha_get(const Scene *scene, Brush *brush) { UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; return (ups->flag & UNIFIED_PAINT_ALPHA) ? ups->alpha : brush->alpha; } +float BKE_brush_weight_get(const Scene *scene, Brush *brush) +{ + UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; + + return (ups->flag & UNIFIED_PAINT_WEIGHT) ? ups->weight : brush->weight; +} + +void BKE_brush_weight_set(const Scene *scene, Brush *brush, float value) +{ + UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; + + if(ups->flag & UNIFIED_PAINT_WEIGHT) + ups->weight = value; + else + brush->weight = value; +} + /* scale unprojected radius to reflect a change in the brush's 2D size */ -void brush_scale_unprojected_radius(float *unprojected_radius, - int new_brush_size, - int old_brush_size) +void BKE_brush_scale_unprojected_radius(float *unprojected_radius, + int new_brush_size, + int old_brush_size) { float scale = new_brush_size; /* avoid division by zero */ @@ -723,15 +741,15 @@ void brush_scale_unprojected_radius(float *unprojected_radius, } /* scale brush size to reflect a change in the brush's unprojected radius */ -void brush_scale_size(int *brush_size, - float new_unprojected_radius, - float old_unprojected_radius) +void BKE_brush_scale_size(int *BKE_brush_size_get, + float new_unprojected_radius, + float old_unprojected_radius) { float scale = new_unprojected_radius; /* avoid division by zero */ if (old_unprojected_radius != 0) scale /= new_unprojected_radius; - (*brush_size)= (int)((float)(*brush_size) * scale); + (*BKE_brush_size_get)= (int)((float)(*BKE_brush_size_get) * scale); } /* Brush Painting */ @@ -739,7 +757,7 @@ void brush_scale_size(int *brush_size, typedef struct BrushPainterCache { short enabled; - int size; /* size override, if 0 uses 2*brush_size(brush) */ + int size; /* size override, if 0 uses 2*BKE_brush_size_get(brush) */ short flt; /* need float imbuf? */ short texonly; /* no alpha, color or fallof, only texture in imbuf */ @@ -777,7 +795,7 @@ struct BrushPainter { BrushPainterCache cache; }; -BrushPainter *brush_painter_new(Scene *scene, Brush *brush) +BrushPainter *BKE_brush_painter_new(Scene *scene, Brush *brush) { BrushPainter *painter= MEM_callocN(sizeof(BrushPainter), "BrushPainter"); @@ -786,15 +804,15 @@ BrushPainter *brush_painter_new(Scene *scene, Brush *brush) painter->firsttouch= 1; painter->cache.lastsize= -1; /* force ibuf create in refresh */ - painter->startsize = brush_size(scene, brush); - painter->startalpha = brush_alpha(scene, brush); + painter->startsize = BKE_brush_size_get(scene, brush); + painter->startalpha = BKE_brush_alpha_get(scene, brush); painter->startjitter = brush->jitter; painter->startspacing = brush->spacing; return painter; } -void brush_painter_require_imbuf(BrushPainter *painter, short flt, short texonly, int size) +void BKE_brush_painter_require_imbuf(BrushPainter *painter, short flt, short texonly, int size) { if ((painter->cache.flt != flt) || (painter->cache.size != size) || ((painter->cache.texonly != texonly) && texonly)) { @@ -816,12 +834,12 @@ void brush_painter_require_imbuf(BrushPainter *painter, short flt, short texonly painter->cache.enabled= 1; } -void brush_painter_free(BrushPainter *painter) +void BKE_brush_painter_free(BrushPainter *painter) { Brush *brush = painter->brush; - brush_set_size(painter->scene, brush, painter->startsize); - brush_set_alpha(painter->scene, brush, painter->startalpha); + BKE_brush_size_set(painter->scene, brush, painter->startsize); + brush_alpha_set(painter->scene, brush, painter->startalpha); brush->jitter = painter->startjitter; brush->spacing = painter->startspacing; @@ -841,7 +859,7 @@ static void brush_painter_do_partial(BrushPainter *painter, ImBuf *oldtexibuf, float *bf, *mf, *tf, *otf=NULL, xoff, yoff, xy[2], rgba[4]; unsigned char *b, *m, *t, *ot= NULL; int dotexold, origx= x, origy= y; - const int radius= brush_size(painter->scene, brush); + const int radius= BKE_brush_size_get(painter->scene, brush); xoff = -radius + 0.5f; yoff = -radius + 0.5f; @@ -879,7 +897,7 @@ static void brush_painter_do_partial(BrushPainter *painter, ImBuf *oldtexibuf, xy[0] = x + xoff; xy[1] = y + yoff; - brush_sample_tex(scene, brush, xy, tf, 0); + BKE_brush_sample_tex(scene, brush, xy, tf, 0); } bf[0] = tf[0]*mf[0]; @@ -910,7 +928,7 @@ static void brush_painter_do_partial(BrushPainter *painter, ImBuf *oldtexibuf, xy[0] = x + xoff; xy[1] = y + yoff; - brush_sample_tex(scene, brush, xy, rgba, 0); + BKE_brush_sample_tex(scene, brush, xy, rgba, 0); rgba_float_to_uchar(t, rgba); } @@ -930,7 +948,7 @@ static void brush_painter_fixed_tex_partial_update(BrushPainter *painter, const BrushPainterCache *cache= &painter->cache; ImBuf *oldtexibuf, *ibuf; int imbflag, destx, desty, srcx, srcy, w, h, x1, y1, x2, y2; - const int diameter= 2*brush_size(scene, brush); + const int diameter= 2*BKE_brush_size_get(scene, brush); imbflag= (cache->flt)? IB_rectfloat: IB_rect; if (!cache->ibuf) @@ -986,8 +1004,8 @@ static void brush_painter_refresh_cache(BrushPainter *painter, const float pos[2 MTex *mtex= &brush->mtex; int size; short flt; - const int diameter= 2*brush_size(scene, brush); - const float alpha= brush_alpha(scene, brush); + const int diameter= 2*BKE_brush_size_get(scene, brush); + const float alpha= BKE_brush_alpha_get(scene, brush); if (diameter != cache->lastsize || alpha != cache->lastalpha || @@ -1006,11 +1024,11 @@ static void brush_painter_refresh_cache(BrushPainter *painter, const float pos[2 size= (cache->size)? cache->size: diameter; if (brush->flag & BRUSH_FIXED_TEX) { - brush_imbuf_new(scene, brush, flt, 3, size, &cache->maskibuf, use_color_correction); + BKE_brush_imbuf_new(scene, brush, flt, 3, size, &cache->maskibuf, use_color_correction); brush_painter_fixed_tex_partial_update(painter, pos); } else - brush_imbuf_new(scene, brush, flt, 2, size, &cache->ibuf, use_color_correction); + BKE_brush_imbuf_new(scene, brush, flt, 2, size, &cache->ibuf, use_color_correction); cache->lastsize= diameter; cache->lastalpha= alpha; @@ -1025,24 +1043,24 @@ static void brush_painter_refresh_cache(BrushPainter *painter, const float pos[2 } } -void brush_painter_break_stroke(BrushPainter *painter) +void BKE_brush_painter_break_stroke(BrushPainter *painter) { painter->firsttouch= 1; } -static void brush_apply_pressure(BrushPainter *painter, Brush *brush, float pressure) +static void brush_pressure_apply(BrushPainter *painter, Brush *brush, float pressure) { - if (brush_use_alpha_pressure(painter->scene, brush)) - brush_set_alpha(painter->scene, brush, MAX2(0.0f, painter->startalpha*pressure)); - if (brush_use_size_pressure(painter->scene, brush)) - brush_set_size(painter->scene, brush, MAX2(1.0f, painter->startsize*pressure)); + if (BKE_brush_use_alpha_pressure(painter->scene, brush)) + brush_alpha_set(painter->scene, brush, MAX2(0.0f, painter->startalpha*pressure)); + if (BKE_brush_use_size_pressure(painter->scene, brush)) + BKE_brush_size_set(painter->scene, brush, MAX2(1.0f, painter->startsize*pressure)); if (brush->flag & BRUSH_JITTER_PRESSURE) brush->jitter = MAX2(0.0f, painter->startjitter*pressure); if (brush->flag & BRUSH_SPACING_PRESSURE) brush->spacing = MAX2(1.0f, painter->startspacing*(1.5f-pressure)); } -void brush_jitter_pos(const Scene *scene, Brush *brush, const float pos[2], float jitterpos[2]) +void BKE_brush_jitter_pos(const Scene *scene, Brush *brush, const float pos[2], float jitterpos[2]) { int use_jitter= brush->jitter != 0; @@ -1052,7 +1070,7 @@ void brush_jitter_pos(const Scene *scene, Brush *brush, const float pos[2], floa if (use_jitter) { float rand_pos[2]; - const int radius= brush_size(scene, brush); + const int radius= BKE_brush_size_get(scene, brush); const int diameter= 2*radius; // find random position within a circle of diameter 1 @@ -1069,8 +1087,8 @@ void brush_jitter_pos(const Scene *scene, Brush *brush, const float pos[2], floa } } -int brush_painter_paint(BrushPainter *painter, BrushFunc func, const float pos[2], double time, float pressure, - void *user, int use_color_correction) +int BKE_brush_painter_paint(BrushPainter *painter, BrushFunc func, const float pos[2], double time, float pressure, + void *user, int use_color_correction) { Scene *scene= painter->scene; Brush *brush= painter->brush; @@ -1087,7 +1105,7 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, const float pos[2 painter->startpaintpos[0]= pos[0]; painter->startpaintpos[1]= pos[1]; - brush_apply_pressure(painter, brush, pressure); + brush_pressure_apply(painter, brush, pressure); if (painter->cache.enabled) brush_painter_refresh_cache(painter, pos, use_color_correction); totpaintops += func(user, painter->cache.ibuf, pos, pos); @@ -1134,11 +1152,11 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, const float pos[2 else { float startdistance, spacing, step, paintpos[2], dmousepos[2], finalpos[2]; float t, len, press; - const int radius= brush_size(scene, brush); + const int radius= BKE_brush_size_get(scene, brush); /* compute brush spacing adapted to brush radius, spacing may depend * on pressure, so update it */ - brush_apply_pressure(painter, brush, painter->lastpressure); + brush_pressure_apply(painter, brush, painter->lastpressure); spacing= MAX2(1.0f, radius)*brush->spacing*0.01f; /* setup starting distance, direction vector and accumulated distance */ @@ -1156,10 +1174,10 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, const float pos[2 t = step/len; press= (1.0f-t)*painter->lastpressure + t*pressure; - brush_apply_pressure(painter, brush, press); + brush_pressure_apply(painter, brush, press); spacing= MAX2(1.0f, radius)*brush->spacing*0.01f; - brush_jitter_pos(scene, brush, paintpos, finalpos); + BKE_brush_jitter_pos(scene, brush, paintpos, finalpos); if (painter->cache.enabled) brush_painter_refresh_cache(painter, finalpos, use_color_correction); @@ -1174,7 +1192,7 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, const float pos[2 } } else { - brush_jitter_pos(scene, brush, pos, finalpos); + BKE_brush_jitter_pos(scene, brush, pos, finalpos); if (painter->cache.enabled) brush_painter_refresh_cache(painter, finalpos, use_color_correction); @@ -1200,9 +1218,9 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, const float pos[2 painter->accumtime -= painttime; while (painter->accumtime >= (double)brush->rate) { - brush_apply_pressure(painter, brush, pressure); + brush_pressure_apply(painter, brush, pressure); - brush_jitter_pos(scene, brush, pos, finalpos); + BKE_brush_jitter_pos(scene, brush, pos, finalpos); if (painter->cache.enabled) brush_painter_refresh_cache(painter, finalpos, use_color_correction); @@ -1220,8 +1238,8 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, const float pos[2 painter->lastmousepos[1]= pos[1]; painter->lastpressure= pressure; - brush_set_alpha(scene, brush, painter->startalpha); - brush_set_size(scene, brush, painter->startsize); + brush_alpha_set(scene, brush, painter->startalpha); + BKE_brush_size_set(scene, brush, painter->startsize); brush->jitter = painter->startjitter; brush->spacing = painter->startspacing; @@ -1229,7 +1247,7 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, const float pos[2 } /* Uses the brush curve control to find a strength value between 0 and 1 */ -float brush_curve_strength_clamp(Brush *br, float p, const float len) +float BKE_brush_curve_strength_clamp(Brush *br, float p, const float len) { if (p >= len) return 0; else p= p/len; @@ -1241,7 +1259,7 @@ float brush_curve_strength_clamp(Brush *br, float p, const float len) } /* same as above but can return negative values if the curve enables * used for sculpt only */ -float brush_curve_strength(Brush *br, float p, const float len) +float BKE_brush_curve_strength(Brush *br, float p, const float len) { if (p >= len) p= 1.0f; @@ -1252,7 +1270,7 @@ float brush_curve_strength(Brush *br, float p, const float len) } /* TODO: should probably be unified with BrushPainter stuff? */ -unsigned int *brush_gen_texture_cache(Brush *br, int half_side) +unsigned int *BKE_brush_gen_texture_cache(Brush *br, int half_side) { unsigned int *texcache = NULL; MTex *mtex = &br->mtex; @@ -1298,7 +1316,7 @@ unsigned int *brush_gen_texture_cache(Brush *br, int half_side) } /**** Radial Control ****/ -struct ImBuf *brush_gen_radial_control_imbuf(Brush *br) +struct ImBuf *BKE_brush_gen_radial_control_imbuf(Brush *br) { ImBuf *im = MEM_callocN(sizeof(ImBuf), "radial control texture"); unsigned int *texcache; @@ -1306,14 +1324,14 @@ struct ImBuf *brush_gen_radial_control_imbuf(Brush *br) int half = side / 2; int i, j; - texcache = brush_gen_texture_cache(br, half); + texcache = BKE_brush_gen_texture_cache(br, half); im->rect_float = MEM_callocN(sizeof(float) * side * side, "radial control rect"); im->x = im->y = side; for (i=0; i<side; ++i) { for (j=0; j<side; ++j) { float magn= sqrt(pow(i - half, 2) + pow(j - half, 2)); - im->rect_float[i*side + j]= brush_curve_strength_clamp(br, magn, half); + im->rect_float[i*side + j]= BKE_brush_curve_strength_clamp(br, magn, half); } } diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c index df80ce6e87c..f0bc2dddbad 100644 --- a/source/blender/blenkernel/intern/bvhutils.c +++ b/source/blender/blenkernel/intern/bvhutils.c @@ -106,7 +106,7 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f B0 = dot_v3v3(diff, e0 ); B1 = dot_v3v3(diff, e1 ); C = dot_v3v3(diff, diff ); - Det = fabs( A00 * A11 - A01 * A01 ); + Det = fabs(A00 * A11 - A01 * A01); S = A01 * B1 - A11 * B0; T = A01 * B0 - A00 * B1; @@ -383,7 +383,7 @@ static void mesh_faces_nearest_point(void *userdata, int index, const float co[3 nearest->index = index; nearest->dist = dist; copy_v3_v3(nearest->co, nearest_tmp); - normal_tri_v3( nearest->no,t0, t1, t2); + normal_tri_v3(nearest->no, t0, t1, t2); } t1 = t2; @@ -402,10 +402,10 @@ static void mesh_faces_spherecast(void *userdata, int index, const BVHTreeRay *r MFace *face = data->face + index; float *t0, *t1, *t2, *t3; - t0 = vert[ face->v1 ].co; - t1 = vert[ face->v2 ].co; - t2 = vert[ face->v3 ].co; - t3 = face->v4 ? vert[ face->v4].co : NULL; + t0 = vert[face->v1].co; + t1 = vert[face->v2].co; + t2 = vert[face->v3].co; + t3 = face->v4 ? vert[face->v4].co : NULL; do @@ -421,7 +421,7 @@ static void mesh_faces_spherecast(void *userdata, int index, const BVHTreeRay *r hit->dist = dist; madd_v3_v3v3fl(hit->co, ray->origin, ray->direction, dist); - normal_tri_v3( hit->no,t0, t1, t2); + normal_tri_v3(hit->no, t0, t1, t2); } t1 = t2; @@ -706,7 +706,7 @@ void free_bvhtree_from_mesh(struct BVHTreeFromMesh *data) if (!data->cached) BLI_bvhtree_free(data->tree); - memset( data, 0, sizeof(*data) ); + memset(data, 0, sizeof(*data)); } } @@ -743,11 +743,11 @@ void bvhcache_insert(BVHCache *cache, BVHTree *tree, int type) { BVHCacheItem *item = NULL; - assert( tree != NULL ); - assert( bvhcache_find(cache, type) == NULL ); + assert(tree != NULL); + assert(bvhcache_find(cache, type) == NULL); item = MEM_mallocN(sizeof(BVHCacheItem), "BVHCacheItem"); - assert( item != NULL ); + assert(item != NULL); item->type = type; item->tree = tree; diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c index 12801228950..11c628e7848 100644 --- a/source/blender/blenkernel/intern/camera.c +++ b/source/blender/blenkernel/intern/camera.c @@ -50,7 +50,7 @@ /****************************** Camera Datablock *****************************/ -void *add_camera(const char *name) +void *BKE_camera_add(const char *name) { Camera *cam; @@ -69,7 +69,7 @@ void *add_camera(const char *name) return cam; } -Camera *copy_camera(Camera *cam) +Camera *BKE_camera_copy(Camera *cam) { Camera *camn; @@ -80,7 +80,7 @@ Camera *copy_camera(Camera *cam) return camn; } -void make_local_camera(Camera *cam) +void BKE_camera_make_local(Camera *cam) { Main *bmain= G.main; Object *ob; @@ -108,7 +108,7 @@ void make_local_camera(Camera *cam) id_clear_lib_data(bmain, &cam->id); } else if (is_local && is_lib) { - Camera *cam_new= copy_camera(cam); + Camera *cam_new= BKE_camera_copy(cam); cam_new->id.us= 0; @@ -127,26 +127,26 @@ void make_local_camera(Camera *cam) } } -void free_camera(Camera *ca) +void BKE_camera_free(Camera *ca) { BKE_free_animdata((ID *)ca); } /******************************** Camera Usage *******************************/ -void object_camera_mode(RenderData *rd, Object *cam_ob) +void BKE_camera_object_mode(RenderData *rd, Object *cam_ob) { rd->mode &= ~(R_ORTHO|R_PANORAMA); if (cam_ob && cam_ob->type==OB_CAMERA) { Camera *cam= cam_ob->data; if (cam->type == CAM_ORTHO) rd->mode |= R_ORTHO; - if (cam->flag & CAM_PANORAMA) rd->mode |= R_PANORAMA; + if (cam->type == CAM_PANO) rd->mode |= R_PANORAMA; } } /* get the camera's dof value, takes the dof object into account */ -float object_camera_dof_distance(Object *ob) +float BKE_camera_object_dof_distance(Object *ob) { Camera *cam = (Camera *)ob->data; if (ob->type != OB_CAMERA) @@ -165,7 +165,7 @@ float object_camera_dof_distance(Object *ob) return cam->YF_dofdist; } -float camera_sensor_size(int sensor_fit, float sensor_x, float sensor_y) +float BKE_camera_sensor_size(int sensor_fit, float sensor_x, float sensor_y) { /* sensor size used to fit to. for auto, sensor_x is both x and y. */ if (sensor_fit == CAMERA_SENSOR_FIT_VERT) @@ -174,7 +174,7 @@ float camera_sensor_size(int sensor_fit, float sensor_x, float sensor_y) return sensor_x; } -int camera_sensor_fit(int sensor_fit, float sizex, float sizey) +int BKE_camera_sensor_fit(int sensor_fit, float sizex, float sizey) { if (sensor_fit == CAMERA_SENSOR_FIT_AUTO) { if (sizex >= sizey) @@ -188,7 +188,7 @@ int camera_sensor_fit(int sensor_fit, float sizex, float sizey) /******************************** Camera Params *******************************/ -void camera_params_init(CameraParams *params) +void BKE_camera_params_init(CameraParams *params) { memset(params, 0, sizeof(CameraParams)); @@ -200,7 +200,7 @@ void camera_params_init(CameraParams *params) params->zoom= 1.0f; } -void camera_params_from_object(CameraParams *params, Object *ob) +void BKE_camera_params_from_object(CameraParams *params, Object *ob) { if (!ob) return; @@ -239,7 +239,7 @@ void camera_params_from_object(CameraParams *params, Object *ob) } } -void camera_params_from_view3d(CameraParams *params, View3D *v3d, RegionView3D *rv3d) +void BKE_camera_params_from_view3d(CameraParams *params, View3D *v3d, RegionView3D *rv3d) { /* common */ params->lens= v3d->lens; @@ -248,7 +248,7 @@ void camera_params_from_view3d(CameraParams *params, View3D *v3d, RegionView3D * if (rv3d->persp==RV3D_CAMOB) { /* camera view */ - camera_params_from_object(params, v3d->camera); + BKE_camera_params_from_object(params, v3d->camera); params->zoom= BKE_screen_view3d_zoom_to_fac((float)rv3d->camzoom); @@ -275,7 +275,7 @@ void camera_params_from_view3d(CameraParams *params, View3D *v3d, RegionView3D * } } -void camera_params_compute_viewplane(CameraParams *params, int winx, int winy, float xasp, float yasp) +void BKE_camera_params_compute_viewplane(CameraParams *params, int winx, int winy, float xasp, float yasp) { rctf viewplane; float pixsize, viewfac, sensor_size, dx, dy; @@ -293,12 +293,12 @@ void camera_params_compute_viewplane(CameraParams *params, int winx, int winy, f } else { /* perspective camera */ - sensor_size= camera_sensor_size(params->sensor_fit, params->sensor_x, params->sensor_y); + sensor_size= BKE_camera_sensor_size(params->sensor_fit, params->sensor_x, params->sensor_y); pixsize= (sensor_size * params->clipsta)/params->lens; } /* determine sensor fit */ - sensor_fit = camera_sensor_fit(params->sensor_fit, xasp*winx, yasp*winy); + sensor_fit = BKE_camera_sensor_fit(params->sensor_fit, xasp*winx, yasp*winy); if (sensor_fit==CAMERA_SENSOR_FIT_HOR) viewfac= winx; @@ -351,23 +351,23 @@ void camera_params_compute_viewplane(CameraParams *params, int winx, int winy, f } /* viewplane is assumed to be already computed */ -void camera_params_compute_matrix(CameraParams *params) +void BKE_camera_params_compute_matrix(CameraParams *params) { - rctf viewplane= params->viewplane; + rctf viewplane = params->viewplane; /* compute projection matrix */ if (params->is_ortho) orthographic_m4(params->winmat, viewplane.xmin, viewplane.xmax, - viewplane.ymin, viewplane.ymax, params->clipsta, params->clipend); + viewplane.ymin, viewplane.ymax, params->clipsta, params->clipend); else perspective_m4(params->winmat, viewplane.xmin, viewplane.xmax, - viewplane.ymin, viewplane.ymax, params->clipsta, params->clipend); + viewplane.ymin, viewplane.ymax, params->clipsta, params->clipend); } /***************************** Camera View Frame *****************************/ -void camera_view_frame_ex(Scene *scene, Camera *camera, float drawsize, const short 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_ex(Scene *scene, Camera *camera, float drawsize, const short 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; float depth; @@ -376,7 +376,7 @@ void camera_view_frame_ex(Scene *scene, Camera *camera, float drawsize, const sh if (scene) { float aspx= (float) scene->r.xsch*scene->r.xasp; float aspy= (float) scene->r.ysch*scene->r.yasp; - int sensor_fit= camera_sensor_fit(camera->sensor_fit, aspx, aspy); + int sensor_fit= BKE_camera_sensor_fit(camera->sensor_fit, aspx, aspy); if (sensor_fit==CAMERA_SENSOR_FIT_HOR) { r_asp[0]= 1.0; @@ -431,14 +431,14 @@ void camera_view_frame_ex(Scene *scene, Camera *camera, float drawsize, const sh r_vec[3][0]= r_shift[0] - facx; r_vec[3][1]= r_shift[1] + facy; r_vec[3][2]= depth; } -void camera_view_frame(Scene *scene, Camera *camera, float r_vec[4][3]) +void BKE_camera_view_frame(Scene *scene, Camera *camera, float r_vec[4][3]) { float dummy_asp[2]; float dummy_shift[2]; float dummy_drawsize; const float dummy_scale[3]= {1.0f, 1.0f, 1.0f}; - camera_view_frame_ex(scene, camera, FALSE, 1.0, dummy_scale, + BKE_camera_view_frame_ex(scene, camera, FALSE, 1.0, dummy_scale, dummy_asp, dummy_shift, &dummy_drawsize, r_vec); } @@ -450,7 +450,7 @@ typedef struct CameraViewFrameData { unsigned int tot; } CameraViewFrameData; -static void camera_to_frame_view_cb(const float co[3], void *user_data) +static void BKE_camera_to_frame_view_cb(const float co[3], void *user_data) { CameraViewFrameData *data= (CameraViewFrameData *)user_data; unsigned int i; @@ -467,17 +467,17 @@ static void camera_to_frame_view_cb(const float co[3], void *user_data) /* don't move the camera, just yield the fit location */ /* only valid for perspective cameras */ -int camera_view_frame_fit_to_scene(Scene *scene, struct View3D *v3d, Object *camera_ob, float r_co[3]) +int BKE_camera_view_frame_fit_to_scene(Scene *scene, struct View3D *v3d, Object *camera_ob, float r_co[3]) { float shift[2]; float plane_tx[4][3]; float rot_obmat[3][3]; - const float zero[3]= {0,0,0}; + const float zero[3]= {0, 0, 0}; CameraViewFrameData data_cb; unsigned int i; - camera_view_frame(scene, camera_ob->data, data_cb.frame_tx); + BKE_camera_view_frame(scene, camera_ob->data, data_cb.frame_tx); copy_m3_m4(rot_obmat, camera_ob->obmat); normalize_m3(rot_obmat); @@ -514,7 +514,7 @@ int camera_view_frame_fit_to_scene(Scene *scene, struct View3D *v3d, Object *cam data_cb.tot= 0; /* run callback on all visible points */ BKE_scene_foreach_display_point(scene, v3d, BA_SELECT, - camera_to_frame_view_cb, &data_cb); + BKE_camera_to_frame_view_cb, &data_cb); if (data_cb.tot <= 1) { return FALSE; diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 4de7df098c3..78a8b975b85 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -176,7 +176,7 @@ static void cdDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3]) int i; if (dm->numVertData) { - for (i=0; i<dm->numVertData; i++) { + for (i = 0; i < dm->numVertData; i++) { DO_MINMAX(cddm->mvert[i].co, min_r, max_r); } } @@ -226,18 +226,18 @@ static const MeshElemMap *cdDM_getPolyMap(Object *ob, DerivedMesh *dm) static int can_pbvh_draw(Object *ob, DerivedMesh *dm) { CDDerivedMesh *cddm = (CDDerivedMesh*) dm; - Mesh *me= ob->data; - int deformed= 0; + Mesh *me = ob->data; + int deformed = 0; /* active modifiers means extra deformation, which can't be handled correct * on birth of PBVH and sculpt "layer" levels, so use PBVH only for internal brush * stuff and show final DerivedMesh so user would see actual object shape */ - deformed|= ob->sculpt->modifiers_active; + deformed |= ob->sculpt->modifiers_active; /* as in case with modifiers, we can't synchronize deformation made against * PBVH and non-locked keyblock, so also use PBVH only for brushes and * final DM to give final result to user */ - deformed|= ob->sculpt->kb && (ob->shapeflag&OB_SHAPE_LOCK) == 0; + deformed |= ob->sculpt->kb && (ob->shapeflag & OB_SHAPE_LOCK) == 0; if (deformed) return 0; @@ -256,6 +256,7 @@ static struct PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm) if (!ob->sculpt) return NULL; + if (ob->sculpt->pbvh) { cddm->pbvh= ob->sculpt->pbvh; cddm->pbvh_draw = can_pbvh_draw(ob, dm); @@ -265,8 +266,10 @@ static struct PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm) * this derivedmesh is just original mesh. it's the multires subsurf dm * that this is actually for, to support a pbvh on a modified mesh */ if (!cddm->pbvh && ob->type == OB_MESH) { - SculptSession *ss= ob->sculpt; - Mesh *me= ob->data; + SculptSession *ss = ob->sculpt; + Mesh *me = ob->data; + int deformed = 0; + cddm->pbvh = BLI_pbvh_new(); cddm->pbvh_draw = can_pbvh_draw(ob, dm); @@ -275,13 +278,15 @@ static struct PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm) BLI_pbvh_build_mesh(cddm->pbvh, me->mface, me->mvert, me->totface, me->totvert); - if (ss->modifiers_active && ob->derivedDeform) { - DerivedMesh *deformdm= ob->derivedDeform; + deformed = ss->modifiers_active || me->key; + + if (deformed && ob->derivedDeform) { + DerivedMesh *deformdm = ob->derivedDeform; float (*vertCos)[3]; int totvert; - totvert= deformdm->getNumVerts(deformdm); - vertCos= MEM_callocN(3*totvert*sizeof(float), "cdDM_getPBVH vertCos"); + totvert = deformdm->getNumVerts(deformdm); + vertCos = MEM_callocN(3*totvert*sizeof(float), "cdDM_getPBVH vertCos"); deformdm->getVertCos(deformdm, vertCos); BLI_pbvh_apply_vertCos(cddm->pbvh, vertCos); MEM_freeN(vertCos); @@ -312,7 +317,7 @@ static void cdDM_drawVerts(DerivedMesh *dm) MVert *mv = cddm->mvert; int i; - if ( GPU_buffer_legacy(dm) ) { + if (GPU_buffer_legacy(dm)) { glBegin(GL_POINTS); for (i = 0; i < dm->numVertData; i++, mv++) glVertex3fv(mv->co); @@ -320,11 +325,11 @@ static void cdDM_drawVerts(DerivedMesh *dm) } else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */ GPU_vertex_setup(dm); - if ( !GPU_buffer_legacy(dm) ) { + if (!GPU_buffer_legacy(dm)) { if (dm->drawObject->tot_triangle_point) - glDrawArrays(GL_POINTS,0, dm->drawObject->tot_triangle_point); + glDrawArrays(GL_POINTS, 0, dm->drawObject->tot_triangle_point); else - glDrawArrays(GL_POINTS,0, dm->drawObject->tot_loose_point); + glDrawArrays(GL_POINTS, 0, dm->drawObject->tot_loose_point); } GPU_buffer_unbind(); } @@ -338,7 +343,7 @@ static void cdDM_drawUVEdges(DerivedMesh *dm) int i; if (mf) { - if ( GPU_buffer_legacy(dm) ) { + if (GPU_buffer_legacy(dm)) { glBegin(GL_LINES); for (i = 0; i < dm->numTessFaceData; i++, mf++, tf++) { if (!(mf->flag&ME_HIDE)) { @@ -370,7 +375,7 @@ static void cdDM_drawUVEdges(DerivedMesh *dm) int curpos = 0; GPU_uvedge_setup(dm); - if ( !GPU_buffer_legacy(dm) ) { + if (!GPU_buffer_legacy(dm)) { for (i = 0; i < dm->numTessFaceData; i++, mf++) { if (!(mf->flag&ME_HIDE)) { draw = 1; @@ -380,7 +385,7 @@ static void cdDM_drawUVEdges(DerivedMesh *dm) } if ( prevdraw != draw ) { if ( prevdraw > 0 && (curpos-prevstart) > 0) { - glDrawArrays(GL_LINES,prevstart,curpos-prevstart); + glDrawArrays(GL_LINES, prevstart, curpos-prevstart); } prevstart = curpos; } @@ -393,7 +398,7 @@ static void cdDM_drawUVEdges(DerivedMesh *dm) prevdraw = draw; } if ( prevdraw > 0 && (curpos-prevstart) > 0 ) { - glDrawArrays(GL_LINES,prevstart,curpos-prevstart); + glDrawArrays(GL_LINES, prevstart, curpos-prevstart); } } GPU_buffer_unbind(); @@ -408,8 +413,8 @@ static void cdDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdges MEdge *medge = cddm->medge; int i; - if ( GPU_buffer_legacy(dm) ) { - DEBUG_VBO( "Using legacy code. cdDM_drawEdges\n" ); + if (GPU_buffer_legacy(dm)) { + DEBUG_VBO("Using legacy code. cdDM_drawEdges\n"); glBegin(GL_LINES); for (i = 0; i < dm->numEdgeData; i++, medge++) { if ((drawAllEdges || (medge->flag & ME_EDGEDRAW)) && @@ -460,8 +465,8 @@ static void cdDM_drawLooseEdges(DerivedMesh *dm) MEdge *medge = cddm->medge; int i; - if ( GPU_buffer_legacy(dm) ) { - DEBUG_VBO( "Using legacy code. cdDM_drawLooseEdges\n" ); + if (GPU_buffer_legacy(dm)) { + DEBUG_VBO("Using legacy code. cdDM_drawLooseEdges\n"); glBegin(GL_LINES); for (i = 0; i < dm->numEdgeData; i++, medge++) { if (medge->flag&ME_LOOSEEDGE) { @@ -477,7 +482,7 @@ static void cdDM_drawLooseEdges(DerivedMesh *dm) int draw = 1; GPU_edge_setup(dm); - if ( !GPU_buffer_legacy(dm) ) { + if (!GPU_buffer_legacy(dm)) { for (i = 0; i < dm->numEdgeData; i++, medge++) { if (medge->flag&ME_LOOSEEDGE) { draw = 1; @@ -530,8 +535,8 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm, return; } - if ( GPU_buffer_legacy(dm) ) { - DEBUG_VBO( "Using legacy code. cdDM_drawFacesSolid\n" ); + if (GPU_buffer_legacy(dm)) { + DEBUG_VBO("Using legacy code. cdDM_drawFacesSolid\n"); glBegin(glmode = GL_QUADS); for (a = 0; a < dm->numTessFaceData; a++, mface++) { int new_glmode, new_matnr, new_shademodel; @@ -558,10 +563,10 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm, /* TODO make this better (cache facenormals as layer?) */ float nor[3]; if (mface->v4) { - normal_quad_v3( nor,mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co, mvert[mface->v4].co); + normal_quad_v3(nor, mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co, mvert[mface->v4].co); } else { - normal_tri_v3( nor,mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co); + normal_tri_v3(nor, mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co); } glNormal3fv(nor); } @@ -580,9 +585,9 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm, glEnd(); } else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */ - GPU_vertex_setup( dm ); - GPU_normal_setup( dm ); - if ( !GPU_buffer_legacy(dm) ) { + GPU_vertex_setup(dm); + GPU_normal_setup(dm); + if (!GPU_buffer_legacy(dm)) { glShadeModel(GL_SMOOTH); for (a = 0; a < dm->drawObject->totmaterial; a++) { if (setMaterial(dm->drawObject->materials[a].mat_nr + 1, NULL)) { @@ -591,7 +596,7 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm, } } } - GPU_buffer_unbind( ); + GPU_buffer_unbind(); } #undef PASSVERT @@ -618,8 +623,8 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, cdDM_update_normals_from_pbvh(dm); - if ( GPU_buffer_legacy(dm) ) { - DEBUG_VBO( "Using legacy code. cdDM_drawFacesTex_common\n" ); + if (GPU_buffer_legacy(dm)) { + DEBUG_VBO("Using legacy code. cdDM_drawFacesTex_common\n"); for (i = 0; i < dm->numTessFaceData; i++, mf++) { MVert *mvert; DMDrawOption draw_option; @@ -642,7 +647,7 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, if (draw_option != DM_DRAW_OPTION_SKIP) { if (draw_option != DM_DRAW_OPTION_NO_MCOL && mcol) - cp= (unsigned char*) &mcol[i*4]; + cp = (unsigned char*) &mcol[i*4]; if (!(mf->flag&ME_SMOOTH)) { if (nors) { @@ -651,10 +656,10 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, else { float nor[3]; if (mf->v4) { - normal_quad_v3( nor,mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co, mv[mf->v4].co); + normal_quad_v3(nor, mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co, mv[mf->v4].co); } else { - normal_tri_v3( nor,mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co); + normal_tri_v3(nor, mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co); } glNormal3fv(nor); } @@ -697,45 +702,45 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, if (!col) col = mcol; - GPU_vertex_setup( dm ); - GPU_normal_setup( dm ); - GPU_uv_setup( dm ); + GPU_vertex_setup(dm); + GPU_normal_setup(dm); + GPU_uv_setup(dm); if ( col != NULL ) { #if 0 - if ( realcol && dm->drawObject->colType == CD_TEXTURE_MCOL ) { + if (realcol && dm->drawObject->colType == CD_TEXTURE_MCOL) { col = 0; } - else if ( mcol && dm->drawObject->colType == CD_MCOL ) { + else if (mcol && dm->drawObject->colType == CD_MCOL) { col = 0; } - if ( col != 0 ) + if (col != 0) #endif { unsigned char *colors = MEM_mallocN(dm->getNumTessFaces(dm)*4*3*sizeof(unsigned char), "cdDM_drawFacesTex_common"); - for ( i=0; i < dm->getNumTessFaces(dm); i++ ) { - for ( j=0; j < 4; j++ ) { + for (i = 0; i < dm->getNumTessFaces(dm); i++) { + for (j = 0; j < 4; j++) { /* bgr -> rgb is intentional (and stupid), but how its stored internally */ colors[i*12+j*3] = col[i*4+j].b; colors[i*12+j*3+1] = col[i*4+j].g; colors[i*12+j*3+2] = col[i*4+j].r; } } - GPU_color3_upload(dm,colors); + GPU_color3_upload(dm, colors); MEM_freeN(colors); if (realcol) dm->drawObject->colType = CD_TEXTURE_MCOL; else if (mcol) dm->drawObject->colType = CD_MCOL; } - GPU_color_setup( dm ); + GPU_color_setup(dm); } - if ( !GPU_buffer_legacy(dm) ) { + if (!GPU_buffer_legacy(dm)) { int tottri = dm->drawObject->tot_triangle_point/3; - int next_actualFace= dm->drawObject->triangle_to_mface[0]; + int next_actualFace = dm->drawObject->triangle_to_mface[0]; - glShadeModel( GL_SMOOTH ); + glShadeModel(GL_SMOOTH); /* lastFlag = 0; */ /* UNUSED */ for (i = 0; i < tottri; i++) { int actualFace = next_actualFace; @@ -761,7 +766,7 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, } /* flush buffer if current triangle isn't drawable or it's last triangle */ - flush= (draw_option == DM_DRAW_OPTION_SKIP) || (i == tottri - 1); + flush = (draw_option == DM_DRAW_OPTION_SKIP) || (i == tottri - 1); if (!flush && compareDrawOptions) { /* also compare draw options and flush buffer if they're different @@ -770,9 +775,9 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, } if (flush) { - int first= startFace*3; + int first = startFace*3; /* Add one to the length if we're drawing at the end of the array */ - int count= (i-startFace+(draw_option != DM_DRAW_OPTION_SKIP ? 1 : 0))*3; + int count = (i-startFace+(draw_option != DM_DRAW_OPTION_SKIP ? 1 : 0))*3; if (count) { if (col) @@ -789,7 +794,7 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, } GPU_buffer_unbind(); - glShadeModel( GL_FLAT ); + glShadeModel(GL_FLAT); } } @@ -825,13 +830,13 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, /* back-buffer always uses legacy since VBO's would need the * color array temporarily overwritten for drawing, then reset. */ - if ( GPU_buffer_legacy(dm) || G.f & G_BACKBUFSEL) { - DEBUG_VBO( "Using legacy code. cdDM_drawMappedFaces\n" ); + if (GPU_buffer_legacy(dm) || G.f & G_BACKBUFSEL) { + DEBUG_VBO("Using legacy code. cdDM_drawMappedFaces\n"); for (i = 0; i < dm->numTessFaceData; i++, mf++) { int drawSmooth = (flag & DM_DRAW_ALWAYS_SMOOTH) ? 1 : (mf->flag & ME_SMOOTH); - DMDrawOption draw_option= DM_DRAW_OPTION_NORMAL; + DMDrawOption draw_option = DM_DRAW_OPTION_NORMAL; - orig= (index==NULL) ? i : *index++; + orig = (index==NULL) ? i : *index++; if (orig == ORIGINDEX_NONE) draw_option= setMaterial(mf->mat_nr + 1, NULL); @@ -856,10 +861,10 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, else { float nor[3]; if (mf->v4) { - normal_quad_v3( nor,mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co, mv[mf->v4].co); + normal_quad_v3(nor, mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co, mv[mf->v4].co); } else { - normal_tri_v3( nor,mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co); + normal_tri_v3(nor, mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co); } glNormal3fv(nor); } @@ -904,7 +909,7 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, GPU_normal_setup(dm); if ( useColors && mc ) GPU_color_setup(dm); - if ( !GPU_buffer_legacy(dm) ) { + if (!GPU_buffer_legacy(dm)) { int tottri = dm->drawObject->tot_triangle_point/3; glShadeModel(GL_SMOOTH); @@ -917,12 +922,12 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, } else { /* we need to check if the next material changes */ - int next_actualFace= dm->drawObject->triangle_to_mface[0]; + int next_actualFace = dm->drawObject->triangle_to_mface[0]; - for ( i = 0; i < tottri; i++ ) { + for (i = 0; i < tottri; i++) { //int actualFace = dm->drawObject->triangle_to_mface[i]; int actualFace = next_actualFace; - MFace *mface= mf + actualFace; + MFace *mface = mf + actualFace; /*int drawSmooth= (flag & DM_DRAW_ALWAYS_SMOOTH) ? 1 : (mface->flag & ME_SMOOTH);*/ /* UNUSED */ DMDrawOption draw_option = DM_DRAW_OPTION_NORMAL; int flush = 0; @@ -930,7 +935,7 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, if (i != tottri-1) next_actualFace= dm->drawObject->triangle_to_mface[i+1]; - orig= (index==NULL) ? actualFace : index[actualFace]; + orig = (index==NULL) ? actualFace : index[actualFace]; if (orig == ORIGINDEX_NONE) draw_option= setMaterial(mface->mat_nr + 1, NULL); @@ -942,19 +947,19 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, * invisible triangle or at the end of the array */ /* flush buffer if current triangle isn't drawable or it's last triangle... */ - flush= (draw_option == DM_DRAW_OPTION_SKIP) || (i == tottri - 1); + flush = (draw_option == DM_DRAW_OPTION_SKIP) || (i == tottri - 1); /* ... or when material setting is dissferent */ - flush|= mf[actualFace].mat_nr != mf[next_actualFace].mat_nr; + flush |= mf[actualFace].mat_nr != mf[next_actualFace].mat_nr; if (!flush && compareDrawOptions) { - flush|= compareDrawOptions(userData, actualFace, next_actualFace) == 0; + flush |= compareDrawOptions(userData, actualFace, next_actualFace) == 0; } if (flush) { - int first= prevstart*3; + int first = prevstart*3; /* Add one to the length if we're drawing at the end of the array */ - int count= (i-prevstart+(draw_option != DM_DRAW_OPTION_SKIP ? 1 : 0))*3; + int count = (i-prevstart+(draw_option != DM_DRAW_OPTION_SKIP ? 1 : 0))*3; if (count) glDrawArrays(GL_TRIANGLES, first, count); @@ -984,20 +989,20 @@ static void cddm_draw_attrib_vertex(DMVertexAttribs *attribs, MVert *mvert, int /* orco texture coordinates */ if (attribs->totorco) { - if (attribs->orco.glTexco) + if (attribs->orco.gl_texco) glTexCoord3fv(attribs->orco.array[index]); else - glVertexAttrib3fvARB(attribs->orco.glIndex, attribs->orco.array[index]); + glVertexAttrib3fvARB(attribs->orco.gl_index, attribs->orco.array[index]); } /* uv texture coordinates */ for (b = 0; b < attribs->tottface; b++) { MTFace *tf = &attribs->tface[b].array[a]; - if (attribs->tface[b].glTexco) + if (attribs->tface[b].gl_texco) glTexCoord2fv(tf->uv[vert]); else - glVertexAttrib2fvARB(attribs->tface[b].glIndex, tf->uv[vert]); + glVertexAttrib2fvARB(attribs->tface[b].gl_index, tf->uv[vert]); } /* vertex colors */ @@ -1005,13 +1010,13 @@ static void cddm_draw_attrib_vertex(DMVertexAttribs *attribs, MVert *mvert, int MCol *cp = &attribs->mcol[b].array[a*4 + vert]; GLubyte col[4]; col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a; - glVertexAttrib4ubvARB(attribs->mcol[b].glIndex, col); + glVertexAttrib4ubvARB(attribs->mcol[b].gl_index, col); } /* tangent for normal mapping */ if (attribs->tottang) { float *tang = attribs->tang.array[a*4 + vert]; - glVertexAttrib4fvARB(attribs->tang.glIndex, tang); + glVertexAttrib4fvARB(attribs->tang.gl_index, tang); } /* vertex normal */ @@ -1045,7 +1050,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, glShadeModel(GL_SMOOTH); if ( GPU_buffer_legacy(dm) || setDrawOptions != NULL ) { - DEBUG_VBO( "Using legacy code. cdDM_drawMappedFacesGLSL\n" ); + DEBUG_VBO("Using legacy code. cdDM_drawMappedFacesGLSL\n"); memset(&attribs, 0, sizeof(attribs)); glBegin(GL_QUADS); @@ -1088,10 +1093,10 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, /* TODO ideally a normal layer should always be available */ float nor[3]; if (mface->v4) { - normal_quad_v3( nor,mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co, mvert[mface->v4].co); + normal_quad_v3(nor, mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co, mvert[mface->v4].co); } else { - normal_tri_v3( nor,mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co); + normal_tri_v3(nor, mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co); } glNormal3fv(nor); } @@ -1122,30 +1127,30 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, GPU_vertex_setup(dm); GPU_normal_setup(dm); - if ( !GPU_buffer_legacy(dm) ) { - for ( i = 0; i < dm->drawObject->tot_triangle_point/3; i++ ) { + if (!GPU_buffer_legacy(dm)) { + for (i = 0; i < dm->drawObject->tot_triangle_point/3; i++) { a = dm->drawObject->triangle_to_mface[i]; mface = mf + a; new_matnr = mface->mat_nr + 1; - if (new_matnr != matnr ) { + if (new_matnr != matnr) { numfaces = curface - start; - if ( numfaces > 0 ) { + if (numfaces > 0) { - if ( dodraw ) { + if (dodraw) { - if ( numdata != 0 ) { + if (numdata != 0) { GPU_buffer_unlock(buffer); - GPU_interleaved_attrib_setup(buffer,datatypes,numdata); + GPU_interleaved_attrib_setup(buffer, datatypes, numdata); } - glDrawArrays(GL_TRIANGLES,start*3,numfaces*3); + glDrawArrays(GL_TRIANGLES, start*3, numfaces*3); - if ( numdata != 0 ) { + if (numdata != 0) { GPU_buffer_free(buffer); @@ -1162,39 +1167,39 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, DM_vertex_attributes_from_gpu(dm, &gattribs, &attribs); if (attribs.totorco) { - datatypes[numdata].index = attribs.orco.glIndex; + datatypes[numdata].index = attribs.orco.gl_index; datatypes[numdata].size = 3; datatypes[numdata].type = GL_FLOAT; numdata++; } for (b = 0; b < attribs.tottface; b++) { - datatypes[numdata].index = attribs.tface[b].glIndex; + datatypes[numdata].index = attribs.tface[b].gl_index; datatypes[numdata].size = 2; datatypes[numdata].type = GL_FLOAT; numdata++; } for (b = 0; b < attribs.totmcol; b++) { - datatypes[numdata].index = attribs.mcol[b].glIndex; + datatypes[numdata].index = attribs.mcol[b].gl_index; datatypes[numdata].size = 4; datatypes[numdata].type = GL_UNSIGNED_BYTE; numdata++; } if (attribs.tottang) { - datatypes[numdata].index = attribs.tang.glIndex; + datatypes[numdata].index = attribs.tang.gl_index; datatypes[numdata].size = 4; datatypes[numdata].type = GL_FLOAT; numdata++; } - if ( numdata != 0 ) { - elementsize = GPU_attrib_element_size( datatypes, numdata ); - buffer = GPU_buffer_alloc( elementsize*dm->drawObject->tot_triangle_point); - if ( buffer == NULL ) { + if (numdata != 0) { + elementsize = GPU_attrib_element_size(datatypes, numdata); + buffer = GPU_buffer_alloc(elementsize * dm->drawObject->tot_triangle_point); + if (buffer == NULL) { GPU_buffer_unbind(); dm->drawObject->legacy = 1; return; } varray = GPU_buffer_lock_stream(buffer); - if ( varray == NULL ) { + if (varray == NULL) { GPU_buffer_unbind(); GPU_buffer_free(buffer); dm->drawObject->legacy = 1; @@ -1205,7 +1210,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, /* if the buffer was set, don't use it again. * prevdraw was assumed true but didnt run so set to false - [#21036] */ /* prevdraw= 0; */ /* UNUSED */ - buffer= NULL; + buffer = NULL; } } } @@ -1213,17 +1218,17 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, if (dodraw && numdata != 0 ) { offset = 0; if (attribs.totorco) { - copy_v3_v3((float *)&varray[elementsize*curface*3],(float *)attribs.orco.array[mface->v1]); - copy_v3_v3((float *)&varray[elementsize*curface*3+elementsize],(float *)attribs.orco.array[mface->v2]); - copy_v3_v3((float *)&varray[elementsize*curface*3+elementsize*2],(float *)attribs.orco.array[mface->v3]); + copy_v3_v3((float *)&varray[elementsize*curface*3], (float *)attribs.orco.array[mface->v1]); + copy_v3_v3((float *)&varray[elementsize*curface*3+elementsize], (float *)attribs.orco.array[mface->v2]); + copy_v3_v3((float *)&varray[elementsize*curface*3+elementsize*2], (float *)attribs.orco.array[mface->v3]); offset += sizeof(float)*3; } for (b = 0; b < attribs.tottface; b++) { MTFace *tf = &attribs.tface[b].array[a]; - copy_v2_v2((float *)&varray[elementsize*curface*3+offset],tf->uv[0]); - copy_v2_v2((float *)&varray[elementsize*curface*3+offset+elementsize],tf->uv[1]); + copy_v2_v2((float *)&varray[elementsize*curface*3+offset], tf->uv[0]); + copy_v2_v2((float *)&varray[elementsize*curface*3+offset+elementsize], tf->uv[1]); - copy_v2_v2((float *)&varray[elementsize*curface*3+offset+elementsize*2],tf->uv[2]); + copy_v2_v2((float *)&varray[elementsize*curface*3+offset+elementsize*2], tf->uv[2]); offset += sizeof(float)*2; } for (b = 0; b < attribs.totmcol; b++) { @@ -1255,16 +1260,16 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, if (dodraw && numdata != 0 ) { offset = 0; if (attribs.totorco) { - copy_v3_v3((float *)&varray[elementsize*curface*3],(float *)attribs.orco.array[mface->v3]); - copy_v3_v3((float *)&varray[elementsize*curface*3+elementsize],(float *)attribs.orco.array[mface->v4]); - copy_v3_v3((float *)&varray[elementsize*curface*3+elementsize*2],(float *)attribs.orco.array[mface->v1]); + copy_v3_v3((float *)&varray[elementsize*curface*3], (float *)attribs.orco.array[mface->v3]); + copy_v3_v3((float *)&varray[elementsize*curface*3+elementsize], (float *)attribs.orco.array[mface->v4]); + copy_v3_v3((float *)&varray[elementsize*curface*3+elementsize*2], (float *)attribs.orco.array[mface->v1]); offset += sizeof(float)*3; } for (b = 0; b < attribs.tottface; b++) { MTFace *tf = &attribs.tface[b].array[a]; - copy_v2_v2((float *)&varray[elementsize*curface*3+offset],tf->uv[2]); - copy_v2_v2((float *)&varray[elementsize*curface*3+offset+elementsize],tf->uv[3]); - copy_v2_v2((float *)&varray[elementsize*curface*3+offset+elementsize*2],tf->uv[0]); + copy_v2_v2((float *)&varray[elementsize*curface*3+offset], tf->uv[2]); + copy_v2_v2((float *)&varray[elementsize*curface*3+offset+elementsize], tf->uv[3]); + copy_v2_v2((float *)&varray[elementsize*curface*3+offset+elementsize*2], tf->uv[0]); offset += sizeof(float)*2; } for (b = 0; b < attribs.totmcol; b++) { @@ -1296,13 +1301,13 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, } } numfaces = curface - start; - if ( numfaces > 0 ) { - if ( dodraw ) { - if ( numdata != 0 ) { + if (numfaces > 0) { + if (dodraw) { + if (numdata != 0) { GPU_buffer_unlock(buffer); - GPU_interleaved_attrib_setup(buffer,datatypes,numdata); + GPU_interleaved_attrib_setup(buffer, datatypes, numdata); } - glDrawArrays(GL_TRIANGLES,start*3,(curface-start)*3); + glDrawArrays(GL_TRIANGLES, start*3, (curface-start)*3); } } GPU_buffer_unbind(); @@ -1374,9 +1379,9 @@ static void cdDM_drawMappedFacesMat(DerivedMesh *dm, float nor[3]; if (mf->v4) - normal_quad_v3( nor,mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co, mvert[mf->v4].co); + normal_quad_v3(nor, mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co, mvert[mf->v4].co); else - normal_tri_v3( nor,mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co); + normal_tri_v3(nor, mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co); glNormal3fv(nor); } @@ -1757,23 +1762,23 @@ static void loops_to_customdata_corners(BMesh *bm, CustomData *facedata, MLoopUV *mloopuv; int i, j, hasPCol = CustomData_has_layer(&bm->ldata, CD_PREVIEW_MLOOPCOL); - for (i=0; i < numTex; i++) { + for (i = 0; i < numTex; i++) { texface = CustomData_get_n(facedata, CD_MTFACE, cdindex, i); texpoly = CustomData_bmesh_get_n(&bm->pdata, f->head.data, CD_MTEXPOLY, i); ME_MTEXFACE_CPY(texface, texpoly); - for (j=0; j<3; j++) { + for (j = 0 ; j < 3; j++) { l = l3[j]; mloopuv = CustomData_bmesh_get_n(&bm->ldata, l->head.data, CD_MLOOPUV, i); copy_v2_v2(texface->uv[j], mloopuv->uv); } } - for (i=0; i < numCol; i++) { + for (i = 0; i < numCol; i++) { mcol = CustomData_get_n(facedata, CD_MCOL, cdindex, i); - for (j=0; j<3; j++) { + for (j = 0; j < 3; j++) { l = l3[j]; mloopcol = CustomData_bmesh_get_n(&bm->ldata, l->head.data, CD_MLOOPCOL, i); MESH_MLOOPCOL_TO_MCOL(mloopcol, &mcol[j]); @@ -1783,7 +1788,7 @@ static void loops_to_customdata_corners(BMesh *bm, CustomData *facedata, if (hasPCol) { mcol = CustomData_get(facedata, cdindex, CD_PREVIEW_MCOL); - for (j=0; j<3; j++) { + for (j = 0; j < 3; j++) { l = l3[j]; mloopcol = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_PREVIEW_MLOOPCOL); MESH_MLOOPCOL_TO_MCOL(mloopcol, &mcol[j]); @@ -1849,7 +1854,7 @@ DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *UNUSED(me), int use_mdis index = dm->getVertDataArray(dm, CD_ORIGINDEX); eve = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL); - for (i=0; eve; eve=BM_iter_step(&iter), i++, index++) { + for (i = 0; eve; eve = BM_iter_step(&iter), i++, index++) { MVert *mv = &mvert[i]; copy_v3_v3(mv->co, eve->co); @@ -1871,7 +1876,7 @@ DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *UNUSED(me), int use_mdis index = dm->getEdgeDataArray(dm, CD_ORIGINDEX); eed = BM_iter_new(&iter, bm, BM_EDGES_OF_MESH, NULL); - for (i=0; eed; eed=BM_iter_step(&iter), i++, index++) { + for (i = 0; eed; eed = BM_iter_step(&iter), i++, index++) { MEdge *med = &medge[i]; BM_elem_index_set(eed, i); /* set_inline */ @@ -1922,7 +1927,7 @@ DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *UNUSED(me), int use_mdis index = CustomData_get_layer(&dm->polyData, CD_ORIGINDEX); j = 0; efa = BM_iter_new(&iter, bm, BM_FACES_OF_MESH, NULL); - for (i=0; efa; i++, efa=BM_iter_step(&iter), index++) { + for (i = 0; efa; i++, efa = BM_iter_step(&iter), index++) { BMLoop *l; MPoly *mp = &mpoly[i]; @@ -2210,7 +2215,7 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap) /*fill newl with destination vertex indices*/ mv = cddm->mvert; c = 0; - for (i=0; i<dm->numVertData; i++, mv++) { + for (i = 0; i < dm->numVertData; i++, mv++) { if (vtargetmap[i] == -1) { BLI_array_append(oldv, i); newv[i] = c++; @@ -2219,7 +2224,7 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap) } /*now link target vertices to destination indices*/ - for (i=0; i<dm->numVertData; i++) { + for (i = 0; i < dm->numVertData; i++) { if (vtargetmap[i] != -1) { newv[i] = newv[vtargetmap[i]]; } @@ -2227,7 +2232,7 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap) /*find-replace merged vertices with target vertices*/ ml = cddm->mloop; - for (i=0; i<totloop; i++, ml++) { + for (i = 0; i < totloop; i++, ml++) { if (vtargetmap[ml->v] != -1) { ml->v = vtargetmap[ml->v]; } @@ -2236,7 +2241,7 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap) /*now go through and fix edges and faces*/ med = cddm->medge; c = 0; - for (i=0; i<dm->numEdgeData; i++, med++) { + for (i = 0; i < dm->numEdgeData; i++, med++) { if (LIKELY(med->v1 != med->v2)) { const unsigned int v1 = (vtargetmap[med->v1] != -1) ? vtargetmap[med->v1] : med->v1; @@ -2260,13 +2265,13 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap) } mp = cddm->mpoly; - for (i=0; i<totpoly; i++, mp++) { + for (i = 0; i < totpoly; i++, mp++) { MPoly *mp2; ml = cddm->mloop + mp->loopstart; c = 0; - for (j=0; j<mp->totloop; j++, ml++) { + for (j = 0; j < mp->totloop; j++, ml++) { med = cddm->medge + ml->e; if (LIKELY(med->v1 != med->v2)) { newl[j+mp->loopstart] = BLI_array_count(mloop); @@ -2292,7 +2297,7 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap) /*update edge indices and copy customdata*/ med = medge; - for (i=0; i<cddm2->dm.numEdgeData; i++, med++) { + for (i = 0; i < cddm2->dm.numEdgeData; i++, med++) { if (newv[med->v1] != -1) med->v1 = newv[med->v1]; if (newv[med->v2] != -1) @@ -2303,7 +2308,7 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap) /*update loop indices and copy customdata*/ ml = mloop; - for (i=0; i<cddm2->dm.numLoopData; i++, ml++) { + for (i = 0; i < cddm2->dm.numLoopData; i++, ml++) { if (newe[ml->e] != -1) ml->e = newe[ml->e]; if (newv[ml->v] != -1) @@ -2314,13 +2319,13 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap) /*copy vertex customdata*/ mv = mvert; - for (i=0; i<cddm2->dm.numVertData; i++, mv++) { + for (i = 0; i < cddm2->dm.numVertData; i++, mv++) { CustomData_copy_data(&dm->vertData, &cddm2->dm.vertData, oldv[i], i, 1); } /*copy poly customdata*/ mp = mpoly; - for (i=0; i<cddm2->dm.numPolyData; i++, mp++) { + for (i = 0; i < cddm2->dm.numPolyData; i++, mp++) { CustomData_copy_data(&dm->polyData, &cddm2->dm.polyData, oldp[i], i, 1); } @@ -2431,14 +2436,14 @@ void CDDM_calc_edges(DerivedMesh *dm) med = cddm->medge; if (med) { - for (i=0; i < numEdges; i++, med++) { + for (i = 0; i < numEdges; i++, med++) { BLI_edgehash_insert(eh, med->v1, med->v2, SET_INT_IN_POINTER(i+1)); } } - for (i=0; i < maxFaces; i++, mp++) { + for (i = 0; i < maxFaces; i++, mp++) { ml = cddm->mloop + mp->loopstart; - for (j=0; j<mp->totloop; j++, ml++) { + for (j = 0; j < mp->totloop; j++, ml++) { v1 = ml->v; v2 = ME_POLY_LOOP_NEXT(cddm->mloop, mp, j)->v; if (!BLI_edgehash_haskey(eh, v1, v2)) { @@ -2477,9 +2482,9 @@ void CDDM_calc_edges(DerivedMesh *dm) cddm->medge = CustomData_get_layer(&dm->edgeData, CD_MEDGE); mp = cddm->mpoly; - for (i=0; i < maxFaces; i++, mp++) { + for (i = 0; i < maxFaces; i++, mp++) { ml = cddm->mloop + mp->loopstart; - for (j=0; j<mp->totloop; j++, ml++) { + for (j = 0; j < mp->totloop; j++, ml++) { v1 = ml->v; v2 = ME_POLY_LOOP_NEXT(cddm->mloop, mp, j)->v; ml->e = GET_INT_FROM_POINTER(BLI_edgehash_lookup(eh, v1, v2)); @@ -2601,13 +2606,13 @@ void CDDM_tessfaces_to_faces(DerivedMesh *dm) /*build edge hash*/ me = cddm->medge; - for (i=0; i<cddm->dm.numEdgeData; i++, me++) { + for (i = 0; i < cddm->dm.numEdgeData; i++, me++) { BLI_edgehash_insert(eh, me->v1, me->v2, SET_INT_IN_POINTER(i)); } mf = cddm->mface; totloop = 0; - for (i=0; i<cddm->dm.numTessFaceData; i++, mf++) { + for (i = 0; i < cddm->dm.numTessFaceData; i++, mf++) { totloop += mf->v4 ? 4 : 3; } @@ -2636,7 +2641,7 @@ void CDDM_tessfaces_to_faces(DerivedMesh *dm) mp = cddm->mpoly; ml = cddm->mloop; l = 0; - for (i=0; i<cddm->dm.numTessFaceData; i++, mf++, mp++, polyindex++) { + for (i = 0; i < cddm->dm.numTessFaceData; i++, mf++, mp++, polyindex++) { mp->flag = mf->flag; mp->loopstart = l; mp->mat_nr = mf->mat_nr; diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index 97baaad430b..b521285c626 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -51,9 +51,9 @@ #include "BKE_pointcache.h" #ifdef _WIN32 -void tstart ( void ) +void tstart( void ) {} -void tend ( void ) +void tend( void ) { } double tval( void ) @@ -64,13 +64,13 @@ double tval( void ) #include <sys/time.h> static struct timeval _tstart, _tend; static struct timezone tz; -void tstart ( void ) +void tstart( void ) { - gettimeofday ( &_tstart, &tz ); + gettimeofday(&_tstart, &tz); } -void tend ( void ) +void tend(void) { - gettimeofday ( &_tend,&tz ); + gettimeofday(&_tend, &tz); } double tval(void) { @@ -111,7 +111,7 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm ); * 1. create object * 2. fill object with standard values or with the GUI settings if given */ -void cloth_init ( ClothModifierData *clmd ) +void cloth_init(ClothModifierData *clmd ) { /* Initialize our new data structure to reasonable values. */ clmd->sim_parms->gravity[0] = 0.0; @@ -605,7 +605,7 @@ void cloth_free_modifier(ClothModifierData *clmd ) } /* frees all */ -void cloth_free_modifier_extern ( ClothModifierData *clmd ) +void cloth_free_modifier_extern(ClothModifierData *clmd ) { Cloth *cloth = NULL; if (G.rt > 0) @@ -728,7 +728,7 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm ) clothObj = clmd->clothObject; - numverts = dm->getNumVerts ( dm ); + numverts = dm->getNumVerts (dm); verts = clothObj->verts; @@ -746,7 +746,7 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm ) // ABS ( clmd->sim_parms->maxgoal - clmd->sim_parms->mingoal ); */ - verts->goal = ( float ) pow ( verts->goal , 4.0f ); + verts->goal = powf(verts->goal, 4.0f); if ( verts->goal >=SOFTGOALSNAP ) { verts->flags |= CLOTH_VERT_FLAG_PINNED; } @@ -781,7 +781,7 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d MVert *mvert = NULL; ClothVertex *verts = NULL; float (*shapekey_rest)[3]= NULL; - float tnull[3] = {0,0,0}; + float tnull[3] = {0, 0, 0}; Cloth *cloth = NULL; float maxdist = 0; @@ -818,20 +818,20 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d if ( clmd->sim_parms->shapekey_rest ) shapekey_rest = dm->getVertDataArray ( dm, CD_CLOTH_ORCO ); - mvert = dm->getVertArray ( dm ); + mvert = dm->getVertArray (dm); verts = clmd->clothObject->verts; // set initial values for ( i = 0; i < dm->getNumVerts(dm); i++, verts++ ) { if (first) { - copy_v3_v3( verts->x, mvert[i].co ); + copy_v3_v3(verts->x, mvert[i].co); - mul_m4_v3( ob->obmat, verts->x ); + mul_m4_v3(ob->obmat, verts->x); if ( shapekey_rest ) { verts->xrest= shapekey_rest[i]; - mul_m4_v3( ob->obmat, verts->xrest ); + mul_m4_v3(ob->obmat, verts->xrest); } else verts->xrest = verts->x; @@ -851,7 +851,7 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d copy_v3_v3 ( verts->xconst, verts->x ); copy_v3_v3 ( verts->txold, verts->x ); copy_v3_v3 ( verts->tx, verts->x ); - mul_v3_fl( verts->v, 0.0f ); + mul_v3_fl(verts->v, 0.0f); verts->impulse_count = 0; copy_v3_v3 ( verts->impulse, tnull ); @@ -895,9 +895,9 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d static void cloth_from_mesh ( ClothModifierData *clmd, DerivedMesh *dm ) { - unsigned int numverts = dm->getNumVerts ( dm ); - unsigned int numfaces = dm->getNumTessFaces ( dm ); - MFace *mface = dm->getTessFaceArray( dm ); + unsigned int numverts = dm->getNumVerts (dm); + unsigned int numfaces = dm->getNumTessFaces (dm); + MFace *mface = dm->getTessFaceArray(dm); unsigned int i = 0; /* Allocate our vertices. */ @@ -936,7 +936,7 @@ static void cloth_from_mesh ( ClothModifierData *clmd, DerivedMesh *dm ) // be careful: implicit solver has to be resettet when using this one! // --> only for implicit handling of this spring! -int cloth_add_spring ( ClothModifierData *clmd, unsigned int indexA, unsigned int indexB, float restlength, int spring_type) +int cloth_add_spring(ClothModifierData *clmd, unsigned int indexA, unsigned int indexB, float restlength, int spring_type) { Cloth *cloth = clmd->clothObject; ClothSpring *spring = NULL; @@ -984,7 +984,7 @@ static void cloth_free_errorsprings(Cloth *cloth, EdgeHash *UNUSED(edgehash), Li if (edgelist) { for ( i = 0; i < cloth->numverts; i++ ) { - BLI_linklist_free ( edgelist[i],NULL ); + BLI_linklist_free ( edgelist[i], NULL ); } MEM_freeN ( edgelist ); @@ -1000,11 +1000,11 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) ClothSpring *spring = NULL, *tspring = NULL, *tspring2 = NULL; unsigned int struct_springs = 0, shear_springs=0, bend_springs = 0; unsigned int i = 0; - unsigned int numverts = (unsigned int)dm->getNumVerts ( dm ); - unsigned int numedges = (unsigned int)dm->getNumEdges ( dm ); - unsigned int numfaces = (unsigned int)dm->getNumTessFaces ( dm ); - MEdge *medge = dm->getEdgeArray ( dm ); - MFace *mface = dm->getTessFaceArray ( dm ); + unsigned int numverts = (unsigned int)dm->getNumVerts (dm); + unsigned int numedges = (unsigned int)dm->getNumEdges (dm); + unsigned int numfaces = (unsigned int)dm->getNumTessFaces (dm); + MEdge *medge = dm->getEdgeArray (dm); + MFace *mface = dm->getTessFaceArray (dm); int index2 = 0; // our second vertex index LinkNode **edgelist = NULL; EdgeHash *edgehash = NULL; @@ -1141,7 +1141,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) spring->restlen = len_v3v3(cloth->verts[spring->kl].xrest, cloth->verts[spring->ij].xrest); spring->type = CLOTH_SPRING_TYPE_BENDING; spring->stiffness = (cloth->verts[spring->kl].bend_stiff + cloth->verts[spring->ij].bend_stiff) / 2.0f; - BLI_edgehash_insert ( edgehash, spring->ij, spring->kl, NULL ); + BLI_edgehash_insert(edgehash, spring->ij, spring->kl, NULL); bend_springs++; BLI_linklist_prepend ( &cloth->springs, spring ); @@ -1190,14 +1190,14 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) /* insert other near springs in edgehash AFTER bending springs are calculated (for selfcolls) */ for (i = 0; i < numedges; i++) { /* struct springs */ - BLI_edgehash_insert ( edgehash, MIN2(medge[i].v1, medge[i].v2), MAX2(medge[i].v2, medge[i].v1), NULL ); + BLI_edgehash_insert(edgehash, MIN2(medge[i].v1, medge[i].v2), MAX2(medge[i].v2, medge[i].v1), NULL); } for (i = 0; i < numfaces; i++) { /* edge springs */ if (mface[i].v4) { - BLI_edgehash_insert ( edgehash, MIN2(mface[i].v1, mface[i].v3), MAX2(mface[i].v3, mface[i].v1), NULL ); + BLI_edgehash_insert(edgehash, MIN2(mface[i].v1, mface[i].v3), MAX2(mface[i].v3, mface[i].v1), NULL); - BLI_edgehash_insert ( edgehash, MIN2(mface[i].v2, mface[i].v4), MAX2(mface[i].v2, mface[i].v4), NULL ); + BLI_edgehash_insert(edgehash, MIN2(mface[i].v2, mface[i].v4), MAX2(mface[i].v2, mface[i].v4), NULL); } } @@ -1206,7 +1206,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) if ( edgelist ) { for ( i = 0; i < numverts; i++ ) { - BLI_linklist_free ( edgelist[i],NULL ); + BLI_linklist_free ( edgelist[i], NULL ); } MEM_freeN ( edgelist ); @@ -1214,8 +1214,8 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) cloth->edgehash = edgehash; - if (G.rt>0) - printf("avg_len: %f\n",clmd->sim_parms->avg_spring_len); + if (G.rt > 0) + printf("avg_len: %f\n", clmd->sim_parms->avg_spring_len); return 1; diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index 264a251c317..609b2d3496c 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -81,10 +81,10 @@ void collision_move_object(CollisionModifierData *collmd, float step, float prev unsigned int i = 0; for ( i = 0; i < collmd->numverts; i++ ) { - sub_v3_v3v3 ( tv, collmd->xnew[i].co, collmd->x[i].co ); - VECADDS ( collmd->current_x[i].co, collmd->x[i].co, tv, prevstep ); - VECADDS ( collmd->current_xnew[i].co, collmd->x[i].co, tv, step ); - sub_v3_v3v3 ( collmd->current_v[i].co, collmd->current_xnew[i].co, collmd->current_x[i].co ); + sub_v3_v3v3(tv, collmd->xnew[i].co, collmd->x[i].co); + VECADDS(collmd->current_x[i].co, collmd->x[i].co, tv, prevstep); + VECADDS(collmd->current_xnew[i].co, collmd->x[i].co, tv, step); + sub_v3_v3v3(collmd->current_v[i].co, collmd->current_xnew[i].co, collmd->current_x[i].co); } bvhtree_update_from_mvert ( collmd->bvhtree, collmd->mfaces, collmd->numfaces, collmd->current_x, collmd->current_xnew, collmd->numverts, 1 ); @@ -116,7 +116,7 @@ BVHTree *bvhtree_build_from_mvert ( MFace *mfaces, unsigned int numfaces, MVert return tree; } -void bvhtree_update_from_mvert ( BVHTree * bvhtree, MFace *faces, int numfaces, MVert *x, MVert *xnew, int UNUSED(numverts), int moving ) +void bvhtree_update_from_mvert(BVHTree * bvhtree, MFace *faces, int numfaces, MVert *x, MVert *xnew, int UNUSED(numverts), int moving ) { int i; MFace *mfaces = faces; @@ -168,7 +168,7 @@ Collision modifier code end * copied from SOLVE_CUBIC.C --> GSL */ -#define mySWAP(a,b) do { double tmp = b ; b = a ; a = tmp ; } while (0) +#define mySWAP(a, b) do { double tmp = b ; b = a ; a = tmp ; } while (0) #if 0 /* UNUSED */ static int gsl_poly_solve_cubic (double a, double b, double c, @@ -445,7 +445,7 @@ static int cloth_get_collision_time ( double a[3], double b[3], double c[3], dou static void collision_compute_barycentric ( float pv[3], float p1[3], float p2[3], float p3[3], float *w1, float *w2, float *w3 ) { double tempV1[3], tempV2[3], tempV4[3]; - double a,b,c,d,e,f; + double a, b, c, d, e, f; VECSUB ( tempV1, p1, p3 ); VECSUB ( tempV2, p2, p3 ); @@ -521,10 +521,10 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM 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 ); + sub_v3_v3v3(relativeVelocity, v2, v1); // Calculate the normal component of the relative velocity (actually only the magnitude - the direction is stored in 'normal'). - magrelVel = dot_v3v3( relativeVelocity, collpair->normal ); + magrelVel = dot_v3v3(relativeVelocity, collpair->normal); // printf("magrelVel: %f\n", magrelVel); @@ -541,16 +541,16 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM // calculate tangential velocity copy_v3_v3 ( temp, collpair->normal ); - mul_v3_fl( temp, magrelVel ); - sub_v3_v3v3 ( vrel_t_pre, relativeVelocity, temp ); + mul_v3_fl(temp, magrelVel); + sub_v3_v3v3(vrel_t_pre, relativeVelocity, temp); // Decrease in magnitude of relative tangential velocity due to coulomb friction // in original formula "magrelVel" should be the "change of relative velocity in normal direction" - magtangent = MIN2 ( clmd->coll_parms->friction * 0.01f * magrelVel, sqrtf( dot_v3v3( vrel_t_pre,vrel_t_pre ) ) ); + magtangent = MIN2(clmd->coll_parms->friction * 0.01f * magrelVel, sqrtf(dot_v3v3(vrel_t_pre, vrel_t_pre))); // Apply friction impulse. if ( magtangent > ALMOST_ZERO ) { - normalize_v3( vrel_t_pre ); + normalize_v3(vrel_t_pre); impulse = magtangent / ( 1.0f + w1*w1 + w2*w2 + w3*w3 ); // 2.0 * VECADDMUL ( cloth1->verts[collpair->ap1].impulse, vrel_t_pre, w1 * impulse ); @@ -573,7 +573,7 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM cloth1->verts[collpair->ap3].impulse_count++; // Apply repulse impulse if distance too short - // I_r = -min(dt*kd, m(0,1d/dt - v_n)) + // I_r = -min(dt*kd, m(0, 1d/dt - v_n)) 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; @@ -839,7 +839,7 @@ static int cloth_edge_collision_response_moving ( ClothModifierData *clmd, Colli VECADDFAC(v1, cloth1->verts[collpair->ap1].tv, cloth1->verts[collpair->ap2].tv, w1); VECADDFAC(v2, collmd->current_v[collpair->bp1].co, collmd->current_v[collpair->bp2].co, w2); - sub_v3_v3v3 ( relativeVelocity, v2, v1); + sub_v3_v3v3(relativeVelocity, v2, v1); // Calculate the normal component of the relative velocity (actually only the magnitude - the direction is stored in 'normal'). magrelVel = dot_v3v3 ( relativeVelocity, collpair->normal ); @@ -856,16 +856,16 @@ static int cloth_edge_collision_response_moving ( ClothModifierData *clmd, Colli // calculate tangential velocity copy_v3_v3 ( temp, collpair->normal ); - mul_v3_fl( temp, magrelVel ); - sub_v3_v3v3 ( vrel_t_pre, relativeVelocity, temp ); + mul_v3_fl(temp, magrelVel); + sub_v3_v3v3(vrel_t_pre, relativeVelocity, temp); // Decrease in magnitude of relative tangential velocity due to coulomb friction // in original formula "magrelVel" should be the "change of relative velocity in normal direction" - magtangent = MIN2 ( clmd->coll_parms->friction * 0.01 * magrelVel,sqrt ( dot_v3v3 ( vrel_t_pre,vrel_t_pre ) ) ); + magtangent = MIN2 ( clmd->coll_parms->friction * 0.01 * magrelVel, sqrt ( dot_v3v3 ( vrel_t_pre, vrel_t_pre ) ) ); // Apply friction impulse. if ( magtangent > ALMOST_ZERO ) { - normalize_v3( vrel_t_pre ); + normalize_v3(vrel_t_pre); impulse = magtangent; VECADDMUL ( pimpulse, vrel_t_pre, impulse); @@ -880,7 +880,7 @@ static int cloth_edge_collision_response_moving ( ClothModifierData *clmd, Colli VECADDMUL ( pimpulse, collpair->normal, impulse); // Apply repulse impulse if distance too short - // I_r = -min(dt*kd, m(0,1d/dt - v_n)) + // I_r = -min(dt*kd, m(0, 1d/dt - v_n)) spf = (float)clmd->sim_parms->stepsPerFrame / clmd->sim_parms->timescale; d = collpair->distance; @@ -937,7 +937,7 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM // Calculate relative "velocity". collision_interpolateOnTriangle ( v1, collmd->current_v[collpair->bp1].co, collmd->current_v[collpair->bp2].co, collmd->current_v[collpair->bp3].co, w1, w2, w3); - sub_v3_v3v3 ( relativeVelocity, v1, cloth1->verts[collpair->collp].tv); + sub_v3_v3v3(relativeVelocity, v1, cloth1->verts[collpair->collp].tv); // Calculate the normal component of the relative velocity (actually only the magnitude - the direction is stored in 'normal'). magrelVel = dot_v3v3 ( relativeVelocity, collpair->normal ); @@ -952,16 +952,16 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM // calculate tangential velocity copy_v3_v3 ( temp, collpair->normal ); - mul_v3_fl( temp, magrelVel ); - sub_v3_v3v3 ( vrel_t_pre, relativeVelocity, temp ); + mul_v3_fl(temp, magrelVel); + sub_v3_v3v3(vrel_t_pre, relativeVelocity, temp); // Decrease in magnitude of relative tangential velocity due to coulomb friction // in original formula "magrelVel" should be the "change of relative velocity in normal direction" - magtangent = MIN2 ( clmd->coll_parms->friction * 0.01 * magrelVel,sqrt ( dot_v3v3 ( vrel_t_pre,vrel_t_pre ) ) ); + magtangent = MIN2 ( clmd->coll_parms->friction * 0.01 * magrelVel, sqrt ( dot_v3v3 ( vrel_t_pre, vrel_t_pre ) ) ); // Apply friction impulse. if ( magtangent > ALMOST_ZERO ) { - normalize_v3( vrel_t_pre ); + normalize_v3(vrel_t_pre); impulse = magtangent; // 2.0 * VECADDMUL ( cloth1->verts[collpair->collp].impulse, vrel_t_pre, impulse); @@ -976,7 +976,7 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM cloth1->verts[collpair->collp].impulse_count++; // Apply repulse impulse if distance too short - // I_r = -min(dt*kd, m(0,1d/dt - v_n)) + // I_r = -min(dt*kd, m(0, 1d/dt - v_n)) spf = (float)clmd->sim_parms->stepsPerFrame / clmd->sim_parms->timescale; d = -collpair->distance; @@ -1001,7 +1001,7 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM // Calculate relative "velocity". collision_interpolateOnTriangle ( v1, cloth1->verts[collpair->ap1].tv, cloth1->verts[collpair->ap2].tv, cloth1->verts[collpair->ap3].tv, w1, w2, w3 ); - sub_v3_v3v3 ( relativeVelocity, collmd->current_v[collpair->collp].co, v1); + sub_v3_v3v3(relativeVelocity, collmd->current_v[collpair->collp].co, v1); // Calculate the normal component of the relative velocity (actually only the magnitude - the direction is stored in 'normal'). magrelVel = dot_v3v3 ( relativeVelocity, collpair->normal ); @@ -1016,16 +1016,16 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM // calculate tangential velocity copy_v3_v3 ( temp, collpair->normal ); - mul_v3_fl( temp, magrelVel ); - sub_v3_v3v3 ( vrel_t_pre, relativeVelocity, temp ); + mul_v3_fl(temp, magrelVel); + sub_v3_v3v3(vrel_t_pre, relativeVelocity, temp); // Decrease in magnitude of relative tangential velocity due to coulomb friction // in original formula "magrelVel" should be the "change of relative velocity in normal direction" - magtangent = MIN2 ( clmd->coll_parms->friction * 0.01 * magrelVel,sqrt ( dot_v3v3 ( vrel_t_pre,vrel_t_pre ) ) ); + magtangent = MIN2 ( clmd->coll_parms->friction * 0.01 * magrelVel, sqrt ( dot_v3v3 ( vrel_t_pre, vrel_t_pre ) ) ); // Apply friction impulse. if ( magtangent > ALMOST_ZERO ) { - normalize_v3( vrel_t_pre ); + normalize_v3(vrel_t_pre); impulse = magtangent; // 2.0 * VECADDMUL ( pimpulse, vrel_t_pre, impulse); @@ -1039,7 +1039,7 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM VECADDMUL ( pimpulse, collpair->normal, impulse); // Apply repulse impulse if distance too short - // I_r = -min(dt*kd, m(0,1d/dt - v_n)) + // I_r = -min(dt*kd, m(0, 1d/dt - v_n)) spf = (float)clmd->sim_parms->stepsPerFrame / clmd->sim_parms->timescale; d = -collpair->distance; @@ -1461,14 +1461,14 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, #ifdef USE_BULLET // calc distance + normal distance = plNearestPoints ( - verts1[collpair->ap1].txold, verts1[collpair->ap2].txold, verts1[collpair->ap3].txold, collmd->current_x[collpair->bp1].co, collmd->current_x[collpair->bp2].co, collmd->current_x[collpair->bp3].co, collpair->pa,collpair->pb,collpair->vector ); + verts1[collpair->ap1].txold, verts1[collpair->ap2].txold, verts1[collpair->ap3].txold, collmd->current_x[collpair->bp1].co, collmd->current_x[collpair->bp2].co, collmd->current_x[collpair->bp3].co, collpair->pa, collpair->pb, collpair->vector ); #else // just be sure that we don't add anything distance = 2.0 * (double)( epsilon1 + epsilon2 + ALMOST_ZERO ); #endif - if ( distance <= ( epsilon1 + epsilon2 + ALMOST_ZERO ) ) { - normalize_v3_v3( collpair->normal, collpair->vector ); + if (distance <= (epsilon1 + epsilon2 + ALMOST_ZERO)) { + normalize_v3_v3(collpair->normal, collpair->vector); collpair->distance = distance; collpair->flag = 0; @@ -1500,7 +1500,7 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, 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 ); + sub_v3_v3v3(relativeVelocity, v2, v1); if (sqrt(dot_v3v3(relativeVelocity, relativeVelocity)) >= distance) { @@ -1547,7 +1547,7 @@ static int cloth_collision_response_moving( ClothModifierData *clmd, CollisionMo 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 ); + sub_v3_v3v3(relativeVelocity, v2, v1); // Calculate the normal component of the relative velocity (actually only the magnitude - the direction is stored in 'normal'). magrelVel = dot_v3v3 ( relativeVelocity, collpair->normal ); @@ -1568,17 +1568,17 @@ static int cloth_collision_response_moving( ClothModifierData *clmd, CollisionMo // calculate tangential velocity copy_v3_v3 ( temp, collpair->normal ); - mul_v3_fl( temp, magrelVel ); - sub_v3_v3v3 ( vrel_t_pre, relativeVelocity, temp ); + mul_v3_fl(temp, magrelVel); + sub_v3_v3v3(vrel_t_pre, relativeVelocity, temp); // Decrease in magnitude of relative tangential velocity due to coulomb friction // in original formula "magrelVel" should be the "change of relative velocity in normal direction" - magtangent = MIN2 ( clmd->coll_parms->friction * 0.01 * magrelVel,sqrt ( dot_v3v3 ( vrel_t_pre,vrel_t_pre ) ) ); + magtangent = MIN2 ( clmd->coll_parms->friction * 0.01 * magrelVel, sqrt ( dot_v3v3 ( vrel_t_pre, vrel_t_pre ) ) ); // Apply friction impulse. if ( magtangent > ALMOST_ZERO ) { - normalize_v3( vrel_t_pre ); + normalize_v3(vrel_t_pre); impulse = 2.0 * magtangent / ( 1.0 + w1*w1 + w2*w2 + w3*w3 ); VECADDMUL ( cloth1->verts[collpair->ap1].impulse, vrel_t_pre, w1 * impulse ); @@ -1601,7 +1601,7 @@ static int cloth_collision_response_moving( ClothModifierData *clmd, CollisionMo cloth1->verts[collpair->ap3].impulse_count++; // Apply repulse impulse if distance too short - // I_r = -min(dt*kd, m(0,1d/dt - v_n)) + // I_r = -min(dt*kd, m(0, 1d/dt - v_n)) /* d = clmd->coll_parms->epsilon*8.0/9.0 + epsilon2*8.0/9.0 - collpair->distance; if ( ( magrelVel < 0.1*d*clmd->sim_parms->stepsPerFrame ) && ( d > ALMOST_ZERO ) ) @@ -1635,7 +1635,7 @@ static float projectPointOntoLine(float *p, float *a, float *b) return dot_v3v3(pa, ba) / dot_v3v3(ba, ba); } -static void calculateEENormal(float *np1, float *np2, float *np3, float *np4,float *out_normal) +static void calculateEENormal(float *np1, float *np2, float *np3, float *np4, float *out_normal) { float line1[3], line2[3]; float length; @@ -1961,14 +1961,14 @@ static int cloth_collision_moving_edges ( ClothModifierData *clmd, CollisionModi // if ( !cloth_are_edges_adjacent ( clmd, collmd, &edgecollpair ) ) { // always put coll points in p21/p22 - sub_v3_v3v3 ( x1, verts1[edgecollpair.p12].txold, verts1[edgecollpair.p11].txold ); - sub_v3_v3v3 ( v1, verts1[edgecollpair.p12].tv, verts1[edgecollpair.p11].tv ); + sub_v3_v3v3(x1, verts1[edgecollpair.p12].txold, verts1[edgecollpair.p11].txold); + sub_v3_v3v3(v1, verts1[edgecollpair.p12].tv, verts1[edgecollpair.p11].tv); - sub_v3_v3v3 ( x2, verts2[edgecollpair.p21].co, verts1[edgecollpair.p11].txold ); - sub_v3_v3v3 ( v2, velocity2[edgecollpair.p21].co, verts1[edgecollpair.p11].tv ); + sub_v3_v3v3(x2, verts2[edgecollpair.p21].co, verts1[edgecollpair.p11].txold); + sub_v3_v3v3(v2, velocity2[edgecollpair.p21].co, verts1[edgecollpair.p11].tv); - sub_v3_v3v3 ( x3, verts2[edgecollpair.p22].co, verts1[edgecollpair.p11].txold ); - sub_v3_v3v3 ( v3, velocity2[edgecollpair.p22].co, verts1[edgecollpair.p11].tv ); + sub_v3_v3v3(x3, verts2[edgecollpair.p22].co, verts1[edgecollpair.p11].txold); + sub_v3_v3v3(v3, velocity2[edgecollpair.p22].co, verts1[edgecollpair.p11].tv); numsolutions = cloth_get_collision_time ( x1, v1, x2, v2, x3, v3, solution ); @@ -1987,7 +1987,7 @@ static int cloth_collision_moving_edges ( ClothModifierData *clmd, CollisionModi // printf("sol %d: %lf\n", k, solution[k]); if ( ( solution[k] >= ALMOST_ZERO ) && ( solution[k] <= 1.0 ) && ( solution[k] > ALMOST_ZERO)) { - float a,b; + float a, b; float out_normal[3]; float distance; float impulse = 0; @@ -2260,11 +2260,11 @@ static void cloth_bvh_objcollisions_nearcheck ( ClothModifierData * clmd, Collis static int cloth_bvh_objcollisions_resolve ( ClothModifierData * clmd, CollisionModifierData *collmd, CollPair *collisions, CollPair *collisions_index) { Cloth *cloth = clmd->clothObject; - int i=0, j = 0, /*numfaces = 0,*/ numverts = 0; + int i=0, j = 0, /*numfaces = 0, */ numverts = 0; ClothVertex *verts = NULL; int ret = 0; int result = 0; - float tnull[3] = {0,0,0}; + float tnull[3] = {0, 0, 0}; /*numfaces = clmd->clothObject->numfaces;*/ /*UNUSED*/ numverts = clmd->clothObject->numverts; @@ -2306,7 +2306,7 @@ static int cloth_bvh_objcollisions_resolve ( ClothModifierData * clmd, Collision } // cloth - object collisions -int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, float dt ) +int cloth_bvh_objcollision(Object *ob, ClothModifierData * clmd, float step, float dt ) { Cloth *cloth= clmd->clothObject; BVHTree *cloth_bvh= cloth->bvhtree; @@ -2343,8 +2343,8 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl ret2 = 0; - collisions = MEM_callocN(sizeof(CollPair *) *numcollobj , "CollPair"); - collisions_index = MEM_callocN(sizeof(CollPair *) *numcollobj , "CollPair"); + collisions = MEM_callocN(sizeof(CollPair *) *numcollobj, "CollPair"); + collisions_index = MEM_callocN(sizeof(CollPair *) *numcollobj, "CollPair"); // check all collision objects for (i = 0; i < numcollobj; i++) { @@ -2444,7 +2444,7 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl } } - sub_v3_v3v3 ( temp, verts[i].tx, verts[j].tx ); + sub_v3_v3v3(temp, verts[i].tx, verts[j].tx); if ( ( ABS ( temp[0] ) > mindistance ) || ( ABS ( temp[1] ) > mindistance ) || ( ABS ( temp[2] ) > mindistance ) ) continue; @@ -2453,24 +2453,24 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl continue; } - length = normalize_v3( temp ); + length = normalize_v3(temp ); if ( length < mindistance ) { float correction = mindistance - length; if ( cloth->verts [i].flags & CLOTH_VERT_FLAG_PINNED ) { - mul_v3_fl( temp, -correction ); + mul_v3_fl(temp, -correction); VECADD ( verts[j].tx, verts[j].tx, temp ); } else if ( cloth->verts [j].flags & CLOTH_VERT_FLAG_PINNED ) { - mul_v3_fl( temp, correction ); + mul_v3_fl(temp, correction); VECADD ( verts[i].tx, verts[i].tx, temp ); } else { - mul_v3_fl( temp, correction * -0.5 ); + mul_v3_fl(temp, correction * -0.5); VECADD ( verts[j].tx, verts[j].tx, temp ); - sub_v3_v3v3 ( verts[i].tx, verts[i].tx, temp ); + sub_v3_v3v3(verts[i].tx, verts[i].tx, temp); } ret = 1; ret2 += ret; @@ -2493,7 +2493,7 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl if ( ret2 ) { for ( i = 0; i < cloth->numverts; i++ ) { if ( ! ( verts [i].flags & CLOTH_VERT_FLAG_PINNED ) ) { - sub_v3_v3v3 ( verts[i].tv, verts[i].tx, verts[i].txold ); + sub_v3_v3v3(verts[i].tv, verts[i].tx, verts[i].txold); } } } diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 6dc1b2a4b00..2955e20c9e2 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -318,8 +318,8 @@ void curvemap_sethandle(CurveMap *cuma, int type) /* reduced copy of garbled calchandleNurb() code in curve.c */ static void calchandle_curvemap(BezTriple *bezt, BezTriple *prev, BezTriple *next, int UNUSED(mode)) { - float *p1,*p2,*p3,pt[3]; - float len,len_a, len_b; + float *p1, *p2, *p3, pt[3]; + float len, len_a, len_b; float dvec_a[2], dvec_b[2]; if (bezt->h1==0 && bezt->h2==0) { @@ -1014,7 +1014,7 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) } } else { - rgb_to_ycc(rgb[0],rgb[1],rgb[2],&ycc[0],&ycc[1],&ycc[2], ycc_mode); + rgb_to_ycc(rgb[0], rgb[1], rgb[2], &ycc[0], &ycc[1], &ycc[2], ycc_mode); for (c=0; c<3; c++) { ycc[c] *=INV_255; if (ycc[c] < scopes->minmax[c][0]) scopes->minmax[c][0] = ycc[c]; diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 82a908eaf57..424ded0397e 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -104,7 +104,7 @@ /* -------------- Naming -------------- */ /* Find the first available, non-duplicate name for a given constraint */ -void unique_constraint_name (bConstraint *con, ListBase *list) +void unique_constraint_name(bConstraint *con, ListBase *list) { BLI_uniquename(list, con, "Const", '.', offsetof(bConstraint, name), sizeof(con->name)); } @@ -177,7 +177,7 @@ bConstraintOb *constraints_make_evalob (Scene *scene, Object *ob, void *subdata, } /* cleanup after constraint evaluation */ -void constraints_clear_evalob (bConstraintOb *cob) +void constraints_clear_evalob(bConstraintOb *cob) { float delta[4][4], imat[4][4]; @@ -272,7 +272,7 @@ static void constraint_pchan_diff_mat(bPoseChannel *pchan, float diff_mat[4][4]) * of a matrix from one space to another for constraint evaluation. * For now, this is only implemented for Objects and PoseChannels. */ -void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4], short from, short to) +void constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[][4], short from, short to) { float diff_mat[4][4]; float imat[4][4]; @@ -1333,7 +1333,7 @@ static void followpath_evaluate (bConstraint *con, bConstraintOb *cob, ListBase if ((data->followflag & FOLLOWPATH_RADIUS)==0) { /* XXX - assume that scale correction means that radius will have some scale error in it - Campbell */ float obsize[3]; - mat4_to_size( obsize,cob->matrix); + mat4_to_size(obsize, cob->matrix); if (obsize[0]) mul_v3_fl(cob->matrix[0], size[0] / obsize[0]); if (obsize[1]) @@ -1475,8 +1475,8 @@ static void sizelimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * bSizeLimitConstraint *data = con->data; float obsize[3], size[3]; - mat4_to_size( size,cob->matrix); - mat4_to_size( obsize,cob->matrix); + mat4_to_size(size, cob->matrix); + mat4_to_size(obsize, cob->matrix); if (data->flag & LIMIT_XMIN) { if (size[0] < data->xmin) @@ -2308,7 +2308,7 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * bConstraintTarget *ct= targets->first; if (VALID_CONS_TARGET(ct)) { - float vec[3],vec2[3]; + float vec[3], vec2[3]; float totmat[3][3]; float tmpmat[3][3]; float invmat[3][3]; @@ -2542,9 +2542,9 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * copy_m4_m4(tmat, cob->matrix); - mdet = determinant_m3( totmat[0][0],totmat[0][1],totmat[0][2], - totmat[1][0],totmat[1][1],totmat[1][2], - totmat[2][0],totmat[2][1],totmat[2][2]); + mdet = determinant_m3(totmat[0][0], totmat[0][1], totmat[0][2], + totmat[1][0], totmat[1][1], totmat[1][2], + totmat[2][0], totmat[2][1], totmat[2][2]); if (mdet==0) { unit_m3(totmat); } @@ -3311,7 +3311,7 @@ static void transform_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * /* obtain target effect */ switch (data->from) { case 2: /* scale */ - mat4_to_size( dvec,ct->matrix); + mat4_to_size(dvec, ct->matrix); break; case 1: /* rotation (convert to degrees first) */ mat4_to_eulO(dvec, cob->rotOrder, ct->matrix); @@ -3602,8 +3602,8 @@ static void damptrack_flush_tars (bConstraint *con, ListBase *list, short nocopy /* array of direction vectors for the tracking flags */ static const float track_dir_vecs[6][3] = { - {+1,0,0}, {0,+1,0}, {0,0,+1}, /* TRACK_X, TRACK_Y, TRACK_Z */ - {-1,0,0}, {0,-1,0}, {0,0,-1} /* TRACK_NX, TRACK_NY, TRACK_NZ */ + {+1, 0, 0}, {0, +1, 0}, {0, 0, +1}, /* TRACK_X, TRACK_Y, TRACK_Z */ + {-1, 0, 0}, {0, -1, 0}, {0, 0, -1} /* TRACK_NX, TRACK_NY, TRACK_NZ */ }; static void damptrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) @@ -4012,8 +4012,8 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase add_v2_v2v2(pos, marker->pos, track->offset); - camera_params_init(¶ms); - camera_params_from_object(¶ms, camob); + BKE_camera_params_init(¶ms); + BKE_camera_params_from_object(¶ms, camob); if (params.is_ortho) { vec[0] = params.ortho_scale * (pos[0] - 0.5f + params.shiftx); @@ -4321,7 +4321,7 @@ bConstraintTypeInfo *constraint_get_typeinfo (bConstraint *con) /* Free data of a specific constraint if it has any info. * be sure to run BIK_clear_data() when freeing an IK constraint, * unless DAG_scene_sort is called. */ -void free_constraint_data (bConstraint *con) +void free_constraint_data(bConstraint *con) { if (con->data) { bConstraintTypeInfo *cti= constraint_get_typeinfo(con); @@ -4336,7 +4336,7 @@ void free_constraint_data (bConstraint *con) } /* Free all constraints from a constraint-stack */ -void free_constraints (ListBase *list) +void free_constraints(ListBase *list) { bConstraint *con; @@ -4350,7 +4350,7 @@ void free_constraints (ListBase *list) /* Remove the specified constraint from the given constraint stack */ -int remove_constraint (ListBase *list, bConstraint *con) +int remove_constraint(ListBase *list, bConstraint *con) { if (con) { free_constraint_data(con); @@ -4362,7 +4362,7 @@ int remove_constraint (ListBase *list, bConstraint *con) } /* Remove all the constraints of the specified type from the given constraint stack */ -void remove_constraints_type (ListBase *list, short type, short last_only) +void remove_constraints_type(ListBase *list, short type, short last_only) { bConstraint *con, *conp; @@ -4488,7 +4488,7 @@ bConstraint *add_ob_constraint(Object *ob, const char *name, short type) /* ......... */ /* Reassign links that constraints have to other data (called during file loading?) */ -void relink_constraints (ListBase *conlist) +void relink_constraints(ListBase *conlist) { bConstraint *con; bConstraintTarget *ct; @@ -4518,7 +4518,7 @@ void relink_constraints (ListBase *conlist) } /* Run the given callback on all ID-blocks in list of constraints */ -void id_loop_constraints (ListBase *conlist, ConstraintIDFunc func, void *userdata) +void id_loop_constraints(ListBase *conlist, ConstraintIDFunc func, void *userdata) { bConstraint *con; @@ -4542,7 +4542,7 @@ static void con_extern_cb(bConstraint *UNUSED(con), ID **idpoin, void *UNUSED(us } /* duplicate all of the constraints in a constraint stack */ -void copy_constraints (ListBase *dst, const ListBase *src, int do_extern) +void copy_constraints(ListBase *dst, const ListBase *src, int do_extern) { bConstraint *con, *srccon; @@ -4596,7 +4596,7 @@ bConstraint *constraints_get_active (ListBase *list) } /* Set the given constraint as the active one (clearing all the others) */ -void constraints_set_active (ListBase *list, bConstraint *con) +void constraints_set_active(ListBase *list, bConstraint *con) { bConstraint *c; @@ -4613,7 +4613,7 @@ void constraints_set_active (ListBase *list, bConstraint *con) /* -------- Constraints and Proxies ------- */ /* Rescue all constraints tagged as being CONSTRAINT_PROXY_LOCAL (i.e. added to bone that's proxy-synced in this file) */ -void extract_proxylocal_constraints (ListBase *dst, ListBase *src) +void extract_proxylocal_constraints(ListBase *dst, ListBase *src) { bConstraint *con, *next; @@ -4630,7 +4630,7 @@ void extract_proxylocal_constraints (ListBase *dst, ListBase *src) } /* Returns if the owner of the constraint is proxy-protected */ -short proxylocked_constraints_owner (Object *ob, bPoseChannel *pchan) +short proxylocked_constraints_owner(Object *ob, bPoseChannel *pchan) { /* Currently, constraints can only be on object or bone level */ if (ob && ob->proxy) { @@ -4659,7 +4659,7 @@ short proxylocked_constraints_owner (Object *ob, bPoseChannel *pchan) * None of the actual calculations of the matrices should be done here! Also, this function is * not to be used by any new constraints, particularly any that have multiple targets. */ -void get_constraint_target_matrix (struct Scene *scene, bConstraint *con, int n, short ownertype, void *ownerdata, float mat[][4], float ctime) +void get_constraint_target_matrix(struct Scene *scene, bConstraint *con, int n, short ownertype, void *ownerdata, float mat[][4], float ctime) { bConstraintTypeInfo *cti= constraint_get_typeinfo(con); ListBase targets = {NULL, NULL}; @@ -4728,7 +4728,7 @@ void get_constraint_target_matrix (struct Scene *scene, bConstraint *con, int n, } /* Get the list of targets required for solving a constraint */ -void get_constraint_targets_for_solving (bConstraint *con, bConstraintOb *cob, ListBase *targets, float ctime) +void get_constraint_targets_for_solving(bConstraint *con, bConstraintOb *cob, ListBase *targets, float ctime) { bConstraintTypeInfo *cti= constraint_get_typeinfo(con); @@ -4763,7 +4763,7 @@ void get_constraint_targets_for_solving (bConstraint *con, bConstraintOb *cob, L * constraints_make_evalob and constraints_clear_evalob should be called before and * after running this function, to sort out cob */ -void solve_constraints (ListBase *conlist, bConstraintOb *cob, float ctime) +void solve_constraints(ListBase *conlist, bConstraintOb *cob, float ctime) { bConstraint *con; float oldmat[4][4]; diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index 7a5b4ef9b24..bd47e7cbd37 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -202,6 +202,7 @@ void CTX_store_free_list(ListBase *contexts) } /* is python initialied? */ + int CTX_py_init_get(bContext *C) { return C->data.py_init; @@ -220,237 +221,6 @@ void CTX_py_dict_set(bContext *C, void *value) C->data.py_context= value; } -/* window manager context */ - -wmWindowManager *CTX_wm_manager(const bContext *C) -{ - return C->wm.manager; -} - -wmWindow *CTX_wm_window(const bContext *C) -{ - return C->wm.window; -} - -bScreen *CTX_wm_screen(const bContext *C) -{ - return C->wm.screen; -} - -ScrArea *CTX_wm_area(const bContext *C) -{ - return C->wm.area; -} - -SpaceLink *CTX_wm_space_data(const bContext *C) -{ - return (C->wm.area)? C->wm.area->spacedata.first: NULL; -} - -ARegion *CTX_wm_region(const bContext *C) -{ - return C->wm.region; -} - -void *CTX_wm_region_data(const bContext *C) -{ - return (C->wm.region)? C->wm.region->regiondata: NULL; -} - -struct ARegion *CTX_wm_menu(const bContext *C) -{ - return C->wm.menu; -} - -struct ReportList *CTX_wm_reports(const bContext *C) -{ - if (C->wm.manager) - return &(C->wm.manager->reports); - - return NULL; -} - -View3D *CTX_wm_view3d(const bContext *C) -{ - if (C->wm.area && C->wm.area->spacetype==SPACE_VIEW3D) - return C->wm.area->spacedata.first; - return NULL; -} - -RegionView3D *CTX_wm_region_view3d(const bContext *C) -{ - if (C->wm.area && C->wm.area->spacetype==SPACE_VIEW3D) - if (C->wm.region) - return C->wm.region->regiondata; - return NULL; -} - -struct SpaceText *CTX_wm_space_text(const bContext *C) -{ - if (C->wm.area && C->wm.area->spacetype==SPACE_TEXT) - return C->wm.area->spacedata.first; - return NULL; -} - -struct SpaceConsole *CTX_wm_space_console(const bContext *C) -{ - if (C->wm.area && C->wm.area->spacetype==SPACE_CONSOLE) - return C->wm.area->spacedata.first; - return NULL; -} - -struct SpaceImage *CTX_wm_space_image(const bContext *C) -{ - if (C->wm.area && C->wm.area->spacetype==SPACE_IMAGE) - return C->wm.area->spacedata.first; - return NULL; -} - -struct SpaceButs *CTX_wm_space_buts(const bContext *C) -{ - if (C->wm.area && C->wm.area->spacetype==SPACE_BUTS) - return C->wm.area->spacedata.first; - return NULL; -} - -struct SpaceFile *CTX_wm_space_file(const bContext *C) -{ - if (C->wm.area && C->wm.area->spacetype==SPACE_FILE) - return C->wm.area->spacedata.first; - return NULL; -} - -struct SpaceSeq *CTX_wm_space_seq(const bContext *C) -{ - if (C->wm.area && C->wm.area->spacetype==SPACE_SEQ) - return C->wm.area->spacedata.first; - return NULL; -} - -struct SpaceOops *CTX_wm_space_outliner(const bContext *C) -{ - if (C->wm.area && C->wm.area->spacetype==SPACE_OUTLINER) - return C->wm.area->spacedata.first; - return NULL; -} - -struct SpaceNla *CTX_wm_space_nla(const bContext *C) -{ - if (C->wm.area && C->wm.area->spacetype==SPACE_NLA) - return C->wm.area->spacedata.first; - return NULL; -} - -struct SpaceTime *CTX_wm_space_time(const bContext *C) -{ - if (C->wm.area && C->wm.area->spacetype==SPACE_TIME) - return C->wm.area->spacedata.first; - return NULL; -} - -struct SpaceNode *CTX_wm_space_node(const bContext *C) -{ - if (C->wm.area && C->wm.area->spacetype==SPACE_NODE) - return C->wm.area->spacedata.first; - return NULL; -} - -struct SpaceLogic *CTX_wm_space_logic(const bContext *C) -{ - if (C->wm.area && C->wm.area->spacetype==SPACE_LOGIC) - return C->wm.area->spacedata.first; - return NULL; -} - -struct SpaceIpo *CTX_wm_space_graph(const bContext *C) -{ - if (C->wm.area && C->wm.area->spacetype==SPACE_IPO) - return C->wm.area->spacedata.first; - return NULL; -} - -struct SpaceAction *CTX_wm_space_action(const bContext *C) -{ - if (C->wm.area && C->wm.area->spacetype==SPACE_ACTION) - return C->wm.area->spacedata.first; - return NULL; -} - -struct SpaceInfo *CTX_wm_space_info(const bContext *C) -{ - if (C->wm.area && C->wm.area->spacetype==SPACE_INFO) - return C->wm.area->spacedata.first; - return NULL; -} - -struct SpaceUserPref *CTX_wm_space_userpref(const bContext *C) -{ - if (C->wm.area && C->wm.area->spacetype==SPACE_USERPREF) - return C->wm.area->spacedata.first; - return NULL; -} - -struct SpaceClip *CTX_wm_space_clip(const bContext *C) -{ - if (C->wm.area && C->wm.area->spacetype==SPACE_CLIP) - return C->wm.area->spacedata.first; - return NULL; -} - -void CTX_wm_manager_set(bContext *C, wmWindowManager *wm) -{ - C->wm.manager= wm; - C->wm.window= NULL; - C->wm.screen= NULL; - C->wm.area= NULL; - C->wm.region= NULL; -} - -void CTX_wm_window_set(bContext *C, wmWindow *win) -{ - C->wm.window= win; - C->wm.screen= (win)? win->screen: NULL; - if (C->wm.screen) - C->data.scene= C->wm.screen->scene; - C->wm.area= NULL; - C->wm.region= NULL; -} - -void CTX_wm_screen_set(bContext *C, bScreen *screen) -{ - C->wm.screen= screen; - if (C->wm.screen) - C->data.scene= C->wm.screen->scene; - C->wm.area= NULL; - C->wm.region= NULL; -} - -void CTX_wm_area_set(bContext *C, ScrArea *area) -{ - C->wm.area= area; - C->wm.region= NULL; -} - -void CTX_wm_region_set(bContext *C, ARegion *region) -{ - C->wm.region= region; -} - -void CTX_wm_menu_set(bContext *C, ARegion *menu) -{ - C->wm.menu= menu; -} - -void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg) -{ - C->wm.operator_poll_msg= msg; -} - -const char *CTX_wm_operator_poll_msg_get(bContext *C) -{ - return C->wm.operator_poll_msg; -} - /* data context utility functions */ struct bContextDataResult { @@ -460,8 +230,27 @@ struct bContextDataResult { short type; /* 0: normal, 1: seq */ }; +static void *ctx_wm_python_context_get(const bContext *C, const char *member, void *fall_through) +{ +#ifdef WITH_PYTHON + bContextDataResult result; + + if (C && CTX_py_dict_get(C)) { + memset(&result, 0, sizeof(bContextDataResult)); + BPY_context_member_get((bContext*)C, member, &result); + if(result.ptr.data) + return result.ptr.data; + } +#endif + + return fall_through; +} + static int ctx_data_get(bContext *C, const char *member, bContextDataResult *result) { + bScreen *sc; + ScrArea *sa; + ARegion *ar; int done= 0, recursion= C->data.recursion; int ret= 0; @@ -493,23 +282,23 @@ static int ctx_data_get(bContext *C, const char *member, bContextDataResult *res done= 1; } } - if (done!=1 && recursion < 2 && C->wm.region) { + if (done!=1 && recursion < 2 && (ar=CTX_wm_region(C))) { C->data.recursion= 2; - if (C->wm.region->type && C->wm.region->type->context) { - ret = C->wm.region->type->context(C, member, result); + if (ar->type && ar->type->context) { + ret = ar->type->context(C, member, result); if (ret) done= -(-ret | -done); } } - if (done!=1 && recursion < 3 && C->wm.area) { + if (done!=1 && recursion < 3 && (sa=CTX_wm_area(C))) { C->data.recursion= 3; - if (C->wm.area->type && C->wm.area->type->context) { - ret = C->wm.area->type->context(C, member, result); + if (sa->type && sa->type->context) { + ret = sa->type->context(C, member, result); if (ret) done= -(-ret | -done); } } - if (done!=1 && recursion < 4 && C->wm.screen) { - bContextDataCallback cb= C->wm.screen->context; + if (done!=1 && recursion < 4 && (sc=CTX_wm_screen(C))) { + bContextDataCallback cb= sc->context; C->data.recursion= 4; if (cb) { ret = cb(C, member, result); @@ -638,6 +427,9 @@ ListBase CTX_data_dir_get(const bContext *C) { bContextDataResult result; ListBase lb; + bScreen *sc; + ScrArea *sa; + ARegion *ar; int a; memset(&lb, 0, sizeof(lb)); @@ -648,24 +440,24 @@ ListBase CTX_data_dir_get(const bContext *C) for (entry=C->wm.store->entries.first; entry; entry=entry->next) data_dir_add(&lb, entry->name); } - if (C->wm.region && C->wm.region->type && C->wm.region->type->context) { + if ((ar=CTX_wm_region(C)) && ar->type && ar->type->context) { memset(&result, 0, sizeof(result)); - C->wm.region->type->context(C, "", &result); + ar->type->context(C, "", &result); if (result.dir) for (a=0; result.dir[a]; a++) data_dir_add(&lb, result.dir[a]); } - if (C->wm.area && C->wm.area->type && C->wm.area->type->context) { + if ((sa=CTX_wm_area(C)) && sa->type && sa->type->context) { memset(&result, 0, sizeof(result)); - C->wm.area->type->context(C, "", &result); + sa->type->context(C, "", &result); if (result.dir) for (a=0; result.dir[a]; a++) data_dir_add(&lb, result.dir[a]); } - if (C->wm.screen && C->wm.screen->context) { - bContextDataCallback cb= C->wm.screen->context; + if ((sc=CTX_wm_screen(C)) && sc->context) { + bContextDataCallback cb= sc->context; memset(&result, 0, sizeof(result)); cb(C, "", &result); @@ -745,6 +537,261 @@ short CTX_data_type_get(bContextDataResult *result) return result->type; } + + +/* window manager context */ + +wmWindowManager *CTX_wm_manager(const bContext *C) +{ + return C->wm.manager; +} + +wmWindow *CTX_wm_window(const bContext *C) +{ + return ctx_wm_python_context_get(C, "window", C->wm.window); +} + +bScreen *CTX_wm_screen(const bContext *C) +{ + return ctx_wm_python_context_get(C, "screen", C->wm.screen); +} + +ScrArea *CTX_wm_area(const bContext *C) +{ + return ctx_wm_python_context_get(C, "area", C->wm.area); +} + +SpaceLink *CTX_wm_space_data(const bContext *C) +{ + ScrArea *sa = CTX_wm_area(C); + return (sa)? sa->spacedata.first: NULL; +} + +ARegion *CTX_wm_region(const bContext *C) +{ + return ctx_wm_python_context_get(C, "region", C->wm.region); +} + +void *CTX_wm_region_data(const bContext *C) +{ + ARegion *ar = CTX_wm_region(C); + return (ar)? ar->regiondata: NULL; +} + +struct ARegion *CTX_wm_menu(const bContext *C) +{ + return C->wm.menu; +} + +struct ReportList *CTX_wm_reports(const bContext *C) +{ + if (C->wm.manager) + return &(C->wm.manager->reports); + + return NULL; +} + +View3D *CTX_wm_view3d(const bContext *C) +{ + ScrArea *sa = CTX_wm_area(C); + if (sa && sa->spacetype==SPACE_VIEW3D) + return sa->spacedata.first; + return NULL; +} + +RegionView3D *CTX_wm_region_view3d(const bContext *C) +{ + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + + if (sa && sa->spacetype==SPACE_VIEW3D) + if (ar) + return ar->regiondata; + return NULL; +} + +struct SpaceText *CTX_wm_space_text(const bContext *C) +{ + ScrArea *sa = CTX_wm_area(C); + if (sa && sa->spacetype==SPACE_TEXT) + return sa->spacedata.first; + return NULL; +} + +struct SpaceConsole *CTX_wm_space_console(const bContext *C) +{ + ScrArea *sa = CTX_wm_area(C); + if (sa && sa->spacetype==SPACE_CONSOLE) + return sa->spacedata.first; + return NULL; +} + +struct SpaceImage *CTX_wm_space_image(const bContext *C) +{ + ScrArea *sa = CTX_wm_area(C); + if (sa && sa->spacetype==SPACE_IMAGE) + return sa->spacedata.first; + return NULL; +} + +struct SpaceButs *CTX_wm_space_buts(const bContext *C) +{ + ScrArea *sa = CTX_wm_area(C); + if (sa && sa->spacetype==SPACE_BUTS) + return sa->spacedata.first; + return NULL; +} + +struct SpaceFile *CTX_wm_space_file(const bContext *C) +{ + ScrArea *sa = CTX_wm_area(C); + if (sa && sa->spacetype==SPACE_FILE) + return sa->spacedata.first; + return NULL; +} + +struct SpaceSeq *CTX_wm_space_seq(const bContext *C) +{ + ScrArea *sa = CTX_wm_area(C); + if (sa && sa->spacetype==SPACE_SEQ) + return sa->spacedata.first; + return NULL; +} + +struct SpaceOops *CTX_wm_space_outliner(const bContext *C) +{ + ScrArea *sa = CTX_wm_area(C); + if (sa && sa->spacetype==SPACE_OUTLINER) + return sa->spacedata.first; + return NULL; +} + +struct SpaceNla *CTX_wm_space_nla(const bContext *C) +{ + ScrArea *sa = CTX_wm_area(C); + if (sa && sa->spacetype==SPACE_NLA) + return sa->spacedata.first; + return NULL; +} + +struct SpaceTime *CTX_wm_space_time(const bContext *C) +{ + ScrArea *sa = CTX_wm_area(C); + if (sa && sa->spacetype==SPACE_TIME) + return sa->spacedata.first; + return NULL; +} + +struct SpaceNode *CTX_wm_space_node(const bContext *C) +{ + ScrArea *sa = CTX_wm_area(C); + if (sa && sa->spacetype==SPACE_NODE) + return sa->spacedata.first; + return NULL; +} + +struct SpaceLogic *CTX_wm_space_logic(const bContext *C) +{ + ScrArea *sa = CTX_wm_area(C); + if (sa && sa->spacetype==SPACE_LOGIC) + return sa->spacedata.first; + return NULL; +} + +struct SpaceIpo *CTX_wm_space_graph(const bContext *C) +{ + ScrArea *sa = CTX_wm_area(C); + if (sa && sa->spacetype==SPACE_IPO) + return sa->spacedata.first; + return NULL; +} + +struct SpaceAction *CTX_wm_space_action(const bContext *C) +{ + ScrArea *sa = CTX_wm_area(C); + if (sa && sa->spacetype==SPACE_ACTION) + return sa->spacedata.first; + return NULL; +} + +struct SpaceInfo *CTX_wm_space_info(const bContext *C) +{ + ScrArea *sa = CTX_wm_area(C); + if (sa && sa->spacetype==SPACE_INFO) + return sa->spacedata.first; + return NULL; +} + +struct SpaceUserPref *CTX_wm_space_userpref(const bContext *C) +{ + ScrArea *sa = CTX_wm_area(C); + if (sa && sa->spacetype==SPACE_USERPREF) + return sa->spacedata.first; + return NULL; +} + +struct SpaceClip *CTX_wm_space_clip(const bContext *C) +{ + ScrArea *sa = CTX_wm_area(C); + if (sa && sa->spacetype==SPACE_CLIP) + return sa->spacedata.first; + return NULL; +} + +void CTX_wm_manager_set(bContext *C, wmWindowManager *wm) +{ + C->wm.manager= wm; + C->wm.window= NULL; + C->wm.screen= NULL; + C->wm.area= NULL; + C->wm.region= NULL; +} + +void CTX_wm_window_set(bContext *C, wmWindow *win) +{ + C->wm.window= win; + C->wm.screen= (win)? win->screen: NULL; + if (C->wm.screen) + C->data.scene= C->wm.screen->scene; + C->wm.area= NULL; + C->wm.region= NULL; +} + +void CTX_wm_screen_set(bContext *C, bScreen *screen) +{ + C->wm.screen= screen; + if (C->wm.screen) + C->data.scene= C->wm.screen->scene; + C->wm.area= NULL; + C->wm.region= NULL; +} + +void CTX_wm_area_set(bContext *C, ScrArea *area) +{ + C->wm.area= area; + C->wm.region= NULL; +} + +void CTX_wm_region_set(bContext *C, ARegion *region) +{ + C->wm.region= region; +} + +void CTX_wm_menu_set(bContext *C, ARegion *menu) +{ + C->wm.menu= menu; +} + +void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg) +{ + C->wm.operator_poll_msg= msg; +} + +const char *CTX_wm_operator_poll_msg_get(bContext *C) +{ + return C->wm.operator_poll_msg; +} + /* data context */ Main *CTX_data_main(const bContext *C) diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index e0cadac586b..85e3d85dfc4 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -121,7 +121,7 @@ void BKE_curve_editNurb_keyIndex_free(EditNurb *editnurb) editnurb->keyindex= NULL; } -void BKE_curve_editNurb_free (Curve *cu) +void BKE_curve_editNurb_free(Curve *cu) { if (cu->editnurb) { BKE_nurbList_free(&cu->editnurb->nurbs); @@ -169,6 +169,8 @@ Curve *BKE_curve_add(const char *name, int type) cu->smallcaps_scale= 0.75f; cu->twist_mode= CU_TWIST_MINIMUM; // XXX: this one seems to be the best one in most cases, at least for curve deform... cu->type= type; + cu->bevfac1= 0.0f; + cu->bevfac2= 1.0f; cu->bb= unit_boundbox(); @@ -194,7 +196,7 @@ Curve *BKE_curve_copy(Curve *cu) cun= copy_libblock(&cu->id); cun->nurb.first= cun->nurb.last= NULL; - BKE_nurbList_duplicate( &(cun->nurb), &(cu->nurb)); + BKE_nurbList_duplicate(&(cun->nurb), &(cu->nurb)); cun->mat= MEM_dupallocN(cu->mat); for (a=0; a<cun->totcol; a++) { @@ -480,19 +482,19 @@ Nurb *BKE_nurb_duplicate(Nurb *nu) Nurb *newnu; int len; - newnu= (Nurb*)MEM_mallocN(sizeof(Nurb),"duplicateNurb"); + newnu= (Nurb*)MEM_mallocN(sizeof(Nurb), "duplicateNurb"); if (newnu==NULL) return NULL; memcpy(newnu, nu, sizeof(Nurb)); if (nu->bezt) { newnu->bezt= - (BezTriple*)MEM_mallocN((nu->pntsu)* sizeof(BezTriple),"duplicateNurb2"); + (BezTriple*)MEM_mallocN((nu->pntsu)* sizeof(BezTriple), "duplicateNurb2"); memcpy(newnu->bezt, nu->bezt, nu->pntsu*sizeof(BezTriple)); } else { len= nu->pntsu*nu->pntsv; newnu->bp= - (BPoint*)MEM_mallocN((len)* sizeof(BPoint),"duplicateNurb3"); + (BPoint*)MEM_mallocN((len)* sizeof(BPoint), "duplicateNurb3"); memcpy(newnu->bp, nu->bp, len*sizeof(BPoint)); newnu->knotsu= newnu->knotsv= NULL; @@ -749,7 +751,7 @@ void BKE_nurb_knot_calc_v(Nurb *nu) static void basisNurb(float t, short order, short pnts, float *knots, float *basis, int *start, int *end) { float d, e; - int i, i1 = 0, i2 = 0 ,j, orderpluspnts, opp2, o2; + int i, i1 = 0, i2 = 0, j, orderpluspnts, opp2, o2; orderpluspnts= order+pnts; opp2 = orderpluspnts-1; @@ -777,7 +779,7 @@ static void basisNurb(float t, short order, short pnts, float *knots, float *bas } basis[i]= 0.0; - /* this is order 2,3,... */ + /* this is order 2, 3, ... */ for (j=2; j<=order; j++) { if (i2+j>= orderpluspnts) i2= opp2-j; @@ -870,7 +872,7 @@ void BKE_nurb_makeFaces(Nurb *nu, float *coord_array, int rowstride, int resolu, jstart= (int *)MEM_mallocN(sizeof(float)*totv, "makeNurbfaces4"); jend= (int *)MEM_mallocN(sizeof(float)*totv, "makeNurbfaces5"); - /* precalculation of basisv and jstart,jend */ + /* precalculation of basisv and jstart, jend */ if (nu->flagv & CU_NURB_CYCLIC) cycl= nu->orderv-1; else cycl= 0; v= vstart; @@ -1076,7 +1078,7 @@ void BKE_nurb_makeCurve(Nurb *nu, float *coord_array, float *tilt_array, float * /* forward differencing method for bezier curve */ void BKE_curve_forward_diff_bezier(float q0, float q1, float q2, float q3, float *p, int it, int stride) { - float rt0,rt1,rt2,rt3,f; + float rt0, rt1, rt2, rt3, f; int a; f= (float)it; @@ -1281,7 +1283,7 @@ float *BKE_curve_make_orco(Scene *scene, Object *ob) } for (u=0; u<sizev; u++) { - for (v=0; v<sizeu; v++,fp+=3) { + for (v=0; v<sizeu; v++, fp+=3) { if (cu->flag & CU_UV_ORCO) { fp[0]= 2.0f*u/(sizev - 1) - 1.0f; fp[1]= 2.0f*v/(sizeu - 1) - 1.0f; @@ -1544,13 +1546,13 @@ static int cu_isectLL(const float v1[3], const float v2[3], const float v3[3], c } -static short bevelinside(BevList *bl1,BevList *bl2) +static short bevelinside(BevList *bl1, BevList *bl2) { /* is bl2 INSIDE bl1 ? with left-right method and "labda's" */ /* returns '1' if correct hole */ BevPoint *bevp, *prevbevp; - float min,max,vec[3],hvec1[3],hvec2[3],lab,mu; - int nr, links=0,rechts=0,mode; + float min, max, vec[3], hvec1[3], hvec2[3], lab, mu; + int nr, links=0, rechts=0, mode; /* take first vertex of possible hole */ @@ -1558,7 +1560,7 @@ static short bevelinside(BevList *bl1,BevList *bl2) hvec1[0]= bevp->vec[0]; hvec1[1]= bevp->vec[1]; hvec1[2]= 0.0; - copy_v3_v3(hvec2,hvec1); + copy_v3_v3(hvec2, hvec1); hvec2[0]+=1000; /* test it with all edges of potential surounding poly */ @@ -1605,7 +1607,7 @@ struct bevelsort { static int vergxcobev(const void *a1, const void *a2) { - const struct bevelsort *x1=a1,*x2=a2; + const struct bevelsort *x1=a1, *x2=a2; if ( x1->left > x2->left ) return 1; else if ( x1->left < x2->left) return -1; @@ -1837,7 +1839,7 @@ static void bevel_list_smooth(BevList *bl, int smooth_iter) while (nr--) { /* interpolate quats */ - float zaxis[3] = {0,0,1}, cross[3], q2[4]; + float zaxis[3] = {0, 0, 1}, cross[3], q2[4]; interp_qt_qtqt(q, bevp0_quat, bevp2->quat, 0.5); normalize_qt(q); @@ -1872,7 +1874,7 @@ static void make_bevel_list_3D_zup(BevList *bl) while (nr--) { /* totally simple */ bisect_v3_v3v3v3(bevp1->dir, bevp0->vec, bevp1->vec, bevp2->vec); - vec_to_quat( bevp1->quat,bevp1->dir, 5, 1); + vec_to_quat(bevp1->quat, bevp1->dir, 5, 1); bevp0= bevp1; bevp1= bevp2; @@ -1896,7 +1898,7 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl) while (nr--) { if (nr+4 > bl->nr) { /* first time and second time, otherwise first point adjusts last */ - vec_to_quat( bevp1->quat,bevp1->dir, 5, 1); + vec_to_quat(bevp1->quat, bevp1->dir, 5, 1); } else { float angle= angle_normalized_v3v3(bevp0->dir, bevp1->dir); @@ -1930,7 +1932,7 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl) * * this is why we compare last with second last * */ - float vec_1[3]= {0,1,0}, vec_2[3]= {0,1,0}, angle, ang_fac, cross_tmp[3]; + float vec_1[3]= {0, 1, 0}, vec_2[3]= {0, 1, 0}, angle, ang_fac, cross_tmp[3]; BevPoint *bevp_first; BevPoint *bevp_last; @@ -2024,11 +2026,11 @@ static void make_bevel_list_3D_tangent(BevList *bl) /* make perpendicular, modify tan in place, is ok */ float cross_tmp[3]; - float zero[3] = {0,0,0}; + float zero[3] = {0, 0, 0}; cross_v3_v3v3(cross_tmp, bevp1->tan, bevp1->dir); normalize_v3(cross_tmp); - tri_to_quat( bevp1->quat,zero, cross_tmp, bevp1->tan); /* XXX - could be faster */ + tri_to_quat(bevp1->quat, zero, cross_tmp, bevp1->tan); /* XXX - could be faster */ /* bevp0= bevp1; */ /* UNUSED */ bevp1= bevp2; @@ -2072,7 +2074,7 @@ static void make_bevel_list_segment_3D(BevList *bl) sub_v3_v3v3(bevp1->dir, bevp1->vec, bevp2->vec); normalize_v3(bevp1->dir); - vec_to_quat( bevp1->quat,bevp1->dir, 5, 1); + vec_to_quat(bevp1->quat, bevp1->dir, 5, 1); axis_angle_to_quat(q, bevp1->dir, bevp1->alfa); mul_qt_qtqt(bevp1->quat, q, bevp1->quat); @@ -2201,24 +2203,23 @@ void BKE_curve_bevelList_make(Object *ob) /* BevPoint must stay aligned to 4 so sizeof(BevPoint)/sizeof(float) works */ for (j=0; j<3; j++) { - BKE_curve_forward_diff_bezier( prevbezt->vec[1][j], prevbezt->vec[2][j], - bezt->vec[0][j], bezt->vec[1][j], - &(bevp->vec[j]), resolu, sizeof(BevPoint)); + BKE_curve_forward_diff_bezier(prevbezt->vec[1][j], prevbezt->vec[2][j], + bezt->vec[0][j], bezt->vec[1][j], + &(bevp->vec[j]), resolu, sizeof(BevPoint)); } /* if both arrays are NULL do nothiong */ - alfa_bezpart( prevbezt, bezt, nu, - do_tilt ? &bevp->alfa : NULL, - do_radius ? &bevp->radius : NULL, - do_weight ? &bevp->weight : NULL, - resolu, sizeof(BevPoint)); + alfa_bezpart(prevbezt, bezt, nu, + do_tilt ? &bevp->alfa : NULL, + do_radius ? &bevp->radius : NULL, + do_weight ? &bevp->weight : NULL, + resolu, sizeof(BevPoint)); if (cu->twist_mode==CU_TWIST_TANGENT) { - forward_diff_bezier_cotangent( - prevbezt->vec[1], prevbezt->vec[2], - bezt->vec[0], bezt->vec[1], - bevp->tan, resolu, sizeof(BevPoint)); + forward_diff_bezier_cotangent(prevbezt->vec[1], prevbezt->vec[2], + bezt->vec[0], bezt->vec[1], + bevp->tan, resolu, sizeof(BevPoint)); } /* indicate with handlecodes double points */ @@ -2256,11 +2257,11 @@ void BKE_curve_bevelList_make(Object *ob) else bl->poly= -1; bevp= (BevPoint *)(bl+1); - BKE_nurb_makeCurve( nu, &bevp->vec[0], - do_tilt ? &bevp->alfa : NULL, - do_radius ? &bevp->radius : NULL, - do_weight ? &bevp->weight : NULL, - resolu, sizeof(BevPoint)); + BKE_nurb_makeCurve(nu, &bevp->vec[0], + do_tilt ? &bevp->alfa : NULL, + do_radius ? &bevp->radius : NULL, + do_weight ? &bevp->weight : NULL, + resolu, sizeof(BevPoint)); } } } @@ -2299,7 +2300,7 @@ void BKE_curve_bevelList_make(Object *ob) memcpy(blnew, bl, sizeof(BevList)); blnew->nr= 0; BLI_remlink(&(cu->bev), bl); - BLI_insertlinkbefore(&(cu->bev),blnext,blnew); /* to make sure bevlijst is tuned with nurblist */ + BLI_insertlinkbefore(&(cu->bev), blnext, blnew); /* to make sure bevlijst is tuned with nurblist */ bevp0= (BevPoint *)(bl+1); bevp1= (BevPoint *)(blnew+1); nr= bl->nr; @@ -2367,7 +2368,7 @@ void BKE_curve_bevelList_make(Object *ob) bl= bl->next; } - qsort(sortdata,poly,sizeof(struct bevelsort), vergxcobev); + qsort(sortdata, poly, sizeof(struct bevelsort), vergxcobev); sd= sortdata+1; for (a=1; a<poly; a++, sd++) { @@ -2442,7 +2443,7 @@ void BKE_curve_bevelList_make(Object *ob) /* from: make_bevel_list_3D_zup, could call but avoid a second loop. * no need for tricky tilt calculation as with 3D curves */ bisect_v3_v3v3v3(bevp1->dir, bevp0->vec, bevp1->vec, bevp2->vec); - vec_to_quat( bevp1->quat,bevp1->dir, 5, 1); + vec_to_quat(bevp1->quat, bevp1->dir, 5, 1); /* done with inline make_bevel_list_3D_zup */ bevp0= bevp1; @@ -2497,7 +2498,7 @@ void BKE_curve_bevelList_make(Object *ob) /* mode: is not zero when FCurve, is 2 when forced horizontal for autohandles */ static void calchandleNurb_intern(BezTriple *bezt, BezTriple *prev, BezTriple *next, int mode, int skip_align) { - float *p1,*p2,*p3, pt[3]; + float *p1, *p2, *p3, pt[3]; float dvec_a[3], dvec_b[3]; float len, len_a, len_b; const float eps= 1e-5; @@ -2545,7 +2546,7 @@ static void calchandleNurb_intern(BezTriple *bezt, BezTriple *prev, BezTriple *n if (len_b==0.0f) len_b=1.0f; - if (ELEM(bezt->h1,HD_AUTO,HD_AUTO_ANIM) || ELEM(bezt->h2,HD_AUTO,HD_AUTO_ANIM)) { /* auto */ + if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM) || ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM)) { /* auto */ float tvec[3]; tvec[0]= dvec_b[0]/len_b + dvec_a[0]/len_a; tvec[1]= dvec_b[1]/len_b + dvec_a[1]/len_a; @@ -2558,7 +2559,7 @@ static void calchandleNurb_intern(BezTriple *bezt, BezTriple *prev, BezTriple *n if (len_a>5.0f*len_b) len_a= 5.0f*len_b; if (len_b>5.0f*len_a) len_b= 5.0f*len_a; - if (ELEM(bezt->h1,HD_AUTO,HD_AUTO_ANIM)) { + if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM)) { len_a/=len; madd_v3_v3v3fl(p2-3, p2, tvec, -len_a); @@ -2584,7 +2585,7 @@ static void calchandleNurb_intern(BezTriple *bezt, BezTriple *prev, BezTriple *n } } } - if (ELEM(bezt->h2,HD_AUTO,HD_AUTO_ANIM)) { + if (ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM)) { len_b/=len; madd_v3_v3v3fl(p2+3, p2, tvec, len_b); @@ -2795,7 +2796,7 @@ void BKE_nurb_handles_autocalc(Nurb *nu, int flag) if (flag==0 || (bezt1->f1 & flag) ) { bezt1->h1= 0; /* distance too short: vectorhandle */ - if ( len_v3v3( bezt1->vec[1], bezt0->vec[1] ) < 0.0001f) { + if (len_v3v3(bezt1->vec[1], bezt0->vec[1]) < 0.0001f) { bezt1->h1= HD_VECT; leftsmall= 1; } @@ -2815,7 +2816,7 @@ void BKE_nurb_handles_autocalc(Nurb *nu, int flag) if (flag==0 || (bezt1->f3 & flag) ) { bezt1->h2= 0; /* distance too short: vectorhandle */ - if ( len_v3v3( bezt1->vec[1], bezt2->vec[1] ) < 0.0001f) { + if (len_v3v3(bezt1->vec[1], bezt2->vec[1]) < 0.0001f) { bezt1->h2= HD_VECT; rightsmall= 1; } @@ -3075,7 +3076,7 @@ float (*BKE_curve_vertexCos_get(Curve *UNUSED(cu), ListBase *lb, int *numVerts_r if (nu->type == CU_BEZIER) { BezTriple *bezt = nu->bezt; - for (i=0; i<nu->pntsu; i++,bezt++) { + for (i=0; i<nu->pntsu; i++, bezt++) { copy_v3_v3(co, bezt->vec[0]); co+=3; copy_v3_v3(co, bezt->vec[1]); co+=3; copy_v3_v3(co, bezt->vec[2]); co+=3; @@ -3084,7 +3085,7 @@ float (*BKE_curve_vertexCos_get(Curve *UNUSED(cu), ListBase *lb, int *numVerts_r else { BPoint *bp = nu->bp; - for (i=0; i<nu->pntsu*nu->pntsv; i++,bp++) { + for (i=0; i<nu->pntsu*nu->pntsv; i++, bp++) { copy_v3_v3(co, bp->vec); co+=3; } } @@ -3103,7 +3104,7 @@ void BK_curve_vertexCos_apply(Curve *UNUSED(cu), ListBase *lb, float (*vertexCos if (nu->type == CU_BEZIER) { BezTriple *bezt = nu->bezt; - for (i=0; i<nu->pntsu; i++,bezt++) { + for (i=0; i<nu->pntsu; i++, bezt++) { copy_v3_v3(bezt->vec[0], co); co+=3; copy_v3_v3(bezt->vec[1], co); co+=3; copy_v3_v3(bezt->vec[2], co); co+=3; @@ -3112,7 +3113,7 @@ void BK_curve_vertexCos_apply(Curve *UNUSED(cu), ListBase *lb, float (*vertexCos else { BPoint *bp = nu->bp; - for (i=0; i<nu->pntsu*nu->pntsv; i++,bp++) { + for (i=0; i<nu->pntsu*nu->pntsv; i++, bp++) { copy_v3_v3(bp->vec, co); co+=3; } } @@ -3132,7 +3133,7 @@ float (*BKE_curve_keyVertexCos_get(Curve *UNUSED(cu), ListBase *lb, float *key)) if (nu->type == CU_BEZIER) { BezTriple *bezt = nu->bezt; - for (i=0; i<nu->pntsu; i++,bezt++) { + for (i=0; i<nu->pntsu; i++, bezt++) { copy_v3_v3(co, key); co+=3; key+=3; copy_v3_v3(co, key); co+=3; key+=3; copy_v3_v3(co, key); co+=3; key+=3; @@ -3142,7 +3143,7 @@ float (*BKE_curve_keyVertexCos_get(Curve *UNUSED(cu), ListBase *lb, float *key)) else { BPoint *bp = nu->bp; - for (i=0; i<nu->pntsu*nu->pntsv; i++,bp++) { + for (i=0; i<nu->pntsu*nu->pntsv; i++, bp++) { copy_v3_v3(co, key); co+=3; key+=3; key++; /* skip tilt */ } @@ -3161,7 +3162,7 @@ void BKE_curve_keyVertexTilts_apply(Curve *UNUSED(cu), ListBase *lb, float *key) if (nu->type == CU_BEZIER) { BezTriple *bezt = nu->bezt; - for (i=0; i<nu->pntsu; i++,bezt++) { + for (i=0; i<nu->pntsu; i++, bezt++) { key+=3*3; bezt->alfa= *key; key+=3; @@ -3170,7 +3171,7 @@ void BKE_curve_keyVertexTilts_apply(Curve *UNUSED(cu), ListBase *lb, float *key) else { BPoint *bp = nu->bp; - for (i=0; i<nu->pntsu*nu->pntsv; i++,bp++) { + for (i=0; i<nu->pntsu*nu->pntsv; i++, bp++) { key+=3; bp->alfa= *key; key++; @@ -3179,7 +3180,7 @@ void BKE_curve_keyVertexTilts_apply(Curve *UNUSED(cu), ListBase *lb, float *key) } } -int BKE_nurb_check_valid_u( struct Nurb *nu ) +int BKE_nurb_check_valid_u(struct Nurb *nu) { if (nu==NULL) return 0; if (nu->pntsu <= 1) return 0; @@ -3194,7 +3195,7 @@ int BKE_nurb_check_valid_u( struct Nurb *nu ) } return 1; } -int BKE_nurb_check_valid_v( struct Nurb *nu) +int BKE_nurb_check_valid_v(struct Nurb *nu) { if (nu==NULL) return 0; if (nu->pntsv <= 1) return 0; @@ -3210,7 +3211,7 @@ int BKE_nurb_check_valid_v( struct Nurb *nu) return 1; } -int BKE_nurb_order_clamp_u( struct Nurb *nu ) +int BKE_nurb_order_clamp_u(struct Nurb *nu) { int change = 0; if (nu->pntsu<nu->orderu) { @@ -3218,13 +3219,13 @@ int BKE_nurb_order_clamp_u( struct Nurb *nu ) change= 1; } if (((nu->flagu & CU_NURB_CYCLIC)==0) && (nu->flagu & CU_NURB_BEZIER)) { - CLAMP(nu->orderu, 3,4); + CLAMP(nu->orderu, 3, 4); change= 1; } return change; } -int BKE_nurb_order_clamp_v( struct Nurb *nu) +int BKE_nurb_order_clamp_v(struct Nurb *nu) { int change = 0; if (nu->pntsv<nu->orderv) { @@ -3232,7 +3233,7 @@ int BKE_nurb_order_clamp_v( struct Nurb *nu) change= 1; } if (((nu->flagv & CU_NURB_CYCLIC)==0) && (nu->flagv & CU_NURB_BEZIER)) { - CLAMP(nu->orderv, 3,4); + CLAMP(nu->orderv, 3, 4); change= 1; } return change; diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index ee8e57d5a3e..e32182ed36e 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -71,7 +71,11 @@ typedef struct LayerTypeInfo { int size; /* the memory size of one element of this layer's data */ const char *structname; /* name of the struct used, for file writing */ int structnum; /* number of structs per element, for file writing */ - const char *defaultname; /* default layer name */ + + /* default layer name. + * note! when NULL this is a way to ensure there is only ever one item + * see: CustomData_layertype_is_singleton() */ + const char *defaultname; /* a function to copy count elements of this layer's data * (deep copy if appropriate) @@ -582,7 +586,7 @@ static int layerEqual_mloopcol(void *data1, void *data2) b = m1->b - m2->b; a = m1->a - m2->a; - return r*r + g*g + b*b + a*a < 0.001; + return r * r + g * g + b * b + a * a < 0.001f; } static void layerMultiply_mloopcol(void *data, float fac) @@ -638,7 +642,7 @@ static void layerInitMinMax_mloopcol(void *vmin, void *vmax) static void layerDefault_mloopcol(void *data, int count) { - MLoopCol default_mloopcol = {255,255,255,255}; + MLoopCol default_mloopcol = {255, 255, 255, 255}; MLoopCol *mlcol = (MLoopCol*)data; int i; for (i = 0; i < count; i++) @@ -986,11 +990,11 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { /* 9: CD_POLYINDEX */ {sizeof(int), "MIntProperty", 1, NULL, NULL, NULL, NULL, NULL, NULL}, /* 10: CD_PROP_FLT */ - {sizeof(MFloatProperty), "MFloatProperty",1,"Float", layerCopy_propFloat,NULL,NULL,NULL}, + {sizeof(MFloatProperty), "MFloatProperty", 1, "Float", layerCopy_propFloat, NULL, NULL, NULL}, /* 11: CD_PROP_INT */ - {sizeof(MIntProperty), "MIntProperty",1,"Int",layerCopy_propInt,NULL,NULL,NULL}, + {sizeof(MIntProperty), "MIntProperty", 1, "Int", layerCopy_propInt, NULL, NULL, NULL}, /* 12: CD_PROP_STR */ - {sizeof(MStringProperty), "MStringProperty",1,"String",layerCopy_propString,NULL,NULL,NULL}, + {sizeof(MStringProperty), "MStringProperty", 1, "String", layerCopy_propString, NULL, NULL, NULL}, /* 13: CD_ORIGSPACE */ {sizeof(OrigSpaceFace), "OrigSpaceFace", 1, "UVMap", layerCopy_origspace_face, NULL, layerInterp_origspace_face, layerSwap_origspace_face, layerDefault_origspace_face}, @@ -1026,10 +1030,9 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { /* 23: CD_CLOTH_ORCO */ {sizeof(float)*3, "", 0, NULL, NULL, NULL, NULL, NULL, NULL}, /* 24: CD_RECAST */ - {sizeof(MRecast), "MRecast", 1,"Recast",NULL,NULL,NULL,NULL} + {sizeof(MRecast), "MRecast", 1, "Recast", NULL, NULL, NULL, NULL}, /* BMESH ONLY */ - , /* 25: CD_MPOLY */ {sizeof(MPoly), "MPoly", 1, "NGon Face", NULL, NULL, NULL, NULL, NULL}, /* 26: CD_MLOOP */ @@ -1042,7 +1045,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { {sizeof(float), "", 0, "BevelWeight", NULL, NULL, layerInterp_bweight}, /* 30: CD_CREASE */ {sizeof(float), "", 0, "SubSurfCrease", NULL, NULL, layerInterp_bweight}, - /* 31: CD_ORIGSPACE_MLOOP */ + /* 31: CD_ORIGSPACE_MLOOP */ {sizeof(OrigSpaceLoop), "OrigSpaceLoop", 1, "OS Loop", NULL, NULL, layerInterp_mloop_origspace, NULL, NULL, layerEqual_mloop_origspace, layerMultiply_mloop_origspace, layerInitMinMax_mloop_origspace, layerAdd_mloop_origspace, layerDoMinMax_mloop_origspace, layerCopyValue_mloop_origspace}, @@ -1064,12 +1067,11 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { static const char *LAYERTYPENAMES[CD_NUMTYPES] = { /* 0-4 */ "CDMVert", "CDMSticky", "CDMDeformVert", "CDMEdge", "CDMFace", /* 5-9 */ "CDMTFace", "CDMCol", "CDOrigIndex", "CDNormal", "CDFlags", - /* 10-14 */ "CDMFloatProperty", "CDMIntProperty","CDMStringProperty", "CDOrigSpace", "CDOrco", + /* 10-14 */ "CDMFloatProperty", "CDMIntProperty", "CDMStringProperty", "CDOrigSpace", "CDOrco", /* 15-19 */ "CDMTexPoly", "CDMLoopUV", "CDMloopCol", "CDTangent", "CDMDisps", - /* 20-24 */"CDPreviewMCol", "CDIDMCol", "CDTextureMCol", "CDClothOrco", "CDMRecast" + /* 20-24 */"CDPreviewMCol", "CDIDMCol", "CDTextureMCol", "CDClothOrco", "CDMRecast", /* BMESH ONLY */ - , /* 25-29 */ "CDMPoly", "CDMLoop", "CDShapeKeyIndex", "CDShapeKey", "CDBevelWeight", /* 30-32 */ "CDSubSurfCrease", "CDOrigSpaceLoop", "CDPreviewLoopCol" /* END BMESH ONLY */ @@ -2601,6 +2603,16 @@ const char *CustomData_layertype_name(int type) return layerType_getName(type); } + +/** + * Can only ever be one of these. + */ +int CustomData_layertype_is_singleton(int type) +{ + const LayerTypeInfo *typeInfo = layerType_getInfo(type); + return typeInfo->defaultname == NULL; +} + static int CustomData_is_property_layer(int type) { if ((type == CD_PROP_FLT) || (type == CD_PROP_INT) || (type == CD_PROP_STR)) diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index 3e0c947ff4a..ebf5735c1cd 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -437,11 +437,51 @@ void defgroup_unique_name(bDeformGroup *dg, Object *ob) BLI_uniquename_cb(defgroup_unique_check, &data, "Group", '.', dg->name, sizeof(dg->name)); } -BLI_INLINE int is_char_sep(const char c) +static int is_char_sep(const char c) { return ELEM4(c, '.', ' ', '-', '_'); } +/* based on BLI_split_dirfile() / os.path.splitext(), "a.b.c" -> ("a.b", ".c") */ + +void BKE_deform_split_suffix(const char string[MAX_VGROUP_NAME], char body[MAX_VGROUP_NAME], char suf[MAX_VGROUP_NAME]) +{ + size_t len = BLI_strnlen(string, MAX_VGROUP_NAME); + size_t i; + + body[0] = suf[0] = '\0'; + + for (i = len - 1; i > 1; i--) { + if (is_char_sep(string[i])) { + BLI_strncpy(body, string, i + 1); + BLI_strncpy(suf, string + i, (len + 1) - i); + return; + } + } + + BLI_strncpy(body, string, len); +} + +/* "a.b.c" -> ("a.", "b.c") */ +void BKE_deform_split_prefix(const char string[MAX_VGROUP_NAME], char pre[MAX_VGROUP_NAME], char body[MAX_VGROUP_NAME]) +{ + size_t len = BLI_strnlen(string, MAX_VGROUP_NAME); + size_t i; + + body[0] = pre[0] = '\0'; + + for (i = 1; i < len; i++) { + if (is_char_sep(string[i])) { + i++; + BLI_strncpy(pre, string, i + 1); + BLI_strncpy(body, string + i, (len + 1) - i); + return; + } + } + + BLI_strncpy(body, string, len); +} + /* finds the best possible flipped name. For renaming; check for unique names afterwards */ /* if strip_number: removes number extensions * note: don't use sizeof() for 'name' or 'from_name' */ @@ -466,7 +506,7 @@ void flip_side_name(char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_ /* We first check the case with a .### extension, let's find the last period */ if (isdigit(name[len - 1])) { index = strrchr(name, '.'); // last occurrence - if (index && isdigit(index[1]) ) { // doesnt handle case bone.1abc2 correct..., whatever! + if (index && isdigit(index[1])) { // doesnt handle case bone.1abc2 correct..., whatever! if (strip_number == 0) { BLI_strncpy(number, index, sizeof(number)); } @@ -478,7 +518,7 @@ void flip_side_name(char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_ BLI_strncpy(prefix, name, sizeof(prefix)); /* first case; separator . - _ with extensions r R l L */ - if (is_char_sep(name[len - 2]) ) { + if (is_char_sep(name[len - 2])) { switch (name[len - 1]) { case 'l': prefix[len - 1] = 0; @@ -499,7 +539,7 @@ void flip_side_name(char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_ } } /* case; beginning with r R l L , with separator after it */ - else if (is_char_sep(name[1]) ) { + else if (is_char_sep(name[1])) { switch (name[0]) { case 'l': strcpy(replace, "r"); diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 045d85242f1..75e22195c6a 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -72,6 +72,7 @@ #include "BKE_pointcache.h" #include "BKE_scene.h" #include "BKE_screen.h" +#include "BKE_tracking.h" #include "BKE_utildefines.h" #include "depsgraph_private.h" @@ -87,18 +88,18 @@ DagNodeQueue * queue_create (int slots) DagNodeQueueElem * elem; int i; - queue = MEM_mallocN(sizeof(DagNodeQueue),"DAG queue"); - queue->freenodes = MEM_mallocN(sizeof(DagNodeQueue),"DAG queue"); + queue = MEM_mallocN(sizeof(DagNodeQueue), "DAG queue"); + queue->freenodes = MEM_mallocN(sizeof(DagNodeQueue), "DAG queue"); queue->count = 0; queue->maxlevel = 0; queue->first = queue->last = NULL; - elem = MEM_mallocN(sizeof(DagNodeQueueElem),"DAG queue elem3"); + elem = MEM_mallocN(sizeof(DagNodeQueueElem), "DAG queue elem3"); elem->node = NULL; elem->next = NULL; queue->freenodes->first = queue->freenodes->last = elem; for (i = 1; i <slots;i++) { - elem = MEM_mallocN(sizeof(DagNodeQueueElem),"DAG queue elem4"); + elem = MEM_mallocN(sizeof(DagNodeQueueElem), "DAG queue elem4"); elem->node = NULL; elem->next = NULL; queue->freenodes->last->next = elem; @@ -159,10 +160,10 @@ void push_queue(DagNodeQueue *queue, DagNode *node) int i; if (node == NULL) { - fprintf(stderr,"pushing null node\n"); + fprintf(stderr, "pushing null node\n"); return; } - /*fprintf(stderr,"BFS push : %s %d\n",((ID *) node->ob)->name, queue->count);*/ + /*fprintf(stderr, "BFS push : %s %d\n", ((ID *) node->ob)->name, queue->count);*/ elem = queue->freenodes->first; if (elem != NULL) { @@ -174,13 +175,13 @@ void push_queue(DagNodeQueue *queue, DagNode *node) queue->freenodes->count--; } else { /* alllocating more */ - elem = MEM_mallocN(sizeof(DagNodeQueueElem),"DAG queue elem1"); + elem = MEM_mallocN(sizeof(DagNodeQueueElem), "DAG queue elem1"); elem->node = NULL; elem->next = NULL; queue->freenodes->first = queue->freenodes->last = elem; for (i = 1; i <DAGQUEUEALLOC;i++) { - elem = MEM_mallocN(sizeof(DagNodeQueueElem),"DAG queue elem2"); + elem = MEM_mallocN(sizeof(DagNodeQueueElem), "DAG queue elem2"); elem->node = NULL; elem->next = NULL; queue->freenodes->last->next = elem; @@ -219,13 +220,13 @@ void push_stack(DagNodeQueue *queue, DagNode *node) queue->freenodes->count--; } else { /* alllocating more */ - elem = MEM_mallocN(sizeof(DagNodeQueueElem),"DAG queue elem1"); + elem = MEM_mallocN(sizeof(DagNodeQueueElem), "DAG queue elem1"); elem->node = NULL; elem->next = NULL; queue->freenodes->first = queue->freenodes->last = elem; for (i = 1; i <DAGQUEUEALLOC;i++) { - elem = MEM_mallocN(sizeof(DagNodeQueueElem),"DAG queue elem2"); + elem = MEM_mallocN(sizeof(DagNodeQueueElem), "DAG queue elem2"); elem->node = NULL; elem->next = NULL; queue->freenodes->last->next = elem; @@ -270,7 +271,7 @@ DagNode * pop_queue(DagNodeQueue *queue) return node; } else { - fprintf(stderr,"return null\n"); + fprintf(stderr, "return null\n"); return NULL; } } @@ -295,7 +296,7 @@ DagForest *dag_init(void) { DagForest *forest; /* use callocN to init all zero */ - forest = MEM_callocN(sizeof(DagForest),"DAG root"); + forest = MEM_callocN(sizeof(DagForest), "DAG root"); return forest; } @@ -376,8 +377,8 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O node = dag_get_node(dag, ob); if ((ob->data) && (mask&DAG_RL_DATA)) { - node2 = dag_get_node(dag,ob->data); - dag_add_relation(dag,node,node2,DAG_RL_DATA, "Object-Data Relation"); + node2 = dag_get_node(dag, ob->data); + dag_add_relation(dag, node, node2, DAG_RL_DATA, "Object-Data Relation"); node2->first_ancestor = ob; node2->ancestor_count += 1; } @@ -401,18 +402,18 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O for (ct= targets.first; ct; ct= ct->next) { if (ct->tar && ct->tar != ob) { - // fprintf(stderr,"armature %s target :%s\n", ob->id.name, target->id.name); + // fprintf(stderr, "armature %s target :%s\n", ob->id.name, target->id.name); node3 = dag_get_node(dag, ct->tar); if (ct->subtarget[0]) { - dag_add_relation(dag,node3,node, DAG_RL_OB_DATA|DAG_RL_DATA_DATA, cti->name); + dag_add_relation(dag, node3, node, DAG_RL_OB_DATA|DAG_RL_DATA_DATA, cti->name); if (ct->tar->type == OB_MESH) node3->customdata_mask |= CD_MASK_MDEFORMVERT; } else if (ELEM3(con->type, CONSTRAINT_TYPE_FOLLOWPATH, CONSTRAINT_TYPE_CLAMPTO, CONSTRAINT_TYPE_SPLINEIK)) - dag_add_relation(dag,node3,node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, cti->name); + dag_add_relation(dag, node3, node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, cti->name); else - dag_add_relation(dag,node3,node, DAG_RL_OB_DATA, cti->name); + dag_add_relation(dag, node3, node, DAG_RL_OB_DATA, cti->name); } } @@ -460,31 +461,31 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O } } if (ob->parent) { - node2 = dag_get_node(dag,ob->parent); + node2 = dag_get_node(dag, ob->parent); switch (ob->partype) { case PARSKEL: - dag_add_relation(dag,node2,node,DAG_RL_DATA_DATA|DAG_RL_OB_OB, "Parent"); + dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_OB, "Parent"); break; case PARVERT1: case PARVERT3: - dag_add_relation(dag,node2,node,DAG_RL_DATA_OB|DAG_RL_OB_OB, "Vertex Parent"); + dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, "Vertex Parent"); node2->customdata_mask |= CD_MASK_ORIGINDEX; break; case PARBONE: - dag_add_relation(dag,node2,node,DAG_RL_DATA_OB|DAG_RL_OB_OB, "Bone Parent"); + dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, "Bone Parent"); break; default: if (ob->parent->type==OB_LATTICE) - dag_add_relation(dag,node2,node,DAG_RL_DATA_DATA|DAG_RL_OB_OB, "Lattice Parent"); + dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_OB, "Lattice Parent"); else if (ob->parent->type==OB_CURVE) { Curve *cu= ob->parent->data; if (cu->flag & CU_PATH) - dag_add_relation(dag,node2,node,DAG_RL_DATA_OB|DAG_RL_OB_OB, "Curve Parent"); + dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, "Curve Parent"); else - dag_add_relation(dag,node2,node,DAG_RL_OB_OB, "Curve Parent"); + dag_add_relation(dag, node2, node, DAG_RL_OB_OB, "Curve Parent"); } else - dag_add_relation(dag,node2,node,DAG_RL_OB_OB, "Parent"); + dag_add_relation(dag, node2, node, DAG_RL_OB_OB, "Parent"); } /* exception case: parent is duplivert */ if (ob->type==OB_MBALL && (ob->parent->transflag & OB_DUPLIVERTS)) { @@ -533,7 +534,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O if (cam->dof_ob) { node2 = dag_get_node(dag, cam->dof_ob); - dag_add_relation(dag,node2,node,DAG_RL_OB_OB, "Camera DoF"); + dag_add_relation(dag, node2, node, DAG_RL_OB_OB, "Camera DoF"); } } break; @@ -543,7 +544,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O if (mom!=ob) { node2 = dag_get_node(dag, mom); - dag_add_relation(dag,node,node2,DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Metaball"); // mom depends on children! + dag_add_relation(dag, node, node2, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Metaball"); // mom depends on children! } } break; @@ -554,16 +555,16 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O if (cu->bevobj) { node2 = dag_get_node(dag, cu->bevobj); - dag_add_relation(dag,node2,node,DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Curve Bevel"); + dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Curve Bevel"); } if (cu->taperobj) { node2 = dag_get_node(dag, cu->taperobj); - dag_add_relation(dag,node2,node,DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Curve Taper"); + dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Curve Taper"); } if (ob->type == OB_FONT) { if (cu->textoncurve) { node2 = dag_get_node(dag, cu->textoncurve); - dag_add_relation(dag,node2,node,DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Texture On Curve"); + dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Texture On Curve"); } } } @@ -587,7 +588,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O if (!psys_check_enabled(ob, psys)) continue; - if (ELEM(part->phystype,PART_PHYS_KEYED,PART_PHYS_BOIDS)) { + if (ELEM(part->phystype, PART_PHYS_KEYED, PART_PHYS_BOIDS)) { ParticleTarget *pt = psys->targets.first; for (; pt; pt=pt->next) { @@ -677,7 +678,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, cti->name); } - dag_add_relation(dag,scenenode,node,DAG_RL_SCENE, "Scene Relation"); + dag_add_relation(dag, scenenode, node, DAG_RL_SCENE, "Scene Relation"); addtoroot = 0; } else if (cti->get_constraint_targets) { @@ -712,7 +713,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O } if (addtoroot == 1 ) - dag_add_relation(dag,scenenode,node,DAG_RL_SCENE, "Scene Relation"); + dag_add_relation(dag, scenenode, node, DAG_RL_SCENE, "Scene Relation"); } struct DagForest *build_dag(Main *bmain, Scene *sce, short mask) @@ -729,7 +730,7 @@ struct DagForest *build_dag(Main *bmain, Scene *sce, short mask) dag = sce->theDag; sce->dagisvalid=1; if ( dag) - free_forest( dag ); + free_forest(dag); else { dag = dag_init(); sce->theDag = dag; @@ -831,7 +832,7 @@ void free_forest(DagForest *Dag) } -DagNode * dag_find_node (DagForest *forest,void * fob) +DagNode * dag_find_node (DagForest *forest, void * fob) { if (forest->nodeHash) return BLI_ghash_lookup(forest->nodeHash, fob); @@ -847,7 +848,7 @@ DagNode * dag_add_node (DagForest *forest, void * fob) { DagNode *node; - node = MEM_callocN(sizeof(DagNode),"DAG node"); + node = MEM_callocN(sizeof(DagNode), "DAG node"); if (node) { node->ob = fob; node->color = DAG_WHITE; @@ -872,7 +873,7 @@ DagNode * dag_add_node (DagForest *forest, void * fob) return node; } -DagNode * dag_get_node (DagForest *forest,void * fob) +DagNode * dag_get_node (DagForest *forest, void * fob) { DagNode *node; @@ -884,7 +885,7 @@ DagNode * dag_get_node (DagForest *forest,void * fob) -DagNode * dag_get_sub_node (DagForest *forest,void * fob) +DagNode * dag_get_sub_node (DagForest *forest, void * fob) { DagNode *node; DagAdjList *mainchild, *prev=NULL; @@ -926,7 +927,7 @@ static void dag_add_parent_relation(DagForest *UNUSED(forest), DagNode *fob1, Da itA = itA->next; } /* create new relation and insert at head. MALLOC alert! */ - itA = MEM_mallocN(sizeof(DagAdjList),"DAG adj list"); + itA = MEM_mallocN(sizeof(DagAdjList), "DAG adj list"); itA->node = fob1; itA->type = rel; itA->count = 1; @@ -951,7 +952,7 @@ void dag_add_relation(DagForest *forest, DagNode *fob1, DagNode *fob2, short rel itA = itA->next; } /* create new relation and insert at head. MALLOC alert! */ - itA = MEM_mallocN(sizeof(DagAdjList),"DAG adj list"); + itA = MEM_mallocN(sizeof(DagAdjList), "DAG adj list"); itA->node = fob2; itA->type = rel; itA->count = 1; @@ -1118,7 +1119,7 @@ void graph_bfs(void) DagAdjList *itA; int minheight; - /* fprintf(stderr,"starting BFS\n ------------\n"); */ + /* fprintf(stderr, "starting BFS\n ------------\n"); */ nqueue = queue_create(DAGQUEUEALLOC); for ( i=0; i<50; i++) pos[i] = 0; @@ -1138,7 +1139,7 @@ void graph_bfs(void) if (node->color == DAG_WHITE) { node->color = DAG_GRAY; node->BFS_dist = 1; - push_queue(nqueue,node); + push_queue(nqueue, node); while (nqueue->count) { node = pop_queue(nqueue); @@ -1149,11 +1150,11 @@ void graph_bfs(void) itA->node->color = DAG_GRAY; itA->node->BFS_dist = node->BFS_dist + 1; itA->node->k = (float) minheight; - push_queue(nqueue,itA->node); + push_queue(nqueue, itA->node); } else { - fprintf(stderr,"bfs not dag tree edge color :%i\n",itA->node->color); + fprintf(stderr, "bfs not dag tree edge color :%i\n", itA->node->color); } @@ -1169,7 +1170,7 @@ void graph_bfs(void) set_node_xy(node, node->BFS_dist*DEPSX*2, pos[node->BFS_dist]*DEPSY*2); node->color = DAG_BLACK; - // fprintf(stderr,"BFS node : %20s %i %5.0f %5.0f\n",((ID *) node->ob)->name,node->BFS_dist, node->x, node->y); + // fprintf(stderr, "BFS node : %20s %i %5.0f %5.0f\n", ((ID *) node->ob)->name, node->BFS_dist, node->x, node->y); } } queue_delete(nqueue); @@ -1190,7 +1191,7 @@ int pre_and_post_source_BFS(DagForest *dag, short mask, DagNode *source, graph_a DagNodeQueue *nqueue; DagAdjList *itA; int retval = 0; - /* fprintf(stderr,"starting BFS\n ------------\n"); */ + /* fprintf(stderr, "starting BFS\n ------------\n"); */ /* Init * dagnode.first is always the root (scene) @@ -1207,7 +1208,7 @@ int pre_and_post_source_BFS(DagForest *dag, short mask, DagNode *source, graph_a if (node->color == DAG_WHITE) { node->color = DAG_GRAY; node->BFS_dist = 1; - pre_func(node->ob,data); + pre_func(node->ob, data); while (nqueue->count) { node = pop_queue(nqueue); @@ -1217,8 +1218,8 @@ int pre_and_post_source_BFS(DagForest *dag, short mask, DagNode *source, graph_a if ((itA->node->color == DAG_WHITE) && (itA->type & mask)) { itA->node->color = DAG_GRAY; itA->node->BFS_dist = node->BFS_dist + 1; - push_queue(nqueue,itA->node); - pre_func(node->ob,data); + push_queue(nqueue, itA->node); + pre_func(node->ob, data); } else { // back or cross edge @@ -1226,10 +1227,10 @@ int pre_and_post_source_BFS(DagForest *dag, short mask, DagNode *source, graph_a } itA = itA->next; } - post_func(node->ob,data); + post_func(node->ob, data); node->color = DAG_BLACK; - // fprintf(stderr,"BFS node : %20s %i %5.0f %5.0f\n",((ID *) node->ob)->name,node->BFS_dist, node->x, node->y); + // fprintf(stderr, "BFS node : %20s %i %5.0f %5.0f\n", ((ID *) node->ob)->name, node->BFS_dist, node->x, node->y); } } queue_delete(nqueue); @@ -1251,7 +1252,7 @@ DagNodeQueue * graph_dfs(void) int maxpos=0; /* int is_cycle = 0; */ /* UNUSED */ /* - *fprintf(stderr,"starting DFS\n ------------\n"); + *fprintf(stderr, "starting DFS\n ------------\n"); */ nqueue = queue_create(DAGQUEUEALLOC); retqueue = queue_create(MainDag->numNodes); @@ -1280,7 +1281,7 @@ DagNodeQueue * graph_dfs(void) node->DFS_dist = 1; node->DFS_dvtm = time; time++; - push_stack(nqueue,node); + push_stack(nqueue, node); while (nqueue->count) { //graph_print_queue(nqueue); @@ -1299,13 +1300,13 @@ DagNodeQueue * graph_dfs(void) time++; itA->node->DFS_dist = node->DFS_dist + 1; itA->node->k = (float) minheight; - push_stack(nqueue,itA->node); + push_stack(nqueue, itA->node); skip = 1; break; } else { if (itA->node->color == DAG_GRAY) { // back edge - fprintf(stderr,"dfs back edge :%15s %15s\n",((ID *) node->ob)->name, ((ID *) itA->node->ob)->name); + fprintf(stderr, "dfs back edge :%15s %15s\n", ((ID *) node->ob)->name, ((ID *) itA->node->ob)->name); /* is_cycle = 1; */ /* UNUSED */ } else if (itA->node->color == DAG_BLACK) { @@ -1316,7 +1317,7 @@ DagNodeQueue * graph_dfs(void) if (node->DFS_dist >= itA->node->DFS_dist) itA->node->DFS_dist = node->DFS_dist + 1; - fprintf(stderr,"dfs forward or cross edge :%15s %i-%i %15s %i-%i\n", + fprintf(stderr, "dfs forward or cross edge :%15s %i-%i %15s %i-%i\n", ((ID *) node->ob)->name, node->DFS_dvtm, node->DFS_fntm, @@ -1326,7 +1327,7 @@ DagNodeQueue * graph_dfs(void) #endif } else - fprintf(stderr,"dfs unknown edge\n"); + fprintf(stderr, "dfs unknown edge\n"); } itA = itA->next; } @@ -1348,16 +1349,16 @@ DagNodeQueue * graph_dfs(void) } set_node_xy(node, node->DFS_dist*DEPSX*2, pos[node->DFS_dist]*DEPSY*2); - // fprintf(stderr,"DFS node : %20s %i %i %i %i\n",((ID *) node->ob)->name,node->BFS_dist, node->DFS_dist, node->DFS_dvtm, node->DFS_fntm ); + // fprintf(stderr, "DFS node : %20s %i %i %i %i\n", ((ID *) node->ob)->name, node->BFS_dist, node->DFS_dist, node->DFS_dvtm, node->DFS_fntm ); - push_stack(retqueue,node); + push_stack(retqueue, node); } } } node = node->next; } while (node); -// fprintf(stderr,"i size : %i\n", maxpos); +// fprintf(stderr, "i size : %i\n", maxpos); queue_delete(nqueue); return(retqueue); @@ -1381,7 +1382,7 @@ int pre_and_post_source_DFS(DagForest *dag, short mask, DagNode *source, graph_a int skip = 0; int retval = 0; /* - *fprintf(stderr,"starting DFS\n ------------\n"); + *fprintf(stderr, "starting DFS\n ------------\n"); */ nqueue = queue_create(DAGQUEUEALLOC); @@ -1406,8 +1407,8 @@ int pre_and_post_source_DFS(DagForest *dag, short mask, DagNode *source, graph_a node->DFS_dist = 1; node->DFS_dvtm = time; time++; - push_stack(nqueue,node); - pre_func(node->ob,data); + push_stack(nqueue, node); + pre_func(node->ob, data); while (nqueue->count) { skip = 0; @@ -1421,8 +1422,8 @@ int pre_and_post_source_DFS(DagForest *dag, short mask, DagNode *source, graph_a time++; itA->node->DFS_dist = node->DFS_dist + 1; - push_stack(nqueue,itA->node); - pre_func(node->ob,data); + push_stack(nqueue, itA->node); + pre_func(node->ob, data); skip = 1; break; @@ -1444,7 +1445,7 @@ int pre_and_post_source_DFS(DagForest *dag, short mask, DagNode *source, graph_a node->DFS_fntm = time; time++; - post_func(node->ob,data); + post_func(node->ob, data); } } } @@ -1462,13 +1463,13 @@ struct DagNodeQueue *get_obparents(struct DagForest *dag, void *ob) DagNodeQueue *nqueue; DagAdjList *itA; - node = dag_find_node(dag,ob); + node = dag_find_node(dag, ob); if (node==NULL) { return NULL; } else if (node->ancestor_count == 1) { // simple case nqueue = queue_create(1); - push_queue(nqueue,node); + push_queue(nqueue, node); } else { /* need to go over the whole dag for adj list */ nqueue = queue_create(node->ancestor_count); @@ -1479,7 +1480,7 @@ struct DagNodeQueue *get_obparents(struct DagForest *dag, void *ob) itA = node->child; while (itA != NULL) { if ((itA->node == node) && (itA->type == DAG_RL_DATA)) { - push_queue(nqueue,node); + push_queue(nqueue, node); } itA = itA->next; } @@ -1496,7 +1497,7 @@ struct DagNodeQueue *get_first_ancestors(struct DagForest *dag, void *ob) DagNodeQueue *nqueue; DagAdjList *itA; - node = dag_find_node(dag,ob); + node = dag_find_node(dag, ob); // need to go over the whole dag for adj list nqueue = queue_create(node->ancestor_count); @@ -1507,7 +1508,7 @@ struct DagNodeQueue *get_first_ancestors(struct DagForest *dag, void *ob) itA = node->child; while (itA != NULL) { if (itA->node == node) { - push_queue(nqueue,node); + push_queue(nqueue, node); } itA = itA->next; } @@ -1544,7 +1545,7 @@ struct DagNodeQueue *get_all_childs(struct DagForest *dag, void *ob) node->color = DAG_GRAY; time++; - push_stack(nqueue,node); + push_stack(nqueue, node); while (nqueue->count) { @@ -1558,7 +1559,7 @@ struct DagNodeQueue *get_all_childs(struct DagForest *dag, void *ob) itA->node->color = DAG_GRAY; time++; - push_stack(nqueue,itA->node); + push_stack(nqueue, itA->node); skip = 1; break; } @@ -1570,7 +1571,7 @@ struct DagNodeQueue *get_all_childs(struct DagForest *dag, void *ob) node->color = DAG_BLACK; time++; - push_stack(retqueue,node); + push_stack(retqueue, node); } } } @@ -1598,7 +1599,7 @@ short are_obs_related(struct DagForest *dag, void *ob1, void *ob2) } #endif -int is_acyclic( DagForest *dag) +int is_acyclic(DagForest *dag) { return dag->is_acyclic; } @@ -1618,10 +1619,10 @@ void graph_print_queue(DagNodeQueue *nqueue) queueElem = nqueue->first; while (queueElem) { - fprintf(stderr,"** %s %i %i-%i ",((ID *) queueElem->node->ob)->name,queueElem->node->color,queueElem->node->DFS_dvtm,queueElem->node->DFS_fntm); + fprintf(stderr, "** %s %i %i-%i ", ((ID *) queueElem->node->ob)->name, queueElem->node->color, queueElem->node->DFS_dvtm, queueElem->node->DFS_fntm); queueElem = queueElem->next; } - fprintf(stderr,"\n"); + fprintf(stderr, "\n"); } void graph_print_queue_dist(DagNodeQueue *nqueue) @@ -1632,16 +1633,16 @@ void graph_print_queue_dist(DagNodeQueue *nqueue) queueElem = nqueue->first; count = 0; while (queueElem) { - fprintf(stderr,"** %25s %2.2i-%2.2i ",((ID *) queueElem->node->ob)->name,queueElem->node->DFS_dvtm,queueElem->node->DFS_fntm); - while (count < queueElem->node->DFS_dvtm-1) { fputc(' ',stderr); count++;} - fputc('|',stderr); - while (count < queueElem->node->DFS_fntm-2) { fputc('-',stderr); count++;} - fputc('|',stderr); - fputc('\n',stderr); + fprintf(stderr, "** %25s %2.2i-%2.2i ", ((ID *) queueElem->node->ob)->name, queueElem->node->DFS_dvtm, queueElem->node->DFS_fntm); + while (count < queueElem->node->DFS_dvtm-1) { fputc(' ', stderr); count++;} + fputc('|', stderr); + while (count < queueElem->node->DFS_fntm-2) { fputc('-', stderr); count++;} + fputc('|', stderr); + fputc('\n', stderr); count = 0; queueElem = queueElem->next; } - fprintf(stderr,"\n"); + fprintf(stderr, "\n"); } void graph_print_adj_list(void) @@ -1651,14 +1652,14 @@ void graph_print_adj_list(void) node = (getMainDag())->DagNode.first; while (node) { - fprintf(stderr,"node : %s col: %i",((ID *) node->ob)->name, node->color); + fprintf(stderr, "node : %s col: %i", ((ID *) node->ob)->name, node->color); itA = node->child; while (itA) { - fprintf(stderr,"-- %s ",((ID *) itA->node->ob)->name); + fprintf(stderr, "-- %s ", ((ID *) itA->node->ob)->name); itA = itA->next; } - fprintf(stderr,"\n"); + fprintf(stderr, "\n"); node = node->next; } } @@ -1722,8 +1723,8 @@ static void scene_sort_groups(Main *bmain, Scene *sce) if (base->object->id.newid) { go= (GroupObject *)base->object->id.newid; base->object->id.newid= NULL; - BLI_remlink( &group->gobject, go); - BLI_addtail( &listb, go); + BLI_remlink(&group->gobject, go); + BLI_addtail(&listb, go); } } /* copy the newly sorted listbase */ @@ -1760,7 +1761,7 @@ void DAG_scene_sort(Main *bmain, Scene *sce) rootnode = sce->theDag->DagNode.first; rootnode->color = DAG_GRAY; time++; - push_stack(nqueue,rootnode); + push_stack(nqueue, rootnode); while (nqueue->count) { @@ -1774,7 +1775,7 @@ void DAG_scene_sort(Main *bmain, Scene *sce) itA->node->color = DAG_GRAY; time++; - push_stack(nqueue,itA->node); + push_stack(nqueue, itA->node); skip = 1; break; } @@ -1793,8 +1794,8 @@ void DAG_scene_sort(Main *bmain, Scene *sce) while (base && base->object != node->ob) base = base->next; if (base) { - BLI_remlink(&sce->base,base); - BLI_addhead(&tempbase,base); + BLI_remlink(&sce->base, base); + BLI_addhead(&tempbase, base); } } } @@ -1803,8 +1804,8 @@ void DAG_scene_sort(Main *bmain, Scene *sce) /* temporal correction for circular dependencies */ base = sce->base.first; while (base) { - BLI_remlink(&sce->base,base); - BLI_addhead(&tempbase,base); + BLI_remlink(&sce->base, base); + BLI_addhead(&tempbase, base); //if (G.debug & G_DEBUG) printf("cyclic %s\n", base->object->id.name); base = sce->base.first; @@ -1930,7 +1931,7 @@ static void flush_update_node(DagNode *node, unsigned int layer, int curtime) } -/* node was checked to have lasttime != curtime , and is of type ID_OB */ +/* node was checked to have lasttime != curtime, and is of type ID_OB */ static unsigned int flush_layer_node(Scene *sce, DagNode *node, int curtime) { DagAdjList *itA; @@ -1952,7 +1953,7 @@ static unsigned int flush_layer_node(Scene *sce, DagNode *node, int curtime) return node->lay; } -/* node was checked to have lasttime != curtime , and is of type ID_OB */ +/* node was checked to have lasttime != curtime, and is of type ID_OB */ static void flush_pointcache_reset(Scene *scene, DagNode *node, int curtime, int reset) { Main *bmain= G.main; @@ -2580,6 +2581,10 @@ static void dag_id_flush_update(Scene *sce, ID *id) } if (idtype == ID_MC) { + MovieClip *clip = (MovieClip *) id; + + BKE_tracking_dopesheet_tag_update(&clip->tracking); + for (obt=bmain->object.first; obt; obt= obt->id.next) { bConstraint *con; for (con = obt->constraints.first; con; con=con->next) { @@ -2897,7 +2902,7 @@ void DAG_pose_sort(Object *ob) while (itA != NULL) { if (itA->node->color == DAG_WHITE) { itA->node->color = DAG_GRAY; - push_stack(nqueue,itA->node); + push_stack(nqueue, itA->node); skip = 1; break; } @@ -2935,8 +2940,8 @@ void DAG_pose_sort(Object *ob) // printf(" %s\n", pchan->name); // } - free_forest( dag ); - MEM_freeN( dag ); + free_forest(dag); + MEM_freeN(dag); ugly_hack_sorry= 1; } diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 3d79386e19a..cf7750520a3 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -1,5 +1,4 @@ /* - * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -197,7 +196,7 @@ void addnormalsDispList(ListBase *lb) for (; b<dl->nr; b++) { - normal_quad_v3( nor,v1, v3, v4, v2); + normal_quad_v3(nor, v1, v3, v4, v2); add_v3_v3(n1, nor); add_v3_v3(n2, nor); @@ -321,7 +320,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, i dl= MEM_callocN(sizeof(DispList), "makeDispListbez"); /* len+1 because of 'forward_diff_bezier' function */ - dl->verts= MEM_callocN( (len+1)*3*sizeof(float), "dlverts"); + dl->verts= MEM_callocN((len+1)*3*sizeof(float), "dlverts"); BLI_addtail(dispbase, dl); dl->parts= 1; dl->nr= len; @@ -352,11 +351,11 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, i else { int j; for (j=0; j<3; j++) { - BKE_curve_forward_diff_bezier( prevbezt->vec[1][j], - prevbezt->vec[2][j], - bezt->vec[0][j], - bezt->vec[1][j], - data+j, resolu, 3*sizeof(float)); + BKE_curve_forward_diff_bezier(prevbezt->vec[1][j], + prevbezt->vec[2][j], + bezt->vec[0][j], + bezt->vec[1][j], + data + j, resolu, 3 * sizeof(float)); } data+= 3*resolu; @@ -433,7 +432,7 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal) totvert= 0; nextcol= 0; - BLI_begin_edgefill(&sf_ctx); + BLI_scanfill_begin(&sf_ctx); dl= dispbase->first; while (dl) { @@ -450,18 +449,18 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal) while (a--) { vlast= eve; - eve = BLI_addfillvert(&sf_ctx, f1); + eve = BLI_scanfill_vert_add(&sf_ctx, f1); totvert++; if (vlast==NULL) v1= eve; else { - BLI_addfilledge(&sf_ctx, vlast, eve); + BLI_scanfill_edge_add(&sf_ctx, vlast, eve); } f1+=3; } if (eve!=NULL && v1!=NULL) { - BLI_addfilledge(&sf_ctx, eve, v1); + BLI_scanfill_edge_add(&sf_ctx, eve, v1); } } else if (colnr<dl->col) { @@ -474,7 +473,7 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal) dl= dl->next; } - if (totvert && (tot= BLI_edgefill(&sf_ctx, FALSE))) { // XXX (obedit && obedit->actcol)?(obedit->actcol-1):0)) { + if (totvert && (tot= BLI_scanfill_calc(&sf_ctx, FALSE))) { // XXX (obedit && obedit->actcol)?(obedit->actcol-1):0)) { if (tot) { dlnew= MEM_callocN(sizeof(DispList), "filldisplist"); dlnew->type= DL_INDEX3; @@ -519,7 +518,7 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal) BLI_addhead(to, dlnew); } - BLI_end_edgefill(&sf_ctx); + BLI_scanfill_end(&sf_ctx); if (nextcol) { /* stay at current char but fill polys with next material */ @@ -970,7 +969,7 @@ static void displist_surf_indices(DispList *dl) dl->totindex= 0; - index=dl->index= MEM_mallocN( 4*sizeof(int)*(dl->parts+1)*(dl->nr+1), "index array nurbs"); + index=dl->index= MEM_mallocN(4*sizeof(int)*(dl->parts+1)*(dl->nr+1), "index array nurbs"); for (a=0; a<dl->parts; a++) { @@ -1197,7 +1196,7 @@ static void rotateBevelPiece(Curve *cu, BevPoint *bevp, DispList *dlb, float wid int b; fp = dlb->verts; - for (b = 0; b<dlb->nr; b++,fp += 3,data += 3) { + for (b = 0; b<dlb->nr; b++, fp += 3, data += 3) { if (cu->flag & CU_3D) { float vec[3]; @@ -1221,10 +1220,11 @@ static void rotateBevelPiece(Curve *cu, BevPoint *bevp, DispList *dlb, float wid *data_r = data; } -static void fillBevelCap(Curve *cu, Nurb *nu, BevPoint *bevp, DispList *dlb, float fac, float widfac, ListBase *dispbase) +static void fillBevelCap(Nurb *nu, DispList *dlb, float *prev_fp, ListBase *dispbase) { DispList *dl; float *data; + int b; dl= MEM_callocN(sizeof(DispList), "makeDispListbev2"); dl->verts= data= MEM_callocN(3*sizeof(float)*dlb->nr, "dlverts"); @@ -1240,7 +1240,8 @@ static void fillBevelCap(Curve *cu, Nurb *nu, BevPoint *bevp, DispList *dlb, flo /* CU_2D conflicts with R_NOPUNOFLIP */ dl->rt= nu->flag & ~CU_2D; - rotateBevelPiece(cu, bevp, dlb, widfac, fac, &data); + for (b = 0; b < dlb->nr; b++, prev_fp += 3, data += 3) + copy_v3_v3(data, prev_fp); BLI_addtail(dispbase, dl); } @@ -1288,7 +1289,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba BevList *bl= cu->bev.first; Nurb *nu= nubase->first; - for (; bl && nu; bl=bl->next,nu=nu->next) { + for (; bl && nu; bl=bl->next, nu=nu->next) { DispList *dl; float *data; BevPoint *bevp; @@ -1333,9 +1334,26 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba ListBase top_capbase = {NULL, NULL}; for (dlb=dlbev.first; dlb; dlb=dlb->next) { + int i, start, steps; + float bevfac1 = MIN2(cu->bevfac1, cu->bevfac2), bevfac2 = MAX2(cu->bevfac1, cu->bevfac2); + float firstblend = 0.0f, lastblend = 0.0f; + + if (cu->bevfac1 - cu->bevfac2 == 0.0f) + continue; + + start = (int)(bevfac1*(bl->nr-1)); + steps = 2+(int)((bevfac2)*(bl->nr-1)) - start; + firstblend = 1.0f - ((float)bevfac1*(bl->nr-1) - (int)((float)bevfac1*(bl->nr-1))); + lastblend = (float)bevfac2*(bl->nr-1) - (int)((float)bevfac2*(bl->nr-1)); + + if (steps > bl->nr) { + steps = bl->nr; + lastblend = 1.0f; + } + /* for each part of the bevel use a separate displblock */ dl= MEM_callocN(sizeof(DispList), "makeDispListbev1"); - dl->verts= data= MEM_callocN(3*sizeof(float)*dlb->nr*bl->nr, "dlverts"); + dl->verts= data= MEM_callocN(3*sizeof(float)*dlb->nr*steps, "dlverts"); BLI_addtail(dispbase, dl); dl->type= DL_SURF; @@ -1343,8 +1361,8 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba dl->flag= dlb->flag & (DL_FRONT_CURVE|DL_BACK_CURVE); if (dlb->type==DL_POLY) dl->flag |= DL_CYCL_U; if (bl->poly>=0) dl->flag |= DL_CYCL_V; - - dl->parts= bl->nr; + + dl->parts= steps; dl->nr= dlb->nr; dl->col= nu->mat_nr; dl->charidx= nu->charidx; @@ -1353,18 +1371,20 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba /* CU_2D conflicts with R_NOPUNOFLIP */ dl->rt= nu->flag & ~CU_2D; - dl->bevelSplitFlag= MEM_callocN(sizeof(*dl->col2)*((bl->nr+0x1F)>>5), "bevelSplitFlag"); + dl->bevelSplitFlag= MEM_callocN(sizeof(*dl->col2)*((steps+0x1F)>>5), "bevelSplitFlag"); /* for each point of poly make a bevel piece */ - bevp= (BevPoint *)(bl+1); - for (a=0; a<bl->nr; a++,bevp++) { + bevp= (BevPoint *)(bl+1) + start; + for (i=start, a=0; a<steps; i++,bevp++,a++) { float fac=1.0; + float *cur_data = data; + if (cu->taperobj==NULL) { if ( (cu->bevobj!=NULL) || !((cu->flag & CU_FRONT) || (cu->flag & CU_BACK)) ) fac = bevp->radius; } else { - fac = calc_taper(scene, cu->taperobj, a, bl->nr); + fac = calc_taper(scene, cu->taperobj, i, bl->nr); } if (bevp->split_tag) { @@ -1374,11 +1394,31 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba /* rotate bevel piece and write in data */ rotateBevelPiece(cu, bevp, dlb, widfac, fac, &data); + if (a == 1 || a == steps - 1) { + float *cur_fp = cur_data, *prev_fp = cur_data - 3*dlb->nr; + int b; + + for (b = 0; b < dlb->nr; b++, prev_fp += 3, cur_fp += 3) { + float cur[3], prev[3]; + + copy_v3_v3(cur, cur_fp); + copy_v3_v3(prev, prev_fp); + + if (a == 1) + interp_v3_v3v3(prev, cur_fp, prev_fp, firstblend); + if (a == steps - 1) + interp_v3_v3v3(cur, prev_fp, cur_fp, lastblend); + + copy_v3_v3(cur_fp, cur); + copy_v3_v3(prev_fp, prev); + } + } + if (cu->bevobj && (cu->flag & CU_FILL_CAPS)) { - if (a == 0) - fillBevelCap(cu, nu, bevp, dlb, fac, widfac, &bottom_capbase); - else if (a == bl->nr - 1) - fillBevelCap(cu, nu, bevp, dlb, fac, widfac, &top_capbase); + if (a == 1) + fillBevelCap(nu, dlb, cur_data - 3*dlb->nr, &bottom_capbase); + if (a == steps - 1) + fillBevelCap(nu, dlb, cur_data, &top_capbase); } } diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index e6f38a3a334..6c5826c5bab 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -1,11 +1,20 @@ -/** -***** BEGIN GPL LICENSE BLOCK ***** +/* + * ***** 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. + * * Contributor(s): Miika Hämäläinen * * ***** END GPL LICENSE BLOCK ***** @@ -78,15 +87,15 @@ /* precalculated gaussian factors for 5x super sampling */ static float gaussianFactors[5] = { 0.996849f, - 0.596145f, - 0.596145f, - 0.596145f, - 0.524141f}; + 0.596145f, + 0.596145f, + 0.596145f, + 0.524141f}; static float gaussianTotal = 3.309425f; /* UV Image neighboring pixel table x and y list */ -static int neighX[8] = {1,1,0,-1,-1,-1, 0, 1}; -static int neighY[8] = {0,1,1, 1, 0,-1,-1,-1}; +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) @@ -110,7 +119,7 @@ static int neighY[8] = {0,1,1, 1, 0,-1,-1,-1}; #define MIN_WETNESS 0.001f #define MAX_WETNESS 5.0f /* dissolve macro */ -#define VALUE_DISSOLVE(VALUE, TIME, SCALE, LOG) (VALUE) = (LOG) ? (VALUE) * (pow(MIN_WETNESS,1.0f/(1.2f*((float)(TIME))/(SCALE)))) : (VALUE) - 1.0f/(TIME)*(SCALE) +#define VALUE_DISSOLVE(VALUE, TIME, SCALE, LOG) (VALUE) = (LOG) ? (VALUE) * (pow(MIN_WETNESS, 1.0f/(1.2f*((float)(TIME))/(SCALE)))) : (VALUE) - 1.0f/(TIME)*(SCALE) /***************************** Internal Structs ***************************/ @@ -376,18 +385,18 @@ void dynamicPaintSurface_updateType(struct DynamicPaintSurface *surface) } if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) { - strcat(surface->output_name,"paintmap"); - strcat(surface->output_name2,"wetmap"); + strcat(surface->output_name, "paintmap"); + strcat(surface->output_name2, "wetmap"); surface_setUniqueOutputName(surface, surface->output_name2, 1); } else if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE) { - strcat(surface->output_name,"displace"); + strcat(surface->output_name, "displace"); } else if (surface->type == MOD_DPAINT_SURFACE_T_WEIGHT) { - strcat(surface->output_name,"weight"); + strcat(surface->output_name, "weight"); } else if (surface->type == MOD_DPAINT_SURFACE_T_WAVE) { - strcat(surface->output_name,"wave"); + strcat(surface->output_name, "wave"); } surface_setUniqueOutputName(surface, surface->output_name, 0); @@ -720,14 +729,14 @@ static void surfaceGenerateGrid(struct DynamicPaintSurface *surface) /* get dimensions */ sub_v3_v3v3(dim, grid->grid_bounds.max, grid->grid_bounds.min); copy_v3_v3(td, dim); - min_dim = MAX3(td[0],td[1],td[2]) / 1000.f; + min_dim = MAX3(td[0], td[1], td[2]) / 1000.f; /* deactivate zero axises */ for (i=0; i<3; i++) { if (td[i]<min_dim) {td[i]=1.0f; axis-=1;} } - if (axis == 0 || MAX3(td[0],td[1],td[2]) < 0.0001f) { + if (axis == 0 || MAX3(td[0], td[1], td[2]) < 0.0001f) { MEM_freeN(grid_bounds); MEM_freeN(bData->grid); bData->grid = NULL; @@ -1428,8 +1437,8 @@ void dynamicPaint_setInitialColor(DynamicPaintSurface *surface) } /* interpolate final uv pos */ - interp_v3_v3v3v3( uv_final, &uv[0], &uv[3], &uv[6], - f_data->barycentricWeights[i*samples].v); + interp_v3_v3v3v3(uv_final, &uv[0], &uv[3], &uv[6], + f_data->barycentricWeights[i*samples].v); /* remap to -1.0 to 1.0 */ uv_final[0] = uv_final[0]*2.0f - 1.0f; uv_final[1] = uv_final[1]*2.0f - 1.0f; @@ -1469,7 +1478,7 @@ void dynamicPaint_setInitialColor(DynamicPaintSurface *surface) #pragma omp parallel for schedule(static) for (i=0; i<sData->total_points; i++) { int face_ind = f_data->uv_p[i].face_index; - float colors[3][4] = {{0.0f,0.0f,0.0f,0.0f}}; + float colors[3][4] = {{0.0f, 0.0f, 0.0f, 0.0f}}; float final_color[4]; int j; /* collect color values */ @@ -1482,8 +1491,8 @@ void dynamicPaint_setInitialColor(DynamicPaintSurface *surface) } /* interpolate final color */ - interp_v4_v4v4v4( final_color, colors[0], colors[1], colors[2], - f_data->barycentricWeights[i*samples].v); + interp_v4_v4v4v4(final_color, colors[0], colors[1], colors[2], + f_data->barycentricWeights[i*samples].v); copy_v3_v3(pPoint[i].color, final_color); pPoint[i].alpha = final_color[3]; @@ -1914,8 +1923,8 @@ struct DerivedMesh *dynamicPaint_Modifier_do(DynamicPaintModifierData *pmd, Scen * Tries to find the neighboring pixel in given (uv space) direction. * Result is used by effect system to move paint on the surface. * -* px,py : origin pixel x and y -* n_index : lookup direction index (use neighX,neighY to get final index) +* px, py : origin pixel x and y +* n_index : lookup direction index (use neighX, neighY to get final index) */ static int dynamicPaint_findNeighbourPixel(PaintUVPoint *tempPoints, DerivedMesh *dm, const char *uvname, int w, int h, int px, int py, int n_index) @@ -1925,7 +1934,7 @@ static int dynamicPaint_findNeighbourPixel(PaintUVPoint *tempPoints, DerivedMesh * and faster/simplier than including possible face tip point links) */ - int x,y; + int x, y; PaintUVPoint *tPoint = NULL; PaintUVPoint *cPoint = NULL; @@ -2121,7 +2130,7 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface) 0.4f, -0.2f, -0.4f, 0.3f}; int ty; - int w,h; + int w, h; int numOfFaces; char uvname[MAX_CUSTOMDATA_LAYER_NAME]; int active_points = 0; @@ -2217,7 +2226,7 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface) short isInside = 0; /* if point is inside a uv face */ float d1[2], d2[2], d3[2], point[5][2]; - float dot00,dot01,dot02,dot11,dot12, invDenom, u,v; + float dot00, dot01, dot02, dot11, dot12, invDenom, u, v; /* Init per pixel settings */ tPoint->face_index = -1; @@ -2258,7 +2267,7 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface) if (faceBB[i].max[1] < (point[sample][1])) continue; /* Calculate point inside a triangle check - * for uv0,1,2 */ + * for uv0, 1, 2 */ sub_v2_v2v2(d1, tface[i].uv[2], tface[i].uv[0]); // uv2 - uv0 sub_v2_v2v2(d2, tface[i].uv[1], tface[i].uv[0]); // uv1 - uv0 sub_v2_v2v2(d3, point[sample], tface[i].uv[0]); // point - uv0 @@ -2358,7 +2367,7 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface) /* If point isn't't on canvas mesh */ if (tPoint->face_index == -1) { int u_min, u_max, v_min, v_max; - int u,v, ind; + int u, v, ind; float point[2]; /* get loop area */ @@ -2696,7 +2705,7 @@ static void dynamicPaint_updateBrushMaterials(Object *brushOb, Material *ui_mat, if (tot) { bMats->ob_mats = MEM_callocN(sizeof(Material*)*(tot), "BrushMaterials"); for (i=0; i<tot; i++) { - bMats->ob_mats[i] = RE_init_sample_material(give_current_material(brushOb,(i+1)), scene); + bMats->ob_mats[i] = RE_init_sample_material(give_current_material(brushOb, (i+1)), scene); } } bMats->tot = tot; @@ -3189,7 +3198,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, if (brush->flags & MOD_DPAINT_PROX_PROJECT && brush->collision != MOD_DPAINT_COL_VOLUME) { mul_v3_fl(avg_brushNor, 1.0f/(float)numOfVerts); /* instead of null vector use positive z */ - if (!(MIN3(avg_brushNor[0],avg_brushNor[1],avg_brushNor[2]))) + if (!(MIN3(avg_brushNor[0], avg_brushNor[1], avg_brushNor[2]))) avg_brushNor[2] = 1.0f; else normalize_v3(avg_brushNor); @@ -3278,7 +3287,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, float dot; if (quad) {v2=mface[hit.index].v3; v3=mface[hit.index].v4;} - normal_tri_v3( hit.no, mvert[v1].co, mvert[v2].co, mvert[v3].co); + normal_tri_v3(hit.no, mvert[v1].co, mvert[v2].co, mvert[v3].co); dot = ray_dir[0]*hit.no[0] + ray_dir[1]*hit.no[1] + ray_dir[2]*hit.no[2]; /* If ray and hit face normal are facing same direction @@ -3402,7 +3411,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, /* velocity brush, only do on main sample */ if (brush->flags & MOD_DPAINT_USES_VELOCITY && ss==0 && brushVelocity) { - int v1,v2,v3; + int v1, v2, v3; float weights[4]; float brushPointVelocity[3]; float velocity[3]; @@ -3424,10 +3433,10 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, * todo: perhaps implement something that handles volume movement as well */ /* interpolate vertex speed vectors to get hit point velocity */ - interp_v3_v3v3v3( brushPointVelocity, - brushVelocity[v1].v, - brushVelocity[v2].v, - brushVelocity[v3].v, weights); + interp_v3_v3v3v3(brushPointVelocity, + brushVelocity[v1].v, + brushVelocity[v2].v, + brushVelocity[v3].v, weights); /* substract canvas point velocity */ if (bData->velocity) { @@ -3888,7 +3897,7 @@ static void dynamicPaint_prepareAdjacencyData(DynamicPaintSurface *surface, int if ((!surface_usesAdjDistance(surface) && !force_init) || !sData->adj_data) return; if (bData->bNeighs) MEM_freeN(bData->bNeighs); - bNeighs = bData->bNeighs = MEM_mallocN(sData->adj_data->total_targets*sizeof(struct BakeAdjPoint),"PaintEffectBake"); + bNeighs = bData->bNeighs = MEM_mallocN(sData->adj_data->total_targets*sizeof(struct BakeAdjPoint), "PaintEffectBake"); if (!bNeighs) return; #pragma omp parallel for schedule(static) @@ -4662,10 +4671,11 @@ static int dynamicPaint_generateBakeData(DynamicPaintSurface *surface, Scene *sc /* per sample coordinates */ for (ss=0; ss<bData->s_num[index]; ss++) { - interp_v3_v3v3v3( bData->realCoord[bData->s_pos[index]+ss].v, - canvas_verts[tPoint->v1].v, - canvas_verts[tPoint->v2].v, - canvas_verts[tPoint->v3].v, f_data->barycentricWeights[index*bData->s_num[index]+ss].v); + interp_v3_v3v3v3(bData->realCoord[bData->s_pos[index]+ss].v, + canvas_verts[tPoint->v1].v, + canvas_verts[tPoint->v2].v, + canvas_verts[tPoint->v3].v, + f_data->barycentricWeights[index * bData->s_num[index] + ss].v); } /* Calculate current pixel surface normal */ @@ -4673,8 +4683,8 @@ static int dynamicPaint_generateBakeData(DynamicPaintSurface *surface, Scene *sc normal_short_to_float_v3(n2, mvert[tPoint->v2].no); normal_short_to_float_v3(n3, mvert[tPoint->v3].no); - interp_v3_v3v3v3( bData->bNormal[index].invNorm, - n1, n2, n3, f_data->barycentricWeights[index*bData->s_num[index]].v); + interp_v3_v3v3v3(bData->bNormal[index].invNorm, + n1, n2, n3, f_data->barycentricWeights[index*bData->s_num[index]].v); mul_mat3_m4_v3(ob->obmat, bData->bNormal[index].invNorm); normalize_v3(bData->bNormal[index].invNorm); negate_v3(bData->bNormal[index].invNorm); diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c index 263f89a363e..428dc176e1d 100644 --- a/source/blender/blenkernel/intern/editderivedmesh.c +++ b/source/blender/blenkernel/intern/editderivedmesh.c @@ -150,8 +150,7 @@ static void BMEdit_RecalcTessellation_intern(BMEditMesh *tm) #endif - f = BM_iter_new(&iter, bm, BM_FACES_OF_MESH, NULL); - for ( ; f; f=BM_iter_step(&iter)) { + BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) { /*don't consider two-edged faces*/ if (f->len < 3) { /* do nothing */ @@ -197,18 +196,18 @@ static void BMEdit_RecalcTessellation_intern(BMEditMesh *tm) ScanFillFace *efa; int totfilltri; - BLI_begin_edgefill(&sf_ctx); + BLI_scanfill_begin(&sf_ctx); /*scanfill time*/ l = BM_iter_new(&liter, bm, BM_LOOPS_OF_FACE, f); for (j=0; l; l=BM_iter_step(&liter), j++) { /*mark order*/ BM_elem_index_set(l, j); /* set_loop */ - v = BLI_addfillvert(&sf_ctx, l->v->co); + v = BLI_scanfill_vert_add(&sf_ctx, l->v->co); v->tmp.p = l; if (lastv) { - /* e = */ BLI_addfilledge(&sf_ctx, lastv, v); + /* e = */ BLI_scanfill_edge_add(&sf_ctx, lastv, v); } lastv = v; @@ -216,9 +215,9 @@ static void BMEdit_RecalcTessellation_intern(BMEditMesh *tm) } /*complete the loop*/ - BLI_addfilledge(&sf_ctx, firstv, v); + BLI_scanfill_edge_add(&sf_ctx, firstv, v); - totfilltri = BLI_edgefill_ex(&sf_ctx, FALSE, f->no); + totfilltri = BLI_scanfill_calc_ex(&sf_ctx, FALSE, f->no); BLI_array_grow_items(looptris, totfilltri); for (efa = sf_ctx.fillfacebase.first; efa; efa=efa->next) { @@ -236,7 +235,7 @@ static void BMEdit_RecalcTessellation_intern(BMEditMesh *tm) i += 1; } - BLI_end_edgefill(&sf_ctx); + BLI_scanfill_end(&sf_ctx); } } @@ -357,17 +356,18 @@ static void emDM_foreachMappedVert( void (*func)(void *userData, int index, const float co[3], const float no_f[3], const short no_s[3]), void *userData) { - EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm; + EditDerivedBMesh *bmdm= (EditDerivedBMesh *)dm; BMVert *eve; BMIter iter; int i; - eve = BM_iter_new(&iter, bmdm->tc->bm, BM_VERTS_OF_MESH, NULL); - for (i=0; eve; i++, eve=BM_iter_step(&iter)) { - if (bmdm->vertexCos) { + if (bmdm->vertexCos) { + BM_ITER_MESH_INDEX (eve, &iter, bmdm->tc->bm, BM_VERTS_OF_MESH, i) { func(userData, i, bmdm->vertexCos[i], bmdm->vertexNos[i], NULL); } - else { + } + else { + BM_ITER_MESH_INDEX (eve, &iter, bmdm->tc->bm, BM_VERTS_OF_MESH, i) { func(userData, i, eve->co, eve->no, NULL); } } @@ -377,7 +377,7 @@ static void emDM_foreachMappedEdge( void (*func)(void *userData, int index, const float v0co[3], const float v1co[3]), void *userData) { - EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm; + EditDerivedBMesh *bmdm= (EditDerivedBMesh *)dm; BMEdge *eed; BMIter iter; int i; @@ -387,14 +387,14 @@ static void emDM_foreachMappedEdge( BM_mesh_elem_index_ensure(bmdm->tc->bm, BM_VERT); eed = BM_iter_new(&iter, bmdm->tc->bm, BM_EDGES_OF_MESH, NULL); - for (i=0; eed; i++,eed=BM_iter_step(&iter)) + for (i=0; eed; i++, eed=BM_iter_step(&iter)) func(userData, i, bmdm->vertexCos[BM_elem_index_get(eed->v1)], bmdm->vertexCos[BM_elem_index_get(eed->v2)]); } else { eed = BM_iter_new(&iter, bmdm->tc->bm, BM_EDGES_OF_MESH, NULL); - for (i=0; eed; i++,eed=BM_iter_step(&iter)) + for (i=0; eed; i++, eed=BM_iter_step(&iter)) func(userData, i, eed->v1->co, eed->v2->co); } } @@ -404,7 +404,7 @@ static void emDM_drawMappedEdges( DMSetDrawOptions setDrawOptions, void *userData) { - EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm; + EditDerivedBMesh *bmdm= (EditDerivedBMesh *)dm; BMEdge *eed; BMIter iter; int i; @@ -415,7 +415,7 @@ static void emDM_drawMappedEdges( glBegin(GL_LINES); eed = BM_iter_new(&iter, bmdm->tc->bm, BM_EDGES_OF_MESH, NULL); - for (i=0; eed; i++,eed=BM_iter_step(&iter)) { + for (i=0; eed; i++, eed=BM_iter_step(&iter)) { if (!setDrawOptions || (setDrawOptions(userData, i) != DM_DRAW_OPTION_SKIP)) { glVertex3fv(bmdm->vertexCos[BM_elem_index_get(eed->v1)]); glVertex3fv(bmdm->vertexCos[BM_elem_index_get(eed->v2)]); @@ -426,7 +426,7 @@ static void emDM_drawMappedEdges( else { glBegin(GL_LINES); eed = BM_iter_new(&iter, bmdm->tc->bm, BM_EDGES_OF_MESH, NULL); - for (i=0; eed; i++,eed=BM_iter_step(&iter)) { + for (i=0; eed; i++, eed=BM_iter_step(&iter)) { if (!setDrawOptions || (setDrawOptions(userData, i) != DM_DRAW_OPTION_SKIP)) { glVertex3fv(eed->v1->co); glVertex3fv(eed->v2->co); @@ -449,7 +449,7 @@ static void emDM_drawMappedEdgesInterp( DMSetDrawInterpOptions setDrawInterpOptions, void *userData) { - EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm; + EditDerivedBMesh *bmdm= (EditDerivedBMesh *)dm; BMEdge *eed; BMIter iter; int i; @@ -460,7 +460,7 @@ static void emDM_drawMappedEdgesInterp( glBegin(GL_LINES); eed = BM_iter_new(&iter, bmdm->tc->bm, BM_EDGES_OF_MESH, NULL); - for (i=0; eed; i++,eed=BM_iter_step(&iter)) { + for (i=0; eed; i++, eed=BM_iter_step(&iter)) { if (!setDrawOptions || (setDrawOptions(userData, i) != DM_DRAW_OPTION_SKIP)) { setDrawInterpOptions(userData, i, 0.0); glVertex3fv(bmdm->vertexCos[BM_elem_index_get(eed->v1)]); @@ -473,7 +473,7 @@ static void emDM_drawMappedEdgesInterp( else { glBegin(GL_LINES); eed = BM_iter_new(&iter, bmdm->tc->bm, BM_EDGES_OF_MESH, NULL); - for (i=0; eed; i++,eed=BM_iter_step(&iter)) { + for (i=0; eed; i++, eed=BM_iter_step(&iter)) { if (!setDrawOptions || (setDrawOptions(userData, i) != DM_DRAW_OPTION_SKIP)) { setDrawInterpOptions(userData, i, 0.0); glVertex3fv(eed->v1->co); @@ -487,7 +487,7 @@ static void emDM_drawMappedEdgesInterp( static void emDM_drawUVEdges(DerivedMesh *dm) { - EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm; + EditDerivedBMesh *bmdm= (EditDerivedBMesh *)dm; BMEditMesh *em = bmdm->tc; BMFace *efa; BMIter iter; @@ -557,7 +557,7 @@ static void emDM_foreachMappedFaceCenter( void (*func)(void *userData, int index, const float co[3], const float no[3]), void *userData) { - EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm; + EditDerivedBMesh *bmdm= (EditDerivedBMesh *)dm; float (*polyNos)[3] = NULL; BMFace *efa; BMIter iter; @@ -572,8 +572,7 @@ static void emDM_foreachMappedFaceCenter( BLI_assert(polyNos != NULL); } - efa = BM_iter_new(&iter, bmdm->tc->bm, BM_FACES_OF_MESH, NULL); - for (i=0; efa; efa=BM_iter_step(&iter), i++) { + BM_ITER_MESH_INDEX (efa, &iter, bmdm->tc->bm, BM_FACES_OF_MESH, i) { emDM__calcFaceCent(bmdm->tc->bm, efa, cent, bmdm->vertexCos); func(userData, i, cent, polyNos ? polyNos[i] : efa->no); } @@ -587,18 +586,18 @@ static void emDM_drawMappedFaces( void *userData, DMDrawFlag flag) { - EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm; + EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm; BMFace *efa; - struct BMLoop *(*looptris)[3]= bmdm->tc->looptris; - const int tottri= bmdm->tc->tottri; - const int lasttri= tottri - 1; /* compare agasint this a lot */ + struct BMLoop *(*looptris)[3] = bmdm->tc->looptris; + const int tottri = bmdm->tc->tottri; + const int lasttri = tottri - 1; /* compare agasint this a lot */ DMDrawOption draw_option; int i, flush; - const int skip_normals= !glIsEnabled(GL_LIGHTING); /* could be passed as an arg */ + const int skip_normals = !glIsEnabled(GL_LIGHTING); /* could be passed as an arg */ /* GL_ZERO is used to detect if drawing has started or not */ - GLenum poly_prev= GL_ZERO; - GLenum shade_prev= GL_ZERO; + GLenum poly_prev = GL_ZERO; + GLenum shade_prev = GL_ZERO; (void)setMaterial; /* UNUSED */ @@ -607,29 +606,29 @@ static void emDM_drawMappedFaces( if (bmdm->vertexCos) { /* add direct access */ - float (*vertexCos)[3]= bmdm->vertexCos; - float (*vertexNos)[3]= bmdm->vertexNos; - float (*polyNos)[3]= bmdm->polyNos; + float (*vertexCos)[3] = bmdm->vertexCos; + float (*vertexNos)[3] = bmdm->vertexNos; + float (*polyNos)[3] = bmdm->polyNos; // int *triPolyMap= bmdm->triPolyMap; BM_mesh_elem_index_ensure(bmdm->tc->bm, BM_VERT | BM_FACE); - for (i=0; i < tottri; i++) { + for (i = 0; i < tottri; i++) { BMLoop **l = looptris[i]; int drawSmooth; efa = l[0]->f; - drawSmooth= (flag & DM_DRAW_ALWAYS_SMOOTH) ? 1 : BM_elem_flag_test(efa, BM_ELEM_SMOOTH); + drawSmooth = (flag & DM_DRAW_ALWAYS_SMOOTH) ? 1 : BM_elem_flag_test(efa, BM_ELEM_SMOOTH); draw_option = (!setDrawOptions ? DM_DRAW_OPTION_NORMAL : setDrawOptions(userData, BM_elem_index_get(efa))); if (draw_option != DM_DRAW_OPTION_SKIP) { - const GLenum poly_type= GL_TRIANGLES; /* BMESH NOTE, this is odd but keep it for now to match trunk */ + const GLenum poly_type = GL_TRIANGLES; /* BMESH NOTE, this is odd but keep it for now to match trunk */ if (draw_option == DM_DRAW_OPTION_STIPPLE) { /* enabled with stipple */ if (poly_prev != GL_ZERO) glEnd(); - poly_prev= GL_ZERO; /* force glBegin */ + poly_prev = GL_ZERO; /* force glBegin */ glEnable(GL_POLYGON_STIPPLE); glPolygonStipple(stipple_quarttone); @@ -638,22 +637,22 @@ static void emDM_drawMappedFaces( if (skip_normals) { if (poly_type != poly_prev) { if (poly_prev != GL_ZERO) glEnd(); - glBegin((poly_prev= poly_type)); /* BMesh: will always be GL_TRIANGLES */ + glBegin((poly_prev = poly_type)); /* BMesh: will always be GL_TRIANGLES */ } glVertex3fv(vertexCos[BM_elem_index_get(l[0]->v)]); glVertex3fv(vertexCos[BM_elem_index_get(l[1]->v)]); glVertex3fv(vertexCos[BM_elem_index_get(l[2]->v)]); } else { - const GLenum shade_type= drawSmooth ? GL_SMOOTH : GL_FLAT; + const GLenum shade_type = drawSmooth ? GL_SMOOTH : GL_FLAT; if (shade_type != shade_prev) { if (poly_prev != GL_ZERO) glEnd(); - glShadeModel((shade_prev= shade_type)); /* same as below but switch shading */ - glBegin((poly_prev= poly_type)); /* BMesh: will always be GL_TRIANGLES */ + glShadeModel((shade_prev = shade_type)); /* same as below but switch shading */ + glBegin((poly_prev = poly_type)); /* BMesh: will always be GL_TRIANGLES */ } if (poly_type != poly_prev) { if (poly_prev != GL_ZERO) glEnd(); - glBegin((poly_prev= poly_type)); /* BMesh: will always be GL_TRIANGLES */ + glBegin((poly_prev = poly_type)); /* BMesh: will always be GL_TRIANGLES */ } if (!drawSmooth) { @@ -672,13 +671,13 @@ static void emDM_drawMappedFaces( } } - flush= (draw_option == DM_DRAW_OPTION_STIPPLE); + flush = (draw_option == DM_DRAW_OPTION_STIPPLE); if (!skip_normals && !flush && (i != lasttri)) - flush|= efa->mat_nr != looptris[i + 1][0]->f->mat_nr; /* TODO, make this neater */ + flush |= efa->mat_nr != looptris[i + 1][0]->f->mat_nr; /* TODO, make this neater */ if (flush) { glEnd(); - poly_prev= GL_ZERO; /* force glBegin */ + poly_prev = GL_ZERO; /* force glBegin */ glDisable(GL_POLYGON_STIPPLE); } @@ -699,11 +698,11 @@ static void emDM_drawMappedFaces( DM_DRAW_OPTION_NORMAL : setDrawOptions(userData, BM_elem_index_get(efa))); if (draw_option != DM_DRAW_OPTION_SKIP) { - const GLenum poly_type= GL_TRIANGLES; /* BMESH NOTE, this is odd but keep it for now to match trunk */ + const GLenum poly_type = GL_TRIANGLES; /* BMESH NOTE, this is odd but keep it for now to match trunk */ if (draw_option == DM_DRAW_OPTION_STIPPLE) { /* enabled with stipple */ if (poly_prev != GL_ZERO) glEnd(); - poly_prev= GL_ZERO; /* force glBegin */ + poly_prev = GL_ZERO; /* force glBegin */ glEnable(GL_POLYGON_STIPPLE); glPolygonStipple(stipple_quarttone); @@ -712,22 +711,22 @@ static void emDM_drawMappedFaces( if (skip_normals) { if (poly_type != poly_prev) { if (poly_prev != GL_ZERO) glEnd(); - glBegin((poly_prev= poly_type)); /* BMesh: will always be GL_TRIANGLES */ + glBegin((poly_prev = poly_type)); /* BMesh: will always be GL_TRIANGLES */ } glVertex3fv(l[0]->v->co); glVertex3fv(l[1]->v->co); glVertex3fv(l[2]->v->co); } else { - const GLenum shade_type= drawSmooth ? GL_SMOOTH : GL_FLAT; + const GLenum shade_type = drawSmooth ? GL_SMOOTH : GL_FLAT; if (shade_type != shade_prev) { if (poly_prev != GL_ZERO) glEnd(); - glShadeModel((shade_prev= shade_type)); /* same as below but switch shading */ - glBegin((poly_prev= poly_type)); /* BMesh: will always be GL_TRIANGLES */ + glShadeModel((shade_prev = shade_type)); /* same as below but switch shading */ + glBegin((poly_prev = poly_type)); /* BMesh: will always be GL_TRIANGLES */ } if (poly_type != poly_prev) { if (poly_prev != GL_ZERO) glEnd(); - glBegin((poly_prev= poly_type)); /* BMesh: will always be GL_TRIANGLES */ + glBegin((poly_prev = poly_type)); /* BMesh: will always be GL_TRIANGLES */ } if (!drawSmooth) { @@ -746,9 +745,9 @@ static void emDM_drawMappedFaces( } } - flush= (draw_option == DM_DRAW_OPTION_STIPPLE); + flush = (draw_option == DM_DRAW_OPTION_STIPPLE); if (!skip_normals && !flush && (i != lasttri)) { - flush|= efa->mat_nr != looptris[i + 1][0]->f->mat_nr; /* TODO, make this neater */ + flush |= efa->mat_nr != looptris[i + 1][0]->f->mat_nr; /* TODO, make this neater */ } if (flush) { @@ -766,7 +765,7 @@ static void emDM_drawMappedFaces( } static void bmdm_get_tri_tex(BMesh *bm, BMLoop **ls, MLoopUV *luv[3], MLoopCol *lcol[3], - int has_uv, int has_col) + int has_uv, int has_col) { if (has_uv) { luv[0] = CustomData_bmesh_get(&bm->ldata, ls[0]->head.data, CD_MLOOPUV); @@ -790,11 +789,11 @@ static void emDM_drawFacesTex_common( DMCompareDrawOptions compareDrawOptions, void *userData) { - EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm; + EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm; BMEditMesh *em = bmdm->tc; - BMesh *bm= bmdm->tc->bm; - float (*vertexCos)[3]= bmdm->vertexCos; - float (*vertexNos)[3]= bmdm->vertexNos; + BMesh *bm = bmdm->tc->bm; + float (*vertexCos)[3] = bmdm->vertexCos; + float (*vertexNos)[3] = bmdm->vertexNos; BMFace *efa; MLoopUV *luv[3], dummyluv = {{0}}; MLoopCol *lcol[3] = {NULL}, dummylcol = {0}; @@ -815,13 +814,12 @@ static void emDM_drawFacesTex_common( if (vertexCos) { BM_mesh_elem_index_ensure(bm, BM_VERT); - glBegin(GL_TRIANGLES); - for (i=0; i<em->tottri; i++) { + for (i = 0; i < em->tottri; i++) { BMLoop **ls = em->looptris[i]; - MTexPoly *tp= has_uv ? CustomData_bmesh_get(&bm->pdata, ls[0]->f->head.data, CD_MTEXPOLY) : NULL; + MTexPoly *tp = has_uv ? CustomData_bmesh_get(&bm->pdata, ls[0]->f->head.data, CD_MTEXPOLY) : NULL; MTFace mtf = {{{0}}}; /*unsigned char *cp= NULL;*/ /*UNUSED*/ - int drawSmooth= BM_elem_flag_test(ls[0]->f, BM_ELEM_SMOOTH); + int drawSmooth = BM_elem_flag_test(ls[0]->f, BM_ELEM_SMOOTH); DMDrawOption draw_option; efa = ls[0]->f; @@ -831,14 +829,15 @@ static void emDM_drawFacesTex_common( } if (drawParams) - draw_option= drawParams(&mtf, has_vcol, efa->mat_nr); + draw_option = drawParams(&mtf, has_vcol, efa->mat_nr); else if (drawParamsMapped) - draw_option= drawParamsMapped(userData, BM_elem_index_get(efa)); + draw_option = drawParamsMapped(userData, BM_elem_index_get(efa)); else - draw_option= DM_DRAW_OPTION_NORMAL; + draw_option = DM_DRAW_OPTION_NORMAL; if (draw_option != DM_DRAW_OPTION_SKIP) { + glBegin(GL_TRIANGLES); if (!drawSmooth) { glNormal3fv(bmdm->polyNos[BM_elem_index_get(efa)]); @@ -880,19 +879,19 @@ static void emDM_drawFacesTex_common( glNormal3fv(vertexNos[BM_elem_index_get(ls[2]->v)]); glVertex3fv(vertexCos[BM_elem_index_get(ls[2]->v)]); } + glEnd(); } } - glEnd(); } else { BM_mesh_elem_index_ensure(bm, BM_VERT); - for (i=0; i<em->tottri; i++) { + for (i = 0; i < em->tottri; i++) { BMLoop **ls = em->looptris[i]; - MTexPoly *tp= has_uv ? CustomData_bmesh_get(&bm->pdata, ls[0]->f->head.data, CD_MTEXPOLY) : NULL; + MTexPoly *tp = has_uv ? CustomData_bmesh_get(&bm->pdata, ls[0]->f->head.data, CD_MTEXPOLY) : NULL; MTFace mtf = {{{0}}}; /*unsigned char *cp= NULL;*/ /*UNUSED*/ - int drawSmooth= BM_elem_flag_test(ls[0]->f, BM_ELEM_SMOOTH); + int drawSmooth = BM_elem_flag_test(ls[0]->f, BM_ELEM_SMOOTH); DMDrawOption draw_option; efa = ls[0]->f; @@ -902,11 +901,11 @@ static void emDM_drawFacesTex_common( } if (drawParams) - draw_option= drawParams(&mtf, has_vcol, efa->mat_nr); + draw_option = drawParams(&mtf, has_vcol, efa->mat_nr); else if (drawParamsMapped) - draw_option= drawParamsMapped(userData, BM_elem_index_get(efa)); + draw_option = drawParamsMapped(userData, BM_elem_index_get(efa)); else - draw_option= DM_DRAW_OPTION_NORMAL; + draw_option = DM_DRAW_OPTION_NORMAL; if (draw_option != DM_DRAW_OPTION_SKIP) { @@ -990,11 +989,11 @@ static void emDM_drawMappedFacesGLSL( DMSetDrawOptions setDrawOptions, void *userData) { - EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm; - BMesh *bm= bmdm->tc->bm; + EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm; + BMesh *bm = bmdm->tc->bm; BMEditMesh *em = bmdm->tc; - float (*vertexCos)[3]= bmdm->vertexCos; - float (*vertexNos)[3]= bmdm->vertexNos; + float (*vertexCos)[3] = bmdm->vertexCos; + float (*vertexNos)[3] = bmdm->vertexNos; BMFace *efa; BMLoop **ltri; DMVertexAttribs attribs; @@ -1014,30 +1013,30 @@ static void emDM_drawMappedFacesGLSL( #define PASSATTRIB(loop, eve, vert) { \ if (attribs.totorco) { \ float *orco = attribs.orco.array[BM_elem_index_get(eve)]; \ - glVertexAttrib3fvARB(attribs.orco.glIndex, orco); \ + glVertexAttrib3fvARB(attribs.orco.gl_index, orco); \ } \ for (b = 0; b < attribs.tottface; b++) { \ MLoopUV *_luv = CustomData_bmesh_get_n(&bm->ldata, loop->head.data, CD_MLOOPUV, b);\ - glVertexAttrib2fvARB(attribs.tface[b].glIndex, _luv->uv); \ + glVertexAttrib2fvARB(attribs.tface[b].gl_index, _luv->uv); \ } \ for (b = 0; b < attribs.totmcol; b++) { \ MLoopCol *_cp = CustomData_bmesh_get_n(&bm->ldata, loop->head.data, CD_MLOOPCOL, b);\ GLubyte _col[4]; \ _col[0]= _cp->b; _col[1]= _cp->g; _col[2]= _cp->r; _col[3]= _cp->a; \ - glVertexAttrib4ubvARB(attribs.mcol[b].glIndex, _col); \ + glVertexAttrib4ubvARB(attribs.mcol[b].gl_index, _col); \ } \ if (attribs.tottang) { \ float *tang = attribs.tang.array[i*4 + vert]; \ - glVertexAttrib3fvARB(attribs.tang.glIndex, tang); \ + glVertexAttrib3fvARB(attribs.tang.gl_index, tang); \ } \ } - for (i=0, ltri=em->looptris[0]; i<em->tottri; i++, ltri += 3) { + for (i = 0, ltri = em->looptris[0]; i < em->tottri; i++, ltri += 3) { int drawSmooth; efa = ltri[0]->f; - drawSmooth= BM_elem_flag_test(efa, BM_ELEM_SMOOTH); + drawSmooth = BM_elem_flag_test(efa, BM_ELEM_SMOOTH); if (setDrawOptions && (setDrawOptions(userData, BM_elem_index_get(efa)) == DM_DRAW_OPTION_SKIP)) continue; @@ -1116,14 +1115,14 @@ static void emDM_drawMappedFacesMat( void (*setMaterial)(void *userData, int, void *attribs), int (*setFace)(void *userData, int index), void *userData) { - EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm; - BMesh *bm= bmdm->tc->bm; + EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm; + BMesh *bm = bmdm->tc->bm; BMEditMesh *em = bmdm->tc; - float (*vertexCos)[3]= bmdm->vertexCos; - float (*vertexNos)[3]= bmdm->vertexNos; + float (*vertexCos)[3] = bmdm->vertexCos; + float (*vertexNos)[3] = bmdm->vertexNos; BMFace *efa; BMLoop **ltri; - DMVertexAttribs attribs= {{{0}}}; + DMVertexAttribs attribs = {{{0}}}; GPUVertexAttribs gattribs; int i, b, matnr, new_matnr; @@ -1132,36 +1131,36 @@ static void emDM_drawMappedFacesMat( /* always use smooth shading even for flat faces, else vertex colors wont interpolate */ glShadeModel(GL_SMOOTH); - BM_mesh_elem_index_ensure(bm, BM_VERT|BM_FACE); + BM_mesh_elem_index_ensure(bm, BM_VERT | BM_FACE); #define PASSATTRIB(loop, eve, vert) { \ if (attribs.totorco) { \ float *orco = attribs.orco.array[BM_elem_index_get(eve)]; \ - if (attribs.orco.glTexco) \ + if (attribs.orco.gl_texco) \ glTexCoord3fv(orco); \ else \ - glVertexAttrib3fvARB(attribs.orco.glIndex, orco); \ + glVertexAttrib3fvARB(attribs.orco.gl_index, orco); \ } \ for (b = 0; b < attribs.tottface; b++) { \ MLoopUV *_luv = CustomData_bmesh_get_n(&bm->ldata, loop->head.data, CD_MLOOPUV, b);\ - if (attribs.tface[b].glTexco) \ + if (attribs.tface[b].gl_texco) \ glTexCoord2fv(_luv->uv); \ else \ - glVertexAttrib2fvARB(attribs.tface[b].glIndex, _luv->uv); \ + glVertexAttrib2fvARB(attribs.tface[b].gl_index, _luv->uv); \ } \ for (b = 0; b < attribs.totmcol; b++) { \ MLoopCol *_cp = CustomData_bmesh_get_n(&bm->ldata, loop->head.data, CD_MLOOPCOL, b);\ GLubyte _col[4]; \ _col[0]= _cp->b; _col[1]= _cp->g; _col[2]= _cp->r; _col[3]= _cp->a; \ - glVertexAttrib4ubvARB(attribs.mcol[b].glIndex, _col); \ + glVertexAttrib4ubvARB(attribs.mcol[b].gl_index, _col); \ } \ if (attribs.tottang) { \ float *tang = attribs.tang.array[i*4 + vert]; \ - glVertexAttrib4fvARB(attribs.tang.glIndex, tang); \ + glVertexAttrib4fvARB(attribs.tang.gl_index, tang); \ } \ } - for (i=0, ltri=em->looptris[0]; i<em->tottri; i++, ltri += 3) { + for (i = 0, ltri = em->looptris[0]; i < em->tottri; i++, ltri += 3) { int drawSmooth; efa = ltri[0]->f; @@ -1235,18 +1234,19 @@ static void emDM_drawMappedFacesMat( static void emDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3]) { - EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm; + EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm; BMVert *eve; BMIter iter; int i; if (bmdm->tc->bm->totvert) { - eve = BM_iter_new(&iter, bmdm->tc->bm, BM_VERTS_OF_MESH, NULL); - for (i=0; eve; eve=BM_iter_step(&iter), i++) { - if (bmdm->vertexCos) { + if (bmdm->vertexCos) { + BM_ITER_MESH_INDEX (eve, &iter, bmdm->tc->bm, BM_VERTS_OF_MESH, i) { DO_MINMAX(bmdm->vertexCos[i], min_r, max_r); } - else { + } + else { + BM_ITER_MESH (eve, &iter, bmdm->tc->bm, BM_VERTS_OF_MESH) { DO_MINMAX(eve->co, min_r, max_r); } } @@ -1258,35 +1258,35 @@ static void emDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3]) } static int emDM_getNumVerts(DerivedMesh *dm) { - EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm; + EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm; return bmdm->tc->bm->totvert; } static int emDM_getNumEdges(DerivedMesh *dm) { - EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm; + EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm; return bmdm->tc->bm->totedge; } static int emDM_getNumTessFaces(DerivedMesh *dm) { - EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm; + EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm; return bmdm->tc->tottri; } static int emDM_getNumLoops(DerivedMesh *dm) { - EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm; + EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm; return bmdm->tc->bm->totloop; } static int emDM_getNumPolys(DerivedMesh *dm) { - EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm; + EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm; return bmdm->tc->bm->totface; } @@ -1413,8 +1413,7 @@ static void emDM_copyEdgeArray(DerivedMesh *dm, MEdge *edge_r) BM_mesh_elem_index_ensure(bm, BM_VERT); - ee = BM_iter_new(&iter, bm, BM_EDGES_OF_MESH, NULL); - for ( ; ee; ee=BM_iter_step(&iter), edge_r++) { + for (ee = BM_iter_new(&iter, bm, BM_EDGES_OF_MESH, NULL); ee; ee = BM_iter_step(&iter), edge_r++) { if (has_bweight) { edge_r->bweight = (unsigned char) (BM_elem_float_data_get(&bm->edata, ee, CD_BWEIGHT)*255.0f); } @@ -1440,7 +1439,7 @@ static void emDM_copyTessFaceArray(DerivedMesh *dm, MFace *face_r) BM_mesh_elem_index_ensure(bm, BM_VERT); - for (i=0; i<bmdm->tc->tottri; i++, face_r++) { + for (i = 0; i < bmdm->tc->tottri; i++, face_r++) { l = bmdm->tc->looptris[i]; ef = l[0]->f; @@ -1499,8 +1498,8 @@ static void emDM_copyPolyArray(DerivedMesh *dm, MPoly *poly_r) static void *emDM_getTessFaceDataArray(DerivedMesh *dm, int type) { - EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm; - BMesh *bm= bmdm->tc->bm; + EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm; + BMesh *bm = bmdm->tc->bm; void *datalayer; datalayer = DM_get_tessface_data_layer(dm, type); @@ -1553,27 +1552,26 @@ static void *emDM_getTessFaceDataArray(DerivedMesh *dm, int type) static void emDM_getVertCos(DerivedMesh *dm, float (*cos_r)[3]) { - EditDerivedBMesh *emdm= (EditDerivedBMesh*) dm; + EditDerivedBMesh *emdm = (EditDerivedBMesh *)dm; BMVert *eve; BMIter iter; int i; - i= 0; - BM_ITER_MESH (eve, &iter, emdm->tc->bm, BM_VERTS_OF_MESH) { - if (emdm->vertexCos) { + if (emdm->vertexCos) { + BM_ITER_MESH_INDEX (eve, &iter, emdm->tc->bm, BM_VERTS_OF_MESH, i) { copy_v3_v3(cos_r[i], emdm->vertexCos[i]); } - else { + } + else { + BM_ITER_MESH_INDEX (eve, &iter, emdm->tc->bm, BM_VERTS_OF_MESH, i) { copy_v3_v3(cos_r[i], eve->co); } - - i++; } } static void emDM_release(DerivedMesh *dm) { - EditDerivedBMesh *bmdm= (EditDerivedBMesh *)dm; + EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm; if (DM_release(dm)) { if (bmdm->vertexCos) { @@ -1690,10 +1688,10 @@ DerivedMesh *getEditDerivedBMesh( DM_add_vert_layer(&bmdm->dm, CD_MDEFORMVERT, CD_CALLOC, NULL); - eve = BM_iter_new(&iter, bmdm->tc->bm, BM_VERTS_OF_MESH, NULL); - for (i=0; eve; eve=BM_iter_step(&iter), i++) + BM_ITER_MESH_INDEX (eve, &iter, bmdm->tc->bm, BM_VERTS_OF_MESH, i) { DM_set_vert_data(&bmdm->dm, i, CD_MDEFORMVERT, CustomData_bmesh_get(&bm->vdata, eve->head.data, CD_MDEFORMVERT)); + } } if (vertexCos) { @@ -1708,16 +1706,13 @@ DerivedMesh *getEditDerivedBMesh( bmdm->vertexNos = MEM_callocN(sizeof(*bmdm->vertexNos) * bm->totvert, "bmdm_vno"); bmdm->polyNos = MEM_mallocN(sizeof(*bmdm->polyNos)*bm->totface, "bmdm_pno"); - i = 0; - BM_ITER_MESH (efa, &fiter, bm, BM_FACES_OF_MESH) { + BM_ITER_MESH_INDEX (efa, &fiter, bm, BM_FACES_OF_MESH, i) { BM_elem_index_set(efa, i); /* set_inline */ BM_face_normal_update_vcos(bm, efa, bmdm->polyNos[i], (float const (*)[3])vertexCos); - i++; } bm->elem_index_dirty &= ~BM_FACE; - eve=BM_iter_new(&viter, bm, BM_VERTS_OF_MESH, NULL); - for (i=0; eve; eve=BM_iter_step(&viter), i++) { + BM_ITER_MESH_INDEX (eve, &viter, bm, BM_VERTS_OF_MESH, i) { float *no = bmdm->vertexNos[i]; BM_ITER_ELEM (efa, &fiter, eve, BM_FACES_OF_VERT) { add_v3_v3(no, bmdm->polyNos[BM_elem_index_get(efa)]); @@ -1725,14 +1720,14 @@ DerivedMesh *getEditDerivedBMesh( /* following Mesh convention; we use vertex coordinate itself * for normal in this case */ - if (normalize_v3(no)==0.0) { + if (normalize_v3(no) == 0.0f) { copy_v3_v3(no, vertexCos[i]); normalize_v3(no); } } } - return (DerivedMesh*) bmdm; + return (DerivedMesh *)bmdm; } /** diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index c275d4ef0ac..7fb0cf9f0fa 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -756,7 +756,7 @@ static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedP strength= eff->pd->f_strength * efd->falloff; - copy_v3_v3(tex_co,point->loc); + copy_v3_v3(tex_co, point->loc); if (eff->pd->flag & PFIELD_TEX_2D) { float fac=-dot_v3v3(tex_co, efd->nor); @@ -767,7 +767,7 @@ static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedP mul_m4_v3(eff->ob->imat, tex_co); } - hasrgb = multitex_ext(eff->pd->tex, tex_co, NULL,NULL, 0, result); + hasrgb = multitex_ext(eff->pd->tex, tex_co, NULL, NULL, 0, result); if (hasrgb && mode==PFIELD_TEX_RGB) { force[0] = (0.5f - result->tr) * strength; @@ -820,7 +820,7 @@ static void do_physical_effector(EffectorCache *eff, EffectorData *efd, Effected { PartDeflect *pd = eff->pd; RNG *rng = pd->rng; - float force[3]={0,0,0}; + float force[3]={0, 0, 0}; float temp[3]; float fac; float strength = pd->f_strength; @@ -905,9 +905,9 @@ static void do_physical_effector(EffectorCache *eff, EffectorData *efd, Effected else { add_v3_v3v3(temp, efd->vec_to_point2, efd->nor2); } - force[0] = -1.0f + 2.0f * BLI_gTurbulence(pd->f_size, temp[0], temp[1], temp[2], 2,0,2); - force[1] = -1.0f + 2.0f * BLI_gTurbulence(pd->f_size, temp[1], temp[2], temp[0], 2,0,2); - force[2] = -1.0f + 2.0f * BLI_gTurbulence(pd->f_size, temp[2], temp[0], temp[1], 2,0,2); + force[0] = -1.0f + 2.0f * BLI_gTurbulence(pd->f_size, temp[0], temp[1], temp[2], 2, 0, 2); + force[1] = -1.0f + 2.0f * BLI_gTurbulence(pd->f_size, temp[1], temp[2], temp[0], 2, 0, 2); + force[2] = -1.0f + 2.0f * BLI_gTurbulence(pd->f_size, temp[2], temp[0], temp[1], 2, 0, 2); mul_v3_fl(force, strength * efd->falloff); break; case PFIELD_DRAG: @@ -993,7 +993,7 @@ void pdDoEffectors(ListBase *effectors, ListBase *colliders, EffectorWeights *we else if (eff->pd->forcefield == PFIELD_TEXTURE) do_texture_effector(eff, &efd, point, force); else { - float temp1[3]={0,0,0}, temp2[3]; + float temp1[3]={0, 0, 0}, temp2[3]; copy_v3_v3(temp1, force); do_physical_effector(eff, &efd, point, force); diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index e85432581d5..0414d69785f 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -71,7 +71,7 @@ /* ---------------------- Freeing --------------------------- */ /* Frees the F-Curve itself too, so make sure BLI_remlink is called before calling this... */ -void free_fcurve (FCurve *fcu) +void free_fcurve(FCurve *fcu) { if (fcu == NULL) return; @@ -95,7 +95,7 @@ void free_fcurve (FCurve *fcu) } /* Frees a list of F-Curves */ -void free_fcurves (ListBase *list) +void free_fcurves(ListBase *list) { FCurve *fcu, *fcn; @@ -151,7 +151,7 @@ FCurve *copy_fcurve (FCurve *fcu) } /* duplicate a list of F-Curves */ -void copy_fcurves (ListBase *dst, ListBase *src) +void copy_fcurves(ListBase *dst, ListBase *src) { FCurve *dfcu, *sfcu; @@ -270,7 +270,7 @@ FCurve *iter_step_fcurve (FCurve *fcu_iter, const char rna_path[]) * - dataPrefix: i.e. 'pose.bones[' or 'nodes[' * - dataName: name of entity within "" immediately following the prefix */ -int list_find_data_fcurves (ListBase *dst, ListBase *src, const char *dataPrefix, const char *dataName) +int list_find_data_fcurves(ListBase *dst, ListBase *src, const char *dataPrefix, const char *dataName) { FCurve *fcu; int matches = 0; @@ -357,7 +357,7 @@ FCurve *rna_get_fcurve (PointerRNA *ptr, PropertyRNA *prop, int rnaindex, bActio /* Binary search algorithm for finding where to insert BezTriple. (for use by insert_bezt_fcurve) * Returns the index to insert at (data already at that index will be offset if replace is 0) */ -int binarysearch_bezt_index (BezTriple array[], float frame, int arraylen, short *replace) +int binarysearch_bezt_index(BezTriple array[], float frame, int arraylen, short *replace) { int start=0, end=arraylen; int loopbreaker= 0, maxloop= arraylen * 2; @@ -476,8 +476,8 @@ static void get_fcurve_end_keyframes (FCurve *fcu, BezTriple **first, BezTriple /* Calculate the extents of F-Curve's data */ -void calc_fcurve_bounds (FCurve *fcu, float *xmin, float *xmax, float *ymin, float *ymax, - const short do_sel_only) +void calc_fcurve_bounds(FCurve *fcu, float *xmin, float *xmax, float *ymin, float *ymax, + const short do_sel_only) { float xminv=999999999.0f, xmaxv=-999999999.0f; float yminv=999999999.0f, ymaxv=-999999999.0f; @@ -558,8 +558,8 @@ void calc_fcurve_bounds (FCurve *fcu, float *xmin, float *xmax, float *ymin, flo } /* Calculate the extents of F-Curve's keyframes */ -void calc_fcurve_range (FCurve *fcu, float *start, float *end, - const short do_sel_only, const short do_min_length) +void calc_fcurve_range(FCurve *fcu, float *start, float *end, + const short do_sel_only, const short do_min_length) { float min=999999999.0f, max=-999999999.0f; short foundvert= FALSE; @@ -610,7 +610,7 @@ void calc_fcurve_range (FCurve *fcu, float *start, float *end, * Usability of keyframes refers to whether they should be displayed, * and also whether they will have any influence on the final result. */ -short fcurve_are_keyframes_usable (FCurve *fcu) +short fcurve_are_keyframes_usable(FCurve *fcu) { /* F-Curve must exist */ if (fcu == NULL) @@ -671,7 +671,7 @@ short fcurve_are_keyframes_usable (FCurve *fcu) /* Can keyframes be added to F-Curve? * Keyframes can only be added if they are already visible */ -short fcurve_is_keyframable (FCurve *fcu) +short fcurve_is_keyframable(FCurve *fcu) { /* F-Curve's keyframes must be "usable" (i.e. visible + have an effect on final result) */ if (fcurve_are_keyframes_usable(fcu) == 0) @@ -688,7 +688,7 @@ short fcurve_is_keyframable (FCurve *fcu) /* ***************************** Keyframe Column Tools ********************************* */ /* add a BezTriple to a column */ -void bezt_add_to_cfra_elem (ListBase *lb, BezTriple *bezt) +void bezt_add_to_cfra_elem(ListBase *lb, BezTriple *bezt) { CfraElem *ce, *cen; @@ -721,7 +721,7 @@ void bezt_add_to_cfra_elem (ListBase *lb, BezTriple *bezt) /* Basic sampling callback which acts as a wrapper for evaluate_fcurve() * 'data' arg here is unneeded here... */ -float fcurve_samplingcb_evalcurve (FCurve *fcu, void *UNUSED(data), float evaltime) +float fcurve_samplingcb_evalcurve(FCurve *fcu, void *UNUSED(data), float evaltime) { /* assume any interference from drivers on the curve is intended... */ return evaluate_fcurve(fcu, evaltime); @@ -731,7 +731,7 @@ float fcurve_samplingcb_evalcurve (FCurve *fcu, void *UNUSED(data), float evalti /* Main API function for creating a set of sampled curve data, given some callback function * used to retrieve the values to store. */ -void fcurve_store_samples (FCurve *fcu, void *data, int start, int end, FcuSampleFunc sample_cb) +void fcurve_store_samples(FCurve *fcu, void *data, int start, int end, FcuSampleFunc sample_cb) { FPoint *fpt, *new_fpt; int cfra; @@ -775,7 +775,7 @@ void fcurve_store_samples (FCurve *fcu, void *data, int start, int end, FcuSampl /* This function recalculates the handles of an F-Curve * If the BezTriples have been rearranged, sort them first before using this. */ -void calchandles_fcurve (FCurve *fcu) +void calchandles_fcurve(FCurve *fcu) { BezTriple *bezt, *prev, *next; int a= fcu->totvert; @@ -803,7 +803,7 @@ void calchandles_fcurve (FCurve *fcu) BKE_nurb_handle_calc(bezt, prev, next, 1); /* 1==special autohandle */ /* for automatic ease in and out */ - if (ELEM(bezt->h1,HD_AUTO,HD_AUTO_ANIM) && ELEM(bezt->h2,HD_AUTO,HD_AUTO_ANIM)) { + if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM) && ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM)) { /* only do this on first or last beztriple */ if ((a == 0) || (a == fcu->totvert-1)) { /* set both handles to have same horizontal value as keyframe */ @@ -828,7 +828,7 @@ void calchandles_fcurve (FCurve *fcu) * -> Vector handles: become 'nothing' when (one half selected AND other not) * - PHASE 2: recalculate handles */ -void testhandles_fcurve (FCurve *fcu, const short use_handle) +void testhandles_fcurve(FCurve *fcu, const short use_handle) { BezTriple *bezt; unsigned int a; @@ -884,7 +884,7 @@ void testhandles_fcurve (FCurve *fcu, const short use_handle) /* This function sorts BezTriples so that they are arranged in chronological order, * as tools working on F-Curves expect that the BezTriples are in order. */ -void sort_time_fcurve (FCurve *fcu) +void sort_time_fcurve(FCurve *fcu) { short ok= 1; @@ -927,7 +927,7 @@ void sort_time_fcurve (FCurve *fcu) } /* This function tests if any BezTriples are out of order, thus requiring a sort */ -short test_time_fcurve (FCurve *fcu) +short test_time_fcurve(FCurve *fcu) { unsigned int a; @@ -1144,8 +1144,8 @@ static float dvar_eval_rotDiff (ChannelDriver *driver, DriverVar *dvar) // 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}; + 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 @@ -1240,7 +1240,7 @@ static float dvar_eval_transChan (ChannelDriver *driver, DriverVar *dvar) Object *ob= (Object *)dtar_id_ensure_proxy_from(dtar->id); bPoseChannel *pchan; float mat[4][4]; - float oldEul[3] = {0.0f,0.0f,0.0f}; + float oldEul[3] = {0.0f, 0.0f, 0.0f}; short useEulers=0, rotOrder=ROT_MODE_EUL; /* check if this target has valid data */ @@ -1394,7 +1394,7 @@ static DriverVarTypeInfo *get_dvar_typeinfo (int type) /* Driver API --------------------------------- */ /* This frees the driver variable itself */ -void driver_free_variable (ChannelDriver *driver, DriverVar *dvar) +void driver_free_variable(ChannelDriver *driver, DriverVar *dvar) { /* sanity checks */ if (dvar == NULL) @@ -1424,7 +1424,7 @@ void driver_free_variable (ChannelDriver *driver, DriverVar *dvar) } /* Change the type of driver variable */ -void driver_change_variable_type (DriverVar *dvar, int type) +void driver_change_variable_type(DriverVar *dvar, int type) { DriverVarTypeInfo *dvti= get_dvar_typeinfo(type); @@ -1547,7 +1547,7 @@ ChannelDriver *fcurve_copy_driver (ChannelDriver *driver) /* Driver Evaluation -------------------------- */ /* Evaluate a Driver Variable to get a value that contributes to the final */ -float driver_get_variable_value (ChannelDriver *driver, DriverVar *dvar) +float driver_get_variable_value(ChannelDriver *driver, DriverVar *dvar) { DriverVarTypeInfo *dvti; @@ -1656,7 +1656,7 @@ static float evaluate_driver (ChannelDriver *driver, const float evaltime) driver->curval= 0.0f; } else { - /* this evaluates the expression using Python,and returns its result: + /* this evaluates the expression using Python, and returns its result: * - on errors it reports, then returns 0.0f */ driver->curval= BPY_driver_exec(driver, evaltime); @@ -2076,7 +2076,7 @@ static float fcurve_eval_samples (FCurve *fcu, FPoint *fpts, float evaltime) /* Evaluate and return the value of the given F-Curve at the specified frame ("evaltime") * Note: this is also used for drivers */ -float evaluate_fcurve (FCurve *fcu, float evaltime) +float evaluate_fcurve(FCurve *fcu, float evaltime) { float cvalue= 0.0f; float devaltime; @@ -2116,13 +2116,13 @@ float evaluate_fcurve (FCurve *fcu, float evaltime) } /* Calculate the value of the given F-Curve at the given frame, and set its curval */ -void calculate_fcurve (FCurve *fcu, float ctime) +void calculate_fcurve(FCurve *fcu, float ctime) { /* only calculate + set curval (overriding the existing value) if curve has * any data which warrants this... */ - if ( (fcu->totvert) || (fcu->driver && !(fcu->driver->flag & DRIVER_FLAG_INVALID)) || - list_has_suitable_fmodifier(&fcu->modifiers, 0, FMI_TYPE_GENERATE_CURVE) ) + if ((fcu->totvert) || (fcu->driver && !(fcu->driver->flag & DRIVER_FLAG_INVALID)) || + list_has_suitable_fmodifier(&fcu->modifiers, 0, FMI_TYPE_GENERATE_CURVE)) { /* calculate and set curval (evaluates driver too if necessary) */ fcu->curval= evaluate_fcurve(fcu, ctime); diff --git a/source/blender/blenkernel/intern/fluidsim.c b/source/blender/blenkernel/intern/fluidsim.c index a930818dd15..9be599ac66c 100644 --- a/source/blender/blenkernel/intern/fluidsim.c +++ b/source/blender/blenkernel/intern/fluidsim.c @@ -78,7 +78,8 @@ void initElbeemMesh(struct Scene *scene, struct Object *ob, int *tris; dm = mesh_create_derived_index_render(scene, ob, CD_MASK_BAREMESH, modifierIndex); - //dm = mesh_create_derived_no_deform(ob,NULL); + + DM_ensure_tessface(dm); mvert = dm->getVertArray(dm); mface = dm->getTessFaceArray(dm); @@ -86,7 +87,7 @@ void initElbeemMesh(struct Scene *scene, struct Object *ob, totface = dm->getNumTessFaces(dm); *numVertices = totvert; - verts = MEM_callocN( totvert*3*sizeof(float), "elbeemmesh_vertices"); + verts = MEM_callocN(totvert*3*sizeof(float), "elbeemmesh_vertices"); for (i=0; i<totvert; i++) { copy_v3_v3(&verts[i*3], mvert[i].co); if (useGlobalCoords) { mul_m4_v3(ob->obmat, &verts[i*3]); } @@ -98,7 +99,7 @@ void initElbeemMesh(struct Scene *scene, struct Object *ob, if (mface[i].v4) { countTris++; } } *numTriangles = countTris; - tris = MEM_callocN( countTris*3*sizeof(int), "elbeemmesh_triangles"); + tris = MEM_callocN(countTris*3*sizeof(int), "elbeemmesh_triangles"); countTris = 0; for (i=0; i<totface; i++) { int face[4]; @@ -122,3 +123,4 @@ void initElbeemMesh(struct Scene *scene, struct Object *ob, dm->release(dm); } + diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index 0b722aabd4c..92c73b23239 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -1058,7 +1058,7 @@ FModifier *copy_fmodifier (FModifier *src) } /* Duplicate all of the F-Modifiers in the Modifier stacks */ -void copy_fmodifiers (ListBase *dst, ListBase *src) +void copy_fmodifiers(ListBase *dst, ListBase *src) { FModifier *fcm, *srcfcm; @@ -1081,7 +1081,7 @@ void copy_fmodifiers (ListBase *dst, ListBase *src) } /* Remove and free the given F-Modifier from the given stack */ -int remove_fmodifier (ListBase *modifiers, FModifier *fcm) +int remove_fmodifier(ListBase *modifiers, FModifier *fcm) { FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm); @@ -1112,7 +1112,7 @@ int remove_fmodifier (ListBase *modifiers, FModifier *fcm) } /* Remove all of a given F-Curve's modifiers */ -void free_fmodifiers (ListBase *modifiers) +void free_fmodifiers(ListBase *modifiers) { FModifier *fcm, *fmn; @@ -1147,7 +1147,7 @@ FModifier *find_active_fmodifier (ListBase *modifiers) } /* Set the active F-Modifier */ -void set_active_fmodifier (ListBase *modifiers, FModifier *fcm) +void set_active_fmodifier(ListBase *modifiers, FModifier *fcm) { FModifier *fm; @@ -1168,7 +1168,7 @@ void set_active_fmodifier (ListBase *modifiers, FModifier *fcm) * - mtype - type of modifier (if 0, doesn't matter) * - acttype - type of action to perform (if -1, doesn't matter) */ -short list_has_suitable_fmodifier (ListBase *modifiers, int mtype, short acttype) +short list_has_suitable_fmodifier(ListBase *modifiers, int mtype, short acttype) { FModifier *fcm; @@ -1252,7 +1252,7 @@ static float eval_fmodifier_influence (FModifier *fcm, float evaltime) * so nevaltime gets set to whatever the last time-modifying modifier likes... * - we start from the end of the stack, as only the last one matters for now */ -float evaluate_time_fmodifiers (ListBase *modifiers, FCurve *fcu, float cvalue, float evaltime) +float evaluate_time_fmodifiers(ListBase *modifiers, FCurve *fcu, float cvalue, float evaltime) { FModifier *fcm; @@ -1301,7 +1301,7 @@ float evaluate_time_fmodifiers (ListBase *modifiers, FCurve *fcu, float cvalue, /* Evalautes the given set of F-Curve Modifiers using the given data * Should only be called after evaluate_time_fmodifiers() has been called... */ -void evaluate_value_fmodifiers (ListBase *modifiers, FCurve *fcu, float *cvalue, float evaltime) +void evaluate_value_fmodifiers(ListBase *modifiers, FCurve *fcu, float *cvalue, float evaltime) { FModifier *fcm; @@ -1338,7 +1338,7 @@ void evaluate_value_fmodifiers (ListBase *modifiers, FCurve *fcu, float *cvalue, /* Bake modifiers for given F-Curve to curve sample data, in the frame range defined * by start and end (inclusive). */ -void fcurve_bake_modifiers (FCurve *fcu, int start, int end) +void fcurve_bake_modifiers(FCurve *fcu, int start, int end) { ChannelDriver *driver; diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 5d7960a9823..a7f01393a02 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -317,7 +317,7 @@ static void build_underline(Curve *cu, float x1, float y1, float x2, float y2, i Nurb *nu2; BPoint *bp; - nu2 =(Nurb*) MEM_callocN(sizeof(Nurb),"underline_nurb"); + nu2 =(Nurb*) MEM_callocN(sizeof(Nurb), "underline_nurb"); if (nu2 == NULL) return; nu2->resolu= cu->resolu; nu2->bezt = NULL; @@ -331,7 +331,7 @@ static void build_underline(Curve *cu, float x1, float y1, float x2, float y2, i nu2->orderv = 1; nu2->flagu = CU_NURB_CYCLIC; - bp = (BPoint*)MEM_callocN(4 * sizeof(BPoint),"underline_bp"); + bp = (BPoint*)MEM_callocN(4 * sizeof(BPoint), "underline_bp"); if (bp == NULL) { MEM_freeN(nu2); return; @@ -382,7 +382,7 @@ static void buildchar(Main *bmain, Curve *cu, unsigned long character, CharInfo } #endif - /* make a copy at distance ofsx,ofsy with shear*/ + /* make a copy at distance ofsx, ofsy with shear*/ fsize= cu->fsize; shear= cu->shear; si= (float)sin(rot); @@ -398,7 +398,7 @@ static void buildchar(Main *bmain, Curve *cu, unsigned long character, CharInfo while (nu1) { bezt1 = nu1->bezt; if (bezt1) { - nu2 =(Nurb*) MEM_mallocN(sizeof(Nurb),"duplichar_nurb"); + nu2 =(Nurb*) MEM_mallocN(sizeof(Nurb), "duplichar_nurb"); if (nu2 == NULL) break; memcpy(nu2, nu1, sizeof(struct Nurb)); nu2->resolu= cu->resolu; @@ -416,7 +416,7 @@ static void buildchar(Main *bmain, Curve *cu, unsigned long character, CharInfo /* nu2->trim.last = 0; */ i = nu2->pntsu; - bezt2 = (BezTriple*)MEM_mallocN(i * sizeof(BezTriple),"duplichar_bezt2"); + bezt2 = (BezTriple*)MEM_mallocN(i * sizeof(BezTriple), "duplichar_bezt2"); if (bezt2 == NULL) { MEM_freeN(nu2); break; @@ -583,14 +583,14 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m /* calc offset and rotation of each char */ ct = chartransdata = - (struct chartrans*)MEM_callocN((slen+1)* sizeof(struct chartrans),"buildtext"); + (struct chartrans*)MEM_callocN((slen+1)* sizeof(struct chartrans), "buildtext"); /* We assume the worst case: 1 character per line (is freed at end anyway) */ - linedata= MEM_mallocN(sizeof(float)*(slen*2 + 1),"buildtext2"); - linedata2= MEM_mallocN(sizeof(float)*(slen*2 + 1),"buildtext3"); - linedata3= MEM_callocN(sizeof(float)*(slen*2 + 1),"buildtext4"); - linedata4= MEM_callocN(sizeof(float)*(slen*2 + 1),"buildtext5"); + linedata = MEM_mallocN(sizeof(float) * (slen * 2 + 1), "buildtext2"); + linedata2 = MEM_mallocN(sizeof(float) * (slen * 2 + 1), "buildtext3"); + linedata3 = MEM_callocN(sizeof(float) * (slen * 2 + 1), "buildtext4"); + linedata4 = MEM_callocN(sizeof(float) * (slen * 2 + 1), "buildtext5"); linedist= cu->linedist; diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index 811cb881f6e..9ea4eafdd73 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -54,7 +54,7 @@ /* --------- Memory Management ------------ */ /* Free strokes belonging to a gp-frame */ -void free_gpencil_strokes (bGPDframe *gpf) +void free_gpencil_strokes(bGPDframe *gpf) { bGPDstroke *gps, *gpsn; @@ -72,7 +72,7 @@ void free_gpencil_strokes (bGPDframe *gpf) } /* Free all of a gp-layer's frames */ -void free_gpencil_frames (bGPDlayer *gpl) +void free_gpencil_frames(bGPDlayer *gpl) { bGPDframe *gpf, *gpfn; @@ -90,7 +90,7 @@ void free_gpencil_frames (bGPDlayer *gpl) } /* Free all of the gp-layers for a viewport (list should be &gpd->layers or so) */ -void free_gpencil_layers (ListBase *list) +void free_gpencil_layers(ListBase *list) { bGPDlayer *gpl, *gpln; @@ -108,7 +108,7 @@ void free_gpencil_layers (ListBase *list) } /* Free all of GPencil datablock's related data, but not the block itself */ -void free_gpencil_data (bGPdata *gpd) +void free_gpencil_data(bGPdata *gpd) { /* free layers */ free_gpencil_layers(&gpd->layers); @@ -299,7 +299,7 @@ bGPdata *gpencil_data_duplicate (bGPdata *src) /* -------- GP-Frame API ---------- */ /* delete the last stroke of the given frame */ -void gpencil_frame_delete_laststroke (bGPDlayer *gpl, bGPDframe *gpf) +void gpencil_frame_delete_laststroke(bGPDlayer *gpl, bGPDframe *gpf) { bGPDstroke *gps= (gpf) ? gpf->strokes.last : NULL; int cfra = (gpf) ? gpf->framenum : 0; /* assume that the current frame was not locked */ @@ -447,7 +447,7 @@ bGPDframe *gpencil_layer_getframe (bGPDlayer *gpl, int cframe, short addnew) } /* delete the given frame from a layer */ -void gpencil_layer_delframe (bGPDlayer *gpl, bGPDframe *gpf) +void gpencil_layer_delframe(bGPDlayer *gpl, bGPDframe *gpf) { /* error checking */ if (ELEM(NULL, gpl, gpf)) @@ -479,7 +479,7 @@ bGPDlayer *gpencil_layer_getactive (bGPdata *gpd) } /* set the active gp-layer */ -void gpencil_layer_setactive (bGPdata *gpd, bGPDlayer *active) +void gpencil_layer_setactive(bGPdata *gpd, bGPDlayer *active) { bGPDlayer *gpl; @@ -496,7 +496,7 @@ void gpencil_layer_setactive (bGPdata *gpd, bGPDlayer *active) } /* delete the active gp-layer */ -void gpencil_layer_delactive (bGPdata *gpd) +void gpencil_layer_delactive(bGPdata *gpd) { bGPDlayer *gpl= gpencil_layer_getactive(gpd); diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c index cf0538b4395..204b2b08563 100644 --- a/source/blender/blenkernel/intern/group.c +++ b/source/blender/blenkernel/intern/group.c @@ -1,5 +1,4 @@ -/* - * +/* * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -176,7 +175,7 @@ static int add_to_group_internal(Group *group, Object *ob) } go= MEM_callocN(sizeof(GroupObject), "groupobject"); - BLI_addtail( &group->gobject, go); + BLI_addtail(&group->gobject, go); go->ob= ob; diff --git a/source/blender/blenkernel/intern/idcode.c b/source/blender/blenkernel/intern/idcode.c index c7dec3d8f4b..c3bd36348c6 100644 --- a/source/blender/blenkernel/intern/idcode.c +++ b/source/blender/blenkernel/intern/idcode.c @@ -53,7 +53,7 @@ static IDType idtypes[]= { { ID_BR, "Brush", "brushes", IDTYPE_FLAGS_ISLINKABLE}, { ID_CA, "Camera", "cameras", IDTYPE_FLAGS_ISLINKABLE}, { ID_CU, "Curve", "curves", IDTYPE_FLAGS_ISLINKABLE}, - { ID_GD, "GPencil", "grease_pencil",IDTYPE_FLAGS_ISLINKABLE}, /* rename gpencil */ + { ID_GD, "GPencil", "grease_pencil", IDTYPE_FLAGS_ISLINKABLE}, /* rename gpencil */ { ID_GR, "Group", "groups", IDTYPE_FLAGS_ISLINKABLE}, { ID_ID, "ID", "ids", 0}, /* plural is fake */ { ID_IM, "Image", "images", IDTYPE_FLAGS_ISLINKABLE}, diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 5c9c942cc6c..9c5c99592ed 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1036,38 +1036,38 @@ char BKE_imtype_valid_depths(const char imtype) * creator.c help info */ char BKE_imtype_from_arg(const char *imtype_arg) { - if (!strcmp(imtype_arg,"TGA")) return R_IMF_IMTYPE_TARGA; - else if (!strcmp(imtype_arg,"IRIS")) return R_IMF_IMTYPE_IRIS; + if (!strcmp(imtype_arg, "TGA")) return R_IMF_IMTYPE_TARGA; + else if (!strcmp(imtype_arg, "IRIS")) return R_IMF_IMTYPE_IRIS; #ifdef WITH_DDS - else if (!strcmp(imtype_arg,"DDS")) return R_IMF_IMTYPE_DDS; + else if (!strcmp(imtype_arg, "DDS")) return R_IMF_IMTYPE_DDS; #endif - else if (!strcmp(imtype_arg,"JPEG")) return R_IMF_IMTYPE_JPEG90; - else if (!strcmp(imtype_arg,"IRIZ")) return R_IMF_IMTYPE_IRIZ; - else if (!strcmp(imtype_arg,"RAWTGA")) return R_IMF_IMTYPE_RAWTGA; - else if (!strcmp(imtype_arg,"AVIRAW")) return R_IMF_IMTYPE_AVIRAW; - else if (!strcmp(imtype_arg,"AVIJPEG")) return R_IMF_IMTYPE_AVIJPEG; - else if (!strcmp(imtype_arg,"PNG")) return R_IMF_IMTYPE_PNG; - else if (!strcmp(imtype_arg,"AVICODEC")) return R_IMF_IMTYPE_AVICODEC; - else if (!strcmp(imtype_arg,"QUICKTIME")) return R_IMF_IMTYPE_QUICKTIME; - else if (!strcmp(imtype_arg,"BMP")) return R_IMF_IMTYPE_BMP; + else if (!strcmp(imtype_arg, "JPEG")) return R_IMF_IMTYPE_JPEG90; + else if (!strcmp(imtype_arg, "IRIZ")) return R_IMF_IMTYPE_IRIZ; + else if (!strcmp(imtype_arg, "RAWTGA")) return R_IMF_IMTYPE_RAWTGA; + else if (!strcmp(imtype_arg, "AVIRAW")) return R_IMF_IMTYPE_AVIRAW; + else if (!strcmp(imtype_arg, "AVIJPEG")) return R_IMF_IMTYPE_AVIJPEG; + else if (!strcmp(imtype_arg, "PNG")) return R_IMF_IMTYPE_PNG; + else if (!strcmp(imtype_arg, "AVICODEC")) return R_IMF_IMTYPE_AVICODEC; + else if (!strcmp(imtype_arg, "QUICKTIME")) return R_IMF_IMTYPE_QUICKTIME; + else if (!strcmp(imtype_arg, "BMP")) return R_IMF_IMTYPE_BMP; #ifdef WITH_HDR - else if (!strcmp(imtype_arg,"HDR")) return R_IMF_IMTYPE_RADHDR; + else if (!strcmp(imtype_arg, "HDR")) return R_IMF_IMTYPE_RADHDR; #endif #ifdef WITH_TIFF - else if (!strcmp(imtype_arg,"TIFF")) return R_IMF_IMTYPE_TIFF; + else if (!strcmp(imtype_arg, "TIFF")) return R_IMF_IMTYPE_TIFF; #endif #ifdef WITH_OPENEXR - else if (!strcmp(imtype_arg,"EXR")) return R_IMF_IMTYPE_OPENEXR; - else if (!strcmp(imtype_arg,"MULTILAYER")) return R_IMF_IMTYPE_MULTILAYER; + else if (!strcmp(imtype_arg, "EXR")) return R_IMF_IMTYPE_OPENEXR; + else if (!strcmp(imtype_arg, "MULTILAYER")) return R_IMF_IMTYPE_MULTILAYER; #endif - else if (!strcmp(imtype_arg,"MPEG")) return R_IMF_IMTYPE_FFMPEG; - else if (!strcmp(imtype_arg,"FRAMESERVER")) return R_IMF_IMTYPE_FRAMESERVER; + else if (!strcmp(imtype_arg, "MPEG")) return R_IMF_IMTYPE_FFMPEG; + else if (!strcmp(imtype_arg, "FRAMESERVER")) return R_IMF_IMTYPE_FRAMESERVER; #ifdef WITH_CINEON - else if (!strcmp(imtype_arg,"CINEON")) return R_IMF_IMTYPE_CINEON; - else if (!strcmp(imtype_arg,"DPX")) return R_IMF_IMTYPE_DPX; + else if (!strcmp(imtype_arg, "CINEON")) return R_IMF_IMTYPE_CINEON; + else if (!strcmp(imtype_arg, "DPX")) return R_IMF_IMTYPE_DPX; #endif #ifdef WITH_OPENJPEG - else if (!strcmp(imtype_arg,"JP2")) return R_IMF_IMTYPE_JP2; + else if (!strcmp(imtype_arg, "JP2")) return R_IMF_IMTYPE_JP2; #endif else return R_IMF_IMTYPE_INVALID; } @@ -1118,7 +1118,7 @@ int BKE_add_image_extension(char *string, const char imtype) } #endif #ifdef WITH_OPENEXR - else if ( ELEM(imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER)) { + else if (ELEM(imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER)) { if (!BLI_testextensie(string, ".exr")) extension= ".exr"; } @@ -1144,7 +1144,7 @@ int BKE_add_image_extension(char *string, const char imtype) } #endif else { // R_IMF_IMTYPE_AVICODEC, R_IMF_IMTYPE_AVIRAW, R_IMF_IMTYPE_AVIJPEG, R_IMF_IMTYPE_JPEG90, R_IMF_IMTYPE_QUICKTIME etc - if (!( BLI_testextensie(string, ".jpg") || BLI_testextensie(string, ".jpeg"))) + if (!(BLI_testextensie(string, ".jpg") || BLI_testextensie(string, ".jpeg"))) extension= ".jpg"; } @@ -2603,7 +2603,7 @@ int BKE_image_user_get_frame(const ImageUser *iuser, int cfra, int fieldnr) /* cyclic */ if (iuser->cycl) { - cfra= ( (cfra) % len ); + cfra= ((cfra) % len); if (cfra < 0) cfra+= len; if (cfra==0) cfra= len; } @@ -2621,7 +2621,7 @@ int BKE_image_user_get_frame(const ImageUser *iuser, int cfra, int fieldnr) framenr+= iuser->offset; if (iuser->cycl) { - framenr= ( (framenr) % len ); + framenr= ((framenr) % len); while (framenr < 0) framenr+= len; if (framenr==0) framenr= len; } diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index b593419db9f..d4861a27057 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -87,7 +87,7 @@ void itstart(void) } static void itend(void) { - gettimeofday(&_itend,&itz); + gettimeofday(&_itend, &itz); } double itval(void) { @@ -98,8 +98,8 @@ double itval(void) } #endif -static float I[3][3] = {{1,0,0},{0,1,0},{0,0,1}}; -static float ZERO[3][3] = {{0,0,0}, {0,0,0}, {0,0,0}}; +static float I[3][3] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}; +static float ZERO[3][3] = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}; /* #define C99 @@ -119,9 +119,9 @@ struct Cloth; typedef float lfVector[3]; typedef struct fmatrix3x3 { float m[3][3]; /* 3x3 matrix */ - unsigned int c,r; /* column and row number */ + unsigned int c, r; /* column and row number */ int pinned; /* is this vertex allowed to move? */ - float n1,n2,n3; /* three normal vectors for collision constrains */ + float n1, n2, n3; /* three normal vectors for collision constrains */ unsigned int vcount; /* vertex count */ unsigned int scount; /* spring count */ } fmatrix3x3; @@ -168,7 +168,7 @@ DO_INLINE void mul_fvectorT_fvectorS(float to[3][3], float vectorA[3], float vec /* printf vector[3] on console: for debug output */ static void print_fvector(float m3[3]) { - printf("%f\n%f\n%f\n\n",m3[0],m3[1],m3[2]); + printf("%f\n%f\n%f\n\n", m3[0], m3[1], m3[2]); } /////////////////////////// @@ -303,9 +303,9 @@ DO_INLINE void sub_lfvector_lfvector(float (*to)[3], float (*fLongVectorA)[3], f /* printf 3x3 matrix on console: for debug output */ static void print_fmatrix(float m3[3][3]) { - printf("%f\t%f\t%f\n",m3[0][0],m3[0][1],m3[0][2]); - printf("%f\t%f\t%f\n",m3[1][0],m3[1][1],m3[1][2]); - printf("%f\t%f\t%f\n\n",m3[2][0],m3[2][1],m3[2][2]); + printf("%f\t%f\t%f\n", m3[0][0], m3[0][1], m3[0][2]); + printf("%f\t%f\t%f\n", m3[1][0], m3[1][1], m3[1][2]); + printf("%f\t%f\t%f\n\n", m3[2][0], m3[2][1], m3[2][2]); } #endif @@ -367,9 +367,9 @@ DO_INLINE void inverse_fmatrix(float to[3][3], float from[3][3]) /* STATUS: verified */ DO_INLINE void mul_fmatrix_S(float matrix[3][3], float scalar) { - mul_fvector_S(matrix[0], matrix[0],scalar); - mul_fvector_S(matrix[1], matrix[1],scalar); - mul_fvector_S(matrix[2], matrix[2],scalar); + mul_fvector_S(matrix[0], matrix[0], scalar); + mul_fvector_S(matrix[1], matrix[1], scalar); + mul_fvector_S(matrix[2], matrix[2], scalar); } /* a vector multiplied by a 3x3 matrix */ @@ -385,17 +385,17 @@ DO_INLINE void mul_fvector_fmatrix(float *to, float *from, float matrix[3][3]) /* STATUS: verified */ DO_INLINE void mul_fmatrix_fvector(float *to, float matrix[3][3], float from[3]) { - to[0] = dot_v3v3(matrix[0],from); - to[1] = dot_v3v3(matrix[1],from); - to[2] = dot_v3v3(matrix[2],from); + to[0] = dot_v3v3(matrix[0], from); + to[1] = dot_v3v3(matrix[1], from); + to[2] = dot_v3v3(matrix[2], from); } /* 3x3 matrix multiplied by a 3x3 matrix */ /* STATUS: verified */ DO_INLINE void mul_fmatrix_fmatrix(float to[3][3], float matrixA[3][3], float matrixB[3][3]) { - mul_fvector_fmatrix(to[0], matrixA[0],matrixB); - mul_fvector_fmatrix(to[1], matrixA[1],matrixB); - mul_fvector_fmatrix(to[2], matrixA[2],matrixB); + mul_fvector_fmatrix(to[0], matrixA[0], matrixB); + mul_fvector_fmatrix(to[1], matrixA[1], matrixB); + mul_fvector_fmatrix(to[2], matrixA[2], matrixB); } /* 3x3 matrix addition with 3x3 matrix */ DO_INLINE void add_fmatrix_fmatrix(float to[3][3], float matrixA[3][3], float matrixB[3][3]) @@ -459,9 +459,9 @@ DO_INLINE void muladd_fvector_fmatrix(float to[3], float from[3], float matrix[3 /* 3x3 matrix multiplied and added to/by a 3x3 matrix and added to another 3x3 matrix */ DO_INLINE void muladd_fmatrix_fmatrix(float to[3][3], float matrixA[3][3], float matrixB[3][3]) { - muladd_fvector_fmatrix(to[0], matrixA[0],matrixB); - muladd_fvector_fmatrix(to[1], matrixA[1],matrixB); - muladd_fvector_fmatrix(to[2], matrixA[2],matrixB); + muladd_fvector_fmatrix(to[0], matrixA[0], matrixB); + muladd_fvector_fmatrix(to[1], matrixA[1], matrixB); + muladd_fvector_fmatrix(to[2], matrixA[2], matrixB); } /* a vector multiplied and sub'd to/by a 3x3 matrix */ DO_INLINE void mulsub_fvector_fmatrix(float to[3], float from[3], float matrix[3][3]) @@ -473,9 +473,9 @@ DO_INLINE void mulsub_fvector_fmatrix(float to[3], float from[3], float matrix[3 /* 3x3 matrix multiplied and sub'd to/by a 3x3 matrix and added to another 3x3 matrix */ DO_INLINE void mulsub_fmatrix_fmatrix(float to[3][3], float matrixA[3][3], float matrixB[3][3]) { - mulsub_fvector_fmatrix(to[0], matrixA[0],matrixB); - mulsub_fvector_fmatrix(to[1], matrixA[1],matrixB); - mulsub_fvector_fmatrix(to[2], matrixA[2],matrixB); + mulsub_fvector_fmatrix(to[0], matrixA[0], matrixB); + mulsub_fvector_fmatrix(to[1], matrixA[1], matrixB); + mulsub_fvector_fmatrix(to[2], matrixA[2], matrixB); } /* 3x3 matrix multiplied+added by a vector */ /* STATUS: verified */ @@ -531,7 +531,7 @@ DO_INLINE void del_bfmatrix(fmatrix3x3 *matrix) DO_INLINE void cp_bfmatrix(fmatrix3x3 *to, fmatrix3x3 *from) { // TODO bounds checking - memcpy(to, from, sizeof(fmatrix3x3) * (from[0].vcount+from[0].scount) ); + memcpy(to, from, sizeof(fmatrix3x3) * (from[0].vcount+from[0].scount)); } /* init big matrix */ @@ -549,8 +549,8 @@ DO_INLINE void init_bfmatrix(fmatrix3x3 *matrix, float m3[3][3]) // slow in parallel DO_INLINE void initdiag_bfmatrix(fmatrix3x3 *matrix, float m3[3][3]) { - unsigned int i,j; - float tmatrix[3][3] = {{0,0,0},{0,0,0},{0,0,0}}; + unsigned int i, j; + float tmatrix[3][3] = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}; for (i = 0; i < matrix[0].vcount; i++) { cp_fmatrix(matrix[i].m, m3); @@ -701,7 +701,7 @@ typedef struct Implicit_Data fmatrix3x3 *A, *dFdV, *dFdX, *S, *P, *Pinv, *bigI, *M; } Implicit_Data; -int implicit_init (Object *UNUSED(ob), ClothModifierData *clmd) +int implicit_init(Object *UNUSED(ob), ClothModifierData *clmd) { unsigned int i = 0; unsigned int pinned = 0; @@ -785,7 +785,7 @@ int implicit_init (Object *UNUSED(ob), ClothModifierData *clmd) return 1; } -int implicit_free (ClothModifierData *clmd) +int implicit_free(ClothModifierData *clmd) { Implicit_Data *id; Cloth *cloth; @@ -824,14 +824,14 @@ int implicit_free (ClothModifierData *clmd) DO_INLINE float fb(float length, float L) { float x = length/L; - return (-11.541f*pow(x,4)+34.193f*pow(x,3)-39.083f*pow(x,2)+23.116f*x-9.713f); + return (-11.541f*pow(x, 4)+34.193f*pow(x, 3)-39.083f*pow(x, 2)+23.116f*x-9.713f); } DO_INLINE float fbderiv(float length, float L) { float x = length/L; - return (-46.164f*pow(x,3)+102.579f*pow(x,2)-78.166f*x+23.116f); + return (-46.164f*pow(x, 3)+102.579f*pow(x, 2)-78.166f*x+23.116f); } DO_INLINE float fbstar(float length, float L, float kb, float cb) @@ -887,12 +887,12 @@ static int cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z add_lfvector_lfvector(ldV, ldV, z, numverts); - // r = B - Mul(tmp,A,X); // just use B if X known to be zero + // r = B - Mul(tmp, A, X); // just use B if X known to be zero cp_lfvector(r, lB, numverts); mul_bfmatrix_lfvector(tmp, lA, ldV); sub_lfvector_lfvector(r, r, tmp, numverts); - filter(r,S); + filter(r, S); cp_lfvector(d, r, numverts); @@ -900,10 +900,10 @@ static int cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z starget = s * sqrt(conjgrad_epsilon); while (s>starget && conjgrad_loopcount < conjgrad_looplimit) { - // Mul(q,A,d); // q = A*d; + // Mul(q, A, d); // q = A*d; mul_bfmatrix_lfvector(q, lA, d); - filter(q,S); + filter(q, S); a = s/dot_lfvector(d, q, numverts); @@ -919,7 +919,7 @@ static int cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z //d = r+d*(s/s_prev); add_lfvector_lfvectorS(d, r, d, (s/s_prev), numverts); - filter(d,S); + filter(d, S); conjgrad_loopcount++; } @@ -1126,7 +1126,7 @@ static int cg_filtered_pre(lfVector *dv, fmatrix3x3 *lA, lfVector *lB, lfVector DO_INLINE void dfdx_spring_type1(float to[3][3], float extent[3], float length, float L, float dot, float k) { // dir is unit length direction, rest is spring's restlength, k is spring constant. - // return (outerprod(dir,dir)*k + (I - outerprod(dir,dir))*(k - ((k*L)/length))); + // return (outerprod(dir, dir)*k + (I - outerprod(dir, dir))*(k - ((k*L)/length))); float temp[3][3]; float temp1 = k*(1.0 - (L/length)); @@ -1148,7 +1148,7 @@ DO_INLINE void dfdx_spring_type1(float to[3][3], float extent[3], float length, DO_INLINE void dfdx_spring_type2(float to[3][3], float dir[3], float length, float L, float k, float cb) { - // return outerprod(dir,dir)*fbstar_jacobi(length, L, k, cb); + // return outerprod(dir, dir)*fbstar_jacobi(length, L, k, cb); mul_fvectorT_fvectorS(to, dir, dir, fbstar_jacobi(length, L, k, cb)); } @@ -1159,10 +1159,10 @@ DO_INLINE void dfdv_damp(float to[3][3], float dir[3], float damping) } -DO_INLINE void dfdx_spring(float to[3][3], float dir[3],float length,float L,float k) +DO_INLINE void dfdx_spring(float to[3][3], float dir[3], float length, float L, float k) { // dir is unit length direction, rest is spring's restlength, k is spring constant. - //return ( (I-outerprod(dir,dir))*Min(1.0f,rest/length) - I) * -k; + //return ( (I-outerprod(dir, dir))*Min(1.0f, rest/length) - I) * -k; mul_fvectorT_fvector(to, dir, dir); sub_fmatrix_fmatrix(to, I, to); @@ -1172,13 +1172,13 @@ DO_INLINE void dfdx_spring(float to[3][3], float dir[3],float length,float L,fl } // unused atm -DO_INLINE void dfdx_damp(float to[3][3], float dir[3],float length,const float vel[3],float rest,float damping) +DO_INLINE void dfdx_damp(float to[3][3], float dir[3], float length, const float vel[3], float rest, float damping) { // inner spring damping vel is the relative velocity of the endpoints. - // return (I-outerprod(dir,dir)) * (-damping * -(dot(dir,vel)/Max(length,rest))); + // return (I-outerprod(dir, dir)) * (-damping * -(dot(dir, vel)/Max(length, rest))); mul_fvectorT_fvector(to, dir, dir); sub_fmatrix_fmatrix(to, I, to); - mul_fmatrix_S(to, (-damping * -(dot_v3v3(dir,vel)/MAX2(length,rest)))); + mul_fmatrix_S(to, (-damping * -(dot_v3v3(dir, vel)/MAX2(length, rest)))); } @@ -1188,17 +1188,17 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s, ClothVertex *verts = cloth->verts; float extent[3]; float length = 0, dot = 0; - float dir[3] = {0,0,0}; + float dir[3] = {0, 0, 0}; float vel[3]; float k = 0.0f; float L = s->restlen; float cb; /* = clmd->sim_parms->structural; */ /*UNUSED*/ - float nullf[3] = {0,0,0}; - float stretch_force[3] = {0,0,0}; - float bending_force[3] = {0,0,0}; - float damping_force[3] = {0,0,0}; - float nulldfdx[3][3]={ {0,0,0}, {0,0,0}, {0,0,0}}; + float nullf[3] = {0, 0, 0}; + float stretch_force[3] = {0, 0, 0}; + float bending_force[3] = {0, 0, 0}; + float damping_force[3] = {0, 0, 0}; + float nulldfdx[3][3]={ {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}; float scaling = 0.0; @@ -1306,7 +1306,7 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s, mul_fvector_S(bending_force, dir, fbstar(length, L, k, cb)); VECADD(s->f, s->f, bending_force); - dfdx_spring_type2(s->dfdx, dir, length,L, k, cb); + dfdx_spring_type2(s->dfdx, dir, length, L, k, cb); } } } @@ -1334,7 +1334,7 @@ DO_INLINE void cloth_apply_spring_force(ClothModifierData *UNUSED(clmd), ClothSp static void CalcFloat( float *v1, float *v2, float *v3, float *n) { - float n1[3],n2[3]; + float n1[3], n2[3]; n1[0]= v1[0]-v2[0]; n2[0]= v2[0]-v3[0]; @@ -1350,7 +1350,7 @@ static void CalcFloat( float *v1, float *v2, float *v3, float *n) static void CalcFloat4( float *v1, float *v2, float *v3, float *v4, float *n) { /* real cross! */ - float n1[3],n2[3]; + float n1[3], n2[3]; n1[0]= v1[0]-v3[0]; n1[1]= v1[1]-v3[1]; @@ -1512,7 +1512,7 @@ static void hair_velocity_smoothing(ClothModifierData *clmd, lfVector *lF, lfVec static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVector *lF, lfVector *lX, lfVector *lV, fmatrix3x3 *dFdV, fmatrix3x3 *dFdX, ListBase *effectors, float time, fmatrix3x3 *M) { - /* Collect forces and derivatives: F,dFdX,dFdV */ + /* Collect forces and derivatives: F, dFdX, dFdV */ Cloth *cloth = clmd->clothObject; unsigned int i = 0; float spring_air = clmd->sim_parms->Cvi * 0.01f; /* viscosity of air scaled in percent */ @@ -1568,17 +1568,17 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec } for (i = 0; i < cloth->numfaces; i++) { - float trinormal[3]={0,0,0}; // normalized triangle normal - float triunnormal[3]={0,0,0}; // not-normalized-triangle normal - float tmp[3]={0,0,0}; + float trinormal[3]={0, 0, 0}; // normalized triangle normal + float triunnormal[3]={0, 0, 0}; // not-normalized-triangle normal + float tmp[3]={0, 0, 0}; float factor = (mfaces[i].v4) ? 0.25 : 1.0 / 3.0; factor *= 0.02; // calculate face normal if (mfaces[i].v4) - CalcFloat4(lX[mfaces[i].v1],lX[mfaces[i].v2],lX[mfaces[i].v3],lX[mfaces[i].v4],triunnormal); + CalcFloat4(lX[mfaces[i].v1], lX[mfaces[i].v2], lX[mfaces[i].v3], lX[mfaces[i].v4], triunnormal); else - CalcFloat(lX[mfaces[i].v1],lX[mfaces[i].v2],lX[mfaces[i].v3],triunnormal); + CalcFloat(lX[mfaces[i].v1], lX[mfaces[i].v2], lX[mfaces[i].v3], triunnormal); normalize_v3_v3(trinormal, triunnormal); @@ -1608,9 +1608,9 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec /* Hair has only edges */ if (cloth->numfaces == 0) { ClothSpring *spring; - float edgevec[3]={0,0,0}; //edge vector - float edgeunnormal[3]={0,0,0}; // not-normalized-edge normal - float tmp[3]={0,0,0}; + float edgevec[3]={0, 0, 0}; //edge vector + float edgeunnormal[3]={0, 0, 0}; // not-normalized-edge normal + float tmp[3]={0, 0, 0}; float factor = 0.01; search = cloth->springs; @@ -1768,7 +1768,7 @@ int cloth_calc_helper_forces(Object *UNUSED(ob), ClothModifierData * clmd, float return 1; } -int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase *effectors) +int implicit_solver(Object *ob, float frame, ClothModifierData *clmd, ListBase *effectors) { unsigned int i=0; float step=0.0f, tf=clmd->sim_parms->timescale; @@ -1908,7 +1908,7 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase return 1; } -void implicit_set_positions (ClothModifierData *clmd) +void implicit_set_positions(ClothModifierData *clmd) { Cloth *cloth = clmd->clothObject; ClothVertex *verts = cloth->verts; diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index c33bb973385..48763382f2a 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -81,7 +81,7 @@ /* Free data from old IPO-Blocks (those which haven't been converted), but not IPO block itself */ // XXX this shouldn't be necessary anymore, but may occur while not all data is converted yet -void free_ipo (Ipo *ipo) +void free_ipo(Ipo *ipo) { IpoCurve *icu, *icn; int n= 0; @@ -1906,7 +1906,8 @@ void do_versions_ipos_to_animato(Main *main) AnimData *adt= BKE_id_add_animdata(id); - SEQ_BEGIN (ed, seq) { + SEQ_BEGIN (ed, seq) + { IpoCurve *icu = (seq->ipo) ? seq->ipo->curve.first : NULL; short adrcode = SEQ_FAC1; diff --git a/source/blender/blenkernel/intern/lamp.c b/source/blender/blenkernel/intern/lamp.c index e981d772df6..11c3269ad37 100644 --- a/source/blender/blenkernel/intern/lamp.c +++ b/source/blender/blenkernel/intern/lamp.c @@ -96,6 +96,7 @@ void *add_lamp(const char *name) la->skyblendfac= 1.0f; la->sky_colorspace= BLI_XYZ_CIE; la->sky_exposure= 1.0f; + la->shadow_frustum_size= 10.0f; curvemapping_initialize(la->curfalloff); return la; diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 12f11a9dee1..e78da48d153 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -131,9 +131,9 @@ void resizelattice(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb) } co = vertexCos[0]; - for (w=0,wc=fw; w<wNew; w++,wc+=dw) { - for (v=0,vc=fv; v<vNew; v++,vc+=dv) { - for (u=0,uc=fu; u<uNew; u++,co+=3,uc+=du) { + for (w=0, wc=fw; w<wNew; w++, wc+=dw) { + for (v=0, vc=fv; v<vNew; v++, vc+=dv) { + for (u=0, uc=fu; u<uNew; u++, co+=3, uc+=du) { co[0] = uc; co[1] = vc; co[2] = wc; @@ -177,7 +177,7 @@ void resizelattice(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb) bp= lt->def; - for (i=0; i<lt->pntsu*lt->pntsv*lt->pntsw; i++,bp++) { + for (i=0; i<lt->pntsu*lt->pntsv*lt->pntsw; i++, bp++) { copy_v3_v3(bp->vec, vertexCos[i]); } @@ -322,9 +322,9 @@ void init_latt_deform(Object *oblatt, Object *ob) invert_m4_m4(imat, lt->latmat); } - for (w=0,fw=lt->fw; w<lt->pntsw; w++,fw+=lt->dw) { - for (v=0,fv=lt->fv; v<lt->pntsv; v++, fv+=lt->dv) { - for (u=0,fu=lt->fu; u<lt->pntsu; u++, bp++, co+=3, fp+=3, fu+=lt->du) { + for (w=0, fw=lt->fw; w<lt->pntsw; w++, fw+=lt->dw) { + for (v=0, fv=lt->fv; v<lt->pntsv; v++, fv+=lt->dv) { + for (u=0, fu=lt->fu; u<lt->pntsu; u++, bp++, co+=3, fp+=3, fu+=lt->du) { if (dl) { fp[0] = co[0] - fu; fp[1] = co[1] - fv; @@ -568,7 +568,7 @@ static int calc_curve_deform(Scene *scene, Object *par, float co[3], /* this is not exactly the same as 2.4x, since the axis is having rotation removed rather than * changing the axis before calculating the tilt but serves much the same purpose */ - float dir_flat[3]={0,0,0}, q[4]; + float dir_flat[3]={0, 0, 0}, q[4]; copy_v3_v3(dir_flat, dir); dir_flat[cd->no_rot_axis-1]= 0.0f; @@ -774,7 +774,7 @@ void curve_deform_vector(Scene *scene, Object *cuOb, Object *target, if (calc_curve_deform(scene, cuOb, vec, target->trackflag, &cd, quat)) { float qmat[3][3]; - quat_to_mat3( qmat,quat); + quat_to_mat3(qmat, quat); mul_m3_m3m3(mat, qmat, cd.objectspace3); } else @@ -937,7 +937,7 @@ float (*lattice_getVertexCos(struct Object *ob, int *numVerts_r))[3] if (lt->editlatt) lt= lt->editlatt->latt; numVerts = *numVerts_r = lt->pntsu*lt->pntsv*lt->pntsw; - vertexCos = MEM_mallocN(sizeof(*vertexCos)*numVerts,"lt_vcos"); + vertexCos = MEM_mallocN(sizeof(*vertexCos)*numVerts, "lt_vcos"); for (i=0; i<numVerts; i++) { copy_v3_v3(vertexCos[i], lt->def[i].vec); diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 8612e9f2b97..52c92034367 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -136,9 +136,9 @@ void BKE_id_lib_local_paths(Main *bmain, Library *lib, ID *id) { char *bpath_user_data[2]= {bmain->name, lib->filepath}; - bpath_traverse_id(bmain, id, - bpath_relocate_visitor, - BPATH_TRAVERSE_SKIP_MULTIFILE, + BLI_bpath_traverse_id(bmain, id, + BLI_bpath_relocate_visitor, + BLI_BPATH_TRAVERSE_SKIP_MULTIFILE, bpath_user_data); } @@ -225,7 +225,7 @@ int id_make_local(ID *id, int test) if (!test) make_local_lamp((Lamp*)id); return 1; case ID_CA: - if (!test) make_local_camera((Camera*)id); + if (!test) BKE_camera_make_local((Camera*)id); return 1; case ID_SPK: if (!test) make_local_speaker((Speaker*)id); @@ -259,7 +259,7 @@ int id_make_local(ID *id, int test) case ID_NT: return 0; /* not implemented */ case ID_BR: - if (!test) make_local_brush((Brush*)id); + if (!test) BKE_brush_make_local((Brush*)id); return 1; case ID_PA: if (!test) make_local_particlesettings((ParticleSettings*)id); @@ -318,7 +318,7 @@ int id_copy(ID *id, ID **newid, int test) if (!test) *newid= (ID*)copy_speaker((Speaker*)id); return 1; case ID_CA: - if (!test) *newid= (ID*)copy_camera((Camera*)id); + if (!test) *newid= (ID*)BKE_camera_copy((Camera*)id); return 1; case ID_IP: return 0; /* deprecated */ @@ -352,7 +352,7 @@ int id_copy(ID *id, ID **newid, int test) if (!test) *newid= (ID*)ntreeCopyTree((bNodeTree*)id); return 1; case ID_BR: - if (!test) *newid= (ID*)copy_brush((Brush*)id); + if (!test) *newid= (ID*)BKE_brush_copy((Brush*)id); return 1; case ID_PA: if (!test) *newid= (ID*)psys_copy_settings((ParticleSettings*)id); @@ -843,7 +843,7 @@ void free_libblock(ListBase *lb, void *idv) free_lamp((Lamp *)id); break; case ID_CA: - free_camera((Camera*) id); + BKE_camera_free((Camera*) id); break; case ID_IP: free_ipo((Ipo *)id); @@ -885,7 +885,7 @@ void free_libblock(ListBase *lb, void *idv) ntreeFreeTree((bNodeTree *)id); break; case ID_BR: - free_brush((Brush *)id); + BKE_brush_free((Brush *)id); break; case ID_PA: psys_free_settings((ParticleSettings *)id); @@ -1031,7 +1031,7 @@ static void IDnames_to_dyn_pupstring(DynStr *pupds, ListBase *lb, ID *link, shor case ID_IM: /* fall through */ case ID_WO: /* fall through */ case ID_LA: /* fall through */ - BLI_snprintf(numstr, sizeof(numstr), "%%i%d", BKE_icon_getid(id) ); + BLI_snprintf(numstr, sizeof(numstr), "%%i%d", BKE_icon_getid(id)); BLI_dynstr_append(pupds, numstr); break; default: @@ -1232,7 +1232,7 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name) continue; } /* this format specifier is from hell... */ - BLI_snprintf(name, sizeof(id->name) - 2,"%s.%.3d", left, nr); + BLI_snprintf(name, sizeof(id->name) - 2, "%s.%.3d", left, nr); return 1; } diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 6ddbf56605a..c76eb3c2fb3 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -801,7 +801,7 @@ void assign_material(Object *ob, Material *ma, short act) matar= MEM_callocN(sizeof(void *)*act, "matarray2"); matbits= MEM_callocN(sizeof(char)*act, "matbits1"); if ( ob->totcol) { - memcpy(matar, ob->mat, sizeof(void *)*( ob->totcol )); + memcpy(matar, ob->mat, sizeof(void *) * ob->totcol); memcpy(matbits, ob->matbits, sizeof(char)*(*totcolp)); MEM_freeN(ob->mat); MEM_freeN(ob->matbits); @@ -1055,31 +1055,31 @@ int material_in_material(Material *parmat, Material *mat) /* ****************** */ #if 0 /* UNUSED */ static char colname_array[125][20]= { -"Black","DarkRed","HalfRed","Red","Red", -"DarkGreen","DarkOlive","Brown","Chocolate","OrangeRed", -"HalfGreen","GreenOlive","DryOlive","Goldenrod","DarkOrange", -"LightGreen","Chartreuse","YellowGreen","Yellow","Gold", -"Green","LawnGreen","GreenYellow","LightOlive","Yellow", -"DarkBlue","DarkPurple","HotPink","VioletPink","RedPink", -"SlateGray","DarkGrey","PalePurple","IndianRed","Tomato", -"SeaGreen","PaleGreen","GreenKhaki","LightBrown","LightSalmon", -"SpringGreen","PaleGreen","MediumOlive","YellowBrown","LightGold", -"LightGreen","LightGreen","LightGreen","GreenYellow","PaleYellow", -"HalfBlue","DarkSky","HalfMagenta","VioletRed","DeepPink", -"SteelBlue","SkyBlue","Orchid","LightHotPink","HotPink", -"SeaGreen","SlateGray","MediumGrey","Burlywood","LightPink", -"SpringGreen","Aquamarine","PaleGreen","Khaki","PaleOrange", -"SpringGreen","SeaGreen","PaleGreen","PaleWhite","YellowWhite", -"LightBlue","Purple","MediumOrchid","Magenta","Magenta", -"RoyalBlue","SlateBlue","MediumOrchid","Orchid","Magenta", -"DeepSkyBlue","LightSteelBlue","LightSkyBlue","Violet","LightPink", -"Cyan","DarkTurquoise","SkyBlue","Grey","Snow", -"Mint","Mint","Aquamarine","MintCream","Ivory", -"Blue","Blue","DarkMagenta","DarkOrchid","Magenta", -"SkyBlue","RoyalBlue","LightSlateBlue","MediumOrchid","Magenta", -"DodgerBlue","SteelBlue","MediumPurple","PalePurple","Plum", -"DeepSkyBlue","PaleBlue","LightSkyBlue","PalePurple","Thistle", -"Cyan","ColdBlue","PaleTurquoise","GhostWhite","White" +"Black", "DarkRed", "HalfRed", "Red", "Red", +"DarkGreen", "DarkOlive", "Brown", "Chocolate", "OrangeRed", +"HalfGreen", "GreenOlive", "DryOlive", "Goldenrod", "DarkOrange", +"LightGreen", "Chartreuse", "YellowGreen", "Yellow", "Gold", +"Green", "LawnGreen", "GreenYellow", "LightOlive", "Yellow", +"DarkBlue", "DarkPurple", "HotPink", "VioletPink", "RedPink", +"SlateGray", "DarkGrey", "PalePurple", "IndianRed", "Tomato", +"SeaGreen", "PaleGreen", "GreenKhaki", "LightBrown", "LightSalmon", +"SpringGreen", "PaleGreen", "MediumOlive", "YellowBrown", "LightGold", +"LightGreen", "LightGreen", "LightGreen", "GreenYellow", "PaleYellow", +"HalfBlue", "DarkSky", "HalfMagenta", "VioletRed", "DeepPink", +"SteelBlue", "SkyBlue", "Orchid", "LightHotPink", "HotPink", +"SeaGreen", "SlateGray", "MediumGrey", "Burlywood", "LightPink", +"SpringGreen", "Aquamarine", "PaleGreen", "Khaki", "PaleOrange", +"SpringGreen", "SeaGreen", "PaleGreen", "PaleWhite", "YellowWhite", +"LightBlue", "Purple", "MediumOrchid", "Magenta", "Magenta", +"RoyalBlue", "SlateBlue", "MediumOrchid", "Orchid", "Magenta", +"DeepSkyBlue", "LightSteelBlue", "LightSkyBlue", "Violet", "LightPink", +"Cyan", "DarkTurquoise", "SkyBlue", "Grey", "Snow", +"Mint", "Mint", "Aquamarine", "MintCream", "Ivory", +"Blue", "Blue", "DarkMagenta", "DarkOrchid", "Magenta", +"SkyBlue", "RoyalBlue", "LightSlateBlue", "MediumOrchid", "Magenta", +"DodgerBlue", "SteelBlue", "MediumPurple", "PalePurple", "Plum", +"DeepSkyBlue", "PaleBlue", "LightSkyBlue", "PalePurple", "Thistle", +"Cyan", "ColdBlue", "PaleTurquoise", "GhostWhite", "White" }; void automatname(Material *ma) @@ -1317,13 +1317,13 @@ void ramp_blend(int type, float r_col[3], const float fac, const float col[3]) break; case MA_RAMP_HUE: { - float rH,rS,rV; - float colH,colS,colV; - float tmpr,tmpg,tmpb; - rgb_to_hsv(col[0],col[1],col[2],&colH,&colS,&colV); + float rH, rS, rV; + float colH, colS, colV; + float tmpr, tmpg, tmpb; + rgb_to_hsv(col[0], col[1], col[2], &colH, &colS, &colV); if (colS != 0) { - rgb_to_hsv(r_col[0],r_col[1],r_col[2],&rH,&rS,&rV); - hsv_to_rgb( colH , rS, rV, &tmpr, &tmpg, &tmpb); + rgb_to_hsv(r_col[0], r_col[1], r_col[2], &rH, &rS, &rV); + hsv_to_rgb(colH, rS, rV, &tmpr, &tmpg, &tmpb); r_col[0] = facm*(r_col[0]) + fac*tmpr; r_col[1] = facm*(r_col[1]) + fac*tmpg; r_col[2] = facm*(r_col[2]) + fac*tmpb; @@ -1332,33 +1332,33 @@ void ramp_blend(int type, float r_col[3], const float fac, const float col[3]) break; case MA_RAMP_SAT: { - float rH,rS,rV; - float colH,colS,colV; - rgb_to_hsv(r_col[0],r_col[1],r_col[2],&rH,&rS,&rV); + float rH, rS, rV; + float colH, colS, colV; + rgb_to_hsv(r_col[0], r_col[1], r_col[2], &rH, &rS, &rV); if (rS != 0) { - rgb_to_hsv(col[0],col[1],col[2],&colH,&colS,&colV); - hsv_to_rgb( rH, (facm*rS +fac*colS), rV, r_col+0, r_col+1, r_col+2); + rgb_to_hsv(col[0], col[1], col[2], &colH, &colS, &colV); + hsv_to_rgb(rH, (facm*rS +fac*colS), rV, r_col+0, r_col+1, r_col+2); } } break; case MA_RAMP_VAL: { - float rH,rS,rV; - float colH,colS,colV; - rgb_to_hsv(r_col[0],r_col[1],r_col[2],&rH,&rS,&rV); - rgb_to_hsv(col[0],col[1],col[2],&colH,&colS,&colV); - hsv_to_rgb( rH, rS, (facm*rV +fac*colV), r_col+0, r_col+1, r_col+2); + float rH, rS, rV; + float colH, colS, colV; + rgb_to_hsv(r_col[0], r_col[1], r_col[2], &rH, &rS, &rV); + rgb_to_hsv(col[0], col[1], col[2], &colH, &colS, &colV); + hsv_to_rgb(rH, rS, (facm*rV +fac*colV), r_col+0, r_col+1, r_col+2); } break; case MA_RAMP_COLOR: { - float rH,rS,rV; - float colH,colS,colV; - float tmpr,tmpg,tmpb; - rgb_to_hsv(col[0],col[1],col[2],&colH,&colS,&colV); + float rH, rS, rV; + float colH, colS, colV; + float tmpr, tmpg, tmpb; + rgb_to_hsv(col[0], col[1], col[2], &colH, &colS, &colV); if (colS != 0) { - rgb_to_hsv(r_col[0],r_col[1],r_col[2],&rH,&rS,&rV); - hsv_to_rgb( colH, colS, rV, &tmpr, &tmpg, &tmpb); + rgb_to_hsv(r_col[0], r_col[1], r_col[2], &rH, &rS, &rV); + hsv_to_rgb(colH, colS, rV, &tmpr, &tmpg, &tmpb); r_col[0] = facm*(r_col[0]) + fac*tmpr; r_col[1] = facm*(r_col[1]) + fac*tmpg; r_col[2] = facm*(r_col[2]) + fac*tmpb; diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 73e3576b57f..8b2e66812c7 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -142,7 +142,7 @@ typedef struct octal_node { struct ListBase elems; /* ListBase of MetaElem pointers (ml_pointer) */ float x_min, y_min, z_min; /* 1st border point */ float x_max, y_max, z_max; /* 7th border point */ - float x,y,z; /* center of node */ + float x, y, z; /* center of node */ int pos, neg; /* number of positive and negative MetaElements in the node */ int count; /* number of MetaElems, which belongs to the node */ } octal_node; @@ -453,7 +453,7 @@ int BKE_metaball_is_basis(Object *ob) } /* return nonzero if ob1 is a basis mball for ob */ -int BKE_metaball_is_basis_for (Object *ob1, Object *ob2) +int BKE_metaball_is_basis_for(Object *ob1, Object *ob2) { int basis1nr, basis2nr; char basis1name[MAX_ID_NAME], basis2name[MAX_ID_NAME]; @@ -520,7 +520,7 @@ Object *BKE_metaball_basis_find(Scene *scene, Object *basis) { Scene *sce_iter= scene; Base *base; - Object *ob,*bob= basis; + Object *ob, *bob= basis; MetaElem *ml=NULL; int basisnr, obnr; char basisname[MAX_ID_NAME], obname[MAX_ID_NAME]; @@ -614,10 +614,10 @@ Object *BKE_metaball_basis_find(Scene *scene, Object *basis) #define HASHBIT (5) #define HASHSIZE (size_t)(1<<(3*HASHBIT)) /*! < hash table size (32768) */ -#define HASH(i,j,k) ((((( (i) & 31)<<5) | ( (j) & 31))<<5 ) | ( (k) & 31) ) +#define HASH(i, j, k) ((((( (i) & 31)<<5) | ( (j) & 31))<<5 ) | ( (k) & 31) ) #define MB_BIT(i, bit) (((i)>>(bit))&1) -#define FLIP(i,bit) ((i)^1<<(bit)) /* flip the given bit of i */ +#define FLIP(i, bit) ((i)^1<<(bit)) /* flip the given bit of i */ /* **************** POLYGONIZATION ************************ */ @@ -713,13 +713,13 @@ static octal_node* find_metaball_octal_node(octal_node *node, float x, float y, if (y < node->y) { if (x < node->x) { if (node->nodes[0]) - return find_metaball_octal_node(node->nodes[0],x,y,z,depth--); + return find_metaball_octal_node(node->nodes[0], x, y, z, depth--); else return node; } else { if (node->nodes[1]) - return find_metaball_octal_node(node->nodes[1],x,y,z,depth--); + return find_metaball_octal_node(node->nodes[1], x, y, z, depth--); else return node; } @@ -727,13 +727,13 @@ static octal_node* find_metaball_octal_node(octal_node *node, float x, float y, else { if (x < node->x) { if (node->nodes[3]) - return find_metaball_octal_node(node->nodes[3],x,y,z,depth--); + return find_metaball_octal_node(node->nodes[3], x, y, z, depth--); else return node; } else { if (node->nodes[2]) - return find_metaball_octal_node(node->nodes[2],x,y,z,depth--); + return find_metaball_octal_node(node->nodes[2], x, y, z, depth--); else return node; } @@ -743,13 +743,13 @@ static octal_node* find_metaball_octal_node(octal_node *node, float x, float y, if (y < node->y) { if (x < node->x) { if (node->nodes[4]) - return find_metaball_octal_node(node->nodes[4],x,y,z,depth--); + return find_metaball_octal_node(node->nodes[4], x, y, z, depth--); else return node; } else { if (node->nodes[5]) - return find_metaball_octal_node(node->nodes[5],x,y,z,depth--); + return find_metaball_octal_node(node->nodes[5], x, y, z, depth--); else return node; } @@ -757,13 +757,13 @@ static octal_node* find_metaball_octal_node(octal_node *node, float x, float y, else { if (x < node->x) { if (node->nodes[7]) - return find_metaball_octal_node(node->nodes[7],x,y,z,depth--); + return find_metaball_octal_node(node->nodes[7], x, y, z, depth--); else return node; } else { if (node->nodes[6]) - return find_metaball_octal_node(node->nodes[6],x,y,z,depth--); + return find_metaball_octal_node(node->nodes[6], x, y, z, depth--); else return node; } @@ -881,7 +881,7 @@ static void *new_pgn_element(int size) } } - cur= MEM_callocN( sizeof(struct pgn_elements), "newpgn"); + cur= MEM_callocN(sizeof(struct pgn_elements), "newpgn"); cur->data= MEM_callocN(blocksize, "newpgn"); BLI_addtail(&lb, cur); @@ -919,9 +919,9 @@ static INTLISTS *cubetable[256]; /* edge: LB, LT, LN, LF, RB, RT, RN, RF, BN, BF, TN, TF */ static int corner1[12] = { - LBN,LTN,LBN,LBF,RBN,RTN,RBN,RBF,LBN,LBF,LTN,LTF}; + LBN, LTN, LBN, LBF, RBN, RTN, RBN, RBF, LBN, LBF, LTN, LTF}; static int corner2[12] = { - LBF,LTF,LTN,LTF,RBF,RTF,RTN,RTF,RBN,RBF,RTN,RTF}; + LBF, LTF, LTN, LTF, RBF, RTF, RTN, RTF, RBN, RBF, RTN, RTF}; static int leftface[12] = { B, L, L, F, R, T, N, R, N, B, T, F}; /* face on left when going corner1 to corner2 */ @@ -1197,7 +1197,7 @@ void BKE_metaball_cubeTable_free(void) /**** Storage ****/ -/* setcenter: set (i,j,k) entry of table[] +/* setcenter: set (i, j, k) entry of table[] * return 1 if already set; otherwise, set and return 0 */ static int setcenter(CENTERLIST *table[], int i, int j, int k) @@ -1405,7 +1405,7 @@ static void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2, int i = 0; MB_POINT pos, neg; float positive = 0.0f, negative = 0.0f; - float dx = 0.0f ,dy = 0.0f ,dz = 0.0f; + float dx = 0.0f, dy = 0.0f, dz = 0.0f; if (v1 < 0) { pos= *p2; @@ -1453,7 +1453,7 @@ static void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2, while (1) { if (i++ == RES) return; p->x = 0.5f*(pos.x + neg.x); - if ((function(p->x,p->y,p->z)) > 0.0f) pos.x = p->x; else neg.x = p->x; + if ((function(p->x, p->y, p->z)) > 0.0f) pos.x = p->x; else neg.x = p->x; } } @@ -1463,7 +1463,7 @@ static void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2, while (1) { if (i++ == RES) return; p->y = 0.5f*(pos.y + neg.y); - if ((function(p->x,p->y,p->z)) > 0.0f) pos.y = p->y; else neg.y = p->y; + if ((function(p->x, p->y, p->z)) > 0.0f) pos.y = p->y; else neg.y = p->y; } } @@ -1473,7 +1473,7 @@ static void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2, while (1) { if (i++ == RES) return; p->z = 0.5f*(pos.z + neg.z); - if ((function(p->x,p->y,p->z)) > 0.0f) pos.z = p->z; else neg.z = p->z; + if ((function(p->x, p->y, p->z)) > 0.0f) pos.z = p->z; else neg.z = p->z; } } @@ -1523,7 +1523,7 @@ static void add_cube(PROCESS *mbproc, int i, int j, int k, int count) /* set corners of initial cube: */ for (n = 0; n < 8; n++) - ncube->cube.corners[n] = setcorner(mbproc, a+MB_BIT(n,2), b+MB_BIT(n,1), c+MB_BIT(n,0)); + ncube->cube.corners[n] = setcorner(mbproc, a+MB_BIT(n, 2), b+MB_BIT(n, 1), c+MB_BIT(n, 0)); } } } @@ -1534,7 +1534,7 @@ static void find_first_points(PROCESS *mbproc, MetaBall *mb, int a) MB_POINT IN, in, OUT, out; /*point;*/ MetaElem *ml; int i, j, k, c_i, c_j, c_k; - int index[3]={1,0,-1}; + int index[3]={1, 0, -1}; float f =0.0f; float in_v /*, out_v*/; MB_POINT workp; @@ -1610,7 +1610,7 @@ static void find_first_points(PROCESS *mbproc, MetaBall *mb, int a) ny = abs((out.y - in.y)/mbproc->size); nz = abs((out.z - in.z)/mbproc->size); - MAXN = MAX3(nx,ny,nz); + MAXN = MAX3(nx, ny, nz); if (MAXN!=0.0f) { dx = (out.x - in.x)/MAXN; dy = (out.y - in.y)/MAXN; @@ -1774,7 +1774,7 @@ static float init_meta(Scene *scene, Object *ob) /* return totsize */ if (ml->s > 10.0f) ml->s = 10.0f; /* Rotation of MetaElem is stored in quat */ - quat_to_mat4( temp3,ml->quat); + quat_to_mat4(temp3, ml->quat); /* Translation of MetaElem */ unit_m4(temp2); @@ -1798,7 +1798,7 @@ static float init_meta(Scene *scene, Object *ob) /* return totsize */ /* MetaBall transformation */ mult_m4_m4m4(mat, temp2, temp1); - invert_m4_m4(imat,mat); + invert_m4_m4(imat, mat); mainb[a]->rad2= ml->rad*ml->rad; @@ -1884,11 +1884,11 @@ static float init_meta(Scene *scene, Object *ob) /* return totsize */ calc_mballco(mainb[a], vec); - size= fabsf( vec[0] ); + size= fabsf(vec[0]); if ( size > totsize ) totsize= size; - size= fabsf( vec[1] ); + size= fabsf(vec[1]); if ( size > totsize ) totsize= size; - size= fabsf( vec[2] ); + size= fabsf(vec[2]); if ( size > totsize ) totsize= size; vec[0]= mainb[a]->x - mainb[a]->rad; @@ -1897,11 +1897,11 @@ static float init_meta(Scene *scene, Object *ob) /* return totsize */ calc_mballco(mainb[a], vec); - size= fabsf( vec[0] ); + size= fabsf(vec[0]); if ( size > totsize ) totsize= size; - size= fabsf( vec[1] ); + size= fabsf(vec[1]); if ( size > totsize ) totsize= size; - size= fabsf( vec[2] ); + size= fabsf(vec[2]); if ( size > totsize ) totsize= size; } @@ -1951,12 +1951,12 @@ static void subdivide_metaball_octal_node(octal_node *node, float size_x, float { MetaElem *ml; ml_pointer *ml_p; - float x,y,z; - int a,i; + float x, y, z; + int a, i; /* create new nodes */ for (a=0;a<8;a++) { - node->nodes[a]= MEM_mallocN(sizeof(octal_node),"octal_node"); + node->nodes[a]= MEM_mallocN(sizeof(octal_node), "octal_node"); for (i=0;i<8;i++) node->nodes[a]->nodes[i]= NULL; node->nodes[a]->parent= node; diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index c7f6bf93831..4b14c2aec4b 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1783,7 +1783,7 @@ void mesh_calc_normals_mapping(MVert *mverts, int numVerts, { mesh_calc_normals_mapping_ex(mverts, numVerts, mloop, mpolys, numLoops, numPolys, polyNors_r, mfaces, numFaces, - origIndexFace, faceNors_r, TRUE); + origIndexFace, faceNors_r, FALSE); } void mesh_calc_normals_mapping_ex(MVert *mverts, int numVerts, @@ -2014,7 +2014,7 @@ static void bm_corners_to_loops(Mesh *me, int findex, int loopstart, int numTex, for (i=0; i<tot; i++, disps += side*side, ld++) { ld->totdisp = side*side; - ld->level = (int)(logf(side - 1.0f) / M_LN2) + 1; + ld->level = (int)(logf(side - 1.0f) / (float)M_LN2) + 1; if (ld->disps) MEM_freeN(ld->disps); @@ -2481,24 +2481,24 @@ int mesh_recalcTessellation(CustomData *fdata, ml = mloop + mp->loopstart; - BLI_begin_edgefill(&sf_ctx); + BLI_scanfill_begin(&sf_ctx); firstv = NULL; lastv = NULL; for (j=0; j<mp->totloop; j++, ml++) { - v = BLI_addfillvert(&sf_ctx, mvert[ml->v].co); + v = BLI_scanfill_vert_add(&sf_ctx, mvert[ml->v].co); v->keyindex = mp->loopstart + j; if (lastv) - BLI_addfilledge(&sf_ctx, lastv, v); + BLI_scanfill_edge_add(&sf_ctx, lastv, v); if (!firstv) firstv = v; lastv = v; } - BLI_addfilledge(&sf_ctx, lastv, firstv); + BLI_scanfill_edge_add(&sf_ctx, lastv, firstv); - totfilltri = BLI_edgefill(&sf_ctx, FALSE); + totfilltri = BLI_scanfill_calc(&sf_ctx, FALSE); if (totfilltri) { BLI_array_grow_items(mface_to_poly_map, totfilltri); BLI_array_grow_items(mface, totfilltri); @@ -2531,7 +2531,7 @@ int mesh_recalcTessellation(CustomData *fdata, } } - BLI_end_edgefill(&sf_ctx); + BLI_scanfill_end(&sf_ctx); } } @@ -2766,64 +2766,20 @@ int mesh_mpoly_to_mface(struct CustomData *fdata, struct CustomData *ldata, static void mesh_calc_ngon_normal(MPoly *mpoly, MLoop *loopstart, MVert *mvert, float normal[3]) { - - MVert *v1, *v2, *v3; - double u[3], v[3], w[3]; - double n[3] = {0.0, 0.0, 0.0}, l; + const int nverts = mpoly->totloop; + float const *v_prev = mvert[loopstart[nverts - 1].v].co; + float const *v_curr = mvert[loopstart->v].co; + float n[3] = {0.0f}; int i; - for (i = 0; i < mpoly->totloop; i++) { - v1 = mvert + loopstart[i].v; - v2 = mvert + loopstart[(i+1)%mpoly->totloop].v; - v3 = mvert + loopstart[(i+2)%mpoly->totloop].v; - - copy_v3db_v3fl(u, v1->co); - copy_v3db_v3fl(v, v2->co); - copy_v3db_v3fl(w, v3->co); - - /*this fixes some weird numerical error*/ - if (i==0) { - u[0] += 0.0001f; - u[1] += 0.0001f; - u[2] += 0.0001f; - } - - /* newell's method - * - * so thats?: - * (a[1] - b[1]) * (a[2] + b[2]); - * a[1]*b[2] - b[1]*a[2] - b[1]*b[2] + a[1]*a[2] - * - * odd. half of that is the cross product. . .what's the - * other half? - * - * also could be like a[1]*(b[2] + a[2]) - b[1]*(a[2] - b[2]) - */ - - n[0] += (u[1] - v[1]) * (u[2] + v[2]); - n[1] += (u[2] - v[2]) * (u[0] + v[0]); - n[2] += (u[0] - v[0]) * (u[1] + v[1]); + /* Newell's Method */ + for (i = 0; i < nverts; v_prev = v_curr, v_curr = mvert[loopstart[++i].v].co) { + add_newell_cross_v3_v3v3(n, v_prev, v_curr); } - - l = n[0]*n[0]+n[1]*n[1]+n[2]*n[2]; - l = sqrt(l); - - if (l == 0.0) { - normal[0] = 0.0f; - normal[1] = 0.0f; - normal[2] = 1.0f; - return; + if (UNLIKELY(normalize_v3_v3(normal, n) == 0.0f)) { + normal[2] = 1.0f; /* other axis set to 0.0 */ } - else l = 1.0f / l; - - n[0] *= l; - n[1] *= l; - n[2] *= l; - - normal[0] = (float) n[0]; - normal[1] = (float) n[1]; - normal[2] = (float) n[2]; } void mesh_calc_poly_normal(MPoly *mpoly, MLoop *loopstart, @@ -2857,54 +2813,20 @@ void mesh_calc_poly_normal(MPoly *mpoly, MLoop *loopstart, static void mesh_calc_ngon_normal_coords(MPoly *mpoly, MLoop *loopstart, const float (*vertex_coords)[3], float normal[3]) { - - const float *v1, *v2, *v3; - double u[3], v[3], w[3]; - double n[3] = {0.0, 0.0, 0.0}, l; + const int nverts = mpoly->totloop; + float const *v_prev = vertex_coords[loopstart[nverts - 1].v]; + float const *v_curr = vertex_coords[loopstart->v]; + float n[3] = {0.0f}; int i; - for (i = 0; i < mpoly->totloop; i++) { - v1 = (const float *)(vertex_coords + loopstart[i].v); - v2 = (const float *)(vertex_coords + loopstart[(i+1)%mpoly->totloop].v); - v3 = (const float *)(vertex_coords + loopstart[(i+2)%mpoly->totloop].v); - - copy_v3db_v3fl(u, v1); - copy_v3db_v3fl(v, v2); - copy_v3db_v3fl(w, v3); - - /*this fixes some weird numerical error*/ - if (i==0) { - u[0] += 0.0001f; - u[1] += 0.0001f; - u[2] += 0.0001f; - } - - n[0] += (u[1] - v[1]) * (u[2] + v[2]); - n[1] += (u[2] - v[2]) * (u[0] + v[0]); - n[2] += (u[0] - v[0]) * (u[1] + v[1]); + /* Newell's Method */ + for (i = 0; i < nverts; v_prev = v_curr, v_curr = vertex_coords[loopstart[++i].v]) { + add_newell_cross_v3_v3v3(n, v_prev, v_curr); } - l = n[0]*n[0]+n[1]*n[1]+n[2]*n[2]; - l = sqrt(l); - - if (l == 0.0) { - normal[0] = 0.0f; - normal[1] = 0.0f; - normal[2] = 1.0f; - - return; - } - else { - l = 1.0f / l; + if (UNLIKELY(normalize_v3_v3(normal, n) == 0.0f)) { + normal[2] = 1.0f; /* other axis set to 0.0 */ } - - n[0] *= l; - n[1] *= l; - n[2] *= l; - - normal[0] = (float) n[0]; - normal[1] = (float) n[1]; - normal[2] = (float) n[2]; } void mesh_calc_poly_normal_coords(MPoly *mpoly, MLoop *loopstart, diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 12aa6232cb0..98cbc957201 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -296,7 +296,7 @@ int modifiers_getCageIndex(struct Scene *scene, Object *ob, int *lastPossibleCag } /* Find the last modifier acting on the cage. */ - for (i=0; md; i++,md=md->next) { + for (i=0; md; i++, md=md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); md->scene= scene; diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index d548d7589bb..7a279572738 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -155,7 +155,7 @@ static void get_sequence_fname(MovieClip *clip, int framenr, char *name) /* movieclips always points to first image from sequence, * autoguess offset for now. could be something smarter in the future */ - offset= sequence_guess_offset(clip->name, strlen(head), numlen); + offset = sequence_guess_offset(clip->name, strlen(head), numlen); if (numlen) BLI_stringenc(name, head, tail, numlen, offset + framenr - 1); @@ -195,7 +195,7 @@ static ImBuf *movieclip_load_sequence_file(MovieClip *clip, MovieClipUser *user, { struct ImBuf *ibuf; char name[FILE_MAX]; - int loadflag, use_proxy= 0; + int loadflag, use_proxy = 0; use_proxy = (flag & MCLIP_USE_PROXY) && user->render_size != MCLIP_PROXY_RENDER_SIZE_FULL; if (use_proxy) { @@ -432,7 +432,7 @@ static MovieClip *movieclip_alloc(const char *name) clip = alloc_libblock(&G.main->movieclip, ID_MC, name); - clip->aspx = clip->aspy= 1.0f; + clip->aspx = clip->aspy = 1.0f; BKE_tracking_init_settings(&clip->tracking); @@ -453,7 +453,7 @@ static MovieClip *movieclip_alloc(const char *name) MovieClip *BKE_movieclip_file_add(const char *name) { MovieClip *clip; - MovieClipUser user; + MovieClipUser user = {0}; int file, len, width, height; const char *libname; char str[FILE_MAX], strtest[FILE_MAX]; @@ -462,7 +462,7 @@ MovieClip *BKE_movieclip_file_add(const char *name) BLI_path_abs(str, G.main->name); /* exists? */ - file = BLI_open(str, O_BINARY|O_RDONLY,0); + file = BLI_open(str, O_BINARY | O_RDONLY, 0); if (file == -1) return NULL; close(file); @@ -660,7 +660,7 @@ static ImBuf *put_postprocessed_frame_to_cache(MovieClip *clip, MovieClipUser *u copy_v2_v2(cache->postprocessed.principal, camera->principal); copy_v3_v3(&cache->postprocessed.k1, &camera->k1); cache->postprocessed.undistoriton_used = TRUE; - postproc_ibuf= get_undistorted_ibuf(clip, NULL, ibuf); + postproc_ibuf = get_undistorted_ibuf(clip, NULL, ibuf); } else { cache->postprocessed.undistoriton_used = FALSE; @@ -704,14 +704,14 @@ static ImBuf *movieclip_get_postprocessed_ibuf(MovieClip *clip, MovieClipUser *u /* try to obtain cached postprocessed frame first */ if (need_postprocessed_frame(user, flag, postprocess_flag)) { - ibuf= get_postprocessed_cached_frame(clip, user, flag, postprocess_flag); + ibuf = get_postprocessed_cached_frame(clip, user, flag, postprocess_flag); if (!ibuf) need_postprocess = TRUE; } if (!ibuf) - ibuf= get_imbuf_cache(clip, user, flag); + ibuf = get_imbuf_cache(clip, user, flag); if (!ibuf) { int use_sequence = FALSE; @@ -825,7 +825,7 @@ static ImBuf *put_stabilized_frame_to_cache(MovieClip *clip, MovieClipUser *user stableibuf = BKE_tracking_stabilize(&clip->tracking, framenr, ibuf, tloc, &tscale, &tangle); - cache->stabilized.ibuf= stableibuf; + cache->stabilized.ibuf = stableibuf; copy_v2_v2(cache->stabilized.loc, tloc); @@ -862,7 +862,7 @@ ImBuf *BKE_movieclip_get_stable_ibuf(MovieClip *clip, MovieClipUser *user, float return NULL; if (clip->tracking.stabilization.flag & TRACKING_2D_STABILIZATION) { - MovieClipCache *cache= clip->cache; + MovieClipCache *cache = clip->cache; stableibuf = get_stable_cached_frame(clip, user, framenr, postprocess_flag); @@ -873,20 +873,20 @@ ImBuf *BKE_movieclip_get_stable_ibuf(MovieClip *clip, MovieClipUser *user, float copy_v2_v2(loc, cache->stabilized.loc); if (scale) - *scale= cache->stabilized.scale; + *scale = cache->stabilized.scale; if (angle) - *angle= cache->stabilized.angle; + *angle = cache->stabilized.angle; } else { if (loc) zero_v2(loc); if (scale) - *scale= 1.0f; + *scale = 1.0f; if (angle) - *angle= 0.0f; + *angle = 0.0f; stableibuf = ibuf; } @@ -1044,7 +1044,7 @@ void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClip if (user->render_flag & MCLIP_PROXY_RENDER_UNDISTORT) { int width, height; - float aspy= 1.0f / clip->tracking.camera.pixel_aspect; + float aspy = 1.0f / clip->tracking.camera.pixel_aspect; BKE_movieclip_get_size(clip, user, &width, &height); @@ -1058,14 +1058,14 @@ void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClip } /* NOTE: margin should be kept in sync with value from ui_draw_but_TRACKPREVIEW */ - tmpibuf= BKE_tracking_get_pattern_imbuf(ibuf, track, &undist_marker, 3 /* margin */, + tmpibuf = BKE_tracking_get_pattern_imbuf(ibuf, track, &undist_marker, 3 /* margin */, 1 /* anchor */, scopes->track_pos, NULL); if (tmpibuf->rect_float) IMB_rect_from_float(tmpibuf); if (tmpibuf->rect) - scopes->track_preview= tmpibuf; + scopes->track_preview = tmpibuf; else IMB_freeImBuf(tmpibuf); } diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index d7212e5eaf9..f3901cec506 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -747,7 +747,7 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob) copy_v3_v3(origco[i], me->mvert[i].co); for (i = 0; i < me->totvert; ++i) { - float avg_no[3] = {0,0,0}, center[3] = {0,0,0}, push[3]; + float avg_no[3] = {0, 0, 0}, center[3] = {0, 0, 0}, push[3]; float dist; int tot = 0; @@ -942,7 +942,7 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm MPoly *mpoly = me->mpoly; MDisps *mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS); int *gridOffset; - int i, k, /*numGrids,*/ gridSize, dGridSize, dSkip; + int i, k, /*numGrids, */ gridSize, dGridSize, dSkip; int totloop, totpoly; /* this happens in the dm made by bmesh_mdisps_space_set */ @@ -1545,9 +1545,9 @@ void multires_free(Multires *mr) } static void create_old_vert_face_map(ListBase **map, IndexNode **mem, const MultiresFace *mface, - const int totvert, const int totface) + const int totvert, const int totface) { - int i,j; + int i, j; IndexNode *node = NULL; (*map) = MEM_callocN(sizeof(ListBase) * totvert, "vert face map"); @@ -1566,7 +1566,7 @@ static void create_old_vert_face_map(ListBase **map, IndexNode **mem, const Mult static void create_old_vert_edge_map(ListBase **map, IndexNode **mem, const MultiresEdge *medge, const int totvert, const int totedge) { - int i,j; + int i, j; IndexNode *node = NULL; (*map) = MEM_callocN(sizeof(ListBase) * totvert, "vert edge map"); @@ -2043,7 +2043,7 @@ static void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3]) /* MLoop *mloop = me->mloop; */ /* UNUSED */ MDisps *mdisps; int *gridOffset; - int i, /*numGrids,*/ gridSize, dGridSize, dSkip, totvert; + int i, /*numGrids, */ gridSize, dGridSize, dSkip, totvert; float (*vertCos)[3] = NULL; MultiresModifierData *mmd= get_multires_modifier(scene, ob, 1); MultiresModifierData high_mmd; diff --git a/source/blender/blenkernel/intern/navmesh_conversion.c b/source/blender/blenkernel/intern/navmesh_conversion.c index 23d2f50c3f7..24382b3bf91 100644 --- a/source/blender/blenkernel/intern/navmesh_conversion.c +++ b/source/blender/blenkernel/intern/navmesh_conversion.c @@ -86,8 +86,8 @@ float distPointToSegmentSq(const float* point, const float* a, const float* b) float abx[3], dx[3]; float d, t; - sub_v3_v3v3(abx, b,a); - sub_v3_v3v3(dx, point,a); + sub_v3_v3v3(abx, b, a); + sub_v3_v3v3(dx, point, a); d = abx[0]*abx[0]+abx[2]*abx[2]; t = abx[0]*dx[0]+abx[2]*dx[2]; @@ -447,7 +447,7 @@ int buildNavMeshDataByDerivedMesh(DerivedMesh *dm, int *vertsPerPoly, } res = buildNavMeshData(*nverts, *verts, ntris, tris, recastData, *trisToFacesMap, - ndtris, dtris, npolys, dmeshes,polys, vertsPerPoly, + ndtris, dtris, npolys, dmeshes, polys, vertsPerPoly, dtrisToPolysMap, dtrisToTrisMap); if (!res) { printf("Converting navmesh: Error! Can't get vertices and indices from mesh\n"); diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 5dfeb37b2ee..96c62a32139 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -73,7 +73,7 @@ /* Remove the given NLA strip from the NLA track it occupies, free the strip's data, * and the strip itself. */ -void free_nlastrip (ListBase *strips, NlaStrip *strip) +void free_nlastrip(ListBase *strips, NlaStrip *strip) { NlaStrip *cs, *csn; @@ -111,7 +111,7 @@ void free_nlastrip (ListBase *strips, NlaStrip *strip) /* Remove the given NLA track from the set of NLA tracks, free the track's data, * and the track itself. */ -void free_nlatrack (ListBase *tracks, NlaTrack *nlt) +void free_nlatrack(ListBase *tracks, NlaTrack *nlt) { NlaStrip *strip, *stripn; @@ -135,7 +135,7 @@ void free_nlatrack (ListBase *tracks, NlaTrack *nlt) /* Free the elements of type NLA Tracks provided in the given list, but do not free * the list itself since that is not free-standing */ -void free_nladata (ListBase *tracks) +void free_nladata(ListBase *tracks) { NlaTrack *nlt, *nltn; @@ -216,7 +216,7 @@ NlaTrack *copy_nlatrack (NlaTrack *nlt) } /* Copy all NLA data */ -void copy_nladata (ListBase *dst, ListBase *src) +void copy_nladata(ListBase *dst, ListBase *src) { NlaTrack *nlt, *nlt_d; @@ -486,7 +486,7 @@ static float nlastrip_get_frame_transition (NlaStrip *strip, float cframe, short * only secure for 'internal' (i.e. within AnimSys evaluation) operations, * but should not be directly relied on for stuff which interacts with editors */ -float nlastrip_get_frame (NlaStrip *strip, float cframe, short mode) +float nlastrip_get_frame(NlaStrip *strip, float cframe, short mode) { switch (strip->type) { case NLASTRIP_TYPE_META: /* meta - for now, does the same as transition (is really just an empty container) */ @@ -506,7 +506,7 @@ float nlastrip_get_frame (NlaStrip *strip, float cframe, short mode) * Public API method - perform this mapping using the given AnimData block * and perform any necessary sanity checks on the value */ -float BKE_nla_tweakedit_remap (AnimData *adt, float cframe, short mode) +float BKE_nla_tweakedit_remap(AnimData *adt, float cframe, short mode) { NlaStrip *strip; @@ -546,7 +546,7 @@ float BKE_nla_tweakedit_remap (AnimData *adt, float cframe, short mode) /* (these functions are used for NLA-Tracks and also for nested/meta-strips) */ /* Check if there is any space in the given list to add the given strip */ -short BKE_nlastrips_has_space (ListBase *strips, float start, float end) +short BKE_nlastrips_has_space(ListBase *strips, float start, float end) { NlaStrip *strip; @@ -580,7 +580,7 @@ short BKE_nlastrips_has_space (ListBase *strips, float start, float end) /* Rearrange the strips in the track so that they are always in order * (usually only needed after a strip has been moved) */ -void BKE_nlastrips_sort_strips (ListBase *strips) +void BKE_nlastrips_sort_strips(ListBase *strips) { ListBase tmp = {NULL, NULL}; NlaStrip *strip, *sstrip, *stripn; @@ -624,7 +624,7 @@ void BKE_nlastrips_sort_strips (ListBase *strips) /* Add the given NLA-Strip to the given list of strips, assuming that it * isn't currently a member of another list */ -short BKE_nlastrips_add_strip (ListBase *strips, NlaStrip *strip) +short BKE_nlastrips_add_strip(ListBase *strips, NlaStrip *strip) { NlaStrip *ns; short not_added = 1; @@ -662,7 +662,7 @@ short BKE_nlastrips_add_strip (ListBase *strips, NlaStrip *strip) * contained within 'Meta-Strips' which act as strips which contain strips. * temp: are the meta-strips to be created 'temporary' ones used for transforms? */ -void BKE_nlastrips_make_metas (ListBase *strips, short temp) +void BKE_nlastrips_make_metas(ListBase *strips, short temp) { NlaStrip *mstrip = NULL; NlaStrip *strip, *stripn; @@ -714,7 +714,7 @@ void BKE_nlastrips_make_metas (ListBase *strips, short temp) } /* Split a meta-strip into a set of normal strips */ -void BKE_nlastrips_clear_metastrip (ListBase *strips, NlaStrip *strip) +void BKE_nlastrips_clear_metastrip(ListBase *strips, NlaStrip *strip) { NlaStrip *cs, *csn; @@ -739,7 +739,7 @@ void BKE_nlastrips_clear_metastrip (ListBase *strips, NlaStrip *strip) * sel: only consider selected meta-strips, otherwise all meta-strips are removed * onlyTemp: only remove the 'temporary' meta-strips used for transforms */ -void BKE_nlastrips_clear_metas (ListBase *strips, short onlySel, short onlyTemp) +void BKE_nlastrips_clear_metas(ListBase *strips, short onlySel, short onlyTemp) { NlaStrip *strip, *stripn; @@ -766,7 +766,7 @@ void BKE_nlastrips_clear_metas (ListBase *strips, short onlySel, short onlyTemp) /* Add the given NLA-Strip to the given Meta-Strip, assuming that the * strip isn't attached to anyy list of strips */ -short BKE_nlameta_add_strip (NlaStrip *mstrip, NlaStrip *strip) +short BKE_nlameta_add_strip(NlaStrip *mstrip, NlaStrip *strip) { /* sanity checks */ if (ELEM(NULL, mstrip, strip)) @@ -816,7 +816,7 @@ short BKE_nlameta_add_strip (NlaStrip *mstrip, NlaStrip *strip) /* Adjust the settings of NLA-Strips contained within a Meta-Strip (recursively), * until the Meta-Strips children all fit within the Meta-Strip's new dimensions */ -void BKE_nlameta_flush_transforms (NlaStrip *mstrip) +void BKE_nlameta_flush_transforms(NlaStrip *mstrip) { NlaStrip *strip; float oStart, oEnd, offset; @@ -915,7 +915,7 @@ NlaTrack *BKE_nlatrack_find_active (ListBase *tracks) /* Toggle the 'solo' setting for the given NLA-track, making sure that it is the only one * that has this status in its AnimData block. */ -void BKE_nlatrack_solo_toggle (AnimData *adt, NlaTrack *nlt) +void BKE_nlatrack_solo_toggle(AnimData *adt, NlaTrack *nlt) { NlaTrack *nt; @@ -947,7 +947,7 @@ void BKE_nlatrack_solo_toggle (AnimData *adt, NlaTrack *nlt) /* Make the given NLA-track the active one for the given stack. If no track is provided, * this function can be used to simply deactivate all the NLA tracks in the given stack too. */ -void BKE_nlatrack_set_active (ListBase *tracks, NlaTrack *nlt_a) +void BKE_nlatrack_set_active(ListBase *tracks, NlaTrack *nlt_a) { NlaTrack *nlt; @@ -965,7 +965,7 @@ void BKE_nlatrack_set_active (ListBase *tracks, NlaTrack *nlt_a) } /* Check if there is any space in the given track to add a strip of the given length */ -short BKE_nlatrack_has_space (NlaTrack *nlt, float start, float end) +short BKE_nlatrack_has_space(NlaTrack *nlt, float start, float end) { /* sanity checks * - track must exist @@ -987,7 +987,7 @@ short BKE_nlatrack_has_space (NlaTrack *nlt, float start, float end) /* Rearrange the strips in the track so that they are always in order * (usually only needed after a strip has been moved) */ -void BKE_nlatrack_sort_strips (NlaTrack *nlt) +void BKE_nlatrack_sort_strips(NlaTrack *nlt) { /* sanity checks */ if (ELEM(NULL, nlt, nlt->strips.first)) @@ -1000,7 +1000,7 @@ void BKE_nlatrack_sort_strips (NlaTrack *nlt) /* Add the given NLA-Strip to the given NLA-Track, assuming that it * isn't currently attached to another one */ -short BKE_nlatrack_add_strip (NlaTrack *nlt, NlaStrip *strip) +short BKE_nlatrack_add_strip(NlaTrack *nlt, NlaStrip *strip) { /* sanity checks */ if (ELEM(NULL, nlt, strip)) @@ -1013,7 +1013,7 @@ short BKE_nlatrack_add_strip (NlaTrack *nlt, NlaStrip *strip) /* Get the extents of the given NLA-Track including gaps between strips, * returning whether this succeeded or not */ -short BKE_nlatrack_get_bounds (NlaTrack *nlt, float bounds[2]) +short BKE_nlatrack_get_bounds(NlaTrack *nlt, float bounds[2]) { NlaStrip *strip; @@ -1061,7 +1061,7 @@ NlaStrip *BKE_nlastrip_find_active (NlaTrack *nlt) } /* Make the given NLA-Strip the active one within the given block */ -void BKE_nlastrip_set_active (AnimData *adt, NlaStrip *strip) +void BKE_nlastrip_set_active(AnimData *adt, NlaStrip *strip) { NlaTrack *nlt; NlaStrip *nls; @@ -1083,7 +1083,7 @@ void BKE_nlastrip_set_active (AnimData *adt, NlaStrip *strip) /* Does the given NLA-strip fall within the given bounds (times)? */ -short BKE_nlastrip_within_bounds (NlaStrip *strip, float min, float max) +short BKE_nlastrip_within_bounds(NlaStrip *strip, float min, float max) { const float stripLen= (strip) ? strip->end - strip->start : 0.0f; const float boundsLen= fabsf(max - min); @@ -1096,15 +1096,15 @@ short BKE_nlastrip_within_bounds (NlaStrip *strip, float min, float max) * - first 2 cases cover when the strip length is less than the bounding area * - second 2 cases cover when the strip length is greater than the bounding area */ - if ( (stripLen < boundsLen) && - !(IN_RANGE(strip->start, min, max) || - IN_RANGE(strip->end, min, max)) ) + if ((stripLen < boundsLen) && + !(IN_RANGE(strip->start, min, max) || + IN_RANGE(strip->end, min, max))) { return 0; } - if ( (stripLen > boundsLen) && - !(IN_RANGE(min, strip->start, strip->end) || - IN_RANGE(max, strip->start, strip->end)) ) + if ((stripLen > boundsLen) && + !(IN_RANGE(min, strip->start, strip->end) || + IN_RANGE(max, strip->start, strip->end)) ) { return 0; } @@ -1116,7 +1116,7 @@ short BKE_nlastrip_within_bounds (NlaStrip *strip, float min, float max) /* Recalculate the start and end frames for the current strip, after changing * the extents of the action or the mapping (repeats or scale factor) info */ -void BKE_nlastrip_recalculate_bounds (NlaStrip *strip) +void BKE_nlastrip_recalculate_bounds(NlaStrip *strip) { float actlen, mapping; @@ -1171,7 +1171,7 @@ static short nlastrip_is_first (AnimData *adt, NlaStrip *strip) /* Animated Strips ------------------------------------------- */ /* Check if the given NLA-Track has any strips with own F-Curves */ -short BKE_nlatrack_has_animated_strips (NlaTrack *nlt) +short BKE_nlatrack_has_animated_strips(NlaTrack *nlt) { NlaStrip *strip; @@ -1190,7 +1190,7 @@ short BKE_nlatrack_has_animated_strips (NlaTrack *nlt) } /* Check if given NLA-Tracks have any strips with own F-Curves */ -short BKE_nlatracks_have_animated_strips (ListBase *tracks) +short BKE_nlatracks_have_animated_strips(ListBase *tracks) { NlaTrack *nlt; @@ -1209,7 +1209,7 @@ short BKE_nlatracks_have_animated_strips (ListBase *tracks) } /* Validate the NLA-Strips 'control' F-Curves based on the flags set*/ -void BKE_nlastrip_validate_fcurves (NlaStrip *strip) +void BKE_nlastrip_validate_fcurves(NlaStrip *strip) { FCurve *fcu; @@ -1272,7 +1272,7 @@ static int nla_editbone_name_check(void *arg, const char *name) * as we need to ensure that the name is unique over several lists of tracks, * not just a single track. */ -void BKE_nlastrip_validate_name (AnimData *adt, NlaStrip *strip) +void BKE_nlastrip_validate_name(AnimData *adt, NlaStrip *strip) { GHash *gh; NlaStrip *tstrip; @@ -1416,7 +1416,7 @@ static void BKE_nlastrip_validate_autoblends (NlaTrack *nlt, NlaStrip *nls) } /* Ensure that auto-blending and other settings are set correctly */ -void BKE_nla_validate_state (AnimData *adt) +void BKE_nla_validate_state(AnimData *adt) { NlaStrip *strip, *fstrip=NULL; NlaTrack *nlt; @@ -1470,7 +1470,7 @@ void BKE_nla_validate_state (AnimData *adt) * so no checks for this are performed. */ // TODO: maybe we should have checks for this too... -void BKE_nla_action_pushdown (AnimData *adt) +void BKE_nla_action_pushdown(AnimData *adt) { NlaStrip *strip; @@ -1518,7 +1518,7 @@ void BKE_nla_action_pushdown (AnimData *adt) /* Find the active strip + track combo, and set them up as the tweaking track, * and return if successful or not. */ -short BKE_nla_tweakmode_enter (AnimData *adt) +short BKE_nla_tweakmode_enter(AnimData *adt) { NlaTrack *nlt, *activeTrack=NULL; NlaStrip *strip, *activeStrip=NULL; @@ -1619,7 +1619,7 @@ short BKE_nla_tweakmode_enter (AnimData *adt) } /* Exit tweakmode for this AnimData block */ -void BKE_nla_tweakmode_exit (AnimData *adt) +void BKE_nla_tweakmode_exit(AnimData *adt) { NlaStrip *strip; NlaTrack *nlt; diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 2fb3f81b147..b2a85ad0629 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -141,8 +141,8 @@ void ntreeInitTypes(bNodeTree *ntree) /* needed info if the pynode script fails now: */ node->storage= ntree; if (node->id!=NULL) { /* not an empty script node */ - node->custom1= 0; - node->custom1= BSET(node->custom1,NODE_DYNAMIC_ADDEXIST); + node->custom1 = 0; + node->custom1 = BSET(node->custom1, NODE_DYNAMIC_ADDEXIST); } // if (node->typeinfo) // node->typeinfo->initfunc(node); diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 78a57534e2b..bf2e5b833b6 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -56,6 +56,7 @@ #include "DNA_space_types.h" #include "DNA_view3d_types.h" #include "DNA_world_types.h" +#include "DNA_object_types.h" #include "BLI_blenlib.h" #include "BLI_bpath.h" @@ -164,9 +165,9 @@ void object_free_particlesystems(Object *ob) while (ob->particlesystem.first) { ParticleSystem *psys = ob->particlesystem.first; - BLI_remlink(&ob->particlesystem,psys); + BLI_remlink(&ob->particlesystem, psys); - psys_free(ob,psys); + psys_free(ob, psys); } } @@ -543,7 +544,7 @@ void unlink_object(Object *ob) BoidParticle *bpa; int p; - for (p=0,pa=tpsys->particles; p<tpsys->totpart; p++,pa++) { + for (p=0, pa=tpsys->particles; p<tpsys->totpart; p++, pa++) { bpa = pa->boid; if (bpa->ground == ob) bpa->ground = NULL; @@ -627,7 +628,8 @@ void unlink_object(Object *ob) #endif if (sce->ed) { Sequence *seq; - SEQ_BEGIN (sce->ed, seq) { + SEQ_BEGIN (sce->ed, seq) + { if (seq->scene_camera == ob) { seq->scene_camera = NULL; } @@ -755,7 +757,7 @@ int exist_object(Object *obtest) /* *************************************************** */ -static void *add_obdata_from_type(int type) +void *add_obdata_from_type(int type) { switch (type) { case OB_MESH: return add_mesh("Mesh"); @@ -763,7 +765,7 @@ static void *add_obdata_from_type(int type) case OB_SURF: return BKE_curve_add("Surf", OB_SURF); case OB_FONT: return BKE_curve_add("Text", OB_FONT); case OB_MBALL: return BKE_metaball_add("Meta"); - case OB_CAMERA: return add_camera("Camera"); + case OB_CAMERA: return BKE_camera_add("Camera"); case OB_LAMP: return add_lamp("Lamp"); case OB_LATTICE: return add_lattice("Lattice"); case OB_ARMATURE: return add_armature("Armature"); @@ -800,6 +802,9 @@ Object *add_only_object(int type, const char *name) { Object *ob; + if(!name) + name = get_obdata_defname(type); + ob= alloc_libblock(&G.main->object, ID_OB, name); /* default object vars */ @@ -888,6 +893,7 @@ Object *add_object(struct Scene *scene, int type) ob->lay= scene->lay; base= scene_add_base(scene, ob); + scene_deselect_all(scene); scene_select_base(scene, base); ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; @@ -1336,7 +1342,7 @@ void object_copy_proxy_drivers(Object *ob, Object *target) if ((Object *)dtar->id == target) dtar->id= (ID *)ob; else { - /* only on local objects because this causes indirect links a -> b -> c,blend to point directly to a.blend + /* only on local objects because this causes indirect links a -> b -> c, blend to point directly to a.blend * when a.blend has a proxy thats linked into c.blend */ if (ob->id.lib==NULL) id_lib_extern((ID *)dtar->id); @@ -1455,7 +1461,7 @@ void object_scale_to_mat3(Object *ob, float mat[][3]) { float vec[3]; mul_v3_v3v3(vec, ob->size, ob->dscale); - size_to_mat3( mat,vec); + size_to_mat3(mat, vec); } void object_rot_to_mat3(Object *ob, float mat[][3]) @@ -1702,12 +1708,12 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4]) /* vec: 4 items! */ - if ( where_on_path(par, ctime, vec, dir, cu->flag & CU_FOLLOW ? quat:NULL, &radius, NULL) ) { + if (where_on_path(par, ctime, vec, dir, cu->flag & CU_FOLLOW ? quat:NULL, &radius, NULL)) { if (cu->flag & CU_FOLLOW) { #if 0 float x1, q[4]; - vec_to_quat( quat,dir, ob->trackflag, ob->upflag); + vec_to_quat(quat, dir, ob->trackflag, ob->upflag); /* the tilt */ normalize_v3(dir); @@ -1811,7 +1817,7 @@ static void give_parvert(Object *par, int nr, float vec[3]) } if (count==0) { - /* keep as 0,0,0 */ + /* keep as 0, 0, 0 */ } else if (count > 0) { mul_v3_fl(vec, 1.0f / count); @@ -1906,8 +1912,8 @@ static void ob_parvert3(Object *ob, Object *par, float mat[][4]) give_parvert(par, ob->par2, v2); give_parvert(par, ob->par3, v3); - tri_to_quat( q,v1, v2, v3); - quat_to_mat3( cmat,q); + tri_to_quat(q, v1, v2, v3); + quat_to_mat3(cmat, q); copy_m4_m3(mat, cmat); if (ob->type==OB_CURVE) { @@ -1928,7 +1934,7 @@ static int where_is_object_parslow(Object *ob, float obmat[4][4], float slowmat[ int a; // include framerate - fac1= ( 1.0f / (1.0f + fabsf(ob->sf)) ); + fac1= (1.0f / (1.0f + fabsf(ob->sf)) ); if (fac1 >= 1.0f) return 0; fac2= 1.0f-fac1; @@ -2040,7 +2046,7 @@ static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[ case PAROBJECT: ok= 0; if (par->type==OB_CURVE) { - if ( ((Curve *)par->data)->flag & CU_PATH ) { + if (((Curve *)par->data)->flag & CU_PATH ) { ob_parcurve(scene, ob, par, tmat); ok= 1; } @@ -2093,7 +2099,7 @@ static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[ copy_m3_m4(originmat, tmat); // origin, voor help line - if ( (ob->partype & PARTYPE)==PARSKEL ) { + if ((ob->partype & PARTYPE)==PARSKEL ) { copy_v3_v3(ob->orig, par->obmat[3]); } else { @@ -2179,7 +2185,7 @@ void what_does_parent(Scene *scene, Object *ob, Object *workob) BoundBox *unit_boundbox(void) { BoundBox *bb; - float min[3] = {-1.0f,-1.0f,-1.0f}, max[3] = {-1.0f,-1.0f,-1.0f}; + float min[3] = {-1.0f, -1.0f, -1.0f}, max[3] = {-1.0f, -1.0f, -1.0f}; bb= MEM_callocN(sizeof(BoundBox), "OB-BoundBox"); boundbox_set_from_min_max(bb, min, max); @@ -2207,7 +2213,7 @@ BoundBox *object_get_boundbox(Object *ob) bb = mesh_get_bb(ob); } else if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { - bb= ob->bb ? ob->bb : ( (Curve *)ob->data )->bb; + bb= ob->bb ? ob->bb : ((Curve *)ob->data )->bb; } else if (ob->type==OB_MBALL) { bb= ob->bb; @@ -2233,7 +2239,7 @@ void object_get_dimensions(Object *ob, float vec[3]) if (bb) { float scale[3]; - mat4_to_size( scale,ob->obmat); + mat4_to_size(scale, ob->obmat); vec[0] = fabsf(scale[0]) * (bb->vec[4][0] - bb->vec[0][0]); vec[1] = fabsf(scale[1]) * (bb->vec[2][1] - bb->vec[0][1]); @@ -2252,7 +2258,7 @@ void object_set_dimensions(Object *ob, const float *value) if (bb) { float scale[3], len[3]; - mat4_to_size( scale,ob->obmat); + mat4_to_size(scale, ob->obmat); len[0] = bb->vec[4][0] - bb->vec[0][0]; len[1] = bb->vec[2][1] - bb->vec[0][1]; @@ -2654,7 +2660,7 @@ void object_handle_update(Scene *scene, Object *ob) else if (psys->flag & PSYS_DELETE) { tpsys=psys->next; BLI_remlink(&ob->particlesystem, psys); - psys_free(ob,psys); + psys_free(ob, psys); psys= tpsys; } else @@ -2906,7 +2912,7 @@ static KeyBlock *insert_lattkey(Scene *scene, Object *ob, const char *name, int int newkey= 0; if (key==NULL) { - key= lt->key= add_key( (ID *)lt); + key= lt->key= add_key((ID *)lt); key->type= KEY_RELATIVE; newkey= 1; } @@ -2944,7 +2950,7 @@ static KeyBlock *insert_curvekey(Scene *scene, Object *ob, const char *name, int int newkey= 0; if (key==NULL) { - key= cu->key= add_key( (ID *)cu); + key= cu->key= add_key((ID *)cu); key->type = KEY_RELATIVE; newkey= 1; } @@ -2991,8 +2997,7 @@ KeyBlock *object_insert_shape_key(Scene *scene, Object *ob, const char *name, in } /* most important if this is modified it should _always_ return True, in certain - * cases false positives are hard to avoid (shape keys for eg) - */ + * cases false positives are hard to avoid (shape keys for example) */ int object_is_modified(Scene *scene, Object *ob) { int flag= 0; @@ -3007,13 +3012,38 @@ int object_is_modified(Scene *scene, Object *ob) md && (flag != (eModifierMode_Render | eModifierMode_Realtime)); md=md->next) { - if ((flag & eModifierMode_Render) == 0 && modifier_isEnabled(scene, md, eModifierMode_Render)) { + if ((flag & eModifierMode_Render) == 0 && modifier_isEnabled(scene, md, eModifierMode_Render)) flag |= eModifierMode_Render; - } - if ((flag & eModifierMode_Realtime) == 0 && modifier_isEnabled(scene, md, eModifierMode_Realtime)) { + if ((flag & eModifierMode_Realtime) == 0 && modifier_isEnabled(scene, md, eModifierMode_Realtime)) + flag |= eModifierMode_Realtime; + } + } + + return flag; +} + +/* test if object is affected by deforming modifiers (for motion blur). again + * most important is to avoid false positives, this is to skip computations + * and we can still if there was actual deformation afterwards */ +int object_is_deform_modified(Scene *scene, Object *ob) +{ + ModifierData *md; + int flag= 0; + + /* cloth */ + for (md=modifiers_getVirtualModifierList(ob); + md && (flag != (eModifierMode_Render | eModifierMode_Realtime)); + md=md->next) + { + ModifierTypeInfo *mti = modifierType_getInfo(md->type); + + if (mti->type == eModifierTypeType_OnlyDeform) { + if (!(flag & eModifierMode_Render) && modifier_isEnabled(scene, md, eModifierMode_Render)) + flag |= eModifierMode_Render; + + if (!(flag & eModifierMode_Realtime) && modifier_isEnabled(scene, md, eModifierMode_Realtime)) flag |= eModifierMode_Realtime; - } } } diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c index 5ba1b3d86c3..4ddcd6f4b51 100644 --- a/source/blender/blenkernel/intern/ocean.c +++ b/source/blender/blenkernel/intern/ocean.c @@ -172,12 +172,12 @@ static float gaussRand (void) /** * Some useful functions * */ -MINLINE float lerp(float a,float b,float f) +MINLINE float lerp(float a, float b, float f) { return a + (b-a)*f; } -MINLINE float catrom(float p0,float p1,float p2,float p3,float f) +MINLINE float catrom(float p0, float p1, float p2, float p3, float f) { return 0.5f *((2.0f * p1) + (-p0 + p2) * f + @@ -191,7 +191,7 @@ MINLINE float omega(float k, float depth) } // modified Phillips spectrum -static float Ph(struct Ocean* o, float kx,float kz ) +static float Ph(struct Ocean* o, float kx, float kz ) { float tmp; float k2 = kx*kx + kz*kz; @@ -206,12 +206,12 @@ static float Ph(struct Ocean* o, float kx,float kz ) tmp *= o->_damp_reflections; } - return o->_A * expf( -1.0f / (k2*(o->_L*o->_L))) * expf(-k2 * (o->_l*o->_l)) * powf(fabsf(tmp),o->_wind_alignment) / (k2*k2); + return o->_A * expf( -1.0f / (k2*(o->_L*o->_L))) * expf(-k2 * (o->_l*o->_l)) * powf(fabsf(tmp), o->_wind_alignment) / (k2*k2); } -static void compute_eigenstuff(struct OceanResult *ocr, float jxx,float jzz,float jxz) +static void compute_eigenstuff(struct OceanResult *ocr, float jxx, float jzz, float jxz) { - float a,b,qplus,qminus; + float a, b, qplus, qminus; a = jxx + jzz; b = sqrt((jxx - jzz)*(jxx - jzz) + 4 * jxz * jxz); @@ -304,15 +304,15 @@ float BKE_ocean_jminus_to_foam(float jminus, float coverage) return foam*foam; } -void BKE_ocean_eval_uv(struct Ocean *oc, struct OceanResult *ocr, float u,float v) +void BKE_ocean_eval_uv(struct Ocean *oc, struct OceanResult *ocr, float u, float v) { - int i0,i1,j0,j1; - float frac_x,frac_z; - float uu,vv; + int i0, i1, j0, j1; + float frac_x, frac_z; + float uu, vv; - // first wrap the texture so 0 <= (u,v) < 1 - u = fmodf(u,1.0f); - v = fmodf(v,1.0f); + // first wrap the texture so 0 <= (u, v) < 1 + u = fmodf(u, 1.0f); + v = fmodf(v, 1.0f); if (u < 0) u += 1.0f; if (v < 0) v += 1.0f; @@ -338,7 +338,7 @@ void BKE_ocean_eval_uv(struct Ocean *oc, struct OceanResult *ocr, float u,float j1 = j1 % oc->_N; -#define BILERP(m) (lerp(lerp(m[i0*oc->_N+j0],m[i1*oc->_N+j0],frac_x),lerp(m[i0*oc->_N+j1],m[i1*oc->_N+j1],frac_x),frac_z)) +#define BILERP(m) (lerp(lerp(m[i0*oc->_N+j0], m[i1*oc->_N+j0], frac_x), lerp(m[i0*oc->_N+j1], m[i1*oc->_N+j1], frac_x), frac_z)) { if (oc->_do_disp_y) { ocr->disp[1] = BILERP(oc->_disp_y); @@ -360,7 +360,7 @@ void BKE_ocean_eval_uv(struct Ocean *oc, struct OceanResult *ocr, float u,float } if (oc->_do_jacobian) { - compute_eigenstuff(ocr, BILERP(oc->_Jxx),BILERP(oc->_Jzz),BILERP(oc->_Jxz)); + compute_eigenstuff(ocr, BILERP(oc->_Jxx), BILERP(oc->_Jzz), BILERP(oc->_Jxz)); } } #undef BILERP @@ -369,15 +369,15 @@ void BKE_ocean_eval_uv(struct Ocean *oc, struct OceanResult *ocr, float u,float } // use catmullrom interpolation rather than linear -void BKE_ocean_eval_uv_catrom(struct Ocean *oc, struct OceanResult *ocr, float u,float v) +void BKE_ocean_eval_uv_catrom(struct Ocean *oc, struct OceanResult *ocr, float u, float v) { - int i0,i1,i2,i3,j0,j1,j2,j3; - float frac_x,frac_z; - float uu,vv; + int i0, i1, i2, i3, j0, j1, j2, j3; + float frac_x, frac_z; + float uu, vv; - // first wrap the texture so 0 <= (u,v) < 1 - u = fmod(u,1.0f); - v = fmod(v,1.0f); + // first wrap the texture so 0 <= (u, v) < 1 + u = fmod(u, 1.0f); + v = fmod(v, 1.0f); if (u < 0) u += 1.0f; if (v < 0) v += 1.0f; @@ -412,10 +412,10 @@ void BKE_ocean_eval_uv_catrom(struct Ocean *oc, struct OceanResult *ocr, float u j0 = j0 < 0 ? j0 + oc->_N : j0; j3 = j3 >= oc->_N ? j3 - oc->_N : j3; -#define INTERP(m) catrom(catrom(m[i0*oc->_N+j0],m[i1*oc->_N+j0],m[i2*oc->_N+j0],m[i3*oc->_N+j0],frac_x),\ - catrom(m[i0*oc->_N+j1],m[i1*oc->_N+j1],m[i2*oc->_N+j1],m[i3*oc->_N+j1],frac_x),\ - catrom(m[i0*oc->_N+j2],m[i1*oc->_N+j2],m[i2*oc->_N+j2],m[i3*oc->_N+j2],frac_x),\ - catrom(m[i0*oc->_N+j3],m[i1*oc->_N+j3],m[i2*oc->_N+j3],m[i3*oc->_N+j3],frac_x),\ +#define INTERP(m) catrom(catrom(m[i0*oc->_N+j0], m[i1*oc->_N+j0], m[i2*oc->_N+j0], m[i3*oc->_N+j0], frac_x), \ + catrom(m[i0*oc->_N+j1], m[i1*oc->_N+j1], m[i2*oc->_N+j1], m[i3*oc->_N+j1], frac_x), \ + catrom(m[i0*oc->_N+j2], m[i1*oc->_N+j2], m[i2*oc->_N+j2], m[i3*oc->_N+j2], frac_x), \ + catrom(m[i0*oc->_N+j3], m[i1*oc->_N+j3], m[i2*oc->_N+j3], m[i3*oc->_N+j3], frac_x), \ frac_z) { @@ -437,7 +437,7 @@ void BKE_ocean_eval_uv_catrom(struct Ocean *oc, struct OceanResult *ocr, float u } if (oc->_do_jacobian) { - compute_eigenstuff(ocr, INTERP(oc->_Jxx),INTERP(oc->_Jzz),INTERP(oc->_Jxz)); + compute_eigenstuff(ocr, INTERP(oc->_Jxx), INTERP(oc->_Jzz), INTERP(oc->_Jxz)); } } #undef INTERP @@ -446,20 +446,20 @@ void BKE_ocean_eval_uv_catrom(struct Ocean *oc, struct OceanResult *ocr, float u } -void BKE_ocean_eval_xz(struct Ocean *oc, struct OceanResult *ocr, float x,float z) +void BKE_ocean_eval_xz(struct Ocean *oc, struct OceanResult *ocr, float x, float z) { - BKE_ocean_eval_uv(oc, ocr, x/oc->_Lx,z/oc->_Lz); + BKE_ocean_eval_uv(oc, ocr, x/oc->_Lx, z/oc->_Lz); } -void BKE_ocean_eval_xz_catrom(struct Ocean *oc, struct OceanResult *ocr, float x,float z) +void BKE_ocean_eval_xz_catrom(struct Ocean *oc, struct OceanResult *ocr, float x, float z) { - BKE_ocean_eval_uv_catrom(oc, ocr, x/oc->_Lx,z/oc->_Lz); + BKE_ocean_eval_uv_catrom(oc, ocr, x/oc->_Lx, z/oc->_Lz); } -// note that this doesn't wrap properly for i,j < 0, but its +// note that this doesn't wrap properly for i, j < 0, but its // not really meant for that being just a way to get the raw data out // to save in some image format. -void BKE_ocean_eval_ij(struct Ocean *oc, struct OceanResult *ocr, int i,int j) +void BKE_ocean_eval_ij(struct Ocean *oc, struct OceanResult *ocr, int i, int j) { BLI_rw_mutex_lock(&oc->oceanmutex, THREAD_LOCK_READ); @@ -486,7 +486,7 @@ void BKE_ocean_eval_ij(struct Ocean *oc, struct OceanResult *ocr, int i,int j) } if (oc->_do_jacobian) { - compute_eigenstuff(ocr, oc->_Jxx[i*oc->_N+j],oc->_Jzz[i*oc->_N+j],oc->_Jxz[i*oc->_N+j]); + compute_eigenstuff(ocr, oc->_Jxx[i*oc->_N+j], oc->_Jzz[i*oc->_N+j], oc->_Jxz[i*oc->_N+j]); } BLI_rw_mutex_unlock(&oc->oceanmutex); @@ -511,8 +511,8 @@ void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount fftw_complex conj_param; - init_complex(exp_param1, 0.0, omega(o->_k[i*(1+o->_N/2)+j],o->_depth)*t); - init_complex(exp_param2, 0.0, -omega(o->_k[i*(1+o->_N/2)+j],o->_depth)*t); + init_complex(exp_param1, 0.0, omega(o->_k[i*(1+o->_N/2)+j], o->_depth)*t); + init_complex(exp_param2, 0.0, -omega(o->_k[i*(1+o->_N/2)+j], o->_depth)*t); exp_complex(exp_param1, exp_param1); exp_complex(exp_param2, exp_param2); conj_complex(conj_param, o->_h0_minus[i*o->_N+j]); @@ -710,7 +710,7 @@ static void set_height_normalize_factor(struct Ocean *oc) float res = 1.0; float max_h = 0.0; - int i,j; + int i, j; if (!oc->_do_disp_y) return; @@ -746,10 +746,10 @@ struct Ocean *BKE_add_ocean(void) return oc; } -void BKE_init_ocean(struct Ocean* o, int M,int N, float Lx, float Lz, float V, float l, float A, float w, float damp, +void BKE_init_ocean(struct Ocean* o, int M, int N, float Lx, float Lz, float V, float l, float A, float w, float damp, float alignment, float depth, float time, short do_height_field, short do_chop, short do_normals, short do_jacobian, int seed) { - int i,j,ii; + int i, j, ii; BLI_rw_mutex_lock(&o->oceanmutex, THREAD_LOCK_WRITE); @@ -792,7 +792,7 @@ void BKE_init_ocean(struct Ocean* o, int M,int N, float Lx, float Lz, float V, f o->_kx[i] = 2.0f * (float)M_PI * i / o->_Lx; // the -ve components - for (i = o->_M-1,ii=0 ; i > o->_M/2 ; --i,++ii) + for (i = o->_M-1, ii=0 ; i > o->_M/2 ; --i, ++ii) o->_kx[i] = -2.0f * (float)M_PI * ii / o->_Lx; // the +ve components and DC @@ -800,7 +800,7 @@ void BKE_init_ocean(struct Ocean* o, int M,int N, float Lx, float Lz, float V, f o->_kz[i] = 2.0f * (float)M_PI * i / o->_Lz; // the -ve components - for (i = o->_N-1,ii=0 ; i > o->_N/2 ; --i,++ii) + for (i = o->_N-1, ii=0 ; i > o->_N/2 ; --i, ++ii) o->_kz[i] = -2.0f * (float)M_PI * ii / o->_Lz; // pre-calculate the k matrix @@ -819,7 +819,7 @@ void BKE_init_ocean(struct Ocean* o, int M,int N, float Lx, float Lz, float V, f fftw_complex r1r2; init_complex(r1r2, r1, r2); mul_complex_f(o->_h0[i*o->_N+j], r1r2, (float)(sqrt(Ph(o, o->_kx[i], o->_kz[j]) / 2.0f))); - mul_complex_f(o->_h0_minus[i*o->_N+j], r1r2, (float)(sqrt(Ph(o, -o->_kx[i],-o->_kz[j]) / 2.0f))); + mul_complex_f(o->_h0_minus[i*o->_N+j], r1r2, (float)(sqrt(Ph(o, -o->_kx[i], -o->_kz[j]) / 2.0f))); } } @@ -828,7 +828,7 @@ void BKE_init_ocean(struct Ocean* o, int M,int N, float Lx, float Lz, float V, f if (o->_do_disp_y) { o->_disp_y = (double*) MEM_mallocN(o->_M * o->_N * sizeof(double), "ocean_disp_y"); - o->_disp_y_plan = fftw_plan_dft_c2r_2d(o->_M,o->_N, o->_fft_in, o->_disp_y, FFTW_ESTIMATE); + o->_disp_y_plan = fftw_plan_dft_c2r_2d(o->_M, o->_N, o->_fft_in, o->_disp_y, FFTW_ESTIMATE); } if (o->_do_normals) { @@ -839,8 +839,8 @@ void BKE_init_ocean(struct Ocean* o, int M,int N, float Lx, float Lz, float V, f /*o->_N_y = (float*) fftwf_malloc(o->_M * o->_N * sizeof(float)); (MEM01)*/ o->_N_z = (double*) MEM_mallocN(o->_M * o->_N * sizeof(double), "ocean_N_z"); - o->_N_x_plan = fftw_plan_dft_c2r_2d(o->_M,o->_N, o->_fft_in_nx, o->_N_x, FFTW_ESTIMATE); - o->_N_z_plan = fftw_plan_dft_c2r_2d(o->_M,o->_N, o->_fft_in_nz, o->_N_z, FFTW_ESTIMATE); + o->_N_x_plan = fftw_plan_dft_c2r_2d(o->_M, o->_N, o->_fft_in_nx, o->_N_x, FFTW_ESTIMATE); + o->_N_z_plan = fftw_plan_dft_c2r_2d(o->_M, o->_N, o->_fft_in_nz, o->_N_z, FFTW_ESTIMATE); } if (o->_do_chop) { @@ -850,8 +850,8 @@ void BKE_init_ocean(struct Ocean* o, int M,int N, float Lx, float Lz, float V, f o->_disp_x = (double*) MEM_mallocN(o->_M * o->_N * sizeof(double), "ocean_disp_x"); o->_disp_z = (double*) MEM_mallocN(o->_M * o->_N * sizeof(double), "ocean_disp_z"); - o->_disp_x_plan = fftw_plan_dft_c2r_2d(o->_M,o->_N, o->_fft_in_x, o->_disp_x, FFTW_ESTIMATE); - o->_disp_z_plan = fftw_plan_dft_c2r_2d(o->_M,o->_N, o->_fft_in_z, o->_disp_z, FFTW_ESTIMATE); + o->_disp_x_plan = fftw_plan_dft_c2r_2d(o->_M, o->_N, o->_fft_in_x, o->_disp_x, FFTW_ESTIMATE); + o->_disp_z_plan = fftw_plan_dft_c2r_2d(o->_M, o->_N, o->_fft_in_z, o->_disp_z, FFTW_ESTIMATE); } if (o->_do_jacobian) { o->_fft_in_jxx = (fftw_complex*) MEM_mallocN(o->_M * (1+o->_N/2) * sizeof(fftw_complex), "ocean_fft_in_jxx"); @@ -862,9 +862,9 @@ void BKE_init_ocean(struct Ocean* o, int M,int N, float Lx, float Lz, float V, f o->_Jzz = (double*) MEM_mallocN(o->_M * o->_N * sizeof(double), "ocean_Jzz"); o->_Jxz = (double*) MEM_mallocN(o->_M * o->_N * sizeof(double), "ocean_Jxz"); - o->_Jxx_plan = fftw_plan_dft_c2r_2d(o->_M,o->_N, o->_fft_in_jxx, o->_Jxx, FFTW_ESTIMATE); - o->_Jzz_plan = fftw_plan_dft_c2r_2d(o->_M,o->_N, o->_fft_in_jzz, o->_Jzz, FFTW_ESTIMATE); - o->_Jxz_plan = fftw_plan_dft_c2r_2d(o->_M,o->_N, o->_fft_in_jxz, o->_Jxz, FFTW_ESTIMATE); + o->_Jxx_plan = fftw_plan_dft_c2r_2d(o->_M, o->_N, o->_fft_in_jxx, o->_Jxx, FFTW_ESTIMATE); + o->_Jzz_plan = fftw_plan_dft_c2r_2d(o->_M, o->_N, o->_fft_in_jzz, o->_Jzz, FFTW_ESTIMATE); + o->_Jxz_plan = fftw_plan_dft_c2r_2d(o->_M, o->_N, o->_fft_in_jxz, o->_Jxz, FFTW_ESTIMATE); } BLI_rw_mutex_unlock(&o->oceanmutex); @@ -1192,7 +1192,7 @@ void BKE_bake_ocean(struct Ocean *o, struct OceanCache *och, void (*update_cb)(v if (o->_do_jacobian) { /* TODO, cleanup unused code - campbell */ - float /*r,*/ /* UNUSED */ pr=0.0f, foam_result; + float /*r, */ /* UNUSED */ pr=0.0f, foam_result; float neg_disp, neg_eplus; ocr.foam = BKE_ocean_jminus_to_foam(ocr.Jminus, och->foam_coverage); @@ -1298,24 +1298,24 @@ float BKE_ocean_jminus_to_foam(float UNUSED(jminus), float UNUSED(coverage)) return 0.0f; } -void BKE_ocean_eval_uv(struct Ocean *UNUSED(oc), struct OceanResult *UNUSED(ocr), float UNUSED(u),float UNUSED(v)) +void BKE_ocean_eval_uv(struct Ocean *UNUSED(oc), struct OceanResult *UNUSED(ocr), float UNUSED(u), float UNUSED(v)) { } // use catmullrom interpolation rather than linear -void BKE_ocean_eval_uv_catrom(struct Ocean *UNUSED(oc), struct OceanResult *UNUSED(ocr), float UNUSED(u),float UNUSED(v)) +void BKE_ocean_eval_uv_catrom(struct Ocean *UNUSED(oc), struct OceanResult *UNUSED(ocr), float UNUSED(u), float UNUSED(v)) { } -void BKE_ocean_eval_xz(struct Ocean *UNUSED(oc), struct OceanResult *UNUSED(ocr), float UNUSED(x),float UNUSED(z)) +void BKE_ocean_eval_xz(struct Ocean *UNUSED(oc), struct OceanResult *UNUSED(ocr), float UNUSED(x), float UNUSED(z)) { } -void BKE_ocean_eval_xz_catrom(struct Ocean *UNUSED(oc), struct OceanResult *UNUSED(ocr), float UNUSED(x),float UNUSED(z)) +void BKE_ocean_eval_xz_catrom(struct Ocean *UNUSED(oc), struct OceanResult *UNUSED(ocr), float UNUSED(x), float UNUSED(z)) { } -void BKE_ocean_eval_ij(struct Ocean *UNUSED(oc), struct OceanResult *UNUSED(ocr), int UNUSED(i),int UNUSED(j)) +void BKE_ocean_eval_ij(struct Ocean *UNUSED(oc), struct OceanResult *UNUSED(ocr), int UNUSED(i), int UNUSED(j)) { } @@ -1330,7 +1330,7 @@ struct Ocean *BKE_add_ocean(void) return oc; } -void BKE_init_ocean(struct Ocean* UNUSED(o), int UNUSED(M),int UNUSED(N), float UNUSED(Lx), float UNUSED(Lz), float UNUSED(V), float UNUSED(l), float UNUSED(A), float UNUSED(w), float UNUSED(damp), +void BKE_init_ocean(struct Ocean* UNUSED(o), int UNUSED(M), int UNUSED(N), float UNUSED(Lx), float UNUSED(Lz), float UNUSED(V), float UNUSED(l), float UNUSED(A), float UNUSED(w), float UNUSED(damp), float UNUSED(alignment), float UNUSED(depth), float UNUSED(time), short UNUSED(do_height_field), short UNUSED(do_chop), short UNUSED(do_normals), short UNUSED(do_jacobian), int UNUSED(seed)) { } diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index e0c61fbcc90..3b5b4b766fb 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -189,7 +189,7 @@ PackedFile *newPackedFile(ReportList *reports, const char *filename, const char // open the file // and create a PackedFile structure - file= BLI_open(name, O_BINARY|O_RDONLY,0); + file= BLI_open(name, O_BINARY|O_RDONLY, 0); if (file <= 0) { BKE_reportf(reports, RPT_ERROR, "Unable to pack file, source path not found: \"%s\"", name); } diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index f417f9b79fb..08d8479fd93 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -126,7 +126,7 @@ void paint_init(Paint *p, const char col[3]) /* If there's no brush, create one */ brush = paint_brush(p); if (brush == NULL) - brush= add_brush("Brush"); + brush= BKE_brush_add("Brush"); paint_brush_set(p, brush); memcpy(p->paint_cursor_col, col, 3); diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index febe4277010..1a1ae8e949c 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -549,7 +549,7 @@ void psys_free(Object *ob, ParticleSystem * psys) // 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)) { + if (ELEM(tpsys->part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) { nr++; break; } @@ -637,7 +637,7 @@ static float psys_render_projected_area(ParticleSystem *psys, const float center /* compute two vectors orthogonal to view vector */ normalize_v3_v3(view, co); - ortho_basis_v3v3_v3( ortho1, ortho2,view); + ortho_basis_v3v3_v3(ortho1, ortho2, view); /* compute on screen minification */ w= co[2]*data->winmat[2][3] + data->winmat[3][3]; @@ -1024,7 +1024,7 @@ void psys_interpolate_particle(short type, ParticleKey keys[4], float dt, Partic float t[4]; if (type<0) { - interp_cubic_v3( result->co, result->vel,keys[1].co, keys[1].vel, keys[2].co, keys[2].vel, dt); + interp_cubic_v3(result->co, result->vel, keys[1].co, keys[1].vel, keys[2].co, keys[2].vel, dt); } else { key_curve_position_weights(dt, t, type); @@ -1357,13 +1357,13 @@ static void do_particle_interpolation(ParticleSystem *psys, int p, ParticleData invdt = dfra * 0.04f * (psys ? psys->part->timetweak : 1.f); mul_v3_fl(keys[1].vel, invdt); mul_v3_fl(keys[2].vel, invdt); - interp_qt_qtqt(result->rot,keys[1].rot,keys[2].rot,keytime); + interp_qt_qtqt(result->rot, keys[1].rot, keys[2].rot, keytime); } - /* now we should have in chronologiacl order k1<=k2<=t<=k3<=k4 with keytime between [0,1]->[k2,k3] (k1 & k4 used for cardinal & bspline interpolation)*/ + /* now we should have in chronologiacl order k1<=k2<=t<=k3<=k4 with keytime between [0, 1]->[k2, k3] (k1 & k4 used for cardinal & bspline interpolation)*/ psys_interpolate_particle((pind->keyed || pind->cache || point_vel) ? -1 /* signal for cubic interpolation */ - : (pind->bspline ? KEY_BSPLINE : KEY_CARDINAL) - ,keys, keytime, result, 1); + : (pind->bspline ? KEY_BSPLINE : KEY_CARDINAL), + keys, keytime, result, 1); /* the velocity needs to be converted back from cubic interpolation */ if (pind->keyed || pind->cache || point_vel) @@ -1403,10 +1403,10 @@ static void interpolate_pathcache(ParticleCacheKey *first, float t, ParticleCach /************************************************/ /* interpolate a location on a face based on face coordinates */ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*orcodata)[3], - float *w, float *vec, float *nor, float *utan, float *vtan, float *orco,float *ornor) + float *w, float *vec, float *nor, float *utan, float *vtan, float *orco, float *ornor) { float *v1=0, *v2=0, *v3=0, *v4=0; - float e1[3],e2[3],s1,s2,t1,t2; + float e1[3], e2[3], s1, s2, t1, t2; float *uv1, *uv2, *uv3, *uv4; float n1[3], n2[3], n3[3], n4[3]; float tuv[4][2]; @@ -1430,7 +1430,7 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or if (mface->flag & ME_SMOOTH) interp_v3_v3v3v3v3(nor, n1, n2, n3, n4, w); else - normal_quad_v3(nor,v1,v2,v3,v4); + normal_quad_v3(nor, v1, v2, v3, v4); } } else { @@ -1440,7 +1440,7 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or if (mface->flag & ME_SMOOTH) interp_v3_v3v3v3(nor, n1, n2, n3, w); else - normal_tri_v3(nor,v1,v2,v3); + normal_tri_v3(nor, v1, v2, v3); } } @@ -1454,11 +1454,11 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or } else { uv1= tuv[0]; uv2= tuv[1]; uv3= tuv[2]; uv4= tuv[3]; - map_to_sphere( uv1, uv1+1,v1[0], v1[1], v1[2]); - map_to_sphere( uv2, uv2+1,v2[0], v2[1], v2[2]); - map_to_sphere( uv3, uv3+1,v3[0], v3[1], v3[2]); + map_to_sphere(uv1, uv1+1, v1[0], v1[1], v1[2]); + map_to_sphere(uv2, uv2+1, v2[0], v2[1], v2[2]); + map_to_sphere(uv3, uv3+1, v3[0], v3[1], v3[2]); if (v4) - map_to_sphere( uv4, uv4+1,v4[0], v4[1], v4[2]); + map_to_sphere(uv4, uv4+1, v4[0], v4[1], v4[2]); } if (v4) { @@ -1503,13 +1503,13 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or interp_v3_v3v3v3v3(orco, o1, o2, o3, o4, w); if (ornor) - normal_quad_v3( ornor,o1, o2, o3, o4); + normal_quad_v3(ornor, o1, o2, o3, o4); } else { interp_v3_v3v3v3(orco, o1, o2, o3, w); if (ornor) - normal_tri_v3( ornor,o1, o2, o3); + normal_tri_v3(ornor, o1, o2, o3); } } else { @@ -1527,7 +1527,7 @@ void psys_interpolate_uvs(const MTFace *tface, int quad, const float w[4], float float v21= tface->uv[1][1]; float v30= tface->uv[2][0]; float v31= tface->uv[2][1]; - float v40,v41; + float v40, v41; if (quad) { v40= tface->uv[3][0]; @@ -1578,8 +1578,8 @@ static float psys_interpolate_value_from_verts(DerivedMesh *dm, short from, int case PART_FROM_FACE: case PART_FROM_VOLUME: { - MFace *mf=dm->getTessFaceData(dm,index,CD_MFACE); - return interpolate_particle_value(values[mf->v1],values[mf->v2],values[mf->v3],values[mf->v4],fw,mf->v4); + MFace *mf=dm->getTessFaceData(dm, index, CD_MFACE); + return interpolate_particle_value(values[mf->v1], values[mf->v2], values[mf->v3], values[mf->v4], fw, mf->v4); } } @@ -1766,10 +1766,10 @@ void psys_particle_on_dm(DerivedMesh *dm, int from, int index, int index_dmcache orcodata= dm->getVertDataArray(dm, CD_ORCO); if (from == PART_FROM_VERT) { - dm->getVertCo(dm,mapindex,vec); + dm->getVertCo(dm, mapindex, vec); if (nor) { - dm->getVertNo(dm,mapindex,nor); + dm->getVertNo(dm, mapindex, nor); normalize_v3(nor); } @@ -1777,7 +1777,7 @@ void psys_particle_on_dm(DerivedMesh *dm, int from, int index, int index_dmcache copy_v3_v3(orco, orcodata[mapindex]); if (ornor) { - dm->getVertNo(dm,mapindex,nor); + dm->getVertNo(dm, mapindex, nor); normalize_v3(nor); } @@ -1791,24 +1791,24 @@ void psys_particle_on_dm(DerivedMesh *dm, int from, int index, int index_dmcache MTFace *mtface; MVert *mvert; - mface=dm->getTessFaceData(dm,mapindex,CD_MFACE); - mvert=dm->getVertDataArray(dm,CD_MVERT); - mtface=CustomData_get_layer(&dm->faceData,CD_MTFACE); + mface=dm->getTessFaceData(dm, mapindex, CD_MFACE); + mvert=dm->getVertDataArray(dm, CD_MVERT); + mtface=CustomData_get_layer(&dm->faceData, CD_MTFACE); if (mtface) mtface += mapindex; if (from==PART_FROM_VOLUME) { - psys_interpolate_face(mvert,mface,mtface,orcodata,mapfw,vec,tmpnor,utan,vtan,orco,ornor); + psys_interpolate_face(mvert, mface, mtface, orcodata, mapfw, vec, tmpnor, utan, vtan, orco, ornor); if (nor) - copy_v3_v3(nor,tmpnor); + copy_v3_v3(nor, tmpnor); normalize_v3(tmpnor); - mul_v3_fl(tmpnor,-foffset); + mul_v3_fl(tmpnor, -foffset); add_v3_v3(vec, tmpnor); } else - psys_interpolate_face(mvert,mface,mtface,orcodata,mapfw,vec,nor,utan,vtan,orco,ornor); + psys_interpolate_face(mvert, mface, mtface, orcodata, mapfw, vec, nor, utan, vtan, orco, ornor); } } @@ -1845,24 +1845,24 @@ ParticleSystemModifierData *psys_get_modifier(Object *ob, ParticleSystem *psys) static void psys_particle_on_shape(int UNUSED(distr), int UNUSED(index), float *UNUSED(fuv), float *vec, float *nor, float *utan, float *vtan, float *orco, float *ornor) { /* TODO */ - float zerovec[3]={0.0f,0.0f,0.0f}; + float zerovec[3]={0.0f, 0.0f, 0.0f}; if (vec) { - copy_v3_v3(vec,zerovec); + copy_v3_v3(vec, zerovec); } if (nor) { - copy_v3_v3(nor,zerovec); + copy_v3_v3(nor, zerovec); } if (utan) { - copy_v3_v3(utan,zerovec); + copy_v3_v3(utan, zerovec); } if (vtan) { - copy_v3_v3(vtan,zerovec); + copy_v3_v3(vtan, zerovec); } if (orco) { - copy_v3_v3(orco,zerovec); + copy_v3_v3(orco, zerovec); } if (ornor) { - copy_v3_v3(ornor,zerovec); + copy_v3_v3(ornor, zerovec); } } /************************************************/ @@ -1873,17 +1873,17 @@ void psys_particle_on_emitter(ParticleSystemModifierData *psmd, int from, int in if (psmd) { if (psmd->psys->part->distr==PART_DISTR_GRID && psmd->psys->part->from != PART_FROM_VERT) { if (vec) - copy_v3_v3(vec,fuv); + copy_v3_v3(vec, fuv); if (orco) copy_v3_v3(orco, fuv); return; } /* we cant use the num_dmcache */ - psys_particle_on_dm(psmd->dm,from,index,index_dmcache,fuv,foffset,vec,nor,utan,vtan,orco,ornor); + psys_particle_on_dm(psmd->dm, from, index, index_dmcache, fuv, foffset, vec, nor, utan, vtan, orco, ornor); } else - psys_particle_on_shape(from,index,fuv,vec,nor,utan,vtan,orco,ornor); + psys_particle_on_shape(from, index, fuv, vec, nor, utan, vtan, orco, ornor); } /************************************************/ @@ -1892,7 +1892,7 @@ void psys_particle_on_emitter(ParticleSystemModifierData *psmd, int from, int in static void do_kink(ParticleKey *state, ParticleKey *par, float *par_rot, float time, float freq, float shape, float amplitude, float flat, short type, short axis, float obmat[][4], int smooth_start) { - float kink[3]={1.f,0.f,0.f}, par_vec[3], q1[4]={1.f,0.f,0.f,0.f}; + float kink[3]={1.f, 0.f, 0.f}, par_vec[3], q1[4]={1.f, 0.f, 0.f, 0.f}; float t, dt=1.f, result[3]; if (par == NULL || type == PART_KINK_NO) @@ -1995,8 +1995,8 @@ static void do_kink(ParticleKey *state, ParticleKey *par, float *par_rot, float } case PART_KINK_BRAID: { - float y_vec[3]={0.f,1.f,0.f}; - float z_vec[3]={0.f,0.f,1.f}; + float y_vec[3]={0.f, 1.f, 0.f}; + float z_vec[3]={0.f, 0.f, 1.f}; float vec_one[3], state_co[3]; float inp_y, inp_z, length; @@ -2077,11 +2077,11 @@ static float do_clump(ParticleKey *state, ParticleKey *par, float time, float cl cpow=1.0f+9.0f*clumppow; if (clumpfac < 0.0f) /* clump roots instead of tips */ - clump = -clumpfac*pa_clump*(float)pow(1.0-(double)time,(double)cpow); + clump = -clumpfac*pa_clump*(float)pow(1.0-(double)time, (double)cpow); else - clump = clumpfac*pa_clump*(float)pow((double)time,(double)cpow); + clump = clumpfac*pa_clump*(float)pow((double)time, (double)cpow); - interp_v3_v3v3(state->co,state->co,par->co,clump); + interp_v3_v3v3(state->co, state->co, par->co, clump); } return clump; @@ -2101,7 +2101,7 @@ void precalc_guides(ParticleSimulationData *sim, ListBase *effectors) return; LOOP_PARTICLES { - psys_particle_on_emitter(sim->psmd,sim->psys->part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,state.co,0,0,0,0,0); + psys_particle_on_emitter(sim->psmd, sim->psys->part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, state.co, 0, 0, 0, 0, 0); mul_m4_v3(sim->ob->obmat, state.co); mul_mat3_m4_v3(sim->ob->obmat, state.vel); @@ -2178,11 +2178,11 @@ int do_guides(ListBase *effectors, ParticleKey *state, int index, float time) cross_v3_v3v3(temp, eff->guide_dir, guidedir); angle = dot_v3v3(eff->guide_dir, guidedir)/(len_v3(eff->guide_dir)); angle = saacos(angle); - axis_angle_to_quat( rot2,temp, angle); + axis_angle_to_quat(rot2, temp, angle); mul_qt_v3(rot2, vec_to_point); /* curve tilt */ - axis_angle_to_quat( rot2,guidedir, guidevec[3] - eff->guide_loc[3]); + axis_angle_to_quat(rot2, guidedir, guidevec[3] - eff->guide_loc[3]); mul_qt_v3(rot2, vec_to_point); } @@ -2203,7 +2203,7 @@ int do_guides(ListBase *effectors, ParticleKey *state, int index, float time) add_v3_v3(vec_to_point, guidevec); - //sub_v3_v3v3(pa_loc,pa_loc,pa_zero); + //sub_v3_v3v3(pa_loc, pa_loc, pa_zero); madd_v3_v3fl(effect, vec_to_point, data->strength); madd_v3_v3fl(veffect, guidedir, data->strength); totstrength += data->strength; @@ -2216,7 +2216,7 @@ int do_guides(ListBase *effectors, ParticleKey *state, int index, float time) if (totstrength > 1.0f) mul_v3_fl(effect, 1.0f / totstrength); CLAMP(totstrength, 0.0f, 1.0f); - //add_v3_v3(effect,pa_zero); + //add_v3_v3(effect, pa_zero); interp_v3_v3v3(state->co, state->co, effect, totstrength); normalize_v3(veffect); @@ -2234,11 +2234,11 @@ static void do_rough(float *loc, float mat[4][4], float t, float fac, float size if (thres != 0.0f) if ((float)fabs((float)(-1.5f+loc[0]+loc[1]+loc[2]))<1.5f*thres) return; - copy_v3_v3(rco,loc); - mul_v3_fl(rco,t); - rough[0]=-1.0f+2.0f*BLI_gTurbulence(size, rco[0], rco[1], rco[2], 2,0,2); - rough[1]=-1.0f+2.0f*BLI_gTurbulence(size, rco[1], rco[2], rco[0], 2,0,2); - rough[2]=-1.0f+2.0f*BLI_gTurbulence(size, rco[2], rco[0], rco[1], 2,0,2); + copy_v3_v3(rco, loc); + mul_v3_fl(rco, t); + rough[0]=-1.0f+2.0f*BLI_gTurbulence(size, rco[0], rco[1], rco[2], 2, 0, 2); + rough[1]=-1.0f+2.0f*BLI_gTurbulence(size, rco[1], rco[2], rco[0], 2, 0, 2); + rough[2]=-1.0f+2.0f*BLI_gTurbulence(size, rco[2], rco[0], rco[1], 2, 0, 2); madd_v3_v3fl(state->co, mat[0], fac * rough[0]); madd_v3_v3fl(state->co, mat[1], fac * rough[1]); @@ -2249,18 +2249,18 @@ static void do_rough_end(float *loc, float mat[4][4], float t, float fac, float float rough[2]; float roughfac; - roughfac=fac*(float)pow((double)t,shape); - copy_v2_v2(rough,loc); + roughfac=fac*(float)pow((double)t, shape); + copy_v2_v2(rough, loc); rough[0]=-1.0f+2.0f*rough[0]; rough[1]=-1.0f+2.0f*rough[1]; - mul_v2_fl(rough,roughfac); + mul_v2_fl(rough, roughfac); madd_v3_v3fl(state->co, mat[0], rough[0]); madd_v3_v3fl(state->co, mat[1], rough[1]); } static void do_path_effectors(ParticleSimulationData *sim, int i, ParticleCacheKey *ca, int k, int steps, float *UNUSED(rootco), float effector, float UNUSED(dfra), float UNUSED(cfra), float *length, float *vec) { - float force[3] = {0.0f,0.0f,0.0f}; + float force[3] = {0.0f, 0.0f, 0.0f}; ParticleKey eff_key; EffectedPoint epoint; @@ -2268,9 +2268,9 @@ static void do_path_effectors(ParticleSimulationData *sim, int i, ParticleCacheK if (sim->psys->flag & PSYS_HAIR_DYNAMICS) return; - copy_v3_v3(eff_key.co,(ca-1)->co); - copy_v3_v3(eff_key.vel,(ca-1)->vel); - copy_qt_qt(eff_key.rot,(ca-1)->rot); + copy_v3_v3(eff_key.co, (ca-1)->co); + copy_v3_v3(eff_key.vel, (ca-1)->vel); + copy_qt_qt(eff_key.rot, (ca-1)->rot); pd_point_from_particle(sim, sim->psys->particles+i, &eff_key, &epoint); pdDoEffectors(sim->psys->effectors, sim->colliders, sim->psys->part->effector_weights, &epoint, force, NULL); @@ -2351,7 +2351,7 @@ void psys_find_parents(ParticleSimulationData *sim) ParticleSettings *part=sim->psys->part; KDTree *tree; ChildParticle *cpa; - int p, totparent,totchild=sim->psys->totchild; + int p, totparent, totchild=sim->psys->totchild; float co[3], orco[3]; int from=PART_FROM_FACE; totparent=(int)(totchild*part->parents*0.3f); @@ -2361,15 +2361,15 @@ void psys_find_parents(ParticleSimulationData *sim) tree=BLI_kdtree_new(totparent); - for (p=0,cpa=sim->psys->child; p<totparent; p++,cpa++) { - psys_particle_on_emitter(sim->psmd,from,cpa->num,DMCACHE_ISCHILD,cpa->fuv,cpa->foffset,co,0,0,0,orco,0); + for (p=0, cpa=sim->psys->child; p<totparent; p++, cpa++) { + psys_particle_on_emitter(sim->psmd, from, cpa->num, DMCACHE_ISCHILD, cpa->fuv, cpa->foffset, co, 0, 0, 0, orco, 0); BLI_kdtree_insert(tree, p, orco, NULL); } BLI_kdtree_balance(tree); - for (; p<totchild; p++,cpa++) { - psys_particle_on_emitter(sim->psmd,from,cpa->num,DMCACHE_ISCHILD,cpa->fuv,cpa->foffset,co,0,0,0,orco,0); + for (; p<totchild; p++, cpa++) { + psys_particle_on_emitter(sim->psmd, from, cpa->num, DMCACHE_ISCHILD, cpa->fuv, cpa->foffset, co, 0, 0, 0, orco, 0); cpa->parent=BLI_kdtree_find_nearest(tree, orco, NULL, NULL); } @@ -2441,10 +2441,10 @@ static int psys_threads_init_path(ParticleThread *threads, Scene *scene, float c } if (psys->renderdata) - steps=(int)pow(2.0,(double)part->ren_step); + steps=(int)pow(2.0, (double)part->ren_step); else { totchild=(int)((float)totchild*(float)part->disp/100.0f); - totparent=MIN2(totparent,totchild); + totparent=MIN2(totparent, totchild); } if (totchild==0) return 0; @@ -2472,14 +2472,14 @@ static int psys_threads_init_path(ParticleThread *threads, Scene *scene, float c psys->lattice = psys_get_lattice(&ctx->sim); /* cache all relevant vertex groups if they exist */ - ctx->vg_length = psys_cache_vgroup(ctx->dm,psys,PSYS_VG_LENGTH); - ctx->vg_clump = psys_cache_vgroup(ctx->dm,psys,PSYS_VG_CLUMP); - ctx->vg_kink = psys_cache_vgroup(ctx->dm,psys,PSYS_VG_KINK); - ctx->vg_rough1 = psys_cache_vgroup(ctx->dm,psys,PSYS_VG_ROUGH1); - ctx->vg_rough2 = psys_cache_vgroup(ctx->dm,psys,PSYS_VG_ROUGH2); - ctx->vg_roughe = psys_cache_vgroup(ctx->dm,psys,PSYS_VG_ROUGHE); + ctx->vg_length = psys_cache_vgroup(ctx->dm, psys, PSYS_VG_LENGTH); + ctx->vg_clump = psys_cache_vgroup(ctx->dm, psys, PSYS_VG_CLUMP); + ctx->vg_kink = psys_cache_vgroup(ctx->dm, psys, PSYS_VG_KINK); + ctx->vg_rough1 = psys_cache_vgroup(ctx->dm, psys, PSYS_VG_ROUGH1); + ctx->vg_rough2 = psys_cache_vgroup(ctx->dm, psys, PSYS_VG_ROUGH2); + ctx->vg_roughe = psys_cache_vgroup(ctx->dm, psys, PSYS_VG_ROUGHE); if (psys->part->flag & PART_CHILD_EFFECT) - ctx->vg_effector = psys_cache_vgroup(ctx->dm,psys,PSYS_VG_EFFECTOR); + ctx->vg_effector = psys_cache_vgroup(ctx->dm, psys, PSYS_VG_EFFECTOR); /* set correct ipo timing */ #if 0 // XXX old animation system @@ -2599,7 +2599,7 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle cpa_fuv = cpa->fuv; cpa_from = PART_FROM_FACE; - psys_particle_on_emitter(ctx->sim.psmd,cpa_from,cpa_num,DMCACHE_ISCHILD,cpa->fuv,foffset,co,ornor,0,0,orco,0); + psys_particle_on_emitter(ctx->sim.psmd, cpa_from, cpa_num, DMCACHE_ISCHILD, cpa->fuv, foffset, co, ornor, 0, 0, orco, 0); mul_m4_v3(ob->obmat, co); @@ -2626,7 +2626,7 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle cpa_num = pa->num; cpa_fuv = pa->fuv; - psys_particle_on_emitter(ctx->sim.psmd,cpa_from,cpa_num,DMCACHE_ISCHILD,cpa_fuv,pa->foffset,co,ornor,0,0,orco,0); + psys_particle_on_emitter(ctx->sim.psmd, cpa_from, cpa_num, DMCACHE_ISCHILD, cpa_fuv, pa->foffset, co, ornor, 0, 0, orco, 0); psys_mat_hair_to_global(ob, ctx->sim.psmd->dm, psys->part->from, pa, hairmat); } @@ -2642,7 +2642,7 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle } /* create the child path */ - for (k=0,child=child_keys; k<=ctx->steps; k++,child++) { + for (k=0, child=child_keys; k<=ctx->steps; k++, child++) { if (ctx->between) { int w=0; @@ -2689,7 +2689,7 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle /* apply effectors */ if (part->flag & PART_CHILD_EFFECT) { - for (k=0,child=child_keys; k<=ctx->steps; k++,child++) { + for (k=0, child=child_keys; k<=ctx->steps; k++, child++) { if (k) { do_path_effectors(&ctx->sim, cpa->pa[0], child, k, ctx->steps, child_keys->co, ptex.effector, 0.0f, ctx->cfra, &eff_length, eff_vec); } @@ -2700,7 +2700,7 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle } } - for (k=0,child=child_keys; k<=ctx->steps; k++,child++) { + for (k=0, child=child_keys; k<=ctx->steps; k++, child++) { t = (float)k/(float)ctx->steps; if (ctx->totparent) @@ -2871,7 +2871,7 @@ static void cache_key_incremental_rotation(ParticleCacheKey *key0, ParticleCache else { angle= saacos(cosangle); cross_v3_v3v3(normal, prev_tangent, tangent); - axis_angle_to_quat( q,normal, angle); + axis_angle_to_quat(q, normal, angle); mul_qt_qtqt(key1->rot, q, key2->rot); } @@ -2954,7 +2954,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) psys_get_texture(sim, pa, &ptex, PAMAP_LENGTH, 0.f); pa_length = ptex.length * (1.0f - part->randlength * PSYS_FRAND(psys->seed + p)); if (vg_length) - pa_length *= psys_particle_value_from_verts(psmd->dm,part->from,pa,vg_length); + pa_length *= psys_particle_value_from_verts(psmd->dm, part->from, pa, vg_length); } pind.keyed = keyed; @@ -3018,9 +3018,9 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) if ((psys->part->flag & PART_CHILD_EFFECT) == 0) { float effector= 1.0f; if (vg_effector) - effector*= psys_particle_value_from_verts(psmd->dm,psys->part->from,pa,vg_effector); + effector*= psys_particle_value_from_verts(psmd->dm, psys->part->from, pa, vg_effector); - sub_v3_v3v3(vec,(cache[p]+1)->co,cache[p]->co); + sub_v3_v3v3(vec, (cache[p]+1)->co, cache[p]->co); length = len_v3(vec); for (k=1, ca=cache[p]+1; k<=steps; k++, ca++) @@ -3290,19 +3290,19 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf void copy_particle_key(ParticleKey *to, ParticleKey *from, int time) { if (time) { - memcpy(to,from,sizeof(ParticleKey)); + memcpy(to, from, sizeof(ParticleKey)); } else { float to_time=to->time; - memcpy(to,from,sizeof(ParticleKey)); + memcpy(to, from, sizeof(ParticleKey)); to->time=to_time; } } void psys_get_from_key(ParticleKey *key, float *loc, float *vel, float *rot, float *time) { - if (loc) copy_v3_v3(loc,key->co); - if (vel) copy_v3_v3(vel,key->vel); - if (rot) copy_qt_qt(rot,key->rot); + if (loc) copy_v3_v3(loc, key->co); + if (vel) copy_v3_v3(vel, key->vel); + if (rot) copy_qt_qt(rot, key->rot); if (time) *time=key->time; } /*-------changing particle keys from space to another-------*/ @@ -3313,12 +3313,12 @@ static void key_from_object(Object *ob, ParticleKey *key) add_v3_v3(key->vel, key->co); - mul_m4_v3(ob->obmat,key->co); - mul_m4_v3(ob->obmat,key->vel); - mat4_to_quat(q,ob->obmat); + mul_m4_v3(ob->obmat, key->co); + mul_m4_v3(ob->obmat, key->vel); + mat4_to_quat(q, ob->obmat); - sub_v3_v3v3(key->vel,key->vel,key->co); - mul_qt_qtqt(key->rot,q,key->rot); + sub_v3_v3v3(key->vel, key->vel, key->co); + mul_qt_qtqt(key->rot, q, key->rot); } #endif @@ -3330,7 +3330,7 @@ static void triatomat(float *v1, float *v2, float *v3, float (*uv)[2], float mat mat[3][3]= 1.0f; /* first axis is the normal */ - normal_tri_v3( mat[2],v1, v2, v3); + normal_tri_v3(mat[2], v1, v2, v3); /* second axis along (1, 0) in uv space */ if (uv) { @@ -3374,8 +3374,8 @@ static void psys_face_mat(Object *ob, DerivedMesh *dm, ParticleData *pa, float m if (i==-1 || i >= dm->getNumTessFaces(dm)) { unit_m4(mat); return; } - mface=dm->getTessFaceData(dm,i,CD_MFACE); - osface=dm->getTessFaceData(dm,i,CD_ORIGSPACE); + mface=dm->getTessFaceData(dm, i, CD_MFACE); + osface=dm->getTessFaceData(dm, i, CD_ORIGSPACE); if (orco && (orcodata=dm->getVertDataArray(dm, CD_ORCO))) { copy_v3_v3(v[0], orcodata[mface->v1]); @@ -3388,9 +3388,9 @@ static void psys_face_mat(Object *ob, DerivedMesh *dm, ParticleData *pa, float m transform_mesh_orco_verts(ob->data, v, 3, 1); } else { - dm->getVertCo(dm,mface->v1,v[0]); - dm->getVertCo(dm,mface->v2,v[1]); - dm->getVertCo(dm,mface->v3,v[2]); + dm->getVertCo(dm, mface->v1, v[0]); + dm->getVertCo(dm, mface->v2, v[1]); + dm->getVertCo(dm, mface->v3, v[2]); } triatomat(v[0], v[1], v[2], (osface)? osface->uv: NULL, mat); @@ -3402,7 +3402,7 @@ void psys_mat_hair_to_object(Object *UNUSED(ob), DerivedMesh *dm, short from, Pa 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); + copy_v3_v3(hairmat[3], vec); } void psys_mat_hair_to_orco(Object *ob, DerivedMesh *dm, short from, ParticleData *pa, float hairmat[][4]) @@ -3415,7 +3415,7 @@ void psys_mat_hair_to_orco(Object *ob, DerivedMesh *dm, short from, ParticleData /* see psys_face_mat for why this function is called */ if (DM_get_vert_data_layer(dm, CD_ORIGINDEX)) transform_mesh_orco_verts(ob->data, &orco, 1, 1); - copy_v3_v3(hairmat[3],orco); + copy_v3_v3(hairmat[3], orco); } void psys_vec_rot_to_face(DerivedMesh *dm, ParticleData *pa, float vec[3]) @@ -3513,7 +3513,7 @@ void object_remove_particle_system(Scene *scene, Object *ob) /* clear particle system */ BLI_remlink(&ob->particlesystem, psys); - psys_free(ob,psys); + psys_free(ob, psys); if (ob->particlesystem.first) ((ParticleSystem *) ob->particlesystem.first)->flag |= PSYS_CURRENT; @@ -3795,7 +3795,7 @@ static void get_cpa_texture(DerivedMesh *dm, ParticleSystem *psys, ParticleSetti copy_v3_v3(texvec, orco); break; case TEXCO_PARTICLE: - /* texture coordinates in range [-1,1] */ + /* texture coordinates in range [-1, 1] */ texvec[0] = 2.f * (cfra - par->time)/(par->dietime-par->time) - 1.f; texvec[1] = 0.f; texvec[2] = 0.f; @@ -3805,7 +3805,7 @@ static void get_cpa_texture(DerivedMesh *dm, ParticleSystem *psys, ParticleSetti externtex(mtex, texvec, &value, rgba, rgba+1, rgba+2, rgba+3, 0); if ((event & mtex->mapto) & PAMAP_ROUGH) - ptex->rough1= ptex->rough2= ptex->roughe= texture_value_blend(def,ptex->rough1,value,mtex->roughfac,blend); + ptex->rough1= ptex->rough2= ptex->roughe= texture_value_blend(def, ptex->rough1, value, mtex->roughfac, blend); SET_PARTICLE_TEXTURE(PAMAP_LENGTH, ptex->length, mtex->lengthfac); SET_PARTICLE_TEXTURE(PAMAP_CLUMP, ptex->clump, mtex->clumpfac); @@ -3860,10 +3860,10 @@ void psys_get_texture(ParticleSimulationData *sim, ParticleData *pa, ParticleTex break; /* no break, failed to get uv's, so let's try orco's */ case TEXCO_ORCO: - psys_particle_on_emitter(sim->psmd,sim->psys->part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,co,0,0,0,texvec, 0); + psys_particle_on_emitter(sim->psmd, sim->psys->part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, co, 0, 0, 0, texvec, 0); break; case TEXCO_PARTICLE: - /* texture coordinates in range [-1,1] */ + /* texture coordinates in range [-1, 1] */ texvec[0] = 2.f * (cfra - pa->time)/(pa->dietime-pa->time) - 1.f; texvec[1] = 0.f; texvec[2] = 0.f; @@ -3882,7 +3882,7 @@ void psys_get_texture(ParticleSimulationData *sim, ParticleData *pa, ParticleTex setvars |= MAP_PA_TIME; } else - ptex->time= texture_value_blend(def,ptex->time,value,mtex->timefac,blend); + ptex->time= texture_value_blend(def, ptex->time, value, mtex->timefac, blend); } SET_PARTICLE_TEXTURE(PAMAP_LIFE, ptex->life, mtex->lifefac) SET_PARTICLE_TEXTURE(PAMAP_DENS, ptex->exist, mtex->padensfac) @@ -3970,19 +3970,19 @@ static void get_child_modifier_parameters(ParticleSettings *part, ParticleThread return; if (ctx->vg_length) - ptex->length*=psys_interpolate_value_from_verts(ctx->dm,cpa_from,cpa_num,cpa_fuv,ctx->vg_length); + ptex->length*=psys_interpolate_value_from_verts(ctx->dm, cpa_from, cpa_num, cpa_fuv, ctx->vg_length); if (ctx->vg_clump) - ptex->clump*=psys_interpolate_value_from_verts(ctx->dm,cpa_from,cpa_num,cpa_fuv,ctx->vg_clump); + ptex->clump*=psys_interpolate_value_from_verts(ctx->dm, cpa_from, cpa_num, cpa_fuv, ctx->vg_clump); if (ctx->vg_kink) - ptex->kink*=psys_interpolate_value_from_verts(ctx->dm,cpa_from,cpa_num,cpa_fuv,ctx->vg_kink); + ptex->kink*=psys_interpolate_value_from_verts(ctx->dm, cpa_from, cpa_num, cpa_fuv, ctx->vg_kink); if (ctx->vg_rough1) - ptex->rough1*=psys_interpolate_value_from_verts(ctx->dm,cpa_from,cpa_num,cpa_fuv,ctx->vg_rough1); + ptex->rough1*=psys_interpolate_value_from_verts(ctx->dm, cpa_from, cpa_num, cpa_fuv, ctx->vg_rough1); if (ctx->vg_rough2) - ptex->rough2*=psys_interpolate_value_from_verts(ctx->dm,cpa_from,cpa_num,cpa_fuv,ctx->vg_rough2); + ptex->rough2*=psys_interpolate_value_from_verts(ctx->dm, cpa_from, cpa_num, cpa_fuv, ctx->vg_rough2); if (ctx->vg_roughe) - ptex->roughe*=psys_interpolate_value_from_verts(ctx->dm,cpa_from,cpa_num,cpa_fuv,ctx->vg_roughe); + ptex->roughe*=psys_interpolate_value_from_verts(ctx->dm, cpa_from, cpa_num, cpa_fuv, ctx->vg_roughe); if (ctx->vg_effector) - ptex->effector*=psys_interpolate_value_from_verts(ctx->dm,cpa_from,cpa_num,cpa_fuv,ctx->vg_effector); + ptex->effector*=psys_interpolate_value_from_verts(ctx->dm, cpa_from, cpa_num, cpa_fuv, ctx->vg_effector); } static void do_child_modifiers(ParticleSimulationData *sim, ParticleTexture *ptex, ParticleKey *par, float *par_rot, ChildParticle *cpa, float *orco, float mat[4][4], ParticleKey *state, float t) { @@ -4098,13 +4098,13 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * } if (psys->lattice && edit==0) - calc_latt_deform(psys->lattice, state->co,1.0f); + calc_latt_deform(psys->lattice, state->co, 1.0f); } } } } else if (totchild) { - //invert_m4_m4(imat,ob->obmat); + //invert_m4_m4(imat, ob->obmat); /* interpolate childcache directly if it exists */ if (psys->childcache) { @@ -4119,7 +4119,7 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * if (state->time < 0.0f) t = psys_get_child_time(psys, cpa, -state->time, NULL, NULL); - + if (totchild && part->childtype==PART_CHILD_FACES) { /* part->parents could still be 0 so we can't test with totparent */ between=1; @@ -4137,17 +4137,17 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * /* get the original coordinates (orco) for texture usage */ cpa_num=cpa->num; - + foffset= cpa->foffset; cpa_fuv = cpa->fuv; cpa_from = PART_FROM_FACE; - psys_particle_on_emitter(psmd,cpa_from,cpa_num,DMCACHE_ISCHILD,cpa->fuv,foffset,co,0,0,0,orco,0); + psys_particle_on_emitter(psmd, cpa_from, cpa_num, DMCACHE_ISCHILD, cpa->fuv, foffset, co, 0, 0, 0, orco, 0); /* we need to save the actual root position of the child for positioning it accurately to the surface of the emitter */ - //copy_v3_v3(cpa_1st,co); + //copy_v3_v3(cpa_1st, co); - //mul_m4_v3(ob->obmat,cpa_1st); + //mul_m4_v3(ob->obmat, cpa_1st); pa = psys->particles + cpa->parent; @@ -4158,38 +4158,38 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * pa=0; } - else { - /* get the parent state */ - keys->time = state->time; - psys_get_particle_on_path(sim, cpa->parent, keys,1); + else { + /* get the parent state */ + keys->time = state->time; + psys_get_particle_on_path(sim, cpa->parent, keys, 1); - /* get the original coordinates (orco) for texture usage */ - pa=psys->particles+cpa->parent; + /* get the original coordinates (orco) for texture usage */ + pa=psys->particles+cpa->parent; - cpa_from=part->from; - cpa_num=pa->num; - cpa_fuv=pa->fuv; + cpa_from=part->from; + cpa_num=pa->num; + cpa_fuv=pa->fuv; - - if (part->type == PART_HAIR) { - psys_particle_on_emitter(psmd,cpa_from,cpa_num,DMCACHE_ISCHILD,cpa_fuv,pa->foffset,co,0,0,0,orco,0); - psys_mat_hair_to_global(sim->ob, sim->psmd->dm, psys->part->from, pa, hairmat); - } - else { - copy_v3_v3(orco, cpa->fuv); - unit_m4(hairmat); + + if (part->type == PART_HAIR) { + psys_particle_on_emitter(psmd, cpa_from, cpa_num, DMCACHE_ISCHILD, cpa_fuv, pa->foffset, co, 0, 0, 0, orco, 0); + psys_mat_hair_to_global(sim->ob, sim->psmd->dm, psys->part->from, pa, hairmat); + } + else { + copy_v3_v3(orco, cpa->fuv); + unit_m4(hairmat); + } } - } /* correct child ipo timing */ - #if 0 // XXX old animation system +#if 0 // XXX old animation system if ((part->flag&PART_ABS_TIME)==0 && part->ipo) { calc_ipo(part->ipo, 100.0f*t); execute_ipo((ID *)part, part->ipo); } - #endif // XXX old animation system - +#endif // XXX old animation system + /* get different child parameters from textures & vgroups */ memset(&ctx, 0, sizeof(ParticleThreadContext)); ctx.sim = *sim; @@ -4238,14 +4238,14 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * if (t>=0.001f) { tstate.time=t-0.001f; - psys_get_particle_on_path(sim,p,&tstate,0); - sub_v3_v3v3(state->vel,state->co,tstate.co); + psys_get_particle_on_path(sim, p, &tstate, 0); + sub_v3_v3v3(state->vel, state->co, tstate.co); normalize_v3(state->vel); } else { tstate.time=t+0.001f; - psys_get_particle_on_path(sim,p,&tstate,0); - sub_v3_v3v3(state->vel,tstate.co,state->co); + psys_get_particle_on_path(sim, p, &tstate, 0); + sub_v3_v3v3(state->vel, tstate.co, state->co); normalize_v3(state->vel); } @@ -4290,7 +4290,7 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta state->time= (cfra - (part->sta + (part->end - part->sta) * PSYS_FRAND(p + 23))) / (part->lifetime * PSYS_FRAND(p + 24)); - psys_get_particle_on_path(sim, p, state,1); + psys_get_particle_on_path(sim, p, state, 1); return 1; } else { @@ -4316,7 +4316,7 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta if (sim->psys->flag & PSYS_KEYED) { state->time= -cfra; - psys_get_particle_on_path(sim, p, state,1); + psys_get_particle_on_path(sim, p, state, 1); return 1; } else { @@ -4334,10 +4334,10 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta do_child_modifiers(sim, NULL, key1, key1->rot, cpa, cpa->fuv, mat, state, t); if (psys->lattice) - calc_latt_deform(sim->psys->lattice, state->co,1.0f); + calc_latt_deform(sim->psys->lattice, state->co, 1.0f); } else { - if (pa->state.time==cfra || ELEM(part->phystype,PART_PHYS_NO,PART_PHYS_KEYED)) + if (pa->state.time==cfra || ELEM(part->phystype, PART_PHYS_NO, PART_PHYS_KEYED)) copy_particle_key(state, &pa->state, 1); else if (pa->prev_state.time==cfra) copy_particle_key(state, &pa->prev_state, 1); @@ -4393,7 +4393,7 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta } if (sim->psys->lattice) - calc_latt_deform(sim->psys->lattice, state->co,1.0f); + calc_latt_deform(sim->psys->lattice, state->co, 1.0f); } return 1; @@ -4418,7 +4418,7 @@ void psys_get_dupli_texture(ParticleSystem *psys, ParticleSettings *part, Partic psys_interpolate_uvs(mtface, mface->v4, cpa->fuv, uv); } - psys_particle_on_emitter(psmd,PART_FROM_FACE,cpa->num,DMCACHE_ISCHILD,cpa->fuv,cpa->foffset,loc,0,0,0,orco,0); + psys_particle_on_emitter(psmd, PART_FROM_FACE, cpa->num, DMCACHE_ISCHILD, cpa->fuv, cpa->foffset, loc, 0, 0, 0, orco, 0); return; } else { @@ -4446,7 +4446,7 @@ void psys_get_dupli_texture(ParticleSystem *psys, ParticleSettings *part, Partic } } - psys_particle_on_emitter(psmd,part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,loc,0,0,0,orco,0); + psys_particle_on_emitter(psmd, part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, loc, 0, 0, 0, orco, 0); } void psys_get_dupli_path_transform(ParticleSimulationData *sim, ParticleData *pa, ChildParticle *cpa, ParticleCacheKey *cache, float mat[][4], float *scale) @@ -4464,9 +4464,9 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim, ParticleData *pa pa = psys->particles + cpa->pa[0]; if (pa) - psys_particle_on_emitter(psmd,sim->psys->part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,loc,nor,0,0,0,0); + psys_particle_on_emitter(psmd, sim->psys->part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, loc, nor, 0, 0, 0, 0); else - psys_particle_on_emitter(psmd,PART_FROM_FACE,cpa->num,DMCACHE_ISCHILD,cpa->fuv,cpa->foffset,loc,nor,0,0,0,0); + psys_particle_on_emitter(psmd, PART_FROM_FACE, cpa->num, DMCACHE_ISCHILD, cpa->fuv, cpa->foffset, loc, nor, 0, 0, 0, 0); if (psys->part->rotmode == PART_ROT_VEL) { copy_m3_m4(nmat, ob->imat); @@ -4475,8 +4475,8 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim, ParticleData *pa normalize_v3(nor); /* make sure that we get a proper side vector */ - if (fabs(dot_v3v3(nor,vec))>0.999999) { - if (fabs(dot_v3v3(nor,xvec))>0.999999) { + if (fabs(dot_v3v3(nor, vec))>0.999999) { + if (fabs(dot_v3v3(nor, xvec))>0.999999) { nor[0] = 0.0f; nor[1] = 1.0f; nor[2] = 0.0f; @@ -4496,7 +4496,7 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim, ParticleData *pa float phasefac = psys->part->phasefac; if (psys->part->randphasefac != 0.0f) phasefac += psys->part->randphasefac * PSYS_FRAND((pa-psys->particles) + 20); - axis_angle_to_quat( q_phase, vec, phasefac*(float)M_PI); + axis_angle_to_quat(q_phase, vec, phasefac*(float)M_PI); mul_qt_v3(q_phase, side); } @@ -4517,7 +4517,7 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim, ParticleData *pa void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3], float zvec[3], float center[3]) { - float onevec[3] = {0.0f,0.0f,0.0f}, tvec[3], tvec2[3]; + float onevec[3] = {0.0f, 0.0f, 0.0f}, tvec[3], tvec2[3]; xvec[0] = 1.0f; xvec[1] = 0.0f; xvec[2] = 0.0f; yvec[0] = 0.0f; yvec[1] = 1.0f; yvec[2] = 0.0f; @@ -4561,10 +4561,10 @@ void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3] } normalize_v3(zvec); - cross_v3_v3v3(xvec,temp,zvec); + cross_v3_v3v3(xvec, temp, zvec); normalize_v3(xvec); - cross_v3_v3v3(yvec,zvec,xvec); + cross_v3_v3v3(yvec, zvec, xvec); } else { sub_v3_v3v3(zvec, bb->ob->obmat[3], bb->vec); @@ -4578,7 +4578,7 @@ void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3] cross_v3_v3v3(xvec, bb->ob->obmat[1], zvec); normalize_v3(xvec); - cross_v3_v3v3(yvec,zvec,xvec); + cross_v3_v3v3(yvec, zvec, xvec); } copy_v3_v3(tvec, xvec); diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index d3644657de7..a4d61cea3fb 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -241,10 +241,10 @@ static void realloc_particles(ParticleSimulationData *sim, int new_totpart) } if (psys->particles) { - totsaved=MIN2(psys->totpart,totpart); + totsaved=MIN2(psys->totpart, totpart); /*save old pars*/ if (totsaved) { - memcpy(newpars,psys->particles,totsaved*sizeof(ParticleData)); + memcpy(newpars, psys->particles, totsaved*sizeof(ParticleData)); if (psys->particles->boid) memcpy(newboids, psys->particles->boid, totsaved*sizeof(BoidParticle)); @@ -418,7 +418,7 @@ static void distribute_simple_children(Scene *scene, Object *ob, DerivedMesh *fi cpa = psys->child; for (i=0; i<child_nbr; i++) { - for (p=0; p<psys->totpart; p++,cpa++) { + for (p=0; p<psys->totpart; p++, cpa++) { float length=2.0; cpa->parent=p; @@ -440,7 +440,7 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys) { ParticleData *pa=NULL; float min[3], max[3], delta[3], d; - MVert *mv, *mvert = dm->getVertDataArray(dm,0); + MVert *mv, *mvert = dm->getVertDataArray(dm, 0); int totvert=dm->getNumVerts(dm), from=psys->part->from; int i, j, k, p, res=psys->part->grid_res, size[3], axis; @@ -452,13 +452,13 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys) mv++; for (i=1; i<totvert; i++, mv++) { - min[0]=MIN2(min[0],mv->co[0]); - min[1]=MIN2(min[1],mv->co[1]); - min[2]=MIN2(min[2],mv->co[2]); + min[0]=MIN2(min[0], mv->co[0]); + min[1]=MIN2(min[1], mv->co[1]); + min[2]=MIN2(min[2], mv->co[2]); - max[0]=MAX2(max[0],mv->co[0]); - max[1]=MAX2(max[1],mv->co[1]); - max[2]=MAX2(max[2],mv->co[2]); + max[0]=MAX2(max[0], mv->co[0]); + max[1]=MAX2(max[1], mv->co[1]); + max[2]=MAX2(max[2], mv->co[2]); } sub_v3_v3v3(delta, max, min); @@ -473,8 +473,8 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys) size[(axis+2)%3] = (int)ceil(delta[(axis+2)%3]/d); /* float errors grrr.. */ - size[(axis+1)%3] = MIN2(size[(axis+1)%3],res); - size[(axis+2)%3] = MIN2(size[(axis+2)%3],res); + size[(axis+1)%3] = MIN2(size[(axis+1)%3], res); + size[(axis+2)%3] = MIN2(size[(axis+2)%3], res); size[0] = MAX2(size[0], 1); size[1] = MAX2(size[1], 1); @@ -485,9 +485,9 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys) min[1]+= d < delta[1] ? d/2.f : delta[1]/2.f; min[2]+= d < delta[2] ? d/2.f : delta[2]/2.f; - for (i=0,p=0,pa=psys->particles; i<res; i++) { + for (i=0, p=0, pa=psys->particles; i<res; i++) { for (j=0; j<res; j++) { - for (k=0; k<res; k++,p++,pa++) { + for (k=0; k<res; k++, p++, pa++) { pa->fuv[0] = min[0] + (float)i*d; pa->fuv[1] = min[1] + (float)j*d; pa->fuv[2] = min[2] + (float)k*d; @@ -507,8 +507,8 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys) min[1] -= d/2.0f; min[2] -= d/2.0f; - for (i=0,mv=mvert; i<totvert; i++,mv++) { - sub_v3_v3v3(vec,mv->co,min); + for (i=0, mv=mvert; i<totvert; i++, mv++) { + sub_v3_v3v3(vec, mv->co, min); vec[0]/=delta[0]; vec[1]/=delta[1]; vec[2]/=delta[2]; @@ -517,7 +517,7 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys) +(int)(vec[2]*(size[2]-1)))->flag &= ~PARS_UNEXIST; } } - else if (ELEM(from,PART_FROM_FACE,PART_FROM_VOLUME)) { + else if (ELEM(from, PART_FROM_FACE, PART_FROM_VOLUME)) { float co1[3], co2[3]; MFace *mface= NULL, *mface_array; @@ -526,7 +526,7 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys) int amax= from==PART_FROM_FACE ? 3 : 1; totface=dm->getNumTessFaces(dm); - mface=mface_array=dm->getTessFaceDataArray(dm,CD_MFACE); + mface=mface_array=dm->getTessFaceDataArray(dm, CD_MFACE); for (a=0; a<amax; a++) { if (a==0) { a0mul=res*res; a1mul=res; a2mul=1; } @@ -545,7 +545,7 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys) co1[a] -= 0.001f*d; /* lets intersect the faces */ - for (i=0; i<totface; i++,mface++) { + for (i=0; i<totface; i++, mface++) { copy_v3_v3(v1, mvert[mface->v1].co); copy_v3_v3(v2, mvert[mface->v2].co); copy_v3_v3(v3, mvert[mface->v3].co); @@ -586,9 +586,9 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys) } if (psys->part->flag & PART_GRID_HEXAGONAL) { - for (i=0,p=0,pa=psys->particles; i<res; i++) { + for (i=0, p=0, pa=psys->particles; i<res; i++) { for (j=0; j<res; j++) { - for (k=0; k<res; k++,p++,pa++) { + for (k=0; k<res; k++, p++, pa++) { if (j%2) pa->fuv[0] += d/2.f; @@ -614,7 +614,7 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys) if (psys->part->grid_rand > 0.f) { float rfac = d * psys->part->grid_rand; - for (p=0,pa=psys->particles; p<psys->totpart; p++,pa++) { + for (p=0, pa=psys->particles; p<psys->totpart; p++, pa++) { if (pa->flag & PARS_UNEXIST) continue; @@ -708,10 +708,10 @@ static void psys_uv_to_w(float u, float v, int quad, float *w) if (quad) { vert[3][0]= 0.0f; vert[3][1]= 1.0f; vert[3][2]= 0.0f; - interp_weights_poly_v3( w,vert, 4, co); + interp_weights_poly_v3(w, vert, 4, co); } else { - interp_weights_poly_v3( w,vert, 3, co); + interp_weights_poly_v3(w, vert, 3, co); w[3]= 0.0f; } } @@ -771,9 +771,9 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch KDTreeNearest ptn[3]; int w, maxw; - psys_particle_on_dm(ctx->dm,from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,co1,0,0,0,orco1,0); + psys_particle_on_dm(ctx->dm, from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, co1, 0, 0, 0, orco1, 0); transform_mesh_orco_verts((Mesh*)ob->data, &orco1, 1, 1); - maxw = BLI_kdtree_find_n_nearest(ctx->tree,3,orco1,NULL,ptn); + maxw = BLI_kdtree_find_n_nearest(ctx->tree, 3, orco1, NULL, ptn); for (w=0; w<maxw; w++) { pa->verts[w]=ptn->num; @@ -785,7 +785,7 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch MFace *mface; pa->num = i = ctx->index[p]; - mface = dm->getTessFaceData(dm,i,CD_MFACE); + mface = dm->getTessFaceData(dm, i, CD_MFACE); switch (distr) { case PART_DISTR_JIT: @@ -796,7 +796,7 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch psys_uv_to_w(0.33333f, 0.33333f, mface->v4, pa->fuv); } else { - ctx->jitoff[i] = fmod(ctx->jitoff[i],(float)ctx->jitlevel); + ctx->jitoff[i] = fmod(ctx->jitoff[i], (float)ctx->jitlevel); psys_uv_to_w(ctx->jit[2*(int)ctx->jitoff[i]], ctx->jit[2*(int)ctx->jitoff[i]+1], mface->v4, pa->fuv); ctx->jitoff[i]++; } @@ -813,21 +813,21 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch /* experimental */ if (from==PART_FROM_VOLUME) { - MVert *mvert=dm->getVertDataArray(dm,CD_MVERT); + MVert *mvert=dm->getVertDataArray(dm, CD_MVERT); tot=dm->getNumTessFaces(dm); - psys_interpolate_face(mvert,mface,0,0,pa->fuv,co1,nor,0,0,0,0); + psys_interpolate_face(mvert, mface, 0, 0, pa->fuv, co1, nor, 0, 0, 0, 0); normalize_v3(nor); - mul_v3_fl(nor,-100.0); + mul_v3_fl(nor, -100.0); - add_v3_v3v3(co2,co1,nor); + add_v3_v3v3(co2, co1, nor); min_d=2.0; intersect=0; - for (i=0,mface=dm->getTessFaceDataArray(dm,CD_MFACE); i<tot; i++,mface++) { + for (i=0, mface=dm->getTessFaceDataArray(dm, CD_MFACE); i<tot; i++, mface++) { if (i==pa->num) continue; v1=mvert[mface->v1].co; @@ -889,14 +889,14 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch if (ctx->tree) { KDTreeNearest ptn[10]; - int w,maxw;//, do_seams; - float maxd /*, mind,dd */, totw= 0.0f; + int w, maxw;//, do_seams; + float maxd /*, mind, dd */, totw= 0.0f; int parent[10]; float pweight[10]; - psys_particle_on_dm(dm,cfrom,cpa->num,DMCACHE_ISCHILD,cpa->fuv,cpa->foffset,co1,nor1,NULL,NULL,orco1,NULL); + psys_particle_on_dm(dm, cfrom, cpa->num, DMCACHE_ISCHILD, cpa->fuv, cpa->foffset, co1, nor1, NULL, NULL, orco1, NULL); transform_mesh_orco_verts((Mesh*)ob->data, &orco1, 1, 1); - maxw = BLI_kdtree_find_n_nearest(ctx->tree,4,orco1,NULL,ptn); + maxw = BLI_kdtree_find_n_nearest(ctx->tree, 4, orco1, NULL, ptn); maxd=ptn[maxw-1].dist; /* mind=ptn[0].dist; */ /* UNUSED */ @@ -904,14 +904,14 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch /* the weights here could be done better */ for (w=0; w<maxw; w++) { parent[w]=ptn[w].index; - pweight[w]=(float)pow(2.0,(double)(-6.0f*ptn[w].dist/maxd)); + pweight[w]=(float)pow(2.0, (double)(-6.0f*ptn[w].dist/maxd)); } for (;w<10; w++) { parent[w]=-1; pweight[w]=0.0f; } - for (w=0,i=0; w<maxw && i<4; w++) { + for (w=0, i=0; w<maxw && i<4; w++) { if (parent[w]>=0) { cpa->pa[i]=parent[w]; cpa->w[i]=pweight[w]; @@ -997,7 +997,7 @@ static void distribute_invalid(Scene *scene, ParticleSystem *psys, int from) int p, totchild = get_psys_tot_child(scene, psys); if (psys->child && totchild) { - for (p=0,cpa=psys->child; p<totchild; p++,cpa++) { + for (p=0, cpa=psys->child; p<totchild; p++, cpa++) { cpa->fuv[0]=cpa->fuv[1]=cpa->fuv[2]=cpa->fuv[3]= 0.0; cpa->foffset= 0.0f; cpa->parent=0; @@ -1033,7 +1033,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D int cfrom=0; int totelem=0, totpart, *particle_element=0, children=0, totseam=0; int jitlevel= 1, distr; - float *element_weight=NULL,*element_sum=NULL,*jitter_offset=NULL, *vweight=NULL; + float *element_weight=NULL, *element_sum=NULL, *jitter_offset=NULL, *vweight=NULL; float cur, maxweight=0.0, tweight, totweight, inv_totweight, co[3], nor[3], orco[3], ornor[3]; if (ELEM3(NULL, ob, psys, psys->part)) @@ -1064,7 +1064,8 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D if (part->distr==PART_DISTR_GRID && from != PART_FROM_VERT) { BLI_srandom(31415926 + psys->seed); dm= CDDM_from_mesh((Mesh*)ob->data, ob); - distribute_grid(dm,psys); + DM_ensure_tessface(dm); + distribute_grid(dm, psys); dm->release(dm); return 0; } @@ -1083,8 +1084,8 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D tree=BLI_kdtree_new(totpart); - for (p=0,pa=psys->particles; p<totpart; p++,pa++) { - psys_particle_on_dm(dm,part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,co,nor,0,0,orco,ornor); + for (p=0, pa=psys->particles; p<totpart; p++, pa++) { + psys_particle_on_dm(dm, part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, co, nor, 0, 0, orco, ornor); transform_mesh_orco_verts((Mesh*)ob->data, &orco, 1, 1); BLI_kdtree_insert(tree, p, orco, ornor); } @@ -1117,12 +1118,12 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D for (p=0; p<totvert; p++) { if (orcodata) { - copy_v3_v3(co,orcodata[p]); + copy_v3_v3(co, orcodata[p]); transform_mesh_orco_verts((Mesh*)ob->data, &co, 1, 1); } else - copy_v3_v3(co,mv[p].co); - BLI_kdtree_insert(tree,p,co,NULL); + copy_v3_v3(co, mv[p].co); + BLI_kdtree_insert(tree, p, co, NULL); } BLI_kdtree_balance(tree); @@ -1136,7 +1137,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D distribute_invalid(scene, psys, children ? PART_FROM_CHILD : 0); if (G.debug & G_DEBUG) - fprintf(stderr,"Particle distribution error: Nothing to emit from!\n"); + fprintf(stderr, "Particle distribution error: Nothing to emit from!\n"); if (dm != finaldm) dm->release(dm); @@ -1159,7 +1160,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D orcodata= dm->getVertDataArray(dm, CD_ORCO); for (i=0; i<totelem; i++) { - MFace *mf=dm->getTessFaceData(dm,i,CD_MFACE); + MFace *mf=dm->getTessFaceData(dm, i, CD_MFACE); if (orcodata) { copy_v3_v3(co1, orcodata[mf->v1]); @@ -1174,14 +1175,14 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D } } else { - v1= (MVert*)dm->getVertData(dm,mf->v1,CD_MVERT); - v2= (MVert*)dm->getVertData(dm,mf->v2,CD_MVERT); - v3= (MVert*)dm->getVertData(dm,mf->v3,CD_MVERT); + v1= (MVert*)dm->getVertData(dm, mf->v1, CD_MVERT); + v2= (MVert*)dm->getVertData(dm, mf->v2, CD_MVERT); + v3= (MVert*)dm->getVertData(dm, mf->v3, CD_MVERT); copy_v3_v3(co1, v1->co); copy_v3_v3(co2, v2->co); copy_v3_v3(co3, v3->co); if (mf->v4) { - v4= (MVert*)dm->getVertData(dm,mf->v4,CD_MVERT); + v4= (MVert*)dm->getVertData(dm, mf->v4, CD_MVERT); copy_v3_v3(co4, v4->co); } } @@ -1201,14 +1202,14 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D maxweight /= totarea; } else { - float min=1.0f/(float)(MIN2(totelem,totpart)); + float min=1.0f/(float)(MIN2(totelem, totpart)); for (i=0; i<totelem; i++) element_weight[i]=min; maxweight=min; } /* Calculate weights from vgroup */ - vweight = psys_cache_vgroup(dm,psys,PSYS_VG_DENSITY); + vweight = psys_cache_vgroup(dm, psys, PSYS_VG_DENSITY); if (vweight) { if (from==PART_FROM_VERT) { @@ -1217,7 +1218,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D } else { /* PART_FROM_FACE / PART_FROM_VOLUME */ for (i=0;i<totelem; i++) { - MFace *mf=dm->getTessFaceData(dm,i,CD_MFACE); + MFace *mf=dm->getTessFaceData(dm, i, CD_MFACE); tweight = vweight[mf->v1] + vweight[mf->v2] + vweight[mf->v3]; if (mf->v4) { @@ -1302,7 +1303,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D } /* Create jittering if needed */ - if (distr==PART_DISTR_JIT && ELEM(from,PART_FROM_FACE,PART_FROM_VOLUME)) { + if (distr==PART_DISTR_JIT && ELEM(from, PART_FROM_FACE, PART_FROM_VOLUME)) { jitlevel= part->userjit; if (jitlevel == 0) { @@ -1398,7 +1399,7 @@ static void distribute_particles_on_shape(ParticleSimulationData *sim, int UNUSE { distribute_invalid(sim->scene, sim->psys, 0); - fprintf(stderr,"Shape emission not yet possible!\n"); + fprintf(stderr, "Shape emission not yet possible!\n"); } static void distribute_particles(ParticleSimulationData *sim, int from) @@ -1418,7 +1419,7 @@ static void distribute_particles(ParticleSimulationData *sim, int from) if (distr_error) { distribute_invalid(sim->scene, sim->psys, from); - fprintf(stderr,"Particle distribution error!\n"); + fprintf(stderr, "Particle distribution error!\n"); } } @@ -1619,18 +1620,18 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P ParticleSystem *psys = sim->psys; ParticleSettings *part; ParticleTexture ptex; - float fac, phasefac, nor[3]={0,0,0},loc[3],vel[3]={0.0,0.0,0.0},rot[4],q2[4]; - float r_vel[3],r_ave[3],r_rot[4],vec[3],p_vel[3]={0.0,0.0,0.0}; - float x_vec[3]={1.0,0.0,0.0}, utan[3]={0.0,1.0,0.0}, vtan[3]={0.0,0.0,1.0}, rot_vec[3]={0.0,0.0,0.0}; + float fac, phasefac, nor[3]={0, 0, 0}, loc[3], vel[3]={0.0, 0.0, 0.0}, rot[4], q2[4]; + float r_vel[3], r_ave[3], r_rot[4], vec[3], p_vel[3]={0.0, 0.0, 0.0}; + float x_vec[3]={1.0, 0.0, 0.0}, utan[3]={0.0, 1.0, 0.0}, vtan[3]={0.0, 0.0, 1.0}, rot_vec[3]={0.0, 0.0, 0.0}; float q_phase[4]; int p = pa - psys->particles; part=psys->part; /* get birth location from object */ if (part->tanfac != 0.f) - psys_particle_on_emitter(sim->psmd, part->from,pa->num, pa->num_dmcache, pa->fuv,pa->foffset,loc,nor,utan,vtan,0,0); + psys_particle_on_emitter(sim->psmd, part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, loc, nor, utan, vtan, 0, 0); else - psys_particle_on_emitter(sim->psmd, part->from,pa->num, pa->num_dmcache, pa->fuv,pa->foffset,loc,nor,0,0,0,0); + psys_particle_on_emitter(sim->psmd, part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, loc, nor, 0, 0, 0, 0); /* get possible textural influence */ psys_get_texture(sim, pa, &ptex, PAMAP_IVEL, cfra); @@ -1646,16 +1647,16 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P /* -tangent */ if (part->tanfac!=0.0f) { - //float phase=vg_rot?2.0f*(psys_particle_value_from_verts(sim->psmd->dm,part->from,pa,vg_rot)-0.5f):0.0f; + //float phase=vg_rot?2.0f*(psys_particle_value_from_verts(sim->psmd->dm, part->from, pa, vg_rot)-0.5f):0.0f; float phase=0.0f; - mul_v3_fl(vtan,-cosf((float)M_PI*(part->tanphase+phase))); + mul_v3_fl(vtan, -cosf((float)M_PI*(part->tanphase+phase))); fac= -sinf((float)M_PI*(part->tanphase+phase)); madd_v3_v3fl(vtan, utan, fac); - mul_mat3_m4_v3(ob->obmat,vtan); + mul_mat3_m4_v3(ob->obmat, vtan); copy_v3_v3(utan, nor); - mul_v3_fl(utan,dot_v3v3(vtan,nor)); + mul_v3_fl(utan, dot_v3v3(vtan, nor)); sub_v3_v3(vtan, utan); normalize_v3(vtan); @@ -1678,7 +1679,7 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P r_ave[1] = 2.0f * (PSYS_FRAND(p + 14) - 0.5f); r_ave[2] = 2.0f * (PSYS_FRAND(p + 15) - 0.5f); - mul_mat3_m4_v3(ob->obmat,r_ave); + mul_mat3_m4_v3(ob->obmat, r_ave); normalize_v3(r_ave); } @@ -1690,14 +1691,14 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P r_rot[3] = 2.0f * (PSYS_FRAND(p + 19) - 0.5f); normalize_qt(r_rot); - mat4_to_quat(rot,ob->obmat); - mul_qt_qtqt(r_rot,r_rot,rot); + mat4_to_quat(rot, ob->obmat); + mul_qt_qtqt(r_rot, r_rot, rot); } if (part->phystype==PART_PHYS_BOIDS && pa->boid) { float dvec[3], q[4], mat[3][3]; - copy_v3_v3(state->co,loc); + copy_v3_v3(state->co, loc); /* boids don't get any initial velocity */ zero_v3(state->vel); @@ -1720,7 +1721,7 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P cross_v3_v3v3(mat[1], mat[2], mat[0]); /* apply rotation */ - mat3_to_quat_is_ok( q,mat); + mat3_to_quat_is_ok(q, mat); copy_qt_qt(state->rot, q); } else { @@ -1774,7 +1775,7 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P mul_v3_v3fl(state->vel, vel, ptex.ivel); /* -location from emitter */ - copy_v3_v3(state->co,loc); + copy_v3_v3(state->co, loc); /* -rotation */ unit_qt(state->rot); @@ -1802,19 +1803,19 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P /* create rotation quat */ negate_v3(rot_vec); - vec_to_quat( q2,rot_vec, OB_POSX, OB_POSZ); + vec_to_quat(q2, rot_vec, OB_POSX, OB_POSZ); /* randomize rotation quat */ if (part->randrotfac!=0.0f) interp_qt_qtqt(rot, q2, r_rot, part->randrotfac); else - copy_qt_qt(rot,q2); + copy_qt_qt(rot, q2); /* rotation phase */ phasefac = part->phasefac; if (part->randphasefac != 0.0f) phasefac += part->randphasefac * PSYS_FRAND(p + 20); - axis_angle_to_quat( q_phase,x_vec, phasefac*(float)M_PI); + axis_angle_to_quat(q_phase, x_vec, phasefac*(float)M_PI); /* combine base rotation & phase */ mul_qt_qtqt(state->rot, rot, q_phase); @@ -2132,7 +2133,7 @@ static void psys_update_effectors(ParticleSimulationData *sim) static void integrate_particle(ParticleSettings *part, ParticleData *pa, float dtime, float *external_acceleration, void (*force_func)(void *forcedata, ParticleKey *state, float *force, float *impulse), void *forcedata) { ParticleKey states[5]; - float force[3],acceleration[3],impulse[3],dx[4][3],dv[4][3],oldpos[3]; + float force[3], acceleration[3], impulse[3], dx[4][3], dv[4][3], oldpos[3]; float pa_mass= (part->flag & PART_SIZEMASS ? part->mass * pa->size : part->mass); int i, steps=1; int integrator = part->integrator; @@ -2537,10 +2538,10 @@ static void sph_force_cb(void *sphdata_v, ParticleKey *state, float *force, floa u = dot_v3v3(vec, dv); if (u < 0.f && visc > 0.f) - madd_v3_v3fl(force, vec, 0.5f * q * visc * u ); + madd_v3_v3fl(force, vec, 0.5f * q * visc * u); if (u > 0.f && stiff_visc > 0.f) - madd_v3_v3fl(force, vec, 0.5f * q * stiff_visc * u ); + madd_v3_v3fl(force, vec, 0.5f * q * stiff_visc * u); } if (spring_constant > 0.f) { @@ -2713,23 +2714,23 @@ static void basic_integrate(ParticleSimulationData *sim, int p, float dfra, floa time=(cfra-pa->time)/pa->lifetime; CLAMP(time, 0.0f, 1.0f); - copy_v3_v3(tkey.co,pa->state.co); - copy_v3_v3(tkey.vel,pa->state.vel); + copy_v3_v3(tkey.co, pa->state.co); + copy_v3_v3(tkey.vel, pa->state.vel); tkey.time=pa->state.time; if (part->type != PART_HAIR) { if (do_guides(sim->psys->effectors, &tkey, p, time)) { - copy_v3_v3(pa->state.co,tkey.co); + copy_v3_v3(pa->state.co, tkey.co); /* guides don't produce valid velocity */ sub_v3_v3v3(pa->state.vel, tkey.co, pa->prev_state.co); - mul_v3_fl(pa->state.vel,1.0f/dtime); + mul_v3_fl(pa->state.vel, 1.0f/dtime); pa->state.time=tkey.time; } } } static void basic_rotate(ParticleSettings *part, ParticleData *pa, float dfra, float timestep) { - float rotfac, rot1[4], rot2[4]={1.0,0.0,0.0,0.0}, dtime=dfra*timestep; + float rotfac, rot1[4], rot2[4]={1.0, 0.0, 0.0, 0.0}, dtime=dfra*timestep; if ((part->flag & PART_ROTATIONS)==0) { pa->state.rot[0]=1.0f; @@ -2757,15 +2758,15 @@ static void basic_rotate(ParticleSettings *part, ParticleData *pa, float dfra, f } rotfac = len_v3(pa->state.ave); - if (rotfac == 0.0f) { /* unit_qt(in VecRotToQuat) doesn't give unit quat [1,0,0,0]?? */ + if (rotfac == 0.0f) { /* unit_qt(in VecRotToQuat) doesn't give unit quat [1, 0, 0, 0]?? */ rot1[0]=1.0f; rot1[1]=rot1[2]=rot1[3]=0; } else { - axis_angle_to_quat(rot1,pa->state.ave,rotfac*dtime); + axis_angle_to_quat(rot1, pa->state.ave, rotfac*dtime); } - mul_qt_qtqt(pa->state.rot,rot1,pa->prev_state.rot); - mul_qt_qtqt(pa->state.rot,rot2,pa->state.rot); + mul_qt_qtqt(pa->state.rot, rot1, pa->prev_state.rot); + mul_qt_qtqt(pa->state.rot, rot2, pa->state.rot); /* keep rotation quat in good health */ normalize_qt(pa->state.rot); @@ -3256,8 +3257,8 @@ static int collision_response(ParticleData *pa, ParticleCollision *col, BVHTreeR float frict = pd->pdef_frict + pd->pdef_rfrict * 2 * (BLI_frand() - 0.5f); float distance, nor[3], dot; - CLAMP(damp,0.0f, 1.0f); - CLAMP(frict,0.0f, 1.0f); + CLAMP(damp, 0.0f, 1.0f); + CLAMP(frict, 0.0f, 1.0f); /* get exact velocity right before collision */ madd_v3_v3v3fl(v0, col->ve1, col->acc, dt1); @@ -3603,7 +3604,7 @@ static void do_hair_dynamics(ParticleSimulationData *sim) psys_mat_hair_to_object(sim->ob, sim->psmd->dm, psys->part->from, pa, hairmat); - for (k=0, key=pa->hair; k<pa->totkey; k++,key++) { + for (k=0, key=pa->hair; k<pa->totkey; k++, key++) { /* create fake root before actual root to resist bending */ if (k==0) { @@ -3869,7 +3870,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) } /* initialize all particles for dynamics */ LOOP_SHOWN_PARTICLES { - copy_particle_key(&pa->prev_state,&pa->state,1); + copy_particle_key(&pa->prev_state, &pa->state, 1); psys_get_texture(sim, pa, &ptex, PAMAP_SIZE, cfra); @@ -3948,7 +3949,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) SPHData sphdata; sph_solver_init(sim, &sphdata); - #pragma omp parallel for firstprivate (sphdata) private (pa) schedule(dynamic,5) + #pragma omp parallel for firstprivate (sphdata) private (pa) schedule(dynamic, 5) LOOP_DYNAMIC_PARTICLES { /* do global forces & effectors */ basic_integrate(sim, p, pa->state.time, cfra); @@ -4085,7 +4086,7 @@ static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra)) gzf = BLI_gzopen(filename, "rb"); if (!gzf) { - BLI_snprintf(debugStrBuffer, sizeof(debugStrBuffer),"readFsPartData::error - Unable to open file for reading '%s'\n", filename); + BLI_snprintf(debugStrBuffer, sizeof(debugStrBuffer), "readFsPartData::error - Unable to open file for reading '%s'\n", filename); // XXX bad level call elbeemDebugOut(debugStrBuffer); return; } @@ -4106,23 +4107,23 @@ static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra)) for (p=0, pa=psys->particles; p<totpart; p++, pa++) { int ptype=0; - gzread(gzf, &ptype, sizeof( ptype )); + gzread(gzf, &ptype, sizeof(ptype)); if (ptype&readMask) { activeParts++; - gzread(gzf, &(pa->size), sizeof( float )); + gzread(gzf, &(pa->size), sizeof(float)); pa->size /= 10.0f; for (j=0; j<3; j++) { float wrf; - gzread(gzf, &wrf, sizeof( wrf )); + gzread(gzf, &wrf, sizeof(wrf)); pa->state.co[j] = wrf; - //fprintf(stderr,"Rj%d ",j); + //fprintf(stderr, "Rj%d ", j); } for (j=0; j<3; j++) { float wrf; - gzread(gzf, &wrf, sizeof( wrf )); + gzread(gzf, &wrf, sizeof(wrf)); pa->state.vel[j] = wrf; } @@ -4134,7 +4135,7 @@ static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra)) pa->dietime = sim->scene->r.efra + 1; pa->lifetime = sim->scene->r.efra; pa->alive = PARS_ALIVE; - //if (a < 25) fprintf(stderr,"FSPARTICLE debug set %s , a%d = %f,%f,%f , life=%f\n", filename, a, pa->co[0],pa->co[1],pa->co[2], pa->lifetime ); + //if (a < 25) fprintf(stderr, "FSPARTICLE debug set %s, a%d = %f, %f, %f, life=%f\n", filename, a, pa->co[0], pa->co[1], pa->co[2], pa->lifetime ); } else { // skip... @@ -4147,7 +4148,7 @@ static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra)) gzclose(gzf); totpart = psys->totpart = activeParts; - BLI_snprintf(debugStrBuffer,sizeof(debugStrBuffer),"readFsPartData::done - particles:%d, active:%d, file:%d, mask:%d\n", psys->totpart,activeParts,fileParts,readMask); + BLI_snprintf(debugStrBuffer, sizeof(debugStrBuffer), "readFsPartData::done - particles:%d, active:%d, file:%d, mask:%d\n", psys->totpart, activeParts, fileParts, readMask); // bad level call // XXX elbeemDebugOut(debugStrBuffer); @@ -4302,7 +4303,7 @@ static void system_step(ParticleSimulationData *sim, float cfra) dynamics_step(sim, cfra+dframe+t_frac - 1.f); psys->cfra = cfra+dframe+t_frac - 1.f; #if 0 - printf("%f,%f,%f,%f\n", cfra+dframe+t_frac - 1.f, t_frac, dt_frac, sim->courant_num); + printf("%f, %f, %f, %f\n", cfra+dframe+t_frac - 1.f, t_frac, dt_frac, sim->courant_num); #endif if (part->time_flag & PART_TIME_AUTOSF) dt_frac = update_timestep(psys, sim, t_frac); @@ -4589,7 +4590,7 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys) if (part->phystype == PART_PHYS_KEYED) { psys_count_keyed_targets(&sim); set_keyed_keys(&sim); - psys_update_path_cache(&sim,(int)cfra); + psys_update_path_cache(&sim, (int)cfra); } break; } diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 39293084dc0..1e80f1e6d1e 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -222,7 +222,7 @@ void BKE_ptcache_make_particle_key(ParticleKey *key, int index, void **data, flo /* no rotation info, so make something nice up */ if (data[BPHYS_DATA_ROTATION]==NULL) { - vec_to_quat( key->rot, key->vel, OB_NEGX, OB_POSZ); + vec_to_quat(key->rot, key->vel, OB_NEGX, OB_POSZ); } else { PTCACHE_DATA_TO(data, BPHYS_DATA_ROTATION, index, key->rot); @@ -366,7 +366,7 @@ static void ptcache_particle_interpolate(int index, void *psys_v, void **data, f /* determine rotation from velocity */ if (data[BPHYS_DATA_LOCATION] && !data[BPHYS_DATA_ROTATION]) { - vec_to_quat( keys[2].rot,keys[2].vel, OB_NEGX, OB_POSZ); + vec_to_quat(keys[2].rot, keys[2].vel, OB_NEGX, OB_POSZ); } if (cfra > pa->time) @@ -400,7 +400,7 @@ static int ptcache_particle_totwrite(void *psys_v, int cfra) if (cfra == 0) return psys->totpart; - for (p=0; p<psys->totpart; p++,pa++) + for (p=0; p<psys->totpart; p++, pa++) totwrite += (cfra >= pa->time - step && cfra <= pa->dietime + step); return totwrite; @@ -720,7 +720,7 @@ static int ptcache_dynamicpaint_read(PTCacheFile *pf, void *dp_v) /* version header */ ptcache_file_read(pf, version, 1, sizeof(char)*4); - if (strncmp(version, DPAINT_CACHE_VERSION,4)) {printf("Dynamic Paint: Invalid cache version: %s!\n",version); return 0;} + if (strncmp(version, DPAINT_CACHE_VERSION, 4)) {printf("Dynamic Paint: Invalid cache version: %s!\n", version); return 0;} if (surface->format != MOD_DPAINT_SURFACE_F_IMAGESEQ && surface->data) { unsigned int data_len; @@ -1260,7 +1260,7 @@ static int ptcache_file_compressed_write(PTCacheFile *pf, unsigned char *in, uns #ifdef WITH_LZMA if (mode == 2) { - r = LzmaCompress(out, &out_len, in, in_len,//assume sizeof(char)==1.... + r = LzmaCompress(out, &out_len, in, in_len, //assume sizeof(char)==1.... props, &sizeOfIt, 5, 1 << 24, 3, 0, 2, 32, 2); if (!(r == SZ_OK) || (out_len >= in_len)) diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index f1caa6ba272..2d3c18ff03b 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -236,7 +236,7 @@ Scene *copy_scene(Scene *sce, int type) } if (sce->ed) { - scen->ed= MEM_callocN( sizeof(Editing), "addseq"); + scen->ed= MEM_callocN(sizeof(Editing), "addseq"); scen->ed->seqbasep= &scen->ed->seqbase; seqbase_dupli_recursive(sce, scen, &scen->ed->seqbase, &sce->ed->seqbase, SEQ_DUPE_ALL); } @@ -415,7 +415,7 @@ Scene *add_scene(const char *name) sce->r.border.xmax = 1.0f; sce->r.border.ymax = 1.0f; - sce->toolsettings = MEM_callocN(sizeof(struct ToolSettings),"Tool Settings Struct"); + sce->toolsettings = MEM_callocN(sizeof(struct ToolSettings), "Tool Settings Struct"); sce->toolsettings->cornertype=1; sce->toolsettings->degr = 90; sce->toolsettings->step = 9; @@ -895,8 +895,6 @@ void scene_deselect_all(Scene *sce) void scene_select_base(Scene *sce, Base *selbase) { - scene_deselect_all(sce); - selbase->flag |= SELECT; selbase->object->flag= selbase->flag; @@ -1016,7 +1014,7 @@ static void scene_update_tagged_recursive(Main *bmain, Scene *scene, Scene *scen void scene_update_tagged(Main *bmain, Scene *scene) { /* keep this first */ - BLI_exec_cb(bmain, &scene->id, BLI_CB_EVT_SCENE_UPDATE_PRE); + BLI_callback_exec(bmain, &scene->id, BLI_CB_EVT_SCENE_UPDATE_PRE); /* flush recalc flags to dependencies */ DAG_ids_flush_tagged(bmain); @@ -1044,7 +1042,7 @@ void scene_update_tagged(Main *bmain, Scene *scene) BKE_ptcache_quick_cache_all(bmain, scene); /* notify editors and python about recalc */ - BLI_exec_cb(bmain, &scene->id, BLI_CB_EVT_SCENE_UPDATE_POST); + BLI_callback_exec(bmain, &scene->id, BLI_CB_EVT_SCENE_UPDATE_POST); DAG_ids_check_recalc(bmain, scene, FALSE); /* clear recalc flags */ @@ -1058,8 +1056,8 @@ void scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay) Scene *sce_iter; /* keep this first */ - BLI_exec_cb(bmain, &sce->id, BLI_CB_EVT_FRAME_CHANGE_PRE); - BLI_exec_cb(bmain, &sce->id, BLI_CB_EVT_SCENE_UPDATE_PRE); + BLI_callback_exec(bmain, &sce->id, BLI_CB_EVT_FRAME_CHANGE_PRE); + BLI_callback_exec(bmain, &sce->id, BLI_CB_EVT_SCENE_UPDATE_PRE); sound_set_cfra(sce->r.cfra); @@ -1093,8 +1091,8 @@ void scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay) scene_update_tagged_recursive(bmain, sce, sce); /* notify editors and python about recalc */ - BLI_exec_cb(bmain, &sce->id, BLI_CB_EVT_SCENE_UPDATE_POST); - BLI_exec_cb(bmain, &sce->id, BLI_CB_EVT_FRAME_CHANGE_POST); + BLI_callback_exec(bmain, &sce->id, BLI_CB_EVT_SCENE_UPDATE_POST); + BLI_callback_exec(bmain, &sce->id, BLI_CB_EVT_FRAME_CHANGE_POST); DAG_ids_check_recalc(bmain, sce, TRUE); diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c index af0c5eae9a8..f69495483ea 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -1,5 +1,4 @@ -/* - * +/* * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index d3eade834e6..5983beac4ef 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -294,7 +294,7 @@ static struct ImBuf * do_plugin_effect( * old plugins) do very bad stuff * with imbuf-internals */ - struct ImBuf * out = prepare_effect_imbufs(context,ibuf1, ibuf2, ibuf3); + struct ImBuf * out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); int x = context.rectx; int y = context.recty; @@ -548,7 +548,7 @@ static struct ImBuf * do_alphaover_effect( struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { - struct ImBuf * out = prepare_effect_imbufs(context,ibuf1, ibuf2, ibuf3); + struct ImBuf * out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); if (out->rect_float) { do_alphaover_effect_float( @@ -937,7 +937,7 @@ static float gammaCorrect(float c) float res = 0.0; i = floor(c * inv_color_step); - /* Clip to range [0,1]: outside, just do the complete calculation. */ + /* Clip to range [0, 1]: outside, just do the complete calculation. */ /* We may have some performance problems here. Stretching up the LUT */ /* may help solve that, by exchanging LUT size for the interpolation. */ /* Negative colors are explicitly handled. */ @@ -1121,7 +1121,7 @@ static struct ImBuf * do_gammacross_effect( struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { - struct ImBuf * out = prepare_effect_imbufs(context,ibuf1, ibuf2, ibuf3); + struct ImBuf * out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); build_gammatabs(); @@ -1240,7 +1240,7 @@ static struct ImBuf * do_add_effect(SeqRenderData context, struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { - struct ImBuf * out = prepare_effect_imbufs(context,ibuf1, ibuf2, ibuf3); + struct ImBuf * out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); if (out->rect_float) { do_add_effect_float( @@ -1357,7 +1357,7 @@ static struct ImBuf * do_sub_effect( struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { - struct ImBuf * out = prepare_effect_imbufs(context,ibuf1, ibuf2, ibuf3); + struct ImBuf * out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); if (out->rect_float) { do_sub_effect_float( @@ -1571,7 +1571,7 @@ static struct ImBuf * do_mul_effect( struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { - struct ImBuf * out = prepare_effect_imbufs(context,ibuf1, ibuf2, ibuf3); + struct ImBuf * out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); if (out->rect_float) { do_mul_effect_float( @@ -1612,7 +1612,7 @@ static void precalc_wipe_zone(WipeZone *wipezone, WipeVars *wipe, int xo, int yo } // This function calculates the blur band for the wipe effects -static float in_band(float width,float dist,int side,int dir) +static float in_band(float width, float dist, int side, int dir) { float alpha; @@ -1636,15 +1636,15 @@ static float in_band(float width,float dist,int side,int dir) static float check_zone(WipeZone *wipezone, int x, int y, Sequence *seq, float facf0) { - float posx, posy,hyp,hyp2,angle,hwidth,b1,b2,b3,pointdist; + float posx, posy, hyp, hyp2, angle, hwidth, b1, b2, b3, pointdist; /* some future stuff */ - // float hyp3,hyp4,b4,b5 - float temp1,temp2,temp3,temp4; //some placeholder variables + // float hyp3, hyp4, b4, b5 + float temp1, temp2, temp3, temp4; //some placeholder variables int xo = wipezone->xo; int yo = wipezone->yo; float halfx = xo*0.5f; float halfy = yo*0.5f; - float widthf,output=0; + float widthf, output=0; WipeVars *wipe = (WipeVars *)seq->effectdata; int width; @@ -1683,15 +1683,15 @@ static float check_zone(WipeZone *wipezone, int x, int y, if (wipe->forward) { if (b1 < b2) - output = in_band(width,hyp,1,1); + output = in_band(width, hyp, 1, 1); else - output = in_band(width,hyp,0,1); + output = in_band(width, hyp, 0, 1); } else { if (b1 < b2) - output = in_band(width,hyp,0,1); + output = in_band(width, hyp, 0, 1); else - output = in_band(width,hyp,1,1); + output = in_band(width, hyp, 1, 1); } break; @@ -1721,25 +1721,25 @@ static float check_zone(WipeZone *wipezone, int x, int y, hwidth = minf(hwidth, fabsf(b3-b1)/2.0f); if (b2 < b1 && b2 < b3 ) { - output = in_band(hwidth,hyp,0,1); + output = in_band(hwidth, hyp, 0, 1); } else if (b2 > b1 && b2 > b3 ) { - output = in_band(hwidth,hyp2,0,1); + output = in_band(hwidth, hyp2, 0, 1); } else { if ( hyp < hwidth && hyp2 > hwidth ) - output = in_band(hwidth,hyp,1,1); + output = in_band(hwidth, hyp, 1, 1); else if ( hyp > hwidth && hyp2 < hwidth ) - output = in_band(hwidth,hyp2,1,1); + output = in_band(hwidth, hyp2, 1, 1); else - output = in_band(hwidth,hyp2,1,1) * in_band(hwidth,hyp,1,1); + output = in_band(hwidth, hyp2, 1, 1) * in_band(hwidth, hyp, 1, 1); } if (!wipe->forward)output = 1-output; break; case DO_CLOCK_WIPE: /* * temp1: angle of effect center in rads - * temp2: angle of line through (halfx,halfy) and (x,y) in rads + * temp2: angle of line through (halfx, halfy) and (x, y) in rads * temp3: angle of low side of blur * temp4: angle of high side of blur */ @@ -1801,19 +1801,19 @@ static float check_zone(WipeZone *wipezone, int x, int y, if (b2 < b1 && b2 < b3 ) { if (hwidth < pointdist) - output = in_band(wipezone,hwidth,hyp,facf0,0,1); + output = in_band(wipezone, hwidth, hyp, facf0, 0, 1); } else if (b2 > b1 && b2 > b3 ) { if (hwidth < pointdist) - output = in_band(wipezone,hwidth,hyp2,facf0,0,1); + output = in_band(wipezone, hwidth, hyp2, facf0, 0, 1); } else { if ( hyp < hwidth && hyp2 > hwidth ) - output = in_band(wipezone,hwidth,hyp,facf0,1,1); + output = in_band(wipezone, hwidth, hyp, facf0, 1, 1); else if ( hyp > hwidth && hyp2 < hwidth ) - output = in_band(wipezone,hwidth,hyp2,facf0,1,1); + output = in_band(wipezone, hwidth, hyp2, facf0, 1, 1); else - output = in_band(wipezone,hwidth,hyp2,facf0,1,1) * in_band(wipezone,hwidth,hyp,facf0,1,1); + output = in_band(wipezone, hwidth, hyp2, facf0, 1, 1) * in_band(wipezone, hwidth, hyp, facf0, 1, 1); } if (invert)facf0 = 1-facf0; @@ -1827,19 +1827,19 @@ static float check_zone(WipeZone *wipezone, int x, int y, if (b2 < b1 && b2 < b3 ) { if (hwidth < pointdist) - output *= in_band(wipezone,hwidth,hyp,facf0,0,1); + output *= in_band(wipezone, hwidth, hyp, facf0, 0, 1); } else if (b2 > b1 && b2 > b3 ) { if (hwidth < pointdist) - output *= in_band(wipezone,hwidth,hyp2,facf0,0,1); + output *= in_band(wipezone, hwidth, hyp2, facf0, 0, 1); } else { if ( hyp < hwidth && hyp2 > hwidth ) - output *= in_band(wipezone,hwidth,hyp,facf0,1,1); + output *= in_band(wipezone, hwidth, hyp, facf0, 1, 1); else if ( hyp > hwidth && hyp2 < hwidth ) - output *= in_band(wipezone,hwidth,hyp2,facf0,1,1); + output *= in_band(wipezone, hwidth, hyp2, facf0, 1, 1); else - output *= in_band(wipezone,hwidth,hyp2,facf0,1,1) * in_band(wipezone,hwidth,hyp,facf0,1,1); + output *= in_band(wipezone, hwidth, hyp2, facf0, 1, 1) * in_band(wipezone, hwidth, hyp, facf0, 1, 1); } break; @@ -1857,8 +1857,8 @@ static float check_zone(WipeZone *wipezone, int x, int y, pointdist = sqrt(temp1*temp1 + temp1*temp1); temp2 = sqrt((halfx-x)*(halfx-x) + (halfy-y)*(halfy-y)); - if (temp2 > pointdist) output = in_band(hwidth,fabs(temp2-pointdist),0,1); - else output = in_band(hwidth,fabs(temp2-pointdist),1,1); + if (temp2 > pointdist) output = in_band(hwidth, fabs(temp2-pointdist), 0, 1); + else output = in_band(hwidth, fabs(temp2-pointdist), 1, 1); if (!wipe->forward) output = 1-output; @@ -1911,7 +1911,7 @@ static void do_wipe_effect_byte(Sequence *seq, float facf0, float UNUSED(facf1), yo = y; for (y=0;y<yo;y++) { for (x=0;x<xo;x++) { - float check = check_zone(&wipezone,x,y,seq,facf0); + float check = check_zone(&wipezone, x, y, seq, facf0); if (check) { if (rt1) { rt[0] = (int)(rt1[0]*check)+ (int)(rt2[0]*(1-check)); @@ -1972,7 +1972,7 @@ static void do_wipe_effect_float(Sequence *seq, float facf0, float UNUSED(facf1) yo = y; for (y=0;y<yo;y++) { for (x=0;x<xo;x++) { - float check = check_zone(&wipezone,x,y,seq,facf0); + float check = check_zone(&wipezone, x, y, seq, facf0); if (check) { if (rt1) { rt[0] = rt1[0]*check+ rt2[0]*(1-check); @@ -2019,7 +2019,7 @@ static struct ImBuf * do_wipe_effect( struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { - struct ImBuf * out = prepare_effect_imbufs(context,ibuf1, ibuf2, ibuf3); + struct ImBuf * out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); if (out->rect_float) { do_wipe_effect_float(seq, @@ -2083,7 +2083,7 @@ static void transform_image(int x, int y, struct ImBuf *ibuf1, struct ImBuf *out { int xo, yo, xi, yi; float xt, yt, xr, yr; - float s,c; + float s, c; xo = x; yo = y; @@ -2114,13 +2114,13 @@ static void transform_image(int x, int y, struct ImBuf *ibuf1, struct ImBuf *out //interpolate switch (interpolation) { case 0: - neareast_interpolation(ibuf1,out, xt,yt,xi,yi); + neareast_interpolation(ibuf1, out, xt, yt, xi, yi); break; case 1: - bilinear_interpolation(ibuf1,out, xt,yt,xi,yi); + bilinear_interpolation(ibuf1, out, xt, yt, xi, yi); break; case 2: - bicubic_interpolation(ibuf1,out, xt,yt,xi,yi); + bicubic_interpolation(ibuf1, out, xt, yt, xi, yi); break; } } @@ -2128,7 +2128,7 @@ static void transform_image(int x, int y, struct ImBuf *ibuf1, struct ImBuf *out } static void do_transform(Scene *scene, Sequence *seq, float UNUSED(facf0), int x, int y, - struct ImBuf *ibuf1,struct ImBuf *out) + struct ImBuf *ibuf1, struct ImBuf *out) { TransformVars *transform = (TransformVars *)seq->effectdata; float scale_x, scale_y, translate_x, translate_y, rotate_radians; @@ -2157,17 +2157,17 @@ static void do_transform(Scene *scene, Sequence *seq, float UNUSED(facf0), int x // Rotate rotate_radians = DEG2RADF(transform->rotIni); - transform_image(x,y, ibuf1, out, scale_x, scale_y, translate_x, translate_y, rotate_radians, transform->interpolation); + transform_image(x, y, ibuf1, out, scale_x, scale_y, translate_x, translate_y, rotate_radians, transform->interpolation); } static struct ImBuf * do_transform_effect( - SeqRenderData context, Sequence *seq,float UNUSED(cfra), + SeqRenderData context, Sequence *seq, float UNUSED(cfra), float facf0, float UNUSED(facf1), struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { - struct ImBuf * out = prepare_effect_imbufs(context,ibuf1, ibuf2, ibuf3); + struct ImBuf * out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); do_transform(context.scene, seq, facf0, context.rectx, context.recty, ibuf1, out); @@ -2180,9 +2180,9 @@ static struct ImBuf * do_transform_effect( * GLOW * ********************************************************************** */ -static void RVBlurBitmap2_byte ( unsigned char* map, int width,int height, - float blur, - int quality) +static void RVBlurBitmap2_byte(unsigned char* map, int width, int height, + float blur, + int quality) /* MUUUCCH better than the previous blur. */ /* We do the blurring in two passes which is a whole lot faster. */ /* I changed the math arount to implement an actual Gaussian */ @@ -2192,9 +2192,9 @@ static void RVBlurBitmap2_byte ( unsigned char* map, int width,int height, /* a small bitmap. Avoid avoid avoid. */ /*=============================== */ { - unsigned char* temp=NULL,*swap; + unsigned char* temp=NULL, *swap; float *filter=NULL; - int x,y,i,fx,fy; + int x, y, i, fx, fy; int index, ix, halfWidth; float fval, k, curColor[3], curColor2[3], weight=0; @@ -2203,7 +2203,7 @@ static void RVBlurBitmap2_byte ( unsigned char* map, int width,int height, return; /* Allocate memory for the tempmap and the blur filter matrix */ - temp= MEM_mallocN( (width*height*4), "blurbitmaptemp"); + temp= MEM_mallocN((width*height*4), "blurbitmaptemp"); if (!temp) return; @@ -2349,7 +2349,7 @@ static void RVBlurBitmap2_byte ( unsigned char* map, int width,int height, MEM_freeN (temp); } -static void RVBlurBitmap2_float ( float* map, int width,int height, +static void RVBlurBitmap2_float ( float* map, int width, int height, float blur, int quality) /* MUUUCCH better than the previous blur. */ @@ -2361,9 +2361,9 @@ static void RVBlurBitmap2_float ( float* map, int width,int height, /* a small bitmap. Avoid avoid avoid. */ /*=============================== */ { - float* temp=NULL,*swap; + float* temp=NULL, *swap; float *filter=NULL; - int x,y,i,fx,fy; + int x, y, i, fx, fy; int index, ix, halfWidth; float fval, k, curColor[3], curColor2[3], weight=0; @@ -2372,7 +2372,7 @@ static void RVBlurBitmap2_float ( float* map, int width,int height, return; /* Allocate memory for the tempmap and the blur filter matrix */ - temp= MEM_mallocN( (width*height*4*sizeof(float)), "blurbitmaptemp"); + temp= MEM_mallocN((width*height*4*sizeof(float)), "blurbitmaptemp"); if (!temp) return; @@ -2526,15 +2526,15 @@ static void RVBlurBitmap2_float ( float* map, int width,int height, /*=============================== */ static void RVAddBitmaps_byte (unsigned char* a, unsigned char* b, unsigned char* c, int width, int height) { - int x,y,index; + int x, y, index; for (y=0;y<height;y++) { for (x=0;x<width;x++) { index=(x+y*width)*4; - c[index+GlowR]=MIN2(255,a[index+GlowR]+b[index+GlowR]); - c[index+GlowG]=MIN2(255,a[index+GlowG]+b[index+GlowG]); - c[index+GlowB]=MIN2(255,a[index+GlowB]+b[index+GlowB]); - c[index+GlowA]=MIN2(255,a[index+GlowA]+b[index+GlowA]); + c[index+GlowR]=MIN2(255, a[index+GlowR]+b[index+GlowR]); + c[index+GlowG]=MIN2(255, a[index+GlowG]+b[index+GlowG]); + c[index+GlowB]=MIN2(255, a[index+GlowB]+b[index+GlowB]); + c[index+GlowA]=MIN2(255, a[index+GlowA]+b[index+GlowA]); } } } @@ -2542,7 +2542,7 @@ static void RVAddBitmaps_byte (unsigned char* a, unsigned char* b, unsigned char static void RVAddBitmaps_float (float* a, float* b, float* c, int width, int height) { - int x,y,index; + int x, y, index; for (y=0;y<height;y++) { for (x=0;x<width;x++) { @@ -2561,7 +2561,7 @@ static void RVIsolateHighlights_byte (unsigned char* in, unsigned char* out, int width, int height, int threshold, float boost, float clamp) { - int x,y,index; + int x, y, index; int intensity; @@ -2591,7 +2591,7 @@ static void RVIsolateHighlights_float (float* in, float* out, int width, int height, float threshold, float boost, float clamp) { - int x,y,index; + int x, y, index; float intensity; @@ -2658,10 +2658,10 @@ static void do_glow_effect_byte(Sequence *seq, int render_size, float facf0, flo unsigned char *inbuf=(unsigned char *)rect1; GlowVars *glow = (GlowVars *)seq->effectdata; - RVIsolateHighlights_byte(inbuf, outbuf , x, y, glow->fMini*765, glow->fBoost * facf0, glow->fClamp); - RVBlurBitmap2_byte (outbuf, x, y, glow->dDist * (render_size / 100.0f),glow->dQuality); + RVIsolateHighlights_byte(inbuf, outbuf, x, y, glow->fMini*765, glow->fBoost * facf0, glow->fClamp); + RVBlurBitmap2_byte (outbuf, x, y, glow->dDist * (render_size / 100.0f), glow->dQuality); if (!glow->bNoComp) - RVAddBitmaps_byte (inbuf , outbuf, outbuf, x, y); + RVAddBitmaps_byte (inbuf, outbuf, outbuf, x, y); } static void do_glow_effect_float(Sequence *seq, int render_size, float facf0, float UNUSED(facf1), @@ -2672,10 +2672,10 @@ static void do_glow_effect_float(Sequence *seq, int render_size, float facf0, fl float *inbuf = rect1; GlowVars *glow = (GlowVars *)seq->effectdata; - RVIsolateHighlights_float(inbuf, outbuf , x, y, glow->fMini*3.0f, glow->fBoost * facf0, glow->fClamp); - RVBlurBitmap2_float (outbuf, x, y, glow->dDist * (render_size / 100.0f),glow->dQuality); + RVIsolateHighlights_float(inbuf, outbuf, x, y, glow->fMini*3.0f, glow->fBoost * facf0, glow->fClamp); + RVBlurBitmap2_float (outbuf, x, y, glow->dDist * (render_size / 100.0f), glow->dQuality); if (!glow->bNoComp) - RVAddBitmaps_float (inbuf , outbuf, outbuf, x, y); + RVAddBitmaps_float (inbuf, outbuf, outbuf, x, y); } static struct ImBuf * do_glow_effect( @@ -2684,7 +2684,7 @@ static struct ImBuf * do_glow_effect( struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { - struct ImBuf * out = prepare_effect_imbufs(context,ibuf1, ibuf2, ibuf3); + struct ImBuf * out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); int render_size = 100*context.rectx/context.scene->r.xsch; @@ -2749,7 +2749,7 @@ static struct ImBuf * do_solid_color( struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { - struct ImBuf * out = prepare_effect_imbufs(context,ibuf1, ibuf2, ibuf3); + struct ImBuf * out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); SolidColorVars *cv = (SolidColorVars *)seq->effectdata; @@ -3234,7 +3234,7 @@ static struct ImBuf * do_overdrop_effect(SeqRenderData context, struct ImBuf * ibuf2, struct ImBuf * ibuf3) { - struct ImBuf * out = prepare_effect_imbufs(context,ibuf1, ibuf2, ibuf3); + struct ImBuf * out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); int x = context.rectx; int y = context.recty; diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 9291cb90dff..395214b1609 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -259,7 +259,8 @@ void seq_free_editing(Scene *scene) if (ed == NULL) return; - SEQ_BEGIN (ed, seq) { + SEQ_BEGIN (ed, seq) + { seq_free_sequence(scene, seq); } SEQ_END diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index e201209ec3f..d6fea87397d 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -121,7 +121,7 @@ void space_transform_invert(const SpaceTransform *data, float *co) static void space_transform_apply_normal(const SpaceTransform *data, float *no) { - mul_mat3_m4_v3( ((SpaceTransform*)data)->local2target, no); + mul_mat3_m4_v3(((SpaceTransform *)data)->local2target, no); normalize_v3(no); // TODO: could we just determine de scale value from the matrix? } @@ -218,19 +218,19 @@ int normal_projection_project_vertex(char options, const float *vert, const floa BVHTreeRayHit hit_tmp; //Copy from hit (we need to convert hit rays from one space coordinates to the other - memcpy( &hit_tmp, hit, sizeof(hit_tmp) ); + memcpy(&hit_tmp, hit, sizeof(hit_tmp)); //Apply space transform (TODO readjust dist) if (transf) { - copy_v3_v3( tmp_co, vert ); - space_transform_apply( transf, tmp_co ); + copy_v3_v3(tmp_co, vert); + space_transform_apply(transf, tmp_co); co = tmp_co; - copy_v3_v3( tmp_no, dir ); - space_transform_apply_normal( transf, tmp_no ); + copy_v3_v3(tmp_no, dir); + space_transform_apply_normal(transf, tmp_no); no = tmp_no; - hit_tmp.dist *= mat4_to_scale( ((SpaceTransform*)transf)->local2target ); + hit_tmp.dist *= mat4_to_scale(((SpaceTransform*)transf)->local2target); } else { co = vert; @@ -263,7 +263,7 @@ int normal_projection_project_vertex(char options, const float *vert, const floa hit_tmp.dist = len_v3v3((float *)vert, hit_tmp.co); } - memcpy(hit, &hit_tmp, sizeof(hit_tmp) ); + memcpy(hit, &hit_tmp, sizeof(hit_tmp)); return TRUE; } return FALSE; @@ -315,7 +315,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc) auxMesh = object_get_derived_final(calc->smd->auxTarget); if (!auxMesh) return; - space_transform_setup( &local2aux, calc->ob, calc->smd->auxTarget); + space_transform_setup(&local2aux, calc->ob, calc->smd->auxTarget); } //After sucessufuly build the trees, start projection vertexs @@ -456,7 +456,7 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc) if (dist > FLT_EPSILON) interp_v3_v3v3(tmp_co, tmp_co, nearest.co, (dist - calc->keepDist)/dist); //linear interpolation else - copy_v3_v3( tmp_co, nearest.co ); + copy_v3_v3(tmp_co, nearest.co); } //Convert the coordinates back to mesh coordinates diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index f3939a2ebfc..f98b6366e97 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -120,7 +120,7 @@ static void tend ( void ) gettimeofday ( &_tend,&tz ); } -static double tval() +static double tval( void ) { double t1, t2; t1 = ( double ) _tstart.tv_sec*1000 + ( double ) _tstart.tv_usec/ ( 1000 ); @@ -481,7 +481,7 @@ static void fill_scs_points(Object *ob, DerivedMesh *dm, SmokeCollSettings *scs) } -static void fill_scs_points_anim(Object *ob, DerivedMesh *dm, SmokeCollSettings *scs) +static void fill_scs_points_anim(Object *UNUSED(ob), DerivedMesh *dm, SmokeCollSettings *scs) { MVert *mvert = dm->getVertArray(dm); MFace *mface = dm->getTessFaceArray(dm); @@ -899,7 +899,7 @@ void smokeModifier_reset(struct SmokeModifierData *smd) } } -void smokeModifier_free (SmokeModifierData *smd) +void smokeModifier_free(SmokeModifierData *smd) { if(smd) { @@ -1066,7 +1066,7 @@ static int get_lamp(Scene *scene, float *light) return found_lamp; } -static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd) +static void smoke_calc_domain(Scene *UNUSED(scene), Object *UNUSED(ob), SmokeModifierData *UNUSED(smd)) { #if 0 SmokeDomainSettings *sds = smd->domain; @@ -1546,7 +1546,7 @@ static void update_flowsfluids(Scene *scene, Object *ob, SmokeDomainSettings *sd MEM_freeN(flowobjs); } -static void update_effectors(Scene *scene, Object *ob, SmokeDomainSettings *sds, float dt) +static void update_effectors(Scene *scene, Object *ob, SmokeDomainSettings *sds, float UNUSED(dt)) { ListBase *effectors = pdInitEffectors(scene, ob, NULL, sds->effector_weights); @@ -1568,7 +1568,7 @@ static void update_effectors(Scene *scene, Object *ob, SmokeDomainSettings *sds, for(z = 0; z < sds->res[2]; z++) { EffectedPoint epoint; - float voxelCenter[3] = {0,0,0} , vel[3] = {0,0,0} , retvel[3] = {0,0,0}; + float voxelCenter[3] = {0,0,0}, vel[3] = {0,0,0}, retvel[3] = {0,0,0}; unsigned int index = smoke_get_index(x, sds->res[0], y, sds->res[1], z); if((density[index] < FLT_EPSILON) || obstacle[index]) diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 5d8a4955e58..690b6c83870 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -90,18 +90,18 @@ static int (*SB_localInterruptCallBack)(void) = NULL; /* ********** soft body engine ******* */ -typedef enum {SB_EDGE=1,SB_BEND=2,SB_STIFFQUAD=3,SB_HANDLE=4} type_spring; +typedef enum {SB_EDGE=1, SB_BEND=2, SB_STIFFQUAD=3, SB_HANDLE=4} type_spring; typedef struct BodySpring { int v1, v2; - float len,cf,load; + float len, cf, load; float ext_force[3]; /* edges colliding and sailing */ type_spring springtype; short flag; } BodySpring; typedef struct BodyFace { - int v1, v2, v3 ,v4; + int v1, v2, v3, v4; float ext_force[3]; /* faces colliding */ short flag; } BodyFace; @@ -124,7 +124,7 @@ typedef struct SBScratch { short flag; BodyFace *bodyface; int totface; - float aabbmin[3],aabbmax[3]; + float aabbmin[3], aabbmax[3]; ReferenceState Ref; } SBScratch; @@ -150,8 +150,8 @@ typedef struct SB_thread_context { #define SOFTGOALSNAP 0.999f /* if bp-> goal is above make it a *forced follow original* and skip all ODE stuff for this bp - removes *unnecessary* stiffnes from ODE system -*/ + * removes *unnecessary* stiffnes from ODE system + */ #define HEUNWARNLIMIT 1 /* 500 would be fine i think for detecting severe *stiff* stuff */ @@ -179,16 +179,16 @@ static void Vec3PlusStVec(float *v, float s, float *v1); static float sb_grav_force_scale(Object *UNUSED(ob)) /* since unit of g is [m/sec^2] and F = mass * g we rescale unit mass of node to 1 gramm - put it to a function here, so we can add user options later without touching simulation code -*/ + * put it to a function here, so we can add user options later without touching simulation code + */ { return (0.001f); } static float sb_fric_force_scale(Object *UNUSED(ob)) /* rescaling unit of drag [1 / sec] to somehow reasonable - put it to a function here, so we can add user options later without touching simulation code -*/ + * put it to a function here, so we can add user options later without touching simulation code + */ { return (0.01f); } @@ -216,15 +216,15 @@ static float sb_time_scale(Object *ob) /* helper functions for everything is animatable jow_go_for2_5 +++++++*/ /* introducing them here, because i know: steps in properties ( at frame timing ) - will cause unwanted responses of the softbody system (which does inter frame calculations ) - so first 'cure' would be: interpolate linear in time .. - Q: why do i write this? - A: because it happend once, that some eger coder 'streamlined' code to fail. - We DO linear interpolation for goals .. and i think we should do on animated properties as well -*/ + * will cause unwanted responses of the softbody system (which does inter frame calculations ) + * so first 'cure' would be: interpolate linear in time .. + * Q: why do i write this? + * A: because it happend once, that some eger coder 'streamlined' code to fail. + * We DO linear interpolation for goals .. and i think we should do on animated properties as well + */ -/* animate sb->maxgoal,sb->mingoal */ -static float _final_goal(Object *ob,BodyPoint *bp)/*jow_go_for2_5 */ +/* animate sb->maxgoal, sb->mingoal */ +static float _final_goal(Object *ob, BodyPoint *bp)/*jow_go_for2_5 */ { float f = -1999.99f; if (ob) { @@ -237,11 +237,11 @@ static float _final_goal(Object *ob,BodyPoint *bp)/*jow_go_for2_5 */ return (f); } } - printf("_final_goal failed! sb or bp ==NULL\n" ); + printf("_final_goal failed! sb or bp ==NULL\n"); return f; /*using crude but spot able values some times helps debuggin */ } -static float _final_mass(Object *ob,BodyPoint *bp) +static float _final_mass(Object *ob, BodyPoint *bp) { if (ob) { SoftBody *sb= ob->soft; /* is supposed to be there */ @@ -249,7 +249,7 @@ static float _final_mass(Object *ob,BodyPoint *bp) return(bp->mass*sb->nodemass); } } - printf("_final_mass failed! sb or bp ==NULL\n" ); + printf("_final_mass failed! sb or bp ==NULL\n"); return 1.0f; } /* helper functions for everything is animateble jow_go_for2_5 ------*/ @@ -259,7 +259,7 @@ static float _final_mass(Object *ob,BodyPoint *bp) /******************** for each target object/face the axis aligned bounding box (AABB) is stored faces parallel to global axes -so only simple "value" in [min,max] ckecks are used +so only simple "value" in [min, max] ckecks are used float operations still */ @@ -295,7 +295,7 @@ static ccd_Mesh *ccd_mesh_make(Object *ob) ccd_Mesh *pccd_M = NULL; ccdf_minmax *mima = NULL; MFace *mface=NULL; - float v[3],hull; + float v[3], hull; int i; cmd =(CollisionModifierData *)modifiers_findByType(ob, eModifierType_Collision); @@ -304,7 +304,7 @@ static ccd_Mesh *ccd_mesh_make(Object *ob) if (!cmd) return NULL; if (!cmd->numverts || !cmd->numfaces) return NULL; - pccd_M = MEM_mallocN(sizeof(ccd_Mesh),"ccd_Mesh"); + pccd_M = MEM_mallocN(sizeof(ccd_Mesh), "ccd_Mesh"); pccd_M->totvert = cmd->numverts; pccd_M->totface = cmd->numfaces; pccd_M->savety = CCD_SAVETY; @@ -314,7 +314,7 @@ static ccd_Mesh *ccd_mesh_make(Object *ob) /* blow it up with forcefield ranges */ - hull = MAX2(ob->pd->pdef_sbift,ob->pd->pdef_sboft); + hull = MAX2(ob->pd->pdef_sbift, ob->pd->pdef_sboft); /* alloc and copy verts*/ pccd_M->mvert = MEM_dupallocN(cmd->xnew); @@ -322,21 +322,21 @@ static ccd_Mesh *ccd_mesh_make(Object *ob) /* determine the ortho BB */ for (i=0; i < pccd_M->totvert; i++) { /* evaluate limits */ - copy_v3_v3(v,pccd_M->mvert[i].co); - pccd_M->bbmin[0] = MIN2(pccd_M->bbmin[0],v[0]-hull); - pccd_M->bbmin[1] = MIN2(pccd_M->bbmin[1],v[1]-hull); - pccd_M->bbmin[2] = MIN2(pccd_M->bbmin[2],v[2]-hull); + copy_v3_v3(v, pccd_M->mvert[i].co); + pccd_M->bbmin[0] = MIN2(pccd_M->bbmin[0], v[0]-hull); + pccd_M->bbmin[1] = MIN2(pccd_M->bbmin[1], v[1]-hull); + pccd_M->bbmin[2] = MIN2(pccd_M->bbmin[2], v[2]-hull); - pccd_M->bbmax[0] = MAX2(pccd_M->bbmax[0],v[0]+hull); - pccd_M->bbmax[1] = MAX2(pccd_M->bbmax[1],v[1]+hull); - pccd_M->bbmax[2] = MAX2(pccd_M->bbmax[2],v[2]+hull); + pccd_M->bbmax[0] = MAX2(pccd_M->bbmax[0], v[0]+hull); + pccd_M->bbmax[1] = MAX2(pccd_M->bbmax[1], v[1]+hull); + pccd_M->bbmax[2] = MAX2(pccd_M->bbmax[2], v[2]+hull); } /* alloc and copy faces*/ pccd_M->mface = MEM_dupallocN(cmd->mfaces); /* OBBs for idea1 */ - pccd_M->mima = MEM_mallocN(sizeof(ccdf_minmax)*pccd_M->totface,"ccd_Mesh_Faces_mima"); + pccd_M->mima = MEM_mallocN(sizeof(ccdf_minmax)*pccd_M->totface, "ccd_Mesh_Faces_mima"); mima = pccd_M->mima; mface = pccd_M->mface; @@ -346,38 +346,38 @@ static ccd_Mesh *ccd_mesh_make(Object *ob) mima->minx=mima->miny=mima->minz=1e30f; mima->maxx=mima->maxy=mima->maxz=-1e30f; - copy_v3_v3(v,pccd_M->mvert[mface->v1].co); - mima->minx = MIN2(mima->minx,v[0]-hull); - mima->miny = MIN2(mima->miny,v[1]-hull); - mima->minz = MIN2(mima->minz,v[2]-hull); - mima->maxx = MAX2(mima->maxx,v[0]+hull); - mima->maxy = MAX2(mima->maxy,v[1]+hull); - mima->maxz = MAX2(mima->maxz,v[2]+hull); - - copy_v3_v3(v,pccd_M->mvert[mface->v2].co); - mima->minx = MIN2(mima->minx,v[0]-hull); - mima->miny = MIN2(mima->miny,v[1]-hull); - mima->minz = MIN2(mima->minz,v[2]-hull); - mima->maxx = MAX2(mima->maxx,v[0]+hull); - mima->maxy = MAX2(mima->maxy,v[1]+hull); - mima->maxz = MAX2(mima->maxz,v[2]+hull); - - copy_v3_v3(v,pccd_M->mvert[mface->v3].co); - mima->minx = MIN2(mima->minx,v[0]-hull); - mima->miny = MIN2(mima->miny,v[1]-hull); - mima->minz = MIN2(mima->minz,v[2]-hull); - mima->maxx = MAX2(mima->maxx,v[0]+hull); - mima->maxy = MAX2(mima->maxy,v[1]+hull); - mima->maxz = MAX2(mima->maxz,v[2]+hull); + copy_v3_v3(v, pccd_M->mvert[mface->v1].co); + mima->minx = MIN2(mima->minx, v[0]-hull); + mima->miny = MIN2(mima->miny, v[1]-hull); + mima->minz = MIN2(mima->minz, v[2]-hull); + mima->maxx = MAX2(mima->maxx, v[0]+hull); + mima->maxy = MAX2(mima->maxy, v[1]+hull); + mima->maxz = MAX2(mima->maxz, v[2]+hull); + + copy_v3_v3(v, pccd_M->mvert[mface->v2].co); + mima->minx = MIN2(mima->minx, v[0]-hull); + mima->miny = MIN2(mima->miny, v[1]-hull); + mima->minz = MIN2(mima->minz, v[2]-hull); + mima->maxx = MAX2(mima->maxx, v[0]+hull); + mima->maxy = MAX2(mima->maxy, v[1]+hull); + mima->maxz = MAX2(mima->maxz, v[2]+hull); + + copy_v3_v3(v, pccd_M->mvert[mface->v3].co); + mima->minx = MIN2(mima->minx, v[0]-hull); + mima->miny = MIN2(mima->miny, v[1]-hull); + mima->minz = MIN2(mima->minz, v[2]-hull); + mima->maxx = MAX2(mima->maxx, v[0]+hull); + mima->maxy = MAX2(mima->maxy, v[1]+hull); + mima->maxz = MAX2(mima->maxz, v[2]+hull); if (mface->v4) { - copy_v3_v3(v,pccd_M->mvert[mface->v4].co); - mima->minx = MIN2(mima->minx,v[0]-hull); - mima->miny = MIN2(mima->miny,v[1]-hull); - mima->minz = MIN2(mima->minz,v[2]-hull); - mima->maxx = MAX2(mima->maxx,v[0]+hull); - mima->maxy = MAX2(mima->maxy,v[1]+hull); - mima->maxz = MAX2(mima->maxz,v[2]+hull); + copy_v3_v3(v, pccd_M->mvert[mface->v4].co); + mima->minx = MIN2(mima->minx, v[0]-hull); + mima->miny = MIN2(mima->miny, v[1]-hull); + mima->minz = MIN2(mima->minz, v[2]-hull); + mima->maxx = MAX2(mima->maxx, v[0]+hull); + mima->maxy = MAX2(mima->maxy, v[1]+hull); + mima->maxz = MAX2(mima->maxz, v[2]+hull); } @@ -387,12 +387,12 @@ static ccd_Mesh *ccd_mesh_make(Object *ob) } return pccd_M; } -static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M) +static void ccd_mesh_update(Object *ob, ccd_Mesh *pccd_M) { CollisionModifierData *cmd; ccdf_minmax *mima = NULL; MFace *mface=NULL; - float v[3],hull; + float v[3], hull; int i; cmd =(CollisionModifierData *)modifiers_findByType(ob, eModifierType_Collision); @@ -412,7 +412,7 @@ static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M) /* blow it up with forcefield ranges */ - hull = MAX2(ob->pd->pdef_sbift,ob->pd->pdef_sboft); + hull = MAX2(ob->pd->pdef_sbift, ob->pd->pdef_sboft); /* rotate current to previous */ if (pccd_M->mprevvert) MEM_freeN(pccd_M->mprevvert); @@ -423,24 +423,24 @@ static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M) /* determine the ortho BB */ for (i=0; i < pccd_M->totvert; i++) { /* evaluate limits */ - copy_v3_v3(v,pccd_M->mvert[i].co); - pccd_M->bbmin[0] = MIN2(pccd_M->bbmin[0],v[0]-hull); - pccd_M->bbmin[1] = MIN2(pccd_M->bbmin[1],v[1]-hull); - pccd_M->bbmin[2] = MIN2(pccd_M->bbmin[2],v[2]-hull); + copy_v3_v3(v, pccd_M->mvert[i].co); + pccd_M->bbmin[0] = MIN2(pccd_M->bbmin[0], v[0]-hull); + pccd_M->bbmin[1] = MIN2(pccd_M->bbmin[1], v[1]-hull); + pccd_M->bbmin[2] = MIN2(pccd_M->bbmin[2], v[2]-hull); - pccd_M->bbmax[0] = MAX2(pccd_M->bbmax[0],v[0]+hull); - pccd_M->bbmax[1] = MAX2(pccd_M->bbmax[1],v[1]+hull); - pccd_M->bbmax[2] = MAX2(pccd_M->bbmax[2],v[2]+hull); + pccd_M->bbmax[0] = MAX2(pccd_M->bbmax[0], v[0]+hull); + pccd_M->bbmax[1] = MAX2(pccd_M->bbmax[1], v[1]+hull); + pccd_M->bbmax[2] = MAX2(pccd_M->bbmax[2], v[2]+hull); /* evaluate limits */ - copy_v3_v3(v,pccd_M->mprevvert[i].co); - pccd_M->bbmin[0] = MIN2(pccd_M->bbmin[0],v[0]-hull); - pccd_M->bbmin[1] = MIN2(pccd_M->bbmin[1],v[1]-hull); - pccd_M->bbmin[2] = MIN2(pccd_M->bbmin[2],v[2]-hull); + copy_v3_v3(v, pccd_M->mprevvert[i].co); + pccd_M->bbmin[0] = MIN2(pccd_M->bbmin[0], v[0]-hull); + pccd_M->bbmin[1] = MIN2(pccd_M->bbmin[1], v[1]-hull); + pccd_M->bbmin[2] = MIN2(pccd_M->bbmin[2], v[2]-hull); - pccd_M->bbmax[0] = MAX2(pccd_M->bbmax[0],v[0]+hull); - pccd_M->bbmax[1] = MAX2(pccd_M->bbmax[1],v[1]+hull); - pccd_M->bbmax[2] = MAX2(pccd_M->bbmax[2],v[2]+hull); + pccd_M->bbmax[0] = MAX2(pccd_M->bbmax[0], v[0]+hull); + pccd_M->bbmax[1] = MAX2(pccd_M->bbmax[1], v[1]+hull); + pccd_M->bbmax[2] = MAX2(pccd_M->bbmax[2], v[2]+hull); } @@ -453,73 +453,73 @@ static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M) mima->minx=mima->miny=mima->minz=1e30f; mima->maxx=mima->maxy=mima->maxz=-1e30f; - copy_v3_v3(v,pccd_M->mvert[mface->v1].co); - mima->minx = MIN2(mima->minx,v[0]-hull); - mima->miny = MIN2(mima->miny,v[1]-hull); - mima->minz = MIN2(mima->minz,v[2]-hull); - mima->maxx = MAX2(mima->maxx,v[0]+hull); - mima->maxy = MAX2(mima->maxy,v[1]+hull); - mima->maxz = MAX2(mima->maxz,v[2]+hull); - - copy_v3_v3(v,pccd_M->mvert[mface->v2].co); - mima->minx = MIN2(mima->minx,v[0]-hull); - mima->miny = MIN2(mima->miny,v[1]-hull); - mima->minz = MIN2(mima->minz,v[2]-hull); - mima->maxx = MAX2(mima->maxx,v[0]+hull); - mima->maxy = MAX2(mima->maxy,v[1]+hull); - mima->maxz = MAX2(mima->maxz,v[2]+hull); - - copy_v3_v3(v,pccd_M->mvert[mface->v3].co); - mima->minx = MIN2(mima->minx,v[0]-hull); - mima->miny = MIN2(mima->miny,v[1]-hull); - mima->minz = MIN2(mima->minz,v[2]-hull); - mima->maxx = MAX2(mima->maxx,v[0]+hull); - mima->maxy = MAX2(mima->maxy,v[1]+hull); - mima->maxz = MAX2(mima->maxz,v[2]+hull); + copy_v3_v3(v, pccd_M->mvert[mface->v1].co); + mima->minx = MIN2(mima->minx, v[0]-hull); + mima->miny = MIN2(mima->miny, v[1]-hull); + mima->minz = MIN2(mima->minz, v[2]-hull); + mima->maxx = MAX2(mima->maxx, v[0]+hull); + mima->maxy = MAX2(mima->maxy, v[1]+hull); + mima->maxz = MAX2(mima->maxz, v[2]+hull); + + copy_v3_v3(v, pccd_M->mvert[mface->v2].co); + mima->minx = MIN2(mima->minx, v[0]-hull); + mima->miny = MIN2(mima->miny, v[1]-hull); + mima->minz = MIN2(mima->minz, v[2]-hull); + mima->maxx = MAX2(mima->maxx, v[0]+hull); + mima->maxy = MAX2(mima->maxy, v[1]+hull); + mima->maxz = MAX2(mima->maxz, v[2]+hull); + + copy_v3_v3(v, pccd_M->mvert[mface->v3].co); + mima->minx = MIN2(mima->minx, v[0]-hull); + mima->miny = MIN2(mima->miny, v[1]-hull); + mima->minz = MIN2(mima->minz, v[2]-hull); + mima->maxx = MAX2(mima->maxx, v[0]+hull); + mima->maxy = MAX2(mima->maxy, v[1]+hull); + mima->maxz = MAX2(mima->maxz, v[2]+hull); if (mface->v4) { - copy_v3_v3(v,pccd_M->mvert[mface->v4].co); - mima->minx = MIN2(mima->minx,v[0]-hull); - mima->miny = MIN2(mima->miny,v[1]-hull); - mima->minz = MIN2(mima->minz,v[2]-hull); - mima->maxx = MAX2(mima->maxx,v[0]+hull); - mima->maxy = MAX2(mima->maxy,v[1]+hull); - mima->maxz = MAX2(mima->maxz,v[2]+hull); + copy_v3_v3(v, pccd_M->mvert[mface->v4].co); + mima->minx = MIN2(mima->minx, v[0]-hull); + mima->miny = MIN2(mima->miny, v[1]-hull); + mima->minz = MIN2(mima->minz, v[2]-hull); + mima->maxx = MAX2(mima->maxx, v[0]+hull); + mima->maxy = MAX2(mima->maxy, v[1]+hull); + mima->maxz = MAX2(mima->maxz, v[2]+hull); } - copy_v3_v3(v,pccd_M->mprevvert[mface->v1].co); - mima->minx = MIN2(mima->minx,v[0]-hull); - mima->miny = MIN2(mima->miny,v[1]-hull); - mima->minz = MIN2(mima->minz,v[2]-hull); - mima->maxx = MAX2(mima->maxx,v[0]+hull); - mima->maxy = MAX2(mima->maxy,v[1]+hull); - mima->maxz = MAX2(mima->maxz,v[2]+hull); - - copy_v3_v3(v,pccd_M->mprevvert[mface->v2].co); - mima->minx = MIN2(mima->minx,v[0]-hull); - mima->miny = MIN2(mima->miny,v[1]-hull); - mima->minz = MIN2(mima->minz,v[2]-hull); - mima->maxx = MAX2(mima->maxx,v[0]+hull); - mima->maxy = MAX2(mima->maxy,v[1]+hull); - mima->maxz = MAX2(mima->maxz,v[2]+hull); - - copy_v3_v3(v,pccd_M->mprevvert[mface->v3].co); - mima->minx = MIN2(mima->minx,v[0]-hull); - mima->miny = MIN2(mima->miny,v[1]-hull); - mima->minz = MIN2(mima->minz,v[2]-hull); - mima->maxx = MAX2(mima->maxx,v[0]+hull); - mima->maxy = MAX2(mima->maxy,v[1]+hull); - mima->maxz = MAX2(mima->maxz,v[2]+hull); + copy_v3_v3(v, pccd_M->mprevvert[mface->v1].co); + mima->minx = MIN2(mima->minx, v[0]-hull); + mima->miny = MIN2(mima->miny, v[1]-hull); + mima->minz = MIN2(mima->minz, v[2]-hull); + mima->maxx = MAX2(mima->maxx, v[0]+hull); + mima->maxy = MAX2(mima->maxy, v[1]+hull); + mima->maxz = MAX2(mima->maxz, v[2]+hull); + + copy_v3_v3(v, pccd_M->mprevvert[mface->v2].co); + mima->minx = MIN2(mima->minx, v[0]-hull); + mima->miny = MIN2(mima->miny, v[1]-hull); + mima->minz = MIN2(mima->minz, v[2]-hull); + mima->maxx = MAX2(mima->maxx, v[0]+hull); + mima->maxy = MAX2(mima->maxy, v[1]+hull); + mima->maxz = MAX2(mima->maxz, v[2]+hull); + + copy_v3_v3(v, pccd_M->mprevvert[mface->v3].co); + mima->minx = MIN2(mima->minx, v[0]-hull); + mima->miny = MIN2(mima->miny, v[1]-hull); + mima->minz = MIN2(mima->minz, v[2]-hull); + mima->maxx = MAX2(mima->maxx, v[0]+hull); + mima->maxy = MAX2(mima->maxy, v[1]+hull); + mima->maxz = MAX2(mima->maxz, v[2]+hull); if (mface->v4) { - copy_v3_v3(v,pccd_M->mprevvert[mface->v4].co); - mima->minx = MIN2(mima->minx,v[0]-hull); - mima->miny = MIN2(mima->miny,v[1]-hull); - mima->minz = MIN2(mima->minz,v[2]-hull); - mima->maxx = MAX2(mima->maxx,v[0]+hull); - mima->maxy = MAX2(mima->maxy,v[1]+hull); - mima->maxz = MAX2(mima->maxz,v[2]+hull); + copy_v3_v3(v, pccd_M->mprevvert[mface->v4].co); + mima->minx = MIN2(mima->minx, v[0]-hull); + mima->miny = MIN2(mima->miny, v[1]-hull); + mima->minz = MIN2(mima->minz, v[2]-hull); + mima->maxx = MAX2(mima->maxx, v[0]+hull); + mima->maxy = MAX2(mima->maxy, v[1]+hull); + mima->maxz = MAX2(mima->maxz, v[2]+hull); } @@ -587,9 +587,9 @@ static void ccd_update_deflector_hash(Scene *scene, Object *vertexowner, GHash * /*+++ only with deflecting set */ if (ob->pd && ob->pd->deflect) { - ccd_Mesh *ccdmesh = BLI_ghash_lookup(hash,ob); + ccd_Mesh *ccdmesh = BLI_ghash_lookup(hash, ob); if (ccdmesh) - ccd_mesh_update(ob,ccdmesh); + ccd_mesh_update(ob, ccdmesh); }/*--- only with deflecting set */ }/* mesh && layer*/ @@ -605,7 +605,7 @@ static void ccd_update_deflector_hash(Scene *scene, Object *vertexowner, GHash * static int count_mesh_quads(Mesh *me) { - int a,result = 0; + int a, result = 0; MFace *mface= me->mface; if (mface) { @@ -631,8 +631,8 @@ static void add_mesh_quad_diag_springs(Object *ob) nofquads = count_mesh_quads(me); if (nofquads) { /* resize spring-array to hold additional quad springs */ - bs_new= MEM_callocN( (ob->soft->totspring + nofquads *2 )*sizeof(BodySpring), "bodyspring"); - memcpy(bs_new,ob->soft->bspring,(ob->soft->totspring )*sizeof(BodySpring)); + bs_new= MEM_callocN((ob->soft->totspring + nofquads *2 )*sizeof(BodySpring), "bodyspring"); + memcpy(bs_new, ob->soft->bspring, (ob->soft->totspring )*sizeof(BodySpring)); if (ob->soft->bspring) MEM_freeN(ob->soft->bspring); /* do this before reassigning the pointer or have a 1st class memory leak */ @@ -664,13 +664,13 @@ static void add_mesh_quad_diag_springs(Object *ob) } } -static void add_2nd_order_roller(Object *ob,float UNUSED(stiffness), int *counter, int addsprings) +static void add_2nd_order_roller(Object *ob, float UNUSED(stiffness), int *counter, int addsprings) { /*assume we have a softbody*/ SoftBody *sb= ob->soft; /* is supposed to be there */ - BodyPoint *bp,*bpo; - BodySpring *bs,*bs2,*bs3= NULL; - int a,b,c,notthis= 0,v0; + BodyPoint *bp, *bpo; + BodySpring *bs, *bs2, *bs3= NULL; + int a, b, c, notthis= 0, v0; if (!sb->bspring) {return;} /* we are 2nd order here so 1rst should have been build :) */ /* first run counting second run adding */ *counter = 0; @@ -726,40 +726,40 @@ static void add_2nd_order_roller(Object *ob,float UNUSED(stiffness), int *counte } -static void add_2nd_order_springs(Object *ob,float stiffness) +static void add_2nd_order_springs(Object *ob, float stiffness) { int counter = 0; BodySpring *bs_new; stiffness *=stiffness; - add_2nd_order_roller(ob,stiffness,&counter,0); /* counting */ + add_2nd_order_roller(ob, stiffness, &counter, 0); /* counting */ if (counter) { /* resize spring-array to hold additional springs */ - bs_new= MEM_callocN( (ob->soft->totspring + counter )*sizeof(BodySpring), "bodyspring"); - memcpy(bs_new,ob->soft->bspring,(ob->soft->totspring )*sizeof(BodySpring)); + bs_new= MEM_callocN((ob->soft->totspring + counter )*sizeof(BodySpring), "bodyspring"); + memcpy(bs_new, ob->soft->bspring, (ob->soft->totspring )*sizeof(BodySpring)); if (ob->soft->bspring) MEM_freeN(ob->soft->bspring); ob->soft->bspring = bs_new; - add_2nd_order_roller(ob,stiffness,&counter,1); /* adding */ + add_2nd_order_roller(ob, stiffness, &counter, 1); /* adding */ ob->soft->totspring += counter; } } -static void add_bp_springlist(BodyPoint *bp,int springID) +static void add_bp_springlist(BodyPoint *bp, int springID) { int *newlist; if (bp->springs == NULL) { - bp->springs = MEM_callocN( sizeof(int), "bpsprings"); + bp->springs = MEM_callocN(sizeof(int), "bpsprings"); bp->springs[0] = springID; bp->nofsprings = 1; } else { bp->nofsprings++; newlist = MEM_callocN(bp->nofsprings * sizeof(int), "bpsprings"); - memcpy(newlist,bp->springs,(bp->nofsprings-1)* sizeof(int)); + memcpy(newlist, bp->springs, (bp->nofsprings-1)* sizeof(int)); MEM_freeN(bp->springs); bp->springs = newlist; bp->springs[bp->nofsprings-1] = springID; @@ -774,7 +774,7 @@ static void build_bps_springlist(Object *ob) SoftBody *sb= ob->soft; /* is supposed to be there */ BodyPoint *bp; BodySpring *bs; - int a,b; + int a, b; if (sb==NULL) return; /* paranoya check */ @@ -787,10 +787,10 @@ static void build_bps_springlist(Object *ob) /* scan for attached inner springs */ for (b=sb->totspring, bs= sb->bspring; b>0; b--, bs++) { if (( (sb->totpoint-a) == bs->v1) ) { - add_bp_springlist(bp,sb->totspring -b); + add_bp_springlist(bp, sb->totspring -b); } if (( (sb->totpoint-a) == bs->v2) ) { - add_bp_springlist(bp,sb->totspring -b); + add_bp_springlist(bp, sb->totspring -b); } }/*for springs*/ }/*for bp*/ @@ -801,8 +801,8 @@ static void calculate_collision_balls(Object *ob) SoftBody *sb= ob->soft; /* is supposed to be there */ BodyPoint *bp; BodySpring *bs; - int a,b,akku_count; - float min,max,akku; + int a, b, akku_count; + float min, max, akku; if (sb==NULL) return; /* paranoya check */ @@ -818,8 +818,8 @@ static void calculate_collision_balls(Object *ob) if (bs->springtype == SB_EDGE) { akku += bs->len; akku_count++, - min = MIN2(bs->len,min); - max = MAX2(bs->len,max); + min = MIN2(bs->len, min); + max = MAX2(bs->len, max); } } @@ -860,9 +860,9 @@ static void renew_softbody(Scene *scene, Object *ob, int totpoint, int totspring sb->totpoint= totpoint; sb->totspring= totspring; - sb->bpoint= MEM_mallocN( totpoint*sizeof(BodyPoint), "bodypoint"); + sb->bpoint= MEM_mallocN(totpoint*sizeof(BodyPoint), "bodypoint"); if (totspring) - sb->bspring= MEM_mallocN( totspring*sizeof(BodySpring), "bodyspring"); + sb->bspring= MEM_mallocN(totspring*sizeof(BodySpring), "bodyspring"); /* initialize BodyPoint array */ for (i=0; i<totpoint; i++) { @@ -1015,21 +1015,21 @@ static int query_external_colliders(Scene *scene, Object *me) /* +++ the aabb "force" section*/ -static int sb_detect_aabb_collisionCached( float UNUSED(force[3]), unsigned int UNUSED(par_layer),struct Object *vertexowner,float UNUSED(time)) +static int sb_detect_aabb_collisionCached(float UNUSED(force[3]), unsigned int UNUSED(par_layer), struct Object *vertexowner, float UNUSED(time)) { Object *ob; SoftBody *sb=vertexowner->soft; GHash *hash; GHashIterator *ihash; - float aabbmin[3],aabbmax[3]; + float aabbmin[3], aabbmax[3]; int deflected=0; #if 0 int a; #endif if ((sb == NULL) || (sb->scratch ==NULL)) return 0; - copy_v3_v3(aabbmin,sb->scratch->aabbmin); - copy_v3_v3(aabbmax,sb->scratch->aabbmax); + copy_v3_v3(aabbmin, sb->scratch->aabbmin); + copy_v3_v3(aabbmax, sb->scratch->aabbmax); hash = vertexowner->soft->scratch->colliderhash; ihash = BLI_ghashIterator_new(hash); @@ -1085,22 +1085,22 @@ static int sb_detect_aabb_collisionCached( float UNUSED(force[3]), unsigned int /* +++ the face external section*/ -static int sb_detect_face_pointCached(float face_v1[3],float face_v2[3],float face_v3[3],float *damp, - float force[3], unsigned int UNUSED(par_layer),struct Object *vertexowner,float time) - { +static int sb_detect_face_pointCached(float face_v1[3], float face_v2[3], float face_v3[3], float *damp, + float force[3], unsigned int UNUSED(par_layer), struct Object *vertexowner, float time) +{ Object *ob; GHash *hash; GHashIterator *ihash; - float nv1[3], edge1[3], edge2[3], d_nvect[3], aabbmin[3],aabbmax[3]; - float facedist,outerfacethickness,tune = 10.f; + float nv1[3], edge1[3], edge2[3], d_nvect[3], aabbmin[3], aabbmax[3]; + float facedist, outerfacethickness, tune = 10.f; int a, deflected=0; - aabbmin[0] = MIN3(face_v1[0],face_v2[0],face_v3[0]); - aabbmin[1] = MIN3(face_v1[1],face_v2[1],face_v3[1]); - aabbmin[2] = MIN3(face_v1[2],face_v2[2],face_v3[2]); - aabbmax[0] = MAX3(face_v1[0],face_v2[0],face_v3[0]); - aabbmax[1] = MAX3(face_v1[1],face_v2[1],face_v3[1]); - aabbmax[2] = MAX3(face_v1[2],face_v2[2],face_v3[2]); + aabbmin[0] = MIN3(face_v1[0], face_v2[0], face_v3[0]); + aabbmin[1] = MIN3(face_v1[1], face_v2[1], face_v3[1]); + aabbmin[2] = MIN3(face_v1[2], face_v2[2], face_v3[2]); + aabbmax[0] = MAX3(face_v1[0], face_v2[0], face_v3[0]); + aabbmax[1] = MAX3(face_v1[1], face_v2[1], face_v3[1]); + aabbmax[2] = MAX3(face_v1[2], face_v2[2], face_v3[2]); /* calculate face normal once again SIGH */ sub_v3_v3v3(edge1, face_v1, face_v2); @@ -1147,16 +1147,16 @@ static int sb_detect_face_pointCached(float face_v1[3],float face_v2[3],float fa /* use mesh*/ if (mvert) { while (a) { - copy_v3_v3(nv1,mvert[a-1].co); + copy_v3_v3(nv1, mvert[a-1].co); if (mprevvert) { - mul_v3_fl(nv1,time); - Vec3PlusStVec(nv1,(1.0f-time),mprevvert[a-1].co); + mul_v3_fl(nv1, time); + Vec3PlusStVec(nv1, (1.0f-time), mprevvert[a-1].co); } /* origin to face_v2*/ sub_v3_v3(nv1, face_v2); - facedist = dot_v3v3(nv1,d_nvect); + facedist = dot_v3v3(nv1, d_nvect); if (ABS(facedist)<outerfacethickness) { - if (isect_point_tri_prism_v3(nv1, face_v1,face_v2,face_v3) ) { + if (isect_point_tri_prism_v3(nv1, face_v1, face_v2, face_v3) ) { float df; if (facedist > 0) { df = (outerfacethickness-facedist)/outerfacethickness; @@ -1168,7 +1168,7 @@ static int sb_detect_face_pointCached(float face_v1[3],float face_v2[3],float fa *damp=df*tune*ob->pd->pdef_sbdamp; df = 0.01f*exp(- 100.0f*df); - Vec3PlusStVec(force,-df,d_nvect); + Vec3PlusStVec(force, -df, d_nvect); deflected = 3; } } @@ -1183,22 +1183,22 @@ static int sb_detect_face_pointCached(float face_v1[3],float face_v2[3],float fa } -static int sb_detect_face_collisionCached(float face_v1[3],float face_v2[3],float face_v3[3],float *damp, - float force[3], unsigned int UNUSED(par_layer),struct Object *vertexowner,float time) +static int sb_detect_face_collisionCached(float face_v1[3], float face_v2[3], float face_v3[3], float *damp, + float force[3], unsigned int UNUSED(par_layer), struct Object *vertexowner, float time) { Object *ob; GHash *hash; GHashIterator *ihash; - float nv1[3], nv2[3], nv3[3], nv4[3], edge1[3], edge2[3], d_nvect[3], aabbmin[3],aabbmax[3]; - float t,tune = 10.0f; + float nv1[3], nv2[3], nv3[3], nv4[3], edge1[3], edge2[3], d_nvect[3], aabbmin[3], aabbmax[3]; + float t, tune = 10.0f; int a, deflected=0; - aabbmin[0] = MIN3(face_v1[0],face_v2[0],face_v3[0]); - aabbmin[1] = MIN3(face_v1[1],face_v2[1],face_v3[1]); - aabbmin[2] = MIN3(face_v1[2],face_v2[2],face_v3[2]); - aabbmax[0] = MAX3(face_v1[0],face_v2[0],face_v3[0]); - aabbmax[1] = MAX3(face_v1[1],face_v2[1],face_v3[1]); - aabbmax[2] = MAX3(face_v1[2],face_v2[2],face_v3[2]); + aabbmin[0] = MIN3(face_v1[0], face_v2[0], face_v3[0]); + aabbmin[1] = MIN3(face_v1[1], face_v2[1], face_v3[1]); + aabbmin[2] = MIN3(face_v1[2], face_v2[2], face_v3[2]); + aabbmax[0] = MAX3(face_v1[0], face_v2[0], face_v3[0]); + aabbmax[1] = MAX3(face_v1[1], face_v2[1], face_v3[1]); + aabbmax[2] = MAX3(face_v1[2], face_v2[2], face_v3[2]); hash = vertexowner->soft->scratch->colliderhash; ihash = BLI_ghashIterator_new(hash); @@ -1257,25 +1257,25 @@ static int sb_detect_face_collisionCached(float face_v1[3],float face_v2[3],floa if (mvert) { - copy_v3_v3(nv1,mvert[mface->v1].co); - copy_v3_v3(nv2,mvert[mface->v2].co); - copy_v3_v3(nv3,mvert[mface->v3].co); + copy_v3_v3(nv1, mvert[mface->v1].co); + copy_v3_v3(nv2, mvert[mface->v2].co); + copy_v3_v3(nv3, mvert[mface->v3].co); if (mface->v4) { - copy_v3_v3(nv4,mvert[mface->v4].co); + copy_v3_v3(nv4, mvert[mface->v4].co); } if (mprevvert) { - mul_v3_fl(nv1,time); - Vec3PlusStVec(nv1,(1.0f-time),mprevvert[mface->v1].co); + mul_v3_fl(nv1, time); + Vec3PlusStVec(nv1, (1.0f-time), mprevvert[mface->v1].co); - mul_v3_fl(nv2,time); - Vec3PlusStVec(nv2,(1.0f-time),mprevvert[mface->v2].co); + mul_v3_fl(nv2, time); + Vec3PlusStVec(nv2, (1.0f-time), mprevvert[mface->v2].co); - mul_v3_fl(nv3,time); - Vec3PlusStVec(nv3,(1.0f-time),mprevvert[mface->v3].co); + mul_v3_fl(nv3, time); + Vec3PlusStVec(nv3, (1.0f-time), mprevvert[mface->v3].co); if (mface->v4) { - mul_v3_fl(nv4,time); - Vec3PlusStVec(nv4,(1.0f-time),mprevvert[mface->v4].co); + mul_v3_fl(nv4, time); + Vec3PlusStVec(nv4, (1.0f-time), mprevvert[mface->v4].co); } } } @@ -1289,7 +1289,7 @@ static int sb_detect_face_collisionCached(float face_v1[3],float face_v2[3],floa isect_line_tri_v3(nv1, nv2, face_v1, face_v2, face_v3, &t, NULL) || isect_line_tri_v3(nv2, nv3, face_v1, face_v2, face_v3, &t, NULL) || isect_line_tri_v3(nv3, nv1, face_v1, face_v2, face_v3, &t, NULL) ) { - Vec3PlusStVec(force,-0.5f,d_nvect); + Vec3PlusStVec(force, -0.5f, d_nvect); *damp=tune*ob->pd->pdef_sbdamp; deflected = 2; } @@ -1304,7 +1304,7 @@ static int sb_detect_face_collisionCached(float face_v1[3],float face_v2[3],floa we did that edge already */ isect_line_tri_v3(nv3, nv4, face_v1, face_v2, face_v3, &t, NULL) || isect_line_tri_v3(nv4, nv1, face_v1, face_v2, face_v3, &t, NULL) ) { - Vec3PlusStVec(force,-0.5f,d_nvect); + Vec3PlusStVec(force, -0.5f, d_nvect); *damp=tune*ob->pd->pdef_sbdamp; deflected = 2; } @@ -1321,12 +1321,12 @@ static int sb_detect_face_collisionCached(float face_v1[3],float face_v2[3],floa -static void scan_for_ext_face_forces(Object *ob,float timenow) +static void scan_for_ext_face_forces(Object *ob, float timenow) { SoftBody *sb = ob->soft; BodyFace *bf; int a; - float damp=0.0f,choke=1.0f; + float damp=0.0f, choke=1.0f; float tune = -10.0f; float feedback[3]; @@ -1339,25 +1339,25 @@ static void scan_for_ext_face_forces(Object *ob,float timenow) /*+++edges intruding*/ bf->flag &= ~BFF_INTERSECT; feedback[0]=feedback[1]=feedback[2]=0.0f; - if (sb_detect_face_collisionCached(sb->bpoint[bf->v1].pos,sb->bpoint[bf->v2].pos, sb->bpoint[bf->v3].pos, - &damp, feedback, ob->lay ,ob , timenow)) { - Vec3PlusStVec(sb->bpoint[bf->v1].force,tune,feedback); - Vec3PlusStVec(sb->bpoint[bf->v2].force,tune,feedback); - Vec3PlusStVec(sb->bpoint[bf->v3].force,tune,feedback); -// Vec3PlusStVec(bf->ext_force,tune,feedback); + if (sb_detect_face_collisionCached(sb->bpoint[bf->v1].pos, sb->bpoint[bf->v2].pos, sb->bpoint[bf->v3].pos, + &damp, feedback, ob->lay, ob, timenow)) { + Vec3PlusStVec(sb->bpoint[bf->v1].force, tune, feedback); + Vec3PlusStVec(sb->bpoint[bf->v2].force, tune, feedback); + Vec3PlusStVec(sb->bpoint[bf->v3].force, tune, feedback); +// Vec3PlusStVec(bf->ext_force, tune, feedback); bf->flag |= BFF_INTERSECT; - choke = MIN2(MAX2(damp,choke),1.0f); + choke = MIN2(MAX2(damp, choke), 1.0f); } feedback[0]=feedback[1]=feedback[2]=0.0f; - if ((bf->v4) && (sb_detect_face_collisionCached(sb->bpoint[bf->v1].pos,sb->bpoint[bf->v3].pos, sb->bpoint[bf->v4].pos, - &damp, feedback, ob->lay ,ob , timenow))) { - Vec3PlusStVec(sb->bpoint[bf->v1].force,tune,feedback); - Vec3PlusStVec(sb->bpoint[bf->v3].force,tune,feedback); - Vec3PlusStVec(sb->bpoint[bf->v4].force,tune,feedback); -// Vec3PlusStVec(bf->ext_force,tune,feedback); + if ((bf->v4) && (sb_detect_face_collisionCached(sb->bpoint[bf->v1].pos, sb->bpoint[bf->v3].pos, sb->bpoint[bf->v4].pos, + &damp, feedback, ob->lay, ob, timenow))) { + Vec3PlusStVec(sb->bpoint[bf->v1].force, tune, feedback); + Vec3PlusStVec(sb->bpoint[bf->v3].force, tune, feedback); + Vec3PlusStVec(sb->bpoint[bf->v4].force, tune, feedback); +// Vec3PlusStVec(bf->ext_force, tune, feedback); bf->flag |= BFF_INTERSECT; - choke = MIN2(MAX2(damp,choke),1.0f); + choke = MIN2(MAX2(damp, choke), 1.0f); } /*---edges intruding*/ @@ -1366,25 +1366,25 @@ static void scan_for_ext_face_forces(Object *ob,float timenow) bf->flag &= ~BFF_CLOSEVERT; tune = -1.0f; feedback[0]=feedback[1]=feedback[2]=0.0f; - if (sb_detect_face_pointCached(sb->bpoint[bf->v1].pos,sb->bpoint[bf->v2].pos, sb->bpoint[bf->v3].pos, - &damp, feedback, ob->lay ,ob , timenow)) { - Vec3PlusStVec(sb->bpoint[bf->v1].force,tune,feedback); - Vec3PlusStVec(sb->bpoint[bf->v2].force,tune,feedback); - Vec3PlusStVec(sb->bpoint[bf->v3].force,tune,feedback); -// Vec3PlusStVec(bf->ext_force,tune,feedback); + if (sb_detect_face_pointCached(sb->bpoint[bf->v1].pos, sb->bpoint[bf->v2].pos, sb->bpoint[bf->v3].pos, + &damp, feedback, ob->lay, ob, timenow)) { + Vec3PlusStVec(sb->bpoint[bf->v1].force, tune, feedback); + Vec3PlusStVec(sb->bpoint[bf->v2].force, tune, feedback); + Vec3PlusStVec(sb->bpoint[bf->v3].force, tune, feedback); +// Vec3PlusStVec(bf->ext_force, tune, feedback); bf->flag |= BFF_CLOSEVERT; - choke = MIN2(MAX2(damp,choke),1.0f); + choke = MIN2(MAX2(damp, choke), 1.0f); } feedback[0]=feedback[1]=feedback[2]=0.0f; - if ((bf->v4) && (sb_detect_face_pointCached(sb->bpoint[bf->v1].pos,sb->bpoint[bf->v3].pos, sb->bpoint[bf->v4].pos, - &damp, feedback, ob->lay ,ob , timenow))) { - Vec3PlusStVec(sb->bpoint[bf->v1].force,tune,feedback); - Vec3PlusStVec(sb->bpoint[bf->v3].force,tune,feedback); - Vec3PlusStVec(sb->bpoint[bf->v4].force,tune,feedback); -// Vec3PlusStVec(bf->ext_force,tune,feedback); + if ((bf->v4) && (sb_detect_face_pointCached(sb->bpoint[bf->v1].pos, sb->bpoint[bf->v3].pos, sb->bpoint[bf->v4].pos, + &damp, feedback, ob->lay, ob, timenow))) { + Vec3PlusStVec(sb->bpoint[bf->v1].force, tune, feedback); + Vec3PlusStVec(sb->bpoint[bf->v3].force, tune, feedback); + Vec3PlusStVec(sb->bpoint[bf->v4].force, tune, feedback); +// Vec3PlusStVec(bf->ext_force, tune, feedback); bf->flag |= BFF_CLOSEVERT; - choke = MIN2(MAX2(damp,choke),1.0f); + choke = MIN2(MAX2(damp, choke), 1.0f); } } /*--- close vertices*/ @@ -1392,11 +1392,11 @@ static void scan_for_ext_face_forces(Object *ob,float timenow) bf = sb->scratch->bodyface; for (a=0; a<sb->scratch->totface; a++, bf++) { if (( bf->flag & BFF_INTERSECT) || ( bf->flag & BFF_CLOSEVERT)) { - sb->bpoint[bf->v1].choke2=MAX2(sb->bpoint[bf->v1].choke2,choke); - sb->bpoint[bf->v2].choke2=MAX2(sb->bpoint[bf->v2].choke2,choke); - sb->bpoint[bf->v3].choke2=MAX2(sb->bpoint[bf->v3].choke2,choke); + sb->bpoint[bf->v1].choke2=MAX2(sb->bpoint[bf->v1].choke2, choke); + sb->bpoint[bf->v2].choke2=MAX2(sb->bpoint[bf->v2].choke2, choke); + sb->bpoint[bf->v3].choke2=MAX2(sb->bpoint[bf->v3].choke2, choke); if (bf->v4) { - sb->bpoint[bf->v2].choke2=MAX2(sb->bpoint[bf->v2].choke2,choke); + sb->bpoint[bf->v2].choke2=MAX2(sb->bpoint[bf->v2].choke2, choke); } } } @@ -1408,24 +1408,24 @@ static void scan_for_ext_face_forces(Object *ob,float timenow) /* +++ the spring external section*/ -static int sb_detect_edge_collisionCached(float edge_v1[3],float edge_v2[3],float *damp, - float force[3], unsigned int UNUSED(par_layer),struct Object *vertexowner,float time) +static int sb_detect_edge_collisionCached(float edge_v1[3], float edge_v2[3], float *damp, + float force[3], unsigned int UNUSED(par_layer), struct Object *vertexowner, float time) { Object *ob; GHash *hash; GHashIterator *ihash; - float nv1[3], nv2[3], nv3[3], nv4[3], edge1[3], edge2[3], d_nvect[3], aabbmin[3],aabbmax[3]; - float t,el; + float nv1[3], nv2[3], nv3[3], nv4[3], edge1[3], edge2[3], d_nvect[3], aabbmin[3], aabbmax[3]; + float t, el; int a, deflected=0; - aabbmin[0] = MIN2(edge_v1[0],edge_v2[0]); - aabbmin[1] = MIN2(edge_v1[1],edge_v2[1]); - aabbmin[2] = MIN2(edge_v1[2],edge_v2[2]); - aabbmax[0] = MAX2(edge_v1[0],edge_v2[0]); - aabbmax[1] = MAX2(edge_v1[1],edge_v2[1]); - aabbmax[2] = MAX2(edge_v1[2],edge_v2[2]); + aabbmin[0] = MIN2(edge_v1[0], edge_v2[0]); + aabbmin[1] = MIN2(edge_v1[1], edge_v2[1]); + aabbmin[2] = MIN2(edge_v1[2], edge_v2[2]); + aabbmax[0] = MAX2(edge_v1[0], edge_v2[0]); + aabbmax[1] = MAX2(edge_v1[1], edge_v2[1]); + aabbmax[2] = MAX2(edge_v1[2], edge_v2[2]); - el = len_v3v3(edge_v1,edge_v2); + el = len_v3v3(edge_v1, edge_v2); hash = vertexowner->soft->scratch->colliderhash; ihash = BLI_ghashIterator_new(hash); @@ -1484,25 +1484,25 @@ static int sb_detect_edge_collisionCached(float edge_v1[3],float edge_v2[3],floa if (mvert) { - copy_v3_v3(nv1,mvert[mface->v1].co); - copy_v3_v3(nv2,mvert[mface->v2].co); - copy_v3_v3(nv3,mvert[mface->v3].co); + copy_v3_v3(nv1, mvert[mface->v1].co); + copy_v3_v3(nv2, mvert[mface->v2].co); + copy_v3_v3(nv3, mvert[mface->v3].co); if (mface->v4) { - copy_v3_v3(nv4,mvert[mface->v4].co); + copy_v3_v3(nv4, mvert[mface->v4].co); } if (mprevvert) { - mul_v3_fl(nv1,time); - Vec3PlusStVec(nv1,(1.0f-time),mprevvert[mface->v1].co); + mul_v3_fl(nv1, time); + Vec3PlusStVec(nv1, (1.0f-time), mprevvert[mface->v1].co); - mul_v3_fl(nv2,time); - Vec3PlusStVec(nv2,(1.0f-time),mprevvert[mface->v2].co); + mul_v3_fl(nv2, time); + Vec3PlusStVec(nv2, (1.0f-time), mprevvert[mface->v2].co); - mul_v3_fl(nv3,time); - Vec3PlusStVec(nv3,(1.0f-time),mprevvert[mface->v3].co); + mul_v3_fl(nv3, time); + Vec3PlusStVec(nv3, (1.0f-time), mprevvert[mface->v3].co); if (mface->v4) { - mul_v3_fl(nv4,time); - Vec3PlusStVec(nv4,(1.0f-time),mprevvert[mface->v4].co); + mul_v3_fl(nv4, time); + Vec3PlusStVec(nv4, (1.0f-time), mprevvert[mface->v4].co); } } } @@ -1514,14 +1514,14 @@ static int sb_detect_edge_collisionCached(float edge_v1[3],float edge_v2[3],floa cross_v3_v3v3(d_nvect, edge2, edge1); normalize_v3(d_nvect); if ( isect_line_tri_v3(edge_v1, edge_v2, nv1, nv2, nv3, &t, NULL)) { - float v1[3],v2[3]; - float intrusiondepth,i1,i2; + float v1[3], v2[3]; + float intrusiondepth, i1, i2; sub_v3_v3v3(v1, edge_v1, nv2); sub_v3_v3v3(v2, edge_v2, nv2); - i1 = dot_v3v3(v1,d_nvect); - i2 = dot_v3v3(v2,d_nvect); - intrusiondepth = -MIN2(i1,i2)/el; - Vec3PlusStVec(force,intrusiondepth,d_nvect); + i1 = dot_v3v3(v1, d_nvect); + i2 = dot_v3v3(v2, d_nvect); + intrusiondepth = -MIN2(i1, i2)/el; + Vec3PlusStVec(force, intrusiondepth, d_nvect); *damp=ob->pd->pdef_sbdamp; deflected = 2; } @@ -1532,17 +1532,17 @@ static int sb_detect_edge_collisionCached(float edge_v1[3],float edge_v2[3],floa cross_v3_v3v3(d_nvect, edge2, edge1); normalize_v3(d_nvect); - if (isect_line_tri_v3( edge_v1, edge_v2,nv1, nv3, nv4, &t, NULL)) { - float v1[3],v2[3]; - float intrusiondepth,i1,i2; + if (isect_line_tri_v3( edge_v1, edge_v2, nv1, nv3, nv4, &t, NULL)) { + float v1[3], v2[3]; + float intrusiondepth, i1, i2; sub_v3_v3v3(v1, edge_v1, nv4); sub_v3_v3v3(v2, edge_v2, nv4); - i1 = dot_v3v3(v1,d_nvect); - i2 = dot_v3v3(v2,d_nvect); - intrusiondepth = -MIN2(i1,i2)/el; + i1 = dot_v3v3(v1, d_nvect); + i2 = dot_v3v3(v2, d_nvect); + intrusiondepth = -MIN2(i1, i2)/el; - Vec3PlusStVec(force,intrusiondepth,d_nvect); + Vec3PlusStVec(force, intrusiondepth, d_nvect); *damp=ob->pd->pdef_sbdamp; deflected = 2; } @@ -1574,8 +1574,8 @@ static void _scan_for_ext_spring_forces(Scene *scene, Object *ob, float timenow, if (bs->springtype == SB_EDGE) { /* +++ springs colliding */ if (ob->softflag & OB_SB_EDGECOLL) { - if ( sb_detect_edge_collisionCached (sb->bpoint[bs->v1].pos , sb->bpoint[bs->v2].pos, - &damp,feedback,ob->lay,ob,timenow)) { + if ( sb_detect_edge_collisionCached (sb->bpoint[bs->v1].pos, sb->bpoint[bs->v2].pos, + &damp, feedback, ob->lay, ob, timenow)) { add_v3_v3(bs->ext_force, feedback); bs->flag |= BSF_INTERSECT; //bs->cf=damp; @@ -1588,40 +1588,40 @@ static void _scan_for_ext_spring_forces(Scene *scene, Object *ob, float timenow, /* +++ springs seeing wind ... n stuff depending on their orientation*/ /* note we don't use sb->mediafrict but use sb->aeroedge for magnitude of effect*/ if (sb->aeroedge) { - float vel[3],sp[3],pr[3],force[3]; - float f,windfactor = 0.25f; + float vel[3], sp[3], pr[3], force[3]; + float f, windfactor = 0.25f; /*see if we have wind*/ if (do_effector) { EffectedPoint epoint; - float speed[3]={0.0f,0.0f,0.0f}; + float speed[3]={0.0f, 0.0f, 0.0f}; float pos[3]; - mid_v3_v3v3(pos, sb->bpoint[bs->v1].pos , sb->bpoint[bs->v2].pos); - mid_v3_v3v3(vel, sb->bpoint[bs->v1].vec , sb->bpoint[bs->v2].vec); + mid_v3_v3v3(pos, sb->bpoint[bs->v1].pos, sb->bpoint[bs->v2].pos); + mid_v3_v3v3(vel, sb->bpoint[bs->v1].vec, sb->bpoint[bs->v2].vec); pd_point_from_soft(scene, pos, vel, -1, &epoint); pdDoEffectors(do_effector, NULL, sb->effector_weights, &epoint, force, speed); - mul_v3_fl(speed,windfactor); + mul_v3_fl(speed, windfactor); add_v3_v3(vel, speed); } /* media in rest */ else { - add_v3_v3v3(vel, sb->bpoint[bs->v1].vec , sb->bpoint[bs->v2].vec); + add_v3_v3v3(vel, sb->bpoint[bs->v1].vec, sb->bpoint[bs->v2].vec); } f = normalize_v3(vel); f = -0.0001f*f*f*sb->aeroedge; /* (todo) add a nice angle dependent function done for now BUT */ /* still there could be some nice drag/lift function, but who needs it */ - sub_v3_v3v3(sp, sb->bpoint[bs->v1].pos , sb->bpoint[bs->v2].pos); - project_v3_v3v3(pr,vel,sp); + sub_v3_v3v3(sp, sb->bpoint[bs->v1].pos, sb->bpoint[bs->v2].pos); + project_v3_v3v3(pr, vel, sp); sub_v3_v3(vel, pr); normalize_v3(vel); if (ob->softflag & OB_SB_AERO_ANGLE) { normalize_v3(sp); - Vec3PlusStVec(bs->ext_force,f*(1.0f-ABS(dot_v3v3(vel,sp))),vel); + Vec3PlusStVec(bs->ext_force, f*(1.0f-ABS(dot_v3v3(vel, sp))), vel); } else { - Vec3PlusStVec(bs->ext_force,f,vel); // to keep compatible with 2.45 release files + Vec3PlusStVec(bs->ext_force, f, vel); // to keep compatible with 2.45 release files } } /* --- springs seeing wind */ @@ -1648,12 +1648,12 @@ static void *exec_scan_for_ext_spring_forces(void *data) return NULL; } -static void sb_sfesf_threads_run(Scene *scene, struct Object *ob, float timenow,int totsprings,int *UNUSED(ptr_to_break_func(void))) +static void sb_sfesf_threads_run(Scene *scene, struct Object *ob, float timenow, int totsprings, int *UNUSED(ptr_to_break_func(void))) { ListBase *do_effector = NULL; ListBase threads; SB_thread_context *sb_threads; - int i, totthread,left,dec; + int i, totthread, left, dec; int lowsprings =100; /* wild guess .. may increase with better thread management 'above' or even be UI option sb->spawn_cf_threads_nopts */ do_effector= pdInitEffectors(scene, ob, NULL, ob->soft->effector_weights); @@ -1710,27 +1710,27 @@ static void sb_sfesf_threads_run(Scene *scene, struct Object *ob, float timenow, /* --- the spring external section*/ -static int choose_winner(float*w, float* pos,float*a,float*b,float*c,float*ca,float*cb,float*cc) +static int choose_winner(float*w, float* pos, float*a, float*b, float*c, float*ca, float*cb, float*cc) { - float mindist,cp; + float mindist, cp; int winner =1; - mindist = ABS(dot_v3v3(pos,a)); + mindist = ABS(dot_v3v3(pos, a)); - cp = ABS(dot_v3v3(pos,b)); + cp = ABS(dot_v3v3(pos, b)); if ( mindist < cp ) { mindist = cp; winner =2; } - cp = ABS(dot_v3v3(pos,c)); + cp = ABS(dot_v3v3(pos, c)); if (mindist < cp ) { mindist = cp; winner =3; } switch (winner) { - case 1: copy_v3_v3(w,ca); break; - case 2: copy_v3_v3(w,cb); break; - case 3: copy_v3_v3(w,cc); + case 1: copy_v3_v3(w, ca); break; + case 2: copy_v3_v3(w, cb); break; + case 3: copy_v3_v3(w, cc); } return(winner); } @@ -1739,12 +1739,12 @@ static int choose_winner(float*w, float* pos,float*a,float*b,float*c,float*ca,fl static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], float *damp, float force[3], unsigned int UNUSED(par_layer), struct Object *vertexowner, - float time,float vel[3], float *intrusion) + float time, float vel[3], float *intrusion) { Object *ob= NULL; GHash *hash; GHashIterator *ihash; - float nv1[3], nv2[3], nv3[3], nv4[3], edge1[3], edge2[3],d_nvect[3], dv1[3],ve[3],avel[3]={0.0,0.0,0.0}, + float nv1[3], nv2[3], nv3[3], nv4[3], edge1[3], edge2[3], d_nvect[3], dv1[3], ve[3], avel[3]={0.0, 0.0, 0.0}, vv1[3], vv2[3], vv3[3], vv4[3], coledge[3]={0.0f, 0.0f, 0.0f}, mindistedge = 1000.0f, outerforceaccu[3], innerforceaccu[3], facedist, /* n_mag, */ /* UNUSED */ force_mag_norm, minx, miny, minz, maxx, maxy, maxz, @@ -1827,11 +1827,11 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], if (mvert) { - copy_v3_v3(nv1,mvert[mface->v1].co); - copy_v3_v3(nv2,mvert[mface->v2].co); - copy_v3_v3(nv3,mvert[mface->v3].co); + copy_v3_v3(nv1, mvert[mface->v1].co); + copy_v3_v3(nv2, mvert[mface->v2].co); + copy_v3_v3(nv3, mvert[mface->v3].co); if (mface->v4) { - copy_v3_v3(nv4,mvert[mface->v4].co); + copy_v3_v3(nv4, mvert[mface->v4].co); } if (mprevvert) { @@ -1841,25 +1841,25 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], since the AABB reduced propabitlty to get here drasticallly it might be a nice tradeof CPU <--> memory */ - sub_v3_v3v3(vv1,nv1,mprevvert[mface->v1].co); - sub_v3_v3v3(vv2,nv2,mprevvert[mface->v2].co); - sub_v3_v3v3(vv3,nv3,mprevvert[mface->v3].co); + sub_v3_v3v3(vv1, nv1, mprevvert[mface->v1].co); + sub_v3_v3v3(vv2, nv2, mprevvert[mface->v2].co); + sub_v3_v3v3(vv3, nv3, mprevvert[mface->v3].co); if (mface->v4) { - sub_v3_v3v3(vv4,nv4,mprevvert[mface->v4].co); + sub_v3_v3v3(vv4, nv4, mprevvert[mface->v4].co); } - mul_v3_fl(nv1,time); - Vec3PlusStVec(nv1,(1.0f-time),mprevvert[mface->v1].co); + mul_v3_fl(nv1, time); + Vec3PlusStVec(nv1, (1.0f-time), mprevvert[mface->v1].co); - mul_v3_fl(nv2,time); - Vec3PlusStVec(nv2,(1.0f-time),mprevvert[mface->v2].co); + mul_v3_fl(nv2, time); + Vec3PlusStVec(nv2, (1.0f-time), mprevvert[mface->v2].co); - mul_v3_fl(nv3,time); - Vec3PlusStVec(nv3,(1.0f-time),mprevvert[mface->v3].co); + mul_v3_fl(nv3, time); + Vec3PlusStVec(nv3, (1.0f-time), mprevvert[mface->v3].co); if (mface->v4) { - mul_v3_fl(nv4,time); - Vec3PlusStVec(nv4,(1.0f-time),mprevvert[mface->v4].co); + mul_v3_fl(nv4, time); + Vec3PlusStVec(nv4, (1.0f-time), mprevvert[mface->v4].co); } } } @@ -1867,11 +1867,11 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], /* switch origin to be nv2*/ sub_v3_v3v3(edge1, nv1, nv2); sub_v3_v3v3(edge2, nv3, nv2); - sub_v3_v3v3(dv1,opco,nv2); /* abuse dv1 to have vertex in question at *origin* of triangle */ + sub_v3_v3v3(dv1, opco, nv2); /* abuse dv1 to have vertex in question at *origin* of triangle */ cross_v3_v3v3(d_nvect, edge2, edge1); /* n_mag = */ /* UNUSED */ normalize_v3(d_nvect); - facedist = dot_v3v3(dv1,d_nvect); + facedist = dot_v3v3(dv1, d_nvect); // so rules are // @@ -1883,16 +1883,16 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], *damp=ob->pd->pdef_sbdamp; if (facedist > 0.0f) { *damp *= (1.0f - facedist/outerfacethickness); - Vec3PlusStVec(outerforceaccu,force_mag_norm,d_nvect); + Vec3PlusStVec(outerforceaccu, force_mag_norm, d_nvect); deflected = 3; } else { - Vec3PlusStVec(innerforceaccu,force_mag_norm,d_nvect); + Vec3PlusStVec(innerforceaccu, force_mag_norm, d_nvect); if (deflected < 2) deflected = 2; } if ((mprevvert) && (*damp > 0.0f)) { - choose_winner(ve,opco,nv1,nv2,nv3,vv1,vv2,vv3); + choose_winner(ve, opco, nv1, nv2, nv3, vv1, vv2, vv3); add_v3_v3(avel, ve); cavel ++; } @@ -1904,11 +1904,11 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], /* switch origin to be nv4 */ sub_v3_v3v3(edge1, nv3, nv4); sub_v3_v3v3(edge2, nv1, nv4); - sub_v3_v3v3(dv1,opco,nv4); /* abuse dv1 to have vertex in question at *origin* of triangle */ + sub_v3_v3v3(dv1, opco, nv4); /* abuse dv1 to have vertex in question at *origin* of triangle */ cross_v3_v3v3(d_nvect, edge2, edge1); /* n_mag = */ /* UNUSED */ normalize_v3(d_nvect); - facedist = dot_v3v3(dv1,d_nvect); + facedist = dot_v3v3(dv1, d_nvect); if ((facedist > innerfacethickness) && (facedist < outerfacethickness)) { if (isect_point_tri_prism_v3(opco, nv1, nv3, nv4) ) { @@ -1918,17 +1918,17 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], *damp=ob->pd->pdef_sbdamp; if (facedist > 0.0f) { *damp *= (1.0f - facedist/outerfacethickness); - Vec3PlusStVec(outerforceaccu,force_mag_norm,d_nvect); + Vec3PlusStVec(outerforceaccu, force_mag_norm, d_nvect); deflected = 3; } else { - Vec3PlusStVec(innerforceaccu,force_mag_norm,d_nvect); + Vec3PlusStVec(innerforceaccu, force_mag_norm, d_nvect); if (deflected < 2) deflected = 2; } if ((mprevvert) && (*damp > 0.0f)) { - choose_winner(ve,opco,nv1,nv3,nv4,vv1,vv3,vv4); + choose_winner(ve, opco, nv1, nv3, nv4, vv1, vv3, vv4); add_v3_v3(avel, ve); cavel ++; } @@ -1942,46 +1942,46 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], float dist; closest_to_line_segment_v3(ve, opco, nv1, nv2); - sub_v3_v3v3(ve,opco,ve); + sub_v3_v3v3(ve, opco, ve); dist = normalize_v3(ve); if ((dist < outerfacethickness)&&(dist < mindistedge )) { - copy_v3_v3(coledge,ve); + copy_v3_v3(coledge, ve); mindistedge = dist, deflected=1; } closest_to_line_segment_v3(ve, opco, nv2, nv3); - sub_v3_v3v3(ve,opco,ve); + sub_v3_v3v3(ve, opco, ve); dist = normalize_v3(ve); if ((dist < outerfacethickness)&&(dist < mindistedge )) { - copy_v3_v3(coledge,ve); + copy_v3_v3(coledge, ve); mindistedge = dist, deflected=1; } closest_to_line_segment_v3(ve, opco, nv3, nv1); - sub_v3_v3v3(ve,opco,ve); + sub_v3_v3v3(ve, opco, ve); dist = normalize_v3(ve); if ((dist < outerfacethickness)&&(dist < mindistedge )) { - copy_v3_v3(coledge,ve); + copy_v3_v3(coledge, ve); mindistedge = dist, deflected=1; } if (mface->v4) { /* quad */ closest_to_line_segment_v3(ve, opco, nv3, nv4); - sub_v3_v3v3(ve,opco,ve); + sub_v3_v3v3(ve, opco, ve); dist = normalize_v3(ve); if ((dist < outerfacethickness)&&(dist < mindistedge )) { - copy_v3_v3(coledge,ve); + copy_v3_v3(coledge, ve); mindistedge = dist, deflected=1; } closest_to_line_segment_v3(ve, opco, nv1, nv4); - sub_v3_v3v3(ve,opco,ve); + sub_v3_v3v3(ve, opco, ve); dist = normalize_v3(ve); if ((dist < outerfacethickness)&&(dist < mindistedge )) { - copy_v3_v3(coledge,ve); + copy_v3_v3(coledge, ve); mindistedge = dist, deflected=1; } @@ -2002,7 +2002,7 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], force_mag_norm =(float)exp(-ee*mindistedge); if (mindistedge > outerfacethickness*ff) force_mag_norm =(float)force_mag_norm*fa*(mindistedge - outerfacethickness)*(mindistedge - outerfacethickness); - Vec3PlusStVec(force,force_mag_norm,coledge); + Vec3PlusStVec(force, force_mag_norm, coledge); *damp=ob->pd->pdef_sbdamp; if (mindistedge > 0.0f) { *damp *= (1.0f - mindistedge/outerfacethickness); @@ -2017,8 +2017,8 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], } BLI_ghashIterator_free(ihash); - if (cavel) mul_v3_fl(avel,1.0f/(float)cavel); - copy_v3_v3(vel,avel); + if (cavel) mul_v3_fl(avel, 1.0f/(float)cavel); + copy_v3_v3(vel, avel); if (ci) *intrusion /= ci; if (deflected) { normalize_v3_v3(facenormal, force); @@ -2028,34 +2028,34 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], /* sandbox to plug in various deflection algos */ -static int sb_deflect_face(Object *ob,float *actpos,float *facenormal,float *force,float *cf,float time,float *vel,float *intrusion) +static int sb_deflect_face(Object *ob, float *actpos, float *facenormal, float *force, float *cf, float time, float *vel, float *intrusion) { float s_actpos[3]; int deflected; - copy_v3_v3(s_actpos,actpos); - deflected= sb_detect_vertex_collisionCached(s_actpos, facenormal, cf, force , ob->lay, ob,time,vel,intrusion); - //deflected= sb_detect_vertex_collisionCachedEx(s_actpos, facenormal, cf, force , ob->lay, ob,time,vel,intrusion); + copy_v3_v3(s_actpos, actpos); + deflected= sb_detect_vertex_collisionCached(s_actpos, facenormal, cf, force, ob->lay, ob, time, vel, intrusion); + //deflected= sb_detect_vertex_collisionCachedEx(s_actpos, facenormal, cf, force, ob->lay, ob, time, vel, intrusion); return(deflected); } /* hiding this for now .. but the jacobian may pop up on other tasks .. so i'd like to keep it -static void dfdx_spring(int ia, int ic, int op, float dir[3],float L,float len,float factor) +static void dfdx_spring(int ia, int ic, int op, float dir[3], float L, float len, float factor) { - float m,delta_ij; - int i ,j; + float m, delta_ij; + int i, j; if (L < len) { for (i=0;i<3;i++) for (j=0;j<3;j++) { delta_ij = (i==j ? (1.0f): (0.0f)); m=factor*(dir[i]*dir[j] + (1-L/len)*(delta_ij - dir[i]*dir[j])); - nlMatrixAdd(ia+i,op+ic+j,m); + nlMatrixAdd(ia+i, op+ic+j, m); } } else { for (i=0;i<3;i++) for (j=0;j<3;j++) { m=factor*dir[i]*dir[j]; - nlMatrixAdd(ia+i,op+ic+j,m); + nlMatrixAdd(ia+i, op+ic+j, m); } } } @@ -2064,24 +2064,24 @@ static void dfdx_spring(int ia, int ic, int op, float dir[3],float L,float len,f static void dfdx_goal(int ia, int ic, int op, float factor) { int i; - for (i=0;i<3;i++) nlMatrixAdd(ia+i,op+ic+i,factor); + for (i=0;i<3;i++) nlMatrixAdd(ia+i, op+ic+i, factor); } -static void dfdv_goal(int ia, int ic,float factor) +static void dfdv_goal(int ia, int ic, float factor) { int i; - for (i=0;i<3;i++) nlMatrixAdd(ia+i,ic+i,factor); + for (i=0;i<3;i++) nlMatrixAdd(ia+i, ic+i, factor); } */ -static void sb_spring_force(Object *ob,int bpi,BodySpring *bs,float iks,float UNUSED(forcetime), int nl_flags) +static void sb_spring_force(Object *ob, int bpi, BodySpring *bs, float iks, float UNUSED(forcetime), int nl_flags) { SoftBody *sb= ob->soft; /* is supposed to be there */ - BodyPoint *bp1,*bp2; + BodyPoint *bp1, *bp2; - float dir[3],dvel[3]; - float distance,forcefactor,kd,absvel,projvel,kw; + float dir[3], dvel[3]; + float distance, forcefactor, kd, absvel, projvel, kw; #if 0 /* UNUSED */ - int ia,ic; + int ia, ic; #endif /* prepare depending on which side of the spring we are on */ if (bpi == bs->v1) { @@ -2108,7 +2108,7 @@ static void sb_spring_force(Object *ob,int bpi,BodySpring *bs,float iks,float UN } /* do bp1 <--> bp2 elastic */ - sub_v3_v3v3(dir,bp1->pos,bp2->pos); + sub_v3_v3v3(dir, bp1->pos, bp2->pos); distance = normalize_v3(dir); if (bs->len < distance) iks = 1.0f/(1.0f-sb->inspring)-1.0f ;/* inner spring constants function */ @@ -2138,15 +2138,15 @@ static void sb_spring_force(Object *ob,int bpi,BodySpring *bs,float iks,float UN } - Vec3PlusStVec(bp1->force,(bs->len - distance)*forcefactor,dir); + Vec3PlusStVec(bp1->force, (bs->len - distance)*forcefactor, dir); /* do bp1 <--> bp2 viscous */ - sub_v3_v3v3(dvel,bp1->vec,bp2->vec); + sub_v3_v3v3(dvel, bp1->vec, bp2->vec); kd = sb->infrict * sb_fric_force_scale(ob); absvel = normalize_v3(dvel); - projvel = dot_v3v3(dir,dvel); + projvel = dot_v3v3(dir, dvel); kd *= absvel * projvel; - Vec3PlusStVec(bp1->force,-kd,dir); + Vec3PlusStVec(bp1->force, -kd, dir); /* do jacobian stuff if needed */ if (nl_flags & NLF_BUILD) { @@ -2154,14 +2154,14 @@ static void sb_spring_force(Object *ob,int bpi,BodySpring *bs,float iks,float UN //float mvel = -forcetime*kd; //float mpos = -forcetime*forcefactor; /* depending on my pos */ - // dfdx_spring(ia,ia,op,dir,bs->len,distance,-mpos); + // dfdx_spring(ia, ia, op, dir, bs->len, distance, -mpos); /* depending on my vel */ - // dfdv_goal(ia,ia,mvel); // well that ignores geometie + // dfdv_goal(ia, ia, mvel); // well that ignores geometie if (bp2->goal < SOFTGOALSNAP) { /* ommit this bp when it snaps */ /* depending on other pos */ - // dfdx_spring(ia,ic,op,dir,bs->len,distance,mpos); + // dfdx_spring(ia, ic, op, dir, bs->len, distance, mpos); /* depending on other vel */ - // dfdv_goal(ia,ia,-mvel); // well that ignores geometie + // dfdv_goal(ia, ia, -mvel); // well that ignores geometie } } } @@ -2170,10 +2170,10 @@ static void sb_spring_force(Object *ob,int bpi,BodySpring *bs,float iks,float UN /* since this is definitely the most CPU consuming task here .. try to spread it */ /* core function _softbody_calc_forces_slice_in_a_thread */ /* result is int to be able to flag user break */ -static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, float forcetime, float timenow,int ifirst,int ilast,int *UNUSED(ptr_to_break_func(void)),ListBase *do_effector,int do_deflector,float fieldfactor, float windfactor) +static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, float forcetime, float timenow, int ifirst, int ilast, int *UNUSED(ptr_to_break_func(void)), ListBase *do_effector, int do_deflector, float fieldfactor, float windfactor) { float iks; - int bb,do_selfcollision,do_springcollision,do_aero; + int bb, do_selfcollision, do_springcollision, do_aero; int number_of_points_here = ilast - ifirst; SoftBody *sb= ob->soft; /* is supposed to be there */ BodyPoint *bp; @@ -2210,8 +2210,8 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo int attached; BodyPoint *obp; BodySpring *bs; - int c,b; - float velcenter[3],dvel[3],def[3]; + int c, b; + float velcenter[3], dvel[3], def[3]; float distance; float compare; float bstune = sb->ballstiff; @@ -2236,42 +2236,42 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo float f = bstune / (distance) + bstune / (compare * compare) * distance - 2.0f * bstune / compare; mid_v3_v3v3(velcenter, bp->vec, obp->vec); - sub_v3_v3v3(dvel,velcenter,bp->vec); - mul_v3_fl(dvel,_final_mass(ob,bp)); + sub_v3_v3v3(dvel, velcenter, bp->vec); + mul_v3_fl(dvel, _final_mass(ob, bp)); - Vec3PlusStVec(bp->force,f*(1.0f-sb->balldamp),def); - Vec3PlusStVec(bp->force,sb->balldamp,dvel); + Vec3PlusStVec(bp->force, f*(1.0f-sb->balldamp), def); + Vec3PlusStVec(bp->force, sb->balldamp, dvel); - /* exploit force(a,b) == -force(b,a) part2/2 */ - sub_v3_v3v3(dvel,velcenter,obp->vec); - mul_v3_fl(dvel,_final_mass(ob,bp)); + /* exploit force(a, b) == -force(b, a) part2/2 */ + sub_v3_v3v3(dvel, velcenter, obp->vec); + mul_v3_fl(dvel, _final_mass(ob, bp)); - Vec3PlusStVec(obp->force,sb->balldamp,dvel); - Vec3PlusStVec(obp->force,-f*(1.0f-sb->balldamp),def); + Vec3PlusStVec(obp->force, sb->balldamp, dvel); + Vec3PlusStVec(obp->force, -f*(1.0f-sb->balldamp), def); } } } } /* naive ball self collision done */ - if (_final_goal(ob,bp) < SOFTGOALSNAP) { /* ommit this bp when it snaps */ + if (_final_goal(ob, bp) < SOFTGOALSNAP) { /* ommit this bp when it snaps */ float auxvect[3]; float velgoal[3]; /* do goal stuff */ if (ob->softflag & OB_SB_GOAL) { /* true elastic goal */ - float ks,kd; - sub_v3_v3v3(auxvect,bp->pos,bp->origT); + float ks, kd; + sub_v3_v3v3(auxvect, bp->pos, bp->origT); ks = 1.0f / (1.0f - _final_goal(ob, bp) * sb->goalspring) - 1.0f; bp->force[0]+= -ks*(auxvect[0]); bp->force[1]+= -ks*(auxvect[1]); bp->force[2]+= -ks*(auxvect[2]); /* calulate damping forces generated by goals*/ - sub_v3_v3v3(velgoal,bp->origS, bp->origE); + sub_v3_v3v3(velgoal, bp->origS, bp->origE); kd = sb->goalfrict * sb_fric_force_scale(ob); - add_v3_v3v3(auxvect,velgoal,bp->vec); + add_v3_v3v3(auxvect, velgoal, bp->vec); if (forcetime > 0.0f) { /* make sure friction does not become rocket motor on time reversal */ bp->force[0]-= kd * (auxvect[0]); @@ -2290,7 +2290,7 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo if (sb && scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) { float gravity[3]; copy_v3_v3(gravity, scene->physics_settings.gravity); - mul_v3_fl(gravity, sb_grav_force_scale(ob)*_final_mass(ob,bp)*sb->effector_weights->global_gravity); /* individual mass of node here */ + mul_v3_fl(gravity, sb_grav_force_scale(ob)*_final_mass(ob, bp)*sb->effector_weights->global_gravity); /* individual mass of node here */ add_v3_v3(bp->force, gravity); } @@ -2305,7 +2305,7 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo pdDoEffectors(do_effector, NULL, sb->effector_weights, &epoint, force, speed); /* apply forcefield*/ - mul_v3_fl(force,fieldfactor* eval_sb_fric_force_scale); + mul_v3_fl(force, fieldfactor* eval_sb_fric_force_scale); add_v3_v3(bp->force, force); /* BP friction in moving media */ @@ -2330,20 +2330,20 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo bp->choke2 = 0.0f; bp->loc_flag &= ~SBF_DOFUZZY; if (do_deflector && !(bp->loc_flag & SBF_OUTOFCOLLISION) ) { - float cfforce[3],defforce[3] ={0.0f,0.0f,0.0f}, vel[3] = {0.0f,0.0f,0.0f}, facenormal[3], cf = 1.0f,intrusion; + float cfforce[3], defforce[3] ={0.0f, 0.0f, 0.0f}, vel[3] = {0.0f, 0.0f, 0.0f}, facenormal[3], cf = 1.0f, intrusion; float kd = 1.0f; - if (sb_deflect_face(ob,bp->pos,facenormal,defforce,&cf,timenow,vel,&intrusion)) { + if (sb_deflect_face(ob, bp->pos, facenormal, defforce, &cf, timenow, vel, &intrusion)) { if (intrusion < 0.0f) { sb->scratch->flag |= SBF_DOFUZZY; bp->loc_flag |= SBF_DOFUZZY; bp->choke = sb->choke*0.01f; } - sub_v3_v3v3(cfforce,bp->vec,vel); - Vec3PlusStVec(bp->force,-cf*50.0f,cfforce); + sub_v3_v3v3(cfforce, bp->vec, vel); + Vec3PlusStVec(bp->force, -cf*50.0f, cfforce); - Vec3PlusStVec(bp->force,kd,defforce); + Vec3PlusStVec(bp->force, kd, defforce); } } @@ -2363,8 +2363,8 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo bp->choke = bs->cf; } - // sb_spring_force(Object *ob,int bpi,BodySpring *bs,float iks,float forcetime,int nl_flags) - sb_spring_force(ob,ilast-bb,bs,iks,forcetime,0); + // sb_spring_force(Object *ob, int bpi, BodySpring *bs, float iks, float forcetime, int nl_flags) + sb_spring_force(ob, ilast-bb, bs, iks, forcetime, 0); }/* loop springs */ }/* existing spring list */ }/*any edges*/ @@ -2377,15 +2377,15 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo static void *exec_softbody_calc_forces(void *data) { SB_thread_context *pctx = (SB_thread_context*)data; - _softbody_calc_forces_slice_in_a_thread(pctx->scene, pctx->ob, pctx->forcetime, pctx->timenow, pctx->ifirst, pctx->ilast, NULL, pctx->do_effector,pctx->do_deflector,pctx->fieldfactor,pctx->windfactor); + _softbody_calc_forces_slice_in_a_thread(pctx->scene, pctx->ob, pctx->forcetime, pctx->timenow, pctx->ifirst, pctx->ilast, NULL, pctx->do_effector, pctx->do_deflector, pctx->fieldfactor, pctx->windfactor); return NULL; } -static void sb_cf_threads_run(Scene *scene, Object *ob, float forcetime, float timenow,int totpoint,int *UNUSED(ptr_to_break_func(void)),struct ListBase *do_effector,int do_deflector,float fieldfactor, float windfactor) +static void sb_cf_threads_run(Scene *scene, Object *ob, float forcetime, float timenow, int totpoint, int *UNUSED(ptr_to_break_func(void)), struct ListBase *do_effector, int do_deflector, float fieldfactor, float windfactor) { ListBase threads; SB_thread_context *sb_threads; - int i, totthread,left,dec; + int i, totthread, left, dec; int lowpoints =100; /* wild guess .. may increase with better thread management 'above' or even be UI option sb->spawn_cf_threads_nopts */ /* figure the number of threads while preventing pretty pointless threading overhead */ @@ -2398,7 +2398,7 @@ static void sb_cf_threads_run(Scene *scene, Object *ob, float forcetime, float t totthread--; } - /* printf("sb_cf_threads_run spawning %d threads\n",totthread); */ + /* printf("sb_cf_threads_run spawning %d threads\n", totthread); */ sb_threads= MEM_callocN(sizeof(SB_thread_context)*totthread, "SBThread"); memset(sb_threads, 0, sizeof(SB_thread_context)*totthread); @@ -2450,7 +2450,7 @@ static void softbody_calc_forcesEx(Scene *scene, Object *ob, float forcetime, fl /* float gravity; */ /* UNUSED */ /* float iks; */ float fieldfactor = -1.0f, windfactor = 0.25; - int do_deflector /*,do_selfcollision*/ ,do_springcollision,do_aero; + int do_deflector /*, do_selfcollision*/, do_springcollision, do_aero; /* gravity = sb->grav * sb_grav_force_scale(ob); */ /* UNUSED */ @@ -2464,20 +2464,20 @@ static void softbody_calc_forcesEx(Scene *scene, Object *ob, float forcetime, fl /* bproot= sb->bpoint; */ /* need this for proper spring addressing */ /* UNUSED */ if (do_springcollision || do_aero) - sb_sfesf_threads_run(scene, ob, timenow,sb->totspring,NULL); + sb_sfesf_threads_run(scene, ob, timenow, sb->totspring, NULL); /* after spring scan because it uses Effoctors too */ do_effector= pdInitEffectors(scene, ob, NULL, sb->effector_weights); if (do_deflector) { float defforce[3]; - do_deflector = sb_detect_aabb_collisionCached(defforce,ob->lay,ob,timenow); + do_deflector = sb_detect_aabb_collisionCached(defforce, ob->lay, ob, timenow); } sb_cf_threads_run(scene, ob, forcetime, timenow, sb->totpoint, NULL, do_effector, do_deflector, fieldfactor, windfactor); /* finally add forces caused by face collision */ - if (ob->softflag & OB_SB_FACECOLL) scan_for_ext_face_forces(ob,timenow); + if (ob->softflag & OB_SB_FACECOLL) scan_for_ext_face_forces(ob, timenow); /* finish matrix and solve */ pdEndEffectors(&do_effector); @@ -2510,10 +2510,10 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa /* BodyPoint *bproot; */ /* UNUSED */ BodySpring *bs; ListBase *do_effector = NULL; - float iks, ks, kd, gravity[3] = {0.0f,0.0f,0.0f}; + float iks, ks, kd, gravity[3] = {0.0f, 0.0f, 0.0f}; float fieldfactor = -1.0f, windfactor = 0.25f; float tune = sb->ballstiff; - int a, b, do_deflector,do_selfcollision,do_springcollision,do_aero; + int a, b, do_deflector, do_selfcollision, do_springcollision, do_aero; /* jacobian @@ -2546,7 +2546,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa if (do_deflector) { float defforce[3]; - do_deflector = sb_detect_aabb_collisionCached(defforce,ob->lay,ob,timenow); + do_deflector = sb_detect_aabb_collisionCached(defforce, ob->lay, ob, timenow); } for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) { @@ -2557,17 +2557,17 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa //int op =3*sb->totpoint; /* dF/dV = v */ /* jacobioan - nlMatrixAdd(op+ia,ia,-forcetime); - nlMatrixAdd(op+ia+1,ia+1,-forcetime); - nlMatrixAdd(op+ia+2,ia+2,-forcetime); + nlMatrixAdd(op+ia, ia, -forcetime); + nlMatrixAdd(op+ia+1, ia+1, -forcetime); + nlMatrixAdd(op+ia+2, ia+2, -forcetime); - nlMatrixAdd(ia,ia,1); - nlMatrixAdd(ia+1,ia+1,1); - nlMatrixAdd(ia+2,ia+2,1); + nlMatrixAdd(ia, ia, 1); + nlMatrixAdd(ia+1, ia+1, 1); + nlMatrixAdd(ia+2, ia+2, 1); - nlMatrixAdd(op+ia,op+ia,1); - nlMatrixAdd(op+ia+1,op+ia+1,1); - nlMatrixAdd(op+ia+2,op+ia+2,1); + nlMatrixAdd(op+ia, op+ia, 1); + nlMatrixAdd(op+ia+1, op+ia+1, 1); + nlMatrixAdd(op+ia+2, op+ia+2, 1); */ @@ -2578,8 +2578,8 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa if (do_selfcollision) { int attached; BodyPoint *obp; - int c,b; - float velcenter[3],dvel[3],def[3]; + int c, b; + float velcenter[3], dvel[3], def[3]; float distance; float compare; @@ -2608,11 +2608,11 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa float f = tune / (distance) + tune / (compare * compare) * distance - 2.0f * tune/compare; mid_v3_v3v3(velcenter, bp->vec, obp->vec); - sub_v3_v3v3(dvel,velcenter,bp->vec); - mul_v3_fl(dvel,_final_mass(ob,bp)); + sub_v3_v3v3(dvel, velcenter, bp->vec); + mul_v3_fl(dvel, _final_mass(ob, bp)); - Vec3PlusStVec(bp->force,f*(1.0f-sb->balldamp),def); - Vec3PlusStVec(bp->force,sb->balldamp,dvel); + Vec3PlusStVec(bp->force, f*(1.0f-sb->balldamp), def); + Vec3PlusStVec(bp->force, sb->balldamp, dvel); if (nl_flags & NLF_BUILD) { //int ia =3*(sb->totpoint-a); @@ -2621,11 +2621,11 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa //float mvel = forcetime*sb->nodemass*sb->balldamp; //float mpos = forcetime*tune*(1.0f-sb->balldamp); /*some quick and dirty entries to the jacobian*/ - //dfdx_goal(ia,ia,op,mpos); - //dfdv_goal(ia,ia,mvel); - /* exploit force(a,b) == -force(b,a) part1/2 */ - //dfdx_goal(ic,ic,op,mpos); - //dfdv_goal(ic,ic,mvel); + //dfdx_goal(ia, ia, op, mpos); + //dfdv_goal(ia, ia, mvel); + /* exploit force(a, b) == -force(b, a) part1/2 */ + //dfdx_goal(ic, ic, op, mpos); + //dfdv_goal(ic, ic, mvel); /*TODO sit down an X-out the true jacobian entries*/ @@ -2638,12 +2638,12 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa */ } - /* exploit force(a,b) == -force(b,a) part2/2 */ - sub_v3_v3v3(dvel,velcenter,obp->vec); - mul_v3_fl(dvel,(_final_mass(ob,bp)+_final_mass(ob,obp))/2.0f); + /* exploit force(a, b) == -force(b, a) part2/2 */ + sub_v3_v3v3(dvel, velcenter, obp->vec); + mul_v3_fl(dvel, (_final_mass(ob, bp)+_final_mass(ob, obp))/2.0f); - Vec3PlusStVec(obp->force,sb->balldamp,dvel); - Vec3PlusStVec(obp->force,-f*(1.0f-sb->balldamp),def); + Vec3PlusStVec(obp->force, sb->balldamp, dvel); + Vec3PlusStVec(obp->force, -f*(1.0f-sb->balldamp), def); } @@ -2652,14 +2652,14 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa } /* naive ball self collision done */ - if (_final_goal(ob,bp) < SOFTGOALSNAP) { /* ommit this bp when it snaps */ + if (_final_goal(ob, bp) < SOFTGOALSNAP) { /* ommit this bp when it snaps */ float auxvect[3]; float velgoal[3]; /* do goal stuff */ if (ob->softflag & OB_SB_GOAL) { /* true elastic goal */ - sub_v3_v3v3(auxvect,bp->pos,bp->origT); + sub_v3_v3v3(auxvect, bp->pos, bp->origT); ks = 1.0f / (1.0f- _final_goal(ob, bp) * sb->goalspring) - 1.0f; bp->force[0]+= -ks*(auxvect[0]); bp->force[1]+= -ks*(auxvect[1]); @@ -2669,14 +2669,14 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa //int ia =3*(sb->totpoint-a); //int op =3*(sb->totpoint); /* depending on my pos */ - //dfdx_goal(ia,ia,op,ks*forcetime); + //dfdx_goal(ia, ia, op, ks*forcetime); } /* calulate damping forces generated by goals*/ - sub_v3_v3v3(velgoal,bp->origS, bp->origE); + sub_v3_v3v3(velgoal, bp->origS, bp->origE); kd = sb->goalfrict * sb_fric_force_scale(ob); - add_v3_v3v3(auxvect,velgoal,bp->vec); + add_v3_v3v3(auxvect, velgoal, bp->vec); if (forcetime > 0.0f) { /* make sure friction does not become rocket motor on time reversal */ bp->force[0]-= kd * (auxvect[0]); @@ -2686,7 +2686,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa //int ia =3*(sb->totpoint-a); normalize_v3(auxvect); /* depending on my vel */ - //dfdv_goal(ia,ia,kd*forcetime); + //dfdv_goal(ia, ia, kd*forcetime); } } @@ -2700,7 +2700,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa /* gravitation */ - madd_v3_v3fl(bp->force, gravity, _final_mass(ob,bp)); /* individual mass of node here */ + madd_v3_v3fl(bp->force, gravity, _final_mass(ob, bp)); /* individual mass of node here */ /* particle field & vortex */ @@ -2713,7 +2713,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa pdDoEffectors(do_effector, NULL, sb->effector_weights, &epoint, force, speed); /* apply forcefield*/ - mul_v3_fl(force,fieldfactor* eval_sb_fric_force_scale); + mul_v3_fl(force, fieldfactor* eval_sb_fric_force_scale); add_v3_v3(bp->force, force); /* BP friction in moving media */ @@ -2736,9 +2736,9 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa //int ia =3*(sb->totpoint-a); /* da/dv = */ - // nlMatrixAdd(ia,ia,forcetime*kd); - // nlMatrixAdd(ia+1,ia+1,forcetime*kd); - // nlMatrixAdd(ia+2,ia+2,forcetime*kd); + // nlMatrixAdd(ia, ia, forcetime*kd); + // nlMatrixAdd(ia+1, ia+1, forcetime*kd); + // nlMatrixAdd(ia+2, ia+2, forcetime*kd); } } @@ -2747,10 +2747,10 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa bp->choke2 = 0.0f; bp->loc_flag &= ~SBF_DOFUZZY; if (do_deflector) { - float cfforce[3],defforce[3] ={0.0f,0.0f,0.0f}, vel[3] = {0.0f,0.0f,0.0f}, facenormal[3], cf = 1.0f,intrusion; + float cfforce[3], defforce[3] ={0.0f, 0.0f, 0.0f}, vel[3] = {0.0f, 0.0f, 0.0f}, facenormal[3], cf = 1.0f, intrusion; kd = 1.0f; - if (sb_deflect_face(ob,bp->pos,facenormal,defforce,&cf,timenow,vel,&intrusion)) { + if (sb_deflect_face(ob, bp->pos, facenormal, defforce, &cf, timenow, vel, &intrusion)) { if ((!nl_flags)&&(intrusion < 0.0f)) { if (G.rt & 0x01) { // 17 we did check for bit 0x10 before /*fixing bug [17428] this forces adaptive step size to tiny steps @@ -2763,12 +2763,12 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa in heun step No1 and leave the heun step No2 adapt to it so we kind of introduced a implicit solver for this case */ - Vec3PlusStVec(bp->pos,-intrusion,facenormal); + Vec3PlusStVec(bp->pos, -intrusion, facenormal); } else { - sub_v3_v3v3(cfforce,bp->vec,vel); - Vec3PlusStVec(bp->force,-cf*50.0f,cfforce); + sub_v3_v3v3(cfforce, bp->vec, vel); + Vec3PlusStVec(bp->force, -cf*50.0f, cfforce); } @@ -2777,15 +2777,15 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa bp->choke = sb->choke*0.01f; } else { - sub_v3_v3v3(cfforce,bp->vec,vel); - Vec3PlusStVec(bp->force,-cf*50.0f,cfforce); + sub_v3_v3v3(cfforce, bp->vec, vel); + Vec3PlusStVec(bp->force, -cf*50.0f, cfforce); } - Vec3PlusStVec(bp->force,kd,defforce); + Vec3PlusStVec(bp->force, kd, defforce); if (nl_flags & NLF_BUILD) { // int ia =3*(sb->totpoint-a); // int op =3*sb->totpoint; - //dfdx_goal(ia,ia,op,mpos); // don't do unless you know - //dfdv_goal(ia,ia,-cf); + //dfdx_goal(ia, ia, op, mpos); // don't do unless you know + //dfdv_goal(ia, ia, -cf); } @@ -2805,9 +2805,9 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa bp->choke = bs->cf; } - // sb_spring_force(Object *ob,int bpi,BodySpring *bs,float iks,float forcetime,int nl_flags) + // sb_spring_force(Object *ob, int bpi, BodySpring *bs, float iks, float forcetime, int nl_flags) // rather remove nl_falgs from code .. will make things a lot cleaner - sb_spring_force(ob,sb->totpoint-a,bs,iks,forcetime,0); + sb_spring_force(ob, sb->totpoint-a, bs, iks, forcetime, 0); }/* loop springs */ }/* existing spring list */ }/*any edges*/ @@ -2817,12 +2817,12 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa /* finally add forces caused by face collision */ - if (ob->softflag & OB_SB_FACECOLL) scan_for_ext_face_forces(ob,timenow); + if (ob->softflag & OB_SB_FACECOLL) scan_for_ext_face_forces(ob, timenow); /* finish matrix and solve */ #if (0) // remove onl linking for now .. still i am not sure .. the jacobian can be useful .. so keep that BM if (nl_flags & NLF_SOLVE) { - //double sct,sst=PIL_check_seconds_timer(); + //double sct, sst=PIL_check_seconds_timer(); for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) { int iv =3*(sb->totpoint-a); int ip =3*(2*sb->totpoint-a); @@ -2847,30 +2847,30 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa /* for debug purpose .. anyhow cropping B vector looks like working */ if (G.rt ==32) for (a=2*sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) { - f=nlGetVariable(0,index); - printf("(%f ",f);index++; - f=nlGetVariable(0,index); - printf("%f ",f);index++; - f=nlGetVariable(0,index); - printf("%f)",f);index++; + f=nlGetVariable(0, index); + printf("(%f ", f);index++; + f=nlGetVariable(0, index); + printf("%f ", f);index++; + f=nlGetVariable(0, index); + printf("%f)", f);index++; } index =0; for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) { - f=nlGetVariable(0,index); + f=nlGetVariable(0, index); bp->impdv[0] = f; index++; - f=nlGetVariable(0,index); + f=nlGetVariable(0, index); bp->impdv[1] = f; index++; - f=nlGetVariable(0,index); + f=nlGetVariable(0, index); bp->impdv[2] = f; index++; } /* for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) { - f=nlGetVariable(0,index); + f=nlGetVariable(0, index); bp->impdx[0] = f; index++; - f=nlGetVariable(0,index); + f=nlGetVariable(0, index); bp->impdx[1] = f; index++; - f=nlGetVariable(0,index); + f=nlGetVariable(0, index); bp->impdx[2] = f; index++; } */ @@ -2878,13 +2878,13 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa else { printf("Matrix inversion failed\n"); for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) { - copy_v3_v3(bp->impdv,bp->force); + copy_v3_v3(bp->impdv, bp->force); } } //sct=PIL_check_seconds_timer(); - //if (sct-sst > 0.01f) printf(" implicit solver time %f %s \r",sct-sst,ob->id.name); + //if (sct-sst > 0.01f) printf(" implicit solver time %f %s \r", sct-sst, ob->id.name); } /* cleanup */ #endif @@ -2896,13 +2896,13 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float * { /* time evolution */ /* actually does an explicit euler step mode == 0 */ - /* or heun ~ 2nd order runge-kutta steps, mode 1,2 */ + /* or heun ~ 2nd order runge-kutta steps, mode 1, 2 */ SoftBody *sb= ob->soft; /* is supposed to be there */ BodyPoint *bp; - float dx[3]={0},dv[3],aabbmin[3],aabbmax[3],cm[3]={0.0f,0.0f,0.0f}; - float timeovermass/*,freezeloc=0.00001f,freezeforce=0.00000000001f*/; - float maxerrpos= 0.0f,maxerrvel = 0.0f; - int a,fuzzy=0; + float dx[3]={0}, dv[3], aabbmin[3], aabbmax[3], cm[3]={0.0f, 0.0f, 0.0f}; + float timeovermass/*, freezeloc=0.00001f, freezeforce=0.00000000001f*/; + float maxerrpos= 0.0f, maxerrvel = 0.0f; + int a, fuzzy=0; forcetime *= sb_time_scale(ob); @@ -2919,21 +2919,21 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float * for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) { /* now we have individual masses */ /* claim a minimum mass for vertex */ - if (_final_mass(ob,bp) > 0.009999f) timeovermass = forcetime/_final_mass(ob,bp); + if (_final_mass(ob, bp) > 0.009999f) timeovermass = forcetime/_final_mass(ob, bp); else timeovermass = forcetime/0.009999f; - if (_final_goal(ob,bp) < SOFTGOALSNAP) { + if (_final_goal(ob, bp) < SOFTGOALSNAP) { /* this makes t~ = t */ - if (mid_flags & MID_PRESERVE) copy_v3_v3(dx,bp->vec); + if (mid_flags & MID_PRESERVE) copy_v3_v3(dx, bp->vec); /* so here is (v)' = a(cceleration) = sum(F_springs)/m + gravitation + some friction forces + more forces*/ /* the ( ... )' operator denotes derivate respective time */ /* the euler step for velocity then becomes */ /* v(t + dt) = v(t) + a(t) * dt */ - mul_v3_fl(bp->force,timeovermass);/* individual mass of node here */ + mul_v3_fl(bp->force, timeovermass);/* individual mass of node here */ /* some nasty if's to have heun in here too */ - copy_v3_v3(dv,bp->force); + copy_v3_v3(dv, bp->force); if (mode == 1) { copy_v3_v3(bp->prevvec, bp->vec); @@ -2946,80 +2946,80 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float * bp->vec[1] = bp->prevvec[1] + 0.5f * (dv[1] + bp->prevdv[1]); bp->vec[2] = bp->prevvec[2] + 0.5f * (dv[2] + bp->prevdv[2]); /* compare euler to heun to estimate error for step sizing */ - maxerrvel = MAX2(maxerrvel,ABS(dv[0] - bp->prevdv[0])); - maxerrvel = MAX2(maxerrvel,ABS(dv[1] - bp->prevdv[1])); - maxerrvel = MAX2(maxerrvel,ABS(dv[2] - bp->prevdv[2])); + maxerrvel = MAX2(maxerrvel, ABS(dv[0] - bp->prevdv[0])); + maxerrvel = MAX2(maxerrvel, ABS(dv[1] - bp->prevdv[1])); + maxerrvel = MAX2(maxerrvel, ABS(dv[2] - bp->prevdv[2])); } else { add_v3_v3(bp->vec, bp->force); } /* this makes t~ = t+dt */ - if (!(mid_flags & MID_PRESERVE)) copy_v3_v3(dx,bp->vec); + if (!(mid_flags & MID_PRESERVE)) copy_v3_v3(dx, bp->vec); /* so here is (x)'= v(elocity) */ /* the euler step for location then becomes */ /* x(t + dt) = x(t) + v(t~) * dt */ - mul_v3_fl(dx,forcetime); + mul_v3_fl(dx, forcetime); /* the freezer coming sooner or later */ /* - if ((dot_v3v3(dx,dx)<freezeloc )&&(dot_v3v3(bp->force,bp->force)<freezeforce )) { + if ((dot_v3v3(dx, dx)<freezeloc )&&(dot_v3v3(bp->force, bp->force)<freezeforce )) { bp->frozen /=2; } else { - bp->frozen = MIN2(bp->frozen*1.05f,1.0f); + bp->frozen = MIN2(bp->frozen*1.05f, 1.0f); } - mul_v3_fl(dx,bp->frozen); + mul_v3_fl(dx, bp->frozen); */ /* again some nasty if's to have heun in here too */ if (mode ==1) { - copy_v3_v3(bp->prevpos,bp->pos); - copy_v3_v3(bp->prevdx ,dx); + copy_v3_v3(bp->prevpos, bp->pos); + copy_v3_v3(bp->prevdx, dx); } if (mode ==2) { bp->pos[0] = bp->prevpos[0] + 0.5f * ( dx[0] + bp->prevdx[0]); bp->pos[1] = bp->prevpos[1] + 0.5f * ( dx[1] + bp->prevdx[1]); bp->pos[2] = bp->prevpos[2] + 0.5f * ( dx[2] + bp->prevdx[2]); - maxerrpos = MAX2(maxerrpos,ABS(dx[0] - bp->prevdx[0])); - maxerrpos = MAX2(maxerrpos,ABS(dx[1] - bp->prevdx[1])); - maxerrpos = MAX2(maxerrpos,ABS(dx[2] - bp->prevdx[2])); - -/* bp->choke is set when we need to pull a vertex or edge out of the collider. - the collider object signals to get out by pushing hard. on the other hand - we don't want to end up in deep space so we add some <viscosity> - to balance that out */ + maxerrpos = MAX2(maxerrpos, ABS(dx[0] - bp->prevdx[0])); + maxerrpos = MAX2(maxerrpos, ABS(dx[1] - bp->prevdx[1])); + maxerrpos = MAX2(maxerrpos, ABS(dx[2] - bp->prevdx[2])); + + /* bp->choke is set when we need to pull a vertex or edge out of the collider. + * the collider object signals to get out by pushing hard. on the other hand + * we don't want to end up in deep space so we add some <viscosity> + * to balance that out */ if (bp->choke2 > 0.0f) { - mul_v3_fl(bp->vec,(1.0f - bp->choke2)); + mul_v3_fl(bp->vec, (1.0f - bp->choke2)); } if (bp->choke > 0.0f) { - mul_v3_fl(bp->vec,(1.0f - bp->choke)); + mul_v3_fl(bp->vec, (1.0f - bp->choke)); } } else { add_v3_v3(bp->pos, dx);} }/*snap*/ /* so while we are looping BPs anyway do statistics on the fly */ - aabbmin[0] = MIN2(aabbmin[0],bp->pos[0]); - aabbmin[1] = MIN2(aabbmin[1],bp->pos[1]); - aabbmin[2] = MIN2(aabbmin[2],bp->pos[2]); - aabbmax[0] = MAX2(aabbmax[0],bp->pos[0]); - aabbmax[1] = MAX2(aabbmax[1],bp->pos[1]); - aabbmax[2] = MAX2(aabbmax[2],bp->pos[2]); + aabbmin[0] = MIN2(aabbmin[0], bp->pos[0]); + aabbmin[1] = MIN2(aabbmin[1], bp->pos[1]); + aabbmin[2] = MIN2(aabbmin[2], bp->pos[2]); + aabbmax[0] = MAX2(aabbmax[0], bp->pos[0]); + aabbmax[1] = MAX2(aabbmax[1], bp->pos[1]); + aabbmax[2] = MAX2(aabbmax[2], bp->pos[2]); if (bp->loc_flag & SBF_DOFUZZY) fuzzy =1; } /*for*/ - if (sb->totpoint) mul_v3_fl(cm,1.0f/sb->totpoint); + if (sb->totpoint) mul_v3_fl(cm, 1.0f/sb->totpoint); if (sb->scratch) { - copy_v3_v3(sb->scratch->aabbmin,aabbmin); - copy_v3_v3(sb->scratch->aabbmax,aabbmax); + copy_v3_v3(sb->scratch->aabbmin, aabbmin); + copy_v3_v3(sb->scratch->aabbmax, aabbmax); } if (err) { /* so step size will be controlled by biggest difference in slope */ if (sb->solverflags & SBSO_OLDERR) - *err = MAX2(maxerrpos,maxerrvel); + *err = MAX2(maxerrpos, maxerrvel); else *err = maxerrpos; - //printf("EP %f EV %f\n",maxerrpos,maxerrvel); + //printf("EP %f EV %f\n", maxerrpos, maxerrvel); if (fuzzy) { *err /= sb->fuzzyness; } @@ -3047,19 +3047,19 @@ static void softbody_store_step(Object *ob) int a; for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) { - copy_v3_v3(bp->prevvec,bp->vec); - copy_v3_v3(bp->prevpos,bp->pos); + copy_v3_v3(bp->prevvec, bp->vec); + copy_v3_v3(bp->prevpos, bp->pos); } } /* used by predictors and correctors */ -static void softbody_store_state(Object *ob,float *ppos,float *pvel) +static void softbody_store_state(Object *ob, float *ppos, float *pvel) { SoftBody *sb= ob->soft; /* is supposed to be there*/ BodyPoint *bp; int a; - float *pp=ppos,*pv=pvel; + float *pp=ppos, *pv=pvel; for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) { @@ -3072,42 +3072,42 @@ static void softbody_store_state(Object *ob,float *ppos,float *pvel) } /* used by predictors and correctors */ -static void softbody_retrieve_state(Object *ob,float *ppos,float *pvel) +static void softbody_retrieve_state(Object *ob, float *ppos, float *pvel) { SoftBody *sb= ob->soft; /* is supposed to be there*/ BodyPoint *bp; int a; - float *pp=ppos,*pv=pvel; + float *pp=ppos, *pv=pvel; for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) { - copy_v3_v3(bp->vec,pv); + copy_v3_v3(bp->vec, pv); pv+=3; - copy_v3_v3(bp->pos,pp); + copy_v3_v3(bp->pos, pp); pp+=3; } } /* used by predictors and correctors */ -static void softbody_swap_state(Object *ob,float *ppos,float *pvel) +static void softbody_swap_state(Object *ob, float *ppos, float *pvel) { SoftBody *sb= ob->soft; /* is supposed to be there*/ BodyPoint *bp; int a; - float *pp=ppos,*pv=pvel; + float *pp=ppos, *pv=pvel; float temp[3]; for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) { copy_v3_v3(temp, bp->vec); - copy_v3_v3(bp->vec,pv); - copy_v3_v3(pv,temp); + copy_v3_v3(bp->vec, pv); + copy_v3_v3(pv, temp); pv+=3; copy_v3_v3(temp, bp->pos); - copy_v3_v3(bp->pos,pp); - copy_v3_v3(pp,temp); + copy_v3_v3(bp->pos, pp); + copy_v3_v3(pp, temp); pp+=3; } } @@ -3127,9 +3127,9 @@ static void softbody_apply_goalsnap(Object *ob) int a; for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) { - if (_final_goal(ob,bp) >= SOFTGOALSNAP) { - copy_v3_v3(bp->prevpos,bp->pos); - copy_v3_v3(bp->pos,bp->origT); + if (_final_goal(ob, bp) >= SOFTGOALSNAP) { + copy_v3_v3(bp->prevpos, bp->pos); + copy_v3_v3(bp->pos, bp->origT); } } } @@ -3141,7 +3141,7 @@ static void apply_spring_memory(Object *ob) BodySpring *bs; BodyPoint *bp1, *bp2; int a; - float b,l,r; + float b, l, r; if (sb && sb->totspring) { b = sb->plastic; @@ -3149,7 +3149,7 @@ static void apply_spring_memory(Object *ob) bs = &sb->bspring[a]; bp1 =&sb->bpoint[bs->v1]; bp2 =&sb->bpoint[bs->v2]; - l = len_v3v3(bp1->pos,bp2->pos); + l = len_v3v3(bp1->pos, bp2->pos); r = bs->len/l; if (( r > 1.05f) || (r < 0.95f)) { bs->len = ((100.0f - b) * bs->len + b*l)/100.0f; @@ -3172,7 +3172,7 @@ static void interpolate_exciter(Object *ob, int timescale, int time) bp->origT[0] = bp->origS[0] + f*(bp->origE[0] - bp->origS[0]); bp->origT[1] = bp->origS[1] + f*(bp->origE[1] - bp->origS[1]); bp->origT[2] = bp->origS[2] + f*(bp->origE[2] - bp->origS[2]); - if (_final_goal(ob,bp) >= SOFTGOALSNAP) { + if (_final_goal(ob, bp) >= SOFTGOALSNAP) { bp->vec[0] = bp->origE[0] - bp->origS[0]; bp->vec[1] = bp->origE[1] - bp->origS[1]; bp->vec[2] = bp->origE[2] - bp->origS[2]; @@ -3268,7 +3268,9 @@ static void mesh_to_softbody(Scene *scene, Object *ob) BodyPoint *bp; BodySpring *bs; int a, totedge; - BKE_mesh_tessface_ensure(me); + + BKE_mesh_tessface_ensure(me); + if (ob->softflag & OB_SB_EDGES) totedge= me->totedge; else totedge= 0; @@ -3289,7 +3291,7 @@ static void mesh_to_softbody(Scene *scene, Object *ob) if ((ob->softflag & OB_SB_GOAL) && sb->vertgroup) { /* even this is a deprecated evil hack */ /* I'd like to have it .. if (sb->namedVG_Goal[0]) */ - get_scalar_from_vertexgroup(ob, a,(short) (sb->vertgroup-1), &bp->goal); + get_scalar_from_vertexgroup(ob, a, (short) (sb->vertgroup-1), &bp->goal); /* do this always, regardless successfull read from vertex group */ /* this is where '2.5 every thing is animatable' goes wrong in the first place jow_go_for2_5 */ /* 1st coding action to take : move this to frame level */ @@ -3308,12 +3310,12 @@ static void mesh_to_softbody(Scene *scene, Object *ob) */ if (sb->namedVG_Mass[0]) { - int grp= defgroup_name_index (ob,sb->namedVG_Mass); - /* printf("VGN %s %d\n",sb->namedVG_Mass,grp); */ + int grp= defgroup_name_index (ob, sb->namedVG_Mass); + /* printf("VGN %s %d\n", sb->namedVG_Mass, grp); */ if (grp > -1) { - get_scalar_from_vertexgroup(ob, a,(short) (grp), &bp->mass); + get_scalar_from_vertexgroup(ob, a, (short) (grp), &bp->mass); /* 2.5 bp->mass = bp->mass * sb->nodemass; */ - /* printf("bp->mass %f\n",bp->mass); */ + /* printf("bp->mass %f\n", bp->mass); */ } } @@ -3321,11 +3323,11 @@ static void mesh_to_softbody(Scene *scene, Object *ob) bp->springweight = 1.0f; if (sb->namedVG_Spring_K[0]) { - int grp= defgroup_name_index (ob,sb->namedVG_Spring_K); - //printf("VGN %s %d\n",sb->namedVG_Spring_K,grp); + int grp= defgroup_name_index (ob, sb->namedVG_Spring_K); + //printf("VGN %s %d\n", sb->namedVG_Spring_K, grp); if (grp > -1) { - get_scalar_from_vertexgroup(ob, a,(short) (grp), &bp->springweight); - //printf("bp->springweight %f\n",bp->springweight); + get_scalar_from_vertexgroup(ob, a, (short) (grp), &bp->springweight); + //printf("bp->springweight %f\n", bp->springweight); } } @@ -3352,7 +3354,7 @@ static void mesh_to_softbody(Scene *scene, Object *ob) build_bps_springlist(ob); /* scan for springs attached to bodypoints ONCE */ /* insert *other second order* springs if desired */ if (sb->secondspring > 0.0000001f) { - add_2nd_order_springs(ob,sb->secondspring); /* exploits the the first run of build_bps_springlist(ob);*/ + add_2nd_order_springs(ob, sb->secondspring); /* exploits the the first run of build_bps_springlist(ob);*/ build_bps_springlist(ob); /* yes we need to do it again*/ } springs_from_mesh(ob); /* write the 'rest'-length of the springs */ @@ -3373,8 +3375,8 @@ static void mesh_faces_to_scratch(Object *ob) int a; /* alloc and copy faces*/ - bodyface = sb->scratch->bodyface = MEM_mallocN(sizeof(BodyFace)*me->totface,"SB_body_Faces"); - //memcpy(sb->scratch->mface,me->mface,sizeof(MFace)*me->totface); + bodyface = sb->scratch->bodyface = MEM_mallocN(sizeof(BodyFace)*me->totface, "SB_body_Faces"); + //memcpy(sb->scratch->mface, me->mface, sizeof(MFace)*me->totface); mface = me->mface; for (a=0; a<me->totface; a++, mface++, bodyface++) { bodyface->v1 = mface->v1; @@ -3391,20 +3393,20 @@ static void reference_to_scratch(Object *ob) SoftBody *sb= ob->soft; ReferenceVert *rp; BodyPoint *bp; - float accu_pos[3] ={0.f,0.f,0.f}; + float accu_pos[3] ={0.f, 0.f, 0.f}; float accu_mass = 0.f; int a; - sb->scratch->Ref.ivert = MEM_mallocN(sizeof(ReferenceVert)*sb->totpoint,"SB_Reference"); + sb->scratch->Ref.ivert = MEM_mallocN(sizeof(ReferenceVert)*sb->totpoint, "SB_Reference"); bp= ob->soft->bpoint; rp= sb->scratch->Ref.ivert; for (a=0; a<sb->totpoint; a++, rp++, bp++) { - copy_v3_v3(rp->pos,bp->pos); + copy_v3_v3(rp->pos, bp->pos); add_v3_v3(accu_pos, bp->pos); - accu_mass += _final_mass(ob,bp); + accu_mass += _final_mass(ob, bp); } - mul_v3_fl(accu_pos,1.0f/accu_mass); - copy_v3_v3(sb->scratch->Ref.com,accu_pos); + mul_v3_fl(accu_pos, 1.0f/accu_mass); + copy_v3_v3(sb->scratch->Ref.com, accu_pos); /* printf("reference_to_scratch\n"); */ } @@ -3412,17 +3414,17 @@ static void reference_to_scratch(Object *ob) helper function to get proper spring length when object is rescaled */ -static float globallen(float *v1,float *v2,Object *ob) +static float globallen(float *v1, float *v2, Object *ob) { - float p1[3],p2[3]; - copy_v3_v3(p1,v1); + float p1[3], p2[3]; + copy_v3_v3(p1, v1); mul_m4_v3(ob->obmat, p1); - copy_v3_v3(p2,v2); + copy_v3_v3(p2, v2); mul_m4_v3(ob->obmat, p2); - return len_v3v3(p1,p2); + return len_v3v3(p1, p2); } -static void makelatticesprings(Lattice *lt, BodySpring *bs, int dostiff,Object *ob) +static void makelatticesprings(Lattice *lt, BodySpring *bs, int dostiff, Object *ob) { BPoint *bp=lt->def, *bpu; int u, v, w, dv, dw, bpc=0, bpuc; @@ -3440,21 +3442,21 @@ static void makelatticesprings(Lattice *lt, BodySpring *bs, int dostiff,Object * bs->v1 = bpc; bs->v2 = bpc-dw; bs->springtype=SB_EDGE; - bs->len= globallen((bp-dw)->vec, bp->vec,ob); + bs->len= globallen((bp-dw)->vec, bp->vec, ob); bs++; } if (v) { bs->v1 = bpc; bs->v2 = bpc-dv; bs->springtype=SB_EDGE; - bs->len= globallen((bp-dv)->vec, bp->vec,ob); + bs->len= globallen((bp-dv)->vec, bp->vec, ob); bs++; } if (u) { bs->v1 = bpuc; bs->v2 = bpc; bs->springtype=SB_EDGE; - bs->len= globallen((bpu)->vec, bp->vec,ob); + bs->len= globallen((bpu)->vec, bp->vec, ob); bs++; } @@ -3465,14 +3467,14 @@ static void makelatticesprings(Lattice *lt, BodySpring *bs, int dostiff,Object * bs->v1 = bpc; bs->v2 = bpc-dw-dv-1; bs->springtype=SB_BEND; - bs->len= globallen((bp-dw-dv-1)->vec, bp->vec,ob); + bs->len= globallen((bp-dw-dv-1)->vec, bp->vec, ob); bs++; } if ( (v < lt->pntsv-1) && (u != 0) ) { bs->v1 = bpc; bs->v2 = bpc-dw+dv-1; bs->springtype=SB_BEND; - bs->len= globallen((bp-dw+dv-1)->vec, bp->vec,ob); + bs->len= globallen((bp-dw+dv-1)->vec, bp->vec, ob); bs++; } } @@ -3482,14 +3484,14 @@ static void makelatticesprings(Lattice *lt, BodySpring *bs, int dostiff,Object * bs->v1 = bpc; bs->v2 = bpc+dw-dv-1; bs->springtype=SB_BEND; - bs->len= globallen((bp+dw-dv-1)->vec, bp->vec,ob); + bs->len= globallen((bp+dw-dv-1)->vec, bp->vec, ob); bs++; } if ( (v < lt->pntsv-1) && (u != 0) ) { bs->v1 = bpc; bs->v2 = bpc+dw+dv-1; bs->springtype=SB_BEND; - bs->len= globallen((bp+dw+dv-1)->vec, bp->vec,ob); + bs->len= globallen((bp+dw+dv-1)->vec, bp->vec, ob); bs++; } } @@ -3541,7 +3543,7 @@ static void lattice_to_softbody(Scene *scene, Object *ob) /* create some helper edges to enable SB lattice to be useful at all */ if (ob->softflag & OB_SB_EDGES) { - makelatticesprings(lt,ob->soft->bspring,ob->softflag & OB_SB_QUADS,ob); + makelatticesprings(lt, ob->soft->bspring, ob->softflag & OB_SB_QUADS, ob); build_bps_springlist(ob); /* link bps to springs */ } } @@ -3604,19 +3606,19 @@ static void curve_surf_to_softbody(Scene *scene, Object *ob) bs->v1= curindex-3; bs->v2= curindex; bs->springtype=SB_HANDLE; - bs->len= globallen( (bezt-1)->vec[0], bezt->vec[0], ob ); + bs->len = globallen((bezt-1)->vec[0], bezt->vec[0], ob); bs++; } bs->v1= curindex; bs->v2= curindex+1; bs->springtype=SB_HANDLE; - bs->len= globallen(bezt->vec[0], bezt->vec[1], ob); + bs->len = globallen(bezt->vec[0], bezt->vec[1], ob); bs++; bs->v1= curindex+1; bs->v2= curindex+2; bs->springtype=SB_HANDLE; - bs->len= globallen(bezt->vec[1], bezt->vec[2], ob); + bs->len = globallen(bezt->vec[1], bezt->vec[2], ob); bs++; } } @@ -3630,7 +3632,7 @@ static void curve_surf_to_softbody(Scene *scene, Object *ob) bs->v1= curindex-1; bs->v2= curindex; bs->springtype=SB_EDGE; - bs->len= globallen( (bpnt-1)->vec, bpnt->vec , ob ); + bs->len= globallen( (bpnt-1)->vec, bpnt->vec, ob ); bs++; } } @@ -3650,7 +3652,7 @@ static void softbody_to_object(Object *ob, float (*vertexCos)[3], int numVerts, if (sb) { BodyPoint *bp= sb->bpoint; int a; - if (sb->solverflags & SBSO_ESTIMATEIPO) {SB_estimate_transform(ob,sb->lcom,sb->lrot,sb->lscale);} + if (sb->solverflags & SBSO_ESTIMATEIPO) {SB_estimate_transform(ob, sb->lcom, sb->lrot, sb->lscale);} /* inverse matrix is not uptodate... */ invert_m4_m4(ob->imat, ob->obmat); @@ -3667,7 +3669,7 @@ static void sb_new_scratch(SoftBody *sb) { if (!sb) return; sb->scratch = MEM_callocN(sizeof(SBScratch), "SBScratch"); - sb->scratch->colliderhash = BLI_ghash_new(BLI_ghashutil_ptrhash,BLI_ghashutil_ptrcmp, "sb_new_scratch gh"); + sb->scratch->colliderhash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "sb_new_scratch gh"); sb->scratch->bodyface = NULL; sb->scratch->totface = 0; sb->scratch->aabbmax[0]=sb->scratch->aabbmax[1]=sb->scratch->aabbmax[2] = 1.0e30f; @@ -3783,7 +3785,7 @@ static void softbody_update_positions(Object *ob, SoftBody *sb, float (*vertexCo if (!sb || !sb->bpoint) return; - for (a=0,bp=sb->bpoint; a<numVerts; a++, bp++) { + for (a=0, bp=sb->bpoint; a<numVerts; a++, bp++) { /* store where goals are now */ copy_v3_v3(bp->origS, bp->origE); /* copy the position of the goals at desired end time */ @@ -3798,47 +3800,47 @@ static void softbody_update_positions(Object *ob, SoftBody *sb, float (*vertexCo /* void SB_estimate_transform */ -/* input Object *ob out (says any object that can do SB like mesh,lattice,curve ) - * output float lloc[3],float lrot[3][3],float lscale[3][3] +/* input Object *ob out (says any object that can do SB like mesh, lattice, curve ) + * output float lloc[3], float lrot[3][3], float lscale[3][3] * that is: * a precise position vector denoting the motion of the center of mass * give a rotation/scale matrix using averaging method, that's why estimate and not calculate * see: this is kind of reverse engeneering: having to states of a point cloud and recover what happend * our advantage here we know the identity of the vertex * there are others methods giving other results. - * lloc,lrot,lscale are allowed to be NULL, just in case you don't need it. + * lloc, lrot, lscale are allowed to be NULL, just in case you don't need it. * should be pretty useful for pythoneers :) * not! velocity .. 2nd order stuff * vcloud_estimate_transform see */ -void SB_estimate_transform(Object *ob,float lloc[3],float lrot[3][3],float lscale[3][3]) +void SB_estimate_transform(Object *ob, float lloc[3], float lrot[3][3], float lscale[3][3]) { BodyPoint *bp; ReferenceVert *rp; SoftBody *sb = NULL; float (*opos)[3]; float (*rpos)[3]; - float com[3],rcom[3]; + float com[3], rcom[3]; int a; if (!ob ||!ob->soft) return; /* why did we get here ? */ sb= ob->soft; if (!sb || !sb->bpoint) return; - opos= MEM_callocN( (sb->totpoint)*3*sizeof(float), "SB_OPOS"); - rpos= MEM_callocN( (sb->totpoint)*3*sizeof(float), "SB_RPOS"); + opos= MEM_callocN((sb->totpoint)*3*sizeof(float), "SB_OPOS"); + rpos= MEM_callocN((sb->totpoint)*3*sizeof(float), "SB_RPOS"); /* might filter vertex selection with a vertex group */ for (a=0, bp=sb->bpoint, rp=sb->scratch->Ref.ivert; a<sb->totpoint; a++, bp++, rp++) { - copy_v3_v3(rpos[a],rp->pos); - copy_v3_v3(opos[a],bp->pos); + copy_v3_v3(rpos[a], rp->pos); + copy_v3_v3(opos[a], bp->pos); } - vcloud_estimate_transform(sb->totpoint, opos, NULL, rpos, NULL, com, rcom,lrot,lscale); - //sub_v3_v3(com,rcom); - if (lloc) copy_v3_v3(lloc,com); - copy_v3_v3(sb->lcom,com); - if (lscale) copy_m3_m3(sb->lscale,lscale); - if (lrot) copy_m3_m3(sb->lrot,lrot); + vcloud_estimate_transform(sb->totpoint, opos, NULL, rpos, NULL, com, rcom, lrot, lscale); + //sub_v3_v3(com, rcom); + if (lloc) copy_v3_v3(lloc, com); + copy_v3_v3(sb->lcom, com); + if (lscale) copy_m3_m3(sb->lscale, lscale); + if (lrot) copy_m3_m3(sb->lrot, lrot); MEM_freeN(opos); @@ -3850,7 +3852,7 @@ static void softbody_reset(Object *ob, SoftBody *sb, float (*vertexCos)[3], int BodyPoint *bp; int a; - for (a=0,bp=sb->bpoint; a<numVerts; a++, bp++) { + for (a=0, bp=sb->bpoint; a<numVerts; a++, bp++) { copy_v3_v3(bp->pos, vertexCos[a]); mul_m4_v3(ob->obmat, bp->pos); /* yep, sofbody is global coords*/ copy_v3_v3(bp->origS, bp->pos); @@ -3890,8 +3892,8 @@ static void softbody_reset(Object *ob, SoftBody *sb, float (*vertexCos)[3], int /* we only need that if we want to reconstruct IPO */ if (1) { reference_to_scratch(ob); - SB_estimate_transform(ob,NULL,NULL,NULL); - SB_estimate_transform(ob,NULL,NULL,NULL); + SB_estimate_transform(ob, NULL, NULL, NULL); + SB_estimate_transform(ob, NULL, NULL, NULL); } switch (ob->type) { case OB_MESH: @@ -3911,7 +3913,7 @@ static void softbody_step(Scene *scene, Object *ob, SoftBody *sb, float dtime) { /* the simulator */ float forcetime; - double sct,sst; + double sct, sst; sst=PIL_check_seconds_timer(); @@ -3951,26 +3953,26 @@ static void softbody_step(Scene *scene, Object *ob, SoftBody *sb, float dtime) forcetime = forcetimemax; /* hope for integrating in one step */ while ( (ABS(timedone) < ABS(dtime)) && (loops < 2000) ) { /* set goals in time */ - interpolate_exciter(ob,200,(int)(200.0f*(timedone/dtime))); + interpolate_exciter(ob, 200, (int)(200.0f*(timedone/dtime))); sb->scratch->flag &= ~SBF_DOFUZZY; /* do predictive euler step */ - softbody_calc_forces(scene, ob, forcetime,timedone/dtime,0); + softbody_calc_forces(scene, ob, forcetime, timedone/dtime, 0); - softbody_apply_forces(ob, forcetime, 1, NULL,mid_flags); + softbody_apply_forces(ob, forcetime, 1, NULL, mid_flags); /* crop new slope values to do averaged slope step */ - softbody_calc_forces(scene, ob, forcetime,timedone/dtime,0); + softbody_calc_forces(scene, ob, forcetime, timedone/dtime, 0); - softbody_apply_forces(ob, forcetime, 2, &err,mid_flags); + softbody_apply_forces(ob, forcetime, 2, &err, mid_flags); softbody_apply_goalsnap(ob); if (err > SoftHeunTol) { /* error needs to be scaled to some quantity */ if (forcetime > forcetimemin) { - forcetime = MAX2(forcetime / 2.0f,forcetimemin); + forcetime = MAX2(forcetime / 2.0f, forcetimemin); softbody_restore_prev_step(ob); - //printf("down,"); + //printf("down, "); } else { timedone += forcetime; @@ -3990,17 +3992,17 @@ static void softbody_step(Scene *scene, Object *ob, SoftBody *sb, float dtime) } } timedone += forcetime; - newtime=MIN2(forcetimemax,MAX2(newtime,forcetimemin)); - //if (newtime > forcetime) printf("up,"); + newtime=MIN2(forcetimemax, MAX2(newtime, forcetimemin)); + //if (newtime > forcetime) printf("up, "); if (forcetime > 0.0f) - forcetime = MIN2(dtime - timedone,newtime); + forcetime = MIN2(dtime - timedone, newtime); else - forcetime = MAX2(dtime - timedone,newtime); + forcetime = MAX2(dtime - timedone, newtime); } loops++; if (sb->solverflags & SBSO_MONITOR ) { sct=PIL_check_seconds_timer(); - if (sct-sst > 0.5f) printf("%3.0f%% \r",100.0f*timedone/dtime); + if (sct-sst > 0.5f) printf("%3.0f%% \r", 100.0f*timedone/dtime); } /* ask for user break */ if (SB_localInterruptCallBack && SB_localInterruptCallBack()) break; @@ -4013,7 +4015,7 @@ static void softbody_step(Scene *scene, Object *ob, SoftBody *sb, float dtime) // if (G.debug & G_DEBUG) { if (sb->solverflags & SBSO_MONITOR ) { if (loops > HEUNWARNLIMIT) /* monitor high loop counts */ - printf("\r needed %d steps/frame",loops); + printf("\r needed %d steps/frame", loops); } } @@ -4036,7 +4038,7 @@ static void softbody_step(Scene *scene, Object *ob, SoftBody *sb, float dtime) if (sb->solverflags & SBSO_MONITOR ) { sct=PIL_check_seconds_timer(); - if ((sct-sst > 0.5f) || (G.debug & G_DEBUG)) printf(" solver time %f sec %s\n",sct-sst,ob->id.name); + if ((sct-sst > 0.5f) || (G.debug & G_DEBUG)) printf(" solver time %f sec %s\n", sct-sst, ob->id.name); } } diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 3de5cf9677e..c69458f236a 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -1718,21 +1718,21 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm, #define PASSATTRIB(dx, dy, vert) { \ if (attribs.totorco) { \ index = getFaceIndex(ss, f, S, x + dx, y + dy, edgeSize, gridSize); \ - glVertexAttrib3fvARB(attribs.orco.glIndex, attribs.orco.array[index]); \ + glVertexAttrib3fvARB(attribs.orco.gl_index, attribs.orco.array[index]); \ } \ for (b = 0; b < attribs.tottface; b++) { \ MTFace *tf = &attribs.tface[b].array[a]; \ - glVertexAttrib2fvARB(attribs.tface[b].glIndex, tf->uv[vert]); \ + glVertexAttrib2fvARB(attribs.tface[b].gl_index, tf->uv[vert]); \ } \ for (b = 0; b < attribs.totmcol; b++) { \ MCol *cp = &attribs.mcol[b].array[a * 4 + vert]; \ GLubyte col[4]; \ col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; \ - glVertexAttrib4ubvARB(attribs.mcol[b].glIndex, col); \ + glVertexAttrib4ubvARB(attribs.mcol[b].gl_index, col); \ } \ if (attribs.tottang) { \ float *tang = attribs.tang.array[a * 4 + vert]; \ - glVertexAttrib4fvARB(attribs.tang.glIndex, tang); \ + glVertexAttrib4fvARB(attribs.tang.gl_index, tang); \ } \ } @@ -1863,27 +1863,27 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, void (*setMaterial)(void * #define PASSATTRIB(dx, dy, vert) { \ if (attribs.totorco) { \ index = getFaceIndex(ss, f, S, x + dx, y + dy, edgeSize, gridSize); \ - if (attribs.orco.glTexco) \ + if (attribs.orco.gl_texco) \ glTexCoord3fv(attribs.orco.array[index]); \ else \ - glVertexAttrib3fvARB(attribs.orco.glIndex, attribs.orco.array[index]); \ + glVertexAttrib3fvARB(attribs.orco.gl_index, attribs.orco.array[index]); \ } \ for (b = 0; b < attribs.tottface; b++) { \ MTFace *tf = &attribs.tface[b].array[a]; \ - if (attribs.tface[b].glTexco) \ + if (attribs.tface[b].gl_texco) \ glTexCoord2fv(tf->uv[vert]); \ else \ - glVertexAttrib2fvARB(attribs.tface[b].glIndex, tf->uv[vert]); \ + glVertexAttrib2fvARB(attribs.tface[b].gl_index, tf->uv[vert]); \ } \ for (b = 0; b < attribs.totmcol; b++) { \ MCol *cp = &attribs.mcol[b].array[a * 4 + vert]; \ GLubyte col[4]; \ col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; \ - glVertexAttrib4ubvARB(attribs.mcol[b].glIndex, col); \ + glVertexAttrib4ubvARB(attribs.mcol[b].gl_index, col); \ } \ if (attribs.tottang) { \ float *tang = attribs.tang.array[a * 4 + vert]; \ - glVertexAttrib4fvARB(attribs.tang.glIndex, tang); \ + glVertexAttrib4fvARB(attribs.tang.gl_index, tang); \ } \ } @@ -2102,7 +2102,7 @@ static void ccgDM_drawFacesTex_common(DerivedMesh *dm, } } else { - glShadeModel(GL_FLAT); + glShadeModel((cp)? GL_SMOOTH: GL_FLAT); glBegin(GL_QUADS); for (y = 0; y < gridFaces; y++) { for (x = 0; x < gridFaces; x++) { @@ -3134,8 +3134,6 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, float *w2; int s, x, y; - origIndex = base_polyOrigIndex ? base_polyOrigIndex[origIndex] : origIndex; - w = get_ss_weights(&wtable, gridCuts, numVerts); ccgdm->faceMap[index].startVert = vertNum; @@ -3146,6 +3144,8 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, faceFlags->mat_nr = mpoly ? mpoly[origIndex].mat_nr : 0; faceFlags++; + origIndex = base_polyOrigIndex ? base_polyOrigIndex[origIndex] : origIndex; + /* set the face base vert */ *((int *)ccgSubSurf_getFaceUserData(ss, f)) = vertNum; diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index cb7369476c0..d67c5fb3698 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -598,8 +598,8 @@ void clear_text(Text *text) /* called directly from rna */ int oldstate; oldstate = txt_get_undostate( ); - txt_set_undostate( 1 ); - txt_sel_all( text ); + txt_set_undostate(1); + txt_sel_all(text); txt_delete_sel(text); txt_set_undostate(oldstate); @@ -666,7 +666,7 @@ static TextLine *txt_new_linen(const char *str, int n) return tmp; } -void txt_clean_text (Text *text) +void txt_clean_text(Text *text) { TextLine **top, **bot; @@ -697,7 +697,7 @@ void txt_clean_text (Text *text) } } -int txt_get_span (TextLine *from, TextLine *to) +int txt_get_span(TextLine *from, TextLine *to) { int ret=0; TextLine *tmp= from; @@ -957,9 +957,8 @@ void txt_move_right(Text *text, short sel) void txt_jump_left(Text *text, short sel) { TextLine **linep, *oldl; - int *charp, oldc, oldflags, i; + int *charp, oldc, oldflags; unsigned char oldu; - int pos; if (!text) return; if (sel) txt_curs_sel(text, &linep, &charp); @@ -974,13 +973,9 @@ void txt_jump_left(Text *text, short sel) oldu= undoing; undoing= 1; /* Don't push individual moves to undo stack */ - pos = *charp; BLI_str_cursor_step_utf8((*linep)->line, (*linep)->len, - &pos, STRCUR_DIR_PREV, + charp, STRCUR_DIR_PREV, STRCUR_JUMP_DELIM); - for (i = *charp; i > pos; i--) { - txt_move_left(text, sel); - } text->flags = oldflags; @@ -991,9 +986,8 @@ void txt_jump_left(Text *text, short sel) void txt_jump_right(Text *text, short sel) { TextLine **linep, *oldl; - int *charp, oldc, oldflags, i; + int *charp, oldc, oldflags; unsigned char oldu; - int pos; if (!text) return; if (sel) txt_curs_sel(text, &linep, &charp); @@ -1008,13 +1002,9 @@ void txt_jump_right(Text *text, short sel) oldu= undoing; undoing= 1; /* Don't push individual moves to undo stack */ - pos = *charp; BLI_str_cursor_step_utf8((*linep)->line, (*linep)->len, - &pos, STRCUR_DIR_NEXT, + charp, STRCUR_DIR_NEXT, STRCUR_JUMP_DELIM); - for (i = *charp; i < pos; i++) { - txt_move_right(text, sel); - } text->flags = oldflags; @@ -1022,7 +1012,7 @@ void txt_jump_right(Text *text, short sel) if (!undoing) txt_undo_add_toop(text, sel?UNDO_STO:UNDO_CTO, txt_get_span(text->lines.first, oldl), oldc, txt_get_span(text->lines.first, *linep), (unsigned short)*charp); } -void txt_move_bol (Text *text, short sel) +void txt_move_bol(Text *text, short sel) { TextLine **linep; int *charp, old; @@ -1039,7 +1029,7 @@ void txt_move_bol (Text *text, short sel) if (!undoing) txt_undo_add_toop(text, sel?UNDO_STO:UNDO_CTO, txt_get_span(text->lines.first, *linep), old, txt_get_span(text->lines.first, *linep), (unsigned short)*charp); } -void txt_move_eol (Text *text, short sel) +void txt_move_eol(Text *text, short sel) { TextLine **linep; int *charp, old; @@ -1056,7 +1046,7 @@ void txt_move_eol (Text *text, short sel) if (!undoing) txt_undo_add_toop(text, sel?UNDO_STO:UNDO_CTO, txt_get_span(text->lines.first, *linep), old, txt_get_span(text->lines.first, *linep), (unsigned short)*charp); } -void txt_move_bof (Text *text, short sel) +void txt_move_bof(Text *text, short sel) { TextLine **linep; int *charp, old; @@ -1074,7 +1064,7 @@ void txt_move_bof (Text *text, short sel) if (!undoing) txt_undo_add_toop(text, sel?UNDO_STO:UNDO_CTO, txt_get_span(text->lines.first, *linep), old, txt_get_span(text->lines.first, *linep), (unsigned short)*charp); } -void txt_move_eof (Text *text, short sel) +void txt_move_eof(Text *text, short sel) { TextLine **linep; int *charp, old; @@ -1092,13 +1082,13 @@ void txt_move_eof (Text *text, short sel) if (!undoing) txt_undo_add_toop(text, sel?UNDO_STO:UNDO_CTO, txt_get_span(text->lines.first, *linep), old, txt_get_span(text->lines.first, *linep), (unsigned short)*charp); } -void txt_move_toline (Text *text, unsigned int line, short sel) +void txt_move_toline(Text *text, unsigned int line, short sel) { txt_move_to(text, line, 0, sel); } /* Moves to a certain byte in a line, not a certain utf8-character! */ -void txt_move_to (Text *text, unsigned int line, unsigned int ch, short sel) +void txt_move_to(Text *text, unsigned int line, unsigned int ch, short sel) { TextLine **linep, *oldl; int *charp, oldc; @@ -1180,7 +1170,7 @@ static void txt_pop_last (Text *text) /* never used: CVS 1.19 */ /* static void txt_pop_selr (Text *text) */ -void txt_pop_sel (Text *text) +void txt_pop_sel(Text *text) { text->sell= text->curl; text->selc= text->curc; @@ -1268,7 +1258,7 @@ static void txt_delete_sel (Text *text) text->selc= text->curc; } -void txt_sel_all (Text *text) +void txt_sel_all(Text *text) { if (!text) return; @@ -1279,7 +1269,7 @@ void txt_sel_all (Text *text) text->selc= text->sell->len; } -void txt_sel_line (Text *text) +void txt_sel_line(Text *text) { if (!text) return; if (!text->curl) return; @@ -2139,7 +2129,7 @@ void txt_do_undo(Text *text) case UNDO_IBLOCK: linep= txt_undo_read_uint32(text->undo_buf, &text->undo_pos); txt_delete_sel(text); - + /* txt_backspace_char removes utf8-characters, not bytes */ buf= MEM_mallocN(linep+1, "iblock buffer"); for (i=0; i < linep; i++) { @@ -2149,19 +2139,19 @@ void txt_do_undo(Text *text) buf[i]= 0; linep= txt_utf8_len(buf); MEM_freeN(buf); - + while (linep>0) { txt_backspace_char(text); linep--; } - + text->undo_pos--; text->undo_pos--; text->undo_pos--; text->undo_pos--; text->undo_pos--; - + break; case UNDO_INDENT: case UNDO_UNINDENT: @@ -2179,7 +2169,7 @@ void txt_do_undo(Text *text) for (i= 0; i < linep; i++) { text->sell = text->sell->next; } - + linep= txt_undo_read_uint32(text->undo_buf, &text->undo_pos); //first line to be selected @@ -2190,7 +2180,7 @@ void txt_do_undo(Text *text) for (i = 0; i < linep; i++) { text->curl = text->curl->next; } - + if (op==UNDO_INDENT) { txt_unindent(text); @@ -2204,9 +2194,18 @@ void txt_do_undo(Text *text) else if (op == UNDO_UNCOMMENT) { txt_comment(text); } - + text->undo_pos--; break; + case UNDO_DUPLICATE: + txt_delete_line(text, text->curl->next); + break; + case UNDO_MOVE_LINES_UP: + txt_move_lines(text, TXT_MOVE_LINE_DOWN); + break; + case UNDO_MOVE_LINES_DOWN: + txt_move_lines(text, TXT_MOVE_LINE_UP); + break; default: //XXX error("Undo buffer error - resetting"); text->undo_pos= -1; @@ -2404,10 +2403,19 @@ void txt_do_redo(Text *text) txt_uncomment(text); } break; + case UNDO_DUPLICATE: + txt_duplicate_line(text); + break; + case UNDO_MOVE_LINES_UP: + txt_move_lines(text, TXT_MOVE_LINE_UP); + break; + case UNDO_MOVE_LINES_DOWN: + txt_move_lines(text, TXT_MOVE_LINE_DOWN); + break; default: //XXX error("Undo buffer error - resetting"); text->undo_pos= -1; - + break; } @@ -2418,7 +2426,7 @@ void txt_do_redo(Text *text) /* Line editing functions */ /**************************/ -void txt_split_curline (Text *text) +void txt_split_curline(Text *text) { TextLine *ins; TextMarker *mrk; @@ -2545,6 +2553,23 @@ static void txt_combine_lines (Text *text, TextLine *linea, TextLine *lineb) txt_clean_text(text); } +void txt_duplicate_line(Text *text) +{ + TextLine *textline; + + if (!text || !text->curl) return; + + if (text->curl == text->sell) { + textline = txt_new_line(text->curl->line); + BLI_insertlinkafter(&text->lines, text->curl, textline); + + txt_make_dirty(text); + txt_clean_text(text); + + if (!undoing) txt_undo_add_op(text, UNDO_DUPLICATE); + } +} + void txt_delete_char(Text *text) { unsigned int c='\n'; @@ -2602,13 +2627,13 @@ void txt_delete_char(Text *text) if (!undoing) txt_undo_add_charop(text, UNDO_DEL_1, c); } -void txt_delete_word (Text *text) +void txt_delete_word(Text *text) { txt_jump_right(text, 1); txt_delete_sel(text); } -void txt_backspace_char (Text *text) +void txt_backspace_char(Text *text) { unsigned int c='\n'; @@ -2671,7 +2696,7 @@ void txt_backspace_char (Text *text) if (!undoing) txt_undo_add_charop(text, UNDO_BS_1, c); } -void txt_backspace_word (Text *text) +void txt_backspace_word(Text *text) { txt_jump_left(text, 1); txt_delete_sel(text); @@ -2745,12 +2770,12 @@ static int txt_add_char_intern (Text *text, unsigned int add, int replace_tabs) return 1; } -int txt_add_char (Text *text, unsigned int add) +int txt_add_char(Text *text, unsigned int add) { return txt_add_char_intern(text, add, text->flags & TXT_TABSTOSPACES); } -int txt_add_raw_char (Text *text, unsigned int add) +int txt_add_raw_char(Text *text, unsigned int add) { return txt_add_char_intern(text, add, 0); } @@ -2761,7 +2786,7 @@ void txt_delete_selected(Text *text) txt_make_dirty(text); } -int txt_replace_char (Text *text, unsigned int add) +int txt_replace_char(Text *text, unsigned int add) { unsigned int del; size_t del_size = 0, add_size; @@ -3020,7 +3045,62 @@ void txt_uncomment(Text *text) } } -int setcurr_tab_spaces (Text *text, int space) + +void txt_move_lines_up(struct Text *text) +{ + TextLine *prev_line; + + if (!text || !text->curl || !text->sell) return; + + txt_order_cursors(text); + + prev_line= text->curl->prev; + + if (!prev_line) return; + + BLI_remlink(&text->lines, prev_line); + BLI_insertlinkafter(&text->lines, text->sell, prev_line); + + txt_make_dirty(text); + txt_clean_text(text); + + if (!undoing) { + txt_undo_add_op(text, UNDO_MOVE_LINES_UP); + } +} + +void txt_move_lines(struct Text *text, const int direction) +{ + TextLine *line_other; + + BLI_assert(ELEM(direction, TXT_MOVE_LINE_UP, TXT_MOVE_LINE_DOWN)); + + if (!text || !text->curl || !text->sell) return; + + txt_order_cursors(text); + + line_other = (direction == TXT_MOVE_LINE_DOWN) ? text->sell->next : text->curl->prev; + + if (!line_other) return; + + BLI_remlink(&text->lines, line_other); + + if (direction == TXT_MOVE_LINE_DOWN) { + BLI_insertlinkbefore(&text->lines, text->curl, line_other); + } + else { + BLI_insertlinkafter(&text->lines, text->sell, line_other); + } + + txt_make_dirty(text); + txt_clean_text(text); + + if (!undoing) { + txt_undo_add_op(text, (direction == TXT_MOVE_LINE_DOWN) ? UNDO_MOVE_LINES_DOWN : UNDO_MOVE_LINES_UP); + } +} + +int setcurr_tab_spaces(Text *text, int space) { int i = 0; int test = 0; diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 29b9505f449..9200b1dca18 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -342,7 +342,7 @@ ColorBand *add_colorband(int rangetype) { ColorBand *coba; - coba= MEM_callocN( sizeof(ColorBand), "colorband"); + coba= MEM_callocN(sizeof(ColorBand), "colorband"); init_colorband(coba, rangetype); return coba; @@ -1056,8 +1056,8 @@ void make_local_texture(Tex *tex) void autotexname(Tex *tex) { Main *bmain= G.main; - char texstr[20][15]= {"None" , "Clouds" , "Wood", "Marble", "Magic" , "Blend", - "Stucci", "Noise" , "Image", "Plugin", "EnvMap" , "Musgrave", + char texstr[20][15]= {"None", "Clouds", "Wood", "Marble", "Magic", "Blend", + "Stucci", "Noise", "Image", "Plugin", "EnvMap", "Musgrave", "Voronoi", "DistNoise", "Point Density", "Voxel Data", "Ocean", "", "", ""}; Image *ima; char di[FILE_MAXDIR], fi[FILE_MAXFILE]; diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index e511cd362de..f4335862629 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -107,7 +107,7 @@ void BKE_tracking_clamp_track(MovieTrackingTrack *track, int event) float max_pyramid_level_factor = 1.0; if (track->tracker == TRACKER_KLT) { - max_pyramid_level_factor= 1 << (track->pyramid_levels - 1); + max_pyramid_level_factor = 1 << (track->pyramid_levels - 1); } /* sort */ @@ -277,7 +277,7 @@ MovieTrackingTrack *BKE_tracking_add_track(MovieTracking *tracking, ListBase *tr MovieTrackingMarker *BKE_tracking_insert_marker(MovieTrackingTrack *track, MovieTrackingMarker *marker) { - MovieTrackingMarker *old_marker= NULL; + MovieTrackingMarker *old_marker = NULL; if (track->markersnr) old_marker = BKE_tracking_exact_marker(track, marker->framenr); @@ -313,7 +313,7 @@ MovieTrackingMarker *BKE_tracking_insert_marker(MovieTrackingTrack *track, Movie void BKE_tracking_delete_marker(MovieTrackingTrack *track, int framenr) { - int a= 0; + int a = 0; while (a<track->markersnr) { if (track->markers[a].framenr == framenr) { @@ -464,7 +464,7 @@ void BKE_tracking_clear_path(MovieTrackingTrack *track, int ref_frame, int actio put_disabled_marker(track, &track->markers[track->markersnr-1], 0, 1); } else if (action == TRACK_CLEAR_UPTO) { - a= track->markersnr-1; + a = track->markersnr-1; while (a >= 0) { if (track->markers[a].framenr <= ref_frame) { @@ -632,6 +632,25 @@ static void tracking_objects_free(ListBase *objects) BLI_freelistN(objects); } +static void tracking_dopesheet_free(MovieTrackingDopesheet *dopesheet) +{ + MovieTrackingDopesheetChannel *channel; + + channel = dopesheet->channels.first; + while (channel) { + if (channel->segments) { + MEM_freeN(channel->segments); + } + + channel = channel->next; + } + + BLI_freelistN(&dopesheet->channels); + + dopesheet->channels.first = dopesheet->channels.last = NULL; + dopesheet->tot_channel = 0; +} + void BKE_tracking_free(MovieTracking *tracking) { tracking_tracks_free(&tracking->tracks); @@ -643,6 +662,8 @@ void BKE_tracking_free(MovieTracking *tracking) if (tracking->camera.intrinsics) BKE_tracking_distortion_destroy(tracking->camera.intrinsics); + + tracking_dopesheet_free(&tracking->dopesheet); } static MovieTrackingTrack *duplicate_track(MovieTrackingTrack *track) @@ -680,6 +701,8 @@ void BKE_tracking_clipboard_copy_tracks(MovieTracking *tracking, MovieTrackingOb ListBase *tracksbase = BKE_tracking_object_tracks(tracking, object); MovieTrackingTrack *track = tracksbase->first; + BKE_tracking_free_clipboard(); + while (track) { if (TRACK_SELECTED(track) && (track->flag & TRACK_HIDDEN) == 0) { MovieTrackingTrack *new_track = duplicate_track(track); @@ -763,7 +786,7 @@ static void tracks_map_get(TracksMap *map, int index, MovieTrackingTrack **track static void tracks_map_insert(TracksMap *map, MovieTrackingTrack *track, void *customdata) { - MovieTrackingTrack new_track= *track; + MovieTrackingTrack new_track = *track; new_track.markers = MEM_dupallocN(new_track.markers); @@ -843,10 +866,10 @@ static void tracks_map_merge(TracksMap *map, MovieTracking *tracking) BLI_ghash_insert(map->hash, track, new_track); if (replace_sel) /* update current selection in clip */ - tracking->act_track= new_track; + tracking->act_track = new_track; if (replace_rot) /* update track used for rotation stabilization */ - tracking->stabilization.rot_track= new_track; + tracking->stabilization.rot_track = new_track; BLI_addtail(&tracks, new_track); } @@ -859,7 +882,7 @@ static void tracks_map_merge(TracksMap *map, MovieTracking *tracking) track->next = track->prev = NULL; BLI_addtail(&new_tracks, track); - track= next; + track = next; } /* now move all tracks which are currently operating and keep their names unique */ @@ -874,15 +897,15 @@ static void tracks_map_merge(TracksMap *map, MovieTracking *tracking) BLI_uniquename(&new_tracks, track, "Track", '.', offsetof(MovieTrackingTrack, name), sizeof(track->name)); - track= next; + track = next; } - *old_tracks= new_tracks; + *old_tracks = new_tracks; } static void tracks_map_free(TracksMap *map, void (*customdata_free) (void *customdata)) { - int i= 0; + int i = 0; BLI_ghash_free(map->hash, NULL, NULL); @@ -998,7 +1021,7 @@ MovieTrackingContext *BKE_tracking_context_new(MovieClip *clip, MovieClipUser *u * than the search size */ int level = MIN2(track->pyramid_levels, max_pyramid_levels); - if (track->tracker==TRACKER_KLT) { + if (track->tracker == TRACKER_KLT) { track_context.region_tracker = libmv_pyramidRegionTrackerNew(100, level, half_wnd, track->minimum_correlation); } @@ -1007,7 +1030,7 @@ MovieTrackingContext *BKE_tracking_context_new(MovieClip *clip, MovieClipUser *u libmv_hybridRegionTrackerNew(100, half_wnd, track->minimum_correlation); } else if (track->tracker == TRACKER_SAD) { - track_context.region_tracker= libmv_bruteRegionTrackerNew(MAX2(wndx, wndy), track->minimum_correlation); + track_context.region_tracker = libmv_bruteRegionTrackerNew(MAX2(wndx, wndy), track->minimum_correlation); } } #endif @@ -1030,7 +1053,7 @@ MovieTrackingContext *BKE_tracking_context_new(MovieClip *clip, MovieClipUser *u * - MCLIP_USE_PROXY_CUSTOM_DIR is needed because proxy/timecode files might * be stored in a different location * ignore all the rest possible flags for now */ - context->clip_flag = clip->flag&MCLIP_TIMECODE_FLAGS; + context->clip_flag = clip->flag & MCLIP_TIMECODE_FLAGS; context->user = *user; context->user.render_size = MCLIP_PROXY_RENDER_SIZE_FULL; @@ -1298,7 +1321,7 @@ static ImBuf *get_keyframed_ibuf(MovieTrackingContext *context, MovieTrackingTra MovieTrackingMarker *next_marker = NULL; if (next>=0 && next<track->markersnr) - next_marker= &track->markers[next]; + next_marker = &track->markers[next]; /* if next mrker is disabled, stop searching keyframe and use current frame as keyframe */ if (next_marker && next_marker->flag & MARKER_DISABLED) @@ -1352,6 +1375,8 @@ void BKE_tracking_sync(MovieTrackingContext *context) newframe = context->user.framenr - 1; context->sync_frame = newframe; + + tracking->dopesheet.ok = FALSE; } void BKE_tracking_sync_user(MovieClipUser *user, MovieTrackingContext *context) @@ -1473,7 +1498,7 @@ int BKE_tracking_next(MovieTrackingContext *context) } marker_new.flag |= MARKER_TRACKED; - marker_new.framenr= nextfra; + marker_new.framenr = nextfra; #pragma omp critical { @@ -1732,7 +1757,7 @@ static int get_refine_intrinsics_flags(MovieTracking *tracking, MovieTrackingObj static int count_tracks_on_both_keyframes(MovieTracking *tracking, ListBase *tracksbase) { int tot = 0; - int frame1 = tracking->settings.keyframe1, frame2= tracking->settings.keyframe2; + int frame1 = tracking->settings.keyframe1, frame2 = tracking->settings.keyframe2; MovieTrackingTrack *track; track = tracksbase->first; @@ -1863,7 +1888,7 @@ void BKE_tracking_reconstruction_context_free(MovieReconstructContext *context) #ifdef WITH_LIBMV static void solve_reconstruction_update_cb(void *customdata, double progress, const char *message) { - ReconstructProgressData *progressdata= customdata; + ReconstructProgressData *progressdata = customdata; if (progressdata->progress) { *progressdata->progress = progress; @@ -1979,7 +2004,7 @@ MovieTrackingTrack *BKE_tracking_named_track(MovieTracking *tracking, MovieTrack static int reconstruction_camera_index(MovieTrackingReconstruction *reconstruction, int framenr, int nearest) { - MovieReconstructedCamera *cameras= reconstruction->cameras; + MovieReconstructedCamera *cameras = reconstruction->cameras; int a = 0, d = 1; if (!reconstruction->camnr) @@ -2216,7 +2241,7 @@ MovieTrackingObject *BKE_tracking_get_camera_object(MovieTracking *tracking) if (object->flag & TRACKING_OBJECT_CAMERA) return object; - object= object->next; + object = object->next; } return NULL; @@ -2249,7 +2274,7 @@ MovieTrackingReconstruction *BKE_tracking_get_reconstruction(MovieTracking *trac void BKE_tracking_apply_intrinsics(MovieTracking *tracking, float co[2], float nco[2]) { - MovieTrackingCamera *camera= &tracking->camera; + MovieTrackingCamera *camera = &tracking->camera; #ifdef WITH_LIBMV double x, y; @@ -2309,7 +2334,7 @@ static int point_in_stroke(bGPDstroke *stroke, float x, float y) count++; } - prev= i; + prev = i; } return count % 2; @@ -2418,10 +2443,10 @@ MovieTrackingTrack *BKE_tracking_indexed_track(MovieTracking *tracking, int trac track = track->next; } - object= object->next; + object = object->next; } - *tracksbase_r= NULL; + *tracksbase_r = NULL; return NULL; } @@ -2645,8 +2670,8 @@ void BKE_tracking_stabilization_data(MovieTracking *tracking, int framenr, int w if ((stab->flag & TRACKING_2D_STABILIZATION) == 0) { zero_v2(loc); - *scale= 1.0f; - *angle= 0.0f; + *scale = 1.0f; + *angle = 0.0f; return; } @@ -2765,10 +2790,10 @@ ImBuf *BKE_tracking_stabilize(MovieTracking *tracking, int framenr, ImBuf *ibuf, copy_v2_v2(loc, tloc); if (scale) - *scale= tscale; + *scale = tscale; if (angle) - *angle= tangle; + *angle = tangle; return tmpibuf; } @@ -3001,7 +3026,7 @@ void BKE_tracking_remove_object(MovieTracking *tracking, MovieTrackingObject *ob if (track == tracking->act_track) tracking->act_track = NULL; - track= track->next; + track = track->next; } tracking_object_free(object); @@ -3033,3 +3058,216 @@ MovieTrackingObject *BKE_tracking_named_object(MovieTracking *tracking, const ch return NULL; } + +/*********************** dopesheet functions *************************/ + +static int channels_alpha_sort(void *a, void *b) +{ + MovieTrackingDopesheetChannel *channel_a = a; + MovieTrackingDopesheetChannel *channel_b = b; + + if (BLI_strcasecmp(channel_a->track->name, channel_b->track->name) > 0) + return 1; + else + return 0; +} + +static int channels_total_track_sort(void *a, void *b) +{ + MovieTrackingDopesheetChannel *channel_a = a; + MovieTrackingDopesheetChannel *channel_b = b; + + if (channel_a->total_frames > channel_b->total_frames) + return 1; + else + return 0; +} + +static int channels_longest_segment_sort(void *a, void *b) +{ + MovieTrackingDopesheetChannel *channel_a = a; + MovieTrackingDopesheetChannel *channel_b = b; + + if (channel_a->max_segment > channel_b->max_segment) + return 1; + else + return 0; +} + +static int channels_alpha_inverse_sort(void *a, void *b) +{ + if (channels_alpha_sort(a, b)) + return 0; + else + return 1; +} + +static int channels_total_track_inverse_sort(void *a, void *b) +{ + if (channels_total_track_sort(a, b)) + return 0; + else + return 1; +} + +static int channels_longest_segment_inverse_sort(void *a, void *b) +{ + if (channels_longest_segment_sort(a, b)) + return 0; + else + return 1; +} + +static void channels_segments_calc(MovieTrackingDopesheetChannel *channel) +{ + MovieTrackingTrack *track = channel->track; + int i, segment; + + channel->tot_segment = 0; + channel->max_segment = 0; + channel->total_frames = 0; + + /* count */ + i = 0; + while (i < track->markersnr) { + MovieTrackingMarker *marker = &track->markers[i]; + + if ((marker->flag & MARKER_DISABLED) == 0) { + int prev_fra = marker->framenr, len = 0; + + i++; + while (i < track->markersnr) { + marker = &track->markers[i]; + + if (marker->framenr != prev_fra + 1) + break; + if (marker->flag & MARKER_DISABLED) + break; + + prev_fra = marker->framenr; + len++; + i++; + } + + channel->tot_segment++; + } + + i++; + } + + if (!channel->tot_segment) + return; + + channel->segments = MEM_callocN(2 * sizeof(int) * channel->tot_segment, "tracking channel segments"); + + /* create segments */ + i = 0; + segment = 0; + while (i < track->markersnr) { + MovieTrackingMarker *marker = &track->markers[i]; + + if ((marker->flag & MARKER_DISABLED) == 0) { + MovieTrackingMarker *start_marker = marker; + int prev_fra = marker->framenr, len = 0; + + i++; + while (i < track->markersnr) { + marker = &track->markers[i]; + + if (marker->framenr != prev_fra + 1) + break; + if (marker->flag & MARKER_DISABLED) + break; + + prev_fra = marker->framenr; + channel->total_frames++; + len++; + i++; + } + + channel->segments[2 * segment] = start_marker->framenr; + channel->segments[2 * segment + 1] = start_marker->framenr + len; + + channel->max_segment = MAX2(channel->max_segment, len); + segment++; + } + + i++; + } +} + +static void tracking_dopesheet_sort(MovieTracking *tracking, int sort_method, int inverse) +{ + MovieTrackingDopesheet *dopesheet = &tracking->dopesheet; + + if (dopesheet->sort_method == sort_method && dopesheet->sort_inverse == inverse) + return; + + if (inverse) { + if (sort_method == TRACK_SORT_NAME) { + BLI_sortlist(&dopesheet->channels, channels_alpha_inverse_sort); + } + else if (sort_method == TRACK_SORT_LONGEST) { + BLI_sortlist(&dopesheet->channels, channels_longest_segment_inverse_sort); + } + else if (sort_method == TRACK_SORT_TOTAL) { + BLI_sortlist(&dopesheet->channels, channels_total_track_inverse_sort); + } + } + else { + if (sort_method == TRACK_SORT_NAME) { + BLI_sortlist(&dopesheet->channels, channels_alpha_sort); + } + else if (sort_method == TRACK_SORT_LONGEST) { + BLI_sortlist(&dopesheet->channels, channels_longest_segment_sort); + } + else if (sort_method == TRACK_SORT_TOTAL) { + BLI_sortlist(&dopesheet->channels, channels_total_track_sort); + } + } + + dopesheet->sort_method = sort_method; + dopesheet->sort_inverse = inverse; +} + +void BKE_tracking_dopesheet_tag_update(MovieTracking *tracking) +{ + MovieTrackingDopesheet *dopesheet = &tracking->dopesheet; + + dopesheet->ok = FALSE; +} + +void BKE_tracking_dopesheet_update(MovieTracking *tracking, int sort_method, int inverse) +{ + MovieTrackingObject *object = BKE_tracking_active_object(tracking); + MovieTrackingDopesheet *dopesheet = &tracking->dopesheet; + MovieTrackingTrack *track; + ListBase *tracksbase = BKE_tracking_object_tracks(tracking, object); + + if (dopesheet->ok) { + tracking_dopesheet_sort(tracking, sort_method, inverse); + return; + } + + tracking_dopesheet_free(dopesheet); + + for (track = tracksbase->first; track; track = track->next) { + if (TRACK_SELECTED(track) && (track->flag & TRACK_HIDDEN) == 0) { + MovieTrackingDopesheetChannel *channel; + + channel = MEM_callocN(sizeof(MovieTrackingDopesheetChannel), "tracking dopesheet channel"); + channel->track = track; + + channels_segments_calc(channel); + + BLI_addtail(&dopesheet->channels, channel); + dopesheet->tot_channel++; + } + } + + dopesheet->sort_method = TRACK_SORT_NONE; + + tracking_dopesheet_sort(tracking, sort_method, inverse); + + dopesheet->ok = TRUE; +} diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index 48e939be7e9..03afc97f324 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -251,7 +251,7 @@ static struct bUnitDef buNaturalTimeDef[] = { {"hour", "hours", "hr", "h", "Hours", 3600.0, 0.0, B_UNIT_DEF_NONE}, {"minute", "minutes", "min", "m", "Minutes", 60.0, 0.0, B_UNIT_DEF_NONE}, {"second", "seconds", "sec", "s", "Seconds", 1.0, 0.0, B_UNIT_DEF_NONE}, /* base unit */ - {"millisecond", "milliseconds", "ms", NULL, "Milliseconds", 0.001, 0.0 , B_UNIT_DEF_NONE}, + {"millisecond", "milliseconds", "ms", NULL, "Milliseconds", 0.001, 0.0, B_UNIT_DEF_NONE}, {"microsecond", "microseconds", "µs", "us", "Microseconds", 0.000001, 0.0, B_UNIT_DEF_NONE}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 079bde0afec..7330269c1f4 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -1,19 +1,25 @@ /* + * ***** BEGIN GPL LICENSE BLOCK ***** * - * ffmpeg-write support - * - * Partial Copyright (c) 2006 Peter Schlaile - * - * 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 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. + * + * Contributor(s): + * + * Partial Copyright (c) 2006 Peter Schlaile + * + * ***** END GPL LICENSE BLOCK ***** */ /** \file blender/blenkernel/intern/writeffmpeg.c diff --git a/source/blender/blenkernel/intern/writeframeserver.c b/source/blender/blenkernel/intern/writeframeserver.c index 62e921f3311..0ff095607e3 100644 --- a/source/blender/blenkernel/intern/writeframeserver.c +++ b/source/blender/blenkernel/intern/writeframeserver.c @@ -1,25 +1,33 @@ /* + * ***** BEGIN GPL LICENSE BLOCK ***** * - * Frameserver - * Makes Blender accessible from TMPGenc directly using VFAPI (you can - * use firefox too ;-) - * - * Copyright (c) 2006 Peter Schlaile - * - * 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 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. + * + * Copyright (c) 2006 Peter Schlaile + * + * Contributor(s): + * + * ***** END GPL LICENSE BLOCK ***** */ /** \file blender/blenkernel/intern/writeframeserver.c * \ingroup bke + * + * Frameserver + * Makes Blender accessible from TMPGenc directly using VFAPI (you can + * use firefox too ;-) */ #ifdef WITH_FRAMESERVER @@ -70,7 +78,7 @@ static int render_height; static int startup_socket_system(void) { WSADATA wsa; - return (WSAStartup(MAKEWORD(2,0),&wsa) == 0); + return (WSAStartup(MAKEWORD(2, 0), &wsa) == 0); } static void shutdown_socket_system(void) |