diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-03-01 01:35:49 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-03-01 01:35:49 +0400 |
commit | 35708fe15044445fead8bc7c3709edea6921cff5 (patch) | |
tree | 835087aae42cd973e4a51895e60e206434c0e0fe /source/blender/blenkernel | |
parent | a20ca0ca32087b97c76819be88091b7caf4da85c (diff) | |
parent | af0a469307d5abe30d59c62c61d8bbc361bdf359 (diff) |
Merged changes in the trunk up to revision 44561.
Conflicts resolved:
source/blender/bmesh/bmesh.h
source/blender/bmesh/bmesh_operators.h
source/blenderplayer/bad_level_call_stubs/stubs.c
Diffstat (limited to 'source/blender/blenkernel')
77 files changed, 1014 insertions, 1133 deletions
diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h index 05b9519d2fe..3103dde31dc 100644 --- a/source/blender/blenkernel/BKE_DerivedMesh.h +++ b/source/blender/blenkernel/BKE_DerivedMesh.h @@ -271,10 +271,6 @@ struct DerivedMesh { */ struct ListBase *(*getPolyMap)(struct Object *ob, DerivedMesh *dm); - /* Get a map of vertices to faces - */ - struct ListBase *(*getFaceMap)(struct Object *ob, DerivedMesh *dm); - /* Get the BVH used for paint modes */ struct PBVH *(*getPBVH)(struct Object *ob, DerivedMesh *dm); @@ -617,7 +613,6 @@ DerivedMesh *mesh_create_derived_no_virtual(struct Scene *scene, struct Object * DerivedMesh *mesh_create_derived_physics(struct Scene *scene, struct Object *ob, float (*vertCos)[3], CustomDataMask dataMask); -DerivedMesh *editbmesh_get_derived(struct BMEditMesh *em, float (*vertexCos)[3]); DerivedMesh *editbmesh_get_derived_base(struct Object *, struct BMEditMesh *em); DerivedMesh *editbmesh_get_derived_cage(struct Scene *scene, struct Object *, struct BMEditMesh *em, CustomDataMask dataMask); @@ -634,11 +629,6 @@ void makeDerivedMesh(struct Scene *scene, struct Object *ob, struct BMEditMesh * int editbmesh_get_first_deform_matrices(struct Scene *, struct Object *, struct BMEditMesh *em, float (**deformmats)[3][3], float (**deformcos)[3]); -/* returns an array of deform matrices for crazyspace correction when sculpting, - and the number of modifiers left */ -int sculpt_get_deform_matrices(struct Scene *scene, struct Object *ob, - float (**deformmats)[3][3], float (**deformcos)[3]); - void weight_to_rgb(float r_rgb[3], const float weight); /* Update the weight MCOL preview layer. * If weights are NULL, use object's active vgroup(s). diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h index e94ad6ecfac..441d63be764 100644 --- a/source/blender/blenkernel/BKE_armature.h +++ b/source/blender/blenkernel/BKE_armature.h @@ -97,16 +97,16 @@ void where_is_pose_bone_tail(struct bPoseChannel *pchan); /* get_objectspace_bone_matrix has to be removed still */ void get_objectspace_bone_matrix (struct Bone* bone, float M_accumulatedMatrix[][4], int root, int posed); -void vec_roll_to_mat3(float *vec, float roll, float mat[][3]); +void vec_roll_to_mat3(const float vec[3], const float roll, float mat[][3]); void mat3_to_vec_roll(float mat[][3], float *vec, float *roll); int get_selected_defgroups(struct Object *ob, char *defbase_sel, int defbase_len); /* Common Conversions Between Co-ordinate Spaces */ void armature_mat_world_to_pose(struct Object *ob, float inmat[][4], float outmat[][4]); -void armature_loc_world_to_pose(struct Object *ob, float *inloc, float *outloc); +void armature_loc_world_to_pose(struct Object *ob, const float inloc[3], float outloc[3]); void armature_mat_pose_to_bone(struct bPoseChannel *pchan, float inmat[][4], float outmat[][4]); -void armature_loc_pose_to_bone(struct bPoseChannel *pchan, float *inloc, float *outloc); +void armature_loc_pose_to_bone(struct bPoseChannel *pchan, const float inloc[3], float outloc[3]); void armature_mat_bone_to_pose(struct bPoseChannel *pchan, float inmat[][4], float outmat[][4]); void armature_mat_pose_to_delta(float delta_mat[][4], float pose_mat[][4], float arm_mat[][4]); diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 237bfc1b588..1c661b3804f 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -90,7 +90,6 @@ extern void BKE_reset_undo(void); extern char *BKE_undo_menu_string(void); extern void BKE_undo_number(struct bContext *C, int nr); extern const char *BKE_undo_get_name(int nr, int *active); -void BKE_undo_save(char *fname); extern void BKE_undo_save_quit(void); extern struct Main *BKE_undo_get_main(struct Scene **scene); diff --git a/source/blender/blenkernel/BKE_bmesh.h b/source/blender/blenkernel/BKE_bmesh.h index 06b4df8b05c..677614e26e3 100644 --- a/source/blender/blenkernel/BKE_bmesh.h +++ b/source/blender/blenkernel/BKE_bmesh.h @@ -35,159 +35,8 @@ * */ -#include "DNA_listBase.h" -#include "BLI_utildefines.h" -#include "BLI_ghash.h" -#include "BLI_mempool.h" -#include "BLI_memarena.h" -#include "DNA_image_types.h" -#include "BKE_DerivedMesh.h" -//XXX #include "transform.h" -#include "bmesh.h" - -/*forward declerations*/ -struct BME_Vert; -struct BME_Edge; -struct BME_Poly; -struct BME_Loop; - /*NOTE: this is the bmesh 1.0 code. it's completely outdated.*/ -/*Notes on further structure Cleanup: - -Remove the tflags, they belong in custom data layers - -Remove the eflags completely, they are mostly not used - -Remove the selection/vis/bevel weight flag/values ect and move them to custom data - -Remove EID member and move to custom data - -Add a radial cycle length, disk cycle length and loop cycle length attributes to custom data and have eulers maintain/use them if present. - -Move data such as vertex coordinates/normals to custom data and leave pointers in structures to active layer data. - -Remove BME_CycleNode structure? -*/ -typedef struct BME_CycleNode{ - struct BME_CycleNode *next, *prev; - void *data; -} BME_CycleNode; - -typedef struct BME_Mesh -{ - ListBase verts, edges, polys; - /*memory pools used for storing mesh elements*/ - struct BLI_mempool *vpool; - struct BLI_mempool *epool; - struct BLI_mempool *ppool; - struct BLI_mempool *lpool; - /*some scratch arrays used by eulers*/ - struct BME_Vert **vtar; - struct BME_Edge **edar; - struct BME_Loop **lpar; - struct BME_Poly **plar; - int vtarlen, edarlen, lparlen, plarlen; - int totvert, totedge, totpoly, totloop; /*record keeping*/ - int nextv, nexte, nextp, nextl; /*Next element ID for verts/edges/faces/loops. Never reused*/ - struct CustomData vdata, edata, pdata, ldata; /*Custom Data Layer information*/ -} BME_Mesh; - -typedef struct BME_Vert -{ - struct BME_Vert *next, *prev; - int EID; - float co[3]; - float no[3]; - struct BME_Edge *edge; /*first edge in the disk cycle for this vertex*/ - void *data; /*custom vertex data*/ - int eflag1, eflag2; /*reserved for use by eulers*/ - int tflag1, tflag2; /*reserved for use by tools*/ - unsigned short flag, h; - float bweight; -} BME_Vert; - -typedef struct BME_Edge -{ - struct BME_Edge *next, *prev; - int EID; - struct BME_Vert *v1, *v2; /*note that order of vertex pointers means nothing to eulers*/ - struct BME_CycleNode d1, d2; /*disk cycle nodes for v1 and v2 respectivley*/ - struct BME_Loop *loop; /*first BME_Loop in the radial cycle around this edge*/ - void *data; /*custom edge data*/ - int eflag1, eflag2; /*reserved for use by eulers*/ - int tflag1, tflag2; /*reserved for use by tools*/ - unsigned short flag, h; - float crease, bweight; -} BME_Edge; - -typedef struct BME_Loop -{ - struct BME_Loop *next, *prev; /*circularly linked list around face*/ - int EID; - struct BME_CycleNode radial; /*circularly linked list used to find faces around an edge*/ - struct BME_Vert *v; /*vertex that this loop starts at.*/ - struct BME_Edge *e; /*edge this loop belongs to*/ - struct BME_Poly *f; /*face this loop belongs to*/ - void *data; /*custom per face vertex data*/ - int eflag1, eflag2; /*reserved for use by eulers*/ - int tflag1, tflag2; /*reserved for use by tools*/ - unsigned short flag, h; -} BME_Loop; - -typedef struct BME_Poly -{ - struct BME_Poly *next, *prev; - int EID; - struct BME_Loop *loopbase; /*First editloop around Polygon.*/ - unsigned int len; /*total length of the face. Eulers should preserve this data*/ - void *data; /*custom face data*/ - int eflag1, eflag2; /*reserved for use by eulers*/ - int tflag1, tflag2; /*reserved for use by tools*/ - unsigned short flag, h, mat_nr; -} BME_Poly; - -/*EDGE UTILITIES*/ -int BME_verts_in_edge(struct BME_Vert *v1, struct BME_Vert *v2, struct BME_Edge *e); -int BME_vert_in_edge(struct BME_Edge *e, BME_Vert *v); -struct BME_Vert *BME_edge_getothervert(struct BME_Edge *e, struct BME_Vert *v); - -/*GENERAL CYCLE*/ -int BME_cycle_length(void *h); - -/*DISK CYCLE*/ -struct BME_Edge *BME_disk_nextedge(struct BME_Edge *e, struct BME_Vert *v); -struct BME_CycleNode *BME_disk_getpointer(struct BME_Edge *e, struct BME_Vert *v); -struct BME_Edge *BME_disk_next_edgeflag(struct BME_Edge *e, struct BME_Vert *v, int eflag, int tflag); -int BME_disk_count_edgeflag(struct BME_Vert *v, int eflag, int tflag); - -/*RADIAL CYCLE*/ -struct BME_Loop *BME_radial_nextloop(struct BME_Loop *l); -int BME_radial_find_face(struct BME_Edge *e,struct BME_Poly *f); - -/*LOOP CYCLE*/ -struct BME_Loop *BME_loop_find_loop(struct BME_Poly *f, struct BME_Vert *v); - -/*MESH CREATION/DESTRUCTION*/ -struct BME_Mesh *BME_make_mesh(int allocsize[4]); -void BME_free_mesh(struct BME_Mesh *bm); -/*FULL MESH VALIDATION*/ -int BME_validate_mesh(struct BME_Mesh *bm, int halt); -/*ENTER/EXIT MODELLING LOOP*/ -int BME_model_begin(struct BME_Mesh *bm); -void BME_model_end(struct BME_Mesh *bm); - -/*MESH CONSTRUCTION API.*/ -/*MAKE*/ -struct BME_Vert *BME_MV(struct BME_Mesh *bm, float *vec); -struct BME_Edge *BME_ME(struct BME_Mesh *bm, struct BME_Vert *v1, struct BME_Vert *v2); -struct BME_Poly *BME_MF(struct BME_Mesh *bm, struct BME_Vert *v1, struct BME_Vert *v2, struct BME_Edge **elist, int len); -/*KILL*/ -int BME_KV(struct BME_Mesh *bm, struct BME_Vert *v); -int BME_KE(struct BME_Mesh *bm, struct BME_Edge *e); -int BME_KF(struct BME_Mesh *bm, struct BME_Poly *bply); -/*SPLIT*/ -struct BME_Vert *BME_SEMV(struct BME_Mesh *bm, struct BME_Vert *tv, struct BME_Edge *e, struct BME_Edge **re); -struct BME_Poly *BME_SFME(struct BME_Mesh *bm, struct BME_Poly *f, struct BME_Vert *v1, struct BME_Vert *v2, struct BME_Loop **rl); -/*JOIN*/ -int BME_JEKV(struct BME_Mesh *bm, struct BME_Edge *ke, struct BME_Vert *kv); -struct BME_Poly *BME_JFKE(struct BME_Mesh *bm, struct BME_Poly *f1, struct BME_Poly *f2,struct BME_Edge *e); /*no reason to return BME_Poly pointer?*/ -/*NORMAL FLIP(Is its own inverse)*/ -int BME_loop_reverse(struct BME_Mesh *bm, struct BME_Poly *f); - /* bevel tool defines */ /* element flags */ #define BME_BEVEL_ORIG 1 @@ -214,8 +63,8 @@ int BME_loop_reverse(struct BME_Mesh *bm, struct BME_Poly *f); #define BME_BEVEL_DIST (1<<12) /* same as above */ typedef struct BME_TransData { - BMesh *bm; /* the bmesh the vert belongs to */ - BMVert *v; /* pointer to the vert this tdata applies to */ + struct BMesh *bm; /* the bmesh the vert belongs to */ + struct BMVert *v; /* pointer to the vert this tdata applies to */ float co[3]; /* the original coordinate */ float org[3]; /* the origin */ float vec[3]; /* a directional vector; always, always normalize! */ @@ -230,13 +79,13 @@ typedef struct BME_TransData { } BME_TransData; typedef struct BME_TransData_Head { - GHash *gh; /* the hash structure for element lookup */ - MemArena *ma; /* the memory "pool" we will be drawing individual elements from */ + struct GHash *gh; /* the hash structure for element lookup */ + struct MemArena *ma; /* the memory "pool" we will be drawing individual elements from */ int len; } BME_TransData_Head; typedef struct BME_Glob { /* stored in Global G for Transform() purposes */ - BMesh *bm; + struct BMesh *bm; BME_TransData_Head *td; struct TransInfo *Trans; /* a pointer to the global Trans struct */ int imval[2]; /* for restoring original mouse co when initTransform() is called multiple times */ @@ -246,7 +95,6 @@ typedef struct BME_Glob { /* stored in Global G for Transform() purposes */ struct BME_TransData *BME_get_transdata(struct BME_TransData_Head *td, struct BMVert *v); void BME_free_transdata(struct BME_TransData_Head *td); -float *BME_bevel_calc_polynormal(struct BME_Poly *f, struct BME_TransData_Head *td); struct BMesh *BME_bevel(struct BMEditMesh *em, float value, int res, int options, int defgrp_index, float angle, BME_TransData_Head **rtd); #endif diff --git a/source/blender/blenkernel/BKE_bmeshCustomData.h b/source/blender/blenkernel/BKE_bmeshCustomData.h deleted file mode 100644 index bbdc6f39cff..00000000000 --- a/source/blender/blenkernel/BKE_bmeshCustomData.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2004 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Geoffrey Bantle. - * - * ***** END GPL LICENSE BLOCK ***** - */ - - -#ifndef __BKE_BMESHCUSTOMDATA_H__ -#define __BKE_BMESHCUSTOMDATA_H__ - -/** \file BKE_bmeshCustomData.h - * \ingroup bke - * \since January 2007 - * \brief BMesh modeler structure and functions - custom data. - */ - -struct BLI_mempool; - -/*Custom Data Types and defines - Eventual plan is to move almost everything to custom data and let caller - decide when making the mesh what layers they want to store in the mesh - - This stuff should probably go in a seperate file.... -*/ - -#define BME_CD_FACETEX 0 /*Image texture/texface*/ -#define BME_CD_LOOPTEX 1 /*UV coordinates*/ -#define BME_CD_LOOPCOL 2 /*Vcolors*/ -#define BME_CD_DEFORMVERT 3 /*Vertex Group/Weights*/ -#define BME_CD_NUMTYPES 4 - -typedef struct BME_CustomDataLayer { - int type; /* type of data in layer */ - int offset; /* offset of layer in block */ - int active; /* offset of active layer*/ - char name[32]; /* layer name */ -} BME_CustomDataLayer; - -typedef struct BME_CustomData { - struct BME_CustomDataLayer *layers; /*Custom Data Layers*/ - struct BLI_mempool *pool; /*pool for alloc of blocks*/ - int totlayer, totsize; /*total layers and total size in bytes of each block*/ -} BME_CustomData; - -typedef struct BME_CustomDataInit{ - int layout[BME_CD_NUMTYPES]; - int active[BME_CD_NUMTYPES]; - int totlayers; - char *nametemplate; -} BME_CustomDataInit; - -/*Custom data types*/ -typedef struct BME_DeformWeight { - int def_nr; - float weight; -} BME_DeformWeight; - -typedef struct BME_DeformVert { - struct BME_DeformWeight *dw; - int totweight; -} BME_DeformVert; - -typedef struct BME_facetex{ - struct Image *tpage; - char flag, transp; - short mode, tile, unwrap; -}BME_facetex; - -typedef struct BME_looptex{ - float u, v; -}BME_looptex; - -typedef struct BME_loopcol{ - char r, g, b, a; -}BME_loopcol; - -/*CUSTOM DATA API*/ -void BME_CD_Create(struct BME_CustomData *data, struct BME_CustomDataInit *init, int initalloc); -void BME_CD_Free(struct BME_CustomData *data); -void BME_CD_free_block(struct BME_CustomData *data, void **block); -void BME_CD_copy_data(const struct BME_CustomData *source, struct BME_CustomData *dest, void *src_block, void **dest_block); -void BME_CD_set_default(struct BME_CustomData *data, void **block); - -#endif diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h index f5cd2635ff7..1ff9bc46638 100644 --- a/source/blender/blenkernel/BKE_brush.h +++ b/source/blender/blenkernel/BKE_brush.h @@ -52,7 +52,6 @@ void brush_reset_sculpt(struct Brush *brush); struct ImBuf *get_brush_icon(struct Brush *brush); /* brush library operations used by different paint panels */ -int brush_delete(struct Brush **current_brush); 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); @@ -60,7 +59,7 @@ int brush_clone_image_delete(struct Brush *brush); /* jitter */ void brush_jitter_pos(const struct Scene *scene, struct Brush *brush, - float *pos, float *jitterpos); + const float pos[2], float jitterpos[2]); /* brush curve */ void brush_curve_preset(struct Brush *b, /*enum CurveMappingPreset*/int preset); @@ -75,13 +74,13 @@ void brush_imbuf_new(const struct Scene *scene, struct Brush *brush, short flt, /* painting */ struct BrushPainter; typedef struct BrushPainter BrushPainter; -typedef int (*BrushFunc)(void *user, struct ImBuf *ibuf, float *lastpos, float *pos); +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, - short texonly, int size); -int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, - double time, float pressure, void *user, int use_color_correction); + short texonly, int size); +int 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); diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h index ec20e3234a3..c453a9b0497 100644 --- a/source/blender/blenkernel/BKE_cloth.h +++ b/source/blender/blenkernel/BKE_cloth.h @@ -203,11 +203,6 @@ int implicit_free ( struct ClothModifierData *clmd ); int implicit_solver ( struct Object *ob, float frame, struct ClothModifierData *clmd, struct ListBase *effectors ); void implicit_set_positions ( struct ClothModifierData *clmd ); -// globally needed -void clmdSetInterruptCallBack ( int ( *f ) ( void ) ); -//////////////////////////////////////////////// - - ///////////////////////////////////////////////// // cloth.c //////////////////////////////////////////////// @@ -218,7 +213,6 @@ void cloth_free_modifier ( struct ClothModifierData *clmd ); void cloth_init ( struct ClothModifierData *clmd ); void clothModifier_do ( struct ClothModifierData *clmd, struct Scene *scene, struct Object *ob, struct DerivedMesh *dm, float (*vertexCos)[3]); -void cloth_update_normals ( ClothVertex *verts, int nVerts, struct MFace *face, int totface ); int cloth_uses_vgroup(struct ClothModifierData *clmd); // needed for collision.c diff --git a/source/blender/blenkernel/BKE_collision.h b/source/blender/blenkernel/BKE_collision.h index 453c16bb8c8..75fdc4981a0 100644 --- a/source/blender/blenkernel/BKE_collision.h +++ b/source/blender/blenkernel/BKE_collision.h @@ -135,16 +135,10 @@ void bvhtree_update_from_mvert ( BVHTree * bvhtree, struct MFace *faces, int num ///////////////////////////////////////////////// -struct LinkNode *BLI_linklist_append_fast ( struct LinkNode **listp, void *ptr ); - // move Collision modifier object inter-frame with step = [0,1] // defined in collisions.c void collision_move_object ( struct CollisionModifierData *collmd, float step, float prevstep ); -// interface for collision functions -void collisions_compute_barycentric ( float pv[3], float p1[3], float p2[3], float p3[3], float *w1, float *w2, float *w3 ); -void interpolateOnTriangle ( float to[3], float v1[3], float v2[3], float v3[3], double w1, double w2, double w3 ); - ///////////////////////////////////////////////// // used in effect.c ///////////////////////////////////////////////// diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h index e5e172accca..99676e444f3 100644 --- a/source/blender/blenkernel/BKE_customdata.h +++ b/source/blender/blenkernel/BKE_customdata.h @@ -291,11 +291,7 @@ void CustomData_bmesh_set_default(struct CustomData *data, void **block); void CustomData_bmesh_free_block(struct CustomData *data, void **block); /* copy custom data to/from layers as in mesh/derivedmesh, to editmesh - blocks of data. the CustomData's must not be compatible */ -void CustomData_to_em_block(const struct CustomData *source, - struct CustomData *dest, int index, void **block); -void CustomData_from_em_block(const struct CustomData *source, - struct CustomData *dest, void *block, int index); + * blocks of data. the CustomData's must not be compatible */ void CustomData_to_bmesh_block(const struct CustomData *source, struct CustomData *dest, int src_index, void **dest_block); void CustomData_from_bmesh_block(const struct CustomData *source, diff --git a/source/blender/blenkernel/BKE_depsgraph.h b/source/blender/blenkernel/BKE_depsgraph.h index 1bc85a64c77..fcc9f860471 100644 --- a/source/blender/blenkernel/BKE_depsgraph.h +++ b/source/blender/blenkernel/BKE_depsgraph.h @@ -97,9 +97,6 @@ short are_obs_related(struct DagForest *dag, void *ob1, void *ob2); int is_acyclic(struct DagForest *dag); // //int get_cycles(struct DagForest *dag, struct DagNodeQueue **queues, int *count); // -void boundbox_deps(void); -void draw_all_deps(void); - /* ********** API *************** */ /* Note that the DAG never executes changes in Objects, only sets flags in Objects */ diff --git a/source/blender/blenkernel/BKE_effect.h b/source/blender/blenkernel/BKE_effect.h index c2706ddb5c0..bb17c891020 100644 --- a/source/blender/blenkernel/BKE_effect.h +++ b/source/blender/blenkernel/BKE_effect.h @@ -109,10 +109,6 @@ typedef struct EffectorCache { int flag; } EffectorCache; -struct Effect *copy_effect(struct Effect *eff); -void copy_effects(struct ListBase *lbn, struct ListBase *lb); -void deselectall_eff(struct Object *ob); - void free_partdeflect(struct PartDeflect *pd); struct ListBase *pdInitEffectors(struct Scene *scene, struct Object *ob_src, struct ParticleSystem *psys_src, struct EffectorWeights *weights); void pdEndEffectors(struct ListBase **effectors); diff --git a/source/blender/blenkernel/BKE_icons.h b/source/blender/blenkernel/BKE_icons.h index 85f259c3d94..3be11913f9e 100644 --- a/source/blender/blenkernel/BKE_icons.h +++ b/source/blender/blenkernel/BKE_icons.h @@ -82,7 +82,7 @@ void BKE_previewimg_free(struct PreviewImage **prv); void BKE_previewimg_free_id(struct ID *id); /* create a new preview image */ -struct PreviewImage* BKE_previewimg_create(void) ; +struct PreviewImage* BKE_previewimg_create(void); /* create a copy of the preview image */ struct PreviewImage* BKE_previewimg_copy(struct PreviewImage *prv); diff --git a/source/blender/blenkernel/BKE_idcode.h b/source/blender/blenkernel/BKE_idcode.h index 2188bed1bf7..d8e77abc989 100644 --- a/source/blender/blenkernel/BKE_idcode.h +++ b/source/blender/blenkernel/BKE_idcode.h @@ -77,7 +77,7 @@ int BKE_idcode_is_valid(int code); /** * Return an ID code and steps the index forward 1. * - * @param index, start as 0. + * @param index start as 0. * @return the code, 0 when all codes have been returned. */ int BKE_idcode_iter_step(int *index); diff --git a/source/blender/blenkernel/BKE_idprop.h b/source/blender/blenkernel/BKE_idprop.h index 5a661f7c731..c4321d25271 100644 --- a/source/blender/blenkernel/BKE_idprop.h +++ b/source/blender/blenkernel/BKE_idprop.h @@ -75,7 +75,6 @@ void IDP_ResizeIDPArray(struct IDProperty *prop, int len); /*this function works for strings too!*/ void IDP_ResizeArray(struct IDProperty *prop, int newlen); void IDP_FreeArray(struct IDProperty *prop); -void IDP_UnlinkArray(struct IDProperty *prop); /* ---------- String Type ------------ */ IDProperty *IDP_NewString(const char *st, const char *name, int maxlen);/* maxlen excludes '\0' */ diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index 722ead80ad9..f5437645551 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -149,9 +149,6 @@ void BKE_image_assign_ibuf(struct Image *ima, struct ImBuf *ibuf); void BKE_image_user_calc_frame(struct ImageUser *iuser, int cfra, int fieldnr); int BKE_image_user_get_frame(const struct ImageUser *iuser, int cfra, int fieldnr); -/* fix things in ImageUser when new image gets assigned */ -void BKE_image_user_new_image(struct Image *ima, struct ImageUser *iuser); - /* sets index offset for multilayer files */ struct RenderPass *BKE_image_multilayer_index(struct RenderResult *rr, struct ImageUser *iuser); diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h index e18a510ac07..23da122ed8b 100644 --- a/source/blender/blenkernel/BKE_library.h +++ b/source/blender/blenkernel/BKE_library.h @@ -83,9 +83,10 @@ void BKE_library_make_local(struct Main *bmain, struct Library *lib, int untagge 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); -void IMAnames_to_pupstring(const char **str, const char *title, const char *extraops, struct ListBase *lb, struct ID *link, short *nr); -void IPOnames_to_pupstring(const char **str, const char *title, const char *extraops, struct ListBase *lb, struct ID* link, short *nr, int blocktype); +void IDnames_to_pupstring(const char **str, const char *title, const char *extraops, + 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); void flag_listbase_ids(ListBase *lb, short flag, short value); void flag_all_listbases_ids(short flag, short value); diff --git a/source/blender/blenkernel/BKE_material.h b/source/blender/blenkernel/BKE_material.h index 3e73f6b9dd9..99561a687b9 100644 --- a/source/blender/blenkernel/BKE_material.h +++ b/source/blender/blenkernel/BKE_material.h @@ -50,7 +50,6 @@ void free_material(struct Material *sc); void test_object_materials(struct ID *id); void resize_object_material(struct Object *ob, const short totcol); void init_material(struct Material *ma); -struct Material *add_material_main(struct Main *main, const char *name); struct Material *add_material(const char *name); struct Material *copy_material(struct Material *ma); struct Material *localize_material(struct Material *ma); @@ -99,10 +98,6 @@ void free_matcopybuf(void); void copy_matcopybuf(struct Material *ma); void paste_matcopybuf(struct Material *ma); -void clear_mat_mtex_copybuf(void); -void copy_mat_mtex_copybuf(struct ID *id); -void paste_mat_mtex_copybuf(struct ID *id); - /* handle backward compatibility for tface/materials called from doversion (fileload=1) or Help Menu (fileload=0) */ int do_version_tface(struct Main *main, int fileload); diff --git a/source/blender/blenkernel/BKE_mball.h b/source/blender/blenkernel/BKE_mball.h index e3b5a006edf..fafd2a3d30e 100644 --- a/source/blender/blenkernel/BKE_mball.h +++ b/source/blender/blenkernel/BKE_mball.h @@ -166,7 +166,7 @@ struct Object *find_basis_mball(struct Scene *scene, struct Object *ob); int is_basis_mball(struct Object *ob); int is_mball_basis_for(struct Object *ob1, struct Object *ob2); void metaball_polygonize(struct Scene *scene, struct Object *ob, struct ListBase *dispbase); -void calc_mballco(struct MetaElem *ml, float *vec); +void calc_mballco(struct MetaElem *ml, float vec[3]); float densfunc(struct MetaElem *ball, float x, float y, float z); float metaball(float x, float y, float z); void accum_mballfaces(int i1, int i2, int i3, int i4); @@ -174,5 +174,10 @@ void *new_pgn_element(int size); int nextcwedge (int edge, int face); void BKE_freecubetable(void); +int BKE_metaball_minmax(struct MetaBall *mb, float min[3], float max[3]); +int BKE_metaball_center_median(struct MetaBall *mb, float cent[3]); +int BKE_metaball_center_bounds(struct MetaBall *mb, float cent[3]); +void BKE_metaball_translate(struct MetaBall *mb, float offset[3]); + #endif diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index 0855d8b6057..6c6153523b7 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -99,6 +99,18 @@ void mesh_calc_poly_center(struct MPoly *mpoly, struct MLoop *loopstart, float mesh_calc_poly_area(struct MPoly *mpoly, struct MLoop *loopstart, struct MVert *mvarray, float polynormal[3]); +/* Find the index of the loop in 'poly' which references vertex, + returns -1 if not found */ +int poly_find_loop_from_vert(const struct MPoly *poly, + const struct MLoop *loopstart, + unsigned vert); + +/* Fill 'adj_r' with the loop indices in 'poly' adjacent to the + vertex. Returns the index of the loop matching vertex, or -1 if the + vertex is not in 'poly' */ +int poly_get_adj_loops_from_vert(unsigned adj_r[3], const struct MPoly *poly, + const struct MLoop *mloop, unsigned vert); + void unlink_mesh(struct Mesh *me); void free_mesh(struct Mesh *me, int unlink); struct Mesh *add_mesh(const char *name); @@ -136,7 +148,7 @@ void mesh_calc_normals_tessface(struct MVert *mverts, int numVerts,struct MFace const char *mesh_cmp(struct Mesh *me1, struct Mesh *me2, float thresh); struct BoundBox *mesh_get_bb(struct Object *ob); -void mesh_get_texspace(struct Mesh *me, float *loc_r, float *rot_r, float *size_r); +void mesh_get_texspace(struct Mesh *me, float r_loc[3], float r_rot[3], float r_size[3]); /* if old, it converts mface->edcode to edge drawflags */ void make_edges(struct Mesh *me, int old); @@ -238,16 +250,9 @@ typedef struct IndexNode { void create_vert_poly_map(struct ListBase **map, IndexNode **mem, struct MPoly *mface, struct MLoop *mloop, const int totvert, const int totface, const int totloop); -void create_vert_face_map(struct ListBase **map, IndexNode **mem, const struct MFace *mface, - const int totvert, const int totface); void create_vert_edge_map(struct ListBase **map, IndexNode **mem, const struct MEdge *medge, const int totvert, const int totedge); -/* functions for making menu's from customdata layers */ -int mesh_layers_menu_charlen(struct CustomData *data, int type); /* use this to work out how many chars to allocate */ -void mesh_layers_menu_concat(struct CustomData *data, int type, char *str); -int mesh_layers_menu(struct CustomData *data, int type); - /* vertex level transformations & checks (no derived mesh) */ int minmax_mesh(struct Mesh *me, float min[3], float max[3]); diff --git a/source/blender/blenkernel/BKE_movieclip.h b/source/blender/blenkernel/BKE_movieclip.h index 2d78e924c90..793ad4dca0e 100644 --- a/source/blender/blenkernel/BKE_movieclip.h +++ b/source/blender/blenkernel/BKE_movieclip.h @@ -55,8 +55,6 @@ void BKE_movieclip_aspect(struct MovieClip *clip, float *aspx, float *aspy); int BKE_movieclip_has_frame(struct MovieClip *clip, struct MovieClipUser *user); void BKE_movieclip_user_set_frame(struct MovieClipUser *user, int framenr); -void BKE_movieclip_select_track(struct MovieClip *clip, struct MovieTrackingTrack *track, int area, int extend); - void BKE_movieclip_update_scopes(struct MovieClip *clip, struct MovieClipUser *user, struct MovieClipScopes *scopes); void BKE_movieclip_get_cache_segments(struct MovieClip *clip, struct MovieClipUser *user, int *totseg_r, int **points_r); diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 926a0e2cc6c..753161d0788 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -165,7 +165,7 @@ typedef struct bNodeType { /// Create a template from an existing node. struct bNodeTemplate (*templatefunc)(struct bNode *); /** If a node can be made from the template in the given node tree. - * \example Node groups can not be created inside their own node tree. + * \note Node groups can not be created inside their own node tree. */ int (*validfunc)(struct bNodeTree *ntree, struct bNodeTemplate *ntemp); @@ -180,6 +180,10 @@ typedef struct bNodeType { struct bNodeTree *(*group_edit_set)(struct bNode *node, int edit); void (*group_edit_clear)(struct bNode *node); + /* Generate a temporary list of internal links (bNodeLink), for muting and disconnect operators. + * Result must be freed by caller! + */ + ListBase (*internal_connect)(struct bNodeTree *, struct bNode *node); /* **** execution callbacks **** */ void *(*initexecfunc)(struct bNode *node); @@ -189,24 +193,10 @@ typedef struct bNodeType { * when a final generic version of execution code is defined, this will be changed anyway */ void (*newexecfunc)(void *data, int thread, struct bNode *, void *nodedata, struct bNodeStack **, struct bNodeStack **); - /* This is the muting callback. - * XXX Mimics the newexecfunc signature... Not sure all of this will be useful, we will see. - */ - void (*mutefunc)(void *data, int thread, struct bNode *, void *nodedata, struct bNodeStack **, struct bNodeStack **); - /* And the muting util. - * Returns links as a ListBase, as pairs of bNodeStack* if in/out bNodeStacks were provided, - * else as pairs of bNodeSocket* if node tree was provided. - */ - ListBase (*mutelinksfunc)(struct bNodeTree *, struct bNode *, struct bNodeStack **, struct bNodeStack **, - struct GPUNodeStack *, struct GPUNodeStack *); /* gpu */ int (*gpufunc)(struct GPUMaterial *mat, struct bNode *node, struct GPUNodeStack *in, struct GPUNodeStack *out); /* extended gpu function */ int (*gpuextfunc)(struct GPUMaterial *mat, struct bNode *node, void *nodedata, struct GPUNodeStack *in, struct GPUNodeStack *out); - /* This is the muting gpu callback. - * XXX Mimics the gpuextfunc signature... Not sure all of this will be useful, we will see. - */ - int (*gpumutefunc)(struct GPUMaterial *, struct bNode *, void *, struct GPUNodeStack *, struct GPUNodeStack *); } bNodeType; /* node->exec, now in use for composites (#define for break is same as ready yes) */ @@ -284,12 +274,8 @@ typedef struct bNodeTreeType int (*validate_link)(struct bNodeTree *ntree, struct bNodeLink *link); - /* Default muting pointers. */ - void (*mutefunc)(void *data, int thread, struct bNode *, void *nodedata, struct bNodeStack **, struct bNodeStack **); - ListBase (*mutelinksfunc)(struct bNodeTree *, struct bNode *, struct bNodeStack **, struct bNodeStack **, - struct GPUNodeStack *, struct GPUNodeStack *); - /* gpu */ - int (*gpumutefunc)(struct GPUMaterial *, struct bNode *, void *, struct GPUNodeStack *, struct GPUNodeStack *); + /* Default internal linking. */ + ListBase (*internal_connect)(struct bNodeTree *, struct bNode *node); } bNodeTreeType; /* ************** GENERIC API, TREES *************** */ @@ -343,7 +329,7 @@ struct bNode *nodeAddNode(struct bNodeTree *ntree, struct bNodeTemplate *ntemp); void nodeUnlinkNode(struct bNodeTree *ntree, struct bNode *node); void nodeUniqueName(struct bNodeTree *ntree, struct bNode *node); -void nodeRegisterType(struct bNodeTreeType *ttype, struct bNodeType *ntype) ; +void nodeRegisterType(struct bNodeTreeType *ttype, struct bNodeType *ntype); void nodeMakeDynamicType(struct bNode *node); int nodeDynamicUnlinkText(struct ID *txtid); @@ -353,6 +339,7 @@ struct bNode *nodeCopyNode(struct bNodeTree *ntree, struct bNode *node); struct bNodeLink *nodeAddLink(struct bNodeTree *ntree, struct bNode *fromnode, struct bNodeSocket *fromsock, struct bNode *tonode, struct bNodeSocket *tosock); void nodeRemLink(struct bNodeTree *ntree, struct bNodeLink *link); void nodeRemSocketLinks(struct bNodeTree *ntree, struct bNodeSocket *sock); +void nodeInternalRelink(struct bNodeTree *ntree, struct bNode *node); void nodeSpaceCoords(struct bNode *node, float *locx, float *locy); void nodeAttachNode(struct bNode *node, struct bNode *parent); @@ -418,18 +405,12 @@ void node_type_exec_new(struct bNodeType *ntype, void (*freeexecfunc)(struct bNode *node, void *nodedata), void (*newexecfunc)(void *data, int thread, struct bNode *, void *nodedata, struct bNodeStack **, struct bNodeStack **)); -void node_type_mute(struct bNodeType *ntype, - void (*mutefunc)(void *data, int thread, struct bNode *, void *nodedata, - struct bNodeStack **, struct bNodeStack **), - ListBase (*mutelinksfunc)(struct bNodeTree *, struct bNode *, struct bNodeStack **, - struct bNodeStack **, struct GPUNodeStack*, struct GPUNodeStack*)); +void node_type_internal_connect(struct bNodeType *ntype, ListBase (*internal_connect)(struct bNodeTree *, struct bNode *)); void node_type_gpu(struct bNodeType *ntype, int (*gpufunc)(struct GPUMaterial *mat, struct bNode *node, struct GPUNodeStack *in, struct GPUNodeStack *out)); void node_type_gpu_ext(struct bNodeType *ntype, int (*gpuextfunc)(struct GPUMaterial *mat, struct bNode *node, void *nodedata, struct GPUNodeStack *in, struct GPUNodeStack *out)); -void node_type_gpu_mute(struct bNodeType *ntype, int (*gpumutefunc)(struct GPUMaterial *, struct bNode *, void *, - struct GPUNodeStack *, struct GPUNodeStack *)); void node_type_compatibility(struct bNodeType *ntype, short compatibility); /* ************** COMMON NODES *************** */ @@ -732,9 +713,7 @@ struct TexResult; /* API */ int ntreeTexTagAnimated(struct bNodeTree *ntree); -void ntreeTexSetPreviewFlag(int); void ntreeTexCheckCyclics(struct bNodeTree *ntree); -char* ntreeTexOutputMenu(struct bNodeTree *ntree); struct bNodeTreeExec *ntreeTexBeginExecTree(struct bNodeTree *ntree, int use_tree_data); void ntreeTexEndExecTree(struct bNodeTreeExec *exec, int use_tree_data); diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index ac703663864..1e9bb85b549 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -83,9 +83,6 @@ struct Object *copy_object(struct Object *ob); void make_local_object(struct Object *ob); int object_is_libdata(struct Object *ob); int object_data_is_libdata(struct Object *ob); -void set_mblur_offs(float blur); -void set_field_offs(float field); -void disable_speed_curve(int val); void object_scale_to_mat3(struct Object *ob, float mat[][3]); void object_rot_to_mat3(struct Object *ob, float mat[][3]); @@ -104,11 +101,11 @@ void where_is_object_mat(struct Scene *scene, struct Object *ob, float obmat[4][ struct BoundBox *unit_boundbox(void); void boundbox_set_from_min_max(struct BoundBox *bb, float min[3], float max[3]); struct BoundBox *object_get_boundbox(struct Object *ob); -void object_get_dimensions(struct Object *ob, float *value); +void object_get_dimensions(struct Object *ob, float vec[3]); void object_set_dimensions(struct Object *ob, const float *value); void object_boundbox_flag(struct Object *ob, int flag, int set); void minmax_object(struct Object *ob, float min[3], float max[3]); -int minmax_object_duplis(struct Scene *scene, struct Object *ob, float *min, float *max); +int minmax_object_duplis(struct Scene *scene, struct Object *ob, float min[3], float max[3]); /* sometimes min-max isnt enough, we need to loop over each point */ void BKE_object_foreach_display_point( @@ -122,7 +119,6 @@ void BKE_scene_foreach_display_point( int BKE_object_parent_loop_check(const struct Object *parent, const struct Object *ob); -void solve_tracking (struct Object *ob, float targetmat[][4]); int ray_hit_boundbox(struct BoundBox *bb, float ray_start[3], float ray_normal[3]); void *object_tfm_backup(struct Object *ob); diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h index c03ecca17cf..4407be4c8be 100644 --- a/source/blender/blenkernel/BKE_particle.h +++ b/source/blender/blenkernel/BKE_particle.h @@ -319,7 +319,7 @@ void psys_free_particles(struct ParticleSystem *psys); void psys_free_children(struct ParticleSystem *psys); void psys_interpolate_particle(short type, struct ParticleKey keys[4], float dt, struct ParticleKey *result, int velocity); -void psys_vec_rot_to_face(struct DerivedMesh *dm, struct ParticleData *pa, float *vec); +void psys_vec_rot_to_face(struct DerivedMesh *dm, struct ParticleData *pa, float vec[3]); void psys_mat_hair_to_object(struct Object *ob, struct DerivedMesh *dm, short from, struct ParticleData *pa, float hairmat[][4]); void psys_mat_hair_to_global(struct Object *ob, struct DerivedMesh *dm, short from, struct ParticleData *pa, float hairmat[][4]); void psys_mat_hair_to_orco(struct Object *ob, struct DerivedMesh *dm, short from, struct ParticleData *pa, float hairmat[][4]); diff --git a/source/blender/blenkernel/BKE_pointcache.h b/source/blender/blenkernel/BKE_pointcache.h index 38f0503b40d..eba5c117199 100644 --- a/source/blender/blenkernel/BKE_pointcache.h +++ b/source/blender/blenkernel/BKE_pointcache.h @@ -288,12 +288,6 @@ void BKE_ptcache_mem_pointers_init(struct PTCacheMem *pm); void BKE_ptcache_mem_pointers_incr(struct PTCacheMem *pm); int BKE_ptcache_mem_pointers_seek(int point_index, struct PTCacheMem *pm); -/* Copy a specific data type from cache data to point data. */ -void BKE_ptcache_data_get(void **data, int type, int index, void *to); - -/* Copy a specific data type from point data to cache data. */ -void BKE_ptcache_data_set(void **data, int type, void *from); - /* Main cache reading call. */ int BKE_ptcache_read(PTCacheID *pid, float cfra); diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h index 5c6058b1453..d787993e030 100644 --- a/source/blender/blenkernel/BKE_sequencer.h +++ b/source/blender/blenkernel/BKE_sequencer.h @@ -40,6 +40,8 @@ struct Strip; struct StripElem; struct bSound; +struct SeqIndexBuildContext; + #define BUILD_SEQAR_COUNT_NOTHING 0 #define BUILD_SEQAR_COUNT_CURRENT 1 #define BUILD_SEQAR_COUNT_CHILDREN 2 @@ -194,9 +196,10 @@ void update_changed_seq_and_deps(struct Scene *scene, struct Sequence *changed_s int input_have_to_preprocess( SeqRenderData context, struct Sequence * seq, float cfra); -void seq_proxy_rebuild(struct Main * bmain, - struct Scene *scene, struct Sequence * seq, +struct SeqIndexBuildContext *seq_proxy_rebuild_context(struct Main *bmain, struct Scene *scene, struct Sequence *seq); +void seq_proxy_rebuild(struct SeqIndexBuildContext *context, short *stop, short *do_update, float *progress); +void seq_proxy_rebuild_finish(struct SeqIndexBuildContext *context, short stop); /* ********************************************************************** @@ -283,7 +286,6 @@ void seq_update_sound_bounds_all(struct Scene *scene); void seq_update_sound_bounds(struct Scene* scene, struct Sequence *seq); void seq_update_muting(struct Editing *ed); void seq_update_sound(struct Scene *scene, struct bSound *sound); -void seqbase_sound_reload(struct Scene *scene, ListBase *seqbase); void seqbase_unique_name_recursive(ListBase *seqbasep, struct Sequence *seq); void seqbase_dupli_recursive(struct Scene *scene, struct Scene *scene_to, ListBase *nseqbase, ListBase *seqbase, int dupe_flag); diff --git a/source/blender/blenkernel/BKE_sketch.h b/source/blender/blenkernel/BKE_sketch.h index 76b3dbacf7f..9cdf9a8fb62 100644 --- a/source/blender/blenkernel/BKE_sketch.h +++ b/source/blender/blenkernel/BKE_sketch.h @@ -142,7 +142,7 @@ void sk_reverseStroke(SK_Stroke *stk); void sk_filterLastContinuousStroke(SK_Stroke *stk); void sk_filterStroke(SK_Stroke *stk, int start, int end); -void sk_initPoint(SK_Point *pt, SK_DrawData *dd, float *no); +void sk_initPoint(SK_Point *pt, SK_DrawData *dd, const float no[3]); void sk_copyPoint(SK_Point *dst, SK_Point *src); int sk_stroke_filtermval(SK_DrawData *dd); diff --git a/source/blender/blenkernel/BKE_subsurf.h b/source/blender/blenkernel/BKE_subsurf.h index 35de1c21a54..8f32063c243 100644 --- a/source/blender/blenkernel/BKE_subsurf.h +++ b/source/blender/blenkernel/BKE_subsurf.h @@ -41,10 +41,10 @@ struct MultiresSubsurf; struct Object; struct PBVH; struct SubsurfModifierData; -struct _CCGEdge; -struct _CCGFace; -struct _CCGSubsurf; -struct _CCGVert; +struct CCGEdge; +struct CCGFace; +struct CCGSubsurf; +struct CCGVert; struct EdgeHash; struct PBVH; struct DMGridData; @@ -65,14 +65,14 @@ void subsurf_calculate_limit_positions(struct Mesh *me, float (*positions_r)[3]) typedef struct CCGDerivedMesh { DerivedMesh dm; - struct _CCGSubSurf *ss; + struct CCGSubSurf *ss; int freeSS; int drawInteriorEdges, useSubsurfUv; - struct {int startVert; struct _CCGVert *vert;} *vertMap; - struct {int startVert; int startEdge; struct _CCGEdge *edge;} *edgeMap; + struct {int startVert; struct CCGVert *vert;} *vertMap; + struct {int startVert; int startEdge; struct CCGEdge *edge;} *edgeMap; struct {int startVert; int startEdge; - int startFace; struct _CCGFace *face;} *faceMap; + int startFace; struct CCGFace *face;} *faceMap; short *edgeFlags; char *faceFlags; @@ -89,7 +89,7 @@ typedef struct CCGDerivedMesh { struct DMGridData **gridData; struct DMGridAdjacency *gridAdjacency; int *gridOffset; - struct _CCGFace **gridFaces; + struct CCGFace **gridFaces; struct { struct MultiresModifierData *mmd; diff --git a/source/blender/blenkernel/BKE_text.h b/source/blender/blenkernel/BKE_text.h index 504b859c183..efd38cac232 100644 --- a/source/blender/blenkernel/BKE_text.h +++ b/source/blender/blenkernel/BKE_text.h @@ -92,8 +92,6 @@ void txt_backspace_word (struct Text *text); int txt_add_char (struct Text *text, unsigned int add); int txt_add_raw_char (struct Text *text, unsigned int add); int txt_replace_char (struct Text *text, unsigned int add); -void txt_export_to_object(struct Text *text); -void txt_export_to_objects(struct Text *text); void txt_unindent (struct Text *text); void txt_comment (struct Text *text); void txt_indent (struct Text *text); @@ -107,8 +105,6 @@ struct TextMarker *txt_find_marker (struct Text *text, struct TextLine *line, i struct TextMarker *txt_find_marker_region (struct Text *text, struct TextLine *line, int start, int end, int group, int flags); struct TextMarker *txt_prev_marker (struct Text *text, struct TextMarker *marker); struct TextMarker *txt_next_marker (struct Text *text, struct TextMarker *marker); -struct TextMarker *txt_prev_marker_color (struct Text *text, struct TextMarker *marker); -struct TextMarker *txt_next_marker_color (struct Text *text, struct TextMarker *marker); /* utility functions, could be moved somewhere more generic but are python/text related */ int text_check_bracket(char ch); diff --git a/source/blender/blenkernel/BKE_tracking.h b/source/blender/blenkernel/BKE_tracking.h index 1be858ecf80..f1daa5d63b3 100644 --- a/source/blender/blenkernel/BKE_tracking.h +++ b/source/blender/blenkernel/BKE_tracking.h @@ -27,7 +27,7 @@ #ifndef __BKE_TRACKING_H__ #define __BKE_TRACKING_H__ -/** \file BKE_trackingp.h +/** \file BKE_tracking.h * \ingroup bke * \author Sergey Sharybin */ @@ -163,11 +163,18 @@ 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); -#define TRACK_SELECTED(track) ((((track)->flag&TRACK_HIDDEN)==0) && ((track)->flag&SELECT || (track)->pat_flag&SELECT || (track)->search_flag&SELECT)) -#define TRACK_AREA_SELECTED(track, area) ((((track)->flag&TRACK_HIDDEN)==0) && ((area)==TRACK_AREA_POINT?(track)->flag&SELECT : ((area)==TRACK_AREA_PAT?(track)->pat_flag&SELECT:(track)->search_flag&SELECT))) -#define TRACK_VIEW_SELECTED(sc, track) ((TRACK_AREA_SELECTED(track, TRACK_AREA_POINT) || (((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 TRACK_SELECTED(track) ((track)->flag&SELECT || (track)->pat_flag&SELECT || (track)->search_flag&SELECT) -#define MARKER_VISIBLE(sc, marker) (((marker)->flag&MARKER_DISABLED)==0 || ((sc)->flag&SC_HIDE_DISABLED)==0) +#define TRACK_AREA_SELECTED(track, area) ((area)==TRACK_AREA_POINT ? (track)->flag&SELECT : \ + ((area)==TRACK_AREA_PAT ? (track)->pat_flag&SELECT : \ + (track)->search_flag&SELECT)) + +#define TRACK_VIEW_SELECTED(sc, track) ((((track)->flag & TRACK_HIDDEN)==0) && \ + ( TRACK_AREA_SELECTED(track, TRACK_AREA_POINT) || \ + (((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 TRACK_CLEAR_UPTO 0 #define TRACK_CLEAR_REMAINED 1 diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index 8d69597f12d..76df916ff44 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -156,7 +156,6 @@ set(SRC BKE_armature.h BKE_blender.h BKE_bmesh.h - BKE_bmeshCustomData.h BKE_bmfont.h BKE_bmfont_types.h BKE_boids.h diff --git a/source/blender/blenkernel/depsgraph_private.h b/source/blender/blenkernel/depsgraph_private.h index 0db3c5615f5..f27ee2f1a41 100644 --- a/source/blender/blenkernel/depsgraph_private.h +++ b/source/blender/blenkernel/depsgraph_private.h @@ -132,6 +132,4 @@ void graph_print_queue(DagNodeQueue *nqueue); void graph_print_queue_dist(DagNodeQueue *nqueue); void graph_print_adj_list(void); -int build_deps(short mask); - -#endif +#endif /* __DEPSGRAPH_PRIVATE_H__ */ diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c index 59aa79a139e..f843d21a975 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.c +++ b/source/blender/blenkernel/intern/CCGSubSurf.c @@ -20,13 +20,6 @@ # define CCG_INLINE inline #endif -/* copied from BKE_utildefines.h ugh */ -#ifdef __GNUC__ -# define UNUSED(x) UNUSED_ ## x __attribute__((__unused__)) -#else -# define UNUSED(x) x -#endif - /* used for normalize_v3 in BLI_math_vector * float.h's FLT_EPSILON causes trouble with subsurf normals - campbell */ #define EPSILON (1.0e-35f) @@ -306,7 +299,7 @@ enum { Face_eEffected = (1 << 0) } /*FaceFlags*/; -struct _CCGVert { +struct CCGVert { CCGVert *next; /* EHData.next */ CCGVertHDL vHDL; /* EHData.key */ @@ -317,9 +310,13 @@ struct _CCGVert { // byte *levelData; // byte *userData; }; -#define VERT_getLevelData(v) ((byte *) &(v)[1]) -struct _CCGEdge { +static CCG_INLINE byte *VERT_getLevelData(CCGVert *v) +{ + return (byte*)(&(v)[1]); +} + +struct CCGEdge { CCGEdge *next; /* EHData.next */ CCGEdgeHDL eHDL; /* EHData.key */ @@ -332,9 +329,13 @@ struct _CCGEdge { // byte *levelData; // byte *userData; }; -#define EDGE_getLevelData(e) ((byte *) &(e)[1]) -struct _CCGFace { +static CCG_INLINE byte *EDGE_getLevelData(CCGEdge *e) +{ + return (byte*)(&(e)[1]); +} + +struct CCGFace { CCGFace *next; /* EHData.next */ CCGFaceHDL fHDL; /* EHData.key */ @@ -346,9 +347,21 @@ struct _CCGFace { // byte **gridData; // byte *userData; }; -#define FACE_getVerts(f) ((CCGVert**) &(f)[1]) -#define FACE_getEdges(f) ((CCGEdge**) &(FACE_getVerts(f)[(f)->numVerts])) -#define FACE_getCenterData(f) ((byte *) &(FACE_getEdges(f)[(f)->numVerts])) + +static CCG_INLINE CCGVert **FACE_getVerts(CCGFace *f) +{ + return (CCGVert**)(&f[1]); +} + +static CCG_INLINE CCGEdge **FACE_getEdges(CCGFace *f) +{ + return (CCGEdge**)(&(FACE_getVerts(f)[f->numVerts])); +} + +static CCG_INLINE byte *FACE_getCenterData(CCGFace *f) +{ + return (byte*)(&(FACE_getEdges(f)[(f)->numVerts])); +} typedef enum { eSyncState_None = 0, @@ -358,7 +371,7 @@ typedef enum { eSyncState_Partial } SyncState; -struct _CCGSubSurf { +struct CCGSubSurf { EHash *vMap; /* map of CCGVertHDL -> Vert */ EHash *eMap; /* map of CCGEdgeHDL -> Edge */ EHash *fMap; /* map of CCGFaceHDL -> Face */ diff --git a/source/blender/blenkernel/intern/CCGSubSurf.h b/source/blender/blenkernel/intern/CCGSubSurf.h index 543411f26f4..a1cbd98d7e8 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.h +++ b/source/blender/blenkernel/intern/CCGSubSurf.h @@ -8,28 +8,27 @@ typedef void* CCGVertHDL; typedef void* CCGEdgeHDL; typedef void* CCGFaceHDL; -typedef struct _CCGVert CCGVert; -typedef struct _CCGEdge CCGEdge; -typedef struct _CCGFace CCGFace; +typedef struct CCGSubSurf CCGSubSurf; +typedef struct CCGVert CCGVert; +typedef struct CCGEdge CCGEdge; +typedef struct CCGFace CCGFace; -typedef struct _CCGMeshIFC CCGMeshIFC; -struct _CCGMeshIFC { +typedef struct CCGMeshIFC { int vertUserSize, edgeUserSize, faceUserSize; int vertDataSize; -}; +} CCGMeshIFC; /***/ typedef void* CCGAllocatorHDL; -typedef struct _CCGAllocatorIFC CCGAllocatorIFC; -struct _CCGAllocatorIFC { +typedef struct CCGAllocatorIFC { void* (*alloc) (CCGAllocatorHDL a, int numBytes); void* (*realloc) (CCGAllocatorHDL a, void *ptr, int newSize, int oldSize); void (*free) (CCGAllocatorHDL a, void *ptr); void (*release) (CCGAllocatorHDL a); -}; +} CCGAllocatorIFC; /***/ @@ -46,13 +45,9 @@ typedef enum { /***/ -typedef struct _CCGSubSurf CCGSubSurf; - CCGSubSurf* ccgSubSurf_new (CCGMeshIFC *ifc, int subdivisionLevels, CCGAllocatorIFC *allocatorIFC, CCGAllocatorHDL allocator); void ccgSubSurf_free (CCGSubSurf *ss); -CCGError ccgSubSurf_sync (CCGSubSurf *ss); - CCGError ccgSubSurf_initFullSync (CCGSubSurf *ss); CCGError ccgSubSurf_initPartialSync (CCGSubSurf *ss); @@ -141,9 +136,9 @@ int ccgSubSurf_getNumFinalFaces (const CCGSubSurf *ss); /***/ -typedef struct _CCGVertIterator CCGVertIterator; -typedef struct _CCGEdgeIterator CCGEdgeIterator; -typedef struct _CCGFaceIterator CCGFaceIterator; +typedef struct CCGVertIterator CCGVertIterator; +typedef struct CCGEdgeIterator CCGEdgeIterator; +typedef struct CCGFaceIterator CCGFaceIterator; CCGVertIterator* ccgSubSurf_getVertIterator (CCGSubSurf *ss); CCGEdgeIterator* ccgSubSurf_getEdgeIterator (CCGSubSurf *ss); diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 0a6d8b7c041..16dd722f1fc 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -1900,23 +1900,37 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D CDDM_apply_vert_coords(*final_r, deformedVerts); CDDM_calc_normals(*final_r); /* was CDDM_calc_normals_mapping - campbell */ - } else if (dm) { + } + else if (dm) { *final_r = dm; (*final_r)->calcNormals(*final_r); /* BMESH_ONLY - BMESH_TODO. check if this is needed */ - } else if (!deformedVerts && cage_r && *cage_r) { + } + else if (!deformedVerts && cage_r && *cage_r) { + /* cage should already have up to date normals */ *final_r = *cage_r; (*final_r)->calcNormals(*final_r); /* BMESH_ONLY - BMESH_TODO. check if this is needed */ - } else { + } + else { + /* this is just a copy of the editmesh, no need to calc normals */ *final_r = getEditDerivedBMesh(em, ob, deformedVerts); deformedVerts = NULL; - (*final_r)->calcNormals(*final_r); /* BMESH_ONLY - BMESH_TODO. check if this is needed */ } /* --- */ /* BMESH_ONLY, ensure tessface's used for drawing, - * but dont recalculate if the last modifier in the stack gives us tessfaces */ - DM_ensure_tessface(*final_r); - if (cage_r && (*cage_r != *final_r)) DM_ensure_tessface(*cage_r); + * but dont recalculate if the last modifier in the stack gives us tessfaces + * check if the derived meshes are DM_TYPE_EDITBMESH before calling, this isnt essential + * but quiets annoying error messages since tessfaces wont be created. */ + if ((*final_r)->type != DM_TYPE_EDITBMESH) { + DM_ensure_tessface(*final_r); + } + if (cage_r) { + if ((*cage_r)->type != DM_TYPE_EDITBMESH) { + if (*cage_r != *final_r) { + DM_ensure_tessface(*cage_r); + } + } + } /* --- */ /* add an orco layer if needed */ @@ -2541,7 +2555,7 @@ void DM_calc_auto_bump_scale(DerivedMesh *dm) } } } - nr_tris_to_pile = nr_verts-2 ; + nr_tris_to_pile = nr_verts - 2; 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 }; diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 000d74f110a..c181548eb19 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -1497,8 +1497,8 @@ static void do_nla(Scene *scene, Object *ob, int blocktype) /* Determine if the current frame is within the strip's range */ length = strip->end-strip->start; actlength = strip->actend-strip->actstart; - striptime = (scene_cfra-(strip->start)) / length; - stripframe = (scene_cfra-(strip->start)) ; + striptime = (scene_cfra - strip->start) / length; + stripframe = (scene_cfra - strip->start); if (striptime>=0.0) { diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index bfafd96b95e..77523980a64 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -1649,7 +1649,7 @@ int count_duplilist(Object *ob) for(; psys; psys=psys->next) pdup += psys->totpart; - if(pdup==0){ + if(pdup==0) { Mesh *me= ob->data; return me->totvert; } diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 36646c85dc1..bc18332844b 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -194,7 +194,7 @@ static void copy_bonechildren(Bone* newBone, Bone* oldBone, Bone* actBone, Bone /* For each child in the list, update it's children */ newChildBone = newBone->childbase.first; - for (curBone = oldBone->childbase.first; curBone; curBone = curBone->next){ + for (curBone = oldBone->childbase.first; curBone; curBone = curBone->next) { newChildBone->parent = newBone; copy_bonechildren(newChildBone, curBone, actBone, newActBone); newChildBone = newChildBone->next; @@ -642,7 +642,7 @@ static void pchan_b_bone_defmats(bPoseChannel *pchan, bPoseChanDeform *pdef_info } } -static void b_bone_deform(bPoseChanDeform *pdef_info, Bone *bone, float *co, DualQuat *dq, float defmat[][3]) +static void b_bone_deform(bPoseChanDeform *pdef_info, Bone *bone, float co[3], DualQuat *dq, float defmat[][3]) { Mat4 *b_bone = pdef_info->b_bone_mats; float (*mat)[4] = b_bone[0].mat; @@ -666,8 +666,9 @@ static void b_bone_deform(bPoseChanDeform *pdef_info, Bone *bone, float *co, Dua else { mul_m4_v3(b_bone[a+1].mat, co); - if (defmat) + if (defmat) { copy_m3_m4(defmat, b_bone[a+1].mat); + } } } @@ -736,7 +737,7 @@ static void pchan_deform_mat_add(bPoseChannel *pchan, float weight, float bbonem add_m3_m3m3(mat, mat, wmat); } -static float dist_bone_deform(bPoseChannel *pchan, bPoseChanDeform *pdef_info, float *vec, DualQuat *dq, +static float dist_bone_deform(bPoseChannel *pchan, bPoseChanDeform *pdef_info, float vec[3], DualQuat *dq, float mat[][3], float *co) { Bone *bone = pchan->bone; @@ -783,7 +784,7 @@ static float dist_bone_deform(bPoseChannel *pchan, bPoseChanDeform *pdef_info, f return contrib; } -static void pchan_bone_deform(bPoseChannel *pchan, bPoseChanDeform *pdef_info, float weight, float *vec, DualQuat *dq, +static void pchan_bone_deform(bPoseChannel *pchan, bPoseChanDeform *pdef_info, float weight, float vec[3], DualQuat *dq, float mat[][3], float *co, float *contrib) { float cop[3], bbonemat[3][3]; @@ -1116,7 +1117,7 @@ void armature_mat_world_to_pose(Object *ob, float inmat[][4], float outmat[][4]) /* Convert Wolrd-Space Location to Pose-Space Location * NOTE: this cannot be used to convert to pose-space location of the supplied * pose-channel into its local space (i.e. 'visual'-keyframing) */ -void armature_loc_world_to_pose(Object *ob, float *inloc, float *outloc) +void armature_loc_world_to_pose(Object *ob, const float inloc[3], float outloc[3]) { float xLocMat[4][4] = MAT4_UNITY; float nLocMat[4][4]; @@ -1338,7 +1339,7 @@ void armature_mat_bone_to_pose(bPoseChannel *pchan, float inmat[][4], float outm /* Convert Pose-Space Location to Bone-Space Location * NOTE: this cannot be used to convert to pose-space location of the supplied * pose-channel into its local space (i.e. 'visual'-keyframing) */ -void armature_loc_pose_to_bone(bPoseChannel *pchan, float *inloc, float *outloc) +void armature_loc_pose_to_bone(bPoseChannel *pchan, const float inloc[3], float outloc[3]) { float xLocMat[4][4] = MAT4_UNITY; float nLocMat[4][4]; @@ -1478,7 +1479,7 @@ void BKE_rotMode_change_values (float quat[4], float eul[3], float axis[3], floa * *************************************************************************** */ /* Computes vector and roll based on a rotation. * "mat" must contain only a rotation, and no scaling. */ -void mat3_to_vec_roll(float mat[][3], float *vec, float *roll) +void mat3_to_vec_roll(float mat[][3], float vec[3], float *roll) { if (vec) copy_v3_v3(vec, mat[1]); @@ -1496,7 +1497,7 @@ void mat3_to_vec_roll(float mat[][3], float *vec, float *roll) /* Calculates the rest matrix of a bone based * On its vector and a roll around that vector */ -void vec_roll_to_mat3(float *vec, float roll, float mat[][3]) +void vec_roll_to_mat3(const float vec[3], const float roll, float mat[][3]) { float nor[3], axis[3], target[3] = {0, 1, 0}; float theta; diff --git a/source/blender/blenkernel/intern/booleanops_mesh.c b/source/blender/blenkernel/intern/booleanops_mesh.c index 8dbf2c1c828..ea626df5018 100644 --- a/source/blender/blenkernel/intern/booleanops_mesh.c +++ b/source/blender/blenkernel/intern/booleanops_mesh.c @@ -45,7 +45,7 @@ void CSG_DestroyMeshDescriptor( CSG_MeshDescriptor *mesh -){ +) { // Call mesh descriptors destroy function.... mesh->m_destroy_func(mesh); } @@ -66,7 +66,7 @@ static void CSG_DestroyCSGMeshInternals( CSG_MeshDescriptor *mesh -){ +) { CSG_FreeVertexDescriptor(&(mesh->m_vertex_iterator)); CSG_FreeFaceDescriptor(&(mesh->m_face_iterator)); } @@ -102,7 +102,7 @@ MakeCSGMeshFromBlenderBase( CSG_LoadBlenderMesh( Object * obj, CSG_MeshDescriptor *output -){ +) { Mesh *me; if (output == NULL || obj == NULL) return 0; @@ -132,7 +132,7 @@ CSG_LoadBlenderMesh( int CSG_AddMeshToBlender( CSG_MeshDescriptor *mesh -){ +) { Mesh *me_new = NULL; Object *ob_new = NULL; float inv_mat[4][4]; @@ -172,7 +172,7 @@ CSG_PerformOp( CSG_MeshDescriptor *mesh2, int int_op_type, CSG_MeshDescriptor *output -){ +) { CSG_OperationType op_type; CSG_BooleanOperation * bool_op = CSG_NewBooleanFunction(); @@ -241,7 +241,7 @@ NewBooleanMeshTest( struct Base * base, struct Base * base_select, int op_type -){ +) { CSG_MeshDescriptor m1,m2,output; CSG_MeshDescriptor output2,output3; diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index f5c39f3e30c..9e706c48430 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -833,7 +833,9 @@ void brush_painter_free(BrushPainter *painter) MEM_freeN(painter); } -static void brush_painter_do_partial(BrushPainter *painter, ImBuf *oldtexibuf, int x, int y, int w, int h, int xt, int yt, float *pos) +static void brush_painter_do_partial(BrushPainter *painter, ImBuf *oldtexibuf, + int x, int y, int w, int h, int xt, int yt, + const float pos[2]) { Scene *scene= painter->scene; Brush *brush= painter->brush; @@ -923,7 +925,7 @@ static void brush_painter_do_partial(BrushPainter *painter, ImBuf *oldtexibuf, i } } -static void brush_painter_fixed_tex_partial_update(BrushPainter *painter, float *pos) +static void brush_painter_fixed_tex_partial_update(BrushPainter *painter, const float pos[2]) { const Scene *scene= painter->scene; Brush *brush= painter->brush; @@ -978,7 +980,7 @@ static void brush_painter_fixed_tex_partial_update(BrushPainter *painter, float brush_painter_do_partial(painter, NULL, x1, y2, x2, ibuf->y, 0, 0, pos); } -static void brush_painter_refresh_cache(BrushPainter *painter, float *pos, int use_color_correction) +static void brush_painter_refresh_cache(BrushPainter *painter, const float pos[2], int use_color_correction) { const Scene *scene= painter->scene; Brush *brush= painter->brush; @@ -1042,7 +1044,7 @@ static void brush_apply_pressure(BrushPainter *painter, Brush *brush, float pres brush->spacing = MAX2(1.0f, painter->startspacing*(1.5f-pressure)); } -void brush_jitter_pos(const Scene *scene, Brush *brush, float pos[2], float jitterpos[2]) +void brush_jitter_pos(const Scene *scene, Brush *brush, const float pos[2], float jitterpos[2]) { int use_jitter= brush->jitter != 0; @@ -1069,7 +1071,8 @@ void brush_jitter_pos(const Scene *scene, Brush *brush, float pos[2], float jitt } } -int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, double time, float pressure, void *user, int use_color_correction) +int 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; diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index b61074d9a94..39cfd1ad9e6 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -111,6 +111,13 @@ static int cdDM_getNumEdges(DerivedMesh *dm) static int cdDM_getNumTessFaces(DerivedMesh *dm) { + /* uncomment and add a breakpoint on the printf() + * to help debug tessfaces issues since BMESH merge. */ +#if 0 + if (dm->numTessFaceData == 0 && dm->numPolyData != 0) { + printf("%s: has no faces!, call DM_ensure_tessface() if you need them\n"); + } +#endif return dm->numTessFaceData; } @@ -223,20 +230,6 @@ static ListBase *cdDM_getPolyMap(Object *ob, DerivedMesh *dm) return cddm->pmap; } -static ListBase *cdDM_getFaceMap(Object *ob, DerivedMesh *dm) -{ - CDDerivedMesh *cddm = (CDDerivedMesh*) dm; - - if(!cddm->fmap && ob->type == OB_MESH) { - Mesh *me= ob->data; - - create_vert_face_map(&cddm->fmap, &cddm->fmap_mem, me->mface, - me->totvert, me->totface); - } - - return cddm->fmap; -} - static int can_pbvh_draw(Object *ob, DerivedMesh *dm) { CDDerivedMesh *cddm = (CDDerivedMesh*) dm; @@ -799,7 +792,7 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, GPU_normal_setup( dm ); GPU_uv_setup( dm ); if( col != NULL ) { - /*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 ) { col = 0; @@ -1689,7 +1682,6 @@ static CDDerivedMesh *cdDM_create(const char *desc) dm->getPBVH = cdDM_getPBVH; dm->getPolyMap = cdDM_getPolyMap; - dm->getFaceMap = cdDM_getFaceMap; dm->drawVerts = cdDM_drawVerts; @@ -2781,3 +2773,23 @@ void CDDM_set_mface(DerivedMesh *dm, MFace *mface) cddm->mface = mface; } + +void CDDM_set_mloop(DerivedMesh *dm, MLoop *mloop) +{ + CDDerivedMesh *cddm = (CDDerivedMesh*)dm; + + if (!CustomData_has_layer(&dm->loopData, CD_MLOOP)) + CustomData_add_layer(&dm->loopData, CD_MLOOP, CD_ASSIGN, mloop, dm->numLoopData); + + cddm->mloop = mloop; +} + +void CDDM_set_mpoly(DerivedMesh *dm, MPoly *mpoly) +{ + CDDerivedMesh *cddm = (CDDerivedMesh*)dm; + + if (!CustomData_has_layer(&dm->polyData, CD_MPOLY)) + CustomData_add_layer(&dm->polyData, CD_MPOLY, CD_ASSIGN, mpoly, dm->numPolyData); + + cddm->mpoly = mpoly; +} diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index 10a955760f0..ecb1ae4bed3 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -194,10 +194,10 @@ gsl_poly_solve_cubic (double a, double b, double c, if (R == 0 && Q == 0) { - *x0 = - a / 3 ; - *x1 = - a / 3 ; - *x2 = - a / 3 ; - return 3 ; + *x0 = - a / 3; + *x1 = - a / 3; + *x2 = - a / 3; + return 3; } else if (CR2 == CQ3) { @@ -222,7 +222,7 @@ gsl_poly_solve_cubic (double a, double b, double c, *x1 = - sqrtQ - a / 3; *x2 = 2 * sqrtQ - a / 3; } - return 3 ; + return 3; } else if (CR2 < CQ3) /* equivalent to R2 < Q3 */ { @@ -237,14 +237,14 @@ gsl_poly_solve_cubic (double a, double b, double c, /* Sort *x0, *x1, *x2 into increasing order */ if (*x0 > *x1) - mySWAP(*x0, *x1) ; + mySWAP(*x0, *x1); if (*x1 > *x2) { - mySWAP(*x1, *x2) ; + mySWAP(*x1, *x2); if (*x0 > *x1) - mySWAP(*x0, *x1) ; + mySWAP(*x0, *x1); } return 3; @@ -253,7 +253,7 @@ gsl_poly_solve_cubic (double a, double b, double c, { double sgnR = (R >= 0 ? 1 : -1); double A = -sgnR * pow (fabs (R) + sqrt (R2 - Q3), 1.0/3.0); - double B = Q / A ; + double B = Q / A; *x0 = A + B - a / 3; return 1; } @@ -297,27 +297,27 @@ gsl_poly_solve_quadratic (double a, double b, double c, { double sgnb = (b > 0 ? 1 : -1); double temp = -0.5 * (b + sgnb * sqrt (disc)); - double r1 = temp / a ; - double r2 = c / temp ; + double r1 = temp / a; + double r2 = c / temp; if (r1 < r2) { - *x0 = r1 ; - *x1 = r2 ; + *x0 = r1; + *x1 = r2; } else { - *x0 = r2 ; - *x1 = r1 ; + *x0 = r2; + *x1 = r1; } } return 2; } else if (disc == 0) { - *x0 = -0.5 * b / a ; - *x1 = -0.5 * b / a ; - return 2 ; + *x0 = -0.5 * b / a; + *x1 = -0.5 * b / a; + return 2; } else { diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 6536dfb529e..931934f8052 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -66,9 +66,9 @@ /* globals */ /* local */ -static int cu_isectLL(float *v1, float *v2, float *v3, float *v4, +static int cu_isectLL(const float v1[3], const float v2[3], const float v3[3], const float v4[3], short cox, short coy, - float *labda, float *mu, float *vec); + float *labda, float *mu, float vec[3]); void unlink_curve(Curve *cu) { @@ -1500,7 +1500,9 @@ void makebevelcurve(Scene *scene, Object *ob, ListBase *disp, int forRender) } } -static int cu_isectLL(float *v1, float *v2, float *v3, float *v4, short cox, short coy, float *labda, float *mu, float *vec) +static int cu_isectLL(const float v1[3], const float v2[3], const float v3[3], const float v4[3], + short cox, short coy, + float *labda, float *mu, float vec[3]) { /* return: -1: colliniar diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index a95cd8d00d8..822293c35e1 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -51,7 +51,7 @@ void defgroup_copy_list(ListBase *outbase, ListBase *inbase) outbase->first= outbase->last= NULL; - for (defgroup = inbase->first; defgroup; defgroup=defgroup->next){ + for (defgroup = inbase->first; defgroup; defgroup=defgroup->next) { defgroupn= defgroup_duplicate(defgroup); BLI_addtail(outbase, defgroupn); } diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 217eb0d68c6..a5097054de2 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -349,7 +349,7 @@ static void dag_add_collision_field_relation(DagForest *dag, Scene *scene, Objec for(base = scene->base.first; base; base= base->next) { if((base->lay & ob->lay) && base->object->pd) { Object *ob1= base->object; - if((ob1->pd->deflect || ob1->pd->forcefield) && (ob1 != ob)) { + if((ob1->pd->deflect || ob1->pd->forcefield) && (ob1 != ob)) { node2 = dag_get_node(dag, ob1); dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Field Collision"); } @@ -380,7 +380,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O node->customdata_mask= 0; if (ob->type == OB_ARMATURE) { - if (ob->pose){ + if (ob->pose) { bPoseChannel *pchan; bConstraint *con; @@ -1421,7 +1421,8 @@ int pre_and_post_source_DFS(DagForest *dag, short mask, DagNode *source, graph_a retval = 1; } // else if (itA->node->color == DAG_BLACK) { // cross or forward -// ; +// +// } } itA = itA->next; } @@ -1770,7 +1771,7 @@ void DAG_scene_sort(Main *bmain, Scene *sce) if (node) { node = pop_queue(nqueue); if (node->ob == sce) // we are done - break ; + break; node->color = DAG_BLACK; time++; @@ -2068,7 +2069,7 @@ void DAG_scene_flush_update(Main *bmain, Scene *sce, unsigned int lay, const sho sce->theDag->time++; // so we know which nodes were accessed lasttime= sce->theDag->time; for(itA = firstnode->child; itA; itA= itA->next) { - if(itA->node->lasttime!=lasttime && itA->node->type==ID_OB) { + if(itA->node->lasttime!=lasttime && itA->node->type==ID_OB) { ob= (Object*)(itA->node->ob); if(ob->recalc & OB_RECALC_ALL) { @@ -2565,7 +2566,7 @@ static void dag_id_flush_update(Scene *sce, ID *id) } if(idtype == ID_MC) { - for(obt=bmain->object.first; obt; obt= obt->id.next){ + for(obt=bmain->object.first; obt; obt= obt->id.next) { bConstraint *con; for (con = obt->constraints.first; con; con=con->next) { bConstraintTypeInfo *cti= constraint_get_typeinfo(con); @@ -2890,7 +2891,7 @@ void DAG_pose_sort(Object *ob) if (node) { node = pop_queue(nqueue); if (node->ob == NULL) // we are done - break ; + break; node->color = DAG_BLACK; /* put node in new list */ diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 3a67c66165a..ea84f73b27f 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -1110,7 +1110,7 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase, if(forRender || nu->hide==0) { int resolu= nu->resolu, resolv= nu->resolv; - if(forRender){ + if(forRender) { if(cu->resolu_ren) resolu= cu->resolu_ren; if(cu->resolv_ren) resolv= cu->resolv_ren; } diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 9a8946ae61e..edd1bc6d679 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -4161,7 +4161,7 @@ static void dynamicPaint_doEffectStep(DynamicPaintSurface *surface, float *force /* * Spread Effect */ - if (surface->effect & MOD_DPAINT_EFFECT_DO_SPREAD) { + if (surface->effect & MOD_DPAINT_EFFECT_DO_SPREAD) { float eff_scale = distance_scale*EFF_MOVEMENT_PER_FRAME*surface->spread_speed*timescale; /* Copy current surface to the previous points array to read unmodified values */ @@ -4204,7 +4204,7 @@ static void dynamicPaint_doEffectStep(DynamicPaintSurface *surface, float *force /* * Shrink Effect */ - if (surface->effect & MOD_DPAINT_EFFECT_DO_SHRINK) { + if (surface->effect & MOD_DPAINT_EFFECT_DO_SHRINK) { float eff_scale = distance_scale*EFF_MOVEMENT_PER_FRAME*surface->shrink_speed*timescale; /* Copy current surface to the previous points array to read unmodified values */ diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c index 5a82fde8487..f73a2ff6c1a 100644 --- a/source/blender/blenkernel/intern/editderivedmesh.c +++ b/source/blender/blenkernel/intern/editderivedmesh.c @@ -1125,7 +1125,7 @@ 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_mesh_elem_index_ensure(bm, BM_VERT|BM_FACE); #define PASSATTRIB(loop, eve, vert) { \ if (attribs.totorco) { \ diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 69d860bfb08..82a5d9aba3a 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -508,7 +508,7 @@ float effector_falloff(EffectorCache *eff, EffectorData *efd, EffectedPoint *UNU falloff=0.0f; else if(eff->pd->zdir == PFIELD_Z_NEG && fac > 0.0f) falloff=0.0f; - else switch(eff->pd->falloff){ + else switch(eff->pd->falloff) { case PFIELD_FALL_SPHERE: falloff*= falloff_func_dist(eff->pd, efd->distance); break; @@ -610,8 +610,9 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin ParticleKey state; /* exclude the particle itself for self effecting particles */ - if(eff->psys == point->psys && *efd->index == point->index) - ; + if(eff->psys == point->psys && *efd->index == point->index) { + /* pass */ + } else { ParticleSimulationData sim= {NULL}; sim.scene= eff->scene; @@ -809,7 +810,7 @@ static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedP } } - if(eff->pd->flag & PFIELD_TEX_2D){ + if(eff->pd->flag & PFIELD_TEX_2D) { float fac = -dot_v3v3(force, efd->nor); madd_v3_v3fl(force, efd->nor, fac); } @@ -836,7 +837,7 @@ static void do_physical_effector(EffectorCache *eff, EffectorData *efd, Effected copy_v3_v3(force, efd->vec_to_point); - switch(pd->forcefield){ + switch(pd->forcefield) { case PFIELD_WIND: copy_v3_v3(force, efd->nor); mul_v3_fl(force, strength * efd->falloff); @@ -1000,7 +1001,7 @@ void pdDoEffectors(ListBase *effectors, ListBase *colliders, EffectorWeights *we do_physical_effector(eff, &efd, point, force); // for softbody backward compatibility - if(point->flag & PE_WIND_AS_SPEED && impulse){ + if(point->flag & PE_WIND_AS_SPEED && impulse) { sub_v3_v3v3(temp2, force, temp1); sub_v3_v3v3(impulse, impulse, temp2); } diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 5feeb4c300d..fa20db0fe72 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -1687,7 +1687,7 @@ static float evaluate_driver (ChannelDriver *driver, const float evaltime) * than the horizontal distance between (v1-v4). * This is to prevent curve loops. */ -void correct_bezpart (float *v1, float *v2, float *v3, float *v4) +void correct_bezpart(float v1[2], float v2[2], float v3[2], float v4[2]) { float h1[2], h2[2], len1, len2, len, fac; diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index 95c0aa60991..8098706e370 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -571,7 +571,7 @@ static float fcm_cycles_time (FCurve *fcu, FModifier *fcm, float UNUSED(cvalue), * 2) if before first frame or after last frame, make sure some cycling is in use */ if (evaltime < prevkey[0]) { - if (data->before_mode) { + if (data->before_mode) { side= -1; mode= data->before_mode; cycles= data->before_cycles; diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index f45899ff365..5a37a65ddbf 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -333,7 +333,7 @@ static void build_underline(Curve *cu, float x1, float y1, float x2, float y2, i nu2->flagu = CU_NURB_CYCLIC; bp = (BPoint*)MEM_callocN(4 * sizeof(BPoint),"underline_bp"); - if (bp == NULL){ + if (bp == NULL) { MEM_freeN(nu2); return; } @@ -399,7 +399,7 @@ static void buildchar(Main *bmain, Curve *cu, unsigned long character, CharInfo while(nu1) { bezt1 = nu1->bezt; - if (bezt1){ + if (bezt1) { nu2 =(Nurb*) MEM_mallocN(sizeof(Nurb),"duplichar_nurb"); if (nu2 == NULL) break; memcpy(nu2, nu1, sizeof(struct Nurb)); @@ -419,7 +419,7 @@ static void buildchar(Main *bmain, Curve *cu, unsigned long character, CharInfo i = nu2->pntsu; bezt2 = (BezTriple*)MEM_mallocN(i * sizeof(BezTriple),"duplichar_bezt2"); - if (bezt2 == NULL){ + if (bezt2 == NULL) { MEM_freeN(nu2); break; } diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c index 8ebac31ad95..989ccf65a88 100644 --- a/source/blender/blenkernel/intern/group.c +++ b/source/blender/blenkernel/intern/group.c @@ -129,7 +129,7 @@ void unlink_group(Group *group) #endif } - for(psys=ob->particlesystem.first; psys; psys=psys->next){ + for(psys=ob->particlesystem.first; psys; psys=psys->next) { if(psys->part->dup_group==group) psys->part->dup_group= NULL; #if 0 /* not used anymore, only keps for readfile.c, no need to account for this */ diff --git a/source/blender/blenkernel/intern/icons.c b/source/blender/blenkernel/intern/icons.c index bcbce2bc1c2..58c88682d3f 100644 --- a/source/blender/blenkernel/intern/icons.c +++ b/source/blender/blenkernel/intern/icons.c @@ -263,7 +263,7 @@ int BKE_icon_getid(struct ID* id) id->icon_id = get_next_free_id(); - if (!id->icon_id){ + if (!id->icon_id) { printf("BKE_icon_getid: Internal error - not enough IDs\n"); return 0; } diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index 3bcb262fac8..093399832a1 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -489,7 +489,7 @@ void IDP_ReplaceGroupInGroup(IDProperty *dest, IDProperty *src) void IDP_ReplaceInGroup(IDProperty *group, IDProperty *prop) { IDProperty *loop; - if((loop= IDP_GetPropertyFromGroup(group, prop->name))) { + if ((loop= IDP_GetPropertyFromGroup(group, prop->name))) { BLI_insertlink(&group->data.group, loop, prop); BLI_remlink(&group->data.group, loop); @@ -506,7 +506,7 @@ void IDP_ReplaceInGroup(IDProperty *group, IDProperty *prop) or 1 if it succeeded in adding to the group.*/ int IDP_AddToGroup(IDProperty *group, IDProperty *prop) { - if(IDP_GetPropertyFromGroup(group, prop->name) == NULL) { + if (IDP_GetPropertyFromGroup(group, prop->name) == NULL) { group->len++; BLI_addtail(&group->data.group, prop); return 1; @@ -517,7 +517,7 @@ int IDP_AddToGroup(IDProperty *group, IDProperty *prop) int IDP_InsertToGroup(IDProperty *group, IDProperty *previous, IDProperty *pnew) { - if(IDP_GetPropertyFromGroup(group, pnew->name) == NULL) { + if (IDP_GetPropertyFromGroup(group, pnew->name) == NULL) { group->len++; BLI_insertlink(&group->data.group, previous, pnew); return 1; diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index f848ee3a676..3cc73d7f7f1 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1122,11 +1122,11 @@ int BKE_add_image_extension(char *string, const char imtype) } #endif #ifdef WITH_CINEON - else if(imtype==R_IMF_IMTYPE_CINEON){ + else if(imtype==R_IMF_IMTYPE_CINEON) { if (!BLI_testextensie(string, ".cin")) extension= ".cin"; } - else if(imtype==R_IMF_IMTYPE_DPX){ + else if(imtype==R_IMF_IMTYPE_DPX) { if (!BLI_testextensie(string, ".dpx")) extension= ".dpx"; } diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index 757d3ddf9ac..f54a885c55e 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -1697,7 +1697,7 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec while(search) { // only handle active springs - // if(((clmd->sim_parms->flags & CSIMSETT_FLAG_TEARING_ENABLED) && !(springs[i].flags & CSPRING_FLAG_DEACTIVATE))|| !(clmd->sim_parms->flags & CSIMSETT_FLAG_TEARING_ENABLED)){} + // if(((clmd->sim_parms->flags & CSIMSETT_FLAG_TEARING_ENABLED) && !(springs[i].flags & CSPRING_FLAG_DEACTIVATE))|| !(clmd->sim_parms->flags & CSIMSETT_FLAG_TEARING_ENABLED)) {} cloth_calc_spring_force(clmd, search->link, lF, lX, lV, dFdV, dFdX, time); search = search->next; diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index f9c52f3c2ba..a2db2de6713 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1344,7 +1344,7 @@ static void lib_indirect_test_id(ID *id, Library *lib) // XXX old animation system! -------------------------------------- { bActionStrip *strip; - for (strip=ob->nlastrips.first; strip; strip=strip->next){ + for (strip=ob->nlastrips.first; strip; strip=strip->next) { LIBTAG(strip->object); LIBTAG(strip->act); LIBTAG(strip->ipo); diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 7f05aaed9b0..52e9dcaa578 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -522,7 +522,7 @@ Object *find_basis_mball(Scene *scene, Object *basis) /* **************** POLYGONIZATION ************************ */ -void calc_mballco(MetaElem *ml, float *vec) +void calc_mballco(MetaElem *ml, float vec[3]) { if (ml->mat) { mul_m4_v3((float ( * )[4])ml->mat, vec); @@ -2282,3 +2282,54 @@ void metaball_polygonize(Scene *scene, Object *ob, ListBase *dispbase) freepolygonize(&mbproc); } +/* basic vertex data functions */ +int BKE_metaball_minmax(MetaBall *mb, float min[3], float max[3]) +{ + MetaElem *ml; + + INIT_MINMAX(min, max); + + for (ml = mb->elems.first; ml; ml = ml->next) { + DO_MINMAX(&ml->x, min, max); + } + + return (mb->elems.first != NULL); +} + +int BKE_metaball_center_median(MetaBall *mb, float cent[3]) +{ + MetaElem *ml; + int total= 0; + + zero_v3(cent); + + for (ml = mb->elems.first; ml; ml = ml->next) { + add_v3_v3(cent, &ml->x); + } + + if (total) + mul_v3_fl(cent, 1.0f/(float)total); + + return (total != 0); +} + +int BKE_metaball_center_bounds(MetaBall *mb, float cent[3]) +{ + float min[3], max[3]; + + if (BKE_metaball_minmax(mb, min, max)) { + mid_v3_v3v3(cent, min, max); + return 1; + } + + return 0; +} + +void BKE_metaball_translate(MetaBall *mb, float offset[3]) +{ + MetaElem *ml; + + for (ml = mb->elems.first; ml; ml = ml->next) { + add_v3_v3(&ml->x, offset); + } +} diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index ca22d917b50..c9b73376a3d 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -683,15 +683,15 @@ BoundBox *mesh_get_bb(Object *ob) return me->bb; } -void mesh_get_texspace(Mesh *me, float *loc_r, float *rot_r, float *size_r) +void mesh_get_texspace(Mesh *me, float r_loc[3], float r_rot[3], float r_size[3]) { if (!me->bb) { tex_space_mesh(me); } - if (loc_r) copy_v3_v3(loc_r, me->loc); - if (rot_r) copy_v3_v3(rot_r, me->rot); - if (size_r) copy_v3_v3(size_r, me->size); + if (r_loc) copy_v3_v3(r_loc, me->loc); + if (r_rot) copy_v3_v3(r_rot, me->rot); + if (r_size) copy_v3_v3(r_size, me->size); } float *get_mesh_orco_verts(Object *ob) @@ -1801,7 +1801,7 @@ void mesh_calc_normals_tessface(MVert *mverts, int numVerts, MFace *mfaces, int } -static void bmesh_corners_to_loops(Mesh *me, int findex, int loopstart, int numTex, int numCol) +static void bm_corners_to_loops(Mesh *me, int findex, int loopstart, int numTex, int numCol) { MTFace *texface; MTexPoly *texpoly; @@ -1937,7 +1937,7 @@ void convert_mfaces_to_mpolys(Mesh *mesh) #undef ML - bmesh_corners_to_loops(mesh, i, mp->loopstart, numTex, numCol); + bm_corners_to_loops(mesh, i, mp->loopstart, numTex, numCol); } /* note, we dont convert FGons at all, these are not even real ngons, @@ -2097,27 +2097,6 @@ void create_vert_poly_map(ListBase **map, IndexNode **mem, } /* Generates a map where the key is the vertex and the value is a list - of faces that use that vertex as a corner. The lists are allocated - from one memory pool. */ -void create_vert_face_map(ListBase **map, IndexNode **mem, const MFace *mface, const int totvert, const int totface) -{ - int i,j; - IndexNode *node = NULL; - - (*map) = MEM_callocN(sizeof(ListBase) * totvert, "vert face map"); - (*mem) = MEM_callocN(sizeof(IndexNode) * totface*4, "vert face map mem"); - node = *mem; - - /* Find the users */ - for (i = 0; i < totface; ++i) { - for (j = 0; j < (mface[i].v4?4:3); ++j, ++node) { - node->index = i; - BLI_addtail(&(*map)[((unsigned int*)(&mface[i]))[j]], node); - } - } -} - -/* Generates a map where the key is the vertex and the value is a list of edges that use that vertex as an endpoint. The lists are allocated from one memory pool. */ void create_vert_edge_map(ListBase **map, IndexNode **mem, const MEdge *medge, const int totvert, const int totedge) @@ -2384,7 +2363,7 @@ int mesh_recalcTesselation(CustomData *fdata, totface = mface_index; - /* note essential but without this we store over-alloc'd memory in the CustomData layers */ + /* not essential but without this we store over-alloc'd memory in the CustomData layers */ if (LIKELY((MEM_allocN_len(mface) / sizeof(*mface)) != totface)) { mface = MEM_reallocN(mface, sizeof(*mface) * totface); mface_to_poly_map = MEM_reallocN(mface_to_poly_map, sizeof(*mface_to_poly_map) * totface); @@ -2854,6 +2833,42 @@ float mesh_calc_poly_area(MPoly *mpoly, MLoop *loopstart, } } +/* Find the index of the loop in 'poly' which references vertex, + returns -1 if not found */ +int poly_find_loop_from_vert(const MPoly *poly, const MLoop *loopstart, + unsigned vert) +{ + int j; + for (j = 0; j < poly->totloop; j++, loopstart++) { + if (loopstart->v == vert) + return j; + } + + return -1; +} + +/* Fill 'adj_r' with the loop indices in 'poly' adjacent to the + vertex. Returns the index of the loop matching vertex, or -1 if the + vertex is not in 'poly' */ +int poly_get_adj_loops_from_vert(unsigned adj_r[3], const MPoly *poly, + const MLoop *mloop, unsigned vert) +{ + int corner = poly_find_loop_from_vert(poly, + &mloop[poly->loopstart], + vert); + + if(corner != -1) { + const MLoop *ml = &mloop[poly->loopstart + corner]; + + /* vertex was found */ + adj_r[0] = ME_POLY_LOOP_PREV(mloop, poly, corner)->v; + adj_r[1] = ml->v; + adj_r[2] = ME_POLY_LOOP_NEXT(mloop, poly, corner)->v; + } + + return corner; +} + /* basic vertex data functions */ int minmax_mesh(Mesh *me, float min[3], float max[3]) { diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c index 0f6fedb0b08..4a988f0b278 100644 --- a/source/blender/blenkernel/intern/mesh_validate.c +++ b/source/blender/blenkernel/intern/mesh_validate.c @@ -233,13 +233,13 @@ int BKE_mesh_validate_arrays( Mesh *me, if(remove == FALSE) { if(mf->v4) { if(mf->v1 == mf->v2) { PRINT(" face %u: verts invalid, v1/v2 both %u\n", i, mf->v1); remove= do_fixes; } - if(mf->v1 == mf->v3) { PRINT(" face %u: verts invalid, v1/v3 both %u\n", i, mf->v1); remove= do_fixes; } - if(mf->v1 == mf->v4) { PRINT(" face %u: verts invalid, v1/v4 both %u\n", i, mf->v1); remove= do_fixes; } + if(mf->v1 == mf->v3) { PRINT(" face %u: verts invalid, v1/v3 both %u\n", i, mf->v1); remove= do_fixes; } + if(mf->v1 == mf->v4) { PRINT(" face %u: verts invalid, v1/v4 both %u\n", i, mf->v1); remove= do_fixes; } - if(mf->v2 == mf->v3) { PRINT(" face %u: verts invalid, v2/v3 both %u\n", i, mf->v2); remove= do_fixes; } - if(mf->v2 == mf->v4) { PRINT(" face %u: verts invalid, v2/v4 both %u\n", i, mf->v2); remove= do_fixes; } + if(mf->v2 == mf->v3) { PRINT(" face %u: verts invalid, v2/v3 both %u\n", i, mf->v2); remove= do_fixes; } + if(mf->v2 == mf->v4) { PRINT(" face %u: verts invalid, v2/v4 both %u\n", i, mf->v2); remove= do_fixes; } - if(mf->v3 == mf->v4) { PRINT(" face %u: verts invalid, v3/v4 both %u\n", i, mf->v3); remove= do_fixes; } + if(mf->v3 == mf->v4) { PRINT(" face %u: verts invalid, v3/v4 both %u\n", i, mf->v3); remove= do_fixes; } } else { if(mf->v1 == mf->v2) { PRINT(" faceT %u: verts invalid, v1/v2 both %u\n", i, mf->v1); remove= do_fixes; } diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 911d303b4cf..9a67260ded4 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -55,7 +55,6 @@ #include "BLI_linklist.h" #include "BLI_string.h" -#include "BKE_bmesh.h" #include "BKE_cloth.h" #include "BKE_key.h" #include "BKE_multires.h" diff --git a/source/blender/blenkernel/intern/modifiers_bmesh.c b/source/blender/blenkernel/intern/modifiers_bmesh.c index 2fdf0e0bb70..6bca40be1e2 100644 --- a/source/blender/blenkernel/intern/modifiers_bmesh.c +++ b/source/blender/blenkernel/intern/modifiers_bmesh.c @@ -36,6 +36,7 @@ #include "BLI_array.h" +#include "BKE_DerivedMesh.h" #include "BKE_bmesh.h" #include "BKE_tessmesh.h" diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index a0f440c10c0..95f4b465beb 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -66,8 +66,15 @@ static const int multires_max_levels = 13; static const int multires_grid_tot[] = {0, 4, 9, 25, 81, 289, 1089, 4225, 16641, 66049, 263169, 1050625, 4198401, 16785409}; static const int multires_side_tot[] = {0, 2, 3, 5, 9, 17, 33, 65, 129, 257, 513, 1025, 2049, 4097}; +/* See multiresModifier_disp_run for description of each operation */ +typedef enum { + APPLY_DISPLACEMENTS, + CALC_DISPLACEMENTS, + ADD_DISPLACEMENTS, +} DispOp; + static void multires_mvert_to_ss(DerivedMesh *dm, MVert *mvert); -static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm2, int invert, int add, DMGridData **oldGridData, int totlvl); +static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm2, DispOp op, DMGridData **oldGridData, int totlvl); DerivedMesh *get_multires_dm(Scene *scene, MultiresModifierData *mmd, Object *ob) { @@ -496,7 +503,7 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob) { DerivedMesh *cddm, *dispdm, *origdm; Mesh *me; - ListBase *fmap; + ListBase *pmap; float (*origco)[3]; int i, j, offset, totlvl; @@ -526,7 +533,7 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob) /* heuristic to produce a better-fitting base mesh */ cddm = CDDM_from_mesh(me, NULL); - fmap = cddm->getFaceMap(ob, cddm); + pmap = cddm->getPolyMap(ob, cddm); origco = MEM_callocN(sizeof(float)*3*me->totvert, "multires apply base origco"); for (i = 0; i < me->totvert ;++i) copy_v3_v3(origco[i], me->mvert[i].co); @@ -537,18 +544,17 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob) float dist; int tot; - /* don't adjust verts not used by at least one face */ - if (!fmap[i].first) + /* don't adjust verts not used by at least one poly */ + if (!pmap[i].first) continue; /* find center */ - for (n = fmap[i].first, tot = 0; n; n = n->next) { - MFace *f = &me->mface[n->index]; - int S = f->v4 ? 4 : 3; + for (n = pmap[i].first, tot = 0; n; n = n->next) { + const MPoly *p = &me->mpoly[n->index]; /* this double counts, not sure if that's bad or good */ - for (j = 0; j < S; ++j) { - int vndx = (&f->v1)[j]; + for (j = 0; j < p->totloop; ++j) { + int vndx = me->mloop[p->loopstart + j].v; if (vndx != i) { add_v3_v3(center, origco[vndx]); ++tot; @@ -558,23 +564,36 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob) mul_v3_fl(center, 1.0f / tot); /* find normal */ - for (n = fmap[i].first; n; n = n->next) { - MFace *f = &me->mface[n->index]; - int S = f->v4 ? 4 : 3; - float v[4][3], no[3]; + for (n = pmap[i].first; n; n = n->next) { + const MPoly *p = &me->mpoly[n->index]; + MPoly fake_poly; + MLoop *fake_loops; + float (*fake_co)[3]; + float no[3]; + + /* set up poly, loops, and coords in order to call + mesh_calc_poly_normal_coords() */ + fake_poly.totloop = p->totloop; + fake_poly.loopstart = 0; + fake_loops = MEM_mallocN(sizeof(MLoop) * p->totloop, "fake_loops"); + fake_co = MEM_mallocN(sizeof(float) * 3 * p->totloop, "fake_co"); - for (j = 0; j < S; ++j) { - int vndx = (&f->v1)[j]; + for (j = 0; j < p->totloop; ++j) { + int vndx = me->mloop[p->loopstart + j].v; + + fake_loops[j].v = j; + if (vndx == i) - copy_v3_v3(v[j], center); + copy_v3_v3(fake_co[j], center); else - copy_v3_v3(v[j], origco[vndx]); + copy_v3_v3(fake_co[j], origco[vndx]); } - if (S == 4) - normal_quad_v3(no, v[0], v[1], v[2], v[3]); - else - normal_tri_v3(no, v[0], v[1], v[2]); + mesh_calc_poly_normal_coords(&fake_poly, fake_loops, + (const float(*)[3])fake_co, no); + MEM_freeN(fake_loops); + MEM_freeN(fake_co); + add_v3_v3(avg_no, no); } normalize_v3(avg_no); @@ -597,7 +616,7 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob) cddm->release(cddm); /* calc disps */ - multiresModifier_disp_run(dispdm, me, NULL, 1, 0, origdm->getGridData(origdm), totlvl); + multiresModifier_disp_run(dispdm, me, NULL, CALC_DISPLACEMENTS, origdm->getGridData(origdm), totlvl); origdm->release(origdm); dispdm->release(dispdm); @@ -664,7 +683,7 @@ static void multires_subdivide(MultiresModifierData *mmd, Object *ob, int totlvl multires_reallocate_mdisps(me->totloop, mdisps, totlvl); /* compute displacements */ - multiresModifier_disp_run(highdm, me, NULL, 1, 0, subGridData, totlvl); + multiresModifier_disp_run(highdm, me, NULL, CALC_DISPLACEMENTS, subGridData, totlvl); /* free */ highdm->release(highdm); @@ -709,7 +728,7 @@ void grid_tangent(int gridSize, int index, int x, int y, int axis, DMGridData ** } } -static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm2, int invert, int add, DMGridData **oldGridData, int totlvl) +static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm2, DispOp op, DMGridData **oldGridData, int totlvl) { CCGDerivedMesh *ccgdm = (CCGDerivedMesh*)dm; DMGridData **gridData, **subGridData; @@ -719,7 +738,7 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm int i, k, /*numGrids,*/ gridSize, dGridSize, dSkip; int totloop, totpoly; - /*this happens in the dm made by bmesh_set_mdisps_space*/ + /* this happens in the dm made by bmesh_mdisps_space_set */ if (dm2 && CustomData_has_layer(&dm2->loopData, CD_MDISPS)) { mpoly = CustomData_get_layer(&dm2->polyData, CD_MPOLY); mdisps = CustomData_get_layer(&dm2->loopData, CD_MDISPS); @@ -732,7 +751,7 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm } if (!mdisps) { - if (invert) + if (op == CALC_DISPLACEMENTS) mdisps = CustomData_add_layer(&me->ldata, CD_MDISPS, CD_DEFAULT, NULL, me->totloop); else return; @@ -791,29 +810,34 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm column_vectors_to_mat3(mat, tx, ty, no); - if (!invert) { - /* convert to object space and add */ + switch(op) { + case APPLY_DISPLACEMENTS: + /* Convert displacement to object space + and add to grid points */ mul_v3_m3v3(disp, mat, data); add_v3_v3v3(co, sco, disp); - } - else if (!add) { - /* convert difference to tangent space */ + break; + case CALC_DISPLACEMENTS: + /* Calculate displacement between new and old + grid points and convert to tangent space */ sub_v3_v3v3(disp, co, sco); invert_m3(mat); mul_v3_m3v3(data, mat, disp); - } - else { - /* convert difference to tangent space */ + break; + case ADD_DISPLACEMENTS: + /* Convert subdivided displacements to tangent + space and add to the original displacements */ invert_m3(mat); mul_v3_m3v3(d, mat, co); add_v3_v3(data, d); + break; } } } } } - if (!invert) { + if (op == APPLY_DISPLACEMENTS) { ccgSubSurf_stitchFaces(ccgdm->ss, 0, NULL, 0); ccgSubSurf_updateNormals(ccgdm->ss, NULL, 0); } @@ -889,7 +913,7 @@ static void multiresModifier_update(DerivedMesh *dm) ccgSubSurf_updateLevels(ss, lvl, NULL, 0); /* add to displacements */ - multiresModifier_disp_run(highdm, me, NULL, 1, 1, subGridData, mmd->totlvl); + multiresModifier_disp_run(highdm, me, NULL, ADD_DISPLACEMENTS, subGridData, mmd->totlvl); /* free */ highdm->release(highdm); @@ -907,7 +931,7 @@ static void multiresModifier_update(DerivedMesh *dm) subdm = subsurf_dm_create_local(ob, cddm, mmd->totlvl, mmd->simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv); cddm->release(cddm); - multiresModifier_disp_run(dm, me, NULL, 1, 0, subdm->getGridData(subdm), mmd->totlvl); + multiresModifier_disp_run(dm, me, NULL, CALC_DISPLACEMENTS, subdm->getGridData(subdm), mmd->totlvl); subdm->release(subdm); } @@ -1104,7 +1128,7 @@ DerivedMesh *multires_dm_create_from_derived(MultiresModifierData *mmd, int loca CustomData_external_read(&me->ldata, &me->id, CD_MASK_MDISPS, me->totloop); /*run displacement*/ - multiresModifier_disp_run(result, ob->data, dm, 0, 0, subGridData, mmd->totlvl); + multiresModifier_disp_run(result, ob->data, dm, APPLY_DISPLACEMENTS, subGridData, mmd->totlvl); for (i = 0; i < numGrids; i++) MEM_freeN(subGridData[i]); diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 12f403d028f..a6795ed3a7d 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -1073,7 +1073,7 @@ void BKE_nlastrip_set_active (AnimData *adt, NlaStrip *strip) /* loop over tracks, deactivating*/ for (nlt= adt->nla_tracks.first; nlt; nlt= nlt->next) { - for (nls= nlt->strips.first; nls; nls= nls->next) { + for (nls= nlt->strips.first; nls; nls= nls->next) { if (nls != strip) nls->flag &= ~NLASTRIP_FLAG_ACTIVE; else diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index cf2cbaed8f1..c394a5354f1 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -542,6 +542,55 @@ void nodeRemSocketLinks(bNodeTree *ntree, bNodeSocket *sock) ntree->update |= NTREE_UPDATE_LINKS; } +void nodeInternalRelink(bNodeTree *ntree, bNode *node) +{ + bNodeLink *link, *link_next; + ListBase intlinks; + + if (!node->typeinfo->internal_connect) + return; + + intlinks = node->typeinfo->internal_connect(ntree, node); + + /* store link pointers in output sockets, for efficient lookup */ + for (link=intlinks.first; link; link=link->next) + link->tosock->link = link; + + /* redirect downstream links */ + for (link=ntree->links.first; link; link=link_next) { + link_next = link->next; + + /* do we have internal link? */ + if (link->fromnode==node) { + if (link->fromsock->link) { + /* get the upstream input link */ + bNodeLink *fromlink = link->fromsock->link->fromsock->link; + /* skip the node */ + if (fromlink) { + link->fromnode = fromlink->fromnode; + link->fromsock = fromlink->fromsock; + + ntree->update |= NTREE_UPDATE_LINKS; + } + else + nodeRemLink(ntree, link); + } + else + nodeRemLink(ntree, link); + } + } + + /* remove remaining upstream links */ + for (link=ntree->links.first; link; link=link_next) { + link_next = link->next; + + if (link->tonode==node) + nodeRemLink(ntree, link); + } + + BLI_freelistN(&intlinks); +} + /* transforms node location to area coords */ void nodeSpaceCoords(bNode *node, float *locx, float *locy) { @@ -1633,11 +1682,8 @@ void node_type_base(bNodeTreeType *ttype, bNodeType *ntype, int type, const char ntype->flag = flag; /* Default muting stuff. */ - if(ttype) { - ntype->mutefunc = ttype->mutefunc; - ntype->mutelinksfunc = ttype->mutelinksfunc; - ntype->gpumutefunc = ttype->gpumutefunc; - } + if(ttype) + ntype->internal_connect = ttype->internal_connect; /* default size values */ ntype->width = 140; @@ -1733,14 +1779,9 @@ void node_type_exec_new(struct bNodeType *ntype, ntype->newexecfunc = newexecfunc; } -void node_type_mute(struct bNodeType *ntype, - void (*mutefunc)(void *data, int thread, struct bNode *, void *nodedata, - struct bNodeStack **, struct bNodeStack **), - ListBase (*mutelinksfunc)(struct bNodeTree *, struct bNode *, struct bNodeStack **, struct bNodeStack **, - struct GPUNodeStack *, struct GPUNodeStack *)) +void node_type_internal_connect(bNodeType *ntype, ListBase (*internal_connect)(bNodeTree *, bNode *)) { - ntype->mutefunc = mutefunc; - ntype->mutelinksfunc = mutelinksfunc; + ntype->internal_connect = internal_connect; } void node_type_gpu(struct bNodeType *ntype, int (*gpufunc)(struct GPUMaterial *mat, struct bNode *node, struct GPUNodeStack *in, struct GPUNodeStack *out)) @@ -1753,12 +1794,6 @@ void node_type_gpu_ext(struct bNodeType *ntype, int (*gpuextfunc)(struct GPUMate ntype->gpuextfunc = gpuextfunc; } -void node_type_gpu_mute(struct bNodeType *ntype, int (*gpumutefunc)(struct GPUMaterial *, struct bNode *, void *, - struct GPUNodeStack *, struct GPUNodeStack *)) -{ - ntype->gpumutefunc = gpumutefunc; -} - void node_type_compatibility(struct bNodeType *ntype, short compatibility) { ntype->compatibility = compatibility; diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 01fe2f5d21a..74c996e9516 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1721,7 +1721,7 @@ static void ob_parbone(Object *ob, Object *par, float mat[][4]) add_v3_v3(mat[3], vec); } -static void give_parvert(Object *par, int nr, float *vec) +static void give_parvert(Object *par, int nr, float vec[3]) { BMEditMesh *em; int a, count; @@ -2181,7 +2181,7 @@ void object_boundbox_flag(Object *ob, int flag, int set) } } -void object_get_dimensions(Object *ob, float *value) +void object_get_dimensions(Object *ob, float vec[3]) { BoundBox *bb = NULL; @@ -2191,11 +2191,11 @@ void object_get_dimensions(Object *ob, float *value) mat4_to_size( scale,ob->obmat); - value[0] = fabsf(scale[0]) * (bb->vec[4][0] - bb->vec[0][0]); - value[1] = fabsf(scale[1]) * (bb->vec[2][1] - bb->vec[0][1]); - value[2] = fabsf(scale[2]) * (bb->vec[1][2] - bb->vec[0][2]); + 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]); + vec[2] = fabsf(scale[2]) * (bb->vec[1][2] - bb->vec[0][2]); } else { - value[0] = value[1] = value[2] = 0.f; + vec[0] = vec[1] = vec[2] = 0.f; } } @@ -2302,7 +2302,7 @@ void minmax_object(Object *ob, float min[3], float max[3]) } } -int minmax_object_duplis(Scene *scene, Object *ob, float *min, float *max) +int minmax_object_duplis(Scene *scene, Object *ob, float min[3], float max[3]) { int ok= 0; if ((ob->transflag & OB_DUPLI)==0) { diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c index f1412981935..00a66edc2b4 100644 --- a/source/blender/blenkernel/intern/ocean.c +++ b/source/blender/blenkernel/intern/ocean.c @@ -422,7 +422,7 @@ void BKE_ocean_eval_uv_catrom(struct Ocean *oc, struct OceanResult *ocr, float u { if (oc->_do_disp_y) { - ocr->disp[1] = INTERP(oc->_disp_y) ; + ocr->disp[1] = INTERP(oc->_disp_y); } if (oc->_do_normals) { diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 38a73daab2a..2e91d76cf21 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -167,7 +167,7 @@ ParticleSystem *psys_get_current(Object *ob) ParticleSystem *psys; if(ob==NULL) return NULL; - for(psys=ob->particlesystem.first; psys; psys=psys->next){ + for(psys=ob->particlesystem.first; psys; psys=psys->next) { if(psys->flag & PSYS_CURRENT) return psys; } @@ -219,12 +219,12 @@ Object *psys_get_lattice(ParticleSimulationData *sim) { Object *lattice=NULL; - if(psys_in_edit_mode(sim->scene, sim->psys)==0){ + if(psys_in_edit_mode(sim->scene, sim->psys)==0) { ModifierData *md = (ModifierData*)psys_get_modifier(sim->ob, sim->psys); - for(; md; md=md->next){ - if(md->type==eModifierType_Lattice){ + for(; md; md=md->next) { + if(md->type==eModifierType_Lattice) { LatticeModifierData *lmd = (LatticeModifierData *)md; lattice=lmd->object; break; @@ -523,7 +523,7 @@ void psys_free_pdd(ParticleSystem *psys) /* free everything */ void psys_free(Object *ob, ParticleSystem * psys) { - if(psys){ + if(psys) { int nr = 0; ParticleSystem * tpsys; @@ -536,14 +536,14 @@ void psys_free(Object *ob, ParticleSystem * psys) if(psys->edit && psys->free_edit) psys->free_edit(psys->edit); - if(psys->child){ + if(psys->child) { MEM_freeN(psys->child); psys->child = NULL; psys->totchild = 0; } // check if we are last non-visible particle system - for(tpsys=ob->particlesystem.first; tpsys; tpsys=tpsys->next){ + for(tpsys=ob->particlesystem.first; tpsys; tpsys=tpsys->next) { if(tpsys->part) { if(ELEM(tpsys->part->ren_as,PART_DRAW_OB,PART_DRAW_GR)) @@ -557,7 +557,7 @@ void psys_free(Object *ob, ParticleSystem * psys) if(!nr) ob->transflag &= ~OB_DUPLIPARTS; - if(psys->part){ + if(psys->part) { psys->part->id.us--; psys->part=NULL; } @@ -744,7 +744,7 @@ void psys_render_restore(Object *ob, ParticleSystem *psys) psys_free_path_cache(psys, NULL); - if(psys->child){ + if(psys->child) { MEM_freeN(psys->child); psys->child= 0; psys->totchild= 0; @@ -1029,10 +1029,10 @@ void psys_interpolate_particle(short type, ParticleKey keys[4], float dt, Partic interp_v3_v3v3v3v3(result->co, keys[0].co, keys[1].co, keys[2].co, keys[3].co, t); - if(velocity){ + if(velocity) { float temp[3]; - if(dt>0.999f){ + if(dt>0.999f) { key_curve_position_weights(dt-0.001f, t, type); interp_v3_v3v3v3v3(temp, keys[0].co, keys[1].co, keys[2].co, keys[3].co, t); sub_v3_v3v3(result->vel, result->co, temp); @@ -1351,7 +1351,7 @@ static void do_particle_interpolation(ParticleSystem *psys, int p, ParticleData keytime = (real_t - keys[1].time) / dfra; /* convert velocity to timestep size */ - if(pind->keyed || pind->cache || point_vel){ + if(pind->keyed || pind->cache || point_vel) { invdt = dfra * 0.04f * (psys ? psys->part->timetweak : 1.f); mul_v3_fl(keys[1].vel, invdt); mul_v3_fl(keys[2].vel, invdt); @@ -1424,7 +1424,7 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or interp_v3_v3v3v3v3(vec, v1, v2, v3, v4, w); - if(nor){ + if(nor) { if(mface->flag & ME_SMOOTH) interp_v3_v3v3v3v3(nor, n1, n2, n3, n4, w); else @@ -1434,7 +1434,7 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or else { interp_v3_v3v3v3(vec, v1, v2, v3, w); - if(nor){ + if(nor) { if(mface->flag & ME_SMOOTH) interp_v3_v3v3v3(nor, n1, n2, n3, w); else @@ -1443,8 +1443,8 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or } /* calculate tangent vectors */ - if(utan && vtan){ - if(tface){ + if(utan && vtan) { + if(tface) { uv1= tface->uv[0]; uv2= tface->uv[1]; uv3= tface->uv[2]; @@ -1459,7 +1459,7 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or map_to_sphere( uv4, uv4+1,v4[0], v4[1], v4[2]); } - if(v4){ + if(v4) { s1= uv3[0] - uv1[0]; s2= uv4[0] - uv1[0]; @@ -1570,7 +1570,7 @@ static float psys_interpolate_value_from_verts(DerivedMesh *dm, short from, int if(values==0 || index==-1) return 0.0; - switch(from){ + switch(from) { case PART_FROM_VERT: return values[index]; case PART_FROM_FACE: @@ -1824,10 +1824,10 @@ ParticleSystemModifierData *psys_get_modifier(Object *ob, ParticleSystem *psys) ModifierData *md; ParticleSystemModifierData *psmd; - for(md=ob->modifiers.first; md; md=md->next){ - if(md->type==eModifierType_ParticleSystem){ + for(md=ob->modifiers.first; md; md=md->next) { + if(md->type==eModifierType_ParticleSystem) { psmd= (ParticleSystemModifierData*) md; - if(psmd->psys==psys){ + if(psmd->psys==psys) { return psmd; } } @@ -1842,22 +1842,22 @@ static void psys_particle_on_shape(int UNUSED(distr), int UNUSED(index), float * { /* TODO */ float zerovec[3]={0.0f,0.0f,0.0f}; - if(vec){ + if(vec) { copy_v3_v3(vec,zerovec); } - if(nor){ + if(nor) { copy_v3_v3(nor,zerovec); } - if(utan){ + if(utan) { copy_v3_v3(utan,zerovec); } - if(vtan){ + if(vtan) { copy_v3_v3(vtan,zerovec); } - if(orco){ + if(orco) { copy_v3_v3(orco,zerovec); } - if(ornor){ + if(ornor) { copy_v3_v3(ornor,zerovec); } } @@ -1866,8 +1866,8 @@ static void psys_particle_on_shape(int UNUSED(distr), int UNUSED(index), float * /************************************************/ void psys_particle_on_emitter(ParticleSystemModifierData *psmd, int from, int index, int index_dmcache, float *fuv, float foffset, float *vec, float *nor, float *utan, float *vtan, float *orco, float *ornor) { - if(psmd){ - if(psmd->psys->part->distr==PART_DISTR_GRID && psmd->psys->part->from != PART_FROM_VERT){ + if(psmd) { + if(psmd->psys->part->distr==PART_DISTR_GRID && psmd->psys->part->from != PART_FROM_VERT) { if(vec) copy_v3_v3(vec,fuv); @@ -2007,13 +2007,13 @@ static void do_kink(ParticleKey *state, ParticleKey *par, float *par_rot, float inp_y=dot_v3v3(y_vec, vec_one); inp_z=dot_v3v3(z_vec, vec_one); - if(inp_y > 0.5f){ + if(inp_y > 0.5f) { copy_v3_v3(state_co, y_vec); mul_v3_fl(y_vec, amplitude*(float)cos(t)); mul_v3_fl(z_vec, amplitude/2.f*(float)sin(2.f*t)); } - else if(inp_z > 0.0f){ + else if(inp_z > 0.0f) { mul_v3_v3fl(state_co, z_vec, (float)sin((float)M_PI/3.f)); madd_v3_v3fl(state_co, y_vec, -0.5f); @@ -2041,7 +2041,7 @@ static void do_kink(ParticleKey *state, ParticleKey *par, float *par_rot, float shape = 2.f*(float)M_PI * (1.f+shape); - if(t<shape){ + if(t<shape) { shape = t/shape; shape = (float)sqrt((double)shape); interp_v3_v3v3(result, result, state_co, shape); @@ -2064,7 +2064,7 @@ static float do_clump(ParticleKey *state, ParticleKey *par, float time, float cl { float clump = 0.f; - if(par && clumpfac!=0.0f){ + if(par && clumpfac!=0.0f) { float cpow; if(clumppow < 0.0f) @@ -2208,7 +2208,7 @@ int do_guides(ListBase *effectors, ParticleKey *state, int index, float time) totstrength *= weight; } - if(totstrength != 0.0f){ + if(totstrength != 0.0f) { if(totstrength > 1.0f) mul_v3_fl(effect, 1.0f / totstrength); CLAMP(totstrength, 0.0f, 1.0f); @@ -2287,7 +2287,7 @@ static void do_path_effectors(ParticleSimulationData *sim, int i, ParticleCacheK } static int check_path_length(int k, ParticleCacheKey *keys, ParticleCacheKey *state, float max_length, float *cur_length, float length, float *dvec) { - if(*cur_length + length > max_length){ + if(*cur_length + length > max_length) { mul_v3_fl(dvec, (max_length - *cur_length) / length); add_v3_v3v3(state->co, (state - 1)->co, dvec); keys->steps = k; @@ -2325,12 +2325,12 @@ float *psys_cache_vgroup(DerivedMesh *dm, ParticleSystem *psys, int vgroup) /* hair dynamics pinning vgroup */ } - else if(psys->vgroup[vgroup]){ + else if(psys->vgroup[vgroup]) { MDeformVert *dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT); - if(dvert){ + if(dvert) { int totvert=dm->getNumVerts(dm), i; vg=MEM_callocN(sizeof(float)*totvert, "vg_cache"); - if(psys->vg_neg&(1<<vgroup)){ + if(psys->vg_neg&(1<<vgroup)) { for(i=0; i<totvert; i++) vg[i]= 1.0f - defvert_find_weight(&dvert[i], psys->vgroup[vgroup] - 1); } @@ -2357,14 +2357,14 @@ void psys_find_parents(ParticleSimulationData *sim) tree=BLI_kdtree_new(totparent); - for(p=0,cpa=sim->psys->child; p<totparent; p++,cpa++){ + 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++){ + 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); } @@ -2426,7 +2426,7 @@ static int psys_threads_init_path(ParticleThread *threads, Scene *scene, float c steps = (int)pow(2.0, (double)pset->draw_step); } - if(totchild && part->childtype==PART_CHILD_FACES){ + if(totchild && part->childtype==PART_CHILD_FACES) { totparent=(int)(totchild*part->parents*0.3f); if(G.rendering && part->child_nbr && part->ren_child_nbr) @@ -2479,7 +2479,7 @@ static int psys_threads_init_path(ParticleThread *threads, Scene *scene, float c /* set correct ipo timing */ #if 0 // XXX old animation system - if(part->flag&PART_ABS_TIME && part->ipo){ + if(part->flag&PART_ABS_TIME && part->ipo) { calc_ipo(part->ipo, cfra); execute_ipo((ID *)part, part->ipo); } @@ -2509,7 +2509,7 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle if(!pcache) return; - if(ctx->between){ + if(ctx->between) { ParticleData *pa = psys->particles + cpa->pa[0]; int w, needupdate; float foffset, wsum=0.f; @@ -2638,8 +2638,8 @@ 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++){ - if(ctx->between){ + for(k=0,child=child_keys; k<=ctx->steps; k++,child++) { + if(ctx->between) { int w=0; zero_v3(child->co); @@ -2696,7 +2696,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) @@ -2720,7 +2720,7 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle do_child_modifiers(&ctx->sim, &ptex, (ParticleKey *)par, par_rot, cpa, orco, hairmat, (ParticleKey *)child, t); /* we have to correct velocity because of kink & clump */ - if(k>1){ + if(k>1) { sub_v3_v3v3((child-1)->vel, child->co, (child-2)->co); mul_v3_fl((child-1)->vel, 0.5); @@ -2732,7 +2732,7 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle sub_v3_v3v3(child->vel, child->co, (child-1)->co); /* check if path needs to be cut before actual end of data points */ - if(k){ + if(k) { sub_v3_v3v3(dvec, child->co, (child-1)->co); length = 1.0f/(float)ctx->steps; k = check_path_length(k, child_keys, child, max_length, &cur_length, length, dvec); @@ -2763,7 +2763,7 @@ static void *exec_child_path_cache(void *data) ChildParticle *cpa; int i, totchild= ctx->totchild, first= 0; - if(thread->tot > 1){ + if(thread->tot > 1) { first= ctx->parent_pass? 0 : ctx->totparent; totchild= ctx->parent_pass? ctx->totparent : ctx->totchild; } @@ -2988,7 +2988,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) dietime = birthtime + pa_length * (dietime - birthtime); /*--interpolate actual path from data points--*/ - for(k=0, ca=cache[p]; k<=steps; k++, ca++){ + for(k=0, ca=cache[p]; k<=steps; k++, ca++) { time = (float)k / (float)steps; t = birthtime + time * (dietime - birthtime); result.time = -t; @@ -3062,7 +3062,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) psys->totcached = totpart; - if(psys->lattice){ + if(psys->lattice) { end_latt_deform(psys->lattice); psys->lattice= NULL; } @@ -3125,7 +3125,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf } /*---first main loop: create all actual particles' paths---*/ - for(i=0, point=edit->points; i<totpart; i++, pa+=pa?1:0, point++){ + for(i=0, point=edit->points; i<totpart; i++, pa+=pa?1:0, point++) { if(edit->totcached && !(point->flag & PEP_EDIT_RECALC)) continue; @@ -3142,7 +3142,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf /* should init_particle_interpolation set this ? */ - if(pset->brushtype==PE_BRUSH_WEIGHT){ + if(pset->brushtype==PE_BRUSH_WEIGHT) { pind.hkey[0] = NULL; /* pa != NULL since the weight brush is only available for hair */ pind.hkey[1] = pa->hair; @@ -3172,7 +3172,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf } /*--interpolate actual path from data points--*/ - for(k=0, ca=cache[i]; k<=steps; k++, ca++){ + for(k=0, ca=cache[i]; k<=steps; k++, ca++) { time = (float)k / (float)steps; t = birthtime + time * (dietime - birthtime); result.time = -t; @@ -3202,7 +3202,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf } /* selection coloring in edit mode */ - if(pset->brushtype==PE_BRUSH_WEIGHT){ + if(pset->brushtype==PE_BRUSH_WEIGHT) { float t2; if(k==0) { @@ -3225,8 +3225,8 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf pind.hkey[0] = pind.hkey[1] - 1; } else { - if((ekey + (pind.ekey[0] - point->keys))->flag & PEK_SELECT){ - if((ekey + (pind.ekey[1] - point->keys))->flag & PEK_SELECT){ + if((ekey + (pind.ekey[0] - point->keys))->flag & PEK_SELECT) { + if((ekey + (pind.ekey[1] - point->keys))->flag & PEK_SELECT) { copy_v3_v3(ca->col, sel_col); } else{ @@ -3235,7 +3235,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf } } else{ - if((ekey + (pind.ekey[1] - point->keys))->flag & PEK_SELECT){ + if((ekey + (pind.ekey[1] - point->keys))->flag & PEK_SELECT) { keytime = (t - (*pind.ekey[0]->time))/((*pind.ekey[1]->time) - (*pind.ekey[0]->time)); interp_v3_v3v3(ca->col, nosel_col, sel_col, keytime); } @@ -3282,7 +3282,7 @@ 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){ + if(time) { memcpy(to,from,sizeof(ParticleKey)); } else{ @@ -3411,7 +3411,7 @@ void psys_mat_hair_to_orco(Object *ob, DerivedMesh *dm, short from, ParticleData copy_v3_v3(hairmat[3],orco); } -void psys_vec_rot_to_face(DerivedMesh *dm, ParticleData *pa, float *vec) +void psys_vec_rot_to_face(DerivedMesh *dm, ParticleData *pa, float vec[3]) { float mat[4][4]; @@ -3669,7 +3669,7 @@ void make_local_particlesettings(ParticleSettings *part) /* test objects */ for(ob= bmain->object.first; ob && ELEM(FALSE, is_lib, is_local); ob= ob->id.next) { ParticleSystem *psys=ob->particlesystem.first; - for(; psys; psys=psys->next){ + for(; psys; psys=psys->next) { if(psys->part==part) { if(ob->id.lib) is_lib= TRUE; else is_local= TRUE; @@ -3691,7 +3691,7 @@ void make_local_particlesettings(ParticleSettings *part) /* do objects */ for(ob= bmain->object.first; ob; ob= ob->id.next) { ParticleSystem *psys; - for(psys= ob->particlesystem.first; psys; psys=psys->next){ + for(psys= ob->particlesystem.first; psys; psys=psys->next) { if(psys->part==part && ob->id.lib==0) { psys->part= part_new; part_new->id.us++; @@ -3763,9 +3763,9 @@ static void get_cpa_texture(DerivedMesh *dm, ParticleSystem *psys, ParticleSetti ptex->length= 1.0f - part->randlength * PSYS_FRAND(child_index + 26); ptex->length*= part->clength_thres < PSYS_FRAND(child_index + 27) ? part->clength : 1.0f; - for(m=0; m<MAX_MTEX; m++, mtexp++){ + for(m=0; m<MAX_MTEX; m++, mtexp++) { mtex = *mtexp; - if(mtex && mtex->mapto){ + if(mtex && mtex->mapto) { float def=mtex->def_var; short blend=mtex->blendtype; short texco = mtex->texco; @@ -3831,9 +3831,9 @@ void psys_get_texture(ParticleSimulationData *sim, ParticleData *pa, ParticleTex ptex->time = (float)(pa - sim->psys->particles)/(float)sim->psys->totpart; - for(m=0; m<MAX_MTEX; m++, mtexp++){ + for(m=0; m<MAX_MTEX; m++, mtexp++) { mtex = *mtexp; - if(mtex && mtex->mapto){ + if(mtex && mtex->mapto) { float def=mtex->def_var; short blend=mtex->blendtype; short texco = mtex->texco; @@ -3869,7 +3869,7 @@ void psys_get_texture(ParticleSimulationData *sim, ParticleData *pa, ParticleTex if((event & mtex->mapto) & PAMAP_TIME) { /* the first time has to set the base value for time regardless of blend mode */ - if((setvars&MAP_PA_TIME)==0){ + if((setvars&MAP_PA_TIME)==0) { int flip= (mtex->timefac < 0.0f); float timefac= fabsf(mtex->timefac); ptex->time *= 1.0f - timefac; @@ -3912,10 +3912,10 @@ float psys_get_child_time(ParticleSystem *psys, ChildParticle *cpa, float cfra, ParticleSettings *part = psys->part; float time, life; - if(part->childtype==PART_CHILD_FACES){ + if(part->childtype==PART_CHILD_FACES) { int w=0; time=0.0; - while(w<4 && cpa->pa[w]>=0){ + while(w<4 && cpa->pa[w]>=0) { time+=cpa->w[w]*(psys->particles+cpa->pa[w])->time; w++; } @@ -4001,7 +4001,7 @@ static void do_child_modifiers(ParticleSimulationData *sim, ParticleTexture *pte /* state is safe to cast, since only co and vel are used */ guided = do_guides(sim->psys->effectors, (ParticleKey*)state, cpa->parent, t); - if(guided==0){ + if(guided==0) { float clump = do_clump(state, par, t, part->clumpfac, part->clumppow, ptex ? ptex->clump : 1.f); if(kink_freq != 0.f) { @@ -4054,7 +4054,7 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * t=state->time; CLAMP(t, 0.0f, 1.0f); - if(p<totpart){ + if(p<totpart) { /* interpolate pathcache directly if it exist */ if(psys->pathcache) { ParticleCacheKey result; @@ -4098,7 +4098,7 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * } } } - else if(totchild){ + else if(totchild) { //invert_m4_m4(imat,ob->obmat); /* interpolate childcache directly if it exists */ @@ -4115,16 +4115,16 @@ 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){ + if(totchild && part->childtype==PART_CHILD_FACES) { /* part->parents could still be 0 so we can't test with totparent */ between=1; } - if(between){ + if(between) { int w = 0; float foffset; /* get parent states */ - while(w<4 && cpa->pa[w]>=0){ + while(w<4 && cpa->pa[w]>=0) { keys[w].time = state->time; psys_get_particle_on_path(sim, cpa->pa[w], keys+w, 1); w++; @@ -4179,7 +4179,7 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * /* correct child ipo timing */ #if 0 // XXX old animation system - if((part->flag&PART_ABS_TIME)==0 && part->ipo){ + if((part->flag&PART_ABS_TIME)==0 && part->ipo) { calc_ipo(part->ipo, 100.0f*t); execute_ipo((ID *)part, part->ipo); } @@ -4193,14 +4193,14 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * /* TODO: assign vertex groups */ get_child_modifier_parameters(part, &ctx, cpa, cpa_from, cpa_num, cpa_fuv, orco, &ptex); - if(between){ + if(between) { int w=0; state->co[0] = state->co[1] = state->co[2] = 0.0f; state->vel[0] = state->vel[1] = state->vel[2] = 0.0f; /* child position is the weighted sum of parent positions */ - while(w<4 && cpa->pa[w]>=0){ + while(w<4 && cpa->pa[w]>=0) { state->co[0] += cpa->w[w] * keys[w].co[0]; state->co[1] += cpa->w[w] * keys[w].co[1]; state->co[2] += cpa->w[w] * keys[w].co[2]; @@ -4227,11 +4227,11 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * do_child_modifiers(sim, &ptex, par, par->rot, cpa, orco, hairmat, state, t); /* try to estimate correct velocity */ - if(vel){ + if(vel) { ParticleKey tstate; float length = len_v3(state->vel); - if(t>=0.001f){ + 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); @@ -4263,11 +4263,11 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta /* negative time means "use current time" */ cfra = state->time > 0 ? state->time : BKE_curframe(sim->scene); - if(p>=totpart){ + if(p>=totpart) { if(!psys->totchild) return 0; - if(part->childtype == PART_CHILD_FACES){ + if(part->childtype == PART_CHILD_FACES) { if(!(psys->flag & PSYS_KEYED)) return 0; @@ -4303,13 +4303,13 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta cfra = MIN2(cfra, pa->dietime); } - if(sim->psys->flag & PSYS_KEYED){ + if(sim->psys->flag & PSYS_KEYED) { state->time= -cfra; psys_get_particle_on_path(sim, p, state,1); return 1; } else{ - if(cpa){ + if(cpa) { float mat[4][4]; ParticleKey *key1; float t = (cfra - pa->time) / pa->lifetime; diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index e48495bcc44..206d9036ba7 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -306,7 +306,7 @@ static int get_psys_tot_child(struct Scene *scene, ParticleSystem *psys) static void alloc_child_particles(ParticleSystem *psys, int tot) { - if(psys->child){ + if(psys->child) { /* only re-allocate if we have to */ if(psys->part->childtype && psys->totchild == tot) { memset(psys->child, 0, tot*sizeof(ChildParticle)); @@ -415,13 +415,13 @@ static void distribute_simple_children(Scene *scene, Object *ob, DerivedMesh *fi alloc_child_particles(psys, totpart); cpa = psys->child; - for(i=0; i<child_nbr; i++){ - for(p=0; p<psys->totpart; p++,cpa++){ + for(i=0; i<child_nbr; i++) { + for(p=0; p<psys->totpart; p++,cpa++) { float length=2.0; cpa->parent=p; /* create even spherical distribution inside unit sphere */ - while(length>=1.0f){ + while(length>=1.0f) { cpa->fuv[0]=2.0f*BLI_frand()-1.0f; cpa->fuv[1]=2.0f*BLI_frand()-1.0f; cpa->fuv[2]=2.0f*BLI_frand()-1.0f; @@ -449,7 +449,7 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys) copy_v3_v3(max, mv->co); mv++; - for(i=1; i<totvert; i++, 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]); @@ -483,9 +483,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(j=0; j<res; j++){ - for(k=0; k<res; k++,p++,pa++){ + 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++) { pa->fuv[0] = min[0] + (float)i*d; pa->fuv[1] = min[1] + (float)j*d; pa->fuv[2] = min[2] + (float)k*d; @@ -496,7 +496,7 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys) } /* enable particles near verts/edges/faces/inside surface */ - if(from==PART_FROM_VERT){ + if(from==PART_FROM_VERT) { float vec[3]; pa=psys->particles; @@ -505,7 +505,7 @@ 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++){ + for(i=0,mv=mvert; i<totvert; i++,mv++) { sub_v3_v3v3(vec,mv->co,min); vec[0]/=delta[0]; vec[1]/=delta[1]; @@ -515,7 +515,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,13 +526,13 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys) totface=dm->getNumTessFaces(dm); mface=mface_array=dm->getTessFaceDataArray(dm,CD_MFACE); - for(a=0; a<amax; a++){ - if(a==0){ a0mul=res*res; a1mul=res; a2mul=1; } - else if(a==1){ a0mul=res; a1mul=1; a2mul=res*res; } + for(a=0; a<amax; a++) { + if(a==0) { a0mul=res*res; a1mul=res; a2mul=1; } + else if(a==1) { a0mul=res; a1mul=1; a2mul=res*res; } else{ a0mul=1; a1mul=res*res; a2mul=res; } - for(a1=0; a1<size[(a+1)%3]; a1++){ - for(a2=0; a2<size[(a+2)%3]; a2++){ + for(a1=0; a1<size[(a+1)%3]; a1++) { + for(a2=0; a2<size[(a+2)%3]; a2++) { mface= mface_array; pa = psys->particles + a1*a1mul + a2*a2mul; @@ -543,22 +543,22 @@ 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); - if(isect_axial_line_tri_v3(a, co1, co2, v2, v3, v1, &lambda)){ + if(isect_axial_line_tri_v3(a, co1, co2, v2, v3, v1, &lambda)) { if(from==PART_FROM_FACE) (pa+(int)(lambda*size[a])*a0mul)->flag &= ~PARS_UNEXIST; else /* store number of intersections */ (pa+(int)(lambda*size[a])*a0mul)->hair_index++; } - if(mface->v4){ + if(mface->v4) { copy_v3_v3(v4, mvert[mface->v4].co); - if(isect_axial_line_tri_v3(a, co1, co2, v4, v1, v3, &lambda)){ + if(isect_axial_line_tri_v3(a, co1, co2, v4, v1, v3, &lambda)) { if(from==PART_FROM_FACE) (pa+(int)(lambda*size[a])*a0mul)->flag &= ~PARS_UNEXIST; else @@ -567,10 +567,10 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys) } } - if(from==PART_FROM_VOLUME){ + if(from==PART_FROM_VOLUME) { int in=pa->hair_index%2; if(in) pa->hair_index++; - for(i=0; i<size[0]; i++){ + for(i=0; i<size[0]; i++) { if(in || (pa+i*a0mul)->hair_index%2) (pa+i*a0mul)->flag &= ~PARS_UNEXIST; /* odd intersections == in->out / out->in */ @@ -584,9 +584,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(j=0; j<res; j++){ - for(k=0; k<res; k++,p++,pa++){ + 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++) { if(j%2) pa->fuv[0] += d/2.f; @@ -599,11 +599,11 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys) } } - if(psys->part->flag & PART_GRID_INVERT){ - for(i=0; i<size[0]; i++){ - for(j=0; j<size[1]; j++){ + if(psys->part->flag & PART_GRID_INVERT) { + for(i=0; i<size[0]; i++) { + for(j=0; j<size[1]; j++) { pa=psys->particles + res*(i*res + j); - for(k=0; k<size[2]; k++, pa++){ + for(k=0; k<size[2]; k++, pa++) { pa->flag ^= PARS_UNEXIST; } } @@ -612,7 +612,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; @@ -765,7 +765,7 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch pa->fuv[1] = pa->fuv[2] = pa->fuv[3] = 0.0; #if ONLY_WORKING_WITH_PA_VERTS - if(ctx->tree){ + if(ctx->tree) { KDTreeNearest ptn[3]; int w, maxw; @@ -773,7 +773,7 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch transform_mesh_orco_verts((Mesh*)ob->data, &orco1, 1, 1); maxw = BLI_kdtree_find_n_nearest(ctx->tree,3,orco1,NULL,ptn); - for(w=0; w<maxw; w++){ + 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 pa->num = i = ctx->index[p]; mface = dm->getTessFaceData(dm,i,CD_MFACE); - switch(distr){ + switch(distr) { case PART_DISTR_JIT: if(ctx->jitlevel == 1) { if(mface->v4) @@ -810,7 +810,7 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch pa->foffset= 0.0f; /* experimental */ - if(from==PART_FROM_VOLUME){ + if(from==PART_FROM_VOLUME) { MVert *mvert=dm->getVertDataArray(dm,CD_MVERT); tot=dm->getNumTessFaces(dm); @@ -825,25 +825,25 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch 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; v2=mvert[mface->v2].co; v3=mvert[mface->v3].co; - if(isect_line_tri_v3(co1, co2, v2, v3, v1, &cur_d, 0)){ - if(cur_d<min_d){ + if(isect_line_tri_v3(co1, co2, v2, v3, v1, &cur_d, 0)) { + if(cur_d<min_d) { min_d=cur_d; pa->foffset=cur_d*50.0f; /* to the middle of volume */ intersect=1; } } - if(mface->v4){ + if(mface->v4) { v4=mvert[mface->v4].co; - if(isect_line_tri_v3(co1, co2, v4, v1, v3, &cur_d, 0)){ - if(cur_d<min_d){ + if(isect_line_tri_v3(co1, co2, v4, v1, v3, &cur_d, 0)) { + if(cur_d<min_d) { min_d=cur_d; pa->foffset=cur_d*50.0f; /* to the middle of volume */ intersect=1; @@ -853,7 +853,7 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch } if(intersect==0) pa->foffset=0.0; - else switch(distr){ + else switch(distr) { case PART_DISTR_JIT: pa->foffset*= ctx->jit[p%(2*ctx->jitlevel)]; break; @@ -883,7 +883,7 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch cpa->num = ctx->index[p]; - if(ctx->tree){ + if(ctx->tree) { KDTreeNearest ptn[10]; int w,maxw;//, do_seams; float maxd /*, mind,dd */, totw= 0.0f; @@ -898,24 +898,24 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch /* mind=ptn[0].dist; */ /* UNUSED */ /* the weights here could be done better */ - for(w=0; w<maxw; w++){ + for(w=0; w<maxw; w++) { parent[w]=ptn[w].index; pweight[w]=(float)pow(2.0,(double)(-6.0f*ptn[w].dist/maxd)); } - for(;w<10; w++){ + for(;w<10; w++) { parent[w]=-1; pweight[w]=0.0f; } - for(w=0,i=0; w<maxw && i<4; w++){ - if(parent[w]>=0){ + for(w=0,i=0; w<maxw && i<4; w++) { + if(parent[w]>=0) { cpa->pa[i]=parent[w]; cpa->w[i]=pweight[w]; totw+=pweight[w]; i++; } } - for(;i<4; i++){ + for(;i<4; i++) { cpa->pa[i]=-1; cpa->w[i]=0.0f; } @@ -993,7 +993,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; @@ -1057,7 +1057,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D } else { /* Grid distribution */ - if(part->distr==PART_DISTR_GRID && from != PART_FROM_VERT){ + 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); @@ -1079,7 +1079,7 @@ 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++){ + 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); @@ -1128,7 +1128,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D /* Get total number of emission elements and allocate needed arrays */ totelem = (from == PART_FROM_VERT) ? dm->getNumVerts(dm) : dm->getNumTessFaces(dm); - if(totelem == 0){ + if(totelem == 0) { distribute_invalid(scene, psys, children ? PART_FROM_CHILD : 0); if(G.f & G_DEBUG) @@ -1147,14 +1147,14 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D jitter_offset = MEM_callocN(sizeof(float)*totelem, "particle_distribution_jitoff"); /* Calculate weights from face areas */ - if((part->flag&PART_EDISTR || children) && from != PART_FROM_VERT){ + if((part->flag&PART_EDISTR || children) && from != PART_FROM_VERT) { MVert *v1, *v2, *v3, *v4; float totarea=0.f, co1[3], co2[3], co3[3], co4[3]; float (*orcodata)[3]; orcodata= dm->getVertDataArray(dm, CD_ORCO); - for(i=0; i<totelem; i++){ + for(i=0; i<totelem; i++) { MFace *mf=dm->getTessFaceData(dm,i,CD_MFACE); if(orcodata) { @@ -1206,13 +1206,13 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D /* Calculate weights from vgroup */ vweight = psys_cache_vgroup(dm,psys,PSYS_VG_DENSITY); - if(vweight){ + if(vweight) { if(from==PART_FROM_VERT) { for(i=0;i<totelem; i++) element_weight[i]*=vweight[i]; } else { /* PART_FROM_FACE / PART_FROM_VOLUME */ - for(i=0;i<totelem; i++){ + for(i=0;i<totelem; i++) { MFace *mf=dm->getTessFaceData(dm,i,CD_MFACE); tweight = vweight[mf->v1] + vweight[mf->v2] + vweight[mf->v3]; @@ -1402,7 +1402,7 @@ static void distribute_particles(ParticleSimulationData *sim, int from) PARTICLE_PSMD; int distr_error=0; - if(psmd){ + if(psmd) { if(psmd->dm) distribute_particles_on_dm(sim, from); else @@ -1411,7 +1411,7 @@ static void distribute_particles(ParticleSimulationData *sim, int from) else distribute_particles_on_shape(sim, from); - if(distr_error){ + if(distr_error) { distribute_invalid(sim->scene, sim->psys, from); fprintf(stderr,"Particle distribution error!\n"); @@ -1467,7 +1467,7 @@ void psys_threads_free(ParticleThread *threads) if(ctx->vg_roughe) MEM_freeN(ctx->vg_roughe); - if(ctx->sim.psys->lattice){ + if(ctx->sim.psys->lattice) { end_latt_deform(ctx->sim.psys->lattice); ctx->sim.psys->lattice= NULL; } @@ -1602,7 +1602,7 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P normalize_v3(nor); /* -tangent */ - if(part->tanfac!=0.0f){ + 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=0.0f; mul_v3_fl(vtan,-cosf((float)M_PI*(part->tanphase+phase))); @@ -1620,7 +1620,7 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P /* -velocity (boids need this even if there's no random velocity) */ - if(part->randfac != 0.0f || (part->phystype==PART_PHYS_BOIDS && pa->boid)){ + if(part->randfac != 0.0f || (part->phystype==PART_PHYS_BOIDS && pa->boid)) { r_vel[0] = 2.0f * (PSYS_FRAND(p + 10) - 0.5f); r_vel[1] = 2.0f * (PSYS_FRAND(p + 11) - 0.5f); r_vel[2] = 2.0f * (PSYS_FRAND(p + 12) - 0.5f); @@ -1630,7 +1630,7 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P } /* -angular velocity */ - if(part->avemode==PART_AVE_RAND){ + if(part->avemode==PART_AVE_RAND) { r_ave[0] = 2.0f * (PSYS_FRAND(p + 13) - 0.5f); r_ave[1] = 2.0f * (PSYS_FRAND(p + 14) - 0.5f); r_ave[2] = 2.0f * (PSYS_FRAND(p + 15) - 0.5f); @@ -1640,7 +1640,7 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P } /* -rotation */ - if(part->randrotfac != 0.0f){ + if(part->randrotfac != 0.0f) { r_rot[0] = 2.0f * (PSYS_FRAND(p + 16) - 0.5f); r_rot[1] = 2.0f * (PSYS_FRAND(p + 17) - 0.5f); r_rot[2] = 2.0f * (PSYS_FRAND(p + 18) - 0.5f); @@ -1685,12 +1685,12 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P /* -velocity from: */ /* *reactions */ - if(dtime > 0.f){ + if(dtime > 0.f) { sub_v3_v3v3(vel, pa->state.vel, pa->prev_state.vel); } /* *emitter velocity */ - if(dtime != 0.f && part->obfac != 0.f){ + if(dtime != 0.f && part->obfac != 0.f) { sub_v3_v3v3(vel, loc, state->co); mul_v3_fl(vel, part->obfac/dtime); } @@ -1736,9 +1736,9 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P /* -rotation */ unit_qt(state->rot); - if(part->rotmode){ + if(part->rotmode) { /* create vector into which rotation is aligned */ - switch(part->rotmode){ + switch(part->rotmode) { case PART_ROT_NOR: copy_v3_v3(rot_vec, nor); break; @@ -1781,8 +1781,8 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P zero_v3(state->ave); - if(part->avemode){ - switch(part->avemode){ + if(part->avemode) { + switch(part->avemode) { case PART_AVE_SPIN: copy_v3_v3(state->ave, vel); break; @@ -1835,7 +1835,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, } - if(part->type == PART_HAIR){ + if(part->type == PART_HAIR) { pa->lifetime = 100.0f; } else{ @@ -1966,7 +1966,7 @@ static void set_keyed_keys(ParticleSimulationData *sim) psys_get_particle_state(&ksim, p%ksim.psys->totpart, key, 1); - if(psys->flag & PSYS_KEYED_TIMING){ + if(psys->flag & PSYS_KEYED_TIMING) { key->time = pa->time + pt->time; if(pt->duration != 0.0f && k+1 < totkeys) { copy_particle_key(key+1, key, 1); @@ -2099,7 +2099,7 @@ static void integrate_particle(ParticleSettings *part, ParticleData *pa, float d if(pa->prev_state.time < 0.f && integrator == PART_INT_VERLET) integrator = PART_INT_EULER; - switch(integrator){ + switch(integrator) { case PART_INT_EULER: steps=1; break; @@ -2118,7 +2118,7 @@ static void integrate_particle(ParticleSettings *part, ParticleData *pa, float d states->time = 0.f; - for(i=0; i<steps; i++){ + for(i=0; i<steps; i++) { zero_v3(force); zero_v3(impulse); @@ -2133,13 +2133,13 @@ static void integrate_particle(ParticleSettings *part, ParticleData *pa, float d /* calculate next state */ add_v3_v3(states[i].vel, impulse); - switch(integrator){ + switch(integrator) { case PART_INT_EULER: madd_v3_v3v3fl(pa->state.co, states->co, states->vel, dtime); madd_v3_v3v3fl(pa->state.vel, states->vel, acceleration, dtime); break; case PART_INT_MIDPOINT: - if(i==0){ + if(i==0) { madd_v3_v3v3fl(states[1].co, states->co, states->vel, dtime*0.5f); madd_v3_v3v3fl(states[1].vel, states->vel, acceleration, dtime*0.5f); states[1].time = dtime*0.5f; @@ -2151,7 +2151,7 @@ static void integrate_particle(ParticleSettings *part, ParticleData *pa, float d } break; case PART_INT_RK4: - switch(i){ + switch(i) { case 0: copy_v3_v3(dx[0], states->vel); mul_v3_fl(dx[0], dtime); @@ -2252,7 +2252,7 @@ static void sph_spring_delete(ParticleSystem *psys, int j) psys->tot_fluidsprings--; - if (psys->tot_fluidsprings < psys->alloc_fluidsprings/2 && psys->alloc_fluidsprings > PSYS_FLUID_SPRINGS_INITIAL_SIZE){ + if (psys->tot_fluidsprings < psys->alloc_fluidsprings/2 && psys->alloc_fluidsprings > PSYS_FLUID_SPRINGS_INITIAL_SIZE) { psys->alloc_fluidsprings /= 2; psys->fluid_springs = (ParticleSpring*)MEM_reallocN(psys->fluid_springs, psys->alloc_fluidsprings * sizeof(ParticleSpring)); } @@ -2508,7 +2508,7 @@ static void sph_force_cb(void *sphdata_v, ParticleKey *state, float *force, floa madd_v3_v3fl(force, vec, -10.f * spring_constant * (1.f - rij/h) * (spring->rest_length - rij)); } - else if(fluid->spring_frames == 0 || (pa->prev_state.time-pa->time) <= fluid->spring_frames){ + else if(fluid->spring_frames == 0 || (pa->prev_state.time-pa->time) <= fluid->spring_frames) { ParticleSpring temp_spring; temp_spring.particle_index[0] = index; temp_spring.particle_index[1] = pfn->index; @@ -2621,7 +2621,7 @@ static void basic_force_cb(void *efdata_v, ParticleKey *state, float *force, flo madd_v3_v3fl(force, state->vel, -part->dragfac * pa->size * pa->size * len_v3(state->vel)); /* brownian force */ - if(part->brownfac != 0.0f){ + if(part->brownfac != 0.0f) { force[0] += (BLI_frand()-0.5f) * part->brownfac; force[1] += (BLI_frand()-0.5f) * part->brownfac; force[2] += (BLI_frand()-0.5f) * part->brownfac; @@ -2684,8 +2684,8 @@ static void basic_rotate(ParticleSettings *part, ParticleData *pa, float dfra, f { float rotfac, rot1[4], rot2[4]={1.0,0.0,0.0,0.0}, dtime=dfra*timestep; - if((part->flag & PART_ROT_DYN)==0){ - if(part->avemode==PART_AVE_SPIN){ + if((part->flag & PART_ROT_DYN)==0) { + if(part->avemode==PART_AVE_SPIN) { float angle; float len1 = len_v3(pa->prev_state.vel); float len2 = len_v3(pa->state.vel); @@ -2704,7 +2704,7 @@ 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; } @@ -3145,7 +3145,7 @@ static int collision_detect(ParticleData *pa, ParticleCollision *col, BVHTreeRay if(hit->dist == 0.0f) hit->dist = col->original_ray_length = 0.000001f; - for(coll = colliders->first; coll; coll=coll->next){ + for(coll = colliders->first; coll; coll=coll->next) { /* for boids: don't check with current ground object */ if(coll->ob == col->skip) continue; @@ -3400,7 +3400,7 @@ static void collision_check(ParticleSimulationData *sim, int p, float dfra, floa } /* 10 iterations to catch multiple collisions */ - while(collision_count < COLLISION_MAX_COLLISIONS){ + while(collision_count < COLLISION_MAX_COLLISIONS) { if(collision_detect(pa, &col, &hit, sim->colliders)) { collision_count++; @@ -3432,7 +3432,7 @@ static void psys_update_path_cache(ParticleSimulationData *sim, float cfra) if(alloc || psys->recalc&PSYS_RECALC_CHILD || (psys->vgroup[PSYS_VG_DENSITY] && (sim->ob && sim->ob->mode & OB_MODE_WEIGHT_PAINT))) distr=1; - if(distr){ + if(distr) { if(alloc) realloc_particles(sim, sim->psys->totpart); @@ -3830,18 +3830,18 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) /* store this, so we can do multiple loops over particles */ pa->state.time = dfra; - if(dietime <= cfra && psys->cfra < dietime){ + if(dietime <= cfra && psys->cfra < dietime) { /* particle dies some time between this and last step */ pa->state.time = dietime - ((birthtime > psys->cfra) ? birthtime : psys->cfra); pa->alive = PARS_DYING; } - else if(birthtime <= cfra && birthtime >= psys->cfra){ + else if(birthtime <= cfra && birthtime >= psys->cfra) { /* particle is born some time between this and last step*/ reset_particle(sim, pa, dfra*timestep, cfra); pa->alive = PARS_ALIVE; pa->state.time = cfra - birthtime; } - else if(dietime < cfra){ + else if(dietime < cfra) { /* nothing to be done when particle is dead */ } @@ -3923,7 +3923,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) /* finalize particle state and time after dynamics */ LOOP_DYNAMIC_PARTICLES { - if(pa->alive == PARS_DYING){ + if(pa->alive == PARS_DYING) { pa->alive=PARS_DEAD; pa->state.time=pa->dietime; } @@ -3982,7 +3982,7 @@ static void cached_step(ParticleSimulationData *sim, float cfra) else pa->alive = PARS_ALIVE; - if(psys->lattice){ + if(psys->lattice) { end_latt_deform(psys->lattice); psys->lattice= NULL; } @@ -3997,7 +3997,7 @@ static void cached_step(ParticleSimulationData *sim, float cfra) static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra)) { ParticleSystem *psys = sim->psys; - if(psys->particles){ + if(psys->particles) { MEM_freeN(psys->particles); psys->particles = 0; psys->totpart = 0; @@ -4263,7 +4263,7 @@ static void system_step(ParticleSimulationData *sim, float cfra) update_children(sim); /* cleanup */ - if(psys->lattice){ + if(psys->lattice) { end_latt_deform(psys->lattice); psys->lattice= NULL; } @@ -4322,7 +4322,7 @@ void psys_check_boid_data(ParticleSystem *psys) pa->boid = bpa++; } } - else if(pa->boid){ + else if(pa->boid) { MEM_freeN(pa->boid); LOOP_PARTICLES pa->boid = NULL; @@ -4425,6 +4425,10 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys) if(!sim.psmd->dm) return; + if (part->from != PART_FROM_VERT) { + DM_ensure_tessface(sim.psmd->dm); + } + /* execute drivers only, as animation has already been done */ BKE_animsys_evaluate_animdata(scene, &part->id, part->adt, cfra, ADT_RECALC_DRIVERS); @@ -4462,7 +4466,7 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys) /* first step is negative so particles get killed and reset */ psys->cfra= 1.0f; - for(i=0; i<=part->hair_step; i++){ + for(i=0; i<=part->hair_step; i++) { hcfra=100.0f*(float)i/(float)psys->part->hair_step; if((part->flag & PART_HAIR_REGROW)==0) BKE_animsys_evaluate_animdata(scene, &part->id, part->adt, hcfra, ADT_RECALC_ANIM); diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index bf9ed8b17e3..705f198865a 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -275,7 +275,7 @@ static void ptcache_particle_read(int index, void *psys_v, void **data, float cf if(cfra > pa->state.time) memcpy(&pa->prev_state, &pa->state, sizeof(ParticleKey)); - if(old_data){ + if(old_data) { /* old format cache */ memcpy(&pa->state, old_data, sizeof(ParticleKey)); return; @@ -3015,7 +3015,7 @@ void BKE_ptcache_toggle_disk_cache(PTCacheID *pid) PointCache *cache = pid->cache; int last_exact = cache->last_exact; - if (!G.relbase_valid){ + if (!G.relbase_valid) { cache->flag &= ~PTCACHE_DISK_CACHE; if (G.f & G_DEBUG) printf("File must be saved before using disk cache!\n"); diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index d88a5c26c2c..aebdf3cef65 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -495,7 +495,7 @@ static void do_alphaover_effect_float(float facf0, float facf1, int x, int y, /* rt = rt1 over rt2 (alpha from rt1) */ fac= fac2; - mfac= 1.0f - (fac2*rt1[3]) ; + mfac= 1.0f - (fac2 * rt1[3]); if(fac <= 0.0f) { memcpy(rt, rt2, 4 * sizeof(float)); @@ -906,9 +906,9 @@ static void makeGammaTables(float gamma) /* multiplication factors used in scaling the interpolation. */ for (i = 0; i < RE_GAMMA_TABLE_SIZE; i++ ) { gamfactor_table[i] = inv_color_step - * (gamma_range_table[i + 1] - gamma_range_table[i]) ; + * (gamma_range_table[i + 1] - gamma_range_table[i]); inv_gamfactor_table[i] = inv_color_step - * (inv_gamma_range_table[i + 1] - inv_gamma_range_table[i]) ; + * (inv_gamma_range_table[i + 1] - inv_gamma_range_table[i]); } } /* end of void makeGammaTables(float gamma) */ @@ -971,7 +971,7 @@ static void gamtabs(float gamma) else if(gamma==1.0f) igamtab1[a-1]= 256*a-1; else { val= a/256.0f; - igamtab1[a-1]= (65535.0*pow(val, gamma)) -1 ; + igamtab1[a - 1]= (65535.0 * pow(val, gamma)) - 1; } } @@ -1631,7 +1631,7 @@ float hyp3,hyp4,b4,b5 if(wipezone->flip) x = xo - x; angle = wipezone->angle; - if(wipe->forward){ + if(wipe->forward) { posx = facf0 * xo; posy = facf0 * yo; } else{ @@ -1699,9 +1699,9 @@ float hyp3,hyp4,b4,b5 hwidth = minf(hwidth, fabsf(b3-b1)/2.0f); - if(b2 < b1 && b2 < b3 ){ + if(b2 < b1 && b2 < b3 ) { output = in_band(hwidth,hyp,0,1); - } else if(b2 > b1 && b2 > b3 ){ + } else if(b2 > b1 && b2 > b3 ) { output = in_band(hwidth,hyp2,0,1); } else { if( hyp < hwidth && hyp2 > hwidth ) @@ -1724,7 +1724,7 @@ float hyp3,hyp4,b4,b5 widthf = wipe->edgeWidth*2.0f*(float)M_PI; temp1 = 2.0f * (float)M_PI * facf0; - if(wipe->forward){ + if(wipe->forward) { temp1 = 2.0f*(float)M_PI - temp1; } @@ -1736,7 +1736,7 @@ float hyp3,hyp4,b4,b5 else if(x<=0 && y <= 0) temp2 += (float)M_PI; else if(x >= 0 && y <= 0) temp2 = 2.0f*(float)M_PI - temp2; - if(wipe->forward){ + if(wipe->forward) { temp3 = temp1-(widthf*0.5f)*facf0; temp4 = temp1+(widthf*0.5f)*(1-facf0); } else{ @@ -1775,10 +1775,10 @@ float hyp3,hyp4,b4,b5 temp2 = yo*(1-facf0/2)-yo*facf0/2; pointdist = sqrt(temp1*temp1 + temp2*temp2); - if(b2 < b1 && b2 < b3 ){ + if(b2 < b1 && b2 < b3 ) { if(hwidth < pointdist) output = in_band(wipezone,hwidth,hyp,facf0,0,1); - } else if(b2 > b1 && b2 > b3 ){ + } else if(b2 > b1 && b2 > b3 ) { if(hwidth < pointdist) output = in_band(wipezone,hwidth,hyp2,facf0,0,1); } else { @@ -1799,10 +1799,10 @@ float hyp3,hyp4,b4,b5 hyp = abs(angle*x+y+(-posy/2-angle*posx/2))*wipezone->pythangle; hyp2 = abs(angle*x+y+(-(yo-posy/2)-angle*(xo-posx/2)))*wipezone->pythangle; - if(b2 < b1 && b2 < b3 ){ + if(b2 < b1 && b2 < b3 ) { if(hwidth < pointdist) output *= in_band(wipezone,hwidth,hyp,facf0,0,1); - } else if(b2 > b1 && b2 > b3 ){ + } else if(b2 > b1 && b2 > b3 ) { if(hwidth < pointdist) output *= in_band(wipezone,hwidth,hyp2,facf0,0,1); } else { @@ -1911,10 +1911,10 @@ static void do_wipe_effect_byte(Sequence *seq, float facf0, float UNUSED(facf1), } rt+=4; - if(rt1 !=NULL){ + if(rt1 !=NULL) { rt1+=4; } - if(rt2 !=NULL){ + if(rt2 !=NULL) { rt2+=4; } } @@ -1969,10 +1969,10 @@ static void do_wipe_effect_float(Sequence *seq, float facf0, float UNUSED(facf1) } rt+=4; - if(rt1 !=NULL){ + if(rt1 !=NULL) { rt1+=4; } - if(rt2 !=NULL){ + if(rt2 !=NULL) { rt2+=4; } } @@ -2107,7 +2107,7 @@ static void do_transform(Scene *scene, Sequence *seq, float UNUSED(facf0), int x } // Translate - if(!transform->percent){ + if(!transform->percent) { float rd_s = (scene->r.size/100.0f); translate_x = transform->xIni*rd_s+(x/2.0f); @@ -2173,7 +2173,7 @@ static void RVBlurBitmap2_byte ( unsigned char* map, int width,int height, /* Allocate memory for the filter elements */ halfWidth = ((quality+1)*blur); filter = (float *)MEM_mallocN(sizeof(float)*halfWidth*2, "blurbitmapfilter"); - if (!filter){ + if (!filter) { MEM_freeN (temp); return; } @@ -2185,7 +2185,7 @@ static void RVBlurBitmap2_byte ( unsigned char* map, int width,int height, /* Blancmange (bmange@airdmhor.gen.nz) */ k = -1.0f/(2.0f*(float)M_PI*blur*blur); - for (ix = 0;ix< halfWidth;ix++){ + for (ix = 0;ix< halfWidth;ix++) { weight = (float)exp(k*(ix*ix)); filter[halfWidth - ix] = weight; filter[halfWidth + ix] = weight; @@ -2201,16 +2201,16 @@ static void RVBlurBitmap2_byte ( unsigned char* map, int width,int height, filter[ix]/=fval; /* Blur the rows */ - for (y=0;y<height;y++){ + for (y=0;y<height;y++) { /* Do the left & right strips */ - for (x=0;x<halfWidth;x++){ + for (x=0;x<halfWidth;x++) { index=(x+y*width)*4; fx=0; curColor[0]=curColor[1]=curColor[2]=0; curColor2[0]=curColor2[1]=curColor2[2]=0; - for (i=x-halfWidth;i<x+halfWidth;i++){ - if ((i>=0)&&(i<width)){ + for (i=x-halfWidth;i<x+halfWidth;i++) { + if ((i>=0)&&(i<width)) { curColor[0]+=map[(i+y*width)*4+GlowR]*filter[fx]; curColor[1]+=map[(i+y*width)*4+GlowG]*filter[fx]; curColor[2]+=map[(i+y*width)*4+GlowB]*filter[fx]; @@ -2234,11 +2234,11 @@ static void RVBlurBitmap2_byte ( unsigned char* map, int width,int height, } /* Do the main body */ - for (x=halfWidth;x<width-halfWidth;x++){ + for (x=halfWidth;x<width-halfWidth;x++) { index=(x+y*width)*4; fx=0; curColor[0]=curColor[1]=curColor[2]=0; - for (i=x-halfWidth;i<x+halfWidth;i++){ + for (i=x-halfWidth;i<x+halfWidth;i++) { curColor[0]+=map[(i+y*width)*4+GlowR]*filter[fx]; curColor[1]+=map[(i+y*width)*4+GlowG]*filter[fx]; curColor[2]+=map[(i+y*width)*4+GlowB]*filter[fx]; @@ -2255,15 +2255,15 @@ static void RVBlurBitmap2_byte ( unsigned char* map, int width,int height, /* Blur the columns */ - for (x=0;x<width;x++){ + for (x=0;x<width;x++) { /* Do the top & bottom strips */ - for (y=0;y<halfWidth;y++){ + for (y=0;y<halfWidth;y++) { index=(x+y*width)*4; fy=0; curColor[0]=curColor[1]=curColor[2]=0; curColor2[0]=curColor2[1]=curColor2[2]=0; - for (i=y-halfWidth;i<y+halfWidth;i++){ - if ((i>=0)&&(i<height)){ + for (i=y-halfWidth;i<y+halfWidth;i++) { + if ((i>=0)&&(i<height)) { /* Bottom */ curColor[0]+=map[(x+i*width)*4+GlowR]*filter[fy]; curColor[1]+=map[(x+i*width)*4+GlowG]*filter[fy]; @@ -2287,11 +2287,11 @@ static void RVBlurBitmap2_byte ( unsigned char* map, int width,int height, temp[((x+(height-1-y)*width)*4)+GlowB]=curColor2[2]; } /* Do the main body */ - for (y=halfWidth;y<height-halfWidth;y++){ + for (y=halfWidth;y<height-halfWidth;y++) { index=(x+y*width)*4; fy=0; curColor[0]=curColor[1]=curColor[2]=0; - for (i=y-halfWidth;i<y+halfWidth;i++){ + for (i=y-halfWidth;i<y+halfWidth;i++) { curColor[0]+=map[(x+i*width)*4+GlowR]*filter[fy]; curColor[1]+=map[(x+i*width)*4+GlowG]*filter[fy]; curColor[2]+=map[(x+i*width)*4+GlowB]*filter[fy]; @@ -2342,7 +2342,7 @@ static void RVBlurBitmap2_float ( float* map, int width,int height, /* Allocate memory for the filter elements */ halfWidth = ((quality+1)*blur); filter = (float *)MEM_mallocN(sizeof(float)*halfWidth*2, "blurbitmapfilter"); - if (!filter){ + if (!filter) { MEM_freeN (temp); return; } @@ -2355,7 +2355,7 @@ static void RVBlurBitmap2_float ( float* map, int width,int height, k = -1.0f/(2.0f*(float)M_PI*blur*blur); - for (ix = 0;ix< halfWidth;ix++){ + for (ix = 0;ix< halfWidth;ix++) { weight = (float)exp(k*(ix*ix)); filter[halfWidth - ix] = weight; filter[halfWidth + ix] = weight; @@ -2371,16 +2371,16 @@ static void RVBlurBitmap2_float ( float* map, int width,int height, filter[ix]/=fval; /* Blur the rows */ - for (y=0;y<height;y++){ + for (y=0;y<height;y++) { /* Do the left & right strips */ - for (x=0;x<halfWidth;x++){ + for (x=0;x<halfWidth;x++) { index=(x+y*width)*4; fx=0; curColor[0]=curColor[1]=curColor[2]=0.0f; curColor2[0]=curColor2[1]=curColor2[2]=0.0f; - for (i=x-halfWidth;i<x+halfWidth;i++){ - if ((i>=0)&&(i<width)){ + for (i=x-halfWidth;i<x+halfWidth;i++) { + if ((i>=0)&&(i<width)) { curColor[0]+=map[(i+y*width)*4+GlowR]*filter[fx]; curColor[1]+=map[(i+y*width)*4+GlowG]*filter[fx]; curColor[2]+=map[(i+y*width)*4+GlowB]*filter[fx]; @@ -2404,11 +2404,11 @@ static void RVBlurBitmap2_float ( float* map, int width,int height, } /* Do the main body */ - for (x=halfWidth;x<width-halfWidth;x++){ + for (x=halfWidth;x<width-halfWidth;x++) { index=(x+y*width)*4; fx=0; curColor[0]=curColor[1]=curColor[2]=0; - for (i=x-halfWidth;i<x+halfWidth;i++){ + for (i=x-halfWidth;i<x+halfWidth;i++) { curColor[0]+=map[(i+y*width)*4+GlowR]*filter[fx]; curColor[1]+=map[(i+y*width)*4+GlowG]*filter[fx]; curColor[2]+=map[(i+y*width)*4+GlowB]*filter[fx]; @@ -2425,15 +2425,15 @@ static void RVBlurBitmap2_float ( float* map, int width,int height, /* Blur the columns */ - for (x=0;x<width;x++){ + for (x=0;x<width;x++) { /* Do the top & bottom strips */ - for (y=0;y<halfWidth;y++){ + for (y=0;y<halfWidth;y++) { index=(x+y*width)*4; fy=0; curColor[0]=curColor[1]=curColor[2]=0; curColor2[0]=curColor2[1]=curColor2[2]=0; - for (i=y-halfWidth;i<y+halfWidth;i++){ - if ((i>=0)&&(i<height)){ + for (i=y-halfWidth;i<y+halfWidth;i++) { + if ((i>=0)&&(i<height)) { /* Bottom */ curColor[0]+=map[(x+i*width)*4+GlowR]*filter[fy]; curColor[1]+=map[(x+i*width)*4+GlowG]*filter[fy]; @@ -2457,11 +2457,11 @@ static void RVBlurBitmap2_float ( float* map, int width,int height, temp[((x+(height-1-y)*width)*4)+GlowB]=curColor2[2]; } /* Do the main body */ - for (y=halfWidth;y<height-halfWidth;y++){ + for (y=halfWidth;y<height-halfWidth;y++) { index=(x+y*width)*4; fy=0; curColor[0]=curColor[1]=curColor[2]=0; - for (i=y-halfWidth;i<y+halfWidth;i++){ + for (i=y-halfWidth;i<y+halfWidth;i++) { curColor[0]+=map[(x+i*width)*4+GlowR]*filter[fy]; curColor[1]+=map[(x+i*width)*4+GlowG]*filter[fy]; curColor[2]+=map[(x+i*width)*4+GlowB]*filter[fy]; @@ -2491,8 +2491,8 @@ static void RVAddBitmaps_byte (unsigned char* a, unsigned char* b, unsigned char { int x,y,index; - for (y=0;y<height;y++){ - for (x=0;x<width;x++){ + 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]); @@ -2507,8 +2507,8 @@ static void RVAddBitmaps_float (float* a, float* b, float* c, { int x,y,index; - for (y=0;y<height;y++){ - for (x=0;x<width;x++){ + for (y=0;y<height;y++) { + for (x=0;x<width;x++) { index=(x+y*width)*4; c[index+GlowR]= MIN2(1.0f, a[index+GlowR]+b[index+GlowR]); c[index+GlowG]= MIN2(1.0f, a[index+GlowG]+b[index+GlowG]); @@ -2534,7 +2534,7 @@ static void RVIsolateHighlights_byte (unsigned char* in, unsigned char* out, /* Isolate the intensity */ intensity=(in[index+GlowR]+in[index+GlowG]+in[index+GlowB]-threshold); - if (intensity>0){ + if (intensity>0) { out[index+GlowR]=MIN2(255*clamp, (in[index+GlowR]*boost*intensity)/255); out[index+GlowG]=MIN2(255*clamp, (in[index+GlowG]*boost*intensity)/255); out[index+GlowB]=MIN2(255*clamp, (in[index+GlowB]*boost*intensity)/255); @@ -2563,7 +2563,7 @@ static void RVIsolateHighlights_float (float* in, float* out, /* Isolate the intensity */ intensity=(in[index+GlowR]+in[index+GlowG]+in[index+GlowB]-threshold); - if (intensity>0){ + if (intensity>0) { out[index+GlowR]=MIN2(clamp, (in[index+GlowR]*boost*intensity)); out[index+GlowG]=MIN2(clamp, (in[index+GlowG]*boost*intensity)); out[index+GlowB]=MIN2(clamp, (in[index+GlowB]*boost*intensity)); diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 1c3cc44c585..92199eadf5b 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1140,6 +1140,18 @@ static int get_shown_sequences( ListBase * seqbasep, int cfra, int chanshown, Se proxy management ********************************************************************** */ +typedef struct SeqIndexBuildContext { + struct IndexBuildContext *index_context; + + int tc_flags; + int size_flags; + int quality; + + Main *bmain; + Scene *scene; + Sequence *seq, *orig_seq; +} SeqIndexBuildContext; + #define PROXY_MAXFILE (2*FILE_MAXDIR+FILE_MAXFILE) static IMB_Proxy_Size seq_rendersize_to_proxysize(int size) @@ -1345,35 +1357,56 @@ static void seq_proxy_build_frame(SeqRenderData context, IMB_freeImBuf(ibuf); } -void seq_proxy_rebuild(struct Main * bmain, Scene *scene, Sequence * seq, - short *stop, short *do_update, float *progress) +struct SeqIndexBuildContext *seq_proxy_rebuild_context(Main *bmain, Scene *scene, Sequence *seq) { - SeqRenderData context; - int cfra; - int tc_flags; - int size_flags; - int quality; + SeqIndexBuildContext *context; + Sequence *nseq; if (!seq->strip || !seq->strip->proxy) { - return; + return NULL; } if (!(seq->flag & SEQ_USE_PROXY)) { - return; + return NULL; } - tc_flags = seq->strip->proxy->build_tc_flags; - size_flags = seq->strip->proxy->build_size_flags; - quality = seq->strip->proxy->quality; + context = MEM_callocN(sizeof(SeqIndexBuildContext), "seq proxy rebuild context"); - if (seq->type == SEQ_MOVIE) { - seq_open_anim_file(seq); + nseq = seq_dupli_recursive(scene, scene, seq, 0); - if (seq->anim) { - IMB_anim_index_rebuild( - seq->anim, tc_flags, size_flags, quality, - stop, do_update, progress); + context->tc_flags = nseq->strip->proxy->build_tc_flags; + context->size_flags = nseq->strip->proxy->build_size_flags; + context->quality = nseq->strip->proxy->quality; + + context->bmain = bmain; + context->scene = scene; + context->orig_seq = seq; + context->seq = nseq; + + if (nseq->type == SEQ_MOVIE) { + seq_open_anim_file(nseq); + + if (nseq->anim) { + context->index_context = IMB_anim_index_rebuild_context(nseq->anim, + context->tc_flags, context->size_flags, context->quality); + } + } + + return context; +} + +void seq_proxy_rebuild(SeqIndexBuildContext *context, short *stop, short *do_update, float *progress) +{ + SeqRenderData render_context; + Sequence *seq = context->seq; + Scene *scene = context->scene; + int cfra; + + if (seq->type == SEQ_MOVIE) { + if (context->index_context) { + IMB_anim_index_rebuild(context->index_context, stop, do_update, progress); } + return; } @@ -1388,25 +1421,25 @@ void seq_proxy_rebuild(struct Main * bmain, Scene *scene, Sequence * seq, /* fail safe code */ - context = seq_new_render_data( - bmain, scene, + render_context = seq_new_render_data( + context->bmain, context->scene, (scene->r.size * (float) scene->r.xsch) / 100.0f + 0.5f, (scene->r.size * (float) scene->r.ysch) / 100.0f + 0.5f, 100); for (cfra = seq->startdisp + seq->startstill; cfra < seq->enddisp - seq->endstill; cfra++) { - if (size_flags & IMB_PROXY_25) { - seq_proxy_build_frame(context, seq, cfra, 25); + if (context->size_flags & IMB_PROXY_25) { + seq_proxy_build_frame(render_context, seq, cfra, 25); } - if (size_flags & IMB_PROXY_50) { - seq_proxy_build_frame(context, seq, cfra, 50); + if (context->size_flags & IMB_PROXY_50) { + seq_proxy_build_frame(render_context, seq, cfra, 50); } - if (size_flags & IMB_PROXY_75) { - seq_proxy_build_frame(context, seq, cfra, 75); + if (context->size_flags & IMB_PROXY_75) { + seq_proxy_build_frame(render_context, seq, cfra, 75); } - if (size_flags & IMB_PROXY_100) { - seq_proxy_build_frame(context, seq, cfra, 100); + if (context->size_flags & IMB_PROXY_100) { + seq_proxy_build_frame(render_context, seq, cfra, 100); } *progress= (float)cfra/(seq->enddisp - seq->endstill @@ -1418,6 +1451,18 @@ void seq_proxy_rebuild(struct Main * bmain, Scene *scene, Sequence * seq, } } +void seq_proxy_rebuild_finish(SeqIndexBuildContext *context, short stop) +{ + if (context->index_context) { + IMB_close_anim_proxies(context->seq->anim); + IMB_close_anim_proxies(context->orig_seq->anim); + IMB_anim_index_rebuild_finish(context->index_context, stop); + } + + seq_free_sequence_recurse(context->scene, context->seq); + + MEM_freeN(context); +} /* ********************************************************************** color balance diff --git a/source/blender/blenkernel/intern/sketch.c b/source/blender/blenkernel/intern/sketch.c index faf382f9ffc..7134f5ac8c1 100644 --- a/source/blender/blenkernel/intern/sketch.c +++ b/source/blender/blenkernel/intern/sketch.c @@ -71,17 +71,15 @@ SK_Sketch* createSketch(void) return sketch; } -void sk_initPoint(SK_Point *pt, SK_DrawData *dd, float *no) +void sk_initPoint(SK_Point *pt, SK_DrawData *dd, const float no[3]) { - if (no) - { + if (no) { normalize_v3_v3(pt->no, no); } - else - { - pt->no[0] = 0; - pt->no[1] = 0; - pt->no[2] = 1; + else { + pt->no[0] = 0.0f; + pt->no[1] = 0.0f; + pt->no[2] = 1.0f; } pt->p2d[0] = dd->mval[0]; pt->p2d[1] = dd->mval[1]; diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index e48a17ac274..063a274715c 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -113,7 +113,7 @@ typedef struct ReferenceVert { typedef struct ReferenceState { float com[3]; /* center of mass*/ ReferenceVert *ivert; /* list of intial values */ -}ReferenceState ; +}ReferenceState; /*private scratch pad for caching and other data only needed when alive*/ @@ -196,7 +196,7 @@ static float sb_time_scale(Object *ob) /* defining the frames to *real* time relation */ { SoftBody *sb= ob->soft; /* is supposed to be there */ - if (sb){ + if (sb) { return(sb->physics_speed); /*hrms .. this could be IPO as well :) estimated range [0.001 sluggish slug - 100.0 very fast (i hope ODE solver can handle that)] @@ -226,10 +226,10 @@ static float sb_time_scale(Object *ob) static float _final_goal(Object *ob,BodyPoint *bp)/*jow_go_for2_5 */ { float f = -1999.99f; - if (ob){ + if (ob) { SoftBody *sb= ob->soft; /* is supposed to be there */ if (!(ob->softflag & OB_SB_GOAL)) return (0.0f); - if (sb&&bp){ + if (sb&&bp) { if (bp->goal < 0.0f) return (0.0f); f = sb->mingoal + bp->goal*ABS(sb->maxgoal - sb->mingoal); f = pow(f, 4.0f); @@ -242,9 +242,9 @@ static float _final_goal(Object *ob,BodyPoint *bp)/*jow_go_for2_5 */ static float _final_mass(Object *ob,BodyPoint *bp) { - if (ob){ + if (ob) { SoftBody *sb= ob->soft; /* is supposed to be there */ - if (sb&&bp){ + if (sb&&bp) { return(bp->mass*sb->nodemass); } } @@ -319,7 +319,7 @@ static ccd_Mesh *ccd_mesh_make(Object *ob) pccd_M->mvert = MEM_dupallocN(cmd->xnew); /* note that xnew coords are already in global space, */ /* determine the ortho BB */ - for (i=0; i < pccd_M->totvert; i++){ + 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); @@ -341,7 +341,7 @@ static ccd_Mesh *ccd_mesh_make(Object *ob) /* anyhoo we need to walk the list of faces and find OBB they live in */ - for (i=0; i < pccd_M->totface; i++){ + for (i=0; i < pccd_M->totface; i++) { mima->minx=mima->miny=mima->minz=1e30f; mima->maxx=mima->maxy=mima->maxz=-1e30f; @@ -369,7 +369,7 @@ static ccd_Mesh *ccd_mesh_make(Object *ob) mima->maxy = MAX2(mima->maxy,v[1]+hull); mima->maxz = MAX2(mima->maxz,v[2]+hull); - if (mface->v4){ + 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); @@ -397,8 +397,8 @@ static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M) cmd =(CollisionModifierData *)modifiers_findByType(ob, eModifierType_Collision); /* first some paranoia checks */ - if (!cmd) return ; - if (!cmd->numverts || !cmd->numfaces) return ; + if (!cmd) return; + if (!cmd->numverts || !cmd->numfaces) return; if ((pccd_M->totvert != cmd->numverts) || (pccd_M->totface != cmd->numfaces)) return; @@ -417,7 +417,7 @@ static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M) pccd_M->mvert = MEM_dupallocN(cmd->xnew); /* note that xnew coords are already in global space, */ /* determine the ortho BB */ - for (i=0; i < pccd_M->totvert; i++){ + 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); @@ -445,7 +445,7 @@ static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M) /* anyhoo we need to walk the list of faces and find OBB they live in */ - for (i=0; i < pccd_M->totface; i++){ + for (i=0; i < pccd_M->totface; i++) { mima->minx=mima->miny=mima->minz=1e30f; mima->maxx=mima->maxy=mima->maxz=-1e30f; @@ -473,7 +473,7 @@ static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M) mima->maxy = MAX2(mima->maxy,v[1]+hull); mima->maxz = MAX2(mima->maxz,v[2]+hull); - if (mface->v4){ + 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); @@ -508,7 +508,7 @@ static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M) mima->maxy = MAX2(mima->maxy,v[1]+hull); mima->maxz = MAX2(mima->maxz,v[2]+hull); - if (mface->v4){ + 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); @@ -523,12 +523,12 @@ static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M) mface++; } - return ; + return; } static void ccd_mesh_free(ccd_Mesh *ccdm) { - if (ccdm && (ccdm->savety == CCD_SAVETY )){ /*make sure we're not nuking objects we don't know*/ + if (ccdm && (ccdm->savety == CCD_SAVETY )) { /*make sure we're not nuking objects we don't know*/ MEM_freeN(ccdm->mface); MEM_freeN(ccdm->mvert); if (ccdm->mprevvert) MEM_freeN(ccdm->mprevvert); @@ -575,7 +575,7 @@ static void ccd_update_deflector_hash(Scene *scene, Object *vertexowner, GHash * /*Only proceed for mesh object in same layer */ if (base->object->type==OB_MESH && (base->lay & vertexowner->lay)) { ob= base->object; - if (ob == vertexowner){ + if (ob == vertexowner) { /* if vertexowner is given we don't want to check collision with owner object */ base = base->next; continue; @@ -618,9 +618,9 @@ static void add_mesh_quad_diag_springs(Object *ob) MFace *mface= me->mface; /*BodyPoint *bp;*/ /*UNUSED*/ BodySpring *bs, *bs_new; - int a ; + int a; - if (ob->soft){ + if (ob->soft) { int nofquads; //float s_shear = ob->soft->shearstiff*ob->soft->shearstiff; @@ -667,7 +667,7 @@ static void add_2nd_order_roller(Object *ob,float UNUSED(stiffness), int *counte 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 :) */ + if (!sb->bspring) {return;} /* we are 2nd order here so 1rst should have been build :) */ /* first run counting second run adding */ *counter = 0; if (addsprings) bs3 = ob->soft->bspring+ob->soft->totspring; @@ -675,36 +675,36 @@ static void add_2nd_order_roller(Object *ob,float UNUSED(stiffness), int *counte /*scan for neighborhood*/ bpo = NULL; v0 = (sb->totpoint-a); - for (b=bp->nofsprings;b>0;b--){ + for (b=bp->nofsprings;b>0;b--) { bs = sb->bspring + bp->springs[b-1]; /*nasty thing here that springs have two ends so here we have to make sure we examine the other */ - if (v0 == bs->v1){ + if (v0 == bs->v1) { bpo = sb->bpoint+bs->v2; notthis = bs->v2; } else { - if (v0 == bs->v2){ + if (v0 == bs->v2) { bpo = sb->bpoint+bs->v1; notthis = bs->v1; } else {printf("oops we should not get here - add_2nd_order_springs");} } - if (bpo){/* so now we have a 2nd order humpdidump */ - for (c=bpo->nofsprings;c>0;c--){ + if (bpo) {/* so now we have a 2nd order humpdidump */ + for (c=bpo->nofsprings;c>0;c--) { bs2 = sb->bspring + bpo->springs[c-1]; - if ((bs2->v1 != notthis) && (bs2->v1 > v0)){ + if ((bs2->v1 != notthis) && (bs2->v1 > v0)) { (*counter)++;/*hit */ - if (addsprings){ + if (addsprings) { bs3->v1= v0; bs3->v2= bs2->v1; bs3->springtype = SB_BEND; bs3++; } } - if ((bs2->v2 !=notthis)&&(bs2->v2 > v0)){ + if ((bs2->v2 !=notthis)&&(bs2->v2 > v0)) { (*counter)++;/*hit */ - if (addsprings){ + if (addsprings) { bs3->v1= v0; bs3->v2= bs2->v2; bs3->springtype = SB_BEND; @@ -739,7 +739,7 @@ static void add_2nd_order_springs(Object *ob,float stiffness) ob->soft->bspring = bs_new; add_2nd_order_roller(ob,stiffness,&counter,1); /* adding */ - ob->soft->totspring +=counter ; + ob->soft->totspring += counter; } } @@ -782,10 +782,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) ){ + if (( (sb->totpoint-a) == bs->v1) ) { add_bp_springlist(bp,sb->totspring -b); } - if (( (sb->totpoint-a) == bs->v2) ){ + if (( (sb->totpoint-a) == bs->v2) ) { add_bp_springlist(bp,sb->totspring -b); } }/*for springs*/ @@ -809,9 +809,9 @@ static void calculate_collision_balls(Object *ob) min = 1e22f; max = -1e22f; /* first estimation based on attached */ - for (b=bp->nofsprings;b>0;b--){ + for (b=bp->nofsprings;b>0;b--) { bs = sb->bspring + bp->springs[b-1]; - if (bs->springtype == SB_EDGE){ + if (bs->springtype == SB_EDGE) { akku += bs->len; akku_count++, min = MIN2(bs->len,min); @@ -820,19 +820,19 @@ static void calculate_collision_balls(Object *ob) } if (akku_count > 0) { - if (sb->sbc_mode == SBC_MODE_MANUAL){ + if (sb->sbc_mode == SBC_MODE_MANUAL) { bp->colball=sb->colball; } - if (sb->sbc_mode == SBC_MODE_AVG){ + if (sb->sbc_mode == SBC_MODE_AVG) { bp->colball = akku/(float)akku_count*sb->colball; } - if (sb->sbc_mode == SBC_MODE_MIN){ + if (sb->sbc_mode == SBC_MODE_MIN) { bp->colball=min*sb->colball; } - if (sb->sbc_mode == SBC_MODE_MAX){ + if (sb->sbc_mode == SBC_MODE_MAX) { bp->colball=max*sb->colball; } - if (sb->sbc_mode == SBC_MODE_AVGMINMAX){ + if (sb->sbc_mode == SBC_MODE_AVGMINMAX) { bp->colball = (min + max)/2.0f*sb->colball; } } @@ -905,17 +905,17 @@ static void free_softbody_baked(SoftBody *sb) } static void free_scratch(SoftBody *sb) { - if (sb->scratch){ + if (sb->scratch) { /* todo make sure everything is cleaned up nicly */ - if (sb->scratch->colliderhash){ + if (sb->scratch->colliderhash) { BLI_ghash_free(sb->scratch->colliderhash, NULL, (GHashValFreeFP) ccd_mesh_free); /*this hoepfully will free all caches*/ sb->scratch->colliderhash = NULL; } - if (sb->scratch->bodyface){ + if (sb->scratch->bodyface) { MEM_freeN(sb->scratch->bodyface); } - if (sb->scratch->Ref.ivert){ + if (sb->scratch->Ref.ivert) { MEM_freeN(sb->scratch->Ref.ivert); } MEM_freeN(sb->scratch); @@ -931,7 +931,7 @@ static void free_softbody_intern(SoftBody *sb) int a; BodyPoint *bp; - if (sb->bpoint){ + if (sb->bpoint) { for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) { /* free spring list */ if (bp->springs != NULL) { @@ -1041,7 +1041,7 @@ static int sb_detect_aabb_collisionCached( float UNUSED(force[3]), unsigned int MVert *mprevvert= NULL; ccdf_minmax *mima= NULL; #endif - if (ccdm){ + if (ccdm) { #if 0 /* UNUSED */ mface= ccdm->mface; mvert= ccdm->mvert; @@ -1115,7 +1115,7 @@ static int sb_detect_face_pointCached(float face_v1[3],float face_v2[3],float fa if (ob->pd && ob->pd->deflect) { MVert *mvert= NULL; MVert *mprevvert= NULL; - if (ccdm){ + if (ccdm) { mvert= ccdm->mvert; a = ccdm->totvert; mprevvert= ccdm->mprevvert; @@ -1142,19 +1142,19 @@ static int sb_detect_face_pointCached(float face_v1[3],float face_v2[3],float fa /* use mesh*/ if (mvert) { - while(a){ + while(a) { copy_v3_v3(nv1,mvert[a-1].co); - if (mprevvert){ + if (mprevvert) { 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); - if (ABS(facedist)<outerfacethickness){ - if (isect_point_tri_prism_v3(nv1, face_v1,face_v2,face_v3) ){ + if (ABS(facedist)<outerfacethickness) { + if (isect_point_tri_prism_v3(nv1, face_v1,face_v2,face_v3) ) { float df; - if (facedist > 0){ + if (facedist > 0) { df = (outerfacethickness-facedist)/outerfacethickness; } else { @@ -1208,7 +1208,7 @@ static int sb_detect_face_collisionCached(float face_v1[3],float face_v2[3],floa MVert *mvert= NULL; MVert *mprevvert= NULL; ccdf_minmax *mima= NULL; - if (ccdm){ + if (ccdm) { mface= ccdm->mface; mvert= ccdm->mvert; mprevvert= ccdm->mprevvert; @@ -1251,15 +1251,15 @@ static int sb_detect_face_collisionCached(float face_v1[3],float face_v2[3],floa } - if (mvert){ + 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); - if (mface->v4){ + if (mface->v4) { copy_v3_v3(nv4,mvert[mface->v4].co); } - if (mprevvert){ + if (mprevvert) { mul_v3_fl(nv1,time); Vec3PlusStVec(nv1,(1.0f-time),mprevvert[mface->v1].co); @@ -1269,7 +1269,7 @@ static int sb_detect_face_collisionCached(float face_v1[3],float face_v2[3],floa mul_v3_fl(nv3,time); Vec3PlusStVec(nv3,(1.0f-time),mprevvert[mface->v3].co); - if (mface->v4){ + if (mface->v4) { mul_v3_fl(nv4,time); Vec3PlusStVec(nv4,(1.0f-time),mprevvert[mface->v4].co); } @@ -1284,12 +1284,12 @@ static int sb_detect_face_collisionCached(float face_v1[3],float face_v2[3],floa if ( 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) ){ + isect_line_tri_v3(nv3, nv1, face_v1, face_v2, face_v3, &t, NULL) ) { Vec3PlusStVec(force,-0.5f,d_nvect); *damp=tune*ob->pd->pdef_sbdamp; deflected = 2; } - if (mface->v4){ /* quad */ + if (mface->v4) { /* quad */ /* switch origin to be nv4 */ sub_v3_v3v3(edge1, nv3, nv4); sub_v3_v3v3(edge2, nv1, nv4); @@ -1299,7 +1299,7 @@ static int sb_detect_face_collisionCached(float face_v1[3],float face_v2[3],floa /* isect_line_tri_v3(nv1, nv3, face_v1, face_v2, face_v3, &t, NULL) || 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) ){ + isect_line_tri_v3(nv4, nv1, face_v1, face_v2, face_v3, &t, NULL) ) { Vec3PlusStVec(force,-0.5f,d_nvect); *damp=tune*ob->pd->pdef_sbdamp; deflected = 2; @@ -1326,7 +1326,7 @@ static void scan_for_ext_face_forces(Object *ob,float timenow) float tune = -10.0f; float feedback[3]; - if (sb && sb->scratch->totface){ + if (sb && sb->scratch->totface) { bf = sb->scratch->bodyface; @@ -1336,7 +1336,7 @@ static void scan_for_ext_face_forces(Object *ob,float timenow) 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)){ + &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); @@ -1347,7 +1347,7 @@ static void scan_for_ext_face_forces(Object *ob,float timenow) 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))){ + &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); @@ -1358,12 +1358,12 @@ static void scan_for_ext_face_forces(Object *ob,float timenow) /*---edges intruding*/ /*+++ close vertices*/ - if (( bf->flag & BFF_INTERSECT)==0){ + if (( bf->flag & BFF_INTERSECT)==0) { 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)){ + &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); @@ -1374,7 +1374,7 @@ static void scan_for_ext_face_forces(Object *ob,float timenow) 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))){ + &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); @@ -1392,7 +1392,7 @@ static void scan_for_ext_face_forces(Object *ob,float timenow) 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){ + if (bf->v4) { sb->bpoint[bf->v2].choke2=MAX2(sb->bpoint[bf->v2].choke2,choke); } } @@ -1436,7 +1436,7 @@ static int sb_detect_edge_collisionCached(float edge_v1[3],float edge_v2[3],floa MVert *mvert= NULL; MVert *mprevvert= NULL; ccdf_minmax *mima= NULL; - if (ccdm){ + if (ccdm) { mface= ccdm->mface; mvert= ccdm->mvert; mprevvert= ccdm->mprevvert; @@ -1479,15 +1479,15 @@ static int sb_detect_edge_collisionCached(float edge_v1[3],float edge_v2[3],floa } - if (mvert){ + 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); - if (mface->v4){ + if (mface->v4) { copy_v3_v3(nv4,mvert[mface->v4].co); } - if (mprevvert){ + if (mprevvert) { mul_v3_fl(nv1,time); Vec3PlusStVec(nv1,(1.0f-time),mprevvert[mface->v1].co); @@ -1497,7 +1497,7 @@ static int sb_detect_edge_collisionCached(float edge_v1[3],float edge_v2[3],floa mul_v3_fl(nv3,time); Vec3PlusStVec(nv3,(1.0f-time),mprevvert[mface->v3].co); - if (mface->v4){ + if (mface->v4) { mul_v3_fl(nv4,time); Vec3PlusStVec(nv4,(1.0f-time),mprevvert[mface->v4].co); } @@ -1510,7 +1510,7 @@ 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)){ + if ( isect_line_tri_v3(edge_v1, edge_v2, nv1, nv2, nv3, &t, NULL)) { float v1[3],v2[3]; float intrusiondepth,i1,i2; sub_v3_v3v3(v1, edge_v1, nv2); @@ -1522,14 +1522,14 @@ static int sb_detect_edge_collisionCached(float edge_v1[3],float edge_v2[3],floa *damp=ob->pd->pdef_sbdamp; deflected = 2; } - if (mface->v4){ /* quad */ + if (mface->v4) { /* quad */ /* switch origin to be nv4 */ sub_v3_v3v3(edge1, nv3, nv4); sub_v3_v3v3(edge2, nv1, nv4); 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)){ + 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); @@ -1561,18 +1561,18 @@ static void _scan_for_ext_spring_forces(Scene *scene, Object *ob, float timenow, float damp; float feedback[3]; - if (sb && sb->totspring){ + if (sb && sb->totspring) { for (a=ifirst; a<ilast; a++) { BodySpring *bs = &sb->bspring[a]; bs->ext_force[0]=bs->ext_force[1]=bs->ext_force[2]=0.0f; feedback[0]=feedback[1]=feedback[2]=0.0f; bs->flag &= ~BSF_INTERSECT; - if (bs->springtype == SB_EDGE){ + if (bs->springtype == SB_EDGE) { /* +++ springs colliding */ - if (ob->softflag & OB_SB_EDGECOLL){ + 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)){ + &damp,feedback,ob->lay,ob,timenow)) { add_v3_v3(bs->ext_force, feedback); bs->flag |= BSF_INTERSECT; //bs->cf=damp; @@ -1584,7 +1584,7 @@ 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){ + if (sb->aeroedge) { float vel[3],sp[3],pr[3],force[3]; float f,windfactor = 0.25f; /*see if we have wind*/ @@ -1613,7 +1613,7 @@ static void _scan_for_ext_spring_forces(Scene *scene, Object *ob, float timenow, project_v3_v3v3(pr,vel,sp); sub_v3_v3(vel, pr); normalize_v3(vel); - if (ob->softflag & OB_SB_AERO_ANGLE){ + if (ob->softflag & OB_SB_AERO_ANGLE) { normalize_v3(sp); Vec3PlusStVec(bs->ext_force,f*(1.0f-ABS(dot_v3v3(vel,sp))),vel); } @@ -1676,7 +1676,7 @@ static void sb_sfesf_threads_run(Scene *scene, struct Object *ob, float timenow, sb_threads[i].timenow = timenow; sb_threads[i].ilast = left; left = left - dec; - if (left >0){ + if (left >0) { sb_threads[i].ifirst = left; } else @@ -1714,17 +1714,17 @@ static int choose_winner(float*w, float* pos,float*a,float*b,float*c,float*ca,fl mindist = ABS(dot_v3v3(pos,a)); cp = ABS(dot_v3v3(pos,b)); - if ( mindist < cp ){ + if ( mindist < cp ) { mindist = cp; winner =2; } cp = ABS(dot_v3v3(pos,c)); - if (mindist < cp ){ + if (mindist < cp ) { mindist = cp; winner =3; } - switch (winner){ + 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); @@ -1766,7 +1766,7 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], MVert *mprevvert= NULL; ccdf_minmax *mima= NULL; - if (ccdm){ + if (ccdm) { mface= ccdm->mface; mvert= ccdm->mvert; mprevvert= ccdm->mprevvert; @@ -1822,16 +1822,16 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], continue; } - if (mvert){ + 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); - if (mface->v4){ + if (mface->v4) { copy_v3_v3(nv4,mvert[mface->v4].co); } - if (mprevvert){ + if (mprevvert) { /* grab the average speed of the collider vertices before we spoil nvX humm could be done once a SB steps but then we' need to store that too @@ -1841,7 +1841,7 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], 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){ + if (mface->v4) { sub_v3_v3v3(vv4,nv4,mprevvert[mface->v4].co); } @@ -1854,7 +1854,7 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], mul_v3_fl(nv3,time); Vec3PlusStVec(nv3,(1.0f-time),mprevvert[mface->v3].co); - if (mface->v4){ + if (mface->v4) { mul_v3_fl(nv4,time); Vec3PlusStVec(nv4,(1.0f-time),mprevvert[mface->v4].co); } @@ -1872,13 +1872,13 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], // so rules are // - if ((facedist > innerfacethickness) && (facedist < outerfacethickness)){ - if (isect_point_tri_prism_v3(opco, nv1, nv2, nv3) ){ + if ((facedist > innerfacethickness) && (facedist < outerfacethickness)) { + if (isect_point_tri_prism_v3(opco, nv1, nv2, nv3) ) { force_mag_norm =(float)exp(-ee*facedist); if (facedist > outerfacethickness*ff) force_mag_norm =(float)force_mag_norm*fa*(facedist - outerfacethickness)*(facedist - outerfacethickness); *damp=ob->pd->pdef_sbdamp; - if (facedist > 0.0f){ + if (facedist > 0.0f) { *damp *= (1.0f - facedist/outerfacethickness); Vec3PlusStVec(outerforceaccu,force_mag_norm,d_nvect); deflected = 3; @@ -1888,7 +1888,7 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], Vec3PlusStVec(innerforceaccu,force_mag_norm,d_nvect); if (deflected < 2) deflected = 2; } - if ((mprevvert) && (*damp > 0.0f)){ + if ((mprevvert) && (*damp > 0.0f)) { choose_winner(ve,opco,nv1,nv2,nv3,vv1,vv2,vv3); add_v3_v3(avel, ve); cavel ++; @@ -1897,7 +1897,7 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], ci++; } } - if (mface->v4){ /* quad */ + if (mface->v4) { /* quad */ /* switch origin to be nv4 */ sub_v3_v3v3(edge1, nv3, nv4); sub_v3_v3v3(edge2, nv1, nv4); @@ -1907,13 +1907,13 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], /* n_mag = */ /* UNUSED */ normalize_v3(d_nvect); facedist = dot_v3v3(dv1,d_nvect); - if ((facedist > innerfacethickness) && (facedist < outerfacethickness)){ - if (isect_point_tri_prism_v3(opco, nv1, nv3, nv4) ){ + if ((facedist > innerfacethickness) && (facedist < outerfacethickness)) { + if (isect_point_tri_prism_v3(opco, nv1, nv3, nv4) ) { force_mag_norm =(float)exp(-ee*facedist); if (facedist > outerfacethickness*ff) force_mag_norm =(float)force_mag_norm*fa*(facedist - outerfacethickness)*(facedist - outerfacethickness); *damp=ob->pd->pdef_sbdamp; - if (facedist > 0.0f){ + if (facedist > 0.0f) { *damp *= (1.0f - facedist/outerfacethickness); Vec3PlusStVec(outerforceaccu,force_mag_norm,d_nvect); deflected = 3; @@ -1924,7 +1924,7 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], if (deflected < 2) deflected = 2; } - if ((mprevvert) && (*damp > 0.0f)){ + if ((mprevvert) && (*damp > 0.0f)) { choose_winner(ve,opco,nv1,nv3,nv4,vv1,vv3,vv4); add_v3_v3(avel, ve); cavel ++; @@ -1941,7 +1941,7 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], closest_to_line_segment_v3(ve, opco, nv1, nv2); sub_v3_v3v3(ve,opco,ve); dist = normalize_v3(ve); - if ((dist < outerfacethickness)&&(dist < mindistedge )){ + if ((dist < outerfacethickness)&&(dist < mindistedge )) { copy_v3_v3(coledge,ve); mindistedge = dist, deflected=1; @@ -1950,7 +1950,7 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], closest_to_line_segment_v3(ve, opco, nv2, nv3); sub_v3_v3v3(ve,opco,ve); dist = normalize_v3(ve); - if ((dist < outerfacethickness)&&(dist < mindistedge )){ + if ((dist < outerfacethickness)&&(dist < mindistedge )) { copy_v3_v3(coledge,ve); mindistedge = dist, deflected=1; @@ -1959,16 +1959,16 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], closest_to_line_segment_v3(ve, opco, nv3, nv1); sub_v3_v3v3(ve,opco,ve); dist = normalize_v3(ve); - if ((dist < outerfacethickness)&&(dist < mindistedge )){ + if ((dist < outerfacethickness)&&(dist < mindistedge )) { copy_v3_v3(coledge,ve); mindistedge = dist, deflected=1; } - if (mface->v4){ /* quad */ + if (mface->v4) { /* quad */ closest_to_line_segment_v3(ve, opco, nv3, nv4); sub_v3_v3v3(ve,opco,ve); dist = normalize_v3(ve); - if ((dist < outerfacethickness)&&(dist < mindistedge )){ + if ((dist < outerfacethickness)&&(dist < mindistedge )) { copy_v3_v3(coledge,ve); mindistedge = dist, deflected=1; @@ -1977,7 +1977,7 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], closest_to_line_segment_v3(ve, opco, nv1, nv4); sub_v3_v3v3(ve,opco,ve); dist = normalize_v3(ve); - if ((dist < outerfacethickness)&&(dist < mindistedge )){ + if ((dist < outerfacethickness)&&(dist < mindistedge )) { copy_v3_v3(coledge,ve); mindistedge = dist, deflected=1; @@ -1995,21 +1995,21 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], BLI_ghashIterator_step(ihash); } /* while () */ - if (deflected == 1){ // no face but 'outer' edge cylinder sees vert + if (deflected == 1) { // no face but 'outer' edge cylinder sees vert 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); *damp=ob->pd->pdef_sbdamp; - if (mindistedge > 0.0f){ + if (mindistedge > 0.0f) { *damp *= (1.0f - mindistedge/outerfacethickness); } } - if (deflected == 2){ // face inner detected + if (deflected == 2) { // face inner detected add_v3_v3(force, innerforceaccu); } - if (deflected == 3){ // face outer detected + if (deflected == 3) { // face outer detected add_v3_v3(force, outerforceaccu); } @@ -2017,7 +2017,7 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], if (cavel) mul_v3_fl(avel,1.0f/(float)cavel); copy_v3_v3(vel,avel); if (ci) *intrusion /= ci; - if (deflected){ + if (deflected) { normalize_v3_v3(facenormal, force); } return deflected; @@ -2040,9 +2040,9 @@ static void dfdx_spring(int ia, int ic, int op, float dir[3],float L,float len,f { float m,delta_ij; int i ,j; - if (L < len){ + if (L < len) { for (i=0;i<3;i++) - for (j=0;j<3;j++){ + 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); @@ -2050,7 +2050,7 @@ static void dfdx_spring(int ia, int ic, int op, float dir[3],float L,float len,f } else{ for (i=0;i<3;i++) - for (j=0;j<3;j++){ + for (j=0;j<3;j++) { m=factor*dir[i]*dir[j]; nlMatrixAdd(ia+i,op+ic+j,m); } @@ -2081,7 +2081,7 @@ static void sb_spring_force(Object *ob,int bpi,BodySpring *bs,float iks,float UN int ia,ic; #endif /* prepare depending on which side of the spring we are on */ - if (bpi == bs->v1){ + if (bpi == bs->v1) { bp1 = &sb->bpoint[bs->v1]; bp2 = &sb->bpoint[bs->v2]; #if 0 /* UNUSED */ @@ -2089,7 +2089,7 @@ static void sb_spring_force(Object *ob,int bpi,BodySpring *bs,float iks,float UN ic =3*bs->v2; #endif } - else if (bpi == bs->v2){ + else if (bpi == bs->v2) { bp1 = &sb->bpoint[bs->v2]; bp2 = &sb->bpoint[bs->v1]; #if 0 /* UNUSED */ @@ -2119,7 +2119,7 @@ static void sb_spring_force(Object *ob,int bpi,BodySpring *bs,float iks,float UN kw = (bp1->springweight+bp2->springweight)/2.0f; kw = kw * kw; kw = kw * kw; - switch (bs->springtype){ + switch (bs->springtype) { case SB_EDGE: case SB_HANDLE: forcefactor *= kw; @@ -2146,7 +2146,7 @@ static void sb_spring_force(Object *ob,int bpi,BodySpring *bs,float iks,float UN Vec3PlusStVec(bp1->force,-kd,dir); /* do jacobian stuff if needed */ - if (nl_flags & NLF_BUILD){ + if (nl_flags & NLF_BUILD) { //int op =3*sb->totpoint; //float mvel = -forcetime*kd; //float mpos = -forcetime*forcefactor; @@ -2154,7 +2154,7 @@ static void sb_spring_force(Object *ob,int bpi,BodySpring *bs,float iks,float UN // dfdx_spring(ia,ia,op,dir,bs->len,distance,-mpos); /* depending on my vel */ // dfdv_goal(ia,ia,mvel); // well that ignores geometie - if (bp2->goal < SOFTGOALSNAP){ /* ommit this bp when it snaps */ + if (bp2->goal < SOFTGOALSNAP) { /* ommit this bp when it snaps */ /* depending on other pos */ // dfdx_spring(ia,ic,op,dir,bs->len,distance,mpos); /* depending on other vel */ @@ -2203,7 +2203,7 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo bp->force[0]= bp->force[1]= bp->force[2]= 0.0; /* naive ball self collision */ /* needs to be done if goal snaps or not */ - if (do_selfcollision){ + if (do_selfcollision) { int attached; BodyPoint *obp; BodySpring *bs; @@ -2220,17 +2220,17 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo /* mathematically it is completly nuts, but performace is pretty much (3) times faster */ if ((ABS(def[0]) > compare) || (ABS(def[1]) > compare) || (ABS(def[2]) > compare)) continue; distance = normalize_v3(def); - if (distance < compare ){ + if (distance < compare ) { /* exclude body points attached with a spring */ attached = 0; - for (b=obp->nofsprings;b>0;b--){ + for (b=obp->nofsprings;b>0;b--) { bs = sb->bspring + obp->springs[b-1]; - if (( ilast-bb == bs->v2) || ( ilast-bb == bs->v1)){ + if (( ilast-bb == bs->v2) || ( ilast-bb == bs->v1)) { attached=1; continue;} } - if (!attached){ - float f = bstune/(distance) + bstune/(compare*compare)*distance - 2.0f*bstune/compare ; + if (!attached) { + 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); @@ -2251,7 +2251,7 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo } /* 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]; @@ -2260,14 +2260,14 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo /* true elastic goal */ float ks,kd; sub_v3_v3v3(auxvect,bp->pos,bp->origT); - ks = 1.0f/(1.0f- _final_goal(ob,bp)*sb->goalspring)-1.0f ; + 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); - kd = sb->goalfrict * sb_fric_force_scale(ob) ; + kd = sb->goalfrict * sb_fric_force_scale(ob); add_v3_v3v3(auxvect,velgoal,bp->vec); if (forcetime > 0.0f) { /* make sure friction does not become rocket motor on time reversal */ @@ -2284,7 +2284,7 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo /* done goal stuff */ /* gravitation */ - if (sb && scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY){ + 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 */ @@ -2330,8 +2330,8 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo 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 (intrusion < 0.0f){ + 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; @@ -2349,12 +2349,12 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo /* +++springs */ iks = 1.0f/(1.0f-sb->inspring)-1.0f ;/* inner spring constants function */ if (ob->softflag & OB_SB_EDGES) { - if (sb->bspring){ /* spring list exists at all ? */ + if (sb->bspring) { /* spring list exists at all ? */ int b; BodySpring *bs; - for (b=bp->nofsprings;b>0;b--){ + for (b=bp->nofsprings;b>0;b--) { bs = sb->bspring + bp->springs[b-1]; - if (do_springcollision || do_aero){ + if (do_springcollision || do_aero) { add_v3_v3(bp->force, bs->ext_force); if (bs->flag & BSF_INTERSECT) bp->choke = bs->cf; @@ -2408,7 +2408,7 @@ static void sb_cf_threads_run(Scene *scene, Object *ob, float forcetime, float t sb_threads[i].timenow = timenow; sb_threads[i].ilast = left; left = left - dec; - if (left >0){ + if (left >0) { sb_threads[i].ifirst = left; } else @@ -2486,7 +2486,7 @@ static void softbody_calc_forcesEx(Scene *scene, Object *ob, float forcetime, fl static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, float timenow, int nl_flags) { /* redirection to the new threaded Version */ - if (!(G.rt & 0x10)){ // 16 + if (!(G.rt & 0x10)) { // 16 softbody_calc_forcesEx(scene, ob, forcetime, timenow, nl_flags); return; } @@ -2516,14 +2516,14 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa /* jacobian NLboolean success; - if (nl_flags){ + if (nl_flags) { nlBegin(NL_SYSTEM); nlBegin(NL_MATRIX); } */ - if (scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY){ + if (scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) { copy_v3_v3(gravity, scene->physics_settings.gravity); mul_v3_fl(gravity, sb_grav_force_scale(ob)*sb->effector_weights->global_gravity); } @@ -2549,7 +2549,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) { /* clear forces accumulator */ bp->force[0]= bp->force[1]= bp->force[2]= 0.0; - if (nl_flags & NLF_BUILD){ + if (nl_flags & NLF_BUILD) { //int ia =3*(sb->totpoint-a); //int op =3*sb->totpoint; /* dF/dV = v */ @@ -2572,7 +2572,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa /* naive ball self collision */ /* needs to be done if goal snaps or not */ - if (do_selfcollision){ + if (do_selfcollision) { int attached; BodyPoint *obp; int c,b; @@ -2592,17 +2592,17 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa if ((ABS(def[0]) > compare) || (ABS(def[1]) > compare) || (ABS(def[2]) > compare)) continue; distance = normalize_v3(def); - if (distance < compare ){ + if (distance < compare ) { /* exclude body points attached with a spring */ attached = 0; - for (b=obp->nofsprings;b>0;b--){ + for (b=obp->nofsprings;b>0;b--) { bs = sb->bspring + obp->springs[b-1]; - if (( sb->totpoint-a == bs->v2) || ( sb->totpoint-a == bs->v1)){ + if (( sb->totpoint-a == bs->v2) || ( sb->totpoint-a == bs->v1)) { attached=1; continue;} } - if (!attached){ - float f = tune/(distance) + tune/(compare*compare)*distance - 2.0f*tune/compare ; + if (!attached) { + 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); @@ -2611,7 +2611,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa Vec3PlusStVec(bp->force,f*(1.0f-sb->balldamp),def); Vec3PlusStVec(bp->force,sb->balldamp,dvel); - if (nl_flags & NLF_BUILD){ + if (nl_flags & NLF_BUILD) { //int ia =3*(sb->totpoint-a); //int ic =3*(sb->totpoint-c); //int op =3*sb->totpoint; @@ -2649,7 +2649,7 @@ 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]; @@ -2657,12 +2657,12 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa if (ob->softflag & OB_SB_GOAL) { /* true elastic goal */ sub_v3_v3v3(auxvect,bp->pos,bp->origT); - ks = 1.0f/(1.0f- _final_goal(ob,bp)*sb->goalspring)-1.0f ; + 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]); - if (nl_flags & NLF_BUILD){ + if (nl_flags & NLF_BUILD) { //int ia =3*(sb->totpoint-a); //int op =3*(sb->totpoint); /* depending on my pos */ @@ -2672,14 +2672,14 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa /* calulate damping forces generated by goals*/ sub_v3_v3v3(velgoal,bp->origS, bp->origE); - kd = sb->goalfrict * sb_fric_force_scale(ob) ; + kd = sb->goalfrict * sb_fric_force_scale(ob); 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]); bp->force[1]-= kd * (auxvect[1]); bp->force[2]-= kd * (auxvect[2]); - if (nl_flags & NLF_BUILD){ + if (nl_flags & NLF_BUILD) { //int ia =3*(sb->totpoint-a); normalize_v3(auxvect); /* depending on my vel */ @@ -2729,7 +2729,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa bp->force[1]-= bp->vec[1]*kd; bp->force[2]-= bp->vec[2]*kd; /* friction in media done */ - if (nl_flags & NLF_BUILD){ + if (nl_flags & NLF_BUILD) { //int ia =3*(sb->totpoint-a); /* da/dv = */ @@ -2747,9 +2747,9 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa 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 ((!nl_flags)&&(intrusion < 0.0f)){ - if (G.rt & 0x01){ // 17 we did check for bit 0x10 before + 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 in some situations .. keeping G.rt==17 option for old files 'needing' the bug */ @@ -2778,7 +2778,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa Vec3PlusStVec(bp->force,-cf*50.0f,cfforce); } Vec3PlusStVec(bp->force,kd,defforce); - if (nl_flags & NLF_BUILD){ + 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 @@ -2793,10 +2793,10 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa /* +++springs */ if (ob->softflag & OB_SB_EDGES) { - if (sb->bspring){ /* spring list exists at all ? */ - for (b=bp->nofsprings;b>0;b--){ + if (sb->bspring) { /* spring list exists at all ? */ + for (b=bp->nofsprings;b>0;b--) { bs = sb->bspring + bp->springs[b-1]; - if (do_springcollision || do_aero){ + if (do_springcollision || do_aero) { add_v3_v3(bp->force, bs->ext_force); if (bs->flag & BSF_INTERSECT) bp->choke = bs->cf; @@ -2818,7 +2818,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa /* 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){ + if (nl_flags & NLF_SOLVE) { //double sct,sst=PIL_check_seconds_timer(); for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) { int iv =3*(sb->totpoint-a); @@ -2839,7 +2839,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa success= nlSolveAdvanced(NULL, 1); // nlPrintMatrix(); /* for debug purpose .. anyhow cropping B vector looks like working */ - if (success){ + if (success) { float f; int index =0; /* for debug purpose .. anyhow cropping B vector looks like working */ @@ -2921,7 +2921,7 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float * 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); @@ -2933,12 +2933,12 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float * /* some nasty if's to have heun in here too */ copy_v3_v3(dv,bp->force); - if (mode == 1){ + if (mode == 1) { copy_v3_v3(bp->prevvec, bp->vec); copy_v3_v3(bp->prevdv, dv); } - if (mode ==2){ + if (mode ==2) { /* be optimistic and execute step */ bp->vec[0] = bp->prevvec[0] + 0.5f * (dv[0] + bp->prevdv[0]); bp->vec[1] = bp->prevvec[1] + 0.5f * (dv[1] + bp->prevdv[1]); @@ -2960,7 +2960,7 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float * /* 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{ @@ -2969,12 +2969,12 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float * mul_v3_fl(dx,bp->frozen); */ /* again some nasty if's to have heun in here too */ - if (mode ==1){ + if (mode ==1) { copy_v3_v3(bp->prevpos,bp->pos); copy_v3_v3(bp->prevdx ,dx); } - if (mode ==2){ + 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]); @@ -2986,10 +2986,10 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float * 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){ + if (bp->choke2 > 0.0f) { mul_v3_fl(bp->vec,(1.0f - bp->choke2)); } - if (bp->choke > 0.0f){ + if (bp->choke > 0.0f) { mul_v3_fl(bp->vec,(1.0f - bp->choke)); } @@ -3007,18 +3007,18 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float * } /*for*/ if (sb->totpoint) mul_v3_fl(cm,1.0f/sb->totpoint); - if (sb->scratch){ + if (sb->scratch) { 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 (err) { /* so step size will be controlled by biggest difference in slope */ if (sb->solverflags & SBSO_OLDERR) *err = MAX2(maxerrpos,maxerrvel); else *err = maxerrpos; //printf("EP %f EV %f \n",maxerrpos,maxerrvel); - if (fuzzy){ + if (fuzzy) { *err /= sb->fuzzyness; } } @@ -3125,7 +3125,7 @@ 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){ + 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) int a; float b,l,r; - if (sb && sb->totspring){ + if (sb && sb->totspring) { b = sb->plastic; for (a=0; a<sb->totspring; a++) { bs = &sb->bspring[a]; @@ -3149,7 +3149,7 @@ static void apply_spring_memory(Object *ob) bp2 =&sb->bpoint[bs->v2]; l = len_v3v3(bp1->pos,bp2->pos); r = bs->len/l; - if (( r > 1.05f) || (r < 0.95f)){ + if (( r > 1.05f) || (r < 0.95f)) { bs->len = ((100.0f - b) * bs->len + b*l)/100.0f; } } @@ -3170,7 +3170,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]; @@ -3209,8 +3209,8 @@ static void get_scalar_from_vertexgroup(Object *ob, int vertID, short groupindex } if (dv) { /* Lets see if this vert is in the weight group */ - for (i=0; i<dv->totweight; i++){ - if (dv->dw[i].def_nr == groupindex){ + for (i=0; i<dv->totweight; i++) { + if (dv->dw[i].def_nr == groupindex) { *target= dv->dw[i].weight; /* got it ! */ break; } @@ -3245,7 +3245,7 @@ static void springs_from_mesh(Object *ob) } /* recalculate spring length for meshes here */ /* public version shrink to fit */ - if (sb->springpreload != 0 ){ + if (sb->springpreload != 0 ) { scale = sb->springpreload / 100.0f; } for (a=0; a<sb->totspring; a++) { @@ -3298,7 +3298,7 @@ static void mesh_to_softbody(Scene *scene, Object *ob) else{ /* in consequence if no group was set .. but we want to animate it laters */ /* logically attach to goal with default first */ - if (ob->softflag & OB_SB_GOAL){bp->goal = sb->defgoal;} + if (ob->softflag & OB_SB_GOAL) {bp->goal = sb->defgoal;} } /* to proove the concept @@ -3309,7 +3309,7 @@ static void mesh_to_softbody(Scene *scene, Object *ob) { int grp= defgroup_name_index (ob,sb->namedVG_Mass); /* printf("VGN %s %d \n",sb->namedVG_Mass,grp); */ - if (grp > -1){ + if (grp > -1) { 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); */ @@ -3323,7 +3323,7 @@ static void mesh_to_softbody(Scene *scene, Object *ob) { int grp= defgroup_name_index (ob,sb->namedVG_Spring_K); //printf("VGN %s %d \n",sb->namedVG_Spring_K,grp); - if (grp > -1){ + if (grp > -1) { get_scalar_from_vertexgroup(ob, a,(short) (grp), &bp->springweight); //printf("bp->springweight %f \n",bp->springweight); @@ -3460,7 +3460,7 @@ static void makelatticesprings(Lattice *lt, BodySpring *bs, int dostiff,Object * if (dostiff) { - if (w){ + if (w) { if ( v && u ) { bs->v1 = bpc; bs->v2 = bpc-dw-dv-1; @@ -3477,7 +3477,7 @@ static void makelatticesprings(Lattice *lt, BodySpring *bs, int dostiff,Object * } } - if (w < lt->pntsw -1){ + if (w < lt->pntsw -1) { if ( v && u ) { bs->v1 = bpc; bs->v2 = bpc+dw-dv-1; @@ -3511,11 +3511,11 @@ static void lattice_to_softbody(Scene *scene, Object *ob) totvert= lt->pntsu*lt->pntsv*lt->pntsw; - if (ob->softflag & OB_SB_EDGES){ + if (ob->softflag & OB_SB_EDGES) { totspring = ((lt->pntsu -1) * lt->pntsv + (lt->pntsv -1) * lt->pntsu) * lt->pntsw +lt->pntsu*lt->pntsv*(lt->pntsw -1); - if (ob->softflag & OB_SB_QUADS){ + if (ob->softflag & OB_SB_QUADS) { totspring += 4*(lt->pntsu -1) * (lt->pntsv -1) * (lt->pntsw-1); } } @@ -3528,7 +3528,7 @@ static void lattice_to_softbody(Scene *scene, Object *ob) /* weights from bpoints, same code used as for mesh vertices */ /* if ((ob->softflag & OB_SB_GOAL) && sb->vertgroup) { 2.4x one*/ /* new! take the weights from lattice vertex anyhow */ - if (ob->softflag & OB_SB_GOAL){ + if (ob->softflag & OB_SB_GOAL) { BodyPoint *bp= sb->bpoint; BPoint *bpnt= lt->def; /* jow_go_for2_5 */ @@ -3540,7 +3540,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){ + if (ob->softflag & OB_SB_EDGES) { makelatticesprings(lt,ob->soft->bspring,ob->softflag & OB_SB_QUADS,ob); build_bps_springlist(ob); /* link bps to springs */ } @@ -3561,7 +3561,7 @@ static void curve_surf_to_softbody(Scene *scene, Object *ob) totvert= count_curveverts(&cu->nurb); - if (ob->softflag & OB_SB_EDGES){ + if (ob->softflag & OB_SB_EDGES) { if (ob->type==OB_CURVE) { totspring= totvert - BLI_countlist(&cu->nurb); } @@ -3648,10 +3648,10 @@ static void curve_surf_to_softbody(Scene *scene, Object *ob) static void softbody_to_object(Object *ob, float (*vertexCos)[3], int numVerts, int local) { SoftBody *sb= ob->soft; - if (sb){ + 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); @@ -3924,8 +3924,8 @@ static void softbody_step(Scene *scene, Object *ob, SoftBody *sb, float dtime) ccd_update_deflector_hash(scene, ob, sb->scratch->colliderhash); - if (sb->scratch->needstobuildcollider){ - if (query_external_colliders(scene, ob)){ + if (sb->scratch->needstobuildcollider) { + if (query_external_colliders(scene, ob)) { ccd_build_deflector_hash(scene, ob, sb->scratch->colliderhash); } sb->scratch->needstobuildcollider=0; @@ -3941,7 +3941,7 @@ static void softbody_step(Scene *scene, Object *ob, SoftBody *sb, float dtime) /* loops = counter for emergency brake * we don't want to lock up the system if physics fail */ - int loops =0 ; + int loops = 0; SoftHeunTol = sb->rklimit; /* humm .. this should be calculated from sb parameters and sizes */ /* adjust loop limits */ @@ -3970,7 +3970,7 @@ static void softbody_step(Scene *scene, Object *ob, SoftBody *sb, float dtime) if (err > SoftHeunTol) { /* error needs to be scaled to some quantity */ - if (forcetime > forcetimemin){ + if (forcetime > forcetimemin) { forcetime = MAX2(forcetime / 2.0f,forcetimemin); softbody_restore_prev_step(ob); //printf("down,"); @@ -3982,7 +3982,7 @@ static void softbody_step(Scene *scene, Object *ob, SoftBody *sb, float dtime) else { float newtime = forcetime * 1.1f; /* hope for 1.1 times better conditions in next step */ - if (sb->scratch->flag & SBF_DOFUZZY){ + if (sb->scratch->flag & SBF_DOFUZZY) { //if (err > SoftHeunTol/(2.0f*sb->fuzzyness)) { /* stay with this stepsize unless err really small */ newtime = forcetime; //} @@ -4001,7 +4001,7 @@ static void softbody_step(Scene *scene, Object *ob, SoftBody *sb, float dtime) forcetime = MAX2(dtime - timedone,newtime); } loops++; - if (sb->solverflags & SBSO_MONITOR ){ + if (sb->solverflags & SBSO_MONITOR ) { sct=PIL_check_seconds_timer(); if (sct-sst > 0.5f) printf("%3.0f%% \r",100.0f*timedone/dtime); } @@ -4013,8 +4013,8 @@ static void softbody_step(Scene *scene, Object *ob, SoftBody *sb, float dtime) interpolate_exciter(ob, 2, 2); softbody_apply_goalsnap(ob); - // if (G.f & G_DEBUG){ - if (sb->solverflags & SBSO_MONITOR ){ + // if (G.f & G_DEBUG) { + if (sb->solverflags & SBSO_MONITOR ) { if (loops > HEUNWARNLIMIT) /* monitor high loop counts */ printf("\r needed %d steps/frame",loops); } @@ -4028,7 +4028,7 @@ static void softbody_step(Scene *scene, Object *ob, SoftBody *sb, float dtime) { /* do semi "fake" implicit euler */ }/*SOLVER SELECT*/ - else if (sb->solver_ID == 3){ + else if (sb->solver_ID == 3) { /* do "stupid" semi "fake" implicit euler */ //removed @@ -4036,9 +4036,9 @@ static void softbody_step(Scene *scene, Object *ob, SoftBody *sb, float dtime) else{ printf("softbody no valid solver ID!"); }/*SOLVER SELECT*/ - if (sb->plastic){ apply_spring_memory(ob);} + if (sb->plastic) { apply_spring_memory(ob);} - if (sb->solverflags & SBSO_MONITOR ){ + if (sb->solverflags & SBSO_MONITOR ) { sct=PIL_check_seconds_timer(); if ((sct-sst > 0.5f) || (G.f & 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 c3f6bbff2f2..9f573397837 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -2444,7 +2444,7 @@ static void ccg_loops_to_corners(CustomData *fdata, CustomData *ldata, MLoopUV *mloopuv; int i, j; - for(i=0; i < numTex; i++){ + for(i=0; i < numTex; i++) { texface = CustomData_get_n(fdata, CD_MTFACE, findex, i); texpoly = CustomData_get_n(pdata, CD_MTEXPOLY, polyindex, i); @@ -2456,7 +2456,7 @@ static void ccg_loops_to_corners(CustomData *fdata, CustomData *ldata, } } - for(i=0; i < numCol; i++){ + for(i=0; i < numCol; i++) { mloopcol = CustomData_get_n(ldata, CD_MLOOPCOL, loopstart, i); mcol = CustomData_get_n(fdata, CD_MCOL, findex, i); @@ -2792,20 +2792,6 @@ static ListBase *ccgDM_getPolyMap(Object *ob, DerivedMesh *dm) return ccgdm->pmap; } -static ListBase *ccgDM_getFaceMap(Object *ob, DerivedMesh *dm) -{ - CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm; - - if(!ccgdm->multires.mmd && !ccgdm->fmap && ob->type == OB_MESH) { - Mesh *me= ob->data; - - create_vert_face_map(&ccgdm->fmap, &ccgdm->fmap_mem, me->mface, - me->totvert, me->totface); - } - - return ccgdm->fmap; -} - static int ccgDM_use_grid_pbvh(CCGDerivedMesh *ccgdm) { MultiresModifierData *mmd= ccgdm->multires.mmd; @@ -2973,7 +2959,6 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, ccgdm->dm.getGridAdjacency = ccgDM_getGridAdjacency; ccgdm->dm.getGridOffset = ccgDM_getGridOffset; ccgdm->dm.getPolyMap = ccgDM_getPolyMap; - ccgdm->dm.getFaceMap = ccgDM_getFaceMap; ccgdm->dm.getPBVH = ccgDM_getPBVH; ccgdm->dm.getTessFace = ccgDM_getFinalFace; diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index 373e1e4b9f4..ede2eb7f461 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -173,7 +173,7 @@ void BKE_tracking_clamp_track(MovieTrackingTrack *track, int event) } } } - else if(event==CLAMP_PYRAMID_LEVELS || (event==CLAMP_SEARCH_DIM && track->tracker == TRACKER_KLT)) { + else if(event==CLAMP_PYRAMID_LEVELS || (event==CLAMP_SEARCH_DIM && track->tracker == TRACKER_KLT)) { float dim[2]; sub_v2_v2v2(dim, track->pat_max, track->pat_min); { @@ -626,7 +626,7 @@ void BKE_tracking_clipboard_copy_tracks(MovieTracking *tracking, MovieTrackingOb MovieTrackingTrack *track = tracksbase->first; while (track) { - if (TRACK_SELECTED(track)) { + if (TRACK_SELECTED(track) && (track->flag & TRACK_HIDDEN) == 0) { MovieTrackingTrack *new_track = duplicate_track(track); BLI_addtail(&tracking_clipboard.tracks, new_track); @@ -896,7 +896,7 @@ MovieTrackingContext *BKE_tracking_context_new(MovieClip *clip, MovieClipUser *u /* count */ track= tracksbase->first; while(track) { - if(TRACK_SELECTED(track) && (track->flag&TRACK_LOCKED)==0) { + if(TRACK_SELECTED(track) && (track->flag & (TRACK_LOCKED | TRACK_HIDDEN))==0) { MovieTrackingMarker *marker= BKE_tracking_get_marker(track, user->framenr); if((marker->flag&MARKER_DISABLED)==0) @@ -917,7 +917,7 @@ MovieTrackingContext *BKE_tracking_context_new(MovieClip *clip, MovieClipUser *u /* create tracking data */ track= tracksbase->first; while(track) { - if(TRACK_SELECTED(track) && (track->flag&TRACK_LOCKED)==0) { + if(TRACK_SELECTED(track) && (track->flag & (TRACK_HIDDEN | TRACK_LOCKED))==0) { MovieTrackingMarker *marker= BKE_tracking_get_marker(track, user->framenr); if((marker->flag&MARKER_DISABLED)==0) { @@ -2883,12 +2883,14 @@ void BKE_tracking_select_track(ListBase *tracksbase, MovieTrackingTrack *track, MovieTrackingTrack *cur= tracksbase->first; while(cur) { - if(cur==track) { - BKE_tracking_track_flag(cur, TRACK_AREA_ALL, SELECT, 1); - BKE_tracking_track_flag(cur, area, SELECT, 0); - } - else { - BKE_tracking_track_flag(cur, TRACK_AREA_ALL, SELECT, 1); + if ((cur->flag & TRACK_HIDDEN) == 0) { + if(cur==track) { + BKE_tracking_track_flag(cur, TRACK_AREA_ALL, SELECT, 1); + BKE_tracking_track_flag(cur, area, SELECT, 0); + } + else { + BKE_tracking_track_flag(cur, TRACK_AREA_ALL, SELECT, 1); + } } cur= cur->next; diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index d47ba1274b1..9d68e1d899c 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -1154,12 +1154,13 @@ IDProperty *ffmpeg_property_add(RenderData *rd, const char *type, int opt_index, /* not all versions of ffmpeg include that, so here we go ... */ -static const AVOption *my_av_find_opt(void *v, const char *name, - const char *unit, int mask, int flags){ +static const AVOption *my_av_find_opt(void *v, const char *name, + const char *unit, int mask, int flags) +{ AVClass *c= *(AVClass**)v; const AVOption *o= c->option; - for(;o && o->name; o++){ + for(;o && o->name; o++) { if(!strcmp(o->name, name) && (!unit || (o->unit && !strcmp(o->unit, unit))) && (o->flags & mask) == flags ) |